Should I use 2D or 3D mesh to calculate EM field without GUI

Numerical methods and mathematical models of Elmer
sunyuan
Posts: 16
Joined: 20 Apr 2022, 11:28
Antispam: Yes

Should I use 2D or 3D mesh to calculate EM field without GUI

Post by sunyuan »

Dear experts

I want to calculate EM field between several wires inside some gas mixture, I made 9 wires (cylinders) and 1 large cylinder to represent infinity. Then, 2D mesh is generated and transformed by ElmerGrid "ElmerGrid 14 2 prototype.msh -autoclean". I got messages like:
Index 20005 too high: ignoring physical surface "wire5boundary"
which I don't know what does it mean. Inside Elmer mesh directory I noticed that "mesh.header" says that there is no boundary elements, and my defined boundary surfaces all became body elements. Can someone tell me how to solve this?
I attach my .geo file here, I used Gmsh's 2D mesh function.
If you can provide a minimal example that can calculate EM field of this it will be very helpful, thank you in advance.
Attachments
prototype.geo
(1.4 KiB) Downloaded 42 times
kevinarden
Posts: 2312
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: Should I use 2D or 3D mesh to calculate EM field without GUI

Post by kevinarden »

Your geometry is 3D so if you only mesh 2D then you will just get surface elements. These surface elements will be bodies. In 2d boundaries are edge elements. You should mesh this 3D.

Another item is that you have to cut the bigger volume with the wires while retaining the wires. This is a boolean operation in gmsh. This allows the wires to be in the volume and share nodes and boundaries with the volume.

The constants in Elmer are in SI, so distance is meters.

You also have to name all of the volumes and surfaces, because only the named ones get written out.

When ElmerGrid translates it will provide a mesh.name file of all of the bodies and surfaces.
I provide an example similar to yours.
prototype.geo
(1.91 KiB) Downloaded 44 times
prototypecase.sif
(4.06 KiB) Downloaded 42 times
raback
Site Admin
Posts: 4832
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Should I use 2D or 3D mesh to calculate EM field without GUI

Post by raback »

Hi,

If your physics allows you should definitely only study the cross section of the wires and use 2D mesh and MagnetoDynamics2D module.

If not, then use 3D mesh and MagnetoDynamics module.

Study the models manual for these and perhaps pick some test case to start from. There are tens of tests starting with "mgdyn" to choose from. I just added the simplest one, mgdyn2D_steady_wire, for sake of completeness.

-Peter
kevinarden
Posts: 2312
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: Should I use 2D or 3D mesh to calculate EM field without GUI

Post by kevinarden »

I have attached a 2D case similar to what you are looking at. It is a cross section of 9 wires in air. The assumption is that it is contionus in and out of the cross section plane.
2dproto.geo
(1.8 KiB) Downloaded 43 times
2dproto.sif
(3.23 KiB) Downloaded 54 times
magfields.png
(281.56 KiB) Not downloaded yet
raback
Site Admin
Posts: 4832
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Should I use 2D or 3D mesh to calculate EM field without GUI

Post by raback »

Hi Kevin,

Nice case you created!

One thing: I think the default name for the vector potential in 2D is "Az". This is because all other components vanish due to symmetry and only one component is left. In 3D you are left with all three components of vector potential. So probably the Dirichlet conditions didn't apply. Or you could give it any name, e.g. "Variable = Potential".

I could imagine that the current density in each wire could be different then they would need to have different bodies and body forces. You would already get some nice variation then by having negative/positive value for the current density. With 9 wires you have quite many permutations...

-Peter
sunyuan
Posts: 16
Joined: 20 Apr 2022, 11:28
Antispam: Yes

Re: Should I use 2D or 3D mesh to calculate EM field without GUI

Post by sunyuan »

Hi Kevin,

Thank you for you reply! I believe I need to use 3D case since wires will have stereo angles between each other.
I ran the example you gave:
$gmsh prototype.geo -3 -o prototype.msh
$ElmerGrid 14 2 prototype.msh -autoclean
$ElmerSolver prototype.sif
but I got a seg fault right after. Do you have the same problem? It seems a Fortran seg fault.
Output:

