

makeConstraintForce ( doc, "FemConstraintForce" ) force_constraint. addObject ( fixed_constraint ) # force_constraint force_constraint = ObjectsFem. makeConstraintFixed ( doc, "FemConstraintFixed" ) fixed_constraint. addObject ( material_object ) # fixed_constraint fixed_constraint = ObjectsFem. makeMaterialSolid ( doc, "SolidMaterial" ) mat = material_object. addObject ( solver_object ) # material material_object = ObjectsFem. IterationsControlParameterTimeUse = False analysis_object. MatrixSolverType = 'default' solver_object. ThermoMechSteadyState = True solver_object.

GeometricalNonlinearity = 'linear' solver_object. makeSolverCalculixCcxTools ( doc, "CalculiX" ) solver_object. makeAnalysis ( doc, "Analysis" ) # solver (we gone use the well tested CcxTools solver object) solver_object = ObjectsFem. # let us create some objects # import to create objects import ObjectsFem # analysis analysis_object = ObjectsFem. Let's start New document and the part to analyze Run the FEM CalculiX Cantilever 3D analysis to ascertain this. Impotant Note: Due to the continuous development of the FEM Workbench it is recommended to use the latest development snapshot of FreeCAD especially for Python scripted FEM analyses.Use the Help → About FreeCAD to see the version of FreeCAD that is installed.

The compatible version of FreeCAD as designated in the tutorial overview.The model from the FEM CalculiX Cantilever 3D tutorial will be used for this example. This tutorial is meant to show how a simple Finite Element Analysis ( FEA) in FreeCAD's FEM Workbench is done using Python. 2.1 New document and the part to analyze.Since the number of tags can vary from element to element (i.e., line to line), just like the element type and the number of node indices, each line may have a different number of integers.įor both $Nodes and $Elements, any help for reading this data quickly is appreciated. Corresponding to the element type, the last few entries in this row correspond to $Node indices that form the element – in the case of a tetrahedron, the last four entries. Then follows the number of integer tags for this element ( 2 in each case here, namely 1 and 11). In each element line, the first number is the index, then follows an enum for the element type ( 4 is for tetrahedra). The first number ( 2) is the number of elements to follow. Points = numpy.array(line.split(), dtype=float) So far, I haven't come up with anything better than islices in a for loop, which is pretty slow.įor k, line in enumerate(islice(f, num_nodes)): In each node line, the first number is the index (not actually needed by still part of the format, ugh), then follow the three spatial coordinates.

The first number ( 8) is the number of nodes to follow. Unfortunately, its data layout is arguably not the best. One of the most used formats is msh from Gmsh. Those files can grow pretty big, so when reading them with Python it's important to do it efficiently. I maintain a little Python package that converts between different formats used for mesh representation à la
