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

This processing module calculates the Jacobian of elements using SpatialDomains::GeomFactors and the Element::GetGeom method. For now it simply prints a list of elements which have negative Jacobian. More...

#include <ProcessJac.h>

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

Public Member Functions

 ProcessJac (NekMeshUtils::MeshSharedPtr m)
 
virtual ~ProcessJac ()
 
virtual void Process ()
 Write mesh to output file. More...
 
- Public Member Functions inherited from Nektar::NekMeshUtils::ProcessModule
NEKMESHUTILS_EXPORT ProcessModule (MeshSharedPtr p_m)
 
- Public Member Functions inherited from Nektar::NekMeshUtils::Module
NEKMESHUTILS_EXPORT Module (MeshSharedPtr p_m)
 
NEKMESHUTILS_EXPORT void RegisterConfig (std::string key, std::string value)
 Register a configuration option with a module. More...
 
NEKMESHUTILS_EXPORT void PrintConfig ()
 Print out all configuration options for a module. More...
 
NEKMESHUTILS_EXPORT void SetDefaults ()
 Sets default configuration options for those which have not been set. More...
 
NEKMESHUTILS_EXPORT MeshSharedPtr GetMesh ()
 
virtual NEKMESHUTILS_EXPORT void ProcessVertices ()
 Extract element vertices. More...
 
virtual NEKMESHUTILS_EXPORT void ProcessEdges (bool ReprocessEdges=true)
 Extract element edges. More...
 
virtual NEKMESHUTILS_EXPORT void ProcessFaces (bool ReprocessFaces=true)
 Extract element faces. More...
 
virtual NEKMESHUTILS_EXPORT void ProcessElements ()
 Generate element IDs. More...
 
virtual NEKMESHUTILS_EXPORT void ProcessComposites ()
 Generate composites. More...
 
virtual NEKMESHUTILS_EXPORT void ClearElementLinks ()
 

Static Public Member Functions

static boost::shared_ptr< Modulecreate (NekMeshUtils::MeshSharedPtr m)
 Creates an instance of this class. More...
 

Static Public Attributes

static NekMeshUtils::ModuleKey className
 

Additional Inherited Members

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

Detailed Description

This processing module calculates the Jacobian of elements using SpatialDomains::GeomFactors and the Element::GetGeom method. For now it simply prints a list of elements which have negative Jacobian.

Definition at line 52 of file ProcessJac.h.

Constructor & Destructor Documentation

Nektar::Utilities::ProcessJac::ProcessJac ( NekMeshUtils::MeshSharedPtr  m)

Definition at line 52 of file ProcessJac.cpp.

References Nektar::NekMeshUtils::Module::m_config.

52  : ProcessModule(m)
53 {
54  m_config["extract"] =
55  ConfigOption(false, "0.0", "Extract non-valid elements from mesh.");
56  m_config["list"] = ConfigOption(
57  false, "0", "Print list of elements having negative Jacobian.");
58 }
Represents a command-line configuration option.
NEKMESHUTILS_EXPORT ProcessModule(MeshSharedPtr p_m)
std::map< std::string, ConfigOption > m_config
List of configuration values.
Nektar::Utilities::ProcessJac::~ProcessJac ( )
virtual

Definition at line 60 of file ProcessJac.cpp.

61 {
62 }

Member Function Documentation

static boost::shared_ptr<Module> Nektar::Utilities::ProcessJac::create ( NekMeshUtils::MeshSharedPtr  m)
inlinestatic

Creates an instance of this class.

Definition at line 56 of file ProcessJac.h.

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

