Personal tools
You are here: Home Forum Other... (new forum, problems, etc.) Re: MEDCoupling: attach dimensional units to field

Re: MEDCoupling: attach dimensional units to field

Up to Other... (new forum, problems, etc.)

Re: MEDCoupling: attach dimensional units to field

Posted by Roberto Da Vià at January 14. 2022

Dear everybody,

I would like to store the dimensional units (a string) of a field when saving it in a med file and then visualize the units in Paravis, similarly to what can be done with OpenFOAM solutions (see attached figure).

MEDCoupling offers the possibility to store a string as a field description, so I could use it to store the dimensional units.

As it regards the visualization on Paravis, is it already possible (and thus I'm missing how to do that) or would it require to modify the MED file reader plugin?

Thanks in advance,

Roberto Da Vià

Attachments

Re: MEDCoupling: attach dimensional units to field

Posted by Gregor Simic at January 15. 2022

Hello Roberto,

I use the MEDCoupling extensively, though through the python API. To add information about the dimensional units to a quantity, you have to set the "infoOnComponents" when creating a medcoupling DataArray. See the following:



# Let us say that we have a 3D vector numpy array of shape (N_cells, 3)

vector_array = np.ones((N_cells, 3), dtype=np.float64)

# Now we wish to convert it to a medcoupling Data array and attach information on the dimensons

medcoupling_array = medcoupling.DataArrayDouble(vector_array)

# Now to attach information on dimensions

medcoupling_array.setInfoOnComponents(["Dim1", "Dim2", "Dim3"])

# From here on you create a field and store it.

 

Hope this helps,

Gregor

 

Re: MEDCoupling: attach dimensional units to field

Posted by Roberto Da Vià at January 17. 2022

Hello Gregor,

thank you for your answer. I tried the method you suggested and I found two problems:

- the length of the string used as info must be shorter than 16 characters (I'm not looking for long strings, but it could be a problem)

- it works only for multi component fields. If you write the info on a one-component field then Paraview does not show you the component label

I'm trying to change che Paraview MED reader, following what has been done for the OpenFOAM reader, in order to read the field description and append it to the field name. In this way it would work for any field

Roberto

Quick reply
URLs will be automatically hyperlinked. Basic HTML tags are OK.
Powered by Ploneboard
History
Activate by Roberto Da Vià on Jan 14, 2022 12:57 PM
Document Actions