"ExecSolver" Subroutine

Numerical methods and mathematical models of Elmer
udeng85
Posts: 45
Joined: 20 Sep 2010, 06:23

"ExecSolver" Subroutine

Post by udeng85 »

Hi all Elmer User,

I am a newbie in the ElmerSolver's coding and would like to pose a question regarding subroutine "SingleSolver" in MainUtils.f90. In subroutine "SingleSolver", it calls another subroutine called "ExecSolver". I've browsed through all the files in Elmer but still unable to locate the subroutine for this "ExecSolver" or executesolver. This leaves me with a dead end to my flowchart. From my understanding, "SingleSolver" as well as "ExecSolver" subroutine is usually needed to solve problems like e.g. heateq. Can anyone help me with this? Thanks you.

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

Re: "ExecSolver" Subroutine

Post by Juha »

Hi,

ElmerSolver uses dynamic loading (dlopen() for unix/linux/etc, LoadLibrary() for windows) of
specific equation solvers, boundary condition user functions, etc. This interface is not
usually available directly from Fortran, hence the c-interfaces in Load.c. The ExecSolver-routine
is an example. They are really just stubs for calling fortran procedures given the memory address
of the procedure ...

Regards, Juha
udeng85
Posts: 45
Joined: 20 Sep 2010, 06:23

Re: "ExecSolver" Subroutine

Post by udeng85 »

Hi Juha and all Elmer User,

How do I switch between Body 1(say fluid) and Body 2(structure) in the coding of Elmer. I've tried using "CASE (Element % BodyId)" and if the bodyid = 1, it's fluid? Is this correct?

-Aizat-
raback
Site Admin
Posts: 4832
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: "ExecSolver" Subroutine

Post by raback »

Hi

Body is a geometric entity and it has definitions for equation - a physical entity - which includes a list of active solvers.
In coding things are made easier by that each solver has the following fields

Code: Select all

Solver % NumberOfActiveElements
Solver % Elements()
and you just loop over them to get, for example

Code: Select all

Element => Solver % ActiveElements(i)
-Peter
udeng85
Posts: 45
Joined: 20 Sep 2010, 06:23

Re: "ExecSolver" Subroutine

Post by udeng85 »

Hi peter,

Thanks a lot for a prompt answer, but I do have a couple more questions:

1) If I were to model say two body in contact with each other but using the same solver "Navier-Stokes" is this the correct approach to my .sif file :-

Code: Select all

Body 1
  Equation = 1
  Material = 1
End           

Body 2
  Equation = 2
  Material = 2
End 
Equation 1
  Active Solvers = 1 
End

Equation 2
  Active Solvers = 1    
End

Solver 1                                                                                                                                                                                                                         
  Equation = Navier-Stokes                                                                                                                                                                                                   
  Stabilize = True                                                                                                                                                                                                               
  Linear System Solver = Iterative                                                                                                                                                                                               
  Linear System Iterative Method = BiCGStab                                                                                                                                                                                      
  Linear System Preconditioning = ILU1                                                                                                                                                                                           
  Linear System Max Iterations = 500                                                                                                                                                                                             
  Linear System Convergence Tolerance = 1.0e-6                                                                                                                                                                                   
  Nonlinear System Max Iterations = 10                                                                                                                                                                                           
  Nonlinear System Convergence Tolerance = 1.0e-3                                                                                                                                                                                
  Nonlinear System Newton After Tolerance = 1.0e-3                                                                                                                                                                               
  Nonlinear System Newton After Iterations = 20                                                                                                                                                                                  
  Nonlinear System Relaxation Factor = 1.0                                                                                                                                                                                       
  Steady State Convergence Tolerance = 1.0e-6                                                                                                                                                                                    
End 
or is it better to separate the "Navier-Stokes" solver to account for two different body(as shown below)?

Code: Select all

Body 1
  Equation = 1
  Material = 1
End           

Body 2
  Equation = 2
  Material = 2
End 

Equation 1
  Active Solvers = 1 
End

Equation 2
  Active Solvers = 2    
End

Solver 1                                                                                                                                                                                                                         
  Equation = Navier-Stokes                                                                                                                                                                                                   
  Stabilize = True                                                                                                                                                                                                               
  Linear System Solver = Iterative                                                                                                                                                                                               
  Linear System Iterative Method = BiCGStab                                                                                                                                                                                      
  Linear System Preconditioning = ILU1                                                                                                                                                                                           
  Linear System Max Iterations = 500                                                                                                                                                                                             
  Linear System Convergence Tolerance = 1.0e-6                                                                                                                                                                                   
  Nonlinear System Max Iterations = 10                                                                                                                                                                                           
  Nonlinear System Convergence Tolerance = 1.0e-3                                                                                                                                                                                
  Nonlinear System Newton After Tolerance = 1.0e-3                                                                                                                                                                               
  Nonlinear System Newton After Iterations = 20                                                                                                                                                                                  
  Nonlinear System Relaxation Factor = 1.0                                                                                                                                                                                       
  Steady State Convergence Tolerance = 1.0e-6                                                                                                                                                                                    
End 

