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

This processing module calculates the vorticity and adds it as an extra-field to the output file. More...

#include <ProcessGrad.h>

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

Public Member Functions

 ProcessGrad (FieldSharedPtr f)
 
virtual ~ProcessGrad ()
 
virtual void Process (po::variables_map &vm)
 Write mesh to output file. More...
 
virtual std::string GetModuleName ()
 
virtual std::string GetModuleDescription ()
 
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 Attributes

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 vorticity and adds it as an extra-field to the output file.

Definition at line 49 of file ProcessGrad.h.

Constructor & Destructor Documentation

◆ ProcessGrad()

Nektar::FieldUtils::ProcessGrad::ProcessGrad ( FieldSharedPtr  f)

Definition at line 56 of file ProcessGrad.cpp.

56  : ProcessModule(f)
57 {
58 }

◆ ~ProcessGrad()

Nektar::FieldUtils::ProcessGrad::~ProcessGrad ( )
virtual

Definition at line 60 of file ProcessGrad.cpp.

61 {
62 }

Member Function Documentation

◆ create()

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

Creates an instance of this class.

Definition at line 53 of file ProcessGrad.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::ProcessGrad::GetModuleDescription ( )
inlinevirtual

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 70 of file ProcessGrad.h.

71  {
72  return "Calculating gradients";
73  }

◆ GetModuleName()

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

Implements Nektar::FieldUtils::Module.

Definition at line 65 of file ProcessGrad.h.

66  {
67  return "ProcessGrad";
68  }

◆ GetModulePriority()

virtual ModulePriority Nektar::FieldUtils::ProcessGrad::GetModulePriority ( )
inlinevirtual

Implements Nektar::FieldUtils::Module.

Definition at line 75 of file ProcessGrad.h.

76  {
77  return eModifyExp;
78  }

References Nektar::FieldUtils::eModifyExp.

◆ Process()

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

Write mesh to output file.

Implements Nektar::FieldUtils::Module.

Definition at line 64 of file ProcessGrad.cpp.

