Linear Options not recognized in WhitneyAVSolver

Numerical methods and mathematical models of Elmer
Post Reply
edge025
Posts: 18
Joined: 27 Apr 2019, 08:48
Antispam: Yes

Linear Options not recognized in WhitneyAVSolver

Post by edge025 » 29 Aug 2019, 23:30

I am running WhitneyAVSolver and I see that it appears to run 2 different solver routines. The issue is with the first one....How can I get it to do more iterations than 1000? How can I change the preconditioner from ILU0?

Below are part of sif file and first part of output

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

Simulation
Max Output Level = 5
Coordinate System = Cartesian
Coordinate Mapping(3) = 1 2 3
Coordinate Scaling = 0.0254
Simulation Type = Steady state
Steady State Max Iterations = 1
Output Intervals = 1
Timestepping Method = BDF
BDF Order = 1
Solver Input File = master.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

Solver 1
Exec Solver = Before Simulation
Equation = "CoilSolver"
Procedure = "CoilSolver" "CoilSolver"

Linear System Solver = Iterative
Linear System Preconditioning = ilu2
Linear System Max Iterations = 10000
Linear System Convergence Tolerance = 1e-10
Linear System Iterative Method = BiCGStabL
Linear System Residual Output = 10
Steady State Convergence Tolerance = 1e-06
Optimize Bandwidth = False

Normalize Coil Current = Logical True
Nonlinear System Consistent Norm = Logical True
End

Solver 2
Equation = "WhitneySolver"
Procedure = "MagnetoDynamics" "WhitneyAVSolver"
Variable = AV
Linear System Solver = Iterative
Linear System Iterative Method = CG
Linear System Preconditioning = None
Linear System Convergence Tolerance = 1.0e-10
Linear System Max Iterations = 5000
Linear System Residual Output = 100
Linear System Abort Not Converged = False
Linear System Precondition Recompute = 1
Optimize Bandwidth = True
End

Solver 3
Equation = MagnetoDynamicsCalcFields
Procedure = "MagnetoDynamics" "MagnetoDynamicsCalcFields"
Potential Variable = String "AV"
Calculate Magnetic Vector Potential = Logical True
Calculate Magnetic Flux Density = Logical True
Calculate Magnetic Field Strength = Logical True
Calculate Electric Field = Logical True
Calculate Current Density = Logical True
Calculate Magnetic Flux Density = Logical True
Calculate Nodal Fields = Logical True
Calculate Elemental Fields = Logical True
calculate nodal forces = logical true
Optimize Bandwidth = True
Linear System Solver = Iterative
Linear System Iterative Method = BiCGStab
Linear System Max Iterations = 500
Linear System Convergence Tolerance = 1.0e-10
Linear System Preconditioning = ILU0
Linear System Abort Not Converged = False
Linear System Residual Output = 1
Linear System Precondition Recompute = 1
End
Solver 4
Equation = Result Output
Procedure = "ResultOutputSolve" "ResultOutputSolver"
Output File Name = case
Binary Output = False
Output Format = Vtu
Exec Solver = after all
End
Solver 5 ! savescalars
Equation = "Savedata"
Procedure = "SaveData" "SaveScalars"
filename = "case.dat"
save component results = logical true
End

Equation 1
Name = "Equation"
Active Solvers(3) = 2 3 4
End
Equation 2
Name = "Equation for Coils"
Active Solvers(4) = 1 2 3 4
End

Component 1
Name = string "Load"
Master Bodies(1) = integer 6
calculate magnetic force = logical true
End
Component 2
Name = String "CoilA"
Coil Type = String "test"
Master Bodies(1) = Integer 4
Desired Coil Current = Real 11247
End
Component 3
Name = String "CoilB"
Coil Type = String "test"
Master Bodies(1) = Integer 5
Desired Coil Current = Real 11247
End

Include master-Materials.sif
Include master-Bodies.sif
Include master-Body Forces.sif
Include master-BCs.sif

