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...
 
virtual std::string GetModuleName ()
 
- 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 (std::string key, std::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, std::set< int > &prismsDone, std::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...
 
std::map< std::string,
ConfigOption
m_config
 List of configuration values. 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.
virtual std::string Nektar::Utilities::ProcessGrad::GetModuleName ( )
inlinevirtual

Implements Nektar::Utilities::Module.

Definition at line 65 of file ProcessGrad.h.

66  {
67  return "ProcessGrad";
68  }
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  if(m_f->m_comm->GetRank() == 0)
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
99 
100  // Get velocity and convert to Cartesian system,
101  // if it is still in transformed system
102  Array<OneD, Array<OneD, NekDouble> > vel (spacedim);
103  if (m_f->m_fieldMetaDataMap.count("MappingCartesianVel"))
104  {
105  if(m_f->m_fieldMetaDataMap["MappingCartesianVel"] == "False")
106  {
107  // Initialize arrays and copy velocity
108  for ( int i =0; i<spacedim; ++i )
109  {
110  vel[i] = Array<OneD, NekDouble> (npoints);
111  if (m_f->m_exp[0]->GetWaveSpace())
112  {
113  m_f->m_exp[0]->HomogeneousBwdTrans(
114  m_f->m_exp[i]->GetPhys(),
115  vel[i]);
116  }
117  else
118  {
119  Vmath::Vcopy(npoints, m_f->m_exp[i]->GetPhys(),1,
120  vel[i],1);
121  }
122 
123  }
124  // Convert velocity to cartesian system
125  mapping->ContravarToCartesian(vel, vel);
126  // Convert back to wavespace if necessary
127  if (m_f->m_exp[0]->GetWaveSpace())
128  {
129  for ( int i =0; i<spacedim; ++i )
130  {
131  m_f->m_exp[0]->HomogeneousFwdTrans(vel[i], vel[i]);
132  }
133  }
134  }
135  else
136  {
137  for ( int i =0; i<spacedim; ++i )
138  {
139  vel[i] = Array<OneD, NekDouble> (npoints);
140  Vmath::Vcopy(npoints, m_f->m_exp[i]->GetPhys(), 1,
141  vel[i], 1);
142  }
143  }
144  }
145  else
146  {
147  for ( int i =0; i<spacedim; ++i )
148  {
149  vel[i] = Array<OneD, NekDouble> (npoints);
150  Vmath::Vcopy(npoints, m_f->m_exp[i]->GetPhys(), 1,
151  vel[i], 1);
152  }
153  }
154 
155  // Calculate Gradient
156  for (i = 0; i < nfields; ++i)
157  {
158  for (j = 0; j < spacedim; ++j)
159  {
160  if (i<spacedim)
161  {
162  m_f->m_exp[i]->PhysDeriv(MultiRegions::DirCartesianMap[j],
163  vel[i],
164  tmp[j]);
165  }
166  else
167  {
168  m_f->m_exp[i]->PhysDeriv(MultiRegions::DirCartesianMap[j],
169  m_f->m_exp[i]->GetPhys(),
170  tmp[j]);
171  }
172  }
173  mapping->CovarToCartesian(tmp, tmp);
174  for( int j = 0; j<spacedim; j++)
175  {
176  Vmath::Vcopy(npoints, tmp[j], 1, grad[i*spacedim+j], 1 );
177  }
178  }
179 
180  for (i = 0; i < addfields; ++i)
181  {
182  m_f->m_exp[nfields + i] = m_f->AppendExpList(m_f->m_fielddef[0]->m_numHomogeneousDir);
183  m_f->m_exp[nfields + i]->UpdatePhys() = grad[i];
184  m_f->m_exp[nfields + i]->FwdTrans_IterPerExp(grad[i],
185  m_f->m_exp[nfields + i]->UpdateCoeffs());
186  }
187 
188  vector<string > outname;
189  for (i = 0; i<nfields; ++i)
190  {
191  if(spacedim == 1)
192  {
193  outname.push_back(m_f->m_fielddef[0]->m_fields[i]+"_x");
194  }
195  else if (spacedim == 2)
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  }
200  else if (spacedim == 3)
201  {
202  outname.push_back(m_f->m_fielddef[0]->m_fields[i]+"_x");
203  outname.push_back(m_f->m_fielddef[0]->m_fields[i]+"_y");
204  outname.push_back(m_f->m_fielddef[0]->m_fields[i]+"_z");
205  }
206  }
207 
208  std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
209  = m_f->m_exp[0]->GetFieldDefinitions();
210  std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
211 
212  for (j = 0; j < nfields + addfields; ++j)
213  {
214  for (i = 0; i < FieldDef.size(); ++i)
215  {
216  if (j >= nfields)
217  {
218  FieldDef[i]->m_fields.push_back(outname[j-nfields]);
219  }
220  else
221  {
222  FieldDef[i]->m_fields.push_back(m_f->m_fielddef[0]->m_fields[j]);
223  }
224  m_f->m_exp[j]->AppendFieldData(FieldDef[i], FieldData[i]);
225  }
226  }
227 
228  m_f->m_fielddef = FieldDef;
229  m_f->m_data = FieldData;
230 }
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.