| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | __title__ = "FreeCAD FEM mesh gmsh document object" |
| | __author__ = "Bernd Hahnebach" |
| | __url__ = "https://www.freecad.org" |
| |
|
| | |
| | |
| | |
| |
|
| | from FreeCAD import Base |
| | from . import base_fempythonobject |
| |
|
| | _PropHelper = base_fempythonobject._PropHelper |
| |
|
| |
|
| | class MeshGmsh(base_fempythonobject.BaseFemPythonObject): |
| | """ |
| | A Fem::FemMeshObject python type, add Gmsh specific properties |
| | """ |
| |
|
| | Type = "Fem::FemMeshGmsh" |
| |
|
| | def __init__(self, obj): |
| | super().__init__(obj) |
| |
|
| | for prop in self._get_properties(): |
| | prop.add_to_object(obj) |
| |
|
| | def _get_properties(self): |
| | prop = [] |
| |
|
| | prop.append( |
| | _PropHelper( |
| | type="App::PropertyLinkList", |
| | name="MeshBoundaryLayerList", |
| | group="Base", |
| | doc="Mesh boundaries need inflation layers", |
| | value=[], |
| | ) |
| | ) |
| | prop.append( |
| | _PropHelper( |
| | type="App::PropertyLinkList", |
| | name="MeshRegionList", |
| | group="Base", |
| | doc="Mesh refinments of the mesh", |
| | value=[], |
| | ) |
| | ) |
| | prop.append( |
| | _PropHelper( |
| | type="App::PropertyLinkList", |
| | name="MeshGroupList", |
| | group="Base", |
| | doc="Mesh groups of the mesh", |
| | value=[], |
| | ) |
| | ) |
| | prop.append( |
| | _PropHelper( |
| | type="App::PropertyLength", |
| | name="CharacteristicLengthMax", |
| | group="Mesh Parameters", |
| | doc="Max mesh element size (0.0 means infinity)", |
| | value=0.0, |
| | ) |
| | ) |
| | prop.append( |
| | _PropHelper( |
| | type="App::PropertyLength", |
| | name="CharacteristicLengthMin", |
| | group="Mesh Parameters", |
| | doc="Min mesh element size", |
| | value=0.0, |
| | ) |
| | ) |
| | prop.append( |
| | _PropHelper( |
| | type="App::PropertyEnumeration", |
| | name="ElementDimension", |
| | group="Mesh Parameters", |
| | doc="Dimension of mesh elements ('From Shape': according ShapeType of part to mesh)", |
| | value=["From Shape", "1D", "2D", "3D"], |
| | ) |
| | ) |
| | prop.append( |
| | _PropHelper( |
| | type="App::PropertyEnumeration", |
| | name="ElementOrder", |
| | group="Mesh Parameters", |
| | doc="Order of mesh elements", |
| | value=["1st", "2nd"], |
| | ) |
| | ) |
| | prop.append( |
| | _PropHelper( |
| | type="App::PropertyBool", |
| | name="OptimizeStd", |
| | group="Mesh Parameters", |
| | doc="Optimize tetrahedral elements", |
| | value=True, |
| | ) |
| | ) |
| | prop.append( |
| | _PropHelper( |
| | type="App::PropertyBool", |
| | name="OptimizeNetgen", |
| | group="Mesh Parameters", |
| | doc="Optimize tetra elements by use of Netgen", |
| | value=False, |
| | ) |
| | ) |
| | prop.append( |
| | _PropHelper( |
| | type="App::PropertyEnumeration", |
| | name="HighOrderOptimize", |
| | group="Mesh Parameters", |
| | doc="Optimization of high order meshes", |
| | value=[ |
| | "None", |
| | "Optimization", |
| | "Elastic+Optimization", |
| | "Elastic", |
| | "Fast curving", |
| | ], |
| | ) |
| | ) |
| | prop.append( |
| | _PropHelper( |
| | type="App::PropertyBool", |
| | name="RecombineAll", |
| | group="Mesh Parameters", |
| | doc="Apply recombination algorithm to all surfaces", |
| | value=False, |
| | ) |
| | ) |
| | prop.append( |
| | _PropHelper( |
| | type="App::PropertyBool", |
| | name="Recombine3DAll", |
| | group="Mesh Parameters", |
| | doc="Apply recombination algorithm to all volumes", |
| | value=False, |
| | ) |
| | ) |
| | prop.append( |
| | _PropHelper( |
| | type="App::PropertyEnumeration", |
| | name="RecombinationAlgorithm", |
| | group="Mesh Parameters", |
| | doc="Recombination algorithm", |
| | value=[ |
| | "Simple", |
| | "Blossom", |
| | "Simple full-quad", |
| | "Blossom full-quad", |
| | ], |
| | ) |
| | ) |
| | prop.append( |
| | _PropHelper( |
| | type="App::PropertyBool", |
| | name="CoherenceMesh", |
| | group="Mesh Parameters", |
| | doc="Removes all duplicate mesh vertices", |
| | value=True, |
| | ) |
| | ) |
| | prop.append( |
| | _PropHelper( |
| | type="App::PropertyFloat", |
| | name="GeometryTolerance", |
| | group="Mesh Parameters", |
| | doc="Geometrical Tolerance (0.0 means GMSH std = 1e-08)", |
| | value=1e-06, |
| | ) |
| | ) |
| | prop.append( |
| | _PropHelper( |
| | type="App::PropertyBool", |
| | name="SecondOrderLinear", |
| | group="Mesh Parameters", |
| | doc="Second order nodes are created by linear interpolation", |
| | value=False, |
| | ) |
| | ) |
| | prop.append( |
| | _PropHelper( |
| | type="App::PropertyIntegerConstraint", |
| | name="MeshSizeFromCurvature", |
| | group="Mesh Parameters", |
| | doc="Number of elements per 2*pi radians, 0 to deactivate", |
| | value=(12, 0, 10000, 1), |
| | ) |
| | ) |
| | prop.append( |
| | _PropHelper( |
| | type="App::PropertyEnumeration", |
| | name="Algorithm2D", |
| | group="Mesh Parameters", |
| | doc="Mesh algorithm 2D", |
| | value=[ |
| | "Automatic", |
| | "MeshAdapt", |
| | "Delaunay", |
| | "Frontal", |
| | "BAMG", |
| | "DelQuad", |
| | "Packing Parallelograms", |
| | "Quasi-structured Quad", |
| | ], |
| | ) |
| | ) |
| | prop.append( |
| | _PropHelper( |
| | type="App::PropertyEnumeration", |
| | name="Algorithm3D", |
| | group="Mesh Parameters", |
| | doc="Mesh algorithm 3D", |
| | value=[ |
| | "Automatic", |
| | "Delaunay", |
| | "New Delaunay", |
| | "Frontal", |
| | "MMG3D", |
| | "R-tree", |
| | "HXT", |
| | ], |
| | ) |
| | ) |
| | prop.append( |
| | _PropHelper( |
| | type="App::PropertyBool", |
| | name="GroupsOfNodes", |
| | group="Mesh Parameters", |
| | doc="For each group create not only the elements but the nodes too", |
| | value=True, |
| | ) |
| | ) |
| | prop.append( |
| | _PropHelper( |
| | type="App::PropertyEnumeration", |
| | name="SubdivisionAlgorithm", |
| | group="Mesh Parameters", |
| | doc="Mesh subdivision algorithm", |
| | value=["None", "All Quadrangles", "All Hexahedra", "Barycentric"], |
| | ) |
| | ) |
| |
|
| | return prop |
| |
|
| | def onDocumentRestored(self, obj): |
| | |
| | for prop in self._get_properties(): |
| | try: |
| | obj.getPropertyByName(prop.name) |
| | except Base.PropertyError: |
| | prop.add_to_object(obj) |
| |
|
| | if prop.name == "Algorithm2D": |
| | |
| | obj.Algorithm2D = prop.value |
| | elif prop.name == "Algorithm3D": |
| | |
| | obj.Algorithm3D = prop.value |
| | elif prop.name == "HighOrderOptimize": |
| | |
| | prop.handle_change_type( |
| | obj, "App::PropertyBool", lambda x: "Optimization" if x else "None" |
| | ) |
| | |
| | if obj.getGroupOfProperty(prop.name) == "FEM Gmsh Mesh Params": |
| | obj.setGroupOfProperty(prop.name, "Mesh Parameters") |
| |
|
| | |
| | try: |
| | value_part = obj.getPropertyByName("Part") |
| | obj.setPropertyStatus("Part", "-LockDynamic") |
| | obj.removeProperty("Part") |
| | |
| | prop = _PropHelper( |
| | type="App::PropertyLinkGlobal", |
| | name="Shape", |
| | group="FEM Mesh", |
| | doc="Geometry object, the mesh is made from. The geometry object has to have a Shape.", |
| | value=value_part, |
| | ) |
| | prop.add_to_object(obj) |
| | except Base.PropertyError: |
| | pass |
| |
|