There is some development of integrating Elmer into Salome going on which for sure we can benefit from.
It looks like that Rainer Jacob already wrote some code to nicely supply/extract all possible solver input setting out of the .edf (xml -files) files which are usually used by ElmerGUI.
I personally use the the official Ubuntu ppa *) thats why I had to search with this results:
There is a relatively old version 7.0 in the experimental branch please see… https://packages.debian.org/experimental/elmer
For just testing the solver it should be OK but you still have to compile the ElmerGUI if you want to use it too.
@HoWil:
I’m gone try to compile ElmerFEM. I do not know anything about the Elmer languarge to define everything. Would it be possible to make an Elmerfile of the FreeCAD 3D FEM Cantilver Example and post it here. It is easier to test a new FEM with an well know example.
Attached you find a .zip file with the complete data regarding a Calculix-Elmer comparison which is discussed subsequently.
If you have a running Elmer and want to recompute the Elmer-project just open it with ‘File->Load Project’, navigate into the folder called ‘mesh_with_BC_from_FC-FEM’ and press ‘Open’.
A short step by step instruction how to rebuild the attached model in FreeCAD, Elmer and Paraview (using 0.17 from ppa and elmer from the official ppa) is given here:
##########################################################################
In FreeCAD:
* Open the standard 3D-FEM example on the start page under 'Example projects' called 'Load an FEM 3D example analysis.
* Select the mesh object called 'Box_Mesh' and delete it. The original Mesh was created with the integrated Netgen-Mesher (and has be recomputed with GMSH).
* Selet the object called 'Cube' and use 'FEM->FEM mesh from shape with GMSH' to generate a new mesh object.
* Select the new mesh object called 'Box_Mesh' and export it via 'File->Export' as 'mesh_with_BC_from_FC-FEM.unv'.
* Execute ElmerGrid in the folder where the exported .unv file is located with 'ElmerGrid 8 2 mesh_with_BC_from_FC-FEM.unv -autoclean'. This transvers the mesh including the boundary conditions stored in the .unv file into several Elmer-mesh files in an identically named folder.
##########################################################################
In ElmerGUI:
* Open the transfered mesh with 'File->Load mesh' by simply navigating into the prior generated folder called as the .unv file. The Mesh is now visible.
* In 'Model->Setup->Simulation->Free_text' insert 'Coordinate scaling = 1'.
* 'Model->Equation->Add' and select in the column 'Linear elasticity' 'Acitve->on' and 'Apply to body-> Body1'. Select 'Edit Solver Settings' for in the current tab and there insert in the 'Solver specific options' in the 'Free text input' the string:'Element=p:2'. Than press 'Apply'.
Select in the 'Result Output' column the 'Active' field.
Select 'Edit Solver Settings' for in the current tab and there insert in the 'Solver specific options' in the select in the 'General' tab under 'Execute solver' the point 'After simulation'.
Press 'Apply' and 'OK'.
* 'Model->Material-Add' and select 'Apply to body-> Body1' and select the 'Material library' -> Select 'Steel (alloy -generic)'. Adopt 'Youngs modulus' to '210.0e9' and 'Poisson ratio' to '0.3'.
* Under 'Model->Boundary condition->Add' in column 'Linear elasticity' set 'Displacement 1' and 'Displacement 2' and 'Displacement 3' to 0. Set 'Name:' to 'BoundaryConditionFixed'. Press 'OK'
* Under 'Model->Boundary condition->Add' in column 'Linear elasticity' set 'Force 2' to 9000000. Set 'Name:' to 'BoundaryConditionForce'. Press 'OK'
* Set 'Model->Set boundary properties' and select left boundary with a double-click. Choose 'BoundaryConditionFixed' from pull down-menu. Click 'Add'.
* Set 'Model->Set boundary properties' and select left boundary with a double-click. Choose 'BoundaryConditionForce' from pull down-menu. Click 'Add'.
* 'File->Save'
* 'File->Save Project'
* 'Sif->Generate'
* 'Run->Start solver'
* After the computation has finished: 'Run->Start paraview'.
##########################################################################
In Paraview:
Select the 'Properties' window press 'Apply' and select in the subgroup for 'Coloring' 'displacement' instead of 'Solid Color'.
The needed Elmer-Solver input file case.sif where all necessary definitions are listed looks like:
Header
CHECK KEYWORDS Warn
Mesh DB "." "."
Include Path ""
Results Directory ""
End
Simulation
Max Output Level = 5
Coordinate System = Cartesian
Coordinate Mapping(3) = 1 2 3
Simulation Type = Steady state
Steady State Max Iterations = 1
Output Intervals = 1
Timestepping Method = BDF
BDF Order = 1
Solver Input File = case.sif
Post File = case.vtu
Coordinate scaling = 0.001
End
Constants
Gravity(4) = 0 -1 0 9.82
Stefan Boltzmann = 5.67e-08
Permittivity of Vacuum = 8.8542e-12
Boltzmann Constant = 1.3807e-23
Unit Charge = 1.602e-19
End
Body 1
Target Bodies(1) = 1
Name = "Body Property 1"
Equation = 1
Material = 1
End
Solver 2
Equation = Linear elasticity
Element=p:2
Variable = -dofs 3 Displacement
Procedure = "StressSolve" "StressSolver"
Exec Solver = Always
Stabilize = True
Bubbles = False
Lumped Mass Matrix = False
Optimize Bandwidth = True
Steady State Convergence Tolerance = 1.0e-5
Nonlinear System Convergence Tolerance = 1.0e-7
Nonlinear System Max Iterations = 20
Nonlinear System Newton After Iterations = 3
Nonlinear System Newton After Tolerance = 1.0e-3
Nonlinear System Relaxation Factor = 1
Linear System Solver = Iterative
Linear System Iterative Method = BiCGStab
Linear System Max Iterations = 500
Linear System Convergence Tolerance = 1.0e-10
BiCGstabl polynomial degree = 2
Linear System Preconditioning = Diagonal
Linear System ILUT Tolerance = 1.0e-3
Linear System Abort Not Converged = False
Linear System Residual Output = 1
Linear System Precondition Recompute = 1
End
Solver 1
Equation = Result Output
Output Format = Vtu
Procedure = "ResultOutputSolve" "ResultOutputSolver"
Output File Name = case
Exec Solver = After Simulation
End
Equation 1
Name = "Equation 1"
Active Solvers(2) = 2 1
End
Material 1
Name = "Steel (alloy - generic)"
Heat expansion Coefficient = 12.0e-6
Electric Conductivity = 1.367e6
Heat Conductivity = 37.2
Sound speed = 5100.0
Heat Capacity = 976.0
Mesh Poisson ratio = 0.285
Density = 7850.0
Poisson ratio = 0.3
Youngs modulus = 210.0e9
End
Boundary Condition 1
Target Boundaries(1) = 1
Name = "BoundaryConditionFixed"
Displacement 3 = 0
Displacement 2 = 0
Displacement 1 = 0
End
Boundary Condition 2
Target Boundaries(1) = 2
Name = "BoundaryConditionForce"
Force 2 = 9000000
End
Note that boundary conditions can also be targeted by names from the .unv when simply accessing them by script and not using ElmerGUI. Comparison Calculix_Elmer.zip (191 KB)
In the case that one wants now to reuse the given mechanical simulation model but wants to switch the boundaries, you would have to do the following steps:
generate a new mesh as .unv with the new faces grouped
translate it with ElmerGrid and copy the Elmer-Mesh-files into the project folder
Check if the defined ‘Target Boundaries’ do still match, see e.g. the prior boundary condition for boundary nr. 2:
Attached the results of CalculiX cantilever analyzed with ElmerFEM. Output format is vtu which is supported by FreeCAD FEM. But FreeCAD only reads the mesh data. A result object is not made.
The result files open fine in Paraview and the displacements could be visualized.
I started to have a look to the issue tonight, there are some new features that I didn’t know yet from the test I made earlier. First why is there an option while importing the results which is asking you through a popup, if we are importing a mesh or results ? Are we sure that selecting result is realling importing results as as you saied this is a mesh, and the import work fine. If it was focused on results it shouldnt import the mesh no ?
No not at all. See dvbranch https://github.com/berndhahnebach/FreeCAD_bhb/commits/femsolverelmer I just added the solver object and the modules needed. At the moment in any case the calculix cantilver is writen as elmer input. The elmer process handling is not implemented. My idea was to start with the result reading because elmer uses output format supported by FreeCAD FEM. I tried *.vtu but may be I should have tried *.vtk
@HoWil:
since you know elmer you could may be give it a try and import some *.vtu or *.vtk in FreeCAD and give some Feedback.
If a frd output file is imported in an empty an analysis, a FEMmesh and a result object is created.
If a frd is read from an analysis run just the result object is created in the active analysis. The mesh from the analysis should fit to the result object.
IMHO it should work the same way with the vtk, vtu etc files, but I have never been imported one before.
I tested my example from over here … http://forum.freecadweb.org/viewtopic.php?f=18&t=16630&start=20#p146553
as well as some other elmer results which all work fine in Paraview 5.0.1. All were imported into FC as .vtu and the example above also as .vtk but I always get only the mesh, no matter if I select results or mesh import!
Is my version of FC sufficiently up-to-date?
OS: Ubuntu 16.04.1 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.9177 (Git)
Build type: Unknown
Branch: femmeshregion
Hash: bba68d007c461ff80b4f72fe82e53b20a8600458
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.0.0
actually it should work, and my implementation supported all kind of result data in the vtk files. Most likely this is a bug or something that got lost during the latest changes. I will try to have a look at this over the next days.
Hallo ickby,
Did you have time to look into this issue?
This is growing interest since almost all new external solver (Elmer, FeniCS, Openfoam) will output some kind of .vtk file or similar.
Thank you in advance,
HoWil
To solve CFD problem, you may reuse some of the code in CfdWorkbench, which is a split from FemWorkbench https://github.com/qingfengxia/Cfd
This workbench is designed to fit in more solvers.
CfdSolverElmer.py derived from CfdSolver which defined most of setting for CFD, include elmer specific settings, example are CfdSolverFoam.py
CfdCaseWriterElmer.py expose only a write_case() method. write_mesh (which should be similar as Bernd has done)and write boundary condition
CfdRunnableElmer.py , then call the calculation and retrieve the result and display, CfdSolverControl can be reused with tiny modification
then add _CommandCfdSolverElmer.py _ViewProviderCfdSolverElmer.py, can be adapted from *Foam.py
add into CfdWorkbench via InitGui.py
CfdResultVTKElmer.py is needed to load result. curently this piece of code (CfdResult and taskpanel) is under review, there is no need to
FluidMaterial.py has several implementation, currently needs a unification.
FemConstraintFluidBoundary.cpp can be reused for common CFD boundary types