How to display an additional field variable?

Post processing utility for Elmer
Post Reply
petroo
Posts: 148
Joined: 13 Jan 2010, 19:07
Location: Aachen, Germany

How to display an additional field variable?

Post by petroo »

Hello Elmerers,

I (re-)define the material property "density" for a fluid that represents a mixture of a viscous liquid with small amounts of immersed air bubbles.
This is done by a MATC statement:

Code: Select all

Material 1
   ...
  Density = Variable Pressure
    Real MATC "max(0.0001 866/(1+0.09*(1/tx)))"
  Compressibility Model = User Defined
  Viscosity = 20.0e-6
End
After performing the simulation I'd like to check the density as a new field variable in ElmerPost. But it is not appearing there as a parameter of choice to be displayed in mesh display.

In a certain approximation to the Tutorials Book, pp. 70 and 109f I tried to convince the solver to add the density to the list of inspectable values by the following declaration:

Code: Select all

Solver 1
  Equation = Navier-Stokes
  !
  Variable = String "Density"
  Variable DOFs = 1
  ...
End
But appearently this method did not yield the desired effect: The density is not shown as a selectable ElmerPost parameter.

So, how to do it correctly, please?

Regards,

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

Re: How to display an additional field variable?

Post by raback »

Hi Peter

You could check the SaveMaterials solver (included in the SaveData module) for the purpose. See Models Manual for more details.

-Peter
petroo
Posts: 148
Joined: 13 Jan 2010, 19:07
Location: Aachen, Germany

Re: How to display an additional field variable?

Post by petroo »

Hi Peter,
raback wrote:You could check the SaveMaterials solver (included in the SaveData module) for the purpose. See Models Manual for more details.r
Did it, but presumably wrong:

Referring to the Models Manual, p. 155, I entered the following solver:

Code: Select all

Solver 2
  Exec Solver = after timestep
  Procedure File "SaveData" "SaveMaterials"
  Parameter 1 String Density
End
The Density is defined in the "Material 1" as given above in my first posting.

Starting the Simulation the following error is returned:

MAIN: ==========================================
MAIN: E L M E R S O L V E R S T A R T I N G
MAIN: Library version: 6.1 (Rev: 4678)
MAIN: Running in parallel using 4 tasks.
MAIN: HYPRE library linked in.
MAIN: ==========================================
MAIN:
MAIN:
MAIN: -----------------------
MAIN: Reading Model ...
ERROR:: Model Input:
ERROR:: Model Input: Unknown specifier: [parameter 1 string density]
ERROR:: Model Input: In section: [solver 2]
ERROR:: Model Input: For property name:[procedure file SaveData SaveMaterials]
ERROR:: Model Input:
ERROR:: Model Input: Unknown specifier: [parameter 1 string density]
ERROR:: Model Input: In section: [solver 2]
ERROR:: Model Input: For property name:[procedure file SaveData SaveMaterials]
ERROR:: Model Input:
ERROR:: Model Input: Unknown specifier: [parameter 1 string density]
ERROR:: Model Input: In section: [solver 2]
ERROR:: Model Input: For property name:[procedure file SaveData SaveMaterials]
--------------------------------------------------------------------------
mpirun has exited due to process rank 2 with PID 15782 on


I guess there is some dumb error in my definitions. :roll:
The tutorials do not mention the SaveMaterials solver, so there is no cheating support. :)

Regards,

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

Re: How to display an additional field variable?

Post by raback »

Hi Peter

The Models Manual has the convention that in the keyword definition the separator '=' is dropped. So the correct way looks more like

Code: Select all

Solver 2
  Exec Solver = after timestep
  Procedure = File "SaveData" "SaveMaterials"
  Parameter 1 = String Density
End
-Peter
petroo
Posts: 148
Joined: 13 Jan 2010, 19:07
Location: Aachen, Germany

Re: How to display an additional field variable?

Post by petroo »

Hello Peter,

I changed the definitions according to your suggestion, and the simulation starts - hoorray! :D

But right at the beginning the solver log window already fusses around:

...
MAIN: Reading Model ...
Model Input: Unlisted keyword: [parameter 1] in section: [solver 2]
Model Input: Unlisted keyword: [save materials] in section: [material 1]
Loading user function library: [SaveData]...[SaveMaterials_Init0]
MAIN: Done
MAIN: -----------------------
WARNING:: AddEquation: Time stepping method defaulted to IMPLICIT EULER
WARNING:: AddEquation: Time stepping method defaulted to IMPLICIT EULER
WARNING:: AddEquation: Time stepping method defaulted to IMPLICIT EULER
WARNING:: AddEquation: Time stepping method defaulted to IMPLICIT EULER
OptimizeBandwidth: ---------------------------------------------------------
OptimizeBandwidth: Computing matrix structure for: navier-stokes...done.
OptimizeBandwidth: Half bandwidth without optimization: 37955
OptimizeBandwidth:
OptimizeBandwidth: Bandwidth Optimization ...done.
OptimizeBandwidth: Half bandwidth after optimization: 1166
OptimizeBandwidth: ---------------------------------------------------------
WARNING:: AddEquation: Time stepping method defaulted to IMPLICIT EULER
WARNING:: ListFind:
WARNING:: ListFind: Requested property: [Equation], not found
WARNING:: ListFind:
Loading user function library: [SaveData]...[SaveMaterials_Init]
...


After that the first timestep seems to be calculated, but the simulation stops after writing the results of the first step with the following message:

...
SaveMaterials: Saving selected parameters as dofs
SaveMaterials: Parameter 1: density
SaveMaterials: All done
WriteToPost: Saving results in ElmerPost format to file ./case.ep.0
MAIN:
MAIN: -------------------------------------
MAIN: Time: 2/40 2.0000000000000000
MAIN: Estimated time left: 4 hours.
MAIN: -------------------------------------
MAIN:
SolveEquations: -------------------------------------
SolveEquations: Coupled system iteration: 1
SolveEquations: -------------------------------------
FlowSolve:
FlowSolve:
FlowSolve: -------------------------------------
FlowSolve: NAVIER-STOKES ITERATION 1
FlowSolve: -------------------------------------
FlowSolve:
FlowSolve: Starting Assembly...
[quad:16976] *** Process received signal ***
[quad:16976] Signal: Segmentation fault (11)
[quad:16976] Signal code: Address not mapped (1)
[quad:16976] Failing at address: (nil)
[quad:16976] [ 0] /lib/libpthread.so.0(+0xf8f0) [0x7f8f222c08f0]
[quad:16976] [ 1] /opt/elmer10/lib/libelmersolver-6.1.so(flowsolver_+0x743b) [0x7f8f23f11bc4]
[quad:16976] [ 2] /opt/elmer10/lib/libelmersolver-6.1.so(+0x14ab02) [0x7f8f23f6cb02]
[quad:16976] [ 3] /opt/elmer10/lib/libelmersolver-6.1.so(execsolver_+0x42) [0x7f8f23f6cb4b]
[quad:16976] [ 4] /opt/elmer10/lib/libelmersolver-6.1.so(__mainutils_MOD_singlesolver+0x67b) [0x7f8f23fc4dd8]
[quad:16976] [ 5] /opt/elmer10/lib/libelmersolver-6.1.so(__mainutils_MOD_solveractivate+0x43a) [0x7f8f23fc5234]
[quad:16976] [ 6] /opt/elmer10/lib/libelmersolver-6.1.so(__mainutils_MOD_solveequations+0x1983) [0x7f8f23fc6c0b]
[quad:16976] [ 7] /opt/elmer10/lib/libelmersolver-6.1.so(+0x27fabd) [0x7f8f240a1abd]
[quad:16976] [ 8] /opt/elmer10/lib/libelmersolver-6.1.so(elmersolver_+0x3079) [0x7f8f240a5a1f]
[quad:16976] [ 9] ElmerSolver_mpi(MAIN__+0xda) [0x40118e]
[quad:16976] [10] ElmerSolver_mpi(main+0x2a) [0x40153a]
[quad:16976] [11] /lib/libc.so.6(__libc_start_main+0xfd) [0x7f8f21f4cc4d]
[quad:16976] [12] ElmerSolver_mpi() [0x400ff9]
[quad:16976] *** End of error message ***
...


The density in fact appears in the list of displayable parameters in ElmerPost. In this respect the operation has succeeded indeed.

Just to give a complete picture of my setting, here is the complete sif file that is put to work:

Code: Select all

Header
  CHECK KEYWORDS Warn
  Mesh DB "." "."
  Include Path ""
  Results Directory ""
End

Simulation
  Max Output Level = 4
  Coordinate System = Cartesian
  Coordinate Mapping(3) = 1 2 3
  !Coordinate Scaling(3) = Real 2.5 2.5 2.5
  Simulation Type = Transient
  Output Intervals(2) = 1 1
  Timestep intervals(2) = 20 20
  Timestep Sizes(2) = 1 1
  Steady State Max Iterations = 20
  Solver Input File = case.sif
  Post File = case.ep
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
  Name = "Body 1"
  Equation = 1
  Material = 1
  Initial condition = 1
End

