Nektar++
Loading...
Searching...
No Matches
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.
 
FIELD_UTILS_EXPORT void PrintConfig ()
 Print out all configuration options for a module.
 
FIELD_UTILS_EXPORT void SetDefaults ()
 Sets default configuration options for those which have not been set.
 
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.
 
- Static Public Member Functions inherited from Nektar::FieldUtils::ProcessBoundaryExtract
static std::shared_ptr< Modulecreate (FieldSharedPtr f)
 Creates an instance of this class.
 

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.
 
std::string v_GetModuleName () override
 
std::string v_GetModuleDescription () override
 
- Protected Member Functions inherited from Nektar::FieldUtils::ProcessBoundaryExtract
ModulePriority v_GetModulePriority () override
 
- Protected Member Functions inherited from Nektar::FieldUtils::Module
 Module ()
 
virtual std::vector< ModuleKeyv_GetModulePrerequisites ()
 

Additional Inherited Members

- Public Attributes inherited from Nektar::FieldUtils::Module
FieldSharedPtr m_f
 Field object.
 
- Protected Attributes inherited from Nektar::FieldUtils::Module
std::map< std::string, ConfigOptionm_config
 List of configuration values.
 
std::set< std::string > m_allowedFiles
 List of allowed file formats.
 

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 " + std::to_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 for (j = 0; j < BndExp[i]->GetExpSize(); ++j, ++cnt)
106 {
107 int elmtNum = BoundarytoElmtID[cnt];
108 int facetNum = BoundarytoTraceID[cnt];
109 int oppositeNum = 0;
110
111 // Get boundary and element expansions.
112 LocalRegions::ExpansionSharedPtr bndElmt = BndExp[i]->GetExp(j);
113 LocalRegions::ExpansionSharedPtr elmt = exp->GetExp(elmtNum);
114
115 // Determine which face is opposite to the surface
116 switch (elmt->DetShapeType())
117 {
119 {
120 oppositeNum = (facetNum + 2) % 4;
121 }
122 break;
123
125 {
126 switch (facetNum)
127 {
128 case 1:
129 oppositeNum = 3;
130 break;
131 case 3:
132 oppositeNum = 1;
133 break;
134 default:
135 ASSERTL0(false, "Surface must be on a triangular "
136 "face of the prism.");
137 }
138 }
139 break;
140
142 {
143 switch (facetNum)
144 {
145 case 0:
146 oppositeNum = 5;
147 break;
148 case 1:
149 oppositeNum = 3;
150 break;
151 case 2:
152 oppositeNum = 4;
153 break;
154 case 3:
155 oppositeNum = 1;
156 break;
157 case 4:
158 oppositeNum = 2;
159 break;
160 case 5:
161 oppositeNum = 0;
162 break;
163 default:
164 ASSERTL0(false, "Face out of bound.");
165 }
166 }
167 break;
168
169 default:
170 ASSERTL0(false, "Element not supported");
171 }
172
173 int nq = elmt->GetTotPoints();
174 int nqBnd = bndElmt->GetTotPoints();
175
176 Array<OneD, Array<OneD, NekDouble>> x(3);
177 x[0] = Array<OneD, NekDouble>(nq);
178 x[1] = Array<OneD, NekDouble>(nq);
179 x[2] = Array<OneD, NekDouble>(nq);
180 elmt->GetCoords(x[0], x[1], x[2]);
181
182 Array<OneD, NekDouble> face1(nqBnd), face2(nqBnd);
183 Array<OneD, NekDouble> dist =
184 BndExp[i]->UpdatePhys() + BndExp[i]->GetPhys_Offset(j);
185
186 // Zero existing value.
187 Vmath::Zero(nqBnd, dist, 1);
188
189 // Calculate distance between two faces of the element
190 for (k = 0; k < expdim; ++k)
191 {
192 switch (expdim)
193 {
194 case 2:
195 {
196 elmt->GetTracePhysVals(facetNum, bndElmt, x[k], face1);
197 elmt->GetTracePhysVals(oppositeNum, bndElmt, x[k],
198 face2);
199 // Consider edge orientation
200 if (elmt->GetTraceOrient(facetNum) !=
201 elmt->GetTraceOrient(oppositeNum))
202 {
203 Vmath::Reverse(nqBnd, face2, 1, face2, 1);
204 }
205 }
206 break;
207 case 3:
208 {
209 // Use orientation from the surface for both faces
210 StdRegions::Orientation orientation =
211 elmt->GetTraceOrient(facetNum);
212 elmt->GetTracePhysVals(facetNum, bndElmt, x[k], face1,
213 orientation);
214 elmt->GetTracePhysVals(oppositeNum, bndElmt, x[k],
215 face2, orientation);
216 }
217 break;
218 default:
219 ASSERTL0(false, "Expansion not supported");
220 }
221 Vmath::Vsub(nqBnd, face1, 1, face2, 1, face1, 1);
222 Vmath::Vvtvp(nqBnd, face1, 1, face1, 1, dist, 1, dist, 1);
223 }
224 Vmath::Vsqrt(nqBnd, dist, 1, dist, 1);
225 }
226
227 BndExp[i]->FwdTransLocalElmt(BndExp[i]->GetPhys(),
228 BndExp[i]->UpdateCoeffs());
229 }
230}
#define ASSERTL0(condition, msg)
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.
std::pair< ModuleType, std::string > ModuleKey
Definition Module.h:180
ModuleFactory & GetModuleFactory()
Definition Module.cpp:47

Definition at line 55 of file ProcessSurfDistance.h.