The creation of multidomain-meshes did dramatically evolve enabling supportive/external FEM-studies for instance in Elmer (as a workaround until it is integrated).
I want simply put the things together that are on the table:
* I generate my geometry in FC and export the mesh as .unv
* ElmerGrid has to be run to transfer the mesh for ElmerSolver to run this mesh together with an externally created solver-input file to compute results
* these results can be evaluated in Paraview give some result value which should be collected.
To cut a long story short, I want to run external scripts like ElmerGrid, ElmerSolver and Paraview from inside FC. I thought about using a macro/py-script or a input field where a external (bash) script can be specified.
Die anyone use something similar? Is there a better way to achieve this?
BR,
HoWil
Run external scripts from FC - a workaround
Moderator: bernd
Forum rules
and Helpful information for the FEM forum
and Helpful information for the FEM forum
Re: Run external scripts from FC - a workaround
It is not hard to achieve, python has a lot of tools to run external scripts/programs, and even collect their answer. Have a look at python's subprocess module, it's basically what you'll need.
Re: Run external scripts from FC - a workaround
Thanks Ulrich, This is exactly what I was looking for to begin with.ulrich1a wrote:Here is an example: viewtopic.php?f=18&t=10789&start=20#p113297
Ulrich
EDIT:
first steps are stony...
Code: Select all
selection = FreeCADGui.Selection.getSelection()
Code: Select all
selection = FreeCADGui.Selection.getSelectionEx()
Re: Run external scripts from FC - a workaround
Both function did exist before. The one gets selected objects from the tree, the other from the 3D-view.
Yes the first steps are not fast. I also need time to explore for me unknow functionality. The documentation needs more love.
Ulrich
Yes the first steps are not fast. I also need time to explore for me unknow functionality. The documentation needs more love.
Ulrich
Re: Run external scripts from FC - a workaround
more examples:
See FreeCAD FEMs GMSH module class: https://github.com/berndhahnebach/FreeC ... ls.py#L369
or the old GMSH macro the GMSH module class is based on:
Macro_GMSH and https://github.com/psicofil/Macros_Free ... Macro#L208
The CalculiX run uses subprocess too.
see https://github.com/berndhahnebach/FreeC ... cx.py#L196
See FreeCAD FEMs GMSH module class: https://github.com/berndhahnebach/FreeC ... ls.py#L369
or the old GMSH macro the GMSH module class is based on:
Macro_GMSH and https://github.com/psicofil/Macros_Free ... Macro#L208
The CalculiX run uses subprocess too.
see https://github.com/berndhahnebach/FreeC ... cx.py#L196
Re: Run external scripts from FC - a workaround
Thanks Ulrich and Bernd.
I have a preliminary working version .
I started with Ulrich's example viewtopic.php?f=18&t=10789&start=20#p113297 and created a first script which takes a Gmesh-Mesh as input, exports it as .unv and runs ElmerGrid, ElmerSolver and Paraview (optional).
For ElmerSolver is a .sif file and for Paraview a .vtk file via two separate dialogs requested.
EDIT:
The .sif file has to be created separately and uses in the attached example the labels from within FC.
The first rough version looks like: The example according to the 3D-calculix-beam with gmsh-mesh is attached with rough mesh : The script was created for/tested with (The new mesh-type 'Fem::FemMeshObjectPython' is needed):
OS: Ubuntu 16.04.1 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.9481 (Git)
Build type: Unknown
Branch: femdev
Hash: c6ca36b29f19815e78bc2d4b4b02e86679d4fbc6
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.0.0
I have a preliminary working version .
I started with Ulrich's example viewtopic.php?f=18&t=10789&start=20#p113297 and created a first script which takes a Gmesh-Mesh as input, exports it as .unv and runs ElmerGrid, ElmerSolver and Paraview (optional).
For ElmerSolver is a .sif file and for Paraview a .vtk file via two separate dialogs requested.
EDIT:
The .sif file has to be created separately and uses in the attached example the labels from within FC.
The first rough version looks like: The example according to the 3D-calculix-beam with gmsh-mesh is attached with rough mesh : The script was created for/tested with (The new mesh-type 'Fem::FemMeshObjectPython' is needed):
OS: Ubuntu 16.04.1 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.9481 (Git)
Build type: Unknown
Branch: femdev
Hash: c6ca36b29f19815e78bc2d4b4b02e86679d4fbc6
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.0.0