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...
 
virtual std::string GetModuleName ()
 
- 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.
virtual std::string Nektar::Utilities::ProcessSurfDistance::GetModuleName ( )
inlinevirtual

Implements Nektar::Utilities::Module.

Definition at line 65 of file ProcessSurfDistance.h.

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