57  {
59  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
void Nektar::Utilities::ProcessJac::Process ( )
virtual

Write mesh to output file.

Implements Nektar::NekMeshUtils::Module.

Definition at line 64 of file ProcessJac.cpp.

References Nektar::eFULL, CellMLToNektar.pycml::extract(), Nektar::NekMeshUtils::Module::m_config, Nektar::NekMeshUtils::Module::m_mesh, CellMLToNektar.cellml_metadata::p, Nektar::NekMeshUtils::Module::ProcessComposites(), Nektar::NekMeshUtils::Module::ProcessEdges(), Nektar::NekMeshUtils::Module::ProcessElements(), Nektar::NekMeshUtils::Module::ProcessFaces(), Nektar::NekMeshUtils::Module::ProcessVertices(), Nektar::LibUtilities::ShapeTypeMap, Vmath::Vmax(), and Vmath::Vmin().

65 {
66  if (m_mesh->m_verbose)
67  {
68  cout << "ProcessJac: Calculating Jacobians... " << endl;
69  }
70 
71  bool extract = m_config["extract"].beenSet;
72  bool printList = m_config["list"].as<bool>();
73  NekDouble thres = m_config["extract"].as<NekDouble>();
74 
75  vector<ElementSharedPtr> el = m_mesh->m_element[m_mesh->m_expDim];
76 
77  if (extract)
78  {
79  m_mesh->m_element[m_mesh->m_expDim].clear();
80  }
81 
82  if (printList)
83  {
84  cout << "Elements with negative Jacobian:" << endl;
85  }
86 
87  int nNeg = 0;
88 
89  Array<OneD, int> bin(20, 0);
90 
91  // Iterate over list of elements of expansion dimension.
92  for (int i = 0; i < el.size(); ++i)
93  {
94  // Create elemental geometry.
96  el[i]->GetGeom(m_mesh->m_spaceDim);
97 
98  // Generate geometric factors.
99  SpatialDomains::GeomFactorsSharedPtr gfac = geom->GetGeomFactors();
100 
101  LibUtilities::PointsKeyVector p = geom->GetPointsKeys();
102  SpatialDomains::DerivStorage deriv = gfac->GetDeriv(p);
103  const int pts = deriv[0][0].num_elements();
104  Array<OneD,NekDouble> jc(pts);
105  for (int k = 0; k < pts; ++k)
106  {
107  DNekMat jac(m_mesh->m_expDim, m_mesh->m_expDim, 0.0, eFULL);
108 
109  for (int l = 0; l < m_mesh->m_expDim; ++l)
110  {
111  for (int j = 0; j < m_mesh->m_expDim; ++j)
112  {
113  jac(j,l) = deriv[l][j][k];
114  }
115  }
116 
117  if(m_mesh->m_expDim == 2)
118  {
119  jc[k] = jac(0,0) * jac(1,1) - jac(0,1)*jac(1,0);
120  }
121  else if(m_mesh->m_expDim == 3)
122  {
123  jc[k] = jac(0,0) * (jac(1,1)*jac(2,2) - jac(2,1)*jac(1,2)) -
124  jac(0,1) * (jac(1,0)*jac(2,2) - jac(2,0)*jac(1,2)) +
125  jac(0,2) * (jac(1,0)*jac(2,1) - jac(2,0)*jac(1,1));
126  }
127  }
128 
129  NekDouble scaledJac = Vmath::Vmin(jc.num_elements(),jc,1) /
130  Vmath::Vmax(jc.num_elements(),jc,1);
131 
132  bool valid = gfac->IsValid();
133 
134  if (extract && (scaledJac < thres || !valid))
135  {
136  m_mesh->m_element[m_mesh->m_expDim].push_back(el[i]);
137  }
138 
139  // Get the Jacobian and, if it is negative, print a warning
140  // message.
141  if (!valid)
142  {
143  nNeg++;
144 
145  if (printList)
146  {
147  cout << " - " << el[i]->GetId() << " ("
148  << LibUtilities::ShapeTypeMap[el[i]->GetConf().m_e] << ")"
149  << " " << scaledJac
150  << endl;
151  }
152  }
153  }
154 
155  if (extract)
156  {
157  m_mesh->m_element[m_mesh->m_expDim - 1].clear();
158  ProcessVertices();
159  ProcessEdges();
160  ProcessFaces();
161  ProcessElements();
163  }
164 
165  if (printList || m_mesh->m_verbose)
166  {
167  cout << "Total negative Jacobians: " << nNeg << endl;
168  }
169  else if (nNeg > 0)
170  {
171  cout << "WARNING: Detected " << nNeg << " element"
172  << (nNeg == 1 ? "" : "s") << " with negative Jacobian." << endl;
173  }
174 }
std::vector< PointsKey > PointsKeyVector
Definition: Points.h:242
T Vmax(int n, const T *x, const int incx)
Return the maximum element in x – called vmax to avoid conflict with max.
Definition: Vmath.cpp:779
T Vmin(int n, const T *x, const int incx)
Return the minimum element in x - called vmin to avoid conflict with min.
Definition: Vmath.cpp:871
const char *const ShapeTypeMap[]
Definition: ShapeType.hpp:66
virtual NEKMESHUTILS_EXPORT void ProcessFaces(bool ReprocessFaces=true)
Extract element faces.
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > DerivStorage
Storage type for derivative of mapping.
Definition: GeomFactors.h:75
virtual NEKMESHUTILS_EXPORT void ProcessElements()
Generate element IDs.
NekMatrix< NekDouble, StandardMatrixTag > DNekMat
Definition: NekTypeDefs.hpp:52
double NekDouble
std::map< std::string, ConfigOption > m_config
List of configuration values.
boost::shared_ptr< GeomFactors > GeomFactorsSharedPtr
Pointer to a GeomFactors object.
Definition: GeomFactors.h:62
virtual NEKMESHUTILS_EXPORT void ProcessVertices()
Extract element vertices.
virtual NEKMESHUTILS_EXPORT void ProcessEdges(bool ReprocessEdges=true)
Extract element edges.
boost::shared_ptr< Geometry > GeometrySharedPtr
Definition: Geometry.h:53
virtual NEKMESHUTILS_EXPORT void ProcessComposites()
Generate composites.

Member Data Documentation

ModuleKey Nektar::Utilities::ProcessJac::className
static
Initial value:
"Process elements based on values of Jacobian.")

Definition at line 60 of file ProcessJac.h.