[SOLVED] Vtu export fails

The graphical user interface of Elmer
CrocoDuck
Posts: 79
Joined: 12 May 2016, 13:15
Antispam: Yes

[SOLVED] Vtu export fails

Post by CrocoDuck »

Hi guys, hope I can get some support here.

So, I am running a simple acoustic simulation with the Helmholtz solver. Here my sif file:

Code: Select all

Header
  CHECK KEYWORDS Warn
  Mesh DB "." "."
  Include Path ""
  Results Directory ""
! Simulation Parameters:
  ! Frequency [Hz]:
  $ f = 3583
  ! Velocity [m / s]
  $ v = 0.000001
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
  Timestepping Method = BDF
  BDF Order = 1
  Solver Input File = case.sif
  Post File = case.ep
Coordinate Scaling = 0.001
End

Constants
  Gravity(4) = 0 -1 0 9.82
  Stefan Boltzmann = 5.67e-08
  Permittivity of Vacuum = 8.8542e-12
  Boltzmann Constant = 1.3807e-23
  Unit Charge = 1.602e-19
End

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

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

Solver 2
  Equation = Result Output
  Procedure = "ResultOutputSolve" "ResultOutputSolver"
  Save Geometry Ids = True
  Output File Name = case
  Output Format = Vtu
  Save Linear Elements = True
  Exec Solver = After Simulation
End

Equation 1
  Name = "Helmholtz EQ"
  Angular Frequency = Real MATC "2 * pi * f"
  Active Solvers(1) = 1
End

Equation 2
  Name = "Result Output EQ"
  Active Solvers(1) = 2
End

Material 1
  Name = "Air (room temperature)"
  Viscosity = 1.983e-5
  Heat expansion Coefficient = 3.43e-3
  Heat Conductivity = 0.0257
  Relative Permittivity = 1.00059
  Sound speed = 343.0
  Heat Capacity = 1005.0
  Density = 1.205
End

Body Force 1
  Name = "SPL"
Press_dB = Variable Pressure Wave 1, Pressure Wave 2
      Real MATC "20*log(((sqrt(tx(0)^2+tx(1)^2))/sqrt(2)))"
End

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

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

I would like to export the Sound Pressure Level (but actually also the Pressure Waves) in a vtu file, to study it with ParaView. The sad thing is that whatever I try on the sif file I can get only GeometryIds accessible on ParaView. I cannot plot anything else, as that was the only data in the vtu. Any of you having an idea of why? Shouldn't the vtu exporter be exporting all the variables by default?

By the way, I am running Elmer on Mac, installed with this.

Edit: Wrong sif file uploaded :oops:

All seems to be fine on the log:

Code: Select all

ResultOutputSolver: -------------------------------------
ResultOutputSolve: Saving with prefix: case
ResultOutputSolver: Dimension of mesh: 3
ResultOutputSolver: Creating list for saving - if not present
CreateListForSaving: Field Variables for Saving
CreateListForSaving: Scalar Field 1: pressure wave 1
CreateListForSaving: Scalar Field 2: pressure wave 2
ResultOutputSolver: Saving in unstructured VTK XML (.vtu) format
VtuOutputSolver: Saving results in VTK XML format with prefix: case
VtuOutputSolver: Saving number of partitions: 1
ResultOutputSolver: -------------------------------------
Edit 2: Oh well... that's embarrassing... Not really sure what happened but it started working...

Any of you able to suggest how can I export the dB values defined in Body Force 1? Should I actually define it somewhere else?
Last edited by CrocoDuck on 23 May 2016, 17:07, edited 1 time in total.
mzenker
Posts: 1999
Joined: 07 Dec 2009, 11:49
Location: Germany

Re: Vtu export fails

Post by mzenker »

Hi,

what happens if you disable the Resultoutput Solver and change the extension from .ep to .vtu in the Simulation section?

HTH,

Matthias
CrocoDuck
Posts: 79
Joined: 12 May 2016, 13:15
Antispam: Yes

Re: Vtu export fails

Post by CrocoDuck »

mzenker wrote:Hi,

