Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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:
Inheritance graph
[legend]
Collaboration diagram for Nektar::FieldUtils::ProcessGrad:
Collaboration graph
[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 ()
 
- 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)
 
FIELD_UTILS_EXPORT void RegisterConfig (string key, 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 bool GetRequireEquiSpaced (void)
 
FIELD_UTILS_EXPORT void SetRequireEquiSpaced (bool pVal)
 
FIELD_UTILS_EXPORT void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 

Static Public Member Functions

static boost::shared_ptr< Modulecreate (FieldSharedPtr f)
 Creates an instance of this class. More...
 

Static Public Attributes

static ModuleKey className
 

Additional Inherited Members

- Protected Member Functions inherited from Nektar::FieldUtils::Module
 Module ()
 
- Protected Attributes inherited from Nektar::FieldUtils::Module
FieldSharedPtr m_f
 Field object. More...
 
map< string, ConfigOptionm_config
 List of configuration values. More...
 
bool m_requireEquiSpaced
 

Detailed Description

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

Definition at line 50 of file ProcessGrad.h.

Constructor & Destructor Documentation

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

Definition at line 57 of file ProcessGrad.cpp.

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

Definition at line 61 of file ProcessGrad.cpp.

62 {
63 }

Member Function Documentation

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

Creates an instance of this class.

Definition at line 54 of file ProcessGrad.h.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr().

55  {
57  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
virtual std::string Nektar::FieldUtils::ProcessGrad::GetModuleName ( )
inlinevirtual

Implements Nektar::FieldUtils::Module.

Definition at line 66 of file ProcessGrad.h.

67  {
68  return "ProcessGrad";
69  }
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.

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

66 {
67  if (m_f->m_verbose)
68  {
69  if (m_f->m_comm->TreatAsRankZero())
70  {
71  cout << "ProcessGrad: Calculating gradients..." << endl;
72  }
73  }
74 
75  int i, j;
76  int expdim = m_f->m_graph->GetMeshDimension();
77  int spacedim = m_f->m_fielddef[0]->m_numHomogeneousDir + expdim;
78  int nfields = m_f->m_fielddef[0]->m_fields.size();
79  int addfields = nfields * spacedim;
80 
81  int npoints = m_f->m_exp[0]->GetNpoints();
82  Array<OneD, Array<OneD, NekDouble> > grad(addfields);
83  m_f->m_exp.resize(nfields + addfields);
84 
85  for (i = 0; i < addfields; ++i)
86  {
87  grad[i] = Array<OneD, NekDouble>(npoints);
88  }
89 
90  Array<OneD, Array<OneD, NekDouble> > tmp(spacedim);
91  for (int i = 0; i < spacedim; i++)
92  {
93  tmp[i] = Array<OneD, NekDouble>(npoints);
94  }
95 
96  // Get mapping
98 
99  // Get velocity and convert to Cartesian system,
100  // if it is still in transformed system
101  Array<OneD, Array<OneD, NekDouble> > vel(spacedim);
102  if (m_f->m_fieldMetaDataMap.count("MappingCartesianVel"))
103  {
104  if (m_f->m_fieldMetaDataMap["MappingCartesianVel"] == "False")
105  {
106  // Initialize arrays and copy velocity
107  for (int i = 0; i < spacedim; ++i)
108  {
109  vel[i] = Array<OneD, NekDouble>(npoints);
110  if (m_f->m_exp[0]->GetWaveSpace())
111  {
112  m_f->m_exp[0]->HomogeneousBwdTrans(m_f->m_exp[i]->GetPhys(),
113  vel[i]);
114  }
115  else
116  {
117  Vmath::Vcopy(npoints, m_f->m_exp[i]->GetPhys(), 1, vel[i],
118  1);
119  }
120  }
121  // Convert velocity to cartesian system
122  mapping->ContravarToCartesian(vel, vel);
123  // Convert back to wavespace if necessary
124  if (m_f->m_exp[0]->GetWaveSpace())
125  {
126  for (int i = 0; i < spacedim; ++i)
127  {
128  m_f->m_exp[0]->HomogeneousFwdTrans(vel[i], vel[i]);
129  }
130  }
131  }
132  else
133  {
134  for (int i = 0; i < spacedim; ++i)
135  {
136  vel[i] = Array<OneD, NekDouble>(npoints);
137  Vmath::Vcopy(npoints, m_f->m_exp[i]->GetPhys(), 1, vel[i], 1);
138  }
139  }
140  }
141  else
142  {
143  for (int i = 0; i < spacedim; ++i)
144  {
145  vel[i] = Array<OneD, NekDouble>(npoints);
146  Vmath::Vcopy(npoints, m_f->m_exp[i]->GetPhys(), 1, vel[i], 1);
147  }
148  }
149 
150  // Calculate Gradient
151  for (i = 0; i < nfields; ++i)
152  {
153  for (j = 0; j < spacedim; ++j)
154  {
155  if (i < spacedim)
156  {
157  m_f->m_exp[i]->PhysDeriv(MultiRegions::DirCartesianMap[j],
158  vel[i], tmp[j]);
159  }
160  else
161  {
162  m_f->m_exp[i]->PhysDeriv(MultiRegions::DirCartesianMap[j],
163  m_f->m_exp[i]->GetPhys(), tmp[j]);
164  }
165  }
166  mapping->CovarToCartesian(tmp, tmp);
167  for (int j = 0; j < spacedim; j++)
168  {
169  Vmath::Vcopy(npoints, tmp[j], 1, grad[i * spacedim + j], 1);
170  }
171  }
172 
173  for (i = 0; i < addfields; ++i)
174  {
175  m_f->m_exp[nfields + i] =
176  m_f->AppendExpList(m_f->m_fielddef[0]->m_numHomogeneousDir);
177  Vmath::Vcopy(npoints, grad[i], 1, m_f->m_exp[nfields + i]->UpdatePhys(),
178  1);
179  m_f->m_exp[nfields + i]->FwdTrans_IterPerExp(
180  grad[i], m_f->m_exp[nfields + i]->UpdateCoeffs());
181  }
182 
183  vector<string> outname;
184  for (i = 0; i < nfields; ++i)
185  {
186  if (spacedim == 1)
187  {
188  outname.push_back(m_f->m_fielddef[0]->m_fields[i] + "_x");
189  }
190  else if (spacedim == 2)
191  {
192  outname.push_back(m_f->m_fielddef[0]->m_fields[i] + "_x");
193  outname.push_back(m_f->m_fielddef[0]->m_fields[i] + "_y");
194  }
195  else if (spacedim == 3)
196  {
197  outname.push_back(m_f->m_fielddef[0]->m_fields[i] + "_x");
198  outname.push_back(m_f->m_fielddef[0]->m_fields[i] + "_y");
199  outname.push_back(m_f->m_fielddef[0]->m_fields[i] + "_z");
200  }
201  }
202 
203  std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef =
204  m_f->m_exp[0]->GetFieldDefinitions();
205  std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
206 
207  for (j = 0; j < nfields + addfields; ++j)
208  {
209  for (i = 0; i < FieldDef.size(); ++i)
210  {
211  if (j >= nfields)
212  {
213  FieldDef[i]->m_fields.push_back(outname[j - nfields]);
214  }
215  else
216  {
217  FieldDef[i]->m_fields.push_back(
218  m_f->m_fielddef[0]->m_fields[j]);
219  }
220  m_f->m_exp[j]->AppendFieldData(FieldDef[i], FieldData[i]);
221  }
222  }
223 
224  m_f->m_fielddef = FieldDef;
225  m_f->m_data = FieldData;
226 }
static GlobalMapping::MappingSharedPtr GetMapping(FieldSharedPtr f)
GLOBAL_MAPPING_EXPORT typedef boost::shared_ptr< Mapping > MappingSharedPtr
A shared pointer to a Mapping object.
Definition: Mapping.h:51
MultiRegions::Direction const DirCartesianMap[]
Definition: ExpList.h:86
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1061
FieldSharedPtr m_f
Field object.

Member Data Documentation

ModuleKey Nektar::FieldUtils::ProcessGrad::className
static
Initial value:
ModuleKey(eProcessModule, "gradient"),
"Computes gradient of fields.")

Definition at line 58 of file ProcessGrad.h.