50 #ifdef HAVE_ZOLTAN2_PARMA
60 #include "Teuchos_XMLParameterListHelpers.hpp"
68 typedef Tpetra::MultiVector<double, int, int>
tMVector_t;
72 if (ttype==apf::Mesh::VERTEX)
74 else if (ttype==apf::Mesh::EDGE)
78 else if (ttype==apf::Mesh::QUAD)
80 else if (ttype==apf::Mesh::TET)
82 else if (ttype==apf::Mesh::HEX)
89 throw "No such APF topology type";
97 int main(
int narg,
char *arg[]) {
99 Tpetra::ScopeGuard tscope(&narg, &arg);
100 Teuchos::RCP<const Teuchos::Comm<int> > CommT = Tpetra::getDefaultComm();
102 #ifdef HAVE_ZOLTAN2_PARMA
108 apf::Mesh2* m = apf::loadMdsMesh(
"pumiTri14/plate.dmg",
"pumiTri14/2/");
111 int dim = m->getDimension();
115 typedef Adapter::lno_t lno_t;
116 typedef Adapter::gno_t gno_t;
117 typedef Adapter::scalar_t scalar_t;
118 typedef Adapter::offset_t offset_t;
120 std::string pri =
"face";
121 std::string adj =
"vertex";
135 bool* has =
new bool[dim+1];
136 for (
int i=0;i<=dim;i++) {
144 std::cerr<<
"Local number of entities does not match in dimension "<<i<<
"\n";
152 apf::GlobalNumbering** gnums =
new apf::GlobalNumbering*[dim];
153 apf::Numbering** lnums =
new apf::Numbering*[dim];
155 for (
int i=0;i<=dim;i++) {
160 gnums[i] = m->getGlobalNumbering(i-sub);
161 lnums[i] = m->getNumbering(i-sub);
164 for (
int i=0;i<=dim;i++) {
169 const scalar_t* x_coords;
170 const scalar_t* y_coords;
171 const scalar_t* z_coords;
175 const offset_t** offsets =
new const offset_t*[dim];
176 const gno_t** adj_gids =
new const gno_t*[dim];
184 for (
int j=0;j<=dim;j++) {
187 if (ia.
availAdjs(ents[i],ents[j])!=(i!=j)) {
188 std::cerr<<
"First Adjacency does not exist from "<<i<<
" to "<< j<<
"\n";
191 ia.
getAdjsView(ents[i],ents[j],offsets[j],adj_gids[j]);
194 apf::MeshIterator* itr = m->begin(i);
195 apf::MeshEntity* ent;
196 size_t* numAdjs =
new size_t[dim+1];
197 for (
int k=0;k<=dim;k++)
199 while ((ent=m->iterate(itr))) {
201 if (apf::getNumber(lnums[i],ent,0,0)!=j) {
202 std::cerr<<
"Local numbering does not match in dimension "<<i<<
" on entity "<<j<<
"\n";
206 if (apf::getNumber(gnums[i],
apf::Node(ent,0))!=gids[j]) {
207 std::cerr<<
"Global numbering does not match in dimension "<<i<<
" on entity "<<j<<
"\n";
213 std::cerr<<
"Topology types do not match in dimension "<<i<<
" on entity "<<j<<
"\n";
220 m->getPoint(ent,0,pnt);
222 pnt = apf::getLinearCentroid(m,ent);
224 if (fabs(pnt[0] - x_coords[j*x_stride])>eps) {
225 std::cerr<<
"X coordinate do not match in dimension "<<i<<
" on entity "<<j<<
"\n";
228 if (fabs(pnt[1] - y_coords[j*y_stride])>eps) {
229 std::cerr<<
"Y coordinate do not match in dimension "<<i<<
" on entity "<<j<<
"\n";
232 if (fabs(pnt[2] - z_coords[j*z_stride])>eps) {
233 std::cerr<<
"Z coordinate do not match in dimension "<<i<<
" on entity "<<j<<
"\n";
238 for (
int k=0;k<=dim;k++) {
243 if (offsets[k]!=NULL || adj_gids[k]!=NULL) {
244 std::cerr<<
"[WARNING] First adjacency to self is not set to NULL in dimension "<<i
245 <<
" to dimension "<<k<<
"\n";
251 m->getAdjacent(ent,k,adjs);
252 offset_t ind = offsets[k][j];
253 for (
unsigned int l=0;l<adjs.getSize();l++) {
254 if (apf::getNumber(gnums[k],
apf::Node(adjs[l],0))!=adj_gids[k][ind]) {
255 std::cerr<<
"First adjacency does not match in dimension " <<i<<
" to dimension "<<k
256 <<
" on entity "<<j<<
"\n";
261 if (ind!=offsets[k][j+1]) {
262 std::cerr<<
"First adjacency length does not match in dimension "<<i<<
" to dimension "
263 <<k<<
" on entity "<<j<<
"\n";
266 numAdjs[k]+=adjs.getSize();
275 for (
int k=0;k<=dim;k++) {
279 std::cerr<<
"Local number of first adjacencies do not match in dimension "<<i
280 <<
" through dimension "<<k<<
"\n";
289 const Adapter::scalar_t arr[] = {1,2,1,3,1,5,1,2,1,6,1,7,1,8};
293 std::cerr<<
"Number of weights incorrect\n";
299 const Adapter::scalar_t* arr2;
302 for (
int i=0;i<7;i++) {
303 if (arr[i*stride]!=arr2[i*stride]) {
304 std::cerr<<
"Weights do not match the original input\n";
309 bool ifIdontfeellikeit =
false;
310 apf::MeshTag*
weights = m->createDoubleTag(
"weights",2);
311 apf::MeshIterator* itr = m->begin(0);
312 apf::MeshEntity* ent;
313 while ((ent=m->iterate(itr))) {
314 if (!ifIdontfeellikeit||PCU_Comm_Self()) {
315 double w[]={1.0,PCU_Comm_Self()+1.0};
316 m->setDoubleTag(ent,weights,w);
318 ifIdontfeellikeit=!ifIdontfeellikeit;
326 std::cerr<<
"Number of weights incorrect\n";
336 while ((ent=m->iterate(itr))) {
338 if (w!=arr2[i*stride]) {
339 std::cerr<<
"Weights do not match the original input\n";
351 while ((ent=m->iterate(itr))) {
354 m->getDoubleTag(ent,weights,w);
357 if (w[1]!=arr2[i*stride]) {
358 std::cerr<<
"Weights do not match the original input\n";
virtual void getAdjsView(MeshEntityType source, MeshEntityType target, const offset_t *&offsets, const gno_t *&adjacencyIds) const
Sets pointers to this process' mesh first adjacencies.
virtual bool availAdjs(MeshEntityType source, MeshEntityType target) const
Returns whether a first adjacency combination is available.
virtual size_t getLocalNumOf(MeshEntityType etype) const =0
Returns the global number of mesh entities of MeshEntityType.
int main(int narg, char *arg[])
virtual void getWeightsViewOf(MeshEntityType etype, const scalar_t *&weights, int &stride, int idx=0) const
Provide a pointer to one of the number of this process' optional entity weights.
Defines the APFMeshAdapter class.
virtual void getIDsViewOf(MeshEntityType etype, gno_t const *&Ids) const =0
Provide a pointer to this process' identifiers.
virtual void getCoordinatesViewOf(MeshEntityType etype, const scalar_t *&coords, int &stride, int coordDim) const
Provide a pointer to one dimension of entity coordinates.
virtual size_t getLocalNumAdjs(MeshEntityType source, MeshEntityType target) const
Returns the number of first adjacencies on this process.
EntityTopologyType
Enumerate entity topology types for meshes: points,lines,polygons,triangles,quadrilaterals, polyhedrons, tetrahedrons, hexhedrons, prisms, or pyramids.
MeshEntityType
Enumerate entity types for meshes: Regions, Faces, Edges, or Vertices.
virtual int getNumWeightsPerOf(MeshEntityType etype) const
Return the number of weights per entity.
virtual void getTopologyViewOf(MeshEntityType etype, enum EntityTopologyType const *&Types) const
Provide a pointer to the entity topology types.