Solver 2                                                                                                                                                                                                                         
  Equation = Navier-Stokes                                                                                                                                                                                                   
  Stabilize = True                                                                                                                                                                                                               
  Linear System Solver = Iterative                                                                                                                                                                                               
  Linear System Iterative Method = BiCGStab                                                                                                                                                                                      
  Linear System Preconditioning = ILU1                                                                                                                                                                                           
  Linear System Max Iterations = 500                                                                                                                                                                                             
  Linear System Convergence Tolerance = 1.0e-6                                                                                                                                                                                   
  Nonlinear System Max Iterations = 10                                                                                                                                                                                           
  Nonlinear System Convergence Tolerance = 1.0e-3                                                                                                                                                                                
  Nonlinear System Newton After Tolerance = 1.0e-3                                                                                                                                                                               
  Nonlinear System Newton After Iterations = 20                                                                                                                                                                                  
  Nonlinear System Relaxation Factor = 1.0                                                                                                                                                                                       
  Steady State Convergence Tolerance = 1.0e-6                                                                                                                                                                                    
End 
2) If I am not mistaken, the code FlowSolve.f90 produce an output variable FlowSol. It two bodies using the same "Navier-Stokes" equation as mentioned above is used, would it be better to use two FlowSol(i) or to differentiate between the two by using the code you have mentioned before(below), in which each body is associated to different FlowSol?

Code: Select all

Element => Solver % ActiveElements(i)
3) Navier-Stokes equation will produce result of Velocity and Pressure. How do I get value of Displacement from Velocity(FlowSolution)? Is there any integration procedure in Elmer that enables me to compute the displacement from velocity?


Sorry for a lengthy question but hope to hear the answer soon. Thank you.

-Aizat-
raback
Site Admin
Posts: 4832
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: "ExecSolver" Subroutine

Post by raback »

Hi

If you have the same physical equation that you want to solve in different bodies you should give them the same Equation definition. Of course there are rare accations when you want to solve, for example, two temperature fields which could be hierarchically coupled and for that aim you would need two instances of the HeatSolver, and therefore also separate Equation definitions for the two bodies. Then you would have to explicitely account for continuity by giving suitable BCs.

If you have coupling to elasticity you need to use another solver for that. A velocity and pressure do not result to displacements, they merely give forces which are used as boundary conditions in the elasticity solvers. There are some examples on fluid-stucture interaction among $ELMER_HOME/tests/fsi*

-Peter
udeng85
Posts: 45
Joined: 20 Sep 2010, 06:23

Re: "ExecSolver" Subroutine

Post by udeng85 »

Hi Peter and all Elmer User,

Thanks for the answer. If I were to include an extra component in the Navier Stokes formulation, namely displacement, from the existing pressure and velocity formulation on Navier-Stokes equation, can I just add an extra component to the existing variable FlowSolution(in MainUtil.f90,NavierStoke and FlowSolve) so that it would look a bit like this:

Code: Select all

Variable = FlowSolution [Velocity :3  Pressure:1  Displacement:3]


Is there any other place that requires changes in coding?

-Aizat-
raback
Site Admin
Posts: 4832
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: "ExecSolver" Subroutine

Post by raback »

Hi

Ok, so you want to make new monolithic solver for visco-elasticity, for example. Yes, you could decleare the variable as you describe. Then you should just make sure that you do assembly correctly for the the local matrix.

You don't need to refer to the variable in MainUtils at all. The references are just for backward compatibility from time when solvers were not dynamically loaded. You could also find more modern assembly routines in different solvers than the legacy FlowSolver that includes a great deal of various tricks.

-Peter
udeng85
Posts: 45
Joined: 20 Sep 2010, 06:23

Re: "ExecSolver" Subroutine

Post by udeng85 »

Hi Juha, Peter and all ElmerUser,

I'd like to pose another question on the selection of different bodies(or element associated with the body). Based on Juha's suggestion, the code should look a bit like below:

Code: Select all

1) Solver % NumberOfActiveElements
Solver % Elements()
or

Code: Select all

 2) Element => Solver % ActiveElements(i)
I am still not sure how to freely choose Model for different bodies without performing a loop(code 2 above). In the first code above, if the code is Solver % Element (1), does this mean that we are working with Body1?

I am trying to use the same equation for both Body1 and Body2; Body2 is viscoelastic material(which includes displacement) and Body1 is fluid. In order for me to do some alterations in the formulation(to include displacement just for Body 2)), it's required for me to know how to select only Body2. The question now is:

1) How do we select select just Body2?
2) Would this introduce a bit of confusion during compilation for both bodies?
3) Is it better to use different equations with inclusion of displacement for body2?

Thank you for your help..

-Aizat-
raback
Site Admin
Posts: 4832
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: "ExecSolver" Subroutine

Post by raback »

Hi,

In Elmer a body may have properties such as equation, initial condition, and body force. In the equation you define the active solvers and this information is used to deduce a list of active elements for each solver. Look for the programmers tutorial, Ch. 4, for example.
http://www.nic.funet.fi/pub/sci/physics ... torial.pdf

Now the difficulty of your case depends whether you want to 1) solve the different equations iteratively or 2) solve the different equations at the same time (monolithic approach). I think you are trying the second one but have parts where the physics is different. If it suffices for you to use the full matrix with just simplified physics in some regions you should be ok. This would be my recommendation as it also works in parallel.

However, if your ultimate goal is to have a number of dofs varying over different bodies and still solve them from the same matrix equation, you could try the CoupledSolver development path. There you can build any kinds of couplings with different kinds of contraints. The matrix topology is build during the first assembly which overcomes many of the limitations of the standard matrix treatment. This does not work in parallel yet. There are just a bunch of solvers in $ELMER_HOME/tests/CoupledSolver* This is probably not what you want but still it may be on option to do really non-standard coupling.

-Peter
Post Reply