43 #include <boost/math/special_functions/fpclassify.hpp>
50 ModuleKey ProcessEquiSpacedOutput::className =
53 ProcessEquiSpacedOutput::create,
54 "Write data as equi-spaced output using simplices to represent the data for connecting points");
61 f->m_setUpEquiSpacedFields =
true;
64 "Only process tetrahedral elements");
83 cout <<
"Interpolating fields to equispaced" << endl;
86 int coordim =
m_f->m_exp[0]->GetCoordim(0);
87 int shapedim =
m_f->m_exp[0]->GetExp(0)->GetShapeDimension();
88 int npts =
m_f->m_exp[0]->GetTotPoints();
89 Array<OneD, Array<OneD, NekDouble> > coords(3);
91 int nel =
m_f->m_exp[0]->GetExpSize();
103 map<int,StdRegions::Orientation > face0orient;
104 set<int> prismorient;
107 for(
int i = 0; i < nel; ++i)
109 e =
m_f->m_exp[0]->GetExp(i);
113 int fid = e->GetGeom()->GetFid(0);
114 if(face0orient.count(fid))
116 prismorient.insert(i);
136 for(
int i = 0; i < nel; ++i)
138 e =
m_f->m_exp[0]->GetExp(i);
141 int fid = e->GetGeom()->GetFid(2);
143 if(face0orient.count(fid))
158 prismorient.insert(i);
165 prismorient.insert(i);
172 for(
int i = 0; i < nel; ++i)
174 e =
m_f->m_exp[0]->GetExp(i);
177 if(
m_f->m_exp[0]->GetExp(i)->DetShapeType() !=
191 switch(e->DetShapeType())
195 int npoints0 = e->GetBasis(0)->GetNumPoints();
199 m_f->m_fieldPts->m_npts.push_back(newpoints);
200 newtotpoints += newpoints;
205 int np0 = e->GetBasis(0)->GetNumPoints();
206 int np1 = e->GetBasis(1)->GetNumPoints();
207 int np = max(np0,np1);
210 m_f->m_fieldPts->m_npts.push_back(newpoints);
211 newtotpoints += newpoints;
216 int np0 = e->GetBasis(0)->GetNumPoints();
217 int np1 = e->GetBasis(1)->GetNumPoints();
218 int np = max(np0,np1);
222 m_f->m_fieldPts->m_npts.push_back(newpoints);
223 newtotpoints += newpoints;
228 int np0 = e->GetBasis(0)->GetNumPoints();
229 int np1 = e->GetBasis(1)->GetNumPoints();
230 int np2 = e->GetBasis(2)->GetNumPoints();
231 int np = max(np0,max(np1,np2));
235 m_f->m_fieldPts->m_npts.push_back(newpoints);
236 newtotpoints += newpoints;
241 int np0 = e->GetBasis(0)->GetNumPoints();
242 int np1 = e->GetBasis(1)->GetNumPoints();
243 int np2 = e->GetBasis(2)->GetNumPoints();
244 int np = max(np0,max(np1,np2));
248 m_f->m_fieldPts->m_npts.push_back(newpoints);
249 newtotpoints += newpoints;
254 int np0 = e->GetBasis(0)->GetNumPoints();
255 int np1 = e->GetBasis(1)->GetNumPoints();
256 int np2 = e->GetBasis(2)->GetNumPoints();
257 int np = max(np0,max(np1,np2));
261 m_f->m_fieldPts->m_npts.push_back(newpoints);
262 newtotpoints += newpoints;
267 int np0 = e->GetBasis(0)->GetNumPoints();
268 int np1 = e->GetBasis(1)->GetNumPoints();
269 int np2 = e->GetBasis(2)->GetNumPoints();
270 int np = max(np0,max(np1,np2));
274 m_f->m_fieldPts->m_npts.push_back(newpoints);
275 newtotpoints += newpoints;
286 bool standard =
true;
288 if(prismorient.count(i))
293 e->GetSimplexEquiSpacedConnectivity(conn,standard);
298 if((prevNcoeffs != e->GetNcoeffs()) ||
299 (prevNpoints != e->GetTotPoints()))
301 prevNcoeffs = e->GetNcoeffs();
302 prevNpoints = e->GetTotPoints();
304 e->GetSimplexEquiSpacedConnectivity(conn);
307 Array<OneD, int> newconn(conn.num_elements());
308 for(
int j = 0; j < conn.num_elements(); ++j)
310 newconn[j] = conn[j] + cnt;
313 m_f->m_fieldPts->m_ptsConn.push_back(newconn);
317 m_f->m_fieldPts->m_ptsDim = coordim;
318 if(
m_f->m_fielddef.size())
320 m_f->m_fieldPts->m_nFields =
m_f->m_exp.size();
324 m_f->m_fieldPts->m_nFields = 0;
327 m_f->m_fieldPts->m_pts = Array<OneD, Array<OneD, NekDouble> >(
328 m_f->m_fieldPts->m_nFields + coordim);
330 for(
int i = 0; i <
m_f->m_fieldPts->m_nFields + coordim; ++i)
332 m_f->m_fieldPts->m_pts[i] = Array<OneD, NekDouble>(newtotpoints);
336 for(
int i = 0; i < coordim; ++i)
338 coords[i] = Array<OneD, NekDouble>(
npts);
341 for(
int i = coordim; i < 3; ++i)
346 m_f->m_exp[0]->GetCoords(coords[0],coords[1],coords[2]);
348 int nq1 =
m_f->m_exp[0]->GetTotPoints();
350 Array<OneD, NekDouble> x1(nq1);
351 Array<OneD, NekDouble> y1(nq1);
352 Array<OneD, NekDouble> z1(nq1);
354 m_f->m_exp[0]->GetCoords(x1, y1, z1);
360 else if (shapedim == 3)
365 Array<OneD, NekDouble> tmp;
367 for(
int n = 0; n < coordim; ++n)
371 for(
int i = 0; i < nel; ++i)
373 m_f->m_exp[0]->GetExp(i)->PhysInterpToSimplexEquiSpaced(
375 tmp =
m_f->m_fieldPts->m_pts[n] + cnt1);
376 cnt1 +=
m_f->m_fieldPts->m_npts[i];
377 cnt +=
m_f->m_exp[0]->GetExp(i)->GetTotPoints();
381 if(
m_f->m_fielddef.size())
383 ASSERTL0(
m_f->m_fielddef[0]->m_fields.size() ==
m_f->m_exp.size(),
384 "More expansion defined than fields");
386 for(
int n = 0; n <
m_f->m_exp.size(); ++n)
390 Array<OneD, const NekDouble> phys =
m_f->m_exp[n]->GetPhys();
391 for(
int i = 0; i < nel; ++i)
393 m_f->m_exp[0]->GetExp(i)->PhysInterpToSimplexEquiSpaced(
395 tmp =
m_f->m_fieldPts->m_pts[coordim + n] + cnt1);
396 cnt1 +=
m_f->m_fieldPts->m_npts[i];
397 cnt +=
m_f->m_exp[0]->GetExp(i)->GetTotPoints();
401 m_f->m_fieldPts->m_fields.push_back(
402 m_f->m_fielddef[0]->m_fields[n]);