Solver 1
  Equation = Navier-Stokes
  !
  Variable = String "Density"
  Variable DOFs = 1
  Variable = Flow Solution[Velocity:3 Pressure:1]
  Bubbles = False
  !
  Stabilize = True
  Steady State Convergence Tolerance = 1.0e-5
  Nonlinear System Convergence Tolerance = 1.0e-4
  Nonlinear System Max Iterations = 10
  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-5
  Linear System Preconditioning = ILU2
  Linear System Residual Output = 1
End

Solver 2
  Exec Solver = after timestep
  Procedure = File "SaveData" "SaveMaterials"
  Parameter 1 = String Density
End

Equation 1
  Name = "NS"
  NS Convect = False
  Active Solvers(2) = 1 2
End

Initial Condition 1
  Name = "Anfangsdruck"
  Velocity 2 = 0
  Velocity 1 = 0
  Pressure = 100000
End

Material 1
  Name = "Lubricant oil (coarse values)"
  Heat Conductivity = 0.128
  Reference Temperature = 293
  Heat Capacity = 2093
  !Density = Variable Pressure
  !  Real
  !  -500000  0.01
  !  0        0.01
  !  500      0.77
  !  100000   0.86
  !  1000000  0.86
  !  End
  Density = Variable Pressure
    Real MATC "max(0.0001 866/(1+0.09*(1/tx)))"
  Compressibility Model = User Defined
  Save Materials = Logical true
  Viscosity = 20.0e-3
  !Viscosity = 20.0e-6
End

Boundary Condition 1
  Target Boundaries(1) = 2
  Name = "Einlass"
  !External Pressure = Variable Time;  MATC "-100000 - 900000*tx"
  External Pressure = Variable Time
    Real
    -1 -2000000
    0  -3000000
    10 -13000000
    40 -43000000
    End
  Velocity 1 = 0
  Velocity 2 = 0
End

Boundary Condition 2
  Target Boundaries(5) = 3 4 5 7 8
  Name = "ruhende Waende"
  !Noslip wall BC = on
  Velocity 1 = 0
  Velocity 2 = 0
  Velocity 3 = 0
End

Boundary Condition 3
  Target Boundaries(1) = 9
  Name = "Auslass"
  !External Pressure = Variable Time;  MATC "-1000  - 1000*tx"
  External Pressure = -100000
  Velocity 1 = 0
  Velocity 2 = 0
End
What is wrong with it, please? Is the SaveMaterials solver compatible with parallel execution?

Kind regards,

Peter
tzwinger
Site Admin
Posts: 99
Joined: 24 Aug 2009, 12:20
Antispam: Yes

Re: How to display an additional field variable?

Post by tzwinger »

Dear Peter,
I could reply your error with a different, but similar case. When I drop the SaveMaterials (Exec Solver = Never), the run survives. Can you confirm that this is also the case for you?
I checked with a debugger, but actually did not find an issue directly in SaveMaterials. Will try to have a closer look.

mfG,

Thomas
tzwinger
Site Admin
Posts: 99
Joined: 24 Aug 2009, 12:20
Antispam: Yes

Re: How to display an additional field variable?

Post by tzwinger »

Dear Peter,
Apparently things go wrong if a variable with the name Density is added by SaveMaterials. I have the suspicion that this is connected to the fact that Density is in the Elmer keyword database (hence a reserved name). If you give it another name, like for instance Dichte, and simply assign in the Material section the same value to it

Code: Select all

 Density = Variable Pressure
    Real MATC "max(0.0001 866/(1+0.09*(1/tx)))"
 Dichte = Variable Pressure
    Real MATC "max(0.0001 866/(1+0.09*(1/tx)))"
then you can display Dichte as a variable and - neither in serial nor parallel - the run gets a segfault.

Best regards,

Thomas
petroo
Posts: 148
Joined: 13 Jan 2010, 19:07
Location: Aachen, Germany

Re: How to display an additional field variable?

Post by petroo »

Hello Thomas,

yes, I confirm your method! Thanks a lot!

Although, I think it is still somewhat queer that the density by itself cannot be saved, and needs a duplication of otherwise identical definition code.

Kind regards,

Peter
Juha
Site Admin
Posts: 357
Joined: 21 Aug 2009, 15:11

Re: How to display an additional field variable?

Post by Juha »

Hi,

>though, I think it is still somewhat queer that the density by itself cannot be saved, and needs a duplication
>of otherwise identical definition code.

This is because the "User defined" compressibility model uses either field variable 'density',
if present, or the material defintion of density. The former should also have values
stored from previous timesteps, which is not true for the SaveMaterials() created density
field variable, hence the core dump.

Juha
Post Reply