spis.Solver.Poisson
Class ConjGrad3DUnstructPoissonSolver

java.lang.Object
  extended byspis.Solver.Poisson.PoissonSolver
      extended byspis.Solver.Poisson.PotPoissonSolver
          extended byspis.Solver.Poisson.ConjGrad3DUnstructPoissonSolver

public class ConjGrad3DUnstructPoissonSolver
extends PotPoissonSolver

Class Name : ConjGrad3DUnstructPoissonSolver
Project ref : SPIS project
File name : ConjGrad3DUnstructPoissonSolver.java
File type : class
Copyright : ONERA, 2 Av. E. Belin, 31055 Toulouse cedex, France http://www.onecert.fr
Status : under development
Creation : 25/08/2003
Modification :

Description : Poisson solving through pre-conditioned conjugate gradient method.

Versions and anomalies correction :

Version numberAuthor (name, e-mail) Corrections/Modifications
0.1 JF Roussel, roussel@onecert.fr and D Volpert, volpert@cert.fr Creation


Version:
0.1
Author:
JF Roussel

Field Summary
private  int[] bandTab
          Matrices bandwith: bandTab[0] for preconditioning, bandTab[1] for Poisson matrix
private  int[] cellWire
          if 0 node of cell i is wire, cellWire[i] = 0 if 1 and only 1 node of cell i is wire, cellWire[i] = 1+local number of this node if more than 1 node of cell i is wire, cellWire[i] < 0
private  double[] densBuf
          Buffer for density
private  double[] diagMass
          Diagonal of the Mass matrix [nodeNb]
private  double[] diagPoisson
          Diagonal of the poisson matrix [nodeNb]
