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

This processing module calculates the height of an element connected to a surface and adds it as an extra-field to the output file. More...

#include <ProcessSurfDistance.h>

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

Public Member Functions

 ProcessSurfDistance (FieldSharedPtr f)
 
virtual ~ProcessSurfDistance ()
 
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
 

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 calculates the height of an element connected to a surface and adds it as an extra-field to the output file.

Definition at line 50 of file ProcessSurfDistance.h.

Constructor & Destructor Documentation

Nektar::Utilities::ProcessSurfDistance::ProcessSurfDistance ( FieldSharedPtr  f)

Definition at line 53 of file ProcessSurfDistance.cpp.

References Nektar::Utilities::Module::m_config, and Nektar::Utilities::Module::m_f.

54  : ProcessModule(f)
55 {
56  m_config["bnd"] = ConfigOption(false,"-1","Boundary region to calculate height");
57  f->m_writeBndFld = true;
58  f->m_declareExpansionAsContField = true;
59  m_f->m_fldToBnd = false;
60 }
map< string, ConfigOption > m_config
List of configuration values.
FieldSharedPtr m_f
Field object.
Nektar::Utilities::ProcessSurfDistance::~ProcessSurfDistance ( )
virtual

Definition at line 62 of file ProcessSurfDistance.cpp.

63 {
64 }

Member Function Documentation

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

Creates an instance of this class.

Definition at line 54 of file ProcessSurfDistance.h.

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

