Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | List of all members
Nektar::Utilities::ProcessQualityMetric Class Reference

This processing module scales the input fld file. More...

#include <ProcessQualityMetric.h>

Inheritance diagram for Nektar::Utilities::ProcessQualityMetric:
Inheritance graph
[legend]
Collaboration diagram for Nektar::Utilities::ProcessQualityMetric:
Collaboration graph
[legend]

Public Member Functions

 ProcessQualityMetric (FieldSharedPtr f)
 
virtual ~ProcessQualityMetric ()
 
virtual void Process (po::variables_map &vm)
 Write mesh to output file. More...
 
- Public Member Functions inherited from Nektar::Utilities::ProcessModule
 ProcessModule ()
 
 ProcessModule (FieldSharedPtr p_f)
 
 ProcessModule (MeshSharedPtr p_m)
 
- Public Member Functions inherited from Nektar::Utilities::Module
 Module (FieldSharedPtr p_f)
 
void RegisterConfig (string key, string value)
 Register a configuration option with a module. More...
 
void PrintConfig ()
 Print out all configuration options for a module. More...
 
void SetDefaults ()
 Sets default configuration options for those which have not been set. More...
 
bool GetRequireEquiSpaced (void)
 
void SetRequireEquiSpaced (bool pVal)
 
void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 
 Module (MeshSharedPtr p_m)
 
virtual void Process ()=0
 
void RegisterConfig (std::string key, std::string value)
 
void PrintConfig ()
 
void SetDefaults ()
 
MeshSharedPtr GetMesh ()
 
virtual void ProcessVertices ()
 Extract element vertices. More...
 
virtual void ProcessEdges (bool ReprocessEdges=true)
 Extract element edges. More...
 
virtual void ProcessFaces (bool ReprocessFaces=true)
 Extract element faces. More...
 
virtual void ProcessElements ()
 Generate element IDs. More...
 
virtual void ProcessComposites ()
 Generate composites. More...
 
virtual void ClearElementLinks ()
 

Static Public Member Functions

static boost::shared_ptr< Modulecreate (FieldSharedPtr f)
 Creates an instance of this class. More...
 

Static Public Attributes

static ModuleKey className
 

Private Member Functions

Array< OneD, NekDoubleGetQ (LocalRegions::ExpansionSharedPtr e)
 

Additional Inherited Members

- Protected Member Functions inherited from Nektar::Utilities::Module
 Module ()
 
void ReorderPrisms (PerMap &perFaces)
 Reorder node IDs so that prisms and tetrahedra are aligned correctly. More...
 
void PrismLines (int prism, PerMap &perFaces, std::set< int > &prismsDone, std::vector< ElementSharedPtr > &line)
 
- Protected Attributes inherited from Nektar::Utilities::Module
FieldSharedPtr m_f
 Field object. More...
 
map< string, ConfigOptionm_config
 List of configuration values. More...
 
bool m_requireEquiSpaced
 
MeshSharedPtr m_mesh
 Mesh object. More...
 
std::map< std::string,
ConfigOption
m_config
 List of configuration values. More...
 

Detailed Description

This processing module scales the input fld file.

Definition at line 47 of file ProcessQualityMetric.h.

Constructor & Destructor Documentation

Nektar::Utilities::ProcessQualityMetric::ProcessQualityMetric ( FieldSharedPtr  f)

Definition at line 61 of file ProcessQualityMetric.cpp.

61  :
62  ProcessModule(f)
63 {
64 
65 }
Nektar::Utilities::ProcessQualityMetric::~ProcessQualityMetric ( )
virtual

Definition at line 67 of file ProcessQualityMetric.cpp.

68 {
69 }

Member Function Documentation

static boost::shared_ptr<Module> Nektar::Utilities::ProcessQualityMetric::create ( FieldSharedPtr  f)
inlinestatic

Creates an instance of this class.

Definition at line 51 of file ProcessQualityMetric.h.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr().

