Nektar++
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
Nektar::FieldUtils::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::FieldUtils::ProcessSurfDistance:
[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 ()
 
virtual std::string GetModuleDescription ()
 
- Public Member Functions inherited from Nektar::FieldUtils::ProcessBoundaryExtract
 ProcessBoundaryExtract (FieldSharedPtr f)
 
virtual ~ProcessBoundaryExtract ()
 
virtual ModulePriority GetModulePriority ()
 
- Public Member Functions inherited from Nektar::FieldUtils::ProcessModule
 ProcessModule ()
 
 ProcessModule (FieldSharedPtr p_f)
 
- Public Member Functions inherited from Nektar::FieldUtils::Module
FIELD_UTILS_EXPORT Module (FieldSharedPtr p_f)
 
FIELD_UTILS_EXPORT void RegisterConfig (std::string key, std::string value="")
 Register a configuration option with a module. More...
 
FIELD_UTILS_EXPORT void PrintConfig ()
 Print out all configuration options for a module. More...
 
FIELD_UTILS_EXPORT void SetDefaults ()
 Sets default configuration options for those which have not been set. More...
 
FIELD_UTILS_EXPORT void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 

Static Public Member Functions

static std::shared_ptr< Modulecreate (FieldSharedPtr f)
 Creates an instance of this class. More...
 
- Static Public Member Functions inherited from Nektar::FieldUtils::ProcessBoundaryExtract
static std::shared_ptr< Modulecreate (FieldSharedPtr f)
 Creates an instance of this class. More...
 

Static Public Attributes

static ModuleKey className
 
- Static Public Attributes inherited from Nektar::FieldUtils::ProcessBoundaryExtract
static ModuleKey className
 

Additional Inherited Members

- Protected Member Functions inherited from Nektar::FieldUtils::Module
 Module ()
 
- Protected Attributes inherited from Nektar::FieldUtils::Module
FieldSharedPtr m_f
 Field object. More...
 
std::map< std::string, ConfigOptionm_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 49 of file ProcessSurfDistance.h.

Constructor & Destructor Documentation

◆ ProcessSurfDistance()

Nektar::FieldUtils::ProcessSurfDistance::ProcessSurfDistance ( FieldSharedPtr  f)

Definition at line 52 of file ProcessSurfDistance.cpp.

◆ ~ProcessSurfDistance()

Nektar::FieldUtils::ProcessSurfDistance::~ProcessSurfDistance ( )
virtual

Definition at line 57 of file ProcessSurfDistance.cpp.

58 {
59 }

Member Function Documentation

◆ create()

static std::shared_ptr<Module> Nektar::FieldUtils::ProcessSurfDistance::create ( FieldSharedPtr  f)
inlinestatic

Creates an instance of this class.

Definition at line 53 of file ProcessSurfDistance.h.

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

54  {
56  }
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.

◆ GetModuleDescription()

virtual std::string Nektar::FieldUtils::ProcessSurfDistance::GetModuleDescription ( )
inlinevirtual

Reimplemented from Nektar::FieldUtils::ProcessBoundaryExtract.

Definition at line 70 of file ProcessSurfDistance.h.

71  {
72  return "Calculating distance to surface";
73  }

◆ GetModuleName()

virtual std::string Nektar::FieldUtils::ProcessSurfDistance::GetModuleName ( )
inlinevirtual

Reimplemented from Nektar::FieldUtils::ProcessBoundaryExtract.

Definition at line 65 of file ProcessSurfDistance.h.

66  {
67  return "ProcessSurfDistance";
68  }

◆ Process()

void Nektar::FieldUtils::ProcessSurfDistance::Process ( po::variables_map &  vm)
virtual

Write mesh to output file.

Reimplemented from Nektar::FieldUtils::ProcessBoundaryExtract.

Definition at line 61 of file ProcessSurfDistance.cpp.

References ASSERTL0, Nektar::LibUtilities::eHexahedron, Nektar::LibUtilities::ePrism, Nektar::LibUtilities::eQuadrilateral, Nektar::FieldUtils::Module::m_config, Nektar::FieldUtils::Module::m_f, Nektar::FieldUtils::ProcessBoundaryExtract::Process(), Vmath::Reverse(), Vmath::Vsqrt(), Vmath::Vsub(), Vmath::Vvtvp(), and Vmath::Zero().

62 {
64  ASSERTL0( !boost::iequals(m_config["bnd"].as<string>(), "All"),
65  "ProcessSurfDistance needs bnd parameter with a single id.");
66 
67  int i, j, k, cnt;
68  int surf = m_config["bnd"].as<int>();
69  int expdim = m_f->m_graph->GetMeshDimension();
70 
71  ASSERTL0(surf >= 0, "Invalid surface " + boost::lexical_cast<string>(surf));
72 
73  int nfields = m_f->m_variables.size();
74  m_f->m_variables.push_back("dist");
75 
76  if (m_f->m_exp[0]->GetNumElmts() == 0)
77  {
78  return;
79  }
80 
81  int NumHomogeneousDir = m_f->m_numHomogeneousDir;
83  if (nfields)
84  {
85  m_f->m_exp.resize(nfields + 1);
86  exp = m_f->AppendExpList(NumHomogeneousDir);
87 
88  m_f->m_exp[nfields] = exp;
89  }
90  else
91  {
92  exp = m_f->m_exp[0];
93  }
94 
95  // Grab boundary expansions.
96  Array<OneD, MultiRegions::ExpListSharedPtr> BndExp =
97  exp->GetBndCondExpansions();
98 
99  // Get map that takes us from boundary element to element.
100  Array<OneD, int> BoundarytoElmtID, BoundarytoTraceID;
101  exp->GetBoundaryToElmtMap(BoundarytoElmtID, BoundarytoTraceID);
102 
103  ASSERTL0(!(m_f->m_numHomogeneousDir),
104  "Homogeneous expansions not supported");
105 
106  for (i = cnt = 0; i < BndExp.num_elements(); ++i)
107  {
108  if (i != surf)
109  {
110  cnt += BndExp[i]->GetExpSize();
111  continue;
112  }
113 
114  for (j = 0; j < BndExp[i]->GetExpSize(); ++j, ++cnt)
115  {
116  int elmtNum = BoundarytoElmtID[cnt];
117  int facetNum = BoundarytoTraceID[cnt];
118  int oppositeNum = 0;
119 
120  // Get boundary and element expansions.
121  LocalRegions::ExpansionSharedPtr bndElmt = BndExp[i]->GetExp(j);
123  exp->GetExp(elmtNum);
124 
125  // Determine which face is opposite to the surface
126  switch (elmt->DetShapeType())
127  {
129  {
130  oppositeNum = (facetNum + 2) % 4;
131  }
132  break;
133 
135  {
136  switch (facetNum)
137  {
138  case 1:
139  oppositeNum = 3;
140  break;
141  case 3:
142  oppositeNum = 1;
143  break;
144  default:
145  ASSERTL0(false, "Surface must be on a triangular "
146  "face of the prism.");
147  }
148  }
149  break;
150 
152  {
153  switch (facetNum)
154  {
155  case 0:
156  oppositeNum = 5;
157  break;
158  case 1:
159  oppositeNum = 3;
160  break;
161  case 2:
162  oppositeNum = 4;
163  break;
164  case 3:
165  oppositeNum = 1;
166  break;
167  case 4:
168  oppositeNum = 2;
169  break;
170  case 5:
171  oppositeNum = 0;
172  break;
173  default:
174  ASSERTL0(false, "Face out of bound.");
175  }
176  }
177  break;
178 
179  default:
180  ASSERTL0(false, "Element not supported");
181  }
182 
183  int nq = elmt->GetTotPoints();
184  int nqBnd = bndElmt->GetTotPoints();
185 
186  Array<OneD, Array<OneD, NekDouble> > x(3);
187  x[0] = Array<OneD, NekDouble>(nq);
188  x[1] = Array<OneD, NekDouble>(nq);
189  x[2] = Array<OneD, NekDouble>(nq);
190  elmt->GetCoords(x[0], x[1], x[2]);
191 
192  Array<OneD, NekDouble> face1(nqBnd), face2(nqBnd);
193  Array<OneD, NekDouble> dist =
194  BndExp[i]->UpdatePhys() + BndExp[i]->GetPhys_Offset(j);
195 
196  // Zero existing value.
197  Vmath::Zero(nqBnd, dist, 1);
198 
199  // Calculate distance between two faces of the element
200  for (k = 0; k < expdim; ++k)
201  {
202  switch (expdim)
203  {
204  case 2:
205  {
206  elmt->GetEdgePhysVals(facetNum, bndElmt, x[k], face1);
207  elmt->GetEdgePhysVals(oppositeNum, bndElmt, x[k],
208  face2);
209  // Consider edge orientation
210  if (elmt->GetEorient(facetNum) ==
211  elmt->GetEorient(oppositeNum))
212  {
213  Vmath::Reverse(nqBnd, face2, 1, face2, 1);
214  }
215  }
216  break;
217  case 3:
218  {
219  // Use orientation from the surface for both faces
220  StdRegions::Orientation orientation =
221  elmt->GetForient(facetNum);
222  elmt->GetFacePhysVals(facetNum, bndElmt, x[k], face1,
223  orientation);
224  elmt->GetFacePhysVals(oppositeNum, bndElmt, x[k], face2,
225  orientation);
226  }
227  break;
228  default:
229  ASSERTL0(false, "Expansion not supported");
230  }
231  Vmath::Vsub(nqBnd, face1, 1, face2, 1, face1, 1);
232  Vmath::Vvtvp(nqBnd, face1, 1, face1, 1, dist, 1, dist, 1);
233  }
234  Vmath::Vsqrt(nqBnd, dist, 1, dist, 1);
235  }
236 
237  BndExp[i]->FwdTrans_IterPerExp(BndExp[i]->GetPhys(),
238  BndExp[i]->UpdateCoeffs());
239  }
240 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
std::map< std::string, ConfigOption > m_config
List of configuration values.
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
void Vsqrt(int n, const T *x, const int incx, T *y, const int incy)
sqrt y = sqrt(x)
Definition: Vmath.cpp:411
virtual void Process(po::variables_map &vm)
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:445
void Reverse(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1088
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:346
std::shared_ptr< Expansion > ExpansionSharedPtr
Definition: Expansion.h:65
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.cpp:376
FieldSharedPtr m_f
Field object.

Member Data Documentation

◆ className

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

Definition at line 57 of file ProcessSurfDistance.h.