GMSH mesh export to .unv with renamed BC/constraints

About the development of the FEM module/workbench.

Moderator: bernd

HoWil
Veteran
Posts: 1279
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

GMSH mesh export to .unv with renamed BC/constraints

Post by HoWil »

Hello,

I did create a mesh in FC and exported it as .unv files for later use with ElmerGrid/Elmer.
This created GMSH mesh did incorporate a FC constraint on a face. This constraint was after creation originally labeled 'FemConstraintFixed' and was renamed by me.
Unfortunately did this renaming not affect the names of the faces when exporting the created mesh as .unv. In the created file is only the original name 'FemConstraintFixed' or enumerated variations like 'FemConstraintFixed001' stored.

Is there any possibility to save the renamed label otherwise it is a bit confusing when working further on with all faces labeled similar to 'FemConstraintFixed' 8-) .

Thx in advance,
HoWil
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: GMSH mesh export to .unv with renamed BC/constraints

Post by bernd »

Every object in FreeCAD has a name and a label. If you change the string of an object in TreeView you change the label. Check PropertyEditor, the label has changed. This could be best seen in the selection view. Relabel an object and select it. In slection view first is the document name, than a dot, than the object name, afterwards in brackets the label is shown. The name of an object in FreeCAD is unique, no spaces and special character are allowed. This makes it much more suitable for robust development than the label. The label is not unique, allows spaces and special characters. If the label should be used in development lots of control code is needed. In FEM no one has implemented this so far. Thus in FEM the names are used. You can not rename an object. You have two possibilities:

- use python to create your object. With this you can give the name at creation time.

Code: Select all

# for an object developed in C++
App.ActiveDocument.addObject("Fem::ConstraintFixed","MySpecialNameForAConxtraint")

# for a Python developed object
import FemShellThickness
FemShellThickness.makeFemShellThickness(20,'MyOwnThickness')
- or change the FEM code to use the object.Label instead of the object.Name for group names in the FEMMesh. It should work if you are careful with labeling your objects, but you could run into trouble with this anyway. Just try.
https://github.com/FreeCAD/FreeCAD/blob ... s.py#L1011 and https://github.com/FreeCAD/FreeCAD/blob ... s.py#L1077

hope this helps bernd
HoWil
Veteran
Posts: 1279
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: GMSH mesh export to .unv with renamed BC/constraints

Post by HoWil »

Hello Bernd,
Thank you for your repy and the example code.

Dont you think that there is an option in the OCC .unv export that enables the export of a body with an additional 'name' which can be different form the name of the body. What I want to say is that we maybe do not have to change the name of the FC-objects (what seems to be complicated) but instead hand the label of the body/object over to the exporter. Since it is possilbe in Salome which is also OCC it should also be possible from (maybe deep-within) FC.

I tried to find a appropriate definition at https://www.opencascade.com/doc/occt-7. ... files.html but without luck.

BR
Howil
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: GMSH mesh export to .unv with renamed BC/constraints

Post by bernd »

HoWil wrote: Dont you think that there is an option in the OCC .unv export that enables the export of a body with an additional 'name' which can be different form the name of the body. What I want to say is that we maybe do not have to change the name of the FC-objects (what seems to be complicated) but instead hand the label of the body/object over to the exporter. Since it is possilbe in Salome which is also OCC it should also be possible from (maybe deep-within) FC.

I tried to find a appropriate definition at https://www.opencascade.com/doc/occt-7. ... files.html but without luck.
Is it in Salomone possible to export an unv which has two names for a group, a robust name to work with and a label for this name similar to FreeCAD?

BTW: the unv export has not much to do with OCCT. The code to export unv is nearly exact the same code Salomone uses to export unv. The whole data model behind FreeCADs FEM is done with SMESH which is the same library Salomone uses. Means FreeCAD could do all the crazy mesh stuff Salomone does. It just needs someone who implements it. See https://github.com/FreeCAD/FreeCAD/tree ... alomesmesh
ulrich1a
Veteran
Posts: 1957
Joined: Sun Jul 07, 2013 12:08 pm

Re: GMSH mesh export to .unv with renamed BC/constraints

Post by ulrich1a »

bernd wrote: Thus in FEM the names are used. You can not rename an object.
Another approach could be to give a name at creation time of the constraint. Thus the task-dialog has to be extended with a name input field.
How difficult is this?

