Nektar++
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | 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 ()
 
- Public Member Functions inherited from Nektar::FieldUtils::ProcessBoundaryExtract
 ProcessBoundaryExtract (FieldSharedPtr f)
 
virtual ~ProcessBoundaryExtract ()
 
- 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)
 
virtual ~Module ()=default
 
void Process (po::variables_map &vm)
 
std::string GetModuleName ()
 
std::string GetModuleDescription ()
 
const ConfigOptionGetConfigOption (const std::string &key) const
 
ModulePriority GetModulePriority ()
 
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 AddFile (std::string fileType, std::string fileName)
 
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
 

Protected Member Functions

virtual void v_Process (po::variables_map &vm) override
 Write mesh to output file. More...
 
virtual std::string v_GetModuleName () override
 
virtual std::string v_GetModuleDescription () override
 
- Protected Member Functions inherited from Nektar::FieldUtils::ProcessBoundaryExtract
virtual ModulePriority v_GetModulePriority () override
 
- Protected Member Functions inherited from Nektar::FieldUtils::Module
 Module ()
 

Additional Inherited Members

- Public Attributes inherited from Nektar::FieldUtils::Module
FieldSharedPtr m_f
 Field object. More...
 
- Protected Attributes inherited from Nektar::FieldUtils::Module
std::map< std::string, ConfigOptionm_config
 List of configuration values. More...
 
std::set< std::string > m_allowedFiles
 List of allowed file formats. 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 51 of file ProcessSurfDistance.cpp.

◆ ~ProcessSurfDistance()

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

Definition at line 56 of file ProcessSurfDistance.cpp.

57 {
58 }

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.

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

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

◆ v_GetModuleDescription()

virtual std::string Nektar::FieldUtils::ProcessSurfDistance::v_GetModuleDescription ( )
inlineoverrideprotectedvirtual

Reimplemented from Nektar::FieldUtils::ProcessBoundaryExtract.

Definition at line 71 of file ProcessSurfDistance.h.

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

◆ v_GetModuleName()

virtual std::string Nektar::FieldUtils::ProcessSurfDistance::v_GetModuleName ( )
inlineoverrideprotectedvirtual

Reimplemented from Nektar::FieldUtils::ProcessBoundaryExtract.

Definition at line 66 of file ProcessSurfDistance.h.

67  {
68  return "ProcessSurfDistance";
69  }

◆ v_Process()

void Nektar::FieldUtils::ProcessSurfDistance::v_Process ( po::variables_map &  vm)
overrideprotectedvirtual

Write mesh to output file.

Reimplemented from Nektar::FieldUtils::ProcessBoundaryExtract.

Definition at line 60 of file ProcessSurfDistance.cpp.

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

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

Member Data Documentation

◆ className

ModuleKey Nektar::FieldUtils::ProcessSurfDistance::className
static
Initial value:
=
"Computes height of element connected to a surface.")
static std::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:198
std::pair< ModuleType, std::string > ModuleKey
Definition: Module.h:317
ModuleFactory & GetModuleFactory()
Definition: Module.cpp:49

Definition at line 57 of file ProcessSurfDistance.h.