OUTPUT
==================================================
ELMER SOLVER (v 8.4) STARTED AT: 2019/08/29 16:26:00
ParCommInit: Initialize #PEs: 1
MAIN:
MAIN: =============================================================
MAIN: ElmerSolver finite element software, Welcome!
MAIN: This program is free software licensed under (L)GPL
MAIN: Copyright 1st April 1995 - , CSC - IT Center for Science Ltd.
MAIN: Webpage http://www.csc.fi/elmer, Email elmeradm@csc.fi
MAIN: Version: 8.4 (Rev: unknown, Compiled: 2019-08-28)
MAIN: Running one task without MPI parallelization.
MAIN: Running with just one thread per task.
MAIN: HYPRE library linked in.
MAIN: MUMPS library linked in.
MAIN: =============================================================
MAIN:
MAIN:
MAIN: -------------------------------------
MAIN: Reading Model: master.sif
LoadInputFile: Scanning input file: master.sif
OpenIncludeFile: Trying to include file: master-Materials.sif
OpenIncludeFile: Trying to include file: master-Bodies.sif
OpenIncludeFile: Trying to include file: master-Body Forces.sif
OpenIncludeFile: Trying to include file: master-BCs.sif
LoadInputFile: Loading input file: master.sif
OpenIncludeFile: Trying to include file: master-Materials.sif
OpenIncludeFile: Trying to include file: master-Bodies.sif
OpenIncludeFile: Trying to include file: master-Body Forces.sif
OpenIncludeFile: Trying to include file: master-BCs.sif
Loading user function library: [CoilSolver]...[CoilSolver_Init0]
Loading user function library: [MagnetoDynamics]...[WhitneyAVSolver_Init0]
Loading user function library: [MagnetoDynamics]...[MagnetoDynamicsCalcFields_Init0]
Loading user function library: [ResultOutputSolve]...[ResultOutputSolver_Init0]
Loading user function library: [SaveData]...[SaveScalars_Init0]
LoadMesh: Base mesh name: ./.
LoadMesh: Scaling coordinates: 2.540E-02 2.540E-02 2.540E-02
LoadMesh: Elapsed REAL time: 18.2707 (s)
MAIN: -------------------------------------
Loading user function library: [CoilSolver]...[CoilSolver_Init]
Loading user function library: [CoilSolver]...[CoilSolver_bulk]
Loading user function library: [CoilSolver]...[CoilSolver]
OptimizeBandwidth: ---------------------------------------------------------
OptimizeBandwidth: Computing matrix structure for: coilsolver...done.
OptimizeBandwidth: Half bandwidth without optimization: 8209
OptimizeBandwidth: ---------------------------------------------------------
Loading user function library: [MagnetoDynamics]...[WhitneyAVSolver_Init]
Loading user function library: [MagnetoDynamics]...[WhitneyAVSolver_bulk]
Loading user function library: [MagnetoDynamics]...[WhitneyAVSolver]
OptimizeBandwidth: ---------------------------------------------------------
OptimizeBandwidth: Computing matrix structure for: whitneysolver...done.
OptimizeBandwidth: Half bandwidth without optimization: 1805657
OptimizeBandwidth:
OptimizeBandwidth: Bandwidth Optimization ...done.
OptimizeBandwidth: Half bandwidth after optimization: 37271
OptimizeBandwidth: ---------------------------------------------------------
Loading user function library: [MagnetoDynamics]...[MagnetoDynamicsCalcFields_Init]
Loading user function library: [MagnetoDynamics]...[MagnetoDynamicsCalcFields_bulk]
Loading user function library: [MagnetoDynamics]...[MagnetoDynamicsCalcFields]
OptimizeBandwidth: ---------------------------------------------------------
OptimizeBandwidth: Computing matrix structure for: magnetodynamicscalcfields...done.
OptimizeBandwidth: Half bandwidth without optimization: 267268
OptimizeBandwidth:
OptimizeBandwidth: Bandwidth Optimization ...done.
OptimizeBandwidth: Half bandwidth after optimization: 8261
OptimizeBandwidth: ---------------------------------------------------------
Loading user function library: [ResultOutputSolve]...[ResultOutputSolver_Init]
Loading user function library: [ResultOutputSolve]...[ResultOutputSolver_bulk]
Loading user function library: [ResultOutputSolve]...[ResultOutputSolver]
Loading user function library: [SaveData]...[SaveScalars_Init]
Loading user function library: [SaveData]...[SaveScalars_bulk]
Loading user function library: [SaveData]...[SaveScalars]
SingleSolver: Attempting to call solver
SingleSolver: Solver Equation string is: coilsolver
CoilSolver: --------------------------------------
CoilSolver: Solving current distribution in a coil
CoilSolver: --------------------------------------
CoilSolver: Set1 : 297 +nodes and 301 -nodes
CoilSolver: Computing the dummy potential field
DefaultFinishBulkAssembly: Saving bulk values for: coilsolver
DefUtils::DefaultDirichletBCs: Setting Dirichlet boundary conditions
DefUtils::DefaultDirichletBCs: Dirichlet boundary conditions set
CRS_IncompleteLU: ILU(2) (Real), Starting Factorization:
CRS_IncompleLU: Recursive round: 1
CRS_IncompleteLU: ILU(2) (Real), NOF nonzeros: 1792567
CRS_IncompleteLU: ILU(2) (Real), filling (%) : 856
CRS_IncompleteLU: ILU(2) (Real), Factorization ready at (s): 0.98
17 0.2623E-10 0.2623E-10
ComputeChange: NS (ITER=1) (NRM,RELC): ( 0.58491950 2.0000000 ) :: coilsolver
CoilSolver: Initial coil current for coil 1: 6.3754E+05
CoilSolver: Coil potential multiplier: 1.7641E-02
CoilSolver: Initial coil current for coil 2: 6.3753E+05
CoilSolver: Coil potential multiplier: 1.7642E-02
CRS_IncompleteLU: ILU(2) (Real), Starting Factorization:
CRS_IncompleteLU: ILU(2) (Real), NOF nonzeros: 1792567
CRS_IncompleteLU: ILU(2) (Real), filling (%) : 856
CRS_IncompleteLU: ILU(2) (Real), Factorization ready at (s): 0.48
1 0.5930E-10 0.5930E-10
CRS_IncompleteLU: ILU(2) (Real), Starting Factorization:
CRS_IncompleteLU: ILU(2) (Real), NOF nonzeros: 1792567
CRS_IncompleteLU: ILU(2) (Real), filling (%) : 856
CRS_IncompleteLU: ILU(2) (Real), Factorization ready at (s): 0.48
2 0.6056E-12 0.6056E-12
CRS_IncompleteLU: ILU(2) (Real), Starting Factorization:
CRS_IncompleteLU: ILU(2) (Real), NOF nonzeros: 1792567
CRS_IncompleteLU: ILU(2) (Real), filling (%) : 856
CRS_IncompleteLU: ILU(2) (Real), Factorization ready at (s): 0.49
2 0.4711E-10 0.4711E-10
CoilSolver: Normalizing current density to a constant value
CoilSolver: Average current density: 1.8749E+06
CoilSolver: Average current density: 1.8749E+06
CoilSolver: --------------------------------------
Loading user function library: [CoilSolver]...[CoilSolver_post]
MAIN:
MAIN: -------------------------------------
MAIN: Steady state iteration: 1
MAIN: -------------------------------------
MAIN:
SingleSolver: Attempting to call solver
SingleSolver: Solver Equation string is: whitneysolver
WhitneyAVSolver: Solving the AV equations with edge elements
OptimizeBandwidth: ---------------------------------------------------------
OptimizeBandwidth: Computing matrix structure for: whitneysolver...done.
OptimizeBandwidth: Half bandwidth without optimization: 267268
OptimizeBandwidth:
OptimizeBandwidth: Bandwidth Optimization ...done.
OptimizeBandwidth: Half bandwidth after optimization: 8261
OptimizeBandwidth: ---------------------------------------------------------
DefUtils::DefaultDirichletBCs: Setting Dirichlet boundary conditions
DefUtils::DefaultDirichletBCs: Dirichlet boundary conditions set
CRS_IncompleteLU: ILU(0) (Real), Starting Factorization:
CRS_IncompleteLU: ILU(0) (Real), NOF nonzeros: 3884191
CRS_IncompleteLU: ILU(0) (Real), filling (%) : 100
CRS_IncompleteLU: ILU(0) (Real), Factorization ready at (s): 0.14
20 0.2942E-01
40 0.2139E-01
60 0.2206E-01
80 0.3023E-01
100 0.1235E-01
120 0.1099E-01
140 0.7863E-02
160 0.6969E-02
180 0.5136E-02
200 0.4738E-02
220 0.4402E-02
240 0.3607E-02
260 0.3194E-02
280 0.7174E-02
300 0.1446E-01
320 0.3093E-02
340 0.2406E-02
360 0.2120E-02
380 0.2037E-02
400 0.2241E-02
420 0.2059E-02
440 0.2316E-02
460 0.1911E-02
480 0.1971E-02
500 0.1798E-02
520 0.1809E-02
540 0.1945E-02
560 0.1784E-02
580 0.2033E-02
600 0.2058E-02
620 0.2064E-02
640 0.2123E-02
660 0.2210E-02
680 0.2085E-02
700 0.2173E-02
720 0.2035E-02
740 0.1870E-02
760 0.1899E-02
780 0.1862E-02
800 0.1620E-01
820 0.1428E-02
840 0.1584E-02
860 0.1178E-02
880 0.4434E-02
900 0.1427E-02
920 0.1046E-02
940 0.1034E-02
960 0.9931E-03
980 0.9461E-03
1000 0.9111E-03
1001 0.9111E-03
WARNING:: IterSolve: Numerical Error: Too many iterations were needed.
MGDynAssembly: Elapsed REAL time: 107.1919 (s)
DefUtils::DefaultDirichletBCs: Setting Dirichlet boundary conditions
DefUtils::DefaultDirichletBCs: Dirichlet boundary conditions set
100 0.5365E+01
200 0.3076E+01
300 0.1874E+01
400 0.1459E+01
500 0.8193E+00