what happens if you disable the Resultoutput Solver and change the extension from .ep to .vtu in the Simulation section?

HTH,

Matthias
Hi Matthias, thank you very much.

That seems to be working as well, I would say. I actually like it much more (it feels simpler). Thanks Again.

Now I only have to figure out how to export Sound Pressure Levels as well. Any suggestion is welcome!
mzenker
Posts: 1999
Joined: 07 Dec 2009, 11:49
Location: Germany

Re: Vtu export fails

Post by mzenker »

Hi,

if the simplified call to Resultoutput Solver (this is in fact what happens if you change the file extension to vtu in the Simulation section) does not do what you want, you might need to switch the solver back on and play with its keywords as explained in the Models Manual. If that doesn't help, you can try with the SaveData/SaveScalars solver, see Models manual.

HTH,

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

Re: Vtu export fails

Post by raback »

Hi

In Solver 1 set

Code: Select all

  Exported Variable 1 = PressdB  
  Nonlinear Update Exported Variables = Logical True
And maintain the PresdB in the BF section. I would not use the underscore in the variablename.

-Peter
CrocoDuck
Posts: 79
Joined: 12 May 2016, 13:15
Antispam: Yes

Re: Vtu export fails

Post by CrocoDuck »

raback wrote:Hi

In Solver 1 set

Code: Select all

  Exported Variable 1 = PressdB  
  Nonlinear Update Exported Variables = Logical True
And maintain the PresdB in the BF section. I would not use the underscore in the variablename.

-Peter
Hi Peter, thank you very much. I indeed tried it and seemed to be working just fine. Here the sif (I renamed the variable SPL):

Code: Select all

Header
  CHECK KEYWORDS Warn
  Mesh DB "." "."
  Include Path ""
  Results Directory ""
! Simulation Parameters:
  ! Frequency [Hz]:
  $ f = 3583
  ! Velocity [m / s]
  $ v = 0.000001
  ! Reference Pressure [Pa]:
  $ P = 0.00002
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
  Timestepping Method = BDF
  BDF Order = 1
  Solver Input File = case.sif
  Post File = case.ep
Coordinate Scaling = 0.001
End

Constants
  Gravity(4) = 0 -1 0 9.82
  Stefan Boltzmann = 5.67e-08
  Permittivity of Vacuum = 8.8542e-12
  Boltzmann Constant = 1.3807e-23
  Unit Charge = 1.602e-19
End

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

Solver 1
  Equation = Helmholtz Equation
  Procedure = "HelmholtzSolve" "HelmholtzSolver"
Nonlinear Update Exported Variables = Logical True
Exported Variable 1 = SPL
  Variable = -dofs 2 Pressure Wave
  Exec Solver = Always
  Stabilize = True
  Bubbles = False
  Lumped Mass Matrix = False
  Optimize Bandwidth = True
  Steady State Convergence Tolerance = 1.0e-5
  Nonlinear System Convergence Tolerance = 1.0e-7
  Nonlinear System Max Iterations = 20
  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 = BiCGStab
  Linear System Max Iterations = 500
  Linear System Convergence Tolerance = 1.0e-10
  BiCGstabl polynomial degree = 2
  Linear System Preconditioning = Diagonal
  Linear System ILUT Tolerance = 1.0e-3
  Linear System Abort Not Converged = False
  Linear System Residual Output = 1
  Linear System Precondition Recompute = 1
End

Solver 2
  Equation = Result Output
  Procedure = "ResultOutputSolve" "ResultOutputSolver"
  Save Geometry Ids = True
  Output File Name = case
  Output Format = Vtu
  Save Linear Elements = True
  Exec Solver = After Simulation
End

Equation 1
  Name = "Helmholtz EQ"
  Angular Frequency = Real MATC "2 * pi * f"
  Active Solvers(1) = 1
End

Equation 2
  Name = "Result Output EQ"
  Active Solvers(1) = 2
End

Material 1
  Name = "Air (room temperature)"
  Viscosity = 1.983e-5
  Heat expansion Coefficient = 3.43e-3
  Heat Conductivity = 0.0257
  Relative Permittivity = 1.00059
  Sound speed = 343.0
  Heat Capacity = 1005.0
  Density = 1.205
