spis.Vol.VolMesh
Class ThreeDUnstructVolMesh

java.lang.Object
  extended byspis.Vol.VolMesh.VolMesh
      extended byspis.Vol.VolMesh.UnstructVolMesh
          extended byspis.Vol.VolMesh.ThreeDUnstructVolMesh
All Implemented Interfaces:
java.io.Serializable

public class ThreeDUnstructVolMesh
extends UnstructVolMesh
implements java.io.Serializable

Class Name : ThreeDUnstructVolMesh (generic Volume Mesh class)
Project ref : SPIS project
File name : ThreeDUnstructVolMesh.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 : 3-dimensional Unstructured Volume Mesh class (tetrahedra only).
Derives from UnstructVolMesh class. Most methods and data shall be implemented at this level.
Constraints on cell/surf/edge/node numbering:
- the i-th cellNode of a cell must be "opposite" the i-th cellSurf (i-th node does not belong to i-th surface)
- the i-th surfNode of a surf must be "opposite" the i-th surfEdge
- ...

Versions and anomalies correction :

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


Version:
0.1
Author:
JF Roussel
See Also:
Serialized Form

Field Summary
private  ThreeDUnstructSurfMesh bsm
          pointer to the 3D untructured surface mesh, external boundary of the simulation box (not a physical surface)
private  float[] bufferNodeArrayF
          buffer used to renumber node quantities on the spot (it is stored as object variable to avoid intensive memory re-allocation)
private  int[] bufferNodeArrayI
          buffer used to renumber node quantities on the spot (it is stored as object variable to avoid intensive memory re-allocation)
private  int[][] cellEdge
          edges of a cell (int[cellNb][6])
private  int cellNb
          cell (tetrahedra) number
private  int[][] cellNode
          nodes of a cell (int[cellNb][4]).
private  int[][] cellSurf
          pointers (indices) to the surfaces surrounding a cell (int[cellNb][4]).
private  float[] cellVol
          Cell volume
private  int[] edgeFlag
          edge flag (int[edgeNb]) to tag special edges. :
- bit 0: 0 = not on a spacrecraft surface
1 = on a spacecraft surface
- bit 1: 0 = not on a thin SC surface
1 = on a thin SC surface
(meaningful only if bit 0 = 1)
- bit 2: 0 = not a wire-like boom
1 = wire-like boom (1D physical surface)
(meaningful only if 1st bit = 1 and 2nd bit = 0)
- bit 3: 0 = not a mesh boundary edge
1 = it is a mesh boundary edge
next bits may be used (transiently) to tag special edges for monitoring...
private  int[] edgeIndexB
          for an edge of the boundary SurfMesh (fourth bit of edgeFlag = 1), index of the edge in the boundary SurfMesh numbering
private  int[] edgeIndexSC
          for an edge of the spacecraft SurfMesh (first bit of edgeFlag = 1), index of the edge in the SC SurfMesh numbering
private  float[] edgeLength
          Edge length
private  int edgeNb
          edge number
private  int[][] edgeNode
          nodes of an edge (int[edgeNb][2])
private  int[] externNum
          external numbering, dimensionned only if nodeRenumbering = true (externNum[internalId] = externalId)
private  int[] internNum
          internal numbering, dimensionned only if nodeRenumbering = true (internNum[externalId] = internalId)
private  int[] nodeFlag
          node flag (int[nodeNb]) to tag special nodes. :
- bit 0: 0 = not on a spacrecraft surface
1 = on a spacecraft surface
- bit 1: 0 = not on a thin SC surface
1 = on a thin SC surface
(meaningful only if bit 0 = 1)
- bit 2: 0 = not a node of a wire-like boom
1 = node of a wire-like boom (1D physical surface)
(meaningful only if 1st bit = 1 and 2nd bit = 0)
- bit 3: 0 = not a mesh boundary node
1 = it is a mesh boundary node
next bits may be used (transiently) to tag special nodes for monitoring...
private  int[] nodeIndexB
          for a node of the boundary SurfMesh (third bit of nodeFlag = 1), index of the node in the boundary SurfMesh numbering
private  int[] nodeIndexSC
          for a node of the spacecraft SurfMesh (first bit of nodeFlag = 1), index of the node in the SC SurfMesh numbering
private  int nodeNb
          node (points) number
private  boolean nodeRenumbering
          Is node renumbering on ?
private  float[] nodeVol
          Can be viewed by physicists as the 'effective' volume surrounding a node, which allows to compute the density from the particle number obtained by PIC charge deposit (numericians would rather call it the lumped mass matrix)
