How can I add properties in 1D .Vtu file?

Hello everyone,

I am very beginner of OGS modelling. I was trying to learn the Decay-chain problem. I went through it understood everything but the only thing I couldn’t solve is creating a .vtu file by adding properties. I prepared one but it has no properties but I downloaded one there is 3 properties. Please help me to solve the problem.

Thanks in advance.

Hi!
This depends a bit on your workflow and the properties you need.
If you need property fields for MaterialIDs and boundaries, and you created your mesh with gmsh, you can use physical entities and create the vtu file via the msh2vtu python script which is part of ogstools.
If you have a bulk and boundary meshes already as VTU format you can use the identifySubdomains util in the ogs binary directory to create bulk_element_ids and bulk_node_ids property arrays that are needed for ogs to identify boundary and source term meshes. Paraview has also some filters that can be used to create/change arrays.
If you save your vtu files as ascii data you can also do it “by hand” as they are basically xml files. You can use Paraview](https://www.paraview.org/) or VTUinterface to change the data mode.
Other tools you could use for python are VTUinterface or meshio. Keep in mind that some OGS specific arrays like MaterialIds or bulk_elem_ids need a specific data type like UInt32 which you might need to set separately.

1 Like

Thank you so much for your help Sir. It really helped me a lot.

Hello Sir,
I hope you are doing well. I have an additional question. I created the .vtu file and created bulk_element_ids and bulk_node_id for 1D problem.
The problem is, I cannot create “materialId” in the .vtu file and also I couldn’t extract points for preparing .vtu file for boundary condition. I searched for tutorial but unfortunately I couldn’t get any.
Please help me.
Thanks in advance.

Hi!
You need to create bulk_node_ids and bulk_elem_ids after you have a boundary mesh.
They are important to identify points from the boundary mesh in the bulk mesh.
If you have a real 1D mesh (i.e. it consists of lines as elements) then creating boundary meshes in paraview is very simple. You just select a point (via the interactive point selection in the viewer, or the spreadsheat representation) and use the extract selection filter, after that, you can save the selection as a vtu file. In 2D and 3D you can use the extract boundary tool in our binary directory: Extract Boundary
To create MaterialIDs you can use VTUInterface (the latest version! 0.704, as older versions don’t support setting types) in python, for example:

import vtk # needed to set the array type
import vtuIO

f = vtuIO.VTUIO("bulk_mesh.vtu")
f.delete_cell_field("MaterialIDs") # If an old MaterialIds array is already present, delete it

# define material ids with the desired mapping
def mat_ids(x,y,z):
      if x<0.5:
          return 0
      else:
          return 1

f.func_to_field(mat_ids, "MaterialIDs","new_bulk_mesh.vtu", cell=True, array_type=vtk.VTK_INT, writefile=True) # it is important that the MaterialIDs array is a cell array of size INT32 (vtk.VTK_INT)
1 Like