private  int[] dirichletFlag
          Dirichlet flag (it must be provided to the solver hence Dirichlet flag cannot be considered as a simple temporary buffer as fourierFlagBuf or other coeff and values
private  double[] dirichletPotBuf
          Buffer for Dirichlet fixed potential
private  double[] fourierAlphaBuf
          Buffer for Fourier alpha coefficient
private  int[] fourierFlagBuf
          Buffer for Fourier flag
private  double[] fourierValueBuf
          Buffer for Fourier non homogeneous value
private  int iterGradient
          max iteration number for linear solver
private  int iterGradientNl
          max iteration number for non-linear solver
private  int iterNewton
          max iteration number for Newton iterations in non-linear solver
private  float[] lenNodeWire
          lenNodeWire[i] is the distance of node i to the wire
private  double[] matMass
          Mass matrix (without the diagonal) [ndimMat]
private  double[] matPoisson
          Poisson matrix (without the diagonal) [ndimMat]
private  float[][] minusDrDn
          minusDrDn[i][j] is -dr/dn of node j of surface i, where r is the distance to the wire and n the normal of the surface i (pointing to the wire)
private  int ndimMat
          Number of non-zero out-of-diagonal element in this matrix profile
private  int[] nonZeroMat
          First table to store the shape of non null elements in Poisson matrix: pointer to matrix row (nonZeroMat[i] is the first element of row i)
private  int[] pointMat
          Second table to store the shape of non null elements in Poisson matrix: column index
private  double[] potBuf
          Buffer for potential
private  double[] precondPoisson
          Poisson pre-conditionner
private  double[] secMember
          Second member in Poisson linear system [nodeNb]
private  double tolGradient
          tolerance for linear solver
private  double tolGradientNl
          tolerance for non-linear solver
private  double tolNewton
          tolerance for Newton iterations in non-linear solver
private  ThreeDUnstructVolMesh vm
          pointer to the 3D unstruct vol mesh (redundant with vm stored at parent class level but vm is stored as VolMesh and its sub-type information is lost, which is not the case here)
private  int[] wireEdge
          wireEdge[i] is the index of the nearest edge of node i
 
Fields inherited from class spis.Solver.Poisson.PoissonSolver
bbc, bsm, elecDens, elecDens2, elecTemp, elecTemp2, linear, scbc, scsm
 
Constructor Summary
ConjGrad3DUnstructPoissonSolver(ThreeDUnstructVolMesh volMesh)
          Constructor with really minimum data, default boundary conditions will be:
- Dirichlet on spacecraft (fixed potential)
- Fourier at external boundaries (potentiel goes asymptotically to zero, within 1 meter)
Default data for non-linear solving are: dens = 10^11 #/m3, Te = 0.1eV.
ConjGrad3DUnstructPoissonSolver(ThreeDUnstructVolMesh volMesh, float ne, float Te, float ne2, float Te2, boolean linear)
          Constructor with little data, default boundary conditions will be:
- Dirichlet on spacecraft (fixed potential)
- Fourier at external boundaries (potentiel goes asymptotically to zero, within 1 meter with these pre-defined parameters)
ConjGrad3DUnstructPoissonSolver(ThreeDUnstructVolMesh volMesh, SurfMesh boundarySurfMesh, SurfMesh scSurfMesh, PoissonBC boundaryBC, PoissonBC scBC, float ne, float Te, float ne2, float Te2, boolean linear)
          Default constructor
 
Method Summary
private  void buildBC(PoissonBC bc)
          Updates buffered fourierFlagBuf, fourierAlphaBuf, fourierValueBuf, dirichletFlag, and dirichletPotBuf arrays from passed Poisson boundary condition
 void buildMatrices(int[] fourierFlag, double[] fourierAlpha, double[] fourierValue, int[] dirFlag, double[] dirichletPot)
          Builds all matrices (and second member vectors) needed to later
solve Poisson equation.
 int getIterGradient()
           
 int getIterGradientNl()
           
 int getIterNewton()
           
 double getTolGradient()
           
 double getTolGradientNl()
           
 double getTolNewton()
           
 void init()
          Initialises solver, which should be done only once at solver creation.
 void initFromBc()
          Builds all matrices (and second member vectors) needed to later
solve Poisson equation, needed each time BC are modified.
 void interpolatePotential(PointList pl, ScalVolField pot, FloatScalTable val)
          Interpolates the potential at each particle position: linear in regular tetrahedra, specific in tetrahedra next to a wire (contrarily to VolMesh interpolatePotential routine).
 void interpolatePotGradient(PointList pl, ScalVolField pot, VectTable val)
          Computes the potential gradient (minus the electric field) at each particle position: linear in regular tetrahedra, specific in tetrahedra next to a wire (contrarily to VolMesh computeGradient(...) routine.)
 void setIterGradient(int i)
           
 void setIterGradientNl(int i)
           
 void setIterNewton(int i)
           
 void setTolGradient(double d)
           
 void setTolGradientNl(double d)
           
 void setTolNewton(double d)
           
 void solveLinear(ScalVolField density, VectVolField E_)
          Solves Poisson equation.
 void solveNonLinear(ScalVolField density, VectVolField E_)
          Solves non-linearPoisson equation.
 
Methods inherited from class spis.Solver.Poisson.PotPoissonSolver
getAnalyticDens
 
Methods inherited from class spis.Solver.Poisson.PoissonSolver
getBbc, getBsm, getElecDens, getElecDens2, getElecTemp, getElecTemp2, getScbc, getScsm, getVm, isLinear, setElecDens, setElecDens2, setElecTemp, setElecTemp2, setLinear, setScPot, solve
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

vm

private ThreeDUnstructVolMesh vm
pointer to the 3D unstruct vol mesh (redundant with vm stored at parent class level but vm is stored as VolMesh and its sub-type information is lost, which is not the case here)


nonZeroMat

private int[] nonZeroMat
First table to store the shape of non null elements in Poisson matrix: pointer to matrix row (nonZeroMat[i] is the first element of row i)


pointMat

private int[] pointMat
Second table to store the shape of non null elements in Poisson matrix: column index


ndimMat

private int ndimMat
Number of non-zero out-of-diagonal element in this matrix profile


bandTab

private int[] bandTab
Matrices bandwith: bandTab[0] for preconditioning, bandTab[1] for Poisson matrix


diagMass

private double[] diagMass
Diagonal of the Mass matrix [nodeNb]


matMass

private double[] matMass
Mass matrix (without the diagonal) [ndimMat]


diagPoisson

private double[] diagPoisson
Diagonal of the poisson matrix [nodeNb]


matPoisson

private double[] matPoisson
Poisson matrix (without the diagonal) [ndimMat]


secMember

private double[] secMember
Second member in Poisson linear system [nodeNb]


precondPoisson

private double[] precondPoisson
Poisson pre-conditionner


dirichletFlag

private int[] dirichletFlag
Dirichlet flag (it must be provided to the solver hence Dirichlet flag cannot be considered as a simple temporary buffer as fourierFlagBuf or other coeff and values


fourierFlagBuf

private int[] fourierFlagBuf
Buffer for Fourier flag


fourierAlphaBuf

private double[] fourierAlphaBuf
Buffer for Fourier alpha coefficient


fourierValueBuf

private double[] fourierValueBuf
Buffer for Fourier non homogeneous value


dirichletPotBuf

private double[] dirichletPotBuf
Buffer for Dirichlet fixed potential


potBuf

private double[] potBuf
Buffer for potential


densBuf

private double[] densBuf
Buffer for density


cellWire

private int[] cellWire
if 0 node of cell i is wire, cellWire[i] = 0 if 1 and only 1 node of cell i is wire, cellWire[i] = 1+local number of this node if more than 1 node of cell i is wire, cellWire[i] < 0


wireEdge

private int[] wireEdge
wireEdge[i] is the index of the nearest edge of node i


minusDrDn

private float[][] minusDrDn
minusDrDn[i][j] is -dr/dn of node j of surface i, where r is the distance to the wire and n the normal of the surface i (pointing to the wire)


lenNodeWire

private float[] lenNodeWire
lenNodeWire[i] is the distance of node i to the wire


tolGradient

private double tolGradient
tolerance for linear solver


iterGradient

private int iterGradient
max iteration number for linear solver


tolGradientNl

private double tolGradientNl
tolerance for non-linear solver


iterGradientNl

private int iterGradientNl
max iteration number for non-linear solver


tolNewton

private double tolNewton
tolerance for Newton iterations in non-linear solver


iterNewton

private int iterNewton
max iteration number for Newton iterations in non-linear solver

Constructor Detail

ConjGrad3DUnstructPoissonSolver

public ConjGrad3DUnstructPoissonSolver(ThreeDUnstructVolMesh volMesh,
                                       SurfMesh boundarySurfMesh,
                                       SurfMesh scSurfMesh,
                                       PoissonBC boundaryBC,
                                       PoissonBC scBC,
                                       float ne,
                                       float Te,
                                       float ne2,
                                       float Te2,
                                       boolean linear)
Default constructor

Parameters:
volMesh - volume mesh
boundarySurfMesh - external boundary surface mesh
scSurfMesh - spacecraft surface mesh
boundaryBC - boundary conditions on external boundary
scBC - boundary conditions on spacecraft
ne - reference electron density (for non linear Poisson solver)
Te - reference electron temperature (for non linear Poisson solver)
linear - if true, linear solver will be used by default

ConjGrad3DUnstructPoissonSolver

public ConjGrad3DUnstructPoissonSolver(ThreeDUnstructVolMesh volMesh,
                                       float ne,
                                       float Te,
                                       float ne2,
                                       float Te2,
                                       boolean linear)
Constructor with little data, default boundary conditions will be:
- Dirichlet on spacecraft (fixed potential)
- Fourier at external boundaries (potentiel goes asymptotically to zero, within 1 meter with these pre-defined parameters)

Parameters:
volMesh - volume mesh (spacecraft and external boundary meshes are extracted from volMesh)
ne - reference electron density (for non linear Poisson solver)
Te - reference electron temperature (for non linear Poisson solver)
linear - linear solver selection by default?

ConjGrad3DUnstructPoissonSolver

public ConjGrad3DUnstructPoissonSolver(ThreeDUnstructVolMesh volMesh)
Constructor with really minimum data, default boundary conditions will be:
- Dirichlet on spacecraft (fixed potential)
- Fourier at external boundaries (potentiel goes asymptotically to zero, within 1 meter)
Default data for non-linear solving are: dens = 10^11 #/m3, Te = 0.1eV.
The default selectionned solver is linear Poisson

Parameters:
volMesh - volume mesh (spacecraft and external boundary meshes are extracted from volMesh)
Method Detail

init

public void init()
Initialises solver, which should be done only once at solver creation.
it mostly renumbers the nodes and determines Poisson matrix shape.
It also allocates arrays to store Poisson and Mass matrices, so that they do not need to be re-allocated at each matrix assembling,
which can be done repetitively, contrarily to this init.
These operations should certainly be done in the constructor, but it was preferred to separate for now (init() should be added in the
constructor later and init passed private, TBM).

Specified by:
init in class PoissonSolver

buildMatrices

public void buildMatrices(int[] fourierFlag,
                          double[] fourierAlpha,
                          double[] fourierValue,
                          int[] dirFlag,
                          double[] dirichletPot)
Builds all matrices (and second member vectors) needed to later
solve Poisson equation.
Inputs are:
- fourierFlag[surfNb]: 1 if Fourier conditions to be implemented on that surface.
- fourierAlpha[surfNb]: alpha parameter in Fourier BC df/dn + alpha n = value
- fourierValue[nodeNb]: value parameter in Fourier BC df/dn + alpha n = value (this is not an error, it centred on nodes, not on surfaces like other Fourier data)
- dirichletFlag[nodeNb]: 1 if Dirichlet conditions to be implemented on that node
- dirichletPot[nodeNb]: fixed potential on Dirichlet nodes
Outputs are internally stored matrices and vectors:
diagMass, matMass, diagPoisson, matPoisson, secMember


initFromBc

public void initFromBc()
Builds all matrices (and second member vectors) needed to later
solve Poisson equation, needed each time BC are modified.
In this version without parameters, boundary conditions data are extracted from internally stored BC data bbc and scbc.
Outputs are internally stored matrices and vectors:
diagMass, matMass, diagPoisson, matPoisson, secMember

Specified by:
initFromBc in class PoissonSolver

buildBC

private void buildBC(PoissonBC bc)
Updates buffered fourierFlagBuf, fourierAlphaBuf, fourierValueBuf, dirichletFlag, and dirichletPotBuf arrays from passed Poisson boundary condition


solveNonLinear

public void solveNonLinear(ScalVolField density,
                           VectVolField E_)
Solves non-linearPoisson equation.
NB: several different interfaces may be implemented to pass control parameters (precision, or iteration number, etc.), but implementin this one, with minimal parameter number, is enforced with this by the abstract method definition of the super class PoissonSlver, so that the user can be sure to have this default interface (automated definition of default control parameters).

Specified by:
solveNonLinear in class PoissonSolver

solveLinear

public void solveLinear(ScalVolField density,
                        VectVolField E_)
Solves Poisson equation.
Several different interfaces may be implemented to pass control parameters (precision, or iteration number, etc.), but implementin this one, with minimal parameter number, is enforced with this by the abstract method definition of the super class PoissonSlver, so that the user can be sure to have this default interface (automated definition of default control parameters). Still TBC.

Specified by:
solveLinear in class PoissonSolver

interpolatePotGradient

public void interpolatePotGradient(PointList pl,
                                   ScalVolField pot,
                                   VectTable val)
Computes the potential gradient (minus the electric field) at each particle position: linear in regular tetrahedra, specific in tetrahedra next to a wire (contrarily to VolMesh computeGradient(...) routine.)
Basically calls the right PoissonInit.computeGradient(...) routine with the right extra parameters.

Specified by:
interpolatePotGradient in class PoissonSolver
Parameters:
pl - particle list (points are enough)
pot - potential (input)
val - gradient at particle locations
See Also:
PoissonInit.computeGradient(float[][], float[][], float[][], float[][], double[], float[], float[], float[], float[], int[], double[], int[][], int[][], int[][], int[][], int[][], int[][], int[], int[], int[], int[], int[], int, ThreeDUnstructVolMesh), ThreeDUnstructVolMesh.computeGradient(PointList, ScalVolField, VectTable)

interpolatePotential

public void interpolatePotential(PointList pl,
                                 ScalVolField pot,
                                 FloatScalTable val)
Interpolates the potential at each particle position: linear in regular tetrahedra, specific in tetrahedra next to a wire (contrarily to VolMesh interpolatePotential routine).
Basically calls the right PoissonInit.interpolatePotential(...) routine with the right extra parameters.

Specified by:
interpolatePotential in class PoissonSolver
Parameters:
pl - particle list (points are enough)
pot - potential (input)
val - gradient at particle locations
See Also:
PoissonInit.interpolatePotential(float[][], float[][], float[], double[], float[], float[], float[], int[], int[][], int[][], int[][], int[][], int[][], int[][], int[], int[], int[], int[], int[], int, ThreeDUnstructVolMesh), ThreeDUnstructVolMesh.interpolate(PointList, VolField, Table)

getIterGradient

public int getIterGradient()
Returns:

getIterGradientNl

public int getIterGradientNl()
Returns:

getIterNewton

public int getIterNewton()
Returns:

getTolGradient

public double getTolGradient()
Returns:

getTolGradientNl

public double getTolGradientNl()
Returns:

getTolNewton

public double getTolNewton()
Returns:

setIterGradient

public void setIterGradient(int i)
Parameters:
i -

setIterGradientNl

public void setIterGradientNl(int i)
Parameters:
i -

setIterNewton

public void setIterNewton(int i)
Parameters:
i -

setTolGradient

public void setTolGradient(double d)
Parameters:
d -

setTolGradientNl

public void setTolGradientNl(double d)
Parameters:
d -

setTolNewton

public void setTolNewton(double d)
Parameters:
d -