private  ThreeDUnstructSurfMesh scsm
          pointer to the 3D untructured spacecraft surface mesh, (a physical surface)
private  float[] surfArea
          Surface area
private  int[][] surfCell
          cells around a surface (int[surfNb][2]) (negative value if out of mesh)
private  int[][] surfEdge
          edges of a surface (int[surfNb][3])
private  int[] surfFlag
          surface flag (int[surfNb]) to tag special surfaces. :
- lowest weight bit: 0 = not a spacecraft surface
(bit 0) 1 = on a spacecraft surface
- next bit: 0 = not a thin surface
(bit 1) 1 = it is a thin surface
(meaningful only if bit 0 = 1)
- bit 2: = 0
- bit 3: 0 = not a mesh boundary surface
1 = it is a mesh boundary surface
next bits may be used (transiently) to tag special surfaces for monitoring, as current computation through a virtual instrument...
private  int[] surfIndexB
          for a surface of the boundary SurfMesh (bit 3 of surfFlag = 1), index of the surface in the boundary SurfMesh numbering
private  int[] surfIndexSC
          for a surface of the spacecraft SurfMesh (bit 0 of surfFlag = 1), index of the surface in the SC SurfMesh numbering
private  int surfNb
          surface (triangle) number
private  int[][] surfNode
          nodes of a surface (int[surfNb][3])
private  float[][] surfNormal
          Normal to a Surface (SurfNormal[i][j] = j-th coordinate of i-th surface normal).
private  float[][][] toBarCo
          Matrices to get the barycentric coordinates ([cellNb][3][3]): {l2,l3,l4} = toBarCo[cellId][][].
private  float[][] xyz
          nodes coordinates (xyz[i][j] = j-th coordinate of i-th node)
 
Fields inherited from class spis.Vol.VolMesh.VolMesh
 
Constructor Summary
ThreeDUnstructVolMesh(Geom geometry, ThreeDUnstructSurfMesh boundarySurfMesh, ThreeDUnstructSurfMesh scSurfMesh, int cellNbr, int surfNbr, int edgeNbr, int nodeNbr, int[][] cellSurfs, int[][] cellEdges, int[][] cellNodes, int[][] surfEdges, int[][] surfNodes, int[][] edgeNodes, int[] surfFlags, int[] surfIdSC, int[] surfIdB, int[] edgeFlags, int[] edgeIdSC, int[] edgeIdB, int[] nodeFlags, int[] nodeIdSC, int[] nodeIdB, float[][] xyzCoord)
          Main constructor with basic sufficient data provided.
 
Method Summary
 void advance(PartList pl, VectTable dx)
          Advances the particles of particle list pl from their current position to their next position, defined by the shift vector dx.
 float[] applyScalFunction(Centring centring, ScalFunctionOfVect f)
          Applies a function of the position to the nodes (or surfaces/cells... depending on centring), and returns the result (f(xi,yi,zi)) as a float array.
 float[][] applyVectFunction(Centring centring, VectFunctionOfVect f)
          Applies a vectorial function of the position to the nodes (or surfaces/cells... depending on centring), and returns the result (f(xi,yi,zi)) as a float[i][] array.
private  float[] cellBary(int cellId)
          return the barycentre of a cell
 void computeBarCo(float[] barCo, float x, float y, float z, int cellNo)
          Computes barycentric coordinates barCo from cartesian coordinates with origin at first tetrahedron point (x = xParticle - xPoint1) for a point (x, y, z) in cell cellNo.
 void computeGradient(PointList pl, ScalVolField vf, VectTable val)
          Similar to Interpolate, but the gradient of a volume field is computed.
 void computeNormals()
          Computes surface normals and makes a few checks.
private  void computeToBarCoMatrices()
          Computes the matrix toBarCo transforming cartesian coordinates into barycentric coordinates.
 void currentDeposit(PartList pl, VectVolField cur)
          Performs the PIC deposit of current of the particle list pl in the current density cur.
 void deposit(PartList pl, ScalVolField dens, int charge, int mass)
          Performs the PIC deposit of charges of the particle list pl in the density dens (dens is incremented, reset it before if you want to start from 0).
 void export()
          exports the mesh(es)
 int[][] getCellEdge()
          Returns the table of the edges of a cell (6 edges of the tetrahedron)
 int[][] getCellNode()
          Returns the table of the nodes of a cell (4 points of the tetrahedron)
 int[][] getCellSurf()
          Returns the table of the surfaces of a cell (4 triangles of the tetrahedron)
 float[] getCellVol()
          Returns cell volumes
 ScalVolField getCellVolField()
          Returns 'node volumes'
 int[] getEdgeFlag()
          Returns the flags of the volume mesh edges
 int[] getEdgeIndexB()
          Returns the boundary-surface indices of the volume mesh edges
 int[] getEdgeIndexSC()
          Returns the SC-surface indices of the volume mesh edges
 float[] getEdgeLength()
          Returns edges lengths
 int[][] getEdgeNode()
          Returns the table of the nodes of an edge (2 points of an edge)
 int getElNb(Centring cent)
          Provides the number of elements for a field with this centring
