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)
 
 ~ProcessSurfDistance () override
 
- Public Member Functions inherited from Nektar::FieldUtils::ProcessBoundaryExtract
 ProcessBoundaryExtract (FieldSharedPtr f)
 
 ~ProcessBoundaryExtract () override
 
- 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 ()
 
std::vector< ModuleKeyGetModulePrerequisites ()
 
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

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

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 47 of file ProcessSurfDistance.h.

Constructor & Destructor Documentation

◆ ProcessSurfDistance()

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

Definition at line 49 of file ProcessSurfDistance.cpp.

◆ ~ProcessSurfDistance()

Nektar::FieldUtils::ProcessSurfDistance::~ProcessSurfDistance ( )
override

Definition at line 54 of file ProcessSurfDistance.cpp.

55{
56}

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 51 of file ProcessSurfDistance.h.

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

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

◆ v_GetModuleDescription()

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

Reimplemented from Nektar::FieldUtils::ProcessBoundaryExtract.

Definition at line 69 of file ProcessSurfDistance.h.

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

◆ v_GetModuleName()

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

Reimplemented from Nektar::FieldUtils::ProcessBoundaryExtract.

Definition at line 64 of file ProcessSurfDistance.h.

65 {
66 return "ProcessSurfDistance";
67 }

◆ 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 58 of file ProcessSurfDistance.cpp.

59{
61 ASSERTL0(!boost::iequals(m_config["bnd"].as<string>(), "All"),
62 "ProcessSurfDistance needs bnd parameter with a single id.");
63
64 int i, j, k, cnt;
65 int surf = m_config["bnd"].as<int>();
66 int expdim = m_f->m_graph->GetMeshDimension();
67
68 ASSERTL0(surf >= 0, "Invalid surface " + boost::lexical_cast<string>(surf));
69
70 int nfields = m_f->m_variables.size();
71 m_f->m_variables.push_back("dist");
72
73 if (m_f->m_exp[0]->GetNumElmts() == 0)
74 {
75 return;
76 }
77
78 int NumHomogeneousDir = m_f->m_numHomogeneousDir;
80 if (nfields)
81 {
82 m_f->m_exp.resize(nfields + 1);
83 exp = m_f->AppendExpList(NumHomogeneousDir);
84
85 m_f->m_exp[nfields] = exp;
86 }
87 else
88 {
89 exp = m_f->m_exp[0];
90 }
91
92 // Grab boundary expansions.
93 Array<OneD, MultiRegions::ExpListSharedPtr> BndExp =
94 exp->GetBndCondExpansions();
95
96 // Get map that takes us from boundary element to element.
97 Array<OneD, int> BoundarytoElmtID, BoundarytoTraceID;
98 exp->GetBoundaryToElmtMap(BoundarytoElmtID, BoundarytoTraceID);
99
100 ASSERTL0(!(m_f->m_numHomogeneousDir),
101 "Homogeneous expansions not supported");
102
103 for (i = cnt = 0; i < BndExp.size(); ++i)
104 {
105 if (i != surf)
106 {
107 cnt += BndExp[i]->GetExpSize();
108 continue;
109 }
110
111 for (j = 0; j < BndExp[i]->GetExpSize(); ++j, ++cnt)
112 {
113 int elmtNum = BoundarytoElmtID[cnt];
114 int facetNum = BoundarytoTraceID[cnt];
115 int oppositeNum = 0;
116
117 // Get boundary and element expansions.
118 LocalRegions::ExpansionSharedPtr bndElmt = BndExp[i]->GetExp(j);
119 LocalRegions::ExpansionSharedPtr elmt = exp->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, "Surface must be on a triangular "
142 "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->GetTracePhysVals(facetNum, bndElmt, x[k], face1);
203 elmt->GetTracePhysVals(oppositeNum, bndElmt, x[k],
204 face2);
205 // Consider edge orientation
206 if (elmt->GetTraceOrient(facetNum) !=
207 elmt->GetTraceOrient(oppositeNum))
208 {
209 Vmath::Reverse(nqBnd, face2, 1, face2, 1);
210 }
211 }
212 break;
213 case 3:
214 {
215 // Use orientation from the surface for both faces
216 StdRegions::Orientation orientation =
217 elmt->GetTraceOrient(facetNum);
218 elmt->GetTracePhysVals(facetNum, bndElmt, x[k], face1,
219 orientation);
220 elmt->GetTracePhysVals(oppositeNum, bndElmt, x[k],
221 face2, orientation);
222 }
223 break;
224 default:
225 ASSERTL0(false, "Expansion not supported");
226 }
227 Vmath::Vsub(nqBnd, face1, 1, face2, 1, face1, 1);
228 Vmath::Vvtvp(nqBnd, face1, 1, face1, 1, dist, 1, dist, 1);
229 }
230 Vmath::Vsqrt(nqBnd, dist, 1, dist, 1);
231 }
232
233 BndExp[i]->FwdTransLocalElmt(BndExp[i]->GetPhys(),
234 BndExp[i]->UpdateCoeffs());
235 }
236}
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208
FieldSharedPtr m_f
Field object.
Definition: Module.h:239
std::map< std::string, ConfigOption > m_config
List of configuration values.
Definition: Module.h:272
void v_Process(po::variables_map &vm) override
std::shared_ptr< Expansion > ExpansionSharedPtr
Definition: Expansion.h:66
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.hpp:340
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.hpp:366
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.hpp:273
void Reverse(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.hpp:844
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.hpp:220

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:197
std::pair< ModuleType, std::string > ModuleKey
Definition: Module.h:180
ModuleFactory & GetModuleFactory()
Definition: Module.cpp:47

Definition at line 55 of file ProcessSurfDistance.h.