End

Body Force 1
  Name = "SPL Calc"
SPL = Variable Pressure Wave 1, Pressure Wave 2
      Real MATC "20 * log((sqrt(tx(0)^2 + tx(1)^2)) / (P * sqrt(2)))"
End

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

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

This has a con though... It seems to be calculating SPL at each iteration, slowing down the solution process considerably (still pretty quick). I would love to be able to calculate SPL from the final solution and then append it to the vtu. Also, I will soon look into trying to export the mean value of SPL on a boundary.
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Vtu export fails

Post by raback »

Hi

It's slow because of MATC. UDF would be much faster.

You could try SaveBoundaryValues or SaveMaterialValues solver (Ch. 46 in Models Manual) and place that to 2nd solver to be executed before the 3rd solver that saves the stuff.

-Peter
CrocoDuck
Posts: 79
Joined: 12 May 2016, 13:15
Antispam: Yes

Re: Vtu export fails

Post by CrocoDuck »

Thanks!

Still have to double check, but this seems to do the job:

Code: Select all

Header
  CHECK KEYWORDS Warn
  Mesh DB "." "."
  Include Path ""
  Results Directory ""
! Simulation Parameters:
  ! Frequency [Hz]:
  $ f = 3583
  ! Velocity [m / s]
  $ v = 0.000001
  ! Reference Pressure [Pa]:
  $ P = 0.00002
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
  Timestepping Method = BDF
  BDF Order = 1
  Solver Input File = case.sif
  Post File = case.ep
Coordinate Scaling = 0.001
End

Constants
  Gravity(4) = 0 -1 0 9.82
  Stefan Boltzmann = 5.67e-08
  Permittivity of Vacuum = 8.8542e-12
  Boltzmann Constant = 1.3807e-23
  Unit Charge = 1.602e-19
End

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

Solver 1
  Equation = Helmholtz Equation
  Procedure = "HelmholtzSolve" "HelmholtzSolver"
  Nonlinear Update Exported Variables = Logical True
  Exported Variable 1 = SPL
  Variable = -dofs 2 Pressure Wave
  Exec Solver = Always
  Stabilize = True
  Bubbles = False
  Lumped Mass Matrix = False
  Optimize Bandwidth = True
  Steady State Convergence Tolerance = 1.0e-5
  Nonlinear System Convergence Tolerance = 1.0e-7
  Nonlinear System Max Iterations = 20
  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 = BiCGStab
  Linear System Max Iterations = 500
  Linear System Convergence Tolerance = 1.0e-10
  BiCGstabl polynomial degree = 2
  Linear System Preconditioning = Diagonal
  Linear System ILUT Tolerance = 1.0e-3
  Linear System Abort Not Converged = False
  Linear System Residual Output = 1
  Linear System Precondition Recompute = 1
End

Solver 2
  Procedure = "SaveData" "SaveScalars"  
  Filename = SPLmean.dat
  Operator 1 = boundary mean
  Variable 1 = SPL
End

Solver 3
  Equation = Result Output
  Procedure = "ResultOutputSolve" "ResultOutputSolver"
  Save Geometry Ids = True
  Output File Name = case
  Output Format = Vtu
  Save Linear Elements = True
  Exec Solver = After Simulation
End

Equation 1
  Name = "Helmholtz EQ"
  Angular Frequency = Real MATC "2 * pi * f"
  Active Solvers(1) = 1
End

Equation 2
  Name = "Result Output EQ"
  Active Solvers(1) = 2
End

Equation 3
  Name = "Equation 3"
End

Material 1
  Name = "Air (room temperature)"
  Viscosity = 1.983e-5
  Heat expansion Coefficient = 3.43e-3
  Heat Conductivity = 0.0257
  Relative Permittivity = 1.00059
  Sound speed = 343.0
  Heat Capacity = 1005.0
  Density = 1.205
End

Body Force 1
  Name = "SPL Calc"