edge025
Posts: 18
Joined: 27 Apr 2019, 08:48
Antispam: Yes

Re: Linear Options not recognized in WhitneyAVSolver

Post by edge025 » 30 Aug 2019, 17:53

Ok, started poking around at this a little more. After reading a little, I increased the output level in the SIF file and saw that this solver appears to be the JfixPotentialSolver. Will fool around with this a little more and report back. Any help would be appreciated. Thanks

Regards,
Joe

edge025
Posts: 18
Joined: 27 Apr 2019, 08:48
Antispam: Yes

Re: Linear Options not recognized in WhitneyAVSolver

Post by edge025 » 30 Aug 2019, 18:33

Yay! Got this to work after poking around in JfixPotentialSolver.F90 and WhitneyAVSolver.F90 source files. I noticed this in the JFix file

IF( .NOT. ASSOCIATED(jfixPot)) THEN
ALLOCATE(Perm(SIZE(Solver % Variable % Perm)))
Perm = 0
Equation=GetString(SolverParams,'Equation',Found)

! Add default strategies for Jfix solver
! The AV equation typically prefers different ones.
IF(.NOT.Visited) THEN
CALL ListAddNewString(SolverParams,'Jfix: Linear System Solver', 'Iterative')
CALL ListAddNewInteger(SolverParams,'Jfix: Linear System Max Iterations', 1000 )
CALL ListAddNewString(SolverParams,'Jfix: Linear System Iterative Method', 'BiCGStab')
CALL ListAddNewLogical(SolverParams,'Jfix: Linear System Use HYPRE', .FALSE.)
CALL ListAddNewLogical(SolverParams,'Jfix: Use Global Mass Matrix',.FALSE.)
CALL ListAddNewString(SolverParams,'Jfix: Linear System Preconditioning', 'Ilu')
CALL ListAddNewConstReal(SolverParams,'Jfix: Linear System Convergence Tolerance', &
0.001_dp*GetCReal(SolverParams,'Linear System Convergence Tolerance', Found))
CALL ListAddNewLogical(SolverParams,'Jfix: Skip Compute Nonlinear Change',.TRUE.)
CALL ListAddNewLogical(SolverParams,'Jfix: Nonlinear System Consistent Norm',.TRUE.)
CALL ListAddNewInteger(SolverParams,'Jfix: Linear System Residual Output',20)
CALL ListAddNewString(SolverParams,'Jfix: Nonlinear System Convergence Measure','Norm')
CALL ListAddNewLogical(SolverParams,'Jfix: Linear System Complex',.FALSE.)
CALL ListAddNewLogical(SolverParams,'Jfix: Apply Conforming BCs',.FALSE.)

