Multiple materials and Mesh

About the development of the FEM module/workbench.

Moderator: bernd

Post Reply
User avatar
lidiriel
Posts: 37
Joined: Sat Dec 21, 2019 9:30 pm
Location: France

Multiple materials and Mesh

Post by lidiriel »

Hi FEM users,

i try a simple example with two cylinders (see attachment freecad_cylinder screenshot)
center cylinder is in copper with potential of 1V and external cylinder is in glass. The external surface is at the potential of 0V.

Inspired by https://github.com/FreeCAD/FreeCAD/tree ... mexamples/ I have created :
  • booleanfragments (compSolid mode) with a compound filter (window-volume filter).
  • solid material copper associate to the internal cylinder
  • solid material glass to the external cylinder


but when i run elmer solver i have the error : ERROR:: ReadTargetNames: Mapping of name is not unique: solid2

if anybody have an idea of the problem ?

here the elmer log :

Code: Select all

Executing solver...
ELMER SOLVER (v 9.0) STARTED AT: 2023/05/16 16:31:08

ParCommInit:  Initialize #PEs:            1
MAIN: OMP_NUM_THREADS not set. Using only 1 thread per task.
MAIN:
MAIN: =============================================================
MAIN: ElmerSolver finite element software, Welcome!
MAIN: This program is free software licensed under (L)GPL
MAIN: Copyright 1st April 1995 - , CSC - IT Center for Science Ltd.
MAIN: Webpage http://www.csc.fi/elmer, Email elmeradm@csc.fi
MAIN: Version: 9.0 (Rev: 40e221719, Compiled: 2023-05-05)
MAIN:  Running one task without MPI parallelization.
MAIN:  Running with just one thread per task.
MAIN:  MUMPS library linked in.
MAIN:  Lua interpreter linked in.
MAIN: =============================================================
MAIN:
MAIN:
MAIN: -------------------------------------
MAIN: Reading Model: case.sif
LoadInputFile: Scanning input file: case.sif
LoadInputFile: Scanning only size info
LoadInputFile: First time visiting
LoadInputFile: Reading base load of sif file
LoadInputFile: Loading input file: case.sif
LoadInputFile: Reading base load of sif file
CheckKeyword:  Unlisted keyword: [potential constant] in section: [boundary condition 1]
LoadInputFile: Number of BCs: 2
LoadInputFile: Number of Body Forces: 0
LoadInputFile: Number of Initial Conditions: 0
LoadInputFile: Number of Materials: 1
LoadInputFile: Number of Equations: 2
LoadInputFile: Number of Solvers: 2
LoadInputFile: Number of Bodies: 2
ListTagKeywords: Setting weight for keywords!
ListTagKeywords: No parameters width suffix: normalize by area
ListTagKeywords: Setting weight for keywords!
ListTagKeywords: No parameters width suffix: normalize by volume
Loading user function library: [StatElecSolve]...[StatElecSolver_Init0]
Loading user function library: [ResultOutputSolve]...[ResultOutputSolver_Init0]
LoadMesh: Loading serial mesh!
ElmerAsciiMesh: Performing step: 1
ElmerAsciiMesh: Base mesh name: .
ReadHeaderFile: Reading header info from file: ./mesh.header
InitializeMesh: Number of nodes in mesh: 24342
InitializeMesh: Number of bulk elements in mesh: 15948
InitializeMesh: Number of boundary elements in mesh: 4268
InitializeMesh: Initial number of max element nodes: 10
ElmerAsciiMesh: Performing step: 2
ReadNodesFile: Reading nodes from file: ./mesh.nodes
MapCoordinates: Performing coordinate mapping
SetMeshDimension: Dimension of mesh is: 3
SetMeshDimension: Max dimension of mesh is: 3
MapCoordinates: Scaling coordinates: 1.000E-03 1.000E-03 1.000E-03
ElmerAsciiMesh: Performing step: 3
ReadElementsFile: Reading bulk elements from file: ./mesh.elements
ElmerAsciiMesh: Performing step: 4
ReadBoundaryFile: Reading boundary elements from file: ./mesh.boundary
PermuteNodeNumbering: Performing node mapping
ReadTargetNames: Reading names info from file: ./mesh.names
ERROR:: ReadTargetNames: Mapping of name is not unique: solid2
No result file was created.

my case.sif :

Code: Select all

Check Keywords "Warn"

Header
  Mesh DB "."
End