Ulrich
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: GMSH mesh export to .unv with renamed BC/constraints

Post by bernd »

ulrich1a wrote:
bernd wrote: Thus in FEM the names are used. You can not rename an object.
Another approach could be to give a name at creation time of the constraint. Thus the task-dialog has to be extended with a name input field.
How difficult is this?

Ulrich
Or an extra popup before the task dialog. an preference chooses if the popup is shown for every new constraint.
HoWil
Veteran
Posts: 1279
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: GMSH mesh export to .unv with renamed BC/constraints

Post by HoWil »

bernd wrote:The code to export unv is nearly exact the same code Salomone uses to export unv.
... hence I built a Salome example and used the 'dump script' function to export the python script recorded in parallel to the GUI interactions (similar to the macro record in FC).
This is what I learned:
* usually Salome exports the mesh without 'names'
* named groups appear in the .unv file after creating groups of node, edges, faces of domains in the mesh-module. Please search with a text editor for 'Group_Face_5_and_Face_6_1' in the attached .py script and for 'Group_Face_5_and_Face_6' in the .unv file.
* in Salome the command 'GroupOnGeom' is used to create such groups in mesh from a geometry-group (in the attached example of type SMESH.FACE)

Code: Select all

Group_Face_5_and_Face_6_1 = Mesh_1.GroupOnGeom(Group_Face_5_and_Face_6,'Group_Face_5_and_Face_6',SMESH.FACE)
EDIT: See also: http://docs.salome-platform.org/5/smesh ... f58606790e

@bernd: does this command and the one in the .py file look familiar to you? Can you use this in FC inserting the face from the constraint for the given group?
Mesh_1.unv.txt
From Salome exported .unv file containing named groups (renamed to .txt for uploading).
(120.74 KiB) Downloaded 73 times
python_dump_create_mesh_groupe_from_geometry_mod.py
dumped salome script for creating the attached .unv
(3.71 KiB) Downloaded 71 times
If you want to use the attached .py script in Salome adopt the filenames accordingly, start Salome and use 'File->Load Script', 'File->Connect'.
Attachments
The model looks like this. In the model tree one can see the group of faces in the geometry section and the according group or faces in the mesh visible.
The model looks like this. In the model tree one can see the group of faces in the geometry section and the according group or faces in the mesh visible.
Screenshot from 2016-12-02 19-49-31.png (161.76 KiB) Viewed 3932 times
Last edited by HoWil on Fri Dec 02, 2016 7:46 pm, edited 1 time in total.
HoWil
Veteran
Posts: 1279
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: GMSH mesh export to .unv with renamed BC/constraints

Post by HoWil »

That means the unv export should be extended by the something similar to:

Mesh_smesh_object_in_FC.GroupOnGeom(Group_of_faces_of_a_constraint_FC, 'Label_of_the_constraint_which_can_be_changed', SMESH.FACE)
HoWil
Veteran
Posts: 1279
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: GMSH mesh export to .unv with renamed BC/constraints

Post by HoWil »

Hi everyone,
Sorry for bringing this up again... but this would make FC-mesh export for Elemer and others much easier to use et least by a factor of 10 (at least... :D ).
Is there a smesh expert who could look at this?? Should I place this request somewhere else?
BR,
HoWil
ulrich1a
Veteran
Posts: 1957
Joined: Sun Jul 07, 2013 12:08 pm

Re: GMSH mesh export to .unv with renamed BC/constraints

Post by ulrich1a »

It is not that difficult to code something in order to define faces from a given set of nodes connected to some elements in the mesh. I have done something similar already. Those algorithm are now part of the FEM-workbench. The problem is, Bern and I are only python coders. I would expect, that the export-function for UNV-meshes is written in C++ or a call to a smesh-function. This makes it hard for us, to get into this. But I did not searched in the code for the export function.

It may be a topic of greater interest, as actually FreeCAD only exports volumes or faces or edges but not a combination of them. This seems to be restricted somewhere in the code and limits the usability of the FEM-workbench also at other places. It think, this was introduced, to avoid exporting of the surface of a solid in a mesh. This surface is created by the meshers, but is not needed for Calculix.

Ulrich

Edit: It seems I got the question totally wrong. The naming of the constraints is something that needs just time for proper coding. As a workaround, I would say, you may use just different types of constraints, in order to memorize them easier.
Post Reply