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 57 of file ProcessGrad.cpp.

57  : ProcessModule(f)
58 {
59 }

◆ ~ProcessGrad()

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

Definition at line 61 of file ProcessGrad.cpp.

62 {
63 }

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 65 of file ProcessGrad.cpp.

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

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:
ModuleKey(eProcessModule, "gradient"),
"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:200
std::pair< ModuleType, std::string > ModuleKey
Definition: Module.h:290
ModuleFactory & GetModuleFactory()
Definition: Module.cpp:49

Definition at line 57 of file ProcessGrad.h.