Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
Nektar::Utilities::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::Utilities::ProcessGrad:
Inheritance graph
[legend]
Collaboration diagram for Nektar::Utilities::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...
 
- Public Member Functions inherited from Nektar::Utilities::ProcessModule
 ProcessModule ()
 
 ProcessModule (FieldSharedPtr p_f)
 
 ProcessModule (MeshSharedPtr p_m)
 
- Public Member Functions inherited from Nektar::Utilities::Module
 Module (FieldSharedPtr p_f)
 
void RegisterConfig (string key, string value)
 Register a configuration option with a module. More...
 
void PrintConfig ()
 Print out all configuration options for a module. More...
 
void SetDefaults ()
 Sets default configuration options for those which have not been set. More...
 
bool GetRequireEquiSpaced (void)
 
void SetRequireEquiSpaced (bool pVal)
 
void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 
 Module (MeshSharedPtr p_m)
 
virtual void Process ()=0
 
void RegisterConfig (string key, string value)
 
void PrintConfig ()
 
void SetDefaults ()
 
MeshSharedPtr GetMesh ()
 
virtual void ProcessVertices ()
 Extract element vertices. More...
 
virtual void ProcessEdges (bool ReprocessEdges=true)
 Extract element edges. More...
 
virtual void ProcessFaces (bool ReprocessFaces=true)
 Extract element faces. More...
 
virtual void ProcessElements ()
 Generate element IDs. More...
 
virtual void ProcessComposites ()
 Generate composites. More...
 
virtual void ClearElementLinks ()
 

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::Utilities::Module
 Module ()
 
void ReorderPrisms (PerMap &perFaces)
 Reorder node IDs so that prisms and tetrahedra are aligned correctly. More...
 
void PrismLines (int prism, PerMap &perFaces, set< int > &prismsDone, vector< ElementSharedPtr > &line)
 
- Protected Attributes inherited from Nektar::Utilities::Module
FieldSharedPtr m_f
 Field object. More...
 
map< string, ConfigOptionm_config
 List of configuration values. More...
 
bool m_requireEquiSpaced
 
MeshSharedPtr m_mesh
 Mesh object. More...
 

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::Utilities::ProcessGrad::ProcessGrad ( FieldSharedPtr  f)

Definition at line 57 of file ProcessGrad.cpp.

Nektar::Utilities::ProcessGrad::~ProcessGrad ( )
virtual

Definition at line 61 of file ProcessGrad.cpp.

62 {
63 }

Member Function Documentation

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

Creates an instance of this class.

Definition at line 54 of file ProcessGrad.h.

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

