2D solving with a 3D mesh

Numerical methods and mathematical models of Elmer
spacedout
Posts: 177
Joined: 30 Mar 2020, 23:27
Antispam: Yes

2D solving with a 3D mesh

Post by spacedout »

Hi to all

I am coupling Elmer to OpenFOAM through EOF. I am solving a 2D problem but OpenFOAM can only deal with 3D meshes. This can be done in OpenFOAM by declaring empty patches for the two planes perpendicular to 3rd unused dimension (call it z axis). Since 3D information is sent to Elmer, I therefore cannot write

Simulation
Coordinate System = "Cartesian 2D"

in the SIF

but instead I must have

Simulation
Coordinate System = "Cartesian"
Coordinate Mapping(3) = 1 2 3

The question is what kind of boundary condition must be set to for the two planes perpendicular to the z axis ?

Right now, I did not write any boundary conditions for these planes which is maybe why the partial derivative dF/dz for the field variable F to be solved is non zero and in fact is a function of x and y. Should I set a zero Dirichlet condition on these two planes ?

Regards
fjimenez
Posts: 63
Joined: 27 Sep 2021, 23:40
Antispam: Yes

Re: 2D solving with a 3D mesh

Post by fjimenez »

Hi,

I have never used the EOF libray but I am quite familiar with OpenFOAM. When you set up a 2D case you indeed have a 3D mesh but you only solve equations for the cell centers, so in practice you end up with solutions living only in 2D space (in both real 2D and axi-symmetric cases). Ideally, you can send these cell centers to Elmer and map them into a 2D mesh so you would not need a 3D mesh in Elmer at all. I am not sure if the EOF library only works for 3D cases or not, I can try to take a look at it and report back.

Cheers,
spacedout
Posts: 177
Joined: 30 Mar 2020, 23:27
Antispam: Yes

Re: 2D solving with a 3D mesh

Post by spacedout »

Hello fjimenez

I am fairly familiar with the EOF library as I have modified its code for over a year. I see 3D coordinates x, y and z everywhere but I am not sure yet
if it will accept a 2D mesh.

If it does not, I suppose it should not be too hard to handle. The mesh is just a trivial extrusion of a 2D mesh. I used Gmesh to make a copy of the 2D data - that will be the z=1 plane. the original is the z=0 plane. You just tell the mesh algorithm to connect points (x,y,0) to (x,y,1).

And sorry for me mentioning zero Dirichlet in my post. I meant zero Neumann. ( dF/dz=0) So the SIF would contain something like that

Boundary Condition 1
Target Boundaries(1) = 1
Name = "front and back"
Potential Grad 3 = Real 0.0
End

I will investigate the two possibilities and keep you posted.

If you have a chance, let me know if you find anything. That would be appreciated.
Thanks
spacedout
Posts: 177
Joined: 30 Mar 2020, 23:27
Antispam: Yes

Re: 2D solving with a 3D mesh

Post by spacedout »

With the following SIF excerpt

Header
Mesh DB "." "Mymesh1"
End

Simulation
Coordinate System = "Cartesian 2D"
.......

where Mymesh1 is a 3D mesh, EOF will yield degenerate 3D elements



and I suppose it would be stupid to try

Header
Mesh DB "." "Mymesh2"
End

Simulation
Coordinate System = "Cartesian"
Coordinate Mapping(3) = 1 2 3

where Mymesh2 is a 2D mesh

Up to now, the second possibility I mentioned in my last post:

Boundary Condition 1
Target Boundaries(1) = 1
Name = "front and back"
Potential Grad 3 = Real 0.0
End

seems to be more promising as long as EOF does the correct interpolation of coordinates and field values
fjimenez
Posts: 63
Joined: 27 Sep 2021, 23:40
Antispam: Yes

Re: 2D solving with a 3D mesh

Post by fjimenez »

Hi spacedout,
I ran the levitation2D test in the eof repository and it seems that the elmer mesh is 2D so you should be able to do what you want to do with a 2D mesh in elmer, as long as your openfoam mesh has only one cell in the z-dimension I guess. Do you have problems when you send your data from openfoam to elmer or is it that the results are wrong? I'll try to set up a new case if I find the time to do so.
spacedout
Posts: 177
Joined: 30 Mar 2020, 23:27
Antispam: Yes

Re: 2D solving with a 3D mesh

Post by spacedout »

Good day fjimenez

First I dont have problems sending data back and forth between openfoam and elmer.
As of my last post, I tried elmer and openfoam meshes with only one cell in the z-dimension (So both are 3D) . However in spite of

Potential Grad 3 = Real 0.0

in the BC, StatElecSolver (solves Poisson eqn) yields dF/dz in the hundreds of millions ! And I observe that the interpolated values to be sent to openfoam can be of the astronomical order of 10**17 ! ( where ** stands for exponent) . The geometry for levitation2D is actually 3D - it is just that only 2 coordinates are needed because of the cylindrical symmetry. In my case I have a 2D Cartesian mesh. It would be nice if I could copy all 2D data from elmer for use by the 3D mesh to satisfy the requirements of eof and openfoam and convert the 3D data sent by openfoam to 2D data which would then be used by elmer. However, I am not sure it this can be easily done. I'll let you know if I make any progress.
fjimenez
Posts: 63
Joined: 27 Sep 2021, 23:40
Antispam: Yes

Re: 2D solving with a 3D mesh

Post by fjimenez »

Hi spacedout,

Well, we might be talking about the same thing using different terminologies. The OF mesh in the test case is indeed 3D, after all it is a finite volume mesh however, I have solved 1D cases in OF and even in these cases I need a 3D mesh. At the end I think you would end up sending the same number of points (cell centers) from OF to Elmer in both 2D cartesian and 2D axi-symmetric meshes. Data of course would be different in both meshes because the are representing different cases.

I think you would not need to define any boundary condition in z in the 3D case in Elmer because these automatically are included in the FE implementation. At least that is what I think, I have more experience with finite volume implementations though.

Lastly, you can solve for the potential in OF (both Laplace and Poisson equations can be easily implemented there), so unless you also need a magnetic field I think you can try doing this directly in OF.

Do you have a simple test case to play with?

Cheers,
spacedout
Posts: 177
Joined: 30 Mar 2020, 23:27
Antispam: Yes

Re: 2D solving with a 3D mesh

Post by spacedout »

Well, fjimenez, ideally I would have used OF for the Poisson equation from the start 4 years ago. And then I would never have considered Elmer. But if you thoroughly search over CFD Online OpenFOAM posts, you will realize that you cannot solve one Poisson equation over two domains of different electrical permittivity with a surface charge on the boundary between the two domains. You are forced to iterate between two Poisson equations over the two domains and this I am very reluctant to do. Elmer's FEM code avoids this iteration.
Of course you are more than welcome to prove me wrong if you think I have overlooked something.

I may try to simplify my test case in order to find out who is the culprit behind this bug. But it will have to wait till I come back from my one week beach vacation.
Ciao
fjimenez
Posts: 63
Joined: 27 Sep 2021, 23:40
Antispam: Yes

Re: 2D solving with a 3D mesh

Post by fjimenez »

oh I see. I wasn't aware of the difficulties of your problem so it was just a suggestion. Good luck with your efforts.

Cheers,
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: 2D solving with a 3D mesh

Post by raback »

Beach vacation sounds great! I think that a minimalistic test case could help to pinpoint the problem. These are already quite complex things in the intersection of two codes so it is very difficult to give advice out of memory. -Peter
Post Reply