Creating a boundary condition within an object, i.e. to measure flux

Mesh generators, CAD programs, and other tools
uplatise
Posts: 15
Joined: 11 Oct 2022, 00:10
Antispam: Yes
Contact:

Creating a boundary condition within an object, i.e. to measure flux

Post by uplatise »

Hi,

for the purpose of using Elmer to calculate flux inside a torus, instead of using paraview, by using the boundary condition for the SaveData, SaveScalars procedure:

Code: Select all

Boundary Condition 4
  Name = "Flux"
  Magnetic Flux Average = Logical True
End
for a given simple gmsh (4.10.5) geometry:

Code: Select all

SetFactory("OpenCASCADE");

Cylinder(1) = {0, 0, -0.15, 0, 0, 0.3,  0.002, 2*Pi};
Cylinder(2) = {0, 0, -0.15, 0, 0, 0.3,  0.100, 2*Pi};

Physical Volume("Wire", 4) = {1};
Physical Volume("Air", 7)  = {4};

Coherence;

Torus(3)    = {0, 0, 0, 0.02, 0.003, 2*Pi};
Curve Loop(15) = {8};
Surface(11) = {15};

Coherence;

Physical Volume("Core", 6) = {3};
Physical Surface("Sky", 8)         = {12, 13, 14};
Physical Surface("Wire End 1", 9)  = {3};
Physical Surface("Wire End 2", 10) = {2};

Physical Surface("Flux", 11) = {11};
But using the latest build (testing/devel deb release channel) of ElmerGrid 14 2 file.geo, it does not include the Flux boundary:

Code: Select all

! ----- names for bodies -----
$ Wire = 4
$ Core = 6
$ Air = 7
! ----- names for boundaries -----
$ Sky = 8
$ Wire End 1 = 9
$ Wire End 2 = 10
Maybe my concept of measuring flux is wrong, however I like the idea that Elmer provides average field for greater accuracy, but had no luck with this boundary condition to get it in. The surface is indeed removed from the resulting Elmer grid file; have converted it back to gmsh.
If it is wrong what would be the right approach to measure the flux inside some volume, as torus?