54  {
56  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
void Nektar::Utilities::ProcessGrad::Process ( po::variables_map &  vm)
virtual

Write mesh to output file.

Implements Nektar::Utilities::Module.

Definition at line 65 of file ProcessGrad.cpp.

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

66 {
67  if (m_f->m_verbose)
68  {
69  cout << "ProcessGrad: Calculating gradients..." << endl;
70  }
71 
72  int i, j;
73  int expdim = m_f->m_graph->GetMeshDimension();
74  int spacedim = m_f->m_fielddef[0]->m_numHomogeneousDir + expdim;
75  int nfields = m_f->m_fielddef[0]->m_fields.size();
76  int addfields = nfields*spacedim;
77 
78  int npoints = m_f->m_exp[0]->GetNpoints();
79  Array<OneD, Array<OneD, NekDouble> > grad(addfields);
80  m_f->m_exp.resize(nfields+addfields);
81 
82  for (i = 0; i < addfields; ++i)
83  {
84  grad[i] = Array<OneD, NekDouble>(npoints);
85  }
86 
87  Array<OneD, Array<OneD, NekDouble> > tmp(spacedim);
88  for( int i = 0; i<spacedim; i++)
89  {
90  tmp[i] = Array<OneD, NekDouble> (npoints);
91  }
92 
93  // Get mapping
96 
97  // Get velocity and convert to Cartesian system,
98  // if it is still in transformed system
99  Array<OneD, Array<OneD, NekDouble> > vel (spacedim);
100  if (m_f->m_fieldMetaDataMap.count("MappingCartesianVel"))
101  {
102  if(m_f->m_fieldMetaDataMap["MappingCartesianVel"] == "False")
103  {
104  // Initialize arrays and copy velocity
105  for ( int i =0; i<spacedim; ++i )
106  {
107  vel[i] = Array<OneD, NekDouble> (npoints);
108  if (m_f->m_exp[0]->GetWaveSpace())
109  {
110  m_f->m_exp[0]->HomogeneousBwdTrans(
111  m_f->m_exp[i]->GetPhys(),
112  vel[i]);
113  }
114  else
115  {
116  Vmath::Vcopy(npoints, m_f->m_exp[i]->GetPhys(),1,
117  vel[i],1);
118  }
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,
138  vel[i], 1);
139  }
140  }
141  }
142  else
143  {
144  for ( int i =0; i<spacedim; ++i )
145  {
146  vel[i] = Array<OneD, NekDouble> (npoints);
147  Vmath::Vcopy(npoints, m_f->m_exp[i]->GetPhys(), 1,
148  vel[i], 1);
149  }
150  }
151 
152  // Calculate Gradient
153  for (i = 0; i < nfields; ++i)
154  {
155  for (j = 0; j < spacedim; ++j)
156  {
157  if (i<spacedim)
158  {
159  m_f->m_exp[i]->PhysDeriv(MultiRegions::DirCartesianMap[j],
160  vel[i],
161  tmp[j]);
162  }
163  else
164  {
165  m_f->m_exp[i]->PhysDeriv(MultiRegions::DirCartesianMap[j],
166  m_f->m_exp[i]->GetPhys(),
167  tmp[j]);
168  }
169  }
170  mapping->CovarToCartesian(tmp, tmp);
171  for( int j = 0; j<spacedim; j++)
172  {
173  Vmath::Vcopy(npoints, tmp[j], 1, grad[i*spacedim+j], 1 );
174  }
175  }
176 
177  for (i = 0; i < addfields; ++i)
178  {
179  m_f->m_exp[nfields + i] = m_f->AppendExpList(m_f->m_fielddef[0]->m_numHomogeneousDir);
180  m_f->m_exp[nfields + i]->UpdatePhys() = grad[i];
181  m_f->m_exp[nfields + i]->FwdTrans_IterPerExp(grad[i],
182  m_f->m_exp[nfields + i]->UpdateCoeffs());
183  }
184 
185  vector<string > outname;
186  for (i = 0; i<nfields; ++i)
187  {
188  if(spacedim == 1)
189  {
190  outname.push_back(m_f->m_fielddef[0]->m_fields[i]+"_x");
191  }
192  else if (spacedim == 2)
193  {
194  outname.push_back(m_f->m_fielddef[0]->m_fields[i]+"_x");
195  outname.push_back(m_f->m_fielddef[0]->m_fields[i]+"_y");
196  }
197  else if (spacedim == 3)
198  {
199  outname.push_back(m_f->m_fielddef[0]->m_fields[i]+"_x");
200  outname.push_back(m_f->m_fielddef[0]->m_fields[i]+"_y");
201  outname.push_back(m_f->m_fielddef[0]->m_fields[i]+"_z");
202  }
203  }
204 
205  std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
206  = m_f->m_exp[0]->GetFieldDefinitions();
207  std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
208 
209  for (j = 0; j < nfields + addfields; ++j)
210  {
211  for (i = 0; i < FieldDef.size(); ++i)
212  {
213  if (j >= nfields)
214  {
215  FieldDef[i]->m_fields.push_back(outname[j-nfields]);
216  }
217  else
218  {
219  FieldDef[i]->m_fields.push_back(m_f->m_fielddef[0]->m_fields[j]);
220  }
221  m_f->m_exp[j]->AppendFieldData(FieldDef[i], FieldData[i]);
222  }
223  }
224 
225  m_f->m_fielddef = FieldDef;
226  m_f->m_data = FieldData;
227 }
FieldSharedPtr m_f
Field object.
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:1047

Member Data Documentation

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

Definition at line 57 of file ProcessGrad.h.