(on nodes/cells/...).
 int getElNb(int relDim)
          Returns the number of elements of relative dimension relDim
 int[] getExternNodeNumberingMap()
          Returns the map of external node numbering.
 IntScalTable getInjectionCell(IntScalTable flagTable, IntScalTable indexTable)
          Returns the table of the cell indices of particles particles injected from boundaries.
 int[] getInternNodeNumberingMap()
          Returns the map of internal node numbering.
 float[][] getNodeCoord()
          Returns nodes coordinates
 int[] getNodeFlag()
          Returns the flags of the volume mesh nodes
 int[] getNodeIndexB()
          Returns the boundary-surface indices of the volume mesh nodes
 int[] getNodeIndexSC()
          Returns the SC-surface indices of the volume mesh nodes
 float[] getNodeVol()
          Returns 'node volumes' as a float array
 ScalVolField getNodeVolField()
          Returns 'node volumes' as a volume field
 float[] getSurfArea()
          Returns surface areas
 int[][] getSurfCell()
          Returns the table of the cells surrounding a surface (2 tetrahedra, one on each side of a triangle)
 int[][] getSurfEdge()
          Returns the table of the edges of a surface (3 edges of a triangle)
 int[] getSurfFlag()
          Returns the flags of the volume mesh triangles
 int[] getSurfIndexB()
          Returns the boundary-surface indices of the volume mesh triangles
 int[] getSurfIndexSC()
          Returns the SC-surface indices of the volume mesh triangles
 int[][] getSurfNode()
          Returns the table of the nodes of a surface (3 points of a triangle)
 float[][] getSurfNormal()
          Returns surface normals
 float[][][] getToBarCo()
          Returns the matrices to get the barycentric coordinates in each cell
 void initialise()
          Performs extra mesh initialisations.
 void interpolate(PointList pl, VolField vf, Table val)
          Interpolates the volume field vf (defined on the mesh nodes/cells/...)
 boolean isNodeRenumberingOn()
           
 void mapToExternalNodeIndexing(float[] array)
          Transforms an internal-node-number-indexed array of node-centered quantities to an external-node-number-indexed array on the spot (i.e. in the same array).
 void mapToExternalNodeIndexing(float[][] internIndexed, float[][] externIndexed)
          Maps node-centered quantities from an internal-node-number-indexed array to an external-node-number-indexed array.
 void mapToExternalNodeIndexing(float[] internIndexed, float[] externIndexed)
          Maps node-centered quantities from an internal-node-number-indexed array to an external-node-number-indexed array.
 void mapToInternalNodeIndexing(float[] array)
          Transforms an external-node-number-indexed array of node-centered quantities to an internal-node-number-indexed array on the spot (i.e. in the same array).
 void mapToInternalNodeIndexing(float[][] externIndexed, float[][] internIndexed)
          Maps node-centered quantities from an external-node-number-indexed array to an internal-node-number-indexed array.
 void mapToInternalNodeIndexing(float[] externIndexed, float[] internIndexed)
          Maps node-centered quantities from an external-node-number-indexed array to an internal-node-number-indexed array.
 void mapToInternalNodeIndexing(int[] array)
          Transforms an external-node-number-indexed array of node-centered integer quantities to an internal-node-number-indexed array on the spot (i.e. in the same array).
 void mapToInternalNodeIndexing(int[] externIndexed, int[] internIndexed)
          Maps integer node-centered quantities from an external-node-number-indexed array to an internal-node-number-indexed array.
private  void mapToSurf(FloatScalTable tIn, FloatScalTable tOut, int[] flag, int[] index, int mask)
          maps table in to table out
 void mapToSurfField(ScalVolField fIn, ScalSurfField fOut, int flag)
          Maps a volume field onto a surface fields.
 void poissonSolve(VectVolField E, ScalVolField dens, PoissonBC bc)
          Solves Poison equation for electric field E (indeed for the potential from which it derives if E is stored as a potential, i.e. of sub-type PotVectVolField) and density dens.
 void samplePos(IntScalTable indexT, SpaceVectTable posT)
          Performs a random sampling of particle positions.
 void setInternNodeNumbering(int[] internNumbering)
          Defines external to internal node numbering maps, external to internal maps, and renumbers node-indexed arrays with the internal numbering (for related surface meshes scsm and bsm too).
 void setNodeRenumbering(boolean b)
           