52  {
54  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
Array< OneD, NekDouble > Nektar::Utilities::ProcessQualityMetric::GetQ ( LocalRegions::ExpansionSharedPtr  e)
private

Definition at line 287 of file ProcessQualityMetric.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL0, Nektar::eFULL, Nektar::LibUtilities::ePrism, Nektar::LibUtilities::eQuadrilateral, Nektar::LibUtilities::eTetrahedron, Nektar::LibUtilities::eTriangle, ErrorUtil::ewarning, Vmath::Fill(), Nektar::LibUtilities::Interp2D(), Nektar::LibUtilities::Interp3D(), Nektar::Utilities::MappingIdealToRef(), and NEKERROR.

Referenced by Process().

288 {
289  SpatialDomains::GeometrySharedPtr geom = e->GetGeom();
290  StdRegions::StdExpansionSharedPtr chi = e->GetGeom()->GetXmap();
291  LibUtilities::PointsKeyVector p = chi->GetPointsKeys();
292  LibUtilities::PointsKeyVector pElem= e->GetPointsKeys();
293  SpatialDomains::GeomFactorsSharedPtr gfac = geom->GetGeomFactors();
294  const int expDim = chi->GetNumBases();
295  int nElemPts = 1;
296 
297  vector<LibUtilities::BasisKey> basisKeys;
298  bool needsInterp = false;
299 
300  for (int i = 0; i < expDim; ++i)
301  {
302  nElemPts *= pElem[i].GetNumPoints();
303  needsInterp =
304  needsInterp || pElem[i].GetNumPoints() < p[i].GetNumPoints() -1;
305  }
306 
307  if (needsInterp)
308  {
309  stringstream err;
310  err << "Interpolating from higher order geometry to lower order in "
311  << "element " << geom->GetGlobalID();
312  NEKERROR(ErrorUtil::ewarning, err.str());
313  }
314 
315  for (int i = 0; i < expDim; ++i)
316  {
317  basisKeys.push_back(
318  needsInterp ? chi->GetBasis(i)->GetBasisKey() :
319  LibUtilities::BasisKey(chi->GetBasisType(i),
320  chi->GetBasisNumModes(i),
321  pElem[i]));
322  }
323 
325  switch(chi->DetShapeType())
326  {
329  basisKeys[0], basisKeys[1]);
330  break;
333  basisKeys[0], basisKeys[1]);
334  break;
337  basisKeys[0], basisKeys[1], basisKeys[2]);
338  break;
341  basisKeys[0], basisKeys[1], basisKeys[2]);
342  break;
343  default:
344  ASSERTL0(false, "nope");
345  }
346 
347  SpatialDomains::DerivStorage deriv = gfac->GetDeriv(pElem);
348 
349  const int pts = deriv[0][0].num_elements();
350  const int nq = chiMod->GetTotPoints();
351 
352  ASSERTL0(pts == nq, "what");
353 
354  vector<DNekMat> i2rm = MappingIdealToRef(geom, chiMod);
355  Array<OneD, NekDouble> eta(nq);
356 
357  for (int k = 0; k < pts; ++k)
358  {
359  DNekMat jac (expDim, expDim, 0.0, eFULL);
360  DNekMat jacIdeal(expDim, expDim, 0.0, eFULL);
361 
362  for (int i = 0; i < expDim; ++i)
363  {
364  for (int j = 0; j < expDim; ++j)
365  {
366  jac(j,i) = deriv[i][j][k];
367  }
368  }
369 
370  jacIdeal = jac * i2rm[k];
371  NekDouble jacDet;
372 
373  if(expDim == 2)
374  {
375  jacDet = jacIdeal(0,0) * jacIdeal(1,1) - jacIdeal(0,1)*jacIdeal(1,0);
376  }
377  else if(expDim == 3)
378  {
379  jacDet = jacIdeal(0,0) * (jacIdeal(1,1)*jacIdeal(2,2) - jacIdeal(2,1)*jacIdeal(1,2)) -
380  jacIdeal(0,1) * (jacIdeal(1,0)*jacIdeal(2,2) - jacIdeal(2,0)*jacIdeal(1,2)) +
381  jacIdeal(0,2) * (jacIdeal(1,0)*jacIdeal(2,1) - jacIdeal(2,0)*jacIdeal(1,1));
382  }
383  else
384  {
385  ASSERTL0(false,"silly exp dim");
386  }
387 
388  NekDouble frob = 0.0;
389 
390  for (int i = 0; i < expDim; ++i)
391  {
392  for (int j = 0; j < expDim; ++j)
393  {
394  frob += jacIdeal(i,j) * jacIdeal(i,j);
395  }
396  }
397 
398  NekDouble sigma = 0.5*(jacDet + sqrt(jacDet*jacDet));
399  eta[k] = expDim * pow(sigma, 2.0/expDim) / frob;
400  }
401 
402  // Project onto output stuff
403  if (needsInterp && pts != 1)
404  {
405  Array<OneD, NekDouble> tmp(nElemPts);
406 
407  if (expDim == 2)
408  {
409  LibUtilities::Interp2D(p[0], p[1], eta, pElem[0], pElem[1], tmp);
410  }
411  else if(expDim == 3)
412  {
413  LibUtilities::Interp3D(p[0], p[1], p[2], eta, pElem[0], pElem[1],
414  pElem[2], tmp);
415  }
416  else
417  {
418  ASSERTL0(false,"mesh dim makes no sense");
419  }
420 
421  eta = tmp;
422  }
423 
424  if (pts == 1)
425  {
426  Vmath::Fill(nq-1, eta[0], &eta[1], 1);
427  }
428 
429  return eta;
430 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
Definition: ErrorUtil.hpp:158
std::vector< PointsKey > PointsKeyVector
Definition: Points.h:220
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.
Definition: Vmath.cpp:46
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...
Definition: Interp.cpp:116
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > DerivStorage
Storage type for derivative of mapping.
Definition: GeomFactors.h:75
NekMatrix< NekDouble, StandardMatrixTag > DNekMat
Definition: NekTypeDefs.hpp:52
double NekDouble
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...
Definition: Interp.cpp:186
boost::shared_ptr< GeomFactors > GeomFactorsSharedPtr
Pointer to a GeomFactors object.
Definition: GeomFactors.h:62
boost::shared_ptr< StdExpansion > StdExpansionSharedPtr
boost::shared_ptr< Geometry > GeometrySharedPtr
Definition: Geometry.h:53
void Nektar::Utilities::ProcessQualityMetric::Process ( po::variables_map &  vm)
virtual

