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

Definition at line 49 of file ProcessScalGrad.h.

Constructor & Destructor Documentation

◆ ProcessScalGrad()

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

Definition at line 54 of file ProcessScalGrad.cpp.

◆ ~ProcessScalGrad()

Nektar::FieldUtils::ProcessScalGrad::~ProcessScalGrad ( )
virtual

Definition at line 58 of file ProcessScalGrad.cpp.

59 {
60 }

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 53 of file ProcessScalGrad.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::ProcessScalGrad::v_GetModuleDescription ( )
inlineoverrideprotectedvirtual

Reimplemented from Nektar::FieldUtils::ProcessBoundaryExtract.

Definition at line 71 of file ProcessScalGrad.h.

72  {
73  return "Calculating scalar gradient";
74  }

◆ v_GetModuleName()

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

Reimplemented from Nektar::FieldUtils::ProcessBoundaryExtract.

Definition at line 66 of file ProcessScalGrad.h.

67  {
68  return "ProcessScalGrad";
69  }

◆ 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 62 of file ProcessScalGrad.cpp.

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

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

Definition at line 57 of file ProcessScalGrad.h.