SCOREC core
Parallel unstructured mesh tools
apfMesh2.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011 Scientific Computation Research Center
3  *
4  * This work is open source software, licensed under the terms of the
5  * BSD license as described in the LICENSE file in the top-level directory.
6  */
7 
8 #ifndef APF_MESH2_H
9 #define APF_MESH2_H
10 
14 #include "apfMesh.h"
15 #include <set>
16 
17 namespace apf {
18 
29 class Mesh2 : public Mesh
30 {
31  public:
36  virtual void setRemotes(MeshEntity* e, Copies& remotes) = 0;
38  virtual void addRemote(MeshEntity* e, int p, MeshEntity* r) = 0;
40  virtual void clearRemotes(MeshEntity* e) = 0;
41 
42 // seol
44  virtual void addGhost(MeshEntity* e, int p, MeshEntity* r) = 0;
45  virtual void deleteGhost(MeshEntity* e) = 0;
46 
49  virtual void setResidence(MeshEntity* e, Parts& residence) = 0;
51  virtual void setParam(MeshEntity* e, Vector3 const& p) = 0;
53  virtual void increment(MeshIterator* it) = 0;
55  virtual bool isDone(MeshIterator* it) = 0;
59  virtual MeshEntity* deref(MeshIterator* it) = 0;
61  void setPoint(MeshEntity* e, int node, Vector3 const& p);
63  virtual void setPoint_(MeshEntity* e, int node, Vector3 const& p) = 0;
67  MeshEntity* createVertex(ModelEntity* c, Vector3 const& point,
68  Vector3 const& param);
71  {
72  if (hasFrozenFields)
73  unfreezeFields(this);
74  }
76  virtual MeshEntity* createVert_(ModelEntity* c) = 0;
79  MeshEntity* createVert(ModelEntity* c)
80  {
82  return createVert_(c);
83  }
85  virtual MeshEntity* createEntity_(int type, ModelEntity* c,
86  MeshEntity** down) = 0;
93  MeshEntity* createEntity(int type, ModelEntity* c, MeshEntity** down)
94  {
96  return createEntity_(type,c,down);
97  }
99  virtual void destroy_(MeshEntity* e) = 0;
103  void destroy(MeshEntity* e)
104  {
105  requireUnfrozen();
106  destroy_(e);
107  }
109  virtual void setModelEntity(MeshEntity* e, ModelEntity* c) = 0;
111  virtual void addMatch(MeshEntity* e, int peer, MeshEntity* match) = 0;
113  virtual void clearMatches(MeshEntity* e) = 0;
115  virtual void clear_() = 0;
120  virtual void acceptChanges() = 0;
121 };
122 
129 void migrate(Mesh2* m, Migration* plan);
130 
131 void migrateSilent(Mesh2* m, Migration* plan);
132 
139 void setMigrationLimit(size_t maxElements, pcu::PCU *PCUObj);
140 
141 class Field;
142 
147 void displaceMesh(Mesh2* m, Field* d, double factor=1.0);
148 
151 {
152  public:
154  virtual void call(MeshEntity* e) = 0;
155 };
156 
159 MeshEntity* makeOrFind(
160  Mesh2* m,
161  ModelEntity* c,
162  int type,
163  MeshEntity** down,
164  BuildCallback* cb = 0,
165  bool* p_made = 0);
166 
172 MeshEntity* buildElement(
173  Mesh2* m,
174  ModelEntity* c,
175  int type,
176  MeshEntity** verts,
177  BuildCallback* cb = 0);
178 
182 MeshEntity* buildOneElement(
183  Mesh2* m,
184  ModelEntity* c,
185  int type,
186  Vector3 const* points);
187 
190 void initResidence(Mesh2* m, int dim);
191 
197 void stitchMesh(Mesh2* m);
198 
200 void clear(Mesh2* m);
201 
202 void packDataClone(Mesh2* m, int to, pcu::PCU *PCUObj);
203 void unpackDataClone(Mesh2* m);
204 
205 // common functions for migration/ghosting/distribution
206 typedef std::vector<MeshEntity*> EntityVector;
207 void packParts(int to, Parts& parts, pcu::PCU *PCUObj);
208 void unpackParts(Parts& parts, pcu::PCU *PCUObj);
209 void moveEntities(
210  Mesh2* m,
211  EntityVector senders[4]);
212 void updateMatching(
213  Mesh2* m,
214  EntityVector affected[4],
215  EntityVector senders[4]);
216 void deleteOldEntities(
217  Mesh2* m,
218  EntityVector affected[4]);
219 void reduceMatchingToSenders(
220  Mesh2* m,
221  EntityVector senders[4]);
222 void getSenders(Mesh2* m,EntityVector affected[4],EntityVector senders[4]);
223 void split(Copies& remotes, Parts& parts, Parts& newParts, pcu::PCU *PCUObj);
224 
225 // seol
226 void packEntity(Mesh2* m, int to, MeshEntity* e, DynamicArray<MeshTag*>& tags, bool ghosting=false);
227 void unpackRemotes(Mesh2* m, MeshEntity* e);
228 void unpackTags(Mesh2* m, MeshEntity* e, DynamicArray<MeshTag*>& tags);
229 void unpackCommon(Mesh2* m, MeshEntity*& sender, ModelEntity*& c, Parts& residence);
230 MeshEntity* unpackVertex(Mesh2* m, ModelEntity* c);
231 MeshEntity* unpackNonVertex(Mesh2* m,int type, ModelEntity* c);
232 
233 }//namespace apf
234 
235 #endif
The APF Mesh interface.
User-defined entity creation callback.
Definition: apfMesh2.h:151
virtual void call(MeshEntity *e)=0
will be called after an entity is created
Extended mesh interface for modification.
Definition: apfMesh2.h:30
virtual MeshEntity * deref(MeshIterator *it)=0
Just dereference an iterator without incrementing it.
void destroy(MeshEntity *e)
Destroy a mesh entity.
Definition: apfMesh2.h:103
virtual MeshEntity * createVert_(ModelEntity *c)=0
Underlying implementation of apf::Mesh2::createVert.
virtual void clearRemotes(MeshEntity *e)=0
Remove remote copies.
virtual void clearMatches(MeshEntity *e)=0
Remove all matched copies of an entity.
virtual void setModelEntity(MeshEntity *e, ModelEntity *c)=0
Change the geometric classification of an entity.
void setPoint(MeshEntity *e, int node, Vector3 const &p)
Set the spacial coordinates of a mesh node.
virtual void setRemotes(MeshEntity *e, Copies &remotes)=0
Set the remote copies of an entity.
virtual void clear_()=0
Remove all entities.
virtual bool isDone(MeshIterator *it)=0
Return true iff the iterator points past the end.
virtual void acceptChanges()=0
Implementation-defined synchronization after modification.
void requireUnfrozen()
require that no fields are stored in arrays
Definition: apfMesh2.h:70
virtual void destroy_(MeshEntity *e)=0
Underlying implementation of apf::Mesh2::destroy.
virtual void addMatch(MeshEntity *e, int peer, MeshEntity *match)=0
Add a matched copy to an entity.
virtual void increment(MeshIterator *it)=0
Just increment an iterator.
virtual void setParam(MeshEntity *e, Vector3 const &p)=0
Set the geometric parametric coordinates for a vertex.
virtual void setResidence(MeshEntity *e, Parts &residence)=0
Set the resident part set of an entity.
virtual void addRemote(MeshEntity *e, int p, MeshEntity *r)=0
Add just one remote copy to an entity.
virtual void addGhost(MeshEntity *e, int p, MeshEntity *r)=0
Add just one ghost copy to an entity.
MeshEntity * createVertex(ModelEntity *c, Vector3 const &point, Vector3 const &param)
Create a fully-specified vertex.
MeshEntity * createEntity(int type, ModelEntity *c, MeshEntity **down)
Create a non-vertex mesh entity.
Definition: apfMesh2.h:93
virtual void setPoint_(MeshEntity *e, int node, Vector3 const &p)=0
Underlying implementation of apf::Mesh2::setPoint.
MeshEntity * createVert(ModelEntity *c)
Just create a vertex.
Definition: apfMesh2.h:79
virtual MeshEntity * createEntity_(int type, ModelEntity *c, MeshEntity **down)=0
Underlying implementation of apf::Mesh2::createEntity.
Interface to a mesh part.
Definition: apfMesh.h:105
bool hasFrozenFields
true if any associated fields use array storage
Definition: apfMesh.h:403
Migration plan object: local elements to destinations.
Definition: apfMesh.h:459
convenience wrapper over apf::Vector<3>
Definition: apfVector.h:151
The Parallel Contrul Unit class encapsulates parallel communication.
Definition: PCU.h:26
All APF symbols are contained in this namespace.
void setMigrationLimit(size_t maxElements, pcu::PCU *PCUObj)
set the maximum elements that apf::migrate moves at once
std::set< int > Parts
Set of unique part ids.
Definition: apfMesh.h:44
std::map< int, MeshEntity * > Copies
Remote copy container.
Definition: apfMesh.h:37
void unfreezeFields(Mesh *m)
unfreeze all associated fields
void stitchMesh(Mesh2 *m)
infer all remote copies from those of vertices
void displaceMesh(Mesh2 *m, Field *d, double factor=1.0)
add a field (times a factor) to the mesh coordinates
MeshEntity * buildOneElement(Mesh2 *m, ModelEntity *c, int type, Vector3 const *points)
build a one-element mesh
void migrate(Mesh2 *m, Migration *plan)
APF's migration function, works on apf::Mesh2.
void clear(Mesh2 *m)
removes all entities and fields.
MeshEntity * buildElement(Mesh2 *m, ModelEntity *c, int type, MeshEntity **verts, BuildCallback *cb=0)
build an entity from its vertices
void initResidence(Mesh2 *m, int dim)
Set entity residence based on remote copies.
MeshEntity * makeOrFind(Mesh2 *m, ModelEntity *c, int type, MeshEntity **down, BuildCallback *cb=0, bool *p_made=0)
like apf::Mesh2::createEntity, but returns already existing entities