private  float[] surfBary(int surfId)
          return the barycentre of a surface
 
Methods inherited from class spis.Vol.VolMesh.VolMesh
eulerSolve, getBsm, getGeom, getScsm, getTotalVol, maxwellSolve, mhdSolve, setBsm, setScsm
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bsm

private ThreeDUnstructSurfMesh bsm
pointer to the 3D untructured surface mesh, external boundary of the simulation box (not a physical surface)


scsm

private ThreeDUnstructSurfMesh scsm
pointer to the 3D untructured spacecraft surface mesh, (a physical surface)


cellNb

private int cellNb
cell (tetrahedra) number


surfNb

private int surfNb
surface (triangle) number


edgeNb

private int edgeNb
edge number


nodeNb

private int nodeNb
node (points) number


cellSurf

private int[][] cellSurf
pointers (indices) to the surfaces surrounding a cell (int[cellNb][4]). The surf cellSurf[n][s] must be opposite the node cellNode[n][s].


cellEdge

private int[][] cellEdge
edges of a cell (int[cellNb][6])


cellNode

private int[][] cellNode
nodes of a cell (int[cellNb][4]). the surf cellSurf[n][s] must be opposite the node cellNode[n][s]


surfEdge

private int[][] surfEdge
edges of a surface (int[surfNb][3])


surfNode

private int[][] surfNode
nodes of a surface (int[surfNb][3])


edgeNode

private int[][] edgeNode
nodes of an edge (int[edgeNb][2])


surfCell

private int[][] surfCell
cells around a surface (int[surfNb][2]) (negative value if out of mesh)


surfFlag

private int[] surfFlag
surface flag (int[surfNb]) to tag special surfaces. :
- lowest weight bit: 0 = not a spacecraft surface
(bit 0) 1 = on a spacecraft surface
- next bit: 0 = not a thin surface
(bit 1) 1 = it is a thin surface
(meaningful only if bit 0 = 1)
- bit 2: = 0
- bit 3: 0 = not a mesh boundary surface
1 = it is a mesh boundary surface
next bits may be used (transiently) to tag special surfaces for monitoring, as current computation through a virtual instrument...
hence:
- surfFlag=0 if a non-physical face between tetrahedra
- surfFlag=1 if regular physical surface
- surfFlag=3 if a thin physical surface
- surfFlag=8 if a boundary surface


surfIndexSC

private int[] surfIndexSC
for a surface of the spacecraft SurfMesh (bit 0 of surfFlag = 1), index of the surface in the SC SurfMesh numbering


surfIndexB

private int[] surfIndexB
for a surface of the boundary SurfMesh (bit 3 of surfFlag = 1), index of the surface in the boundary SurfMesh numbering


edgeFlag

private int[] edgeFlag
edge flag (int[edgeNb]) to tag special edges. :
- bit 0: 0 = not on a spacrecraft surface
1 = on a spacecraft surface
- bit 1: 0 = not on a thin SC surface
1 = on a thin SC surface
(meaningful only if bit 0 = 1)
- bit 2: 0 = not a wire-like boom
1 = wire-like boom (1D physical surface)
(meaningful only if 1st bit = 1 and 2nd bit = 0)
- bit 3: 0 = not a mesh boundary edge
1 = it is a mesh boundary edge
next bits may be used (transiently) to tag special edges for monitoring...
hence:
- edgeFlag=0 if a non-physical edge in volume
- edgeFlag=1 if a regular physical edge on a SC surface
- edgeFlag=3 if an edge of a thin physical SC surface
- edgeFlag=5 if a wire-like element (1D physical surface)
- edgeFlag=8 if a boundary edge
- edgeFlag=9 if both a SC edge
and a boundary edge
- edgeFlag=11 if an edge of a thin SC surface
and a boundary edge


edgeIndexSC

private int[] edgeIndexSC
for an edge of the spacecraft SurfMesh (first bit of edgeFlag = 1), index of the edge in the SC SurfMesh numbering


edgeIndexB

private int[] edgeIndexB
for an edge of the boundary SurfMesh (fourth bit of edgeFlag = 1), index of the edge in the boundary SurfMesh numbering


nodeFlag