65 {
66  m_f->SetUpExp(vm);
67 
68  int i, j;
69  int expdim = m_f->m_graph->GetMeshDimension();
70  int spacedim = m_f->m_numHomogeneousDir + expdim;
71  int nfields = m_f->m_variables.size();
72  int addfields = nfields * spacedim;
73 
74  for (i = 0; i < nfields; ++i)
75  {
76  if (spacedim == 1)
77  {
78  m_f->m_variables.push_back(m_f->m_variables[i] + "_x");
79  }
80  else if (spacedim == 2)
81  {
82  m_f->m_variables.push_back(m_f->m_variables[i] + "_x");
83  m_f->m_variables.push_back(m_f->m_variables[i] + "_y");
84  }
85  else if (spacedim == 3)
86  {
87  m_f->m_variables.push_back(m_f->m_variables[i] + "_x");
88  m_f->m_variables.push_back(m_f->m_variables[i] + "_y");
89  m_f->m_variables.push_back(m_f->m_variables[i] + "_z");
90  }
91  }
92 
93  // Skip in case of empty partition
94  if (m_f->m_exp[0]->GetNumElmts() == 0)
95  {
96  return;
97  }
98 
99  int npoints = m_f->m_exp[0]->GetNpoints();
100  Array<OneD, Array<OneD, NekDouble>> grad(addfields);
101  m_f->m_exp.resize(nfields + addfields);
102 
103  for (i = 0; i < addfields; ++i)
104  {
105  grad[i] = Array<OneD, NekDouble>(npoints);
106  }
107 
108  Array<OneD, Array<OneD, NekDouble>> tmp(spacedim);
109  for (int i = 0; i < spacedim; i++)
110  {
111  tmp[i] = Array<OneD, NekDouble>(npoints);
112  }
113 
114  // Get mapping
116 
117  // Get velocity and convert to Cartesian system,
118  // if it is still in transformed system
119  Array<OneD, Array<OneD, NekDouble>> vel(spacedim);
120  if (m_f->m_fieldMetaDataMap.count("MappingCartesianVel"))
121  {
122  if (m_f->m_fieldMetaDataMap["MappingCartesianVel"] == "False")
123  {
124  // Initialize arrays and copy velocity
125  for (int i = 0; i < spacedim; ++i)
126  {
127  vel[i] = Array<OneD, NekDouble>(npoints);
128  if (m_f->m_exp[0]->GetWaveSpace())
129  {
130  m_f->m_exp[0]->HomogeneousBwdTrans(m_f->m_exp[i]->GetPhys(),
131  vel[i]);
132  }
133  else
134  {
135  Vmath::Vcopy(npoints, m_f->m_exp[i]->GetPhys(), 1, vel[i],
136  1);
137  }
138  }
139  // Convert velocity to cartesian system
140  mapping->ContravarToCartesian(vel, vel);
141  // Convert back to wavespace if necessary
142  if (m_f->m_exp[0]->GetWaveSpace())
143  {
144  for (int i = 0; i < spacedim; ++i)
145  {
146  m_f->m_exp[0]->HomogeneousFwdTrans(vel[i], vel[i]);
147  }
148  }
149  }
150  else
151  {
152  for (int i = 0; i < spacedim; ++i)
153  {
154  vel[i] = Array<OneD, NekDouble>(npoints);
155  Vmath::Vcopy(npoints, m_f->m_exp[i]->GetPhys(), 1, vel[i], 1);
156  }
157  }
158  }
159  else
160  {
161  for (int i = 0; i < spacedim && i < nfields; ++i)
162  {
163  vel[i] = Array<OneD, NekDouble>(npoints);
164  Vmath::Vcopy(npoints, m_f->m_exp[i]->GetPhys(), 1, vel[i], 1);
165  }
166  }
167 
168  // Calculate Gradient
169  for (i = 0; i < nfields; ++i)
170  {
171  for (j = 0; j < spacedim; ++j)
172  {
173  if (i < spacedim)
174  {
175  m_f->m_exp[i]->PhysDeriv(MultiRegions::DirCartesianMap[j],
176  vel[i], tmp[j]);
177  }
178  else
179  {
180  m_f->m_exp[i]->PhysDeriv(MultiRegions::DirCartesianMap[j],
181  m_f->m_exp[i]->GetPhys(), tmp[j]);
182  }
183  }
184  mapping->CovarToCartesian(tmp, tmp);
185  for (int j = 0; j < spacedim; j++)
186  {
187  Vmath::Vcopy(npoints, tmp[j], 1, grad[i * spacedim + j], 1);
188  }
189  }
190 
191  for (i = 0; i < addfields; ++i)
192  {
193  m_f->m_exp[nfields + i] = m_f->AppendExpList(m_f->m_numHomogeneousDir);
194  Vmath::Vcopy(npoints, grad[i], 1, m_f->m_exp[nfields + i]->UpdatePhys(),
195  1);
196  m_f->m_exp[nfields + i]->FwdTransLocalElmt(
197  grad[i], m_f->m_exp[nfields + i]->UpdateCoeffs());
198  }
199 }
FieldSharedPtr m_f
Field object.
Definition: Module.h:225
static GlobalMapping::MappingSharedPtr GetMapping(FieldSharedPtr f)
GLOBAL_MAPPING_EXPORT typedef std::shared_ptr< Mapping > MappingSharedPtr
A shared pointer to a Mapping object.
Definition: Mapping.h:50
MultiRegions::Direction const DirCartesianMap[]
Definition: ExpList.h:89
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1255

References Nektar::MultiRegions::DirCartesianMap, Nektar::FieldUtils::ProcessMapping::GetMapping(), Nektar::FieldUtils::Module::m_f, Nektar::GlobalMapping::MappingSharedPtr, and Vmath::Vcopy().

Member Data Documentation

◆ className

ModuleKey Nektar::FieldUtils::ProcessGrad::className
static
Initial value:
"Computes gradient of fields.")
static std::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
Definition: ProcessGrad.h:53
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:285
ModuleFactory & GetModuleFactory()
Definition: Module.cpp:49

Definition at line 57 of file ProcessGrad.h.