siyuan@SiyuandeMacBook-Pro cdc_prototype % ElmerSolver prototype.sif
ELMER SOLVER (v 9.0) STARTED AT: 2022/07/30 16:16:19
ParCommInit: Initialize #PEs: 1
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: c84377f0, Compiled: 2022-04-21)
MAIN: Running one task without MPI parallelization.
MAIN: Running with just one thread per task.
MAIN: =============================================================
LoadInputFile: Trying to read "Run Control" section only
MAIN:
MAIN:
MAIN: -------------------------------------
MAIN: Reading Model: prototype.sif
LoadInputFile: Scanning input file: prototype.sif
LoadInputFile: Scanning only size info
LoadInputFile: First time visiting
LoadInputFile: Reading base load of sif file
LoadInputFile: Loading input file: prototype.sif
LoadInputFile: Reading base load of sif file
LoadInputFile: Number of BCs: 6
LoadInputFile: Number of Body Forces: 0
LoadInputFile: Number of Initial Conditions: 0
LoadInputFile: Number of Materials: 2
LoadInputFile: Number of Equations: 1
LoadInputFile: Number of Solvers: 2
LoadInputFile: Number of Bodies: 10
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
ElmerAsciiMesh: Base mesh name: ./prototype
LoadMesh: Elapsed REAL time: 0.0417 (s)
MAIN: -------------------------------------
AddVtuOutputSolverHack: Adding ResultOutputSolver to write VTU output in file: case
OptimizeBandwidth: ---------------------------------------------------------
OptimizeBandwidth: Computing matrix structure for: mgdynamics...done.
OptimizeBandwidth: Half bandwidth without optimization: 23308
OptimizeBandwidth:
OptimizeBandwidth: Bandwidth Optimization ...done.
OptimizeBandwidth: Half bandwidth after optimization: 7184
OptimizeBandwidth: ---------------------------------------------------------
OptimizeBandwidth: ---------------------------------------------------------
OptimizeBandwidth: Computing matrix structure for: mgdynamicscalc...done.
OptimizeBandwidth: Half bandwidth without optimization: 3082
OptimizeBandwidth:
OptimizeBandwidth: Bandwidth Optimization ...done.
OptimizeBandwidth: Half bandwidth after optimization: 968
OptimizeBandwidth: ---------------------------------------------------------
ElmerSolver: Number of timesteps to be saved: 1
MAIN:
MAIN: -------------------------------------
MAIN: Steady state iteration: 1
MAIN: -------------------------------------
MAIN:

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:

Could not print backtrace: executable file is not an executable
#0 0x1057b1147
#1 0x1057b01db
#2 0x1a12d94c3
#3 0x1051820b3
zsh: segmentation fault ElmerSolver prototype.sif
kevinarden
Posts: 2312
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: Should I use 2D or 3D mesh to calculate EM field without GUI

Post by kevinarden »

No I did not receive a seg fault. How much ram does the computer have?
sunyuan
Posts: 16
Joined: 20 Apr 2022, 11:28
Antispam: Yes

Re: Should I use 2D or 3D mesh to calculate EM field without GUI

Post by sunyuan »

Ah...It stoped right after I ran the ElmerSolver so I couldn't see how much ram it had, but if it stopped instantly should not be much, right?
I don't have a clue of how this seg fault comes out... I didn't change the sif file, the only change is in the .geo file from "MeshSizeFromCurvature = 8" to "MeshSizeFromCurvature = 10"
Rich_B
Posts: 423
Joined: 24 Aug 2009, 20:18

Re: Should I use 2D or 3D mesh to calculate EM field without GUI

Post by Rich_B »

Hello,

Regarding the ram question, how much ram does your MacBook Pro have installed? Do you have access to another computer, that has more ram installed, if so, maybe try again with more ram.

Rich.
kevinarden
Posts: 2312
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: Should I use 2D or 3D mesh to calculate EM field without GUI

Post by kevinarden »

at "MeshSizeFromCurvature = 10" it was hitting around 12 GB ram with Element = "P:2"
at "MeshSizeFromCurvature = 8" it was hitting around 6 GB ram with Element = "P:2"

you might try to comment out the Element ="P:2" to see if it would run.
Post Reply