n=SIZE(Solver % Def_Dofs,1)
m=SIZE(Solver % Def_Dofs,2)
k=SIZE(Solver % Def_Dofs,3)
ALLOCATE(Def_Dofs(n,m,k))
Def_Dofs = Solver % Def_Dofs
END IF

So I made Solver 2 in the SIF look like this and it worked! Hurray for open source!

Solver 2
Equation = "WhitneySolver"
Procedure = "MagnetoDynamics" "WhitneyAVSolver"
Variable = AV
Linear System Solver = Iterative
Linear System Iterative Method = CG
Linear System Preconditioning = None
Linear System Convergence Tolerance = 1.0e-10
Linear System Max Iterations = 5000
Linear System Residual Output = 100
Linear System Abort Not Converged = False
Linear System Precondition Recompute = 1
Optimize Bandwidth = True

Jfix: Linear System Solver = Iterative
Jfix: Linear System Iterative Method = bicgstab
Jfix: Linear System Preconditioning = ILU1
Jfix: Linear System Convergence Tolerance = 1.0e-10
Jfix: Linear System Max Iterations = 5000
Jfix: Linear System Residual Output = 100
Jfix: Linear System Abort Not Converged = False
Jfix: Linear System Precondition Recompute = 1
Jfix: Optimize Bandwidth = True
End

Hope this is helpful to others.

Regards,
Joe

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

Re: Linear Options not recognized in WhitneyAVSolver

Post by raback » 06 Sep 2019, 12:42

Hi

Yes, some solvers use the feature of namespace when you have to combine different linear solver strategies (or material parameters etc.) in one simulation. Another example is block preconditioning where different setting may be needed for different blocks in the linear system. Then the namespace is set to be "block11:".

The Jfix potential is needed to set the current source to be divergence free. The equation is usually easy to solve and therefore the default settings are relatively cheap.

-Peter

Post Reply