private int[] nodeFlag
node flag (int[nodeNb]) to tag special nodes. :
- bit 0: 0 = not on a spacrecraft surface
1 = on a spacecraft surface
- bit 1: 0 = not on a thin SC surface
1 = on a thin SC surface
(meaningful only if bit 0 = 1)
- bit 2: 0 = not a node of a wire-like boom
1 = node of a wire-like boom (1D physical surface)
(meaningful only if 1st bit = 1 and 2nd bit = 0)
- bit 3: 0 = not a mesh boundary node
1 = it is a mesh boundary node
next bits may be used (transiently) to tag special nodes for monitoring...
hence:
- nodeFlag=0 if a non-physical node in volume
- nodeFlag=1 if a regular physical node on a SC surface
- nodeFlag=3 if a node of a thin physical SC surface
- edgeFlag=5 if a node of wire-like element
- nodeFlag=8 if a boundary node
- nodeFlag=9 if both a SC node and a boundary node
- nodeFlag=11 if a node of a thin SC surface and a boundary node


nodeIndexSC

private int[] nodeIndexSC
for a node of the spacecraft SurfMesh (first bit of nodeFlag = 1), index of the node in the SC SurfMesh numbering


nodeIndexB

private int[] nodeIndexB
for a node of the boundary SurfMesh (third bit of nodeFlag = 1), index of the node in the boundary SurfMesh numbering


xyz

private float[][] xyz
nodes coordinates (xyz[i][j] = j-th coordinate of i-th node)


cellVol

private float[] cellVol
Cell volume


surfArea

private float[] surfArea
Surface area


edgeLength

private float[] edgeLength
Edge length


nodeVol

private float[] nodeVol
Can be viewed by physicists as the 'effective' volume surrounding a node, which allows to compute the density from the particle number obtained by PIC charge deposit (numericians would rather call it the lumped mass matrix)


surfNormal

private float[][] surfNormal
Normal to a Surface (SurfNormal[i][j] = j-th coordinate of i-th surface normal). The normal points into the second cell referenced in surfCell, surCell[][1]


toBarCo

private float[][][] toBarCo
Matrices to get the barycentric coordinates ([cellNb][3][3]): {l2,l3,l4} = toBarCo[cellId][][].{x-x1,y-y1,z-z1}, with l1 = 1 - l2 - l3 - l4


nodeRenumbering

private boolean nodeRenumbering
Is node renumbering on ?


internNum

private int[] internNum
internal numbering, dimensionned only if nodeRenumbering = true (internNum[externalId] = internalId)


externNum

private int[] externNum
external numbering, dimensionned only if nodeRenumbering = true (externNum[internalId] = externalId)


bufferNodeArrayI

private int[] bufferNodeArrayI
buffer used to renumber node quantities on the spot (it is stored as object variable to avoid intensive memory re-allocation)


bufferNodeArrayF

private float[] bufferNodeArrayF
buffer used to renumber node quantities on the spot (it is stored as object variable to avoid intensive memory re-allocation)

Constructor Detail

ThreeDUnstructVolMesh

public ThreeDUnstructVolMesh(Geom geometry,
                             ThreeDUnstructSurfMesh boundarySurfMesh,
                             ThreeDUnstructSurfMesh scSurfMesh,
                             int cellNbr,
                             int surfNbr,
                             int edgeNbr,
                             int nodeNbr,
                             int[][] cellSurfs,
                             int[][] cellEdges,
                             int[][] cellNodes,
                             int[][] surfEdges,
                             int[][] surfNodes,
                             int[][] edgeNodes,
                             int[] surfFlags,
                             int[] surfIdSC,
                             int[] surfIdB,
                             int[] edgeFlags,
                             int[] edgeIdSC,
                             int[] edgeIdB,
                             int[] nodeFlags,
                             int[] nodeIdSC,
                             int[] nodeIdB,
                             float[][] xyzCoord)
Main constructor with basic sufficient data provided.
The provided surface meshes must already be built, since their consistency with the volume mesh is checked, so building interconnected volume and surface meshes must be in the following order:
- scSurfMesh = new SurfMesh(VolMesh_reference = null,...)
- boundarySurfMesh = new SurfMesh(VolMesh_reference = null,...)
- volMesh = new VolMesh(boundarySurfMesh, scSurfMesh, ...)
- boundarySurfMesh.setVm(volMesh)
- scSurfMesh.setVm(volMesh).
The tables are not copied, the new ThreeDUnstructVolMesh instance simply points to the provided tables.

Method Detail

initialise

public void initialise()
Performs extra mesh initialisations.
Must be called at the end of the constructor after passed variables are stored.
Tasks performes are:
- mesh consistency cheks/modifications
- computation of matrices to obtain barycentric coordinates
- initialisation of area/vol/length/normals...


