Nektar++
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
Nektar::FieldUtils::ProcessScalGrad Class Reference

This processing module calculates the scalar gradient field and writes it to a surface output file. More...

#include <ProcessScalGrad.h>

Inheritance diagram for Nektar::FieldUtils::ProcessScalGrad:
[legend]

Public Member Functions

 ProcessScalGrad (FieldSharedPtr f)
 
 ~ProcessScalGrad () 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 scalar gradient field and writes it to a surface output file.

Definition at line 47 of file ProcessScalGrad.h.

Constructor & Destructor Documentation

◆ ProcessScalGrad()

Nektar::FieldUtils::ProcessScalGrad::ProcessScalGrad ( FieldSharedPtr  f)

Definition at line 52 of file ProcessScalGrad.cpp.

◆ ~ProcessScalGrad()

Nektar::FieldUtils::ProcessScalGrad::~ProcessScalGrad ( )
override

Definition at line 56 of file ProcessScalGrad.cpp.

57{
58}

Member Function Documentation

◆ create()

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

Creates an instance of this class.

Definition at line 51 of file ProcessScalGrad.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::ProcessScalGrad::v_GetModuleDescription ( )
inlineoverrideprotectedvirtual

Reimplemented from Nektar::FieldUtils::ProcessBoundaryExtract.

Definition at line 69 of file ProcessScalGrad.h.

70 {
71 return "Calculating scalar gradient";
72 }

◆ v_GetModuleName()

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

Reimplemented from Nektar::FieldUtils::ProcessBoundaryExtract.

Definition at line 64 of file ProcessScalGrad.h.

65 {
66 return "ProcessScalGrad";
67 }

◆ v_Process()

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

Write mesh to output file.

Reimplemented from Nektar::FieldUtils::ProcessBoundaryExtract.

Definition at line 60 of file ProcessScalGrad.cpp.