Write mesh to output file.

Implements Nektar::Utilities::Module.

Definition at line 71 of file ProcessQualityMetric.cpp.

References ASSERTL0, GetQ(), Nektar::Utilities::Module::m_f, and Vmath::Vcopy().

72 {
73  if (m_f->m_verbose)
74  {
75  cout << "ProcessQualityMetric: Process Jacobian fld" << endl;
76  }
77 
78  Array<OneD, NekDouble> &phys = m_f->m_exp[0]->UpdatePhys();
79  Array<OneD, NekDouble> &coeffs = m_f->m_exp[0]->UpdateCoeffs();
80 
81  for(int i =0; i < m_f->m_exp[0]->GetExpSize(); ++i)
82  {
83  // copy Jacobian into field
84  LocalRegions::ExpansionSharedPtr Elmt = m_f->m_exp[0]->GetExp(i);
85  int offset = m_f->m_exp[0]->GetPhys_Offset(i);
86  Array<OneD, NekDouble> q = GetQ(Elmt);
87  Array<OneD, NekDouble> out = phys + offset;
88 
89  ASSERTL0(q.num_elements() == Elmt->GetTotPoints(), "number of points mismatch");
90  Vmath::Vcopy(q.num_elements(), q, 1, out, 1);
91  }
92 
93  m_f->m_exp[0]->FwdTrans_IterPerExp(phys, coeffs);
94 
95  std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
96  = m_f->m_exp[0]->GetFieldDefinitions();
97  std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
98 
99  for (int i = 0; i < FieldDef.size(); ++i)
100  {
101  FieldDef[i]->m_fields.push_back("QualityMetric");
102  m_f->m_exp[0]->AppendFieldData(FieldDef[i], FieldData[i]);
103  }
104 
105  m_f->m_fielddef = FieldDef;
106  m_f->m_data = FieldData;
107 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
FieldSharedPtr m_f
Field object.
boost::shared_ptr< Expansion > ExpansionSharedPtr
Definition: Expansion.h:68
Array< OneD, NekDouble > GetQ(LocalRegions::ExpansionSharedPtr e)
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1047

Member Data Documentation

ModuleKey Nektar::Utilities::ProcessQualityMetric::className
static
Initial value:
=
ModuleKey(eProcessModule, "qualitymetric"),
"add quality metric to field.")

Definition at line 55 of file ProcessQualityMetric.h.