computeNormals

public void computeNormals()
Computes surface normals and makes a few checks.
Rules to be checked are the following:
1- normals are pointing out of the mesh at mesh boundaries (this.surfNormals): surfNormal[i][] points out of the volume mesh for any boundary surface i.
2- normals of volume mesh triangles and surface mesh triangles are identical
3- as a consequence of rule 1, rule 2 can be translated as "normals of boundary surface meshes (scsm and bsm) are pointing out of the volume mesh": xxsm.surfNormal(surfIndexYY(i)) points out of surCell[i][1] for the surface i of SC mesh (xx=sc, YY=SC) or boundary mesh (xx=b, YY=B). NB: as a consequence, only two of the three rules 1,2,3 have to be checked 4- the normal of a surface points into its second neighbouring cell, which is not necessarily the case before, and is enforced here:
surfNormal[i][] points into surCell[i][1] for any surface i, and points out of surCell[i][0].
Rule 4 allows to obtain normals pointing out of s-th surface (s = local index, in [0-3]) of c-th cell the following way:
if (surfCell[cellSurf[c][s]][1] == c) {
// your normal is -surfNormal[cellSurf[c][s]]
} else { // we should then have (surfCell[cellSurf[c][s]][0] == c)
// your normal is surfNormal[cellSurf[c][s]]
}
Rules 1, 3 and 4 are enforced here by re_ordering surfCell (rule 4), surfNode (rule 1), but rules 2 and 3 depend on surface meshes face orientations, which are not modified here. NB: It is always implicit that normals follow the direct triedra orientation rule, from which a normal is defined from the simple order of three points of the surface.


cellBary

private float[] cellBary(int cellId)
return the barycentre of a cell


surfBary

private float[] surfBary(int surfId)
return the barycentre of a surface


computeToBarCoMatrices

private void computeToBarCoMatrices()
Computes the matrix toBarCo transforming cartesian coordinates into barycentric coordinates.
It is stored in the ThreeDUnstructVolMesh object to speed up particle trajectory computation. It is invoked at object creation and does not need to be directly invoked by the user, hence it scope private.
From x = x1*l1+x2*l2+x3*l3+x4*l4 and l1 = 1-l2-l3-l4, hence x - x1 = (x2-x1)*l2 + (x3-x1)*l3 + (x4-x1)*l4 (same for y and z), we get
|(x-x1) |x2-x1 x3-x1 x4-x1| |l2 |l2
|(y-y1) = |y2-y1 y3-y1 y4-y1|.|l3 = A.|l3
|(z-z1) |z2-z1 z3-z1 z4-z1| |l4 |l4
hence lambda(2,3,4) = A-1.(X-X1) and the matrix A-1 is the matrix toBarCo needed.


interpolate

public void interpolate(PointList pl,
                        VolField vf,
                        Table val)
Interpolates the volume field vf (defined on the mesh nodes/cells/...) at the points of the point list pl (particle positions).
The field values are returned in val. The Table of values val must be of the same type as the field (vector/scalar/...) More than the point position may be used in PointList, as e.g. the index of the current cell of the particle (unstructured meshes).
Ex: Interpolate(pl,E,E_values).

Specified by:
interpolate in class VolMesh

computeGradient

public void computeGradient(PointList pl,
                            ScalVolField vf,
                            VectTable val)
Similar to Interpolate, but the gradient of a volume field is computed.
As a consequence val is a tensor of larger order than VolField by one unit, e.g. vf scalar, val vector => Gradient(PartList pl,ScalVolField vf,VectTable val), the only version implemented for now.
Ex: Gradient(pl,potential,"-E_values")

Specified by:
computeGradient in class VolMesh
See Also:
VolMesh.interpolate(PointList, VolField, Table)

advance

public void advance(PartList pl,
                    VectTable dx)
Advances the particles of particle list pl from their current position to their next position, defined by the shift vector dx.
The flags and indices of the particles are updated (each particle flag indicates the particle status in_vol/on-surf/null/... and the index is the index of particle cell/surface/...) It is basically an intersection computation, the dynamics itself is computed in PartList.move method.

Specified by:
advance in class VolMesh

computeBarCo

public void computeBarCo(float[] barCo,
                         float x,
                         float y,
                         float z,
                         int cellNo)
Computes barycentric coordinates barCo from cartesian coordinates with origin at first tetrahedron point (x = xParticle - xPoint1) for a point (x, y, z) in cell cellNo.

Parameters:
barCo - output
x -
y -
z -
cellNo -

deposit

public void deposit(PartList pl,
                    ScalVolField dens,
                    int charge,
                    int mass)
