Nektar++
Public Member Functions | Static Public Member Functions | Static Public Attributes | 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 ()
 
virtual void Process (po::variables_map &vm)
 Write mesh to output file. More...
 
virtual std::string GetModuleName ()
 
virtual std::string GetModuleDescription ()
 
- Public Member Functions inherited from Nektar::FieldUtils::ProcessBoundaryExtract
 ProcessBoundaryExtract (FieldSharedPtr f)
 
virtual ~ProcessBoundaryExtract ()
 
virtual ModulePriority GetModulePriority ()
 
- 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
 
const ConfigOptionGetConfigOption (const std::string &key) const
 
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
 

Additional Inherited Members

- Public Attributes inherited from Nektar::FieldUtils::Module
FieldSharedPtr m_f
 Field object. More...
 
- Protected Member Functions inherited from Nektar::FieldUtils::Module
 Module ()
 
- 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 55 of file ProcessScalGrad.cpp.

◆ ~ProcessScalGrad()

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

Definition at line 59 of file ProcessScalGrad.cpp.

60 {
61 }

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().

◆ GetModuleDescription()

virtual std::string Nektar::FieldUtils::ProcessScalGrad::GetModuleDescription ( )
inlinevirtual

Reimplemented from Nektar::FieldUtils::ProcessBoundaryExtract.

Definition at line 70 of file ProcessScalGrad.h.

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

◆ GetModuleName()

virtual std::string Nektar::FieldUtils::ProcessScalGrad::GetModuleName ( )
inlinevirtual

Reimplemented from Nektar::FieldUtils::ProcessBoundaryExtract.

Definition at line 65 of file ProcessScalGrad.h.

66  {
67  return "ProcessScalGrad";
68  }

◆ Process()

void Nektar::FieldUtils::ProcessScalGrad::Process ( po::variables_map &  vm)
virtual

Write mesh to output file.

Reimplemented from Nektar::FieldUtils::ProcessBoundaryExtract.

Definition at line 63 of file ProcessScalGrad.cpp.

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

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

Member Data Documentation

◆ className

ModuleKey Nektar::FieldUtils::ProcessScalGrad::className
static
Initial value:
=
ModuleKey(eProcessModule, "scalargrad"),
"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:200
std::pair< ModuleType, std::string > ModuleKey
Definition: Module.h:290
ModuleFactory & GetModuleFactory()
Definition: Module.cpp:49

Definition at line 57 of file ProcessScalGrad.h.