HelmholtzSolve Outputs a Vector Result for 2D Mesh Study

Numerical methods and mathematical models of Elmer
Post Reply
CrocoDuck
Posts: 79
Joined: 12 May 2016, 13:15
Antispam: Yes

HelmholtzSolve Outputs a Vector Result for 2D Mesh Study

Post by CrocoDuck »

Hi!

I used the Helmholtz Solver for acoustics a bunch of times for 3D meshes. Typically, the vtu file Elmer saves has two scalar fields inside, "pressure wave 1" and "pressure wave 2". Today I produced a simulation on a 2D mesh instead, on the XY plane. After I solved the study, I was surprised to find that inside the final vtu there is a single vector field "pressure wave" with 3 components, "pressure wave_X", "pressure wave_Y" and"pressure wave_Z". The _Z component seems to be 0 all over, and to me it looks like _X and _Y are the real and imaginary parts of the actual scalar field.

I could not find information in the Models Manual about how the mesh dimensionality affects the resulting vtu. Do you guys think my interpretation of the result above is correct?

My sif is file below, I now realise that I used a 3D cartesian system. Any chance this is the reason why I got a vector field instead of a scalar one?

Code: Select all

Header
  CHECK KEYWORDS Warn
  Mesh DB "." "."
  Include Path ""
  Results Directory ""
$ f = 40000
$ p = 1.205
$ U = 0.34
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
  Coordinate Scaling = 0.001
  Solver Input File = case.sif
  Post File = case.vtu
End

Constants
  Gravity(4) = 0 -1 0 9.82
  Stefan Boltzmann = 5.670374419e-08
  Permittivity of Vacuum = 8.85418781e-12
  Permeability of Vacuum = 1.25663706e-6
  Boltzmann Constant = 1.380649e-23
  Unit Charge = 1.6021766e-19
End

Body 1
  Target Bodies(1) = 1
  Name = "Body 1"
  Equation = 1
  Material = 1
End

Solver 1
  Equation = Helmholtz Equation
  Variable = -dofs 2 Pressure Wave
Element = "p:2"
  Procedure = "HelmholtzSolve" "HelmholtzSolver"
  Exec Solver = Always
  Stabilize = True
  Optimize Bandwidth = True
  Steady State Convergence Tolerance = 1.0e-5
  Nonlinear System Convergence Tolerance = 1.0e-7
  Nonlinear System Max Iterations = 1
  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 = BiCGStabl
  Linear System Max Iterations = 10000
  Linear System Convergence Tolerance = 1.0e-10
  BiCGstabl polynomial degree = 2
  Linear System Preconditioning = ILUT
  Linear System ILUT Tolerance = 1.0e-3
  Linear System Abort Not Converged = False
  Linear System Residual Output = 10
  Linear System Precondition Recompute = 1
End

Equation 1
  Name = "Helmholtz"
Frequency = Real MATC "f"
  Active Solvers(1) = 1
End

Material 1
  Name = "Air (room temperature)"
  Turbulent Prandtl Number = 0.713
  Relative Permeability = 1.00000037
  Sound speed = 343.0
  Heat Capacity = 1005.0
  Viscosity = 1.983e-5
  Relative Permittivity = 1.00059
  Heat expansion Coefficient = 3.43e-3
  Heat Conductivity = 0.0257
  Porosity Model = Always saturated
  Density = Real MATC "p"
End

Boundary Condition 1
  Target Boundaries(7) = 1 3 4 5 6 7 8 
  Name = "Rigid"
  Wave Flux 1 = 0
  Wave Flux 2 = 0
End

Boundary Condition 2
  Target Boundaries(1) = 2 
  Name = "Radiator"
  Wave Flux 2 = Real MATC "2 * pi * f * p * U"
  Wave Flux 1 = 0
End

Boundary Condition 3
  Target Boundaries(1) = 9 
  Name = "Outlet"
  Plane Wave BC = True
End
CrocoDuck
Posts: 79
Joined: 12 May 2016, 13:15
Antispam: Yes

Re: HelmholtzSolve Outputs a Vector Result for 2D Mesh Study

Post by CrocoDuck »

That's intriguing... I setup two very similar studies and I ended up with "pressure wave 1" and "pressure wave 2"... Maybe I did something weird by mistake with the first one...
CrocoDuck
Posts: 79
Joined: 12 May 2016, 13:15
Antispam: Yes

Re: HelmholtzSolve Outputs a Vector Result for 2D Mesh Study

Post by CrocoDuck »

I think I figured out what makes the "pressure wave" vector field to happen.

I am preparing my mesh with Salome. If the root geometric entity that I mesh is a "Face" then the results will have a "pressure wave" vector field.

Does any of you guys know what would be the best way to setup a 2D mesh with Salome for 2D problems for Elmer? I tried to play with the "Coordinate Mapping" setting, but it turns out that, even if my mesh is 2D, I still need a 3D coordinate system for the solver to run.

Cheers!
kevinarden
Posts: 2237
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: HelmholtzSolve Outputs a Vector Result for 2D Mesh Study

Post by kevinarden »

Coordinate System = Cartesian

I am assuming this defaults to 3D there is also

Coordinate System = Cartesian 2D

Coordinate System String
Defines the coordinate system to be used, one of: Cartesian 1D, Cartesian 2D, Cartesian
3D, Polar 2D, Polar 3D, Cylindric, Cylindric Symmetric and Axi
Symmetric.
CrocoDuck
Posts: 79
Joined: 12 May 2016, 13:15
Antispam: Yes

Re: HelmholtzSolve Outputs a Vector Result for 2D Mesh Study

Post by CrocoDuck »

Hi, thank you very much.

I tried it and I got a vector field result again:

Code: Select all

Simulation
  Max Output Level = 5
  Coordinate System = "Cartesian 2D"
  Coordinate Mapping(3) = 1 2 3
  Simulation Type = Steady state
  Steady State Max Iterations = 1
  Output Intervals = 1
  Coordinate Scaling = 0.001
  Solver Input File = case.sif
  Post File = case.vtu
End
Coordinate Mapping needs to be a permutation of 1,2 and 3. Attempting this:

Code: Select all

Simulation
  Max Output Level = 5
  Coordinate System = "Cartesian 2D"
  Coordinate Mapping(3) = 1 2
  Simulation Type = Steady state
  Steady State Max Iterations = 1
  Output Intervals = 1
  Coordinate Scaling = 0.001
  Solver Input File = case.sif
  Post File = case.vtu
End
Results in this:

Code: Select all

ERROR:: MapCoordinates:  Inconsistent Coordinate Mapping:            1           2
ERROR:: MapCoordinates:  Coordinate mapping should be a permutation of 1,2 and 3
I see from here that keywords like "Cartesian 2D" are legacy, and that Elmer infers the dimensionality from the mesh dimension. Looks like I need to make sure my mesh is 2D instead of 3D with all Z coordinates set to 0. I will dig into Salome to figure out how to do it, or give it a stab with Gmsh.

Thank you for your help, let me know if you have other tips!
kevinarden
Posts: 2237
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: HelmholtzSolve Outputs a Vector Result for 2D Mesh Study

Post by kevinarden »

Sometimes I read the mesh.nodes file into a spreadsheet or text editor and do a replace all.
Post Reply