Performs the PIC deposit of charges of the particle list pl in the density dens (dens is incremented, reset it before if you want to start from 0).
If charge=1, particle number is multiplied by particle charge
If mass=1, particle number is multiplied by particle mass
Examples:
- deposit(pl, dens, 0, 0) computes number density
- deposit(pl, dens, 1, 0) computes charge density
- deposit(pl, dens, 0, 1) computes mass density

Specified by:
deposit in class VolMesh

currentDeposit

public void currentDeposit(PartList pl,
                           VectVolField cur)
Performs the PIC deposit of current of the particle list pl in the current density cur.

Specified by:
currentDeposit in class VolMesh

poissonSolve

public void poissonSolve(VectVolField E,
                         ScalVolField dens,
                         PoissonBC bc)
Solves Poison equation for electric field E (indeed for the potential from which it derives if E is stored as a potential, i.e. of sub-type PotVectVolField) and density dens. The boundary conditions are defined in bc. The type BC, for boundary condition, is still TBD today, , but will consist of a few surface fields for the surface parameters describing the boundary conditions (different derived types).

Specified by:
poissonSolve in class VolMesh

samplePos

public void samplePos(IntScalTable indexT,
                      SpaceVectTable posT)
Performs a random sampling of particle positions. Particles of index n are generated in cell n.

Specified by:
samplePos in class VolMesh
Parameters:
indexT -
posT -

mapToInternalNodeIndexing

public void mapToInternalNodeIndexing(float[] externIndexed,
                                      float[] internIndexed)
Maps node-centered quantities from an external-node-number-indexed array to an internal-node-number-indexed array.

Specified by:
mapToInternalNodeIndexing in class VolMesh

mapToInternalNodeIndexing

public void mapToInternalNodeIndexing(int[] externIndexed,
                                      int[] internIndexed)
Maps integer node-centered quantities from an external-node-number-indexed array to an internal-node-number-indexed array.


mapToInternalNodeIndexing

public void mapToInternalNodeIndexing(float[][] externIndexed,
                                      float[][] internIndexed)
Maps node-centered quantities from an external-node-number-indexed array to an internal-node-number-indexed array.

Specified by:
mapToInternalNodeIndexing in class VolMesh

mapToExternalNodeIndexing

public void mapToExternalNodeIndexing(float[] internIndexed,
                                      float[] externIndexed)
Maps node-centered quantities from an internal-node-number-indexed array to an external-node-number-indexed array.

Specified by:
mapToExternalNodeIndexing in class VolMesh

mapToExternalNodeIndexing

public void mapToExternalNodeIndexing(float[][] internIndexed,
                                      float[][] externIndexed)
Maps node-centered quantities from an internal-node-number-indexed array to an external-node-number-indexed array.

Specified by:
mapToExternalNodeIndexing in class VolMesh

mapToInternalNodeIndexing

public void mapToInternalNodeIndexing(float[] array)
Transforms an external-node-number-indexed array of node-centered quantities to an internal-node-number-indexed array on the spot (i.e. in the same array).


mapToInternalNodeIndexing

public void mapToInternalNodeIndexing(int[] array)
Transforms an external-node-number-indexed array of node-centered integer quantities to an internal-node-number-indexed array on the spot (i.e. in the same array).


mapToExternalNodeIndexing

public void mapToExternalNodeIndexing(float[] array)
Transforms an internal-node-number-indexed array of node-centered quantities to an external-node-number-indexed array on the spot (i.e. in the same array).


setInternNodeNumbering

public void setInternNodeNumbering(int[] internNumbering)
Defines external to internal node numbering maps, external to internal maps, and renumbers node-indexed arrays with the internal numbering (for related surface meshes scsm and bsm too). Start from the internal numbers as a function of external (internNum) and builds the reverse table (externNum), and then sets the correct flag (nodeRenumbering = true) and renumbers the node-indexed arrays of itself, scsm and bsm)


applyScalFunction

public float[] applyScalFunction(Centring centring,
                                 ScalFunctionOfVect f)
Applies a function of the position to the nodes (or surfaces/cells... depending on centring), and returns the result (f(xi,yi,zi)) as a float array.

Specified by:
applyScalFunction in class VolMesh

applyVectFunction

public float[][] applyVectFunction(Centring centring,
                                   VectFunctionOfVect f)
Applies a vectorial function of the position to the nodes (or surfaces/cells... depending on centring), and returns the result (f(xi,yi,zi)) as a float[i][] array.

Specified by:
applyVectFunction in class VolMesh

mapToSurfField

