Good afternoon Elmer community
I have dozens of questions on this topic whether I use standard solvers or designing new ones amd whether I deal with global variables or field variables. I cannot find the answers to them in the elmer solver manual. I am not sure how to start this thread but I will give it a try with say the field variable in AdvectionDiffusion.F90. Here is a snippet of the .sif file:
Equation 1
Name = "test"
Active Solvers(2) = 1 2
End
Solver 1
Equation = positive ion density
Procedure = "AdvectionDiffusion" "AdvectionDiffusionSolver"
Variable = Np
.......
End
Solver 2
Equation = electron density
Procedure = "AdvectionDiffusion" "AdvectionDiffusionSolver"
Variable = Ne
.......
End
Is ElmerSolver smart enough to allocate distinct memory space for field values associated to the Ne and Np string variables ?
If the answer is yes, then lets add the following to the same .sif file. Take note that my examples have no intended physical meaning whatsoever. I just want to know if they are programmatically correct. I hope ElmerSolver knows where to find the field variables when it encounters their corresponding string variables.
Body Force 1
VarName Diffusion Source real = Variable Np, Ne
Real MATC "2.0e-0*(tx(0)-tx(1)))"
End
Sincerely yours
Marc
Creating and passing variables
-
- Site Admin
- Posts: 4823
- Joined: 22 Aug 2009, 11:57
- Antispam: Yes
- Location: Espoo, Finland
- Contact:
Re: Creating and passing variables
Hi Marc
Yes, that's exactly how to do it. The possibility of Elmer to have unlimited number of Solvers and to have almost all Real valued keyword depend on any field variable is the basis of the multiphysics features set of Elmer.
Now there may be some local variables in the solvers that are not always reallocated. I looked at this particular solver and there you would run into problems if you would call it twice such that "Mesh % MaxElementNodes" would be too small for the 2nd calling. This could happen in some multimesh case...
Have fun!
-Peter
Yes, that's exactly how to do it. The possibility of Elmer to have unlimited number of Solvers and to have almost all Real valued keyword depend on any field variable is the basis of the multiphysics features set of Elmer.
Now there may be some local variables in the solvers that are not always reallocated. I looked at this particular solver and there you would run into problems if you would call it twice such that "Mesh % MaxElementNodes" would be too small for the 2nd calling. This could happen in some multimesh case...
Have fun!
-Peter
-
- Site Admin
- Posts: 4823
- Joined: 22 Aug 2009, 11:57
- Antispam: Yes
- Location: Espoo, Finland
- Contact:
Re: Creating and passing variables
For your purposes I might rather use the "ModelPDE" or some modern variants of it. It has everything in the same module and solver for generic advection-diffusion-reaction equation. -Peter
Re: Creating and passing variables
All that flexibility is great !
But I should have first read the programmer's tutorial before starting this thread. After all, for those who did not write the ElmerSolver code, it is still unclear how the information contained in the .sif file is structured when transferred to variables in memory to be used inside the solver subroutine. I also recommend the novice to peruse a few standard solvers.
At least now I know that Solver % Variable holds everything about the solver's field variable and you get its values by a pointer to
Solver % Variable % Values
and the name of the variable as given in the .sif file is obtained by calling
GetVarName( Solver % Variable)
Moreover,
Solver % Mesh % Variables
holds everything about other solvers field variables that are named for some solver in the .sif file. So for example, if some solver has a field variable named Temperature, then in another solver, one can access the temperature values by writing
Dummy => VariableGet( Solver % Mesh % Variables, 'Temperature' )
Savet => Dummy % Values
You can even read or write global values in the model. For example, as I found out in the elmer solver manual, you can read the current time:
TimeVar => VariableGet( Solver % Mesh % Variables, ’Time’ )
Time = TimeVar % Values(1)
Have a nice and long Labor Day weekend everybody!
Marc
But I should have first read the programmer's tutorial before starting this thread. After all, for those who did not write the ElmerSolver code, it is still unclear how the information contained in the .sif file is structured when transferred to variables in memory to be used inside the solver subroutine. I also recommend the novice to peruse a few standard solvers.
At least now I know that Solver % Variable holds everything about the solver's field variable and you get its values by a pointer to
Solver % Variable % Values
and the name of the variable as given in the .sif file is obtained by calling
GetVarName( Solver % Variable)
Moreover,
Solver % Mesh % Variables
holds everything about other solvers field variables that are named for some solver in the .sif file. So for example, if some solver has a field variable named Temperature, then in another solver, one can access the temperature values by writing
Dummy => VariableGet( Solver % Mesh % Variables, 'Temperature' )
Savet => Dummy % Values
You can even read or write global values in the model. For example, as I found out in the elmer solver manual, you can read the current time:
TimeVar => VariableGet( Solver % Mesh % Variables, ’Time’ )
Time = TimeVar % Values(1)
Have a nice and long Labor Day weekend everybody!
Marc