18 #include "apfDynamicArray.h"
41 typedef std::map<int,MeshEntity*>
Copies;
119 virtual std::size_t
count(
int dimension) = 0;
121 virtual MeshIterator*
begin(
int dimension) = 0;
124 virtual MeshEntity*
iterate(MeshIterator* it) = 0;
128 virtual void end(MeshIterator* it) = 0;
131 virtual bool hasAdjacency(
int from_dim,
int to_dim) = 0;
133 virtual void createAdjacency(
int from_dim,
int to_dim) = 0;
135 virtual void deleteAdjacency(
int from_dim,
int to_dim) = 0;
138 virtual bool isShared(MeshEntity* e) = 0;
140 virtual bool isGhosted(MeshEntity* e) = 0;
141 virtual bool isGhost(MeshEntity* e) = 0;
144 virtual bool isOwned(MeshEntity* e) = 0;
146 virtual int getOwner(MeshEntity* e) = 0;
182 virtual void getAdjacent(MeshEntity* e,
int dimension,
192 virtual int getDownward(MeshEntity* e,
int dimension,
193 MeshEntity** adjacent) = 0;
197 virtual MeshEntity*
getUpward(MeshEntity* e,
int i) = 0;
199 virtual void getUp(MeshEntity* e,
Up& up) = 0;
201 virtual bool hasUp(MeshEntity* e) = 0;
221 virtual int getGhosts(MeshEntity* e,
Copies& ghosts) = 0;
229 virtual MeshTag*
createIntTag(
const char* name,
int size) = 0;
231 virtual MeshTag*
createLongTag(
const char* name,
int size) = 0;
233 virtual MeshTag*
findTag(
const char* name) = 0;
239 virtual void getTags(DynamicArray<MeshTag*>& tags) = 0;
242 virtual void getDoubleTag(MeshEntity* e, MeshTag* tag,
double* data) = 0;
245 virtual void setDoubleTag(MeshEntity* e, MeshTag* tag,
double const* data) = 0;
248 virtual void getIntTag(MeshEntity* e, MeshTag* tag,
int* data) = 0;
251 virtual void setIntTag(MeshEntity* e, MeshTag* tag,
int const* data) = 0;
254 virtual void getLongTag(MeshEntity* e, MeshTag* tag,
long* data) = 0;
257 virtual void setLongTag(MeshEntity* e, MeshTag* tag,
long const* data) = 0;
260 virtual void removeTag(MeshEntity* e, MeshTag* tag) = 0;
262 virtual bool hasTag(MeshEntity* e, MeshTag* tag) = 0;
264 virtual void renameTag(MeshTag* tag,
const char* newName) = 0;
283 virtual const char*
getTagName(MeshTag* t) = 0;
285 virtual ModelEntity*
toModel(MeshEntity* e) = 0;
343 virtual int getId() = 0;
345 virtual void writeNative(
const char* fileName) = 0;
350 virtual void verify() = 0;
393 int countGlobalNumberings();
401 Field* coordinateField;
402 std::vector<Field*> fields;
403 std::vector<Numbering*> numberings;
404 std::vector<GlobalNumbering*> globalNumberings;
410 void verify(
Mesh* m,
bool abort_on_error=
true);
412 long verifyVolumes(
Mesh* m,
bool printVolumes =
true);
439 int bridgeDimension,
int targetDimension,
Adjacent& result);
464 MeshEntity*
get(
int i);
466 bool has(MeshEntity* e);
468 void send(MeshEntity* e,
int to);
471 Mesh* getMesh() {
return mesh;}
475 std::vector<MeshEntity*> elements;
487 virtual bool isOwned(MeshEntity* e) = 0;
489 virtual int getOwner(MeshEntity* e) = 0;
493 virtual bool isShared(MeshEntity* e) = 0;
496 struct NormalSharing :
public Sharing
498 NormalSharing(
Mesh* m);
499 virtual int getOwner(MeshEntity* e);
500 virtual bool isOwned(MeshEntity* e);
501 virtual void getCopies(MeshEntity* e,
503 virtual bool isShared(MeshEntity* e);
508 struct MatchedSharing :
public Sharing
510 MatchedSharing(
Mesh* m);
511 Copy getOwnerCopy(MeshEntity* e);
512 virtual int getOwner(MeshEntity* e);
513 virtual bool isOwned(MeshEntity* e);
514 virtual void getCopies(MeshEntity* e,
516 virtual bool isShared(MeshEntity* e);
519 size_t getNeighborCount(
int peer);
520 bool isLess(Copy
const& a, Copy
const& b);
521 void getNeighbors(
Parts& neighbors);
523 NormalSharing helper;
524 std::map<int, size_t> countMap;
560 int findIn(MeshEntity** a,
int n, MeshEntity* e);
595 virtual MeshEntity* apply(
int type, MeshEntity** down) = 0;
596 MeshEntity* run(
int type, MeshEntity** verts);
597 void runDown(
int type, MeshEntity** verts, MeshEntity** down);
612 int& which,
bool& flip,
int&
rotate);
614 void packString(std::string s,
int to);
615 std::string unpackString();
616 void packTagInfo(
Mesh* m, MeshTag* t,
int to);
617 void unpackTagInfo(std::string& name,
int& type,
int& size);
619 extern char const*
const dimName[4];
void getAlignment(Mesh *m, MeshEntity *elem, MeshEntity *boundary, int &which, bool &flip, int &rotate)
boundary entity alignment to an element
void send(MeshEntity *e, int to)
assign a destination part id to an element
void unfreezeFields(Mesh *m)
unfreeze all associated fields
Numbering * getNumbering(int i)
get the i'th associated numbering
void getFirstDerivative(ModelEntity *g, Vector3 const &p, Vector3 &t0, Vector3 &t1)
get first derivative at a point
std::map< int, MeshEntity * > Copies
Remote copy container.
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...
virtual void getUp(MeshEntity *e, Up &up)=0
Get the unordered set of one-level upward entities.
void removeField(Field *f)
disassociate a field from this mesh
Migration plan object: local elements to destinations.
virtual bool isOwned(MeshEntity *e)=0
return true if the entity is owned
DynamicArray< Copy > CopyArray
a set of copies, possibly multiple copies per part
Copy Match
matches are just a special case of copies
virtual void setLongTag(MeshEntity *e, MeshTag *tag, long const *data)=0
set long array tag data
void getPoint(MeshEntity *e, int node, Vector3 &point)
Returns the coordinates of a node on a mesh entity.
64-bit IEE754 floating-point number
void boundingBox(ModelEntity *g, Vector3 &bmin, Vector3 &bmax)
get the bounding box of the model entity g
Migration(Mesh *m)
must be constructed with a mesh
NumberingOf< long > GlobalNumbering
Global numberings use 64-bit integers.
static char const *const typeName[TYPES]
name strings for apf::Mesh::Type
int const prism_edge_verts[9][2]
map from prism edge order to prism vertex order
int const hex_quad_verts[6][4]
map from hex quad order to hex vertex order
virtual void removeTag(MeshEntity *e, MeshTag *tag)=0
detach tag data from an entity.
int count()
return the number of elements with assigned destinations
placeholder to set array sizes
MeshEntity * Downward[12]
a static array type downward adjacency queries.
bool canGetModelNormal()
return true if the geometric model supports normal computation
Field * getField(int i)
get the i'th associated field
CopyArray Matches
a set of periodic copies
void changeMeshShape(Mesh *m, FieldShape *newShape, bool project=true)
deprecated wrapper for apf::Mesh::changeShape
bool hasFrozenFields
true if any associated fields use array storage
Copy getOtherCopy(Mesh *m, MeshEntity *s)
given a mesh face, return its remote copy
MeshEntity * findUpward(Mesh *m, int type, MeshEntity **down)
find an entity from one-level downward adjacencies
virtual ~Mesh()
destroy the base class structures.
virtual void getParam(MeshEntity *e, Vector3 &p)=0
Get the geometric parametric coordinates of a vertex.
virtual void end(MeshIterator *it)=0
destroy an iterator.
virtual int getOwner(MeshEntity *e)=0
Returns the owning part number of this entity.
Sharing * getSharing(Mesh *m)
create a default sharing object for this mesh
Describes field distribution and shape functions.
int getDimension(Mesh *m, MeshEntity *e)
get the dimension of a mesh entity
static int const typeDimension[TYPES]
for a given entity type, its dimension.
void init(FieldShape *s)
initialize the base class structures.
virtual void renameTag(MeshTag *tag, const char *newName)=0
renames a tag
virtual int getId()=0
Get the part ID.
virtual int getOwner(MeshEntity *e)=0
return owning part ID
void getPeers(Mesh *m, int d, Parts &peers)
scan the part for [vtx|edge|face]-adjacent part ids
virtual int getDownward(MeshEntity *e, int dimension, MeshEntity **adjacent)=0
Returns an ordered set of downward adjacent entities.
virtual int getTagSize(MeshTag *t)=0
return the array size of a tag
Type
Entity topological types.
FieldShape * getShape() const
get the distribution of the mesh's coordinate field
virtual void writeNative(const char *fileName)=0
write the underlying mesh into a set of files
virtual std::size_t count(int dimension)=0
returns the number of entities in this dimension
Copy(int p, MeshEntity *e)
build from contents
bool isInClosureOf(ModelEntity *g, ModelEntity *target)
checks if g is in the closure of the target
void getParamOn(ModelEntity *g, MeshEntity *e, Vector3 &p)
reparameterize mesh vertex (e) onto model entity (g)
virtual void getTags(DynamicArray< MeshTag * > &tags)=0
Get all the tags on a mesh part.
the basic structure for all GMI models
bool has(MeshEntity *e)
return true if the element has been assigned a destination
void setCoordinateField(Field *field)
Set the mesh's coordinate field - Be very careful using this.
int countNumberings()
get the number of associated numberings
virtual double getElementBytes(int)
estimate mesh entity memory usage.
int countFields()
get the number of associated fields
virtual void destroyTag(MeshTag *tag)=0
Removes a mesh tag. This does not detach data from entities.
void verify(Mesh *m, bool abort_on_error=true)
run consistency checks on an apf::Mesh structure
int const prism_tri_verts[2][3]
map from prism triangle order to prism vertex order
virtual MeshTag * createLongTag(const char *name, int size)=0
Creates a long array tag over the mesh given a name and size.
Numbering * findNumbering(const char *name)
lookup a numbering by its unique name
int const pyramid_tri_verts[4][3]
map from pyramid triangle order to pyramid vertex order
TagType
Tag data type enumeration.
void unite(Parts &into, Parts const &from)
unite two sets of unique part ids
static int const adjacentCount[TYPES][4]
for a given entity type, number of adjacent entities of a given dimension
int const tet_edge_verts[6][2]
map from tet edge order to tet vertex order
int getModelType(ModelEntity *e)
return the model entity dimension
virtual void getLongTag(MeshEntity *e, MeshTag *tag, long *data)=0
get long array tag data
Interface to a mesh part.
virtual gmi_model * getModel()=0
get a GMI interface to the geometric model
void getNormal(ModelEntity *g, Vector3 const &p, Vector3 &n)
get normal vector at a point
MeshEntity * findElement(Mesh *m, int type, MeshEntity **verts)
finds an entity from a set of vertices
bool isOnModel(ModelEntity *g, Vector3 p, double scale)
checks if p is on model g
bool getPeriodicRange(ModelEntity *g, int axis, double range[2])
get the periodic properties of a model entity
virtual bool hasMatching()=0
return true if the mesh has matched entities
bool isSimplex(int type)
return true if the topological type is a simplex
void findTriDown(Mesh *m, MeshEntity **verts, MeshEntity **down)
given the vertices of a triangle, find its edges
MeshEntity * getEdgeVertOppositeVert(Mesh *m, MeshEntity *edge, MeshEntity *v)
get the other vertex of an edge
virtual void getDgCopies(MeshEntity *e, DgCopies &dgCopies, ModelEntity *me=0)=0
get the DG copies of an entity on optional model entity filter
int const quad_edge_verts[4][2]
map from quad edge order to quad vertex order
virtual bool hasTag(MeshEntity *e, MeshTag *tag)=0
Returns true if there is data for this tag attached.
apf::Mesh2 Mesh
convenient mesh name
int const prism_quad_verts[3][4]
map from prism quad order to prism vertex order
static Type const simplexTypes[4]
the simplex type for each dimension
abstract description of entity copy sharing
statically sized container for upward adjacency queries.
virtual void destroyNative()=0
actually destroy the underlying mesh data structure
convenience wrapper over apf::Vector<3>
int peer
resident part of the copy object
virtual MeshIterator * begin(int dimension)=0
begins iteration over elements of one dimension
bool canSnap()
return true if the geometric model supports snapping
int const tet_tri_verts[4][3]
map from tet triangle order to tet vertex order
GlobalNumbering * findGlobalNumbering(const char *name)
lookup a numbering by its unique name
int n
actual number of adjacent entities
virtual bool hasUp(MeshEntity *e)=0
Return true iff the entity has upward adjacencies.
virtual MeshTag * findTag(const char *name)=0
Finds a tag by name, returns 0 if it doesn't exist.
virtual unsigned getTagChecksum(MeshTag *tag, int type)=0
returns the checksum of a tag for the specificed topological type
void warnAboutEmptyParts(Mesh *m)
print to stderr the number of empty parts, if any
virtual void setModel(gmi_model *newModel)=0
set the geometric model
int const tri_edge_verts[3][2]
map from triangle edge order to triangle vertex order
virtual void verify()=0
run a set of consistency checks on the underlying data structure
void removeTagFromDimension(Mesh *m, MeshTag *tag, int d)
removes a tag from all entities of dimension (d)
virtual void getDoubleTag(MeshEntity *e, MeshTag *tag, double *data)=0
get double array tag data
virtual void getIntTag(MeshEntity *e, MeshTag *tag, int *data)=0
get int array tag data
int findIn(MeshEntity **a, int n, MeshEntity *e)
find pointer (e) in array (a) of length (n)
virtual ModelEntity * toModel(MeshEntity *e)=0
get geometric classification
virtual MeshTag * createIntTag(const char *name, int size)=0
Creates an int array tag over the mesh given a name and size.
virtual MeshEntity * getUpward(MeshEntity *e, int i)=0
Get the i'th one-level upward adjacent entity.
std::set< int > Parts
Set of unique part ids.
Vector3 getLinearCentroid(Mesh *m, MeshEntity *e)
get the average of the entity's vertex coordinates
virtual void getCopies(MeshEntity *e, CopyArray &copies)=0
get the copies of the entity
int const pyramid_edge_verts[8][2]
map from pyramid edge order to pyramid vertex order
DynamicArray< MeshEntity * > Adjacent
Set of adjacent mesh entities.
bool canGetClosestPoint()
return true if the geometric model supports get closest point
virtual void setDoubleTag(MeshEntity *e, MeshTag *tag, double const *data)=0
set double array tag data
void changeShape(FieldShape *newShape, bool project=true)
make a new coordinate field.
Field * getCoordinateField()
get the mesh's coordinate field
virtual void getRemotes(MeshEntity *e, Copies &remotes)=0
Get the remote copies of an entity.
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 ...
void getClosestPoint(ModelEntity *g, Vector3 const &from, Vector3 &to, Vector3 &p)
get closest point on geometry
virtual const char * getTagName(MeshTag *t)=0
return the name of a tag
virtual MeshEntity * iterate(MeshIterator *it)=0
iterate over mesh entities
virtual bool isShared(MeshEntity *e)=0
Returns true if the entity is shared in parallel.
int sending(MeshEntity *e)
return the destination part id of an element
int countEntitiesOfType(Mesh *m, int type)
count all on-part entities of one topological type
MeshEntity * entity
on-part pointer to the copy object
Matrix3x3 rotate(Vector3 const &u, double a)
get the rotation matrix around an axis
int getFirstType(Mesh *m, int dim)
get the type of the first entity in this dimension
ModelEntity * findModelEntity(int type, int tag)
get the model entity by dimension and identifier
virtual void migrate(Migration *plan)=0
Migrate elements.
virtual void getMatches(MeshEntity *e, Matches &m)=0
get the periodic copies of an entity
bool isParamPointInsideModel(ModelEntity *g, Vector3 const ¶m, Vector3 &x)
checks if parametric point is inside the model, and updates puts the location in x ...
void printStats(Mesh *m)
print global mesh entity counts per dimension
virtual MeshTag * createDoubleTag(const char *name, int size)=0
Creates a double array tag over the mesh given a name and size.
NumberingOf< int > Numbering
Numbering is meant to be a 32-bit local numbering.
void addField(Field *f)
associate a field with this mesh
int countEntitiesOn(Mesh *m, ModelEntity *me, int dim)
count the number of mesh entities classified on a model entity
CopyArray DgCopies
a set of DG copies
void snapToModel(ModelEntity *m, Vector3 const &p, Vector3 &x)
evaluate parametric coordinate (p) as a spatial point (x)
Field * findField(const char *name)
lookup a field by its unique name
virtual void getResidence(MeshEntity *e, Parts &residence)=0
Get the resident parts of an entity.
virtual void getPoint_(MeshEntity *e, int node, Vector3 &point)=0
Implementation-defined code for apf::Mesh::getPoint.
MeshEntity * e[400]
array containing pointers to adjacent entities
virtual int countUpward(MeshEntity *e)=0
Return the number of one-level upward adjacent entities.
void removeNumbering(Numbering *f)
disassociate a numbering from this mesh
virtual int getDimension()=0
returns the element dimension of this mesh
Vector< N > project(Vector< N > const &a, Vector< N > const &b)
Returns vector (a) projected onto vector (b)
void addNumbering(Numbering *f)
associate a numbering with this mesh
virtual void setIntTag(MeshEntity *e, MeshTag *tag, int const *data)=0
set int array tag data
virtual void getAdjacent(MeshEntity *e, int dimension, Adjacent &adjacent)=0
Returns the set of entities of one dimension adjacent to a given entity.
The APF linear algebra vector interface.
int getModelTag(ModelEntity *e)
get the dimension-unique model entity identifier
virtual int getTagType(MeshTag *t)=0
get the data type of a tag
virtual Type getType(MeshEntity *e)=0
Get the topological type of a mesh entity.
void getBridgeAdjacent(Mesh *m, MeshEntity *origin, int bridgeDimension, int targetDimension, Adjacent &result)
get 2nd-order adjacent entities
a reference to an object representing the same entity