SPL = Variable Pressure Wave 1, Pressure Wave 2
      Real MATC "20 * log((sqrt(tx(0)^2 + tx(1)^2)) / (P * sqrt(2)))"
End

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

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

Boundary Condition 3
  Target Boundaries(1) = 1 
  Name = "Hard Wall 2"
  Wave Flux 1 = 0
  Wave Flux 2 = 0
  Save Scalars = Logical True
End
So, summing up:
  • Define the new variable in Body Force:

    Code: Select all

    Body Force 1
      Name = "SPL Calc"
    SPL = Variable Pressure Wave 1, Pressure Wave 2
          Real MATC "20 * log((sqrt(tx(0)^2 + tx(1)^2)) / (P * sqrt(2)))"
    End
    
  • Add the lines to the primary solver (Helmholtz in this case):

    Code: Select all

      Nonlinear Update Exported Variables = Logical True
      Exported Variable 1 = SPL
    
  • Add a SaveData solver (simple explanation here):

    Code: Select all

    Solver 2
      Procedure = "SaveData" "SaveScalars"  
      Filename = SPLmean.dat
      Operator 1 = boundary mean
      Variable 1 = SPL
      ! Want to append to file?
      File Append = Logical True
    End
    
  • Add "Save Scalars = Logical True" to the boundary you want info about. This way SPLmean.dat will contain the wanted data.
  • Add the Result Output solver to export all the goodies:

    Code: Select all

    Solver 3
      Equation = Result Output
      Procedure = "ResultOutputSolve" "ResultOutputSolver"
      Save Geometry Ids = True
      Output File Name = case
      Output Format = Vtu
      Save Linear Elements = True
      Exec Solver = After Simulation
    End
    
Now I will try to improve it with a nice SPL UDF.
CrocoDuck
Posts: 79
Joined: 12 May 2016, 13:15
Antispam: Yes

Re: Vtu export fails

Post by CrocoDuck »

Hi there! I am back to this problem. I am trying to improve it with an UDF. Here what I wrote:

Code: Select all

!-------------------------------------------------------------------------------
!> File: AcousticsHelpers.f90
!> Written by: ST, 23 May 2016
!> Modified by: -
!-------------------------------------------------------------------------------
FUNCTION SPLCalc(Model, n, f) RESULT(g)
	USE DefUtils
	TYPE(Model_t) :: Model
	INTEGER :: n
	REAL(KIND=dp) :: f, g
	
	g = 20 * log10((sqrt(f(1)**2 + f(2)**2)) / (0.00002 * sqrt(2.0)))
	
END FUNCTION SPLCalc
Compilation:

Code: Select all

elmerf90 -o AcousticsHelpers.so AcousticsHelpers.f90
no errors.

Installation:

Code: Select all

cp AcousticsHelpers.so /usr/local/opt/elmer/share/elmersolver/lib/AcousticsHelpers.dylib
Called with:

Code: Select all

Body Force 1
  Name = "SPL Calc"
  SPL = Variable Pressure Wave 1, Pressure Wave 2
      Real Procedure "AcousticsHelpers" "SPLCalc"
End
The problem is that when the function is called (apparently) elmersolver kinda crashes without error messages. What I am doing wrong?
CrocoDuck
Posts: 79
Joined: 12 May 2016, 13:15
Antispam: Yes

Re: Vtu export fails

Post by CrocoDuck »

Ok, this seems to work but with very different results from the MATC expression:

Code: Select all

FUNCTION SPLCalcIGN(Model, n, f, h) RESULT(g)
   USE DefUtils
   TYPE(Model_t) :: Model
   INTEGER :: n
   REAL(KIND=dp) :: f, h, g
   
   g = 20 * log10((sqrt(f**2 + h**2)) / (0.00002 * sqrt(2.0)))
   
END FUNCTION SPLCalcIGN
Not really sure about what's happening...

EDIT: By having a look with paraview the results from SPLCalcIGN are super - wrong, while the MATC are spot on...
Last edited by CrocoDuck on 23 May 2016, 14:48, edited 1 time in total.
Post Reply