Solver 1
  Calculate Electric Energy = Logical True
  Calculate Electric Field = Logical True
  Equation = String "Stat Elec Solver"
  Exec Solver = String "Always"
  Linear System Abort Not Converged = Logical False
  Linear System Convergence Tolerance = Real 1e-10
  Linear System Iterative Method = String "BiCGStab"
  Linear System Max Iterations = Integer 500
  Linear System Precondition Recompute = Integer 1
  Linear System Preconditioning = String "ILU0"
  Linear System Residual Output = Integer 1
  Linear System Solver = String "Iterative"
  Optimize Bandwidth = Logical True
  Procedure = File "StatElecSolve" "StatElecSolver"
  Stabilize = Logical True
  Steady State Convergence Tolerance = Real 1e-05
  Variable = String "Potential"
  Variable DOFs = Integer 1
End

Simulation 
  Coordinate Mapping(3) = Integer 1 2 3
  Coordinate Scaling = Real 0.001
  Coordinate System = String "Cartesian 3D"
  Output Intervals = Integer 1
  Simulation Type = String "Steady State"
  Steady State Max Iterations = Integer 1
  Steady State Min Iterations = Integer 0
  Use Mesh Names = Logical True
End

Constants 
  Permittivity Of Vacuum = Real 8.854189999999999e-12
End

Body 1
  Equation = Integer 1
  Material = Integer 1
  Name = String "Solid1"
End

Material 1
  Relative Permittivity = Real 5.0
End

Equation 1
  Active Solvers(2) = Integer 1 2
End

Solver 2
  Coordinate Scaling Revert = Logical True
  Equation = String "ResultOutput"
  Exec Solver = String "After simulation"
  Output File Name = File "case"
  Procedure = File "ResultOutputSolve" "ResultOutputSolver"
  Vtu Format = Logical True
End

Body 2
  Equation = Integer 2
  Name = String "Solid2"
End

Equation 2
  Active Solvers(2) = Integer 1 2
End

Boundary Condition 1
  Name = String "Solid2"
  Potential = Real 1.0
  Potential Constant = Logical True
End

Boundary Condition 2
  Name = String "Face1"
  Potential = Real 0.0
End


mesh.names

Code: Select all

! ----- names for bodies -----
$ Solid1 = 3
$ Solid2 = 4
! ----- names for boundaries -----
$ Face1 = 2
$ bnry5 = 5
$ bnry6 = 6
entities.sif

Code: Select all

!------ Skeleton for body section -----
Body 1
  Name = Solid1
End

Body 2
  Name = Solid2
End

!------ Skeleton for boundary section -----
Boundary Condition 1
  Name = Face1
End

Boundary Condition 2
  Name = bnry5
End

Boundary Condition 3
  Name = bnry6
End

My configuration is :

Code: Select all

OS: Debian GNU/Linux 11 (bullseye) (X-Cinnamon/lightdm-xsession)
Word size of FreeCAD: 64-bit
Version: 0.20.2.29603 (Git) AppImage
Build type: Release
Branch: (HEAD detached at 0.20.2)
Hash: 930dd9a76203a3260b1e6256c70c1c3cad8c5cb8
Python 3.10.8, Qt 5.15.4, Coin 4.0.0, Vtk 9.1.0, OCC 7.6.3
Locale: French/France (fr_FR)
Installed mods: 
  * fasteners 0.4.52
  * ThreadProfile 1.84.0
ELMER SOLVER (v 9.0)
Attachments
freecad_cylinder.png
freecad_cylinder.png (93.37 KiB) Viewed 1452 times
RichB2k
Posts: 9
Joined: Thu Sep 08, 2022 8:50 pm

Re: Multiple materials and Mesh

Post by RichB2k »

Hello,

Take a look at this Elmer forum post, it may help.

http://www.elmerfem.org/forum/viewtopic.php?t=7968

Thanks, Rich.
User avatar
lidiriel
Posts: 37
Joined: Sat Dec 21, 2019 9:30 pm
Location: France

Re: Multiple materials and Mesh

Post by lidiriel »

Hello,
i have read this thread :
RichB2k wrote: Tue May 16, 2023 4:58 pm Take a look at this Elmer forum post, it may help.
http://www.elmerfem.org/forum/viewtopic.php?t=7968
but i have no idea to resolv my problem.
in the file shape2mesh.geo

Code: Select all

// save
Mesh.Format = 2;
// Ignore Physical definitions and save all elements;
Mesh.SaveAll = 1;
Save "/home/ludovic/Elmer/test/cylinder2/FEMMeshGmsh/CompoundFilter_Mesh.unv";
the option SaveAll is set to 1. But i don't know how i can change this option to test.
RichB2k
Posts: 9
Joined: Thu Sep 08, 2022 8:50 pm