public void mapToSurfField(ScalVolField fIn,
                           ScalSurfField fOut,
                           int flag)
Maps a volume field onto a surface fields. if they have different centring, interpolation may be needed on the surface (not all types supported): if flag = 1, the quantity is extensive, which results in sommations, if flag = 0, it is intensive, which results in averages.

Specified by:
mapToSurfField in class VolMesh

mapToSurf

private void mapToSurf(FloatScalTable tIn,
                       FloatScalTable tOut,
                       int[] flag,
                       int[] index,
                       int mask)
maps table in to table out


export

public void export()
exports the mesh(es)


getInjectionCell

public IntScalTable getInjectionCell(IntScalTable flagTable,
                                     IntScalTable indexTable)
Returns the table of the cell indices of particles particles injected from boundaries. All the flags must be on a boundary (spacecraft or external, mixing allowed)

Specified by:
getInjectionCell in class VolMesh
Parameters:
flagTable - flag of the particles (on SC or on boundary, cf PartList)
indexTable - surface index for a particle on a surface mesh
Returns:
cell indices (in this VolMesh numbering)

getInternNodeNumberingMap

public int[] getInternNodeNumberingMap()
Returns the map of internal node numbering.


getExternNodeNumberingMap

public int[] getExternNodeNumberingMap()
Returns the map of external node numbering.


getElNb

public int getElNb(Centring cent)
Provides the number of elements for a field with this centring
(on nodes/cells/...).

Specified by:
getElNb in class VolMesh

getElNb

public int getElNb(int relDim)
Returns the number of elements of relative dimension relDim

Specified by:
getElNb in class VolMesh

getCellSurf

public int[][] getCellSurf()
Returns the table of the surfaces of a cell (4 triangles of the tetrahedron)


getCellEdge

public int[][] getCellEdge()
Returns the table of the edges of a cell (6 edges of the tetrahedron)


getCellNode

public int[][] getCellNode()
Returns the table of the nodes of a cell (4 points of the tetrahedron)


getSurfEdge

public int[][] getSurfEdge()
Returns the table of the edges of a surface (3 edges of a triangle)


getSurfNode

public int[][] getSurfNode()
Returns the table of the nodes of a surface (3 points of a triangle)


getEdgeNode

public int[][] getEdgeNode()
Returns the table of the nodes of an edge (2 points of an edge)


getSurfCell

public int[][] getSurfCell()
Returns the table of the cells surrounding a surface (2 tetrahedra, one on each side of a triangle)


getSurfFlag

public int[] getSurfFlag()
Returns the flags of the volume mesh triangles


getSurfIndexSC

public int[] getSurfIndexSC()
Returns the SC-surface indices of the volume mesh triangles


getSurfIndexB

public int[] getSurfIndexB()
Returns the boundary-surface indices of the volume mesh triangles


getEdgeFlag

public int[] getEdgeFlag()
Returns the flags of the volume mesh edges


getEdgeIndexSC

public int[] getEdgeIndexSC()
Returns the SC-surface indices of the volume mesh edges


getEdgeIndexB

public int[] getEdgeIndexB()
Returns the boundary-surface indices of the volume mesh edges


getNodeFlag

public int[] getNodeFlag()
Returns the flags of the volume mesh nodes


getNodeIndexSC

public int[] getNodeIndexSC()
Returns the SC-surface indices of the volume mesh nodes


getNodeIndexB

public int[] getNodeIndexB()
Returns the boundary-surface indices of the volume mesh nodes


getNodeCoord

public float[][] getNodeCoord()
Returns nodes coordinates


getCellVol

public float[] getCellVol()
Returns cell volumes


getCellVolField

public ScalVolField getCellVolField()
Returns 'node volumes'

Specified by:
getCellVolField in class VolMesh

getSurfArea

public float[] getSurfArea()
Returns surface areas


getEdgeLength

public float[] getEdgeLength()
Returns edges lengths


getNodeVol

public float[] getNodeVol()
Returns 'node volumes' as a float array


getNodeVolField

public ScalVolField getNodeVolField()
Returns 'node volumes' as a volume field

Specified by:
getNodeVolField in class VolMesh

getSurfNormal

public float[][] getSurfNormal()
Returns surface normals


getToBarCo

public float[][][] getToBarCo()
Returns the matrices to get the barycentric coordinates in each cell


isNodeRenumberingOn

public boolean isNodeRenumberingOn()
Returns:
true if node renumbering is on (defined by CutHill McKee renumbering)

setNodeRenumbering

public void setNodeRenumbering(boolean b)
Parameters:
b - true if node renumbering is on (defined by CutHill McKee renumbering)