61{
63
64 int i, j, k;
65
66 int spacedim = m_f->m_graph->GetSpaceDimension();
67 if ((m_f->m_numHomogeneousDir) == 1 || (m_f->m_numHomogeneousDir) == 2)
68 {
69 spacedim = 3;
70 }
71
72 int nfields = m_f->m_variables.size();
73
74 string var;
75 for (i = 0; i < nfields; i++)
76 {
77 var = m_f->m_variables[i];
78 stringstream filename;
79 filename << var << "_scalar_gradient";
80 filename >> var;
81 m_f->m_variables[i] = var;
82 }
83 if (m_f->m_exp[0]->GetNumElmts() == 0)
84 {
85 return;
86 }
87
88 if (spacedim == 1)
89 {
90 ASSERTL0(false, "Error: scalar gradient for a 1D problem cannot "
91 "be computed");
92 }
93
94 int ngrad = spacedim;
95 int n, cnt, elmtid, nq, offset, boundary, nfq;
96 int npoints = m_f->m_exp[0]->GetNpoints();
97 Array<OneD, NekDouble> scalar;
98 Array<OneD, Array<OneD, NekDouble>> grad(ngrad), fgrad(ngrad),
99 outfield(nfields);
100
103 Array<OneD, int> BoundarytoElmtID, BoundarytoTraceID;
104 Array<OneD, Array<OneD, MultiRegions::ExpListSharedPtr>> BndExp(nfields);
105
106 m_f->m_exp[0]->GetBoundaryToElmtMap(BoundarytoElmtID, BoundarytoTraceID);
107
108 for (i = 0; i < nfields; i++)
109 {
110 BndExp[i] = m_f->m_exp[i]->GetBndCondExpansions();
111 outfield[i] = Array<OneD, NekDouble>(npoints);
112 }
113
114 // loop over the types of boundary conditions
115 for (cnt = n = 0; n < BndExp[0].size(); ++n)
116 {
117 bool doneBnd = false;
118 // identify if boundary has been defined
119 for (int b = 0; b < m_f->m_bndRegionsToWrite.size(); ++b)
120 {
121 if (n == m_f->m_bndRegionsToWrite[b])
122 {
123 doneBnd = true;
124 for (i = 0; i < BndExp[0][n]->GetExpSize(); ++i, cnt++)
125 {
126 // find element and face of this expansion.
127 elmtid = BoundarytoElmtID[cnt];
128 elmt = m_f->m_exp[0]->GetExp(elmtid);
129 nq = elmt->GetTotPoints();
130 offset = m_f->m_exp[0]->GetPhys_Offset(elmtid);
131
132 // Initialise local arrays for the velocity
133 // gradients, and stress components size of total
134 // number of quadrature points for each element
135 // (hence local).
136 for (j = 0; j < ngrad; ++j)
137 {
138 grad[j] = Array<OneD, NekDouble>(nq);
139 }
140
141 if (spacedim == 2)
142 {
143 // Not implemented in 2D.
144 }
145 else
146 {
147 for (j = 0; j < nfields; j++)
148 {
149 outfield[j] = BndExp[j][n]->UpdateCoeffs() +
150 BndExp[j][n]->GetCoeff_Offset(i);
151 }
152
153 // Get face 2D expansion from element expansion
154 bc = std::dynamic_pointer_cast<
155 StdRegions::StdExpansion2D>(
156 BndExp[0][n]->GetExp(i));
157 nfq = bc->GetTotPoints();
158
159 // identify boundary of element looking at.
160 boundary = BoundarytoTraceID[cnt];
161
162 const LocalRegions::Expansion *lep =
163 dynamic_cast<const LocalRegions::Expansion *>(
164 &(*bc));
165
166 // Get face normals
168 m_metricinfo = lep->GetMetricInfo();
169
170 const Array<OneD, const Array<OneD, NekDouble>>
171 normals = elmt->GetTraceNormal(boundary);
172
173 // initialise arrays
174 for (j = 0; j < ngrad; ++j)
175 {
176 fgrad[j] = Array<OneD, NekDouble>(nfq);
177 }
178 Array<OneD, NekDouble> gradnorm(nfq);
179
180 for (k = 0; k < nfields; k++)
181 {
182 Vmath::Zero(nfq, gradnorm, 1);
183
184 scalar = m_f->m_exp[k]->GetPhys() + offset;
185 elmt->PhysDeriv(scalar, grad[0], grad[1], grad[2]);
186
187 for (j = 0; j < ngrad; ++j)
188 {
189 elmt->GetTracePhysVals(boundary, bc, grad[j],
190 fgrad[j]);
191 }
192
193 // surface curved
194 if (m_metricinfo->GetGtype() ==
196 {
197 for (j = 0; j < ngrad; j++)
198 {
199 Vmath::Vvtvp(nfq, normals[j], 1, fgrad[j],
200 1, gradnorm, 1, gradnorm, 1);
201 }
202 }
203 else
204 {
205 for (j = 0; j < ngrad; j++)
206 {
207 Vmath::Svtvp(nfq, normals[j][0], fgrad[j],
208 1, gradnorm, 1, gradnorm, 1);
209 }
210 }
211 bc->FwdTrans(gradnorm, outfield[k]);
212 }
213 }
214 }
215 }
216 }
217 if (doneBnd == false)
218 {
219 cnt += BndExp[0][n]->GetExpSize();
220 }
221 }
222
223 for (j = 0; j < nfields; ++j)
224 {
225 for (int b = 0; b < m_f->m_bndRegionsToWrite.size(); ++b)
226 {
227 m_f->m_exp[j]->UpdateBndCondExpansion(m_f->m_bndRegionsToWrite[b]) =
228 BndExp[j][m_f->m_bndRegionsToWrite[b]];
229 }
230 }
231}
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208
FieldSharedPtr m_f
Field object.
Definition: Module.h:239
void v_Process(po::variables_map &vm) override
std::shared_ptr< Expansion > ExpansionSharedPtr
Definition: Expansion.h:66
std::shared_ptr< GeomFactors > GeomFactorsSharedPtr
Pointer to a GeomFactors object.
Definition: GeomFactors.h:60
@ eDeformed
Geometry is curved or has non-constant factors.
std::shared_ptr< StdExpansion2D > StdExpansion2DSharedPtr
void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Svtvp (scalar times vector plus vector): z = alpha*x + y.
Definition: Vmath.hpp:396
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

References ASSERTL0, Nektar::SpatialDomains::eDeformed, Nektar::LocalRegions::Expansion::GetMetricInfo(), Nektar::StdRegions::StdExpansion::GetTotPoints(), Nektar::FieldUtils::Module::m_f, Vmath::Svtvp(), Nektar::FieldUtils::ProcessBoundaryExtract::v_Process(), Vmath::Vvtvp(), and Vmath::Zero().

Member Data Documentation

◆ className

ModuleKey Nektar::FieldUtils::ProcessScalGrad::className
static
Initial value:
=
"Computes scalar gradient field.")
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 ProcessScalGrad.h.