19 #include "apfDynamicArray.h"
42 typedef std::map<int,MeshEntity*>
Copies;
120 virtual std::size_t
count(
int dimension) = 0;
122 virtual MeshIterator*
begin(
int dimension) = 0;
125 virtual MeshEntity*
iterate(MeshIterator* it) = 0;
129 virtual void end(MeshIterator* it) = 0;
132 virtual bool hasAdjacency(
int from_dim,
int to_dim) = 0;
134 virtual void createAdjacency(
int from_dim,
int to_dim) = 0;
136 virtual void deleteAdjacency(
int from_dim,
int to_dim) = 0;
141 virtual bool isGhosted(MeshEntity* e) = 0;
142 virtual bool isGhost(MeshEntity* e) = 0;
194 MeshEntity** adjacent) = 0;
198 virtual MeshEntity*
getUpward(MeshEntity* e,
int i) = 0;
200 virtual void getUp(MeshEntity* e,
Up& up) = 0;
202 virtual bool hasUp(MeshEntity* e) = 0;
222 virtual int getGhosts(MeshEntity* e,
Copies& ghosts) = 0;
234 virtual MeshTag*
findTag(
const char* name) = 0;
240 virtual void getTags(DynamicArray<MeshTag*>& tags) = 0;
243 virtual void getDoubleTag(MeshEntity* e, MeshTag* tag,
double* data) = 0;
246 virtual void setDoubleTag(MeshEntity* e, MeshTag* tag,
double const* data) = 0;
249 virtual void getIntTag(MeshEntity* e, MeshTag* tag,
int* data) = 0;
252 virtual void setIntTag(MeshEntity* e, MeshTag* tag,
int const* data) = 0;
255 virtual void getLongTag(MeshEntity* e, MeshTag* tag,
long* data) = 0;
258 virtual void setLongTag(MeshEntity* e, MeshTag* tag,
long const* data) = 0;
261 virtual void removeTag(MeshEntity* e, MeshTag* tag) = 0;
263 virtual bool hasTag(MeshEntity* e, MeshTag* tag) = 0;
265 virtual void renameTag(MeshTag* tag,
const char* newName) = 0;
286 virtual ModelEntity*
toModel(MeshEntity* e) = 0;
394 int countGlobalNumberings();
405 Field* coordinateField;
406 std::vector<Field*> fields;
407 std::vector<Numbering*> numberings;
408 std::vector<GlobalNumbering*> globalNumberings;
417 long verifyVolumes(
Mesh* m,
bool printVolumes =
true);
444 int bridgeDimension,
int targetDimension,
Adjacent& result);
473 void send(MeshEntity* e,
int to);
476 Mesh* getMesh() {
return mesh;}
480 std::vector<MeshEntity*> elements;
498 virtual bool isShared(MeshEntity* e) = 0;
501 struct NormalSharing :
public Sharing
503 NormalSharing(
Mesh* m);
504 virtual int getOwner(MeshEntity* e);
505 virtual bool isOwned(MeshEntity* e);
506 virtual void getCopies(MeshEntity* e,
508 virtual bool isShared(MeshEntity* e);
513 struct MatchedSharing :
public Sharing
515 MatchedSharing(
Mesh* m);
516 Copy getOwnerCopy(MeshEntity* e);
517 virtual int getOwner(MeshEntity* e);
518 virtual bool isOwned(MeshEntity* e);
519 virtual void getCopies(MeshEntity* e,
521 virtual bool isShared(MeshEntity* e);
524 size_t getNeighborCount(
int peer);
525 bool isLess(Copy
const& a, Copy
const& b);
526 void getNeighbors(Parts& neighbors);
528 NormalSharing helper;
529 std::map<int, size_t> countMap;
565 int findIn(MeshEntity** a,
int n, MeshEntity* e);
604 virtual MeshEntity* apply(
int type, MeshEntity** down) = 0;
605 MeshEntity* run(
int type, MeshEntity** verts);
606 void runDown(
int type, MeshEntity** verts, MeshEntity** down);
621 int& which,
bool& flip,
int&
rotate);
623 void packString(std::string s,
int to,
pcu::PCU *PCUObj);
624 std::string unpackString(
pcu::PCU *PCUObj);
625 void packTagInfo(
Mesh* m, MeshTag* t,
int to);
626 void unpackTagInfo(std::string& name,
int& type,
int& size,
pcu::PCU *PCUObj);
628 extern char const*
const dimName[4];
The C++ interface to the Parallel Control Unit.
The APF linear algebra vector interface.
Describes field distribution and shape functions.
Interface to a mesh part.
virtual void writeNative(const char *fileName)=0
write the underlying mesh into a set of files
virtual void getPoint_(MeshEntity *e, int node, Vector3 &point)=0
Implementation-defined code for apf::Mesh::getPoint.
virtual const char * getTagName(MeshTag *t)=0
return the name of a tag
void setCoordinateField(Field *field)
Set the mesh's coordinate field - Be very careful using this.
void boundingBox(ModelEntity *g, Vector3 &bmin, Vector3 &bmax)
get the bounding box of the model entity g
virtual ModelEntity * toModel(MeshEntity *e)=0
get geometric classification
Field * findField(const char *name)
lookup a field by its unique name
void addField(Field *f)
associate a field with this mesh
bool canGetModelNormal()
return true if the geometric model supports normal computation
bool hasFrozenFields
true if any associated fields use array storage
virtual void getLongTag(MeshEntity *e, MeshTag *tag, long *data)=0
get long array tag data
virtual void end(MeshIterator *it)=0
destroy an iterator.
virtual unsigned getTagChecksum(MeshTag *tag, int type)=0
returns the checksum of a tag for the specificed topological type
void getParamOn(ModelEntity *g, MeshEntity *e, Vector3 &p)
reparameterize mesh vertex (e) onto model entity (g)
int countNumberings()
get the number of associated numberings
TagType
Tag data type enumeration.
@ DOUBLE
64-bit IEE754 floating-point number
@ LONG
signed 64-bit integer
@ INT
signed 32-bit integer
virtual ~Mesh()
destroy the base class structures.
virtual void setIntTag(MeshEntity *e, MeshTag *tag, int const *data)=0
set int array tag data
Field * getCoordinateField()
get the mesh's coordinate field
void getPoint(MeshEntity *e, int node, Vector3 &point)
Returns the coordinates of a node on a mesh entity.
virtual gmi_model * getModel()=0
get a GMI interface to the geometric model
virtual double getElementBytes(int)
estimate mesh entity memory usage.
virtual void setModel(gmi_model *newModel)=0
set the geometric model
virtual void renameTag(MeshTag *tag, const char *newName)=0
renames a tag
void getNormal(ModelEntity *g, Vector3 const &p, Vector3 &n)
get normal vector at a point
virtual int getTagType(MeshTag *t)=0
get the data type of a tag
virtual void getResidence(MeshEntity *e, Parts &residence)=0
Get the resident parts of an entity.
void removeField(Field *f)
disassociate a field from this mesh
bool isInClosureOf(ModelEntity *g, ModelEntity *target)
checks if g is in the closure of the target
virtual int getTagSize(MeshTag *t)=0
return the array size of a tag
bool canSnap()
return true if the geometric model supports snapping
void removeNumbering(Numbering *f)
disassociate a numbering from this mesh
bool isParamPointInsideModel(ModelEntity *g, Vector3 const ¶m, Vector3 &x)
checks if parametric point is inside the model, and updates puts the location in x
virtual void verify()=0
run a set of consistency checks on the underlying data structure
virtual bool hasMatching()=0
return true if the mesh has matched entities
virtual bool hasUp(MeshEntity *e)=0
Return true iff the entity has upward adjacencies.
virtual void getTags(DynamicArray< MeshTag * > &tags)=0
Get all the tags on a mesh part.
virtual bool isShared(MeshEntity *e)=0
Returns true if the entity is shared in parallel.
void changeShape(FieldShape *newShape, bool project=true)
make a new coordinate field.
Type
Entity topological types.
@ HEX
hexahedron (cube, brick)
@ QUAD
quadrilateral (square)
@ PRISM
triangular prism (wedge)
@ PYRAMID
quadrilateral pyramid
@ TYPES
placeholder to set array sizes
virtual void destroyTag(MeshTag *tag)=0
Removes a mesh tag. This does not detach data from entities.
void addNumbering(Numbering *f)
associate a numbering with this mesh
bool isOnModel(ModelEntity *g, Vector3 p, double scale)
checks if p is on model g
virtual bool hasTag(MeshEntity *e, MeshTag *tag)=0
Returns true if there is data for this tag attached.
virtual MeshEntity * getUpward(MeshEntity *e, int i)=0
Get the i'th one-level upward adjacent entity.
GlobalNumbering * findGlobalNumbering(const char *name)
lookup a numbering by its unique name
Field * getField(int i)
get the i'th associated field
virtual void removeTag(MeshEntity *e, MeshTag *tag)=0
detach tag data from an entity.
virtual void getDoubleTag(MeshEntity *e, MeshTag *tag, double *data)=0
get double array tag data
int countFields()
get the number of associated fields
virtual int getDimension()=0
returns the element dimension of this mesh
virtual MeshTag * createLongTag(const char *name, int size)=0
Creates a long array tag over the mesh given a name and size.
void getClosestPoint(ModelEntity *g, Vector3 const &from, Vector3 &to, Vector3 &p)
get closest point on geometry
static int const adjacentCount[TYPES][4]
for a given entity type, number of adjacent entities of a given dimension
virtual MeshTag * createIntTag(const char *name, int size)=0
Creates an int array tag over the mesh given a name and size.
void getFirstDerivative(ModelEntity *g, Vector3 const &p, Vector3 &t0, Vector3 &t1)
get first derivative at a point
void snapToModel(ModelEntity *m, Vector3 const &p, Vector3 &x)
evaluate parametric coordinate (p) as a spatial point (x)
virtual MeshIterator * begin(int dimension)=0
begins iteration over elements of one dimension
virtual MeshTag * findTag(const char *name)=0
Finds a tag by name, returns 0 if it doesn't exist.
void init(FieldShape *s, pcu::PCU *PCUObj)
initialize the base class structures.
FieldShape * getShape() const
get the distribution of the mesh's coordinate field
virtual void getUp(MeshEntity *e, Up &up)=0
Get the unordered set of one-level upward entities.
virtual void getMatches(MeshEntity *e, Matches &m)=0
get the periodic copies of an entity
int getModelTag(ModelEntity *e)
get the dimension-unique model entity identifier
virtual void destroyNative()=0
actually destroy the underlying mesh data structure
virtual MeshTag * createDoubleTag(const char *name, int size)=0
Creates a double array tag over the mesh given a name and size.
virtual void migrate(Migration *plan)=0
Migrate elements.
virtual int getId()=0
Get the part ID.
virtual void setLongTag(MeshEntity *e, MeshTag *tag, long const *data)=0
set long array tag data
static char const *const typeName[TYPES]
name strings for apf::Mesh::Type
bool canGetClosestPoint()
return true if the geometric model supports get closest point
pcu::PCU * getPCU() const
get the mesh pcu
virtual int getOwner(MeshEntity *e)=0
Returns the owning part number of this entity.
Numbering * getNumbering(int i)
get the i'th associated numbering
virtual bool isOwned(MeshEntity *e)=0
Returns true if the entity is shared in parallel and this is the dominant copy, or the entity is not ...
int getModelType(ModelEntity *e)
return the model entity dimension
virtual void getDgCopies(MeshEntity *e, DgCopies &dgCopies, ModelEntity *me=0)=0
get the DG copies of an entity on optional model entity filter
virtual int countUpward(MeshEntity *e)=0
Return the number of one-level upward adjacent entities.
virtual MeshEntity * iterate(MeshIterator *it)=0
iterate over mesh entities
bool getPeriodicRange(ModelEntity *g, int axis, double range[2])
get the periodic properties of a model entity
virtual Type getType(MeshEntity *e)=0
Get the topological type of a mesh entity.
virtual std::size_t count(int dimension)=0
returns the number of entities in this dimension
virtual void getIntTag(MeshEntity *e, MeshTag *tag, int *data)=0
get int array tag data
static Type const simplexTypes[4]
the simplex type for each dimension
virtual void getAdjacent(MeshEntity *e, int dimension, Adjacent &adjacent)=0
Returns the set of entities of one dimension adjacent to a given entity.
virtual int getDownward(MeshEntity *e, int dimension, MeshEntity **adjacent)=0
Returns an ordered set of downward adjacent entities.
virtual void getRemotes(MeshEntity *e, Copies &remotes)=0
Get the remote copies of an entity.
virtual void setDoubleTag(MeshEntity *e, MeshTag *tag, double const *data)=0
set double array tag data
ModelEntity * findModelEntity(int type, int tag)
get the model entity by dimension and identifier
Numbering * findNumbering(const char *name)
lookup a numbering by its unique name
virtual void getParam(MeshEntity *e, Vector3 &p)=0
Get the geometric parametric coordinates of a vertex.
static int const typeDimension[TYPES]
for a given entity type, its dimension.
Migration plan object: local elements to destinations.
MeshEntity * get(int i)
get the i'th element with an assigned destination
void send(MeshEntity *e, int to)
assign a destination part id to an element
Migration(Mesh *m)
must be constructed with a mesh
int sending(MeshEntity *e)
return the destination part id of an element
bool has(MeshEntity *e)
return true if the element has been assigned a destination
int count()
return the number of elements with assigned destinations
convenience wrapper over apf::Vector<3>
The Parallel Contrul Unit class encapsulates parallel communication.
All APF symbols are contained in this namespace.
DynamicArray< Copy > CopyArray
a set of copies, possibly multiple copies per part
MeshEntity * Downward[12]
a static array type downward adjacency queries.
void removeTagFromDimension(Mesh *m, MeshTag *tag, int d)
removes a tag from all entities of dimension (d)
int const prism_edge_verts[9][2]
map from prism edge order to prism vertex order
int countEntitiesOn(Mesh *m, ModelEntity *me, int dim)
count the number of mesh entities classified on a model entity
int const pyramid_tri_verts[4][3]
map from pyramid triangle order to pyramid vertex order
int const prism_quad_verts[3][4]
map from prism quad order to prism vertex order
DynamicArray< MeshEntity * > Adjacent
Set of adjacent mesh entities.
int countEntitiesOfType(Mesh *m, int type)
count all on-part entities of one topological type
int const prism_tri_verts[2][3]
map from prism triangle order to prism vertex order
int countOwned(Mesh *m, int dim, Sharing *shr=NULL)
count the number of owned entities of dimension (dim) using sharing shr the default sharing is used i...
int const tri_edge_verts[3][2]
map from triangle edge order to triangle vertex order
std::set< int > Parts
Set of unique part ids.
int getDimension(MeshElement *me)
Return the dimension of a MeshElement's MeshEntity.
void printStats(Mesh *m)
print global mesh entity counts per dimension
bool isSimplex(int type)
return true if the topological type is a simplex
Sharing * getSharing(Mesh *m)
create a default sharing object for this mesh
std::map< int, MeshEntity * > Copies
Remote copy container.
int const hex_quad_verts[6][4]
map from hex quad order to hex vertex order
void unfreezeFields(Mesh *m)
unfreeze all associated fields
void getBridgeAdjacent(Mesh *m, MeshEntity *origin, int bridgeDimension, int targetDimension, Adjacent &result)
get 2nd-order adjacent entities
NumberingOf< int > Numbering
Numbering is meant to be a 32-bit local numbering.
int const tet_edge_verts[6][2]
map from tet edge order to tet vertex order
NumberingOf< long > GlobalNumbering
Global numberings use 64-bit integers.
void freezeFields(Mesh *m)
freeze all associated fields
Copy Match
matches are just a special case of copies
int getFirstType(Mesh *m, int dim)
get the type of the first entity in this dimension
Vector< N > project(Vector< N > const &a, Vector< N > const &b)
Returns vector (a) projected onto vector (b)
MeshTag * tagOpposites(GlobalNumbering *gn, const char *name)
Tag boundary faces with global ids of opposite elements.
CopyArray Matches
a set of periodic copies
MeshEntity * findElement(Mesh *m, int type, MeshEntity **verts)
finds an entity from a set of vertices
MeshEntity * getEdgeVertOppositeVert(Mesh *m, MeshEntity *edge, MeshEntity *v)
get the other vertex of an edge
void verify(Mesh *m, bool abort_on_error=true)
run consistency checks on an apf::Mesh structure
Copy getOtherCopy(Mesh *m, MeshEntity *s)
given a mesh face, return its remote copy
int findIn(MeshEntity **a, int n, MeshEntity *e)
find pointer (e) in array (a) of length (n)
void getAlignment(Mesh *m, MeshEntity *elem, MeshEntity *boundary, int &which, bool &flip, int &rotate)
boundary entity alignment to an element
MeshEntity * findUpward(Mesh *m, int type, MeshEntity **down)
find an entity from one-level downward adjacencies
Vector3 getLinearCentroid(Mesh *m, MeshEntity *e)
get the average of the entity's vertex coordinates
void getPeers(Mesh *m, int d, Parts &peers)
scan the part for [vtx|edge|face]-adjacent part ids
CopyArray DgCopies
a set of DG copies
void unite(Parts &into, Parts const &from)
unite two sets of unique part ids
Matrix3x3 rotate(Vector3 const &u, double a)
get the rotation matrix around an axis
void warnAboutEmptyParts(Mesh *m)
print to stderr the number of empty parts, if any
void changeMeshShape(Mesh *m, FieldShape *newShape, bool project=true)
deprecated wrapper for apf::Mesh::changeShape
int const pyramid_edge_verts[8][2]
map from pyramid edge order to pyramid vertex order
void findTriDown(Mesh *m, MeshEntity **verts, MeshEntity **down)
given the vertices of a triangle, find its edges
int const tet_tri_verts[4][3]
map from tet triangle order to tet vertex order
int const quad_edge_verts[4][2]
map from quad edge order to quad vertex order
apf::Mesh2 Mesh
convenient mesh name
a reference to an object representing the same entity
Copy(int p, MeshEntity *e)
build from contents
int peer
resident part of the copy object
MeshEntity * entity
on-part pointer to the copy object
abstract description of entity copy sharing
virtual bool isOwned(MeshEntity *e)=0
return true if the entity is owned
virtual void getCopies(MeshEntity *e, CopyArray &copies)=0
get the copies of the entity
virtual int getOwner(MeshEntity *e)=0
return owning part ID
statically sized container for upward adjacency queries.
int n
actual number of adjacent entities
MeshEntity * e[400]
array containing pointers to adjacent entities
the basic structure for all GMI models