Re: Multiple materials and Mesh

Post by RichB2k »

Hello,

Looks like the automated build process that calls gmsh isn't working well for you.

In this post:

viewtopic.php?t=77149&sid=91a6d7a8655c6 ... 2c13844766
To test the new features, I created a Windows build:
https://github.com/FreeCAD/FreeCAD-Bund ... taller.exe
for Linux and MacOS, wait for the next weekly build:
https://github.com/FreeCAD/FreeCAD-Bund ... kly-builds
(must have revision number 32552 or higher)
Where in your first post, this is the version number:
Word size of FreeCAD: 64-bit
Version: 0.20.2.29603 (Git) AppImage
If you update your version of FreeCAD, does it help?

Also, if you could post your FreeCAD example file, that would help.

Thanks, Rich.
User avatar
lidiriel
Posts: 37
Joined: Sat Dec 21, 2019 9:30 pm
Location: France

Re: Multiple materials and Mesh

Post by lidiriel »

I use
  • freecad 0.20.2 git revision 29603
  • gmsh 4.11.1
  • elmer local compilation from devel branch (commit 40e2217199a2fb69a48cb3c04a1ad841ea784579)
i will try to upgrade freecad.

here you can download the test file cylinder2.FCStd and generated files by gmsh and Elmer : https://filesender.renater.fr/?s=downlo ... 33519076a2

regards
User avatar
lidiriel
Posts: 37
Joined: Sat Dec 21, 2019 9:30 pm
Location: France

Re: Multiple materials and Mesh

Post by lidiriel »

with the last freecad version :

Code: Select all

OS: Debian GNU/Linux 11 (bullseye) (X-Cinnamon/lightdm-xsession)
Word size of FreeCAD: 64-bit
Version: 0.21.0.33263 (Git) AppImage
Build type: Release
Branch: master
Hash: 864f99bf984c237ef38d9451fd6f3a5ec34e6eb4
i can't load the FEM workbench

Code: Select all

11:10:30  /tmp/.mount_FreeCABa46ej/usr/lib/././libnglib4smesh.so: undefined symbol: _ZNK17XCAFDoc_ColorTool8GetColorERK9TDF_LabelR14Quantity_Color
11:10:30  Traceback (most recent call last):
  File "<string>", line 71, in Initialize
  File "/tmp/.mount_FreeCABa46ej/usr/lib/python3.11/site-packages/shiboken2/files.dir/shibokensupport/feature.py", line 139, in _import
    return original_import(name, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
           
It is linked to the issue : https://github.com/FreeCAD/FreeCAD-Bundle/issues/173
RichB2k
Posts: 9
Joined: Thu Sep 08, 2022 8:50 pm

Re: Multiple materials and Mesh

Post by RichB2k »

Hello,

Loading and running your file cylinder2.FCStd, I get the same error message from elmersolver.

Code: Select all

OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.21.0.32552 (Git)
Build type: Release
Branch: master
Hash: e2b3a5d2f791fb78a61daac9bdab374058f682f2
Python 3.8.10, Qt 5.15.2, Coin 4.0.1, Vtk 8.2.0, OCC 7.6.3
Locale: English/United States (en_US)
The release date is listed as 2023/03/26

The errors seem to be related to naming of bodies and surfaces. I don't know enough about FreeCAD to be helpful, but at least you can stay with your old version and maybe figure out a different approach to naming the parts.

Rich.
AlbertoR
Posts: 8
Joined: Mon May 29, 2023 7:50 am

Re: Multiple materials and Mesh

Post by AlbertoR »

Hello,
I got exactly the same problem in another model, I can provide it if it is necessary.

From my investigation it is related to the constraint: changing it the computation can go on.

I tried to make some work around defining the references of the constraints using the Python console* without success.
* the python instruction is:

Code: Select all

FreeCAD.getDocument('<filename>').getObject('ConstraintElectrostaticPotential002').References = (FreeCAD.getDocument('<filename>').getObject('BooleanFragments'),u'Solid1')
I have also named the reference with 'SOlid1' but in the ELMER log it is reported always as 'solid1' and thus it seems that string is somehow translated in a only-lowercase word.

Anyway if you use the Faces instead of the Solids to reference the constraints the problem could disappear (at least it disappeared to me).

Regards,
Alberto
Post Reply