54  {
56  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
void Nektar::Utilities::ProcessSurfDistance::Process ( po::variables_map &  vm)
virtual

Write mesh to output file.

Implements Nektar::Utilities::Module.

Definition at line 66 of file ProcessSurfDistance.cpp.

References ASSERTL0, Nektar::LibUtilities::eHexahedron, Nektar::LibUtilities::ePrism, Nektar::LibUtilities::eQuadrilateral, Nektar::Utilities::Module::m_config, Nektar::Utilities::Module::m_f, Vmath::Reverse(), Nektar::NekMeshUtils::surf, Vmath::Vsqrt(), Vmath::Vsub(), Vmath::Vvtvp(), and Vmath::Zero().

67 {
68  int i, j, k, cnt;
69  int surf = m_config["bnd"].as<int>();
70  int expdim = m_f->m_graph->GetMeshDimension();
71 
72  ASSERTL0(surf >= 0, "Invalid surface "+boost::lexical_cast<string>(surf));
73 
74  // Add this boundary region to the list that we will output.
75  m_f->m_bndRegionsToWrite.push_back(surf);
76 
77  // Remove existing fields.
78  m_f->m_exp.resize(1);
79 
80  // Grab boundary expansions.
81  Array<OneD, MultiRegions::ExpListSharedPtr> BndExp =
82  m_f->m_exp[0]->GetBndCondExpansions();
83 
84  // Get map that takes us from boundary element to element.
85  Array<OneD, int> BoundarytoElmtID, BoundarytoTraceID;
86  m_f->m_exp[0]->GetBoundaryToElmtMap(BoundarytoElmtID, BoundarytoTraceID);
87 
88  if (m_f->m_fielddef.size() == 0)
89  {
90  m_f->m_fielddef = m_f->m_exp[0]->GetFieldDefinitions();
91  m_f->m_fielddef[0]->m_fields.push_back("dist");
92  }
93  else
94  {
95  // Override field variable
96  m_f->m_fielddef[0]->m_fields[0] = "dist";
97  }
98 
99  ASSERTL0(!(m_f->m_fielddef[0]->m_numHomogeneousDir),
100  "Homogeneous expansions not supported");
101 
102  for (i = cnt = 0; i < BndExp.num_elements(); ++i)
103  {
104  if (i != surf)
105  {
106  cnt += BndExp[i]->GetExpSize();
107  continue;
108  }
109 
110  for (j = 0; j < BndExp[i]->GetExpSize(); ++j, ++cnt)
111  {
112  int elmtNum = BoundarytoElmtID [cnt];
113  int facetNum = BoundarytoTraceID[cnt];
114  int oppositeNum;
115 
116  // Get boundary and element expansions.
117  LocalRegions::ExpansionSharedPtr bndElmt = BndExp[i]->GetExp(j);
119  m_f->m_exp[0]->GetExp(elmtNum);
120 
121  // Determine which face is opposite to the surface
122  switch(elmt->DetShapeType())
123  {
125  {
126  oppositeNum = (facetNum+2)%4;
127  }
128  break;
129 
131  {
132  switch(facetNum)
133  {
134  case 1:
135  oppositeNum = 3;
136  break;
137  case 3:
138  oppositeNum = 1;
139  break;
140  default:
141  ASSERTL0(false,
142  "Surface must be on a triangular face of the prism.");
143  }
144  }
145  break;
146 
148  {
149  switch(facetNum)
150  {
151  case 0:
152  oppositeNum = 5;
153  break;
154  case 1:
155  oppositeNum = 3;
156  break;
157  case 2:
158  oppositeNum = 4;
159  break;
160  case 3:
161  oppositeNum = 1;
162  break;
163  case 4:
164  oppositeNum = 2;
165  break;
166  case 5:
167  oppositeNum = 0;
168  break;
169  default:
170  ASSERTL0(false, "Face out of bound.");
171  }
172  }
173  break;
174 
175  default:
176  ASSERTL0(false, "Element not supported");
177  }
178 
179  int nq = elmt ->GetTotPoints();
180  int nqBnd = bndElmt->GetTotPoints();
181 
182  Array<OneD, Array<OneD, NekDouble> > x(3);
183  x[0] = Array<OneD, NekDouble>(nq);
184  x[1] = Array<OneD, NekDouble>(nq);
185  x[2] = Array<OneD, NekDouble>(nq);
186  elmt->GetCoords(x[0], x[1], x[2]);
187 
188  Array<OneD, NekDouble> face1(nqBnd), face2(nqBnd);
189  Array<OneD, NekDouble> dist =
190  BndExp[i]->UpdatePhys() + BndExp[i]->GetPhys_Offset(j);
191 
192  // Zero existing value.
193  Vmath::Zero(nqBnd, dist, 1);
194 
195  // Calculate distance between two faces of the element
196  for (k = 0; k < expdim; ++k)
197  {
198  switch(expdim)
199  {
200  case 2:
201  {
202  elmt->GetEdgePhysVals(facetNum, bndElmt, x[k], face1);
203  elmt->GetEdgePhysVals(oppositeNum, bndElmt, x[k], face2);
204  // Consider edge orientation
205  if (elmt->GetEorient(facetNum) ==
206  elmt->GetEorient(oppositeNum))
207  {
208  Vmath::Reverse(nqBnd, face2, 1, face2, 1);
209  }
210  }
211  break;
212  case 3:
213  {
214  // Use orientation from the surface for both faces
215  StdRegions::Orientation orientation =
216  elmt->GetForient(facetNum);
217  elmt->GetFacePhysVals(facetNum, bndElmt,
218  x[k], face1, orientation);
219  elmt->GetFacePhysVals(oppositeNum, bndElmt,
220  x[k], face2, orientation);
221  }
222  break;
223  default:
224  ASSERTL0(false, "Expansion not supported");
225  }
226  Vmath::Vsub (nqBnd, face1, 1, face2, 1, face1, 1);
227  Vmath::Vvtvp(nqBnd, face1, 1, face1, 1, dist, 1, dist, 1);
228  }
229  Vmath::Vsqrt(nqBnd, dist, 1, dist, 1);
230  }
231 
232  BndExp[i]->FwdTrans(BndExp[i]->GetPhys(), BndExp[i]->UpdateCoeffs());
233  }
234 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
void Vsqrt(int n, const T *x, const int incx, T *y, const int incy)
sqrt y = sqrt(x)
Definition: Vmath.cpp:394
map< string, ConfigOption > m_config
List of configuration values.
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Definition: Vmath.cpp:428
FieldSharedPtr m_f
Field object.
void Reverse(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1071
boost::shared_ptr< Expansion > ExpansionSharedPtr
Definition: Expansion.h:68
void Vsub(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Subtract vector z = x-y.
Definition: Vmath.cpp:329
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.cpp:359

Member Data Documentation

ModuleKey Nektar::Utilities::ProcessSurfDistance::className
static
Initial value:
=
ModuleKey(eProcessModule, "surfdistance"),
"Computes height of element connected to a surface.")

Definition at line 57 of file ProcessSurfDistance.h.