15 #ifdef HAVE_ZOLTAN2_PARMA
25 #include "Teuchos_XMLParameterListHelpers.hpp"
33 typedef Tpetra::MultiVector<double, int, int>
tMVector_t;
37 if (ttype==apf::Mesh::VERTEX)
39 else if (ttype==apf::Mesh::EDGE)
43 else if (ttype==apf::Mesh::QUAD)
45 else if (ttype==apf::Mesh::TET)
47 else if (ttype==apf::Mesh::HEX)
54 throw "No such APF topology type";
62 int main(
int narg,
char *arg[]) {
64 Tpetra::ScopeGuard tscope(&narg, &arg);
65 Teuchos::RCP<const Teuchos::Comm<int> > CommT = Tpetra::getDefaultComm();
67 #ifdef HAVE_ZOLTAN2_PARMA
73 apf::Mesh2* m = apf::loadMdsMesh(
"pumiTri14/plate.dmg",
"pumiTri14/2/");
76 int dim = m->getDimension();
82 typedef Adapter::scalar_t scalar_t;
83 typedef Adapter::offset_t offset_t;
85 std::string pri =
"face";
86 std::string adj =
"vertex";
100 bool* has =
new bool[dim+1];
101 for (
int i=0;i<=dim;i++) {
109 std::cerr<<
"Local number of entities does not match in dimension "<<i<<
"\n";
117 apf::GlobalNumbering** gnums =
new apf::GlobalNumbering*[dim];
118 apf::Numbering** lnums =
new apf::Numbering*[dim];
120 for (
int i=0;i<=dim;i++) {
125 gnums[i] = m->getGlobalNumbering(i-sub);
126 lnums[i] = m->getNumbering(i-sub);
129 for (
int i=0;i<=dim;i++) {
134 const scalar_t* x_coords;
135 const scalar_t* y_coords;
136 const scalar_t* z_coords;
140 const offset_t** offsets =
new const offset_t*[dim];
141 const gno_t** adj_gids =
new const gno_t*[dim];
149 for (
int j=0;j<=dim;j++) {
152 if (ia.
availAdjs(ents[i],ents[j])!=(i!=j)) {
153 std::cerr<<
"First Adjacency does not exist from "<<i<<
" to "<< j<<
"\n";
156 ia.
getAdjsView(ents[i],ents[j],offsets[j],adj_gids[j]);
159 apf::MeshIterator* itr = m->begin(i);
160 apf::MeshEntity* ent;
161 size_t* numAdjs =
new size_t[dim+1];
162 for (
int k=0;k<=dim;k++)
164 while ((ent=m->iterate(itr))) {
166 if (apf::getNumber(lnums[i],ent,0,0)!=j) {
167 std::cerr<<
"Local numbering does not match in dimension "<<i<<
" on entity "<<j<<
"\n";
171 if (apf::getNumber(gnums[i],
apf::Node(ent,0))!=gids[j]) {
172 std::cerr<<
"Global numbering does not match in dimension "<<i<<
" on entity "<<j<<
"\n";
178 std::cerr<<
"Topology types do not match in dimension "<<i<<
" on entity "<<j<<
"\n";
185 m->getPoint(ent,0,pnt);
187 pnt = apf::getLinearCentroid(m,ent);
189 if (fabs(pnt[0] - x_coords[j*x_stride])>eps) {
190 std::cerr<<
"X coordinate do not match in dimension "<<i<<
" on entity "<<j<<
"\n";
193 if (fabs(pnt[1] - y_coords[j*y_stride])>eps) {
194 std::cerr<<
"Y coordinate do not match in dimension "<<i<<
" on entity "<<j<<
"\n";
197 if (fabs(pnt[2] - z_coords[j*z_stride])>eps) {
198 std::cerr<<
"Z coordinate do not match in dimension "<<i<<
" on entity "<<j<<
"\n";
203 for (
int k=0;k<=dim;k++) {
208 if (offsets[k]!=NULL || adj_gids[k]!=NULL) {
209 std::cerr<<
"[WARNING] First adjacency to self is not set to NULL in dimension "<<i
210 <<
" to dimension "<<k<<
"\n";
216 m->getAdjacent(ent,k,adjs);
217 offset_t ind = offsets[k][j];
218 for (
unsigned int l=0;l<adjs.getSize();l++) {
219 if (apf::getNumber(gnums[k],
apf::Node(adjs[l],0))!=adj_gids[k][ind]) {
220 std::cerr<<
"First adjacency does not match in dimension " <<i<<
" to dimension "<<k
221 <<
" on entity "<<j<<
"\n";
226 if (ind!=offsets[k][j+1]) {
227 std::cerr<<
"First adjacency length does not match in dimension "<<i<<
" to dimension "
228 <<k<<
" on entity "<<j<<
"\n";
231 numAdjs[k]+=adjs.getSize();
240 for (
int k=0;k<=dim;k++) {
244 std::cerr<<
"Local number of first adjacencies do not match in dimension "<<i
245 <<
" through dimension "<<k<<
"\n";
254 const Adapter::scalar_t arr[] = {1,2,1,3,1,5,1,2,1,6,1,7,1,8};
258 std::cerr<<
"Number of weights incorrect\n";
264 const Adapter::scalar_t* arr2;
267 for (
int i=0;i<7;i++) {
268 if (arr[i*stride]!=arr2[i*stride]) {
269 std::cerr<<
"Weights do not match the original input\n";
274 bool ifIdontfeellikeit =
false;
275 apf::MeshTag*
weights = m->createDoubleTag(
"weights",2);
276 apf::MeshIterator* itr = m->begin(0);
277 apf::MeshEntity* ent;
278 while ((ent=m->iterate(itr))) {
279 if (!ifIdontfeellikeit||PCU_Comm_Self()) {
280 double w[]={1.0,PCU_Comm_Self()+1.0};
281 m->setDoubleTag(ent,weights,w);
283 ifIdontfeellikeit=!ifIdontfeellikeit;
291 std::cerr<<
"Number of weights incorrect\n";
301 while ((ent=m->iterate(itr))) {
303 if (w!=arr2[i*stride]) {
304 std::cerr<<
"Weights do not match the original input\n";
316 while ((ent=m->iterate(itr))) {
319 m->getDoubleTag(ent,weights,w);
322 if (w[1]!=arr2[i*stride]) {
323 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.
map_t::global_ordinal_type gno_t
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.
int main(int narg, char **arg)
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.
map_t::local_ordinal_type lno_t
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.
Tpetra::MultiVector< zscalar_t, zlno_t, zgno_t, znode_t > tMVector_t