55 ModuleKey ProcessQualityMetric::className =
58 ProcessQualityMetric::create,
59 "add quality metric to field.");
75 if(
m_f->m_comm->TreatAsRankZero())
77 cout <<
"ProcessQualityMetric: Adding quality metric to field"
85 for(
int i =0; i <
m_f->m_exp[0]->GetExpSize(); ++i)
89 int offset =
m_f->m_exp[0]->GetPhys_Offset(i);
93 ASSERTL0(q.num_elements() == Elmt->GetTotPoints(),
"number of points mismatch");
97 m_f->m_exp[0]->FwdTrans_IterPerExp(phys, coeffs);
99 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
100 =
m_f->m_exp[0]->GetFieldDefinitions();
101 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
103 for (
int i = 0; i < FieldDef.size(); ++i)
105 FieldDef[i]->m_fields.push_back(
"QualityMetric");
106 m_f->m_exp[0]->AppendFieldData(FieldDef[i], FieldData[i]);
109 m_f->m_fielddef = FieldDef;
110 m_f->m_data = FieldData;
120 vector<Array<OneD, NekDouble> > xy;
121 for(
int i = 0; i < geom->GetNumVerts(); i++)
133 for(
int j = 0; j < b[1]->GetNumPoints(); j++)
135 for(
int i = 0; i < b[0]->GetNumPoints(); i++)
137 NekDouble a1 = 0.5*(1.0-u[i]), a2 = 0.5*(1.0+u[i]);
138 NekDouble b1 = 0.5*(1.0-v[j]), b2 = 0.5*(1.0+v[j]);
141 dxdz(0,0) = 0.5*(-b1*xy[0][0] + b1*xy[1][0] + b2*xy[2][0] - b2*xy[3][0]);
142 dxdz(1,0) = 0.5*(-b1*xy[0][1] + b1*xy[1][1] + b2*xy[2][1] - b2*xy[3][1]);
144 dxdz(0,1) = 0.5*(-a1*xy[0][0] - a2*xy[1][0] + a2*xy[2][0] + a1*xy[3][0]);
145 dxdz(1,1) = 0.5*(-a1*xy[0][1] - a2*xy[1][1] + a2*xy[2][1] + a1*xy[3][1]);
154 vector<Array<OneD, NekDouble> > xy;
155 for(
int i = 0; i < geom->GetNumVerts(); i++)
167 for(
int i = 0; i < b[0]->GetNumPoints(); i++)
169 for(
int j = 0; j < b[1]->GetNumPoints(); j++)
172 dxdz(0,0) = -xy[0][0]/2.0 + xy[1][0]/2.0;
174 dxdz(0,1) = -xy[0][0]/2.0 + xy[2][0]/2.0;
176 dxdz(1,0) = -xy[0][1]/2.0 + xy[1][1]/2.0;
178 dxdz(1,1) = -xy[0][1]/2.0 + xy[2][1]/2.0;
187 vector<Array<OneD, NekDouble> > xyz;
188 for(
int i = 0; i < geom->GetNumVerts(); i++)
201 for(
int i = 0; i < b[0]->GetNumPoints(); i++)
203 for(
int j = 0; j < b[1]->GetNumPoints(); j++)
205 for(
int k = 0; k < b[2]->GetNumPoints(); k++)
208 dxdz(0,0) = -xyz[0][0]/2.0 + xyz[1][0]/2.0;
210 dxdz(0,1) = -xyz[0][0]/2.0 + xyz[2][0]/2.0;
212 dxdz(0,2) = -xyz[0][0]/2.0 + xyz[3][0]/2.0;
215 dxdz(1,0) = -xyz[0][1]/2.0 + xyz[1][1]/2.0;
217 dxdz(1,1) = -xyz[0][1]/2.0 + xyz[2][1]/2.0;
219 dxdz(1,2) = -xyz[0][1]/2.0 + xyz[3][1]/2.0;
222 dxdz(2,0) = -xyz[0][2]/2.0 + xyz[1][2]/2.0;
224 dxdz(2,1) = -xyz[0][2]/2.0 + xyz[2][2]/2.0;
226 dxdz(2,2) = -xyz[0][2]/2.0 + xyz[3][2]/2.0;
236 vector<Array<OneD, NekDouble> > xyz;
237 for(
int i = 0; i < geom->GetNumVerts(); i++)
250 for(
int k = 0; k < b[2]->GetNumPoints(); k++)
252 for(
int j = 0; j < b[1]->GetNumPoints(); j++)
254 for(
int i = 0; i < b[0]->GetNumPoints(); i++)
256 NekDouble xi1 = 0.5*(1+eta1[i])*(1-eta3[k])-1.0;
258 NekDouble b1 = 0.5*(1-eta2[j]), b2 = 0.5*(1+eta2[j]);
259 NekDouble c1 = 0.5*(1-eta3[k]), c2 = 0.5*(1+eta3[k]);
263 dxdz(0,0) = 0.5*(-b1*xyz[0][0] + b1*xyz[1][0] + b2*xyz[2][0] - b2*xyz[3][0]);
264 dxdz(1,0) = 0.5*(-b1*xyz[0][1] + b1*xyz[1][1] + b2*xyz[2][1] - b2*xyz[3][1]);
265 dxdz(2,0) = 0.5*(-b1*xyz[0][2] + b1*xyz[1][2] + b2*xyz[2][2] - b2*xyz[3][2]);
267 dxdz(0,1) = 0.5*((a2-c1)*xyz[0][0] - a2*xyz[1][0] + a2*xyz[2][0] + (c1-a2)*xyz[3][0] - c2*xyz[4][0] + c2*xyz[5][0]);
268 dxdz(1,1) = 0.5*((a2-c1)*xyz[0][1] - a2*xyz[1][1] + a2*xyz[2][1] + (c1-a2)*xyz[3][1] - c2*xyz[4][1] + c2*xyz[5][1]);
269 dxdz(2,1) = 0.5*((a2-c1)*xyz[0][2] - a2*xyz[1][2] + a2*xyz[2][2] + (c1-a2)*xyz[3][2] - c2*xyz[4][2] + c2*xyz[5][2]);
271 dxdz(0,2) = 0.5*(-b1*xyz[0][0] - b2*xyz[3][0] + b1*xyz[4][0] + b2*xyz[5][0]);
272 dxdz(1,2) = 0.5*(-b1*xyz[0][1] - b2*xyz[3][1] + b1*xyz[4][1] + b2*xyz[5][1]);
273 dxdz(2,2) = 0.5*(-b1*xyz[0][2] - b2*xyz[3][2] + b1*xyz[4][2] + b2*xyz[5][2]);
298 const int expDim = chi->GetNumBases();
301 vector<LibUtilities::BasisKey> basisKeys;
302 bool needsInterp =
false;
304 for (
int i = 0; i < expDim; ++i)
306 nElemPts *= pElem[i].GetNumPoints();
308 needsInterp || pElem[i].GetNumPoints() < p[i].GetNumPoints() -1;
314 err <<
"Interpolating from higher order geometry to lower order in "
315 <<
"element " << geom->GetGlobalID();
319 for (
int i = 0; i < expDim; ++i)
322 needsInterp ? chi->GetBasis(i)->GetBasisKey() :
324 chi->GetBasisNumModes(i),
329 switch(chi->DetShapeType())
333 basisKeys[0], basisKeys[1]);
337 basisKeys[0], basisKeys[1]);
341 basisKeys[0], basisKeys[1], basisKeys[2]);
345 basisKeys[0], basisKeys[1], basisKeys[2]);
353 const int pts = deriv[0][0].num_elements();
354 const int nq = chiMod->GetTotPoints();
361 for (
int k = 0; k < pts; ++k)
366 for (
int i = 0; i < expDim; ++i)
368 for (
int j = 0; j < expDim; ++j)
370 jac(j,i) = deriv[i][j][k];
374 jacIdeal = jac * i2rm[k];
379 jacDet = jacIdeal(0,0) * jacIdeal(1,1) - jacIdeal(0,1)*jacIdeal(1,0);
383 jacDet = jacIdeal(0,0) * (jacIdeal(1,1)*jacIdeal(2,2) - jacIdeal(2,1)*jacIdeal(1,2)) -
384 jacIdeal(0,1) * (jacIdeal(1,0)*jacIdeal(2,2) - jacIdeal(2,0)*jacIdeal(1,2)) +
385 jacIdeal(0,2) * (jacIdeal(1,0)*jacIdeal(2,1) - jacIdeal(2,0)*jacIdeal(1,1));
394 for (
int i = 0; i < expDim; ++i)
396 for (
int j = 0; j < expDim; ++j)
398 frob += jacIdeal(i,j) * jacIdeal(i,j);
402 NekDouble sigma = 0.5*(jacDet + sqrt(jacDet*jacDet));
403 eta[k] = expDim * pow(sigma, 2.0/expDim) / frob;
407 if (needsInterp && pts != 1)
422 ASSERTL0(
false,
"mesh dim makes no sense");
#define ASSERTL0(condition, msg)
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
std::vector< PointsKey > PointsKeyVector
pair< ModuleType, string > ModuleKey
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
virtual ~ProcessQualityMetric()
FieldSharedPtr m_f
Field object.
void Interp2D(const BasisKey &fbasis0, const BasisKey &fbasis1, const Array< OneD, const NekDouble > &from, const BasisKey &tbasis0, const BasisKey &tbasis1, Array< OneD, NekDouble > &to)
this function interpolates a 2D function evaluated at the quadrature points of the 2D basis...
boost::shared_ptr< Expansion > ExpansionSharedPtr
boost::shared_ptr< Field > FieldSharedPtr
vector< DNekMat > MappingIdealToRef(SpatialDomains::GeometrySharedPtr geom, StdRegions::StdExpansionSharedPtr chi)
void Interp3D(const BasisKey &fbasis0, const BasisKey &fbasis1, const BasisKey &fbasis2, const Array< OneD, const NekDouble > &from, const BasisKey &tbasis0, const BasisKey &tbasis1, const BasisKey &tbasis2, Array< OneD, NekDouble > &to)
this function interpolates a 3D function evaluated at the quadrature points of the 3D basis...
boost::shared_ptr< GeomFactors > GeomFactorsSharedPtr
Pointer to a GeomFactors object.
Array< OneD, NekDouble > GetQ(LocalRegions::ExpansionSharedPtr e)
boost::shared_ptr< StdExpansion > StdExpansionSharedPtr
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
boost::shared_ptr< Geometry > GeometrySharedPtr
Describes the specification for a Basis.
boost::shared_ptr< PointGeom > PointGeomSharedPtr
ModuleFactory & GetModuleFactory()
Abstract base class for processing modules.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.