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

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.
 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.
 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.
 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)
           
 
Methods inherited from class spis.Vol.VolMesh.VolMesh
eulerSolve, getBsm, getGeom, getScsm, getTotalVol, maxwellSolve, mhdSolve, setBsm, setScsm
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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.


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

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)