Extend FEM Module/es

El banco de trabajo FEM ya es compatible con muchas restricciones diferentes y un puñado de solucionadores. A pesar de que las personas a menudo necesitan restricciones no son compatibles con los chorros de FreeCAD. Esta página es el punto de partida para una serie de tutoriales y otros recursos que describen cómo extender el entorno de trabajo FEM utilizando el marco existente. Si bien esta serie también puede ser útil para los desarrolladores de software, la idea es permitir que los usuarios de FEM con un poco de interferencia en la codificación Python agreguen las cosas que necesitan ellos mismos.

Agregar nuevas restricciones, ecuaciones o solucionadores es principalmente un trabajo de rutina. Pero hacerlo por primera vez no será tan fácil como podría parecer. Una comprensión de los siguientes temas será útil:


 * Python scripting in FreeCAD.
 * FreeCAD Scripting Tutorial
 * FreeCAD Scripting Basics
 * Extending FreeCAD with Python.
 * Scripted Objects
 * A solid understanding of the solver for which new objects shall be added (e.g. CalculiX or Elmer) is important.
 * A little knowledge about build systems, especially cmake (build system used by FreeCAD).

Build System (cmake)
The build system must be modified regardless of which objects shall be added o the FEM workbench. Every python module (file) must be registered. The FEM workbench requires every new python module to be registered in. This is true regardless of the type of the python module (GUI or non-GUI). Where exactly the module must be inserted depends on the role of the module. Solver, equations and constraints all use different lists. Searching for similar files and inserting the new file in the same list works most of the time.

As an example lets add a new constraint called which is related to the flow equation. So, FlowPressure will widely used as for this constraint. A new constraint requires at least the following new modules: These three files must be added to as well as. All inserted lines of code are indicated by a starting +.
 * (may be unnecessary)
 * (may be unnecessary)
 * (may be unnecessary)

Source Organization
For organizing the python code the FEM module uses the following approach. The module is split into the following packages:
 * , which contains all non-GUI like python proxies for document objects and
 * containing everything GUI related like python proxies for view provider
 * C++ based task panels are stored in '',
 * icons can be found in '',
 * .ui files are stored in '' commands.

One package doesn't follow this pattern:. It has its place on the same level as and. The package contains solver and equation related packages and modules and it is organized the following way:

.femsolver .femsolver.elmer .femsolver.elmer.equations .femsolver.calculix .femsolver.calculix.equations .femsolver.z88 .femsolver.z88.equations

Solver
In FreeCAD a solver can be split into two parts:
 * One is the document object used by the user to interact with the solver. Though it solver parameter can be set and it is also used to control the solving process.
 * The other one are the so called tasks of a solver. The solving process is split into those tasks, namely: check, prepare, solve and results. Those do the actual work of exporting the analysis into a format understood by the solver executable, starting the executable and loading the results back into FreeCAD.

Most files related to a solver reside in a sub-package of the package (e.g. for Elmer its in ). The following list enumerates all files related to the implementation of a solver. Those are the files that need to be copied and modified to add support for a new solver to FreeCAD. The given example is taken from the solver implementation of Elmer.


 * femsolver/elmer/solver.py: Document object visible in the tree-view. Implemented in python via a document proxy and view proxy.
 * femsolver/elmer/tasks.py: Module containing one task class per task required for a solver implementation. Those tasks divide the process of solving a analysis into the following steps: check, prepare, solve, results.
 * femcommands/commands.py: Adds the solver document object to the active document. Required to access the solver object from the GUI.

There is a tutorial of adding a new solver: Add FEM solver tutorial

Equations
An equation represents a particular physics that shall be considered when solving the analysis (e.g. Flow, Heat). Not all solver in FreeCAD support (all) equations. Equations are represented by child objects of the corresponding solver object. In the tree-view this looks like this:


 * elmer-solver
 * elasticity
 * heat
 * flow
 * electrostatics

Most solver specific options (e.g. max. iterations, method of solving, etc) are set via the equation objects. One consequence of this is that each solver must have it's own implementation of &quot;the same&quot; equation. CalculiX would have a different Heat-object that Elmer. To avoid having multiple buttons for the same physics in the GUI each solver object adds it's equations itself.

The actual implementation can be split into the generic and the solver specific part. The generic part can be found in the module. The solver specific part resides inside individual Equations sub-packages of the solver packages (e.g. ).

Adding a new equations to Elmer should be very easy. For newcomers there exists a tutorial which shows how to add a new equation to Elmer by adding the existing elasticity solver to FreeCAD: Add FEM Equation Tutorial.

Restricciones
Las restricciones definen condiciones de contorno para el problema que se resolverá. En FreeCAD, las restricciones no son específicas de un solucionador en particular. Un solucionador de problemas puede ser resuelto por todos los solucionadores que soportan todas las condiciones en el análisis.

Agregar nuevas restricciones es bastante sencillo. Para los recién llegados hay un tutorial:Add FEM Constraint Tutorial.