My real case is based on a step file at which I had no luck and created above simple model. For a step, have tried creating planes, duplicating them, making surfaces bigger, cutting the volume (as per https://gmsh.info/doc/texinfo/gmsh.html#t20 example), etc.

Any help is appreciated.

Kind regards,
Uros
Rich_B
Posts: 421
Joined: 24 Aug 2009, 20:18

Re: Creating a boundary condition within an object, i.e. to measure flux

Post by Rich_B »

Hello,

Perhaps this forum post will be helpful for you:

viewtopic.php?p=27253#p27253
Physical groups of volumes become bodies in Elmer
Physical groups of surfaces become boundaries in Elemer
Posting a complete minimal working example, with sif file and geometry files, is always helpful.

Rich.
uplatise
Posts: 15
Joined: 11 Oct 2022, 00:10
Antispam: Yes
Contact:

Re: Creating a boundary condition within an object, i.e. to measure flux

Post by uplatise »

Hi Rich,

thank you for reply. Do not see the solution in your referenced post. Of course physical groups of surfaces are to be expected to become boundaries, but the one which I have mentioned, the "Flux", disappears after the ElmerGrid conversion.

The gmsh .geo file has been provided, in which you can observe:
  • all the physical bodies of volumes and surfaces,
  • generate a mesh (save as .msh), which file still contains all of the volumes and surfaces
  • and by doing ElmerGrid 14 2 file.geo the Flux boundary disappears in the generated mesh output.
so the key question is about ElmerGrid or how to get the boundary (surface) for measuring flux in this simple torus?

Uros.
Rich_B
Posts: 421
Joined: 24 Aug 2009, 20:18

Re: Creating a boundary condition within an object, i.e. to measure flux

Post by Rich_B »

Hello again,

Have you tried using Boolean Fragments to create the three bodies, something like this:
SetFactory("OpenCASCADE");

Cylinder(1) = {0, 0, -0.15, 0, 0, 0.3, 0.002, 2*Pi};
Cylinder(2) = {0, 0, -0.15, 0, 0, 0.3, 0.100, 2*Pi};
Torus(3) = {0, 0, 0, 0.02, 0.003, 2*Pi};

BooleanFragments{ Volume{2}; Delete; }{ Volume{1}; Volume{3}; Delete; }
The BooleanFragments command will create a fourth volume, number 4, with the inner cylinder and the torus removed. BF also runs the Coherence command. Reviewing the results of the above looks much better in ElmerGUI.

Then add your physical volumes and surfaces commands.

Rich.
uplatise
Posts: 15
Joined: 11 Oct 2022, 00:10
Antispam: Yes
Contact:

Re: Creating a boundary condition within an object, i.e. to measure flux

Post by uplatise »

Hi,

I have tried with the example I have pointed out for managing the step model.

Anyway:

Code: Select all

SetFactory("OpenCASCADE");

Cylinder(1) = {0, 0, -0.15, 0, 0, 0.3,  0.002, 2*Pi};
Cylinder(2) = {0, 0, -0.15, 0, 0, 0.3,  0.100, 2*Pi};
Torus(3)    = {0, 0, 0, 0.02, 0.003, 2*Pi};

BooleanFragments{ Volume{2}; Delete; }{ Volume{1}; Volume{3}; Delete; } 

Curve Loop(13) = {8};
Plane Surface(11) = {13};
Physical Surface("Flux", 14) = {11};
results with ElmerGrid 14 2 ... content of mesh.names:

Code: Select all

 
! ----- names for boundaries -----
while in gmsh the physical surface is there.
For some unknown reason ElmerGrid conversion keeps removing this boundary.

Uros.
Rich_B
Posts: 421
Joined: 24 Aug 2009, 20:18

Re: Creating a boundary condition within an object, i.e. to measure flux

Post by Rich_B »

Hello,

Here is another version that creates boundary surfaces in the torus, without using physical groups. The results look appropriate in ElmerGUI.
SetFactory("OpenCASCADE");

Cylinder(1) = {0, 0, -0.15, 0, 0, 0.3, 0.100, 2*Pi};
Cylinder(2) = {0, 0, -0.15, 0, 0, 0.3, 0.002, 2*Pi};
Torus(3) = {0, 0, 0, 0.02, 0.003, Pi};
//+
Rotate {{0, 0, 1}, {0, 0, 0}, Pi} {
Duplicata { Volume{3}; }
}

BooleanFragments{ Volume{1}; Delete; }{ Volume{2,3,4}; Delete; }
This doesn't address your issues with missing physical groups after converting with elmergrid, but it may be useful as a model that should work with Elmer.

Rich.
uplatise
Posts: 15
Joined: 11 Oct 2022, 00:10
Antispam: Yes
Contact:

Re: Creating a boundary condition within an object, i.e. to measure flux

Post by uplatise »

Thank you for another version,

and yes still the main question is, is it a bug or a feature of ElmerGrid, my misunderstanding/improper use of ElmerGrid and if the later is the case, what should be the right way of creating a surface and using the Average Flux calculation of the Save Scalars through some body.

Let's try to focus into this question if anybody can help finding a solution.

Uros.
Rich_B
Posts: 421
Joined: 24 Aug 2009, 20:18

Re: Creating a boundary condition within an object, i.e. to measure flux

Post by Rich_B »

Hello,

Here's another version, this time with physical groups. The cross sections of the torus show up as boundaries 6 and 7 in ElmerGUI. The names file is generated by elmergrid, and contains all of the physical names entered in the gmsh geo file.

Rich.
Attachments
flux20.geo
(815 Bytes) Downloaded 69 times
uplatise
Posts: 15
Joined: 11 Oct 2022, 00:10
Antispam: Yes
Contact:

Re: Creating a boundary condition within an object, i.e. to measure flux

Post by uplatise »

Incredible, they indeed remain in. Do you have any explanation for this, why?

Thank you.
Rich_B
Posts: 421
Joined: 24 Aug 2009, 20:18

Re: Creating a boundary condition within an object, i.e. to measure flux

Post by Rich_B »

Hello,

Gmsh is built with layers. First make sure the geometry without physical groups is working with ElmerGUI. ElmerGUI is a good tool to visualize the model with mesh, including looking at boundaries and bodies. Then add physical groups using the gmsh gui, adding surfaces first, then the volumes. Be sure to add physical groups to all surfaces and bodies, don't skip any entities. Finish up by inspecting the results with ElmerGUI.

Rich.
Post Reply