SCOREC core
Parallel unstructured mesh tools
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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;
39 
40 // seol
42  virtual void addGhost(MeshEntity* e, int p, MeshEntity* r) = 0;
43  virtual void deleteGhost(MeshEntity* e) = 0;
44 
47  virtual void setResidence(MeshEntity* e, Parts& residence) = 0;
49  virtual void setParam(MeshEntity* e, Vector3 const& p) = 0;
51  virtual void increment(MeshIterator* it) = 0;
53  virtual bool isDone(MeshIterator* it) = 0;
57  virtual MeshEntity* deref(MeshIterator* it) = 0;
59  void setPoint(MeshEntity* e, int node, Vector3 const& p);
61  virtual void setPoint_(MeshEntity* e, int node, Vector3 const& p) = 0;
65  MeshEntity* createVertex(ModelEntity* c, Vector3 const& point,
66  Vector3 const& param);
69  {
70  if (hasFrozenFields)
71  unfreezeFields(this);
72  }
74  virtual MeshEntity* createVert_(ModelEntity* c) = 0;
77  MeshEntity* createVert(ModelEntity* c)
78  {
80  return createVert_(c);
81  }
83  virtual MeshEntity* createEntity_(int type, ModelEntity* c,
84  MeshEntity** down) = 0;
91  MeshEntity* createEntity(int type, ModelEntity* c, MeshEntity** down)
92  {
94  return createEntity_(type,c,down);
95  }
97  virtual void destroy_(MeshEntity* e) = 0;
101  void destroy(MeshEntity* e)
102  {
103  requireUnfrozen();
104  destroy_(e);
105  }
107  virtual void setModelEntity(MeshEntity* e, ModelEntity* c) = 0;
109  virtual void addMatch(MeshEntity* e, int peer, MeshEntity* match) = 0;
111  virtual void clearMatches(MeshEntity* e) = 0;
113  virtual void clear_() = 0;
118  virtual void acceptChanges() = 0;
119 };
120 
127 void migrate(Mesh2* m, Migration* plan);
128 
129 void migrateSilent(Mesh2* m, Migration* plan);
130 
137 void setMigrationLimit(size_t maxElements);
138 
139 class Field;
140 
145 void displaceMesh(Mesh2* m, Field* d, double factor=1.0);
146 
149 {
150  public:
152  virtual void call(MeshEntity* e) = 0;
153 };
154 
157 MeshEntity* makeOrFind(
158  Mesh2* m,
159  ModelEntity* c,
160  int type,
161  MeshEntity** down,
162  BuildCallback* cb = 0,
163  bool* p_made = 0);
164 
170 MeshEntity* buildElement(
171  Mesh2* m,
172  ModelEntity* c,
173  int type,
174  MeshEntity** verts,
175  BuildCallback* cb = 0);
176 
180 MeshEntity* buildOneElement(
181  Mesh2* m,
182  ModelEntity* c,
183  int type,
184  Vector3 const* points);
185 
188 void initResidence(Mesh2* m, int dim);
189 
195 void stitchMesh(Mesh2* m);
196 
198 void clear(Mesh2* m);
199 
200 void packDataClone(Mesh2* m, int to);
201 void unpackDataClone(Mesh2* m);
202 
203 // common functions for migration/ghosting/distribution
204 typedef std::vector<MeshEntity*> EntityVector;
205 void packParts(int to, Parts& parts);
206 void unpackParts(Parts& parts);
207 void moveEntities(
208  Mesh2* m,
209  EntityVector senders[4]);
210 void updateMatching(
211  Mesh2* m,
212  EntityVector affected[4],
213  EntityVector senders[4]);
214 void deleteOldEntities(
215  Mesh2* m,
216  EntityVector affected[4]);
217 void reduceMatchingToSenders(
218  Mesh2* m,
219  EntityVector senders[4]);
220 void getSenders(Mesh2* m,EntityVector affected[4],EntityVector senders[4]);
221 void split(Copies& remotes, Parts& parts, Parts& newParts);
222 
223 // seol
224 void packEntity(Mesh2* m, int to, MeshEntity* e, DynamicArray<MeshTag*>& tags, bool ghosting=false);
225 void unpackRemotes(Mesh2* m, MeshEntity* e);
226 void unpackTags(Mesh2* m, MeshEntity* e, DynamicArray<MeshTag*>& tags);
227 void unpackCommon(Mesh2* m, MeshEntity*& sender, ModelEntity*& c, Parts& residence);
228 MeshEntity* unpackVertex(Mesh2* m, ModelEntity* c);
229 MeshEntity* unpackNonVertex(Mesh2* m,int type, ModelEntity* c);
230 
231 }//namespace apf
232 
233 #endif
void unfreezeFields(Mesh *m)
unfreeze all associated fields
std::map< int, MeshEntity * > Copies
Remote copy container.
Definition: apfMesh.h:36
virtual void addGhost(MeshEntity *e, int p, MeshEntity *r)=0
Add just one ghost copy to an entity.
virtual void destroy_(MeshEntity *e)=0
Underlying implementation of apf::Mesh2::destroy.
MeshEntity * buildElement(Mesh2 *m, ModelEntity *c, int type, MeshEntity **verts, BuildCallback *cb=0)
build an entity from its vertices
virtual void setModelEntity(MeshEntity *e, ModelEntity *c)=0
Change the geometric classification of an entity.
MeshEntity * createVertex(ModelEntity *c, Vector3 const &point, Vector3 const &param)
Create a fully-specified vertex.
User-defined entity creation callback.
Definition: apfMesh2.h:148
bool hasFrozenFields
true if any associated fields use array storage
Definition: apfMesh.h:399
virtual MeshEntity * createVert_(ModelEntity *c)=0
Underlying implementation of apf::Mesh2::createVert.
void migrate(Mesh2 *m, Migration *plan)
APF&#39;s migration function, works on apf::Mesh2.
virtual MeshEntity * createEntity_(int type, ModelEntity *c, MeshEntity **down)=0
Underlying implementation of apf::Mesh2::createEntity.
MeshEntity * createEntity(int type, ModelEntity *c, MeshEntity **down)
Create a non-vertex mesh entity.
Definition: apfMesh2.h:91
virtual void setParam(MeshEntity *e, Vector3 const &p)=0
Set the geometric parametric coordinates for a vertex.
virtual void clearMatches(MeshEntity *e)=0
Remove all matched copies of an entity.
MeshEntity * createVert(ModelEntity *c)
Just create a vertex.
Definition: apfMesh2.h:77
virtual void increment(MeshIterator *it)=0
Just increment an iterator.
virtual void setResidence(MeshEntity *e, Parts &residence)=0
Set the resident part set of an entity.
MeshEntity * buildOneElement(Mesh2 *m, ModelEntity *c, int type, Vector3 const *points)
build a one-element mesh
virtual void addMatch(MeshEntity *e, int peer, MeshEntity *match)=0
Add a matched copy to an entity.
void clear(Mesh2 *m)
removes all entities and fields.
virtual void clear_()=0
Remove all entities.
void displaceMesh(Mesh2 *m, Field *d, double factor=1.0)
add a field (times a factor) to the mesh coordinates
Interface to a mesh part.
Definition: apfMesh.h:103
void stitchMesh(Mesh2 *m)
infer all remote copies from those of vertices
void initResidence(Mesh2 *m, int dim)
Set entity residence based on remote copies.
void setMigrationLimit(size_t maxElements)
set the maximum elements that apf::migrate moves at once
void setPoint(MeshEntity *e, int node, Vector3 const &p)
Set the spacial coordinates of a mesh node.
void destroy(MeshEntity *e)
Destroy a mesh entity.
Definition: apfMesh2.h:101
convenience wrapper over apf::Vector&lt;3&gt;
Definition: apfVector.h:150
virtual MeshEntity * deref(MeshIterator *it)=0
Just dereference an iterator without incrementing it.
virtual void setPoint_(MeshEntity *e, int node, Vector3 const &p)=0
Underlying implementation of apf::Mesh2::setPoint.
virtual void addRemote(MeshEntity *e, int p, MeshEntity *r)=0
Add just one remote copy to an entity.
std::set< int > Parts
Set of unique part ids.
Definition: apfMesh.h:43
Extended mesh interface for modification.
Definition: apfMesh2.h:29
void requireUnfrozen()
require that no fields are stored in arrays
Definition: apfMesh2.h:68
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
virtual void setRemotes(MeshEntity *e, Copies &remotes)=0
Set the remote copies of an entity.
The APF Mesh interface.
virtual bool isDone(MeshIterator *it)=0
Return true iff the iterator points past the end.
virtual void call(MeshEntity *e)=0
will be called after an entity is created
virtual void acceptChanges()=0
Implementation-defined synchronization after modification.