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::ProcessVorticity Class Reference

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

#include <ProcessVorticity.h>

Inheritance diagram for Nektar::Utilities::ProcessVorticity:
Inheritance graph
[legend]
Collaboration diagram for Nektar::Utilities::ProcessVorticity:
Collaboration graph
[legend]

Public Member Functions

 ProcessVorticity (FieldSharedPtr f)
 
virtual ~ProcessVorticity ()
 
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 49 of file ProcessVorticity.h.

Constructor & Destructor Documentation

Nektar::Utilities::ProcessVorticity::ProcessVorticity ( FieldSharedPtr  f)

Definition at line 57 of file ProcessVorticity.cpp.

Nektar::Utilities::ProcessVorticity::~ProcessVorticity ( )
virtual

Definition at line 61 of file ProcessVorticity.cpp.

62 {
63 }

Member Function Documentation

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

Creates an instance of this class.

Definition at line 53 of file ProcessVorticity.h.

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

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

Implements Nektar::Utilities::Module.

Definition at line 64 of file ProcessVorticity.h.

65  {
66  return "ProcessVorticity";
67  }
void Nektar::Utilities::ProcessVorticity::Process ( po::variables_map &  vm)
virtual

Write mesh to output file.

Implements Nektar::Utilities::Module.

Definition at line 65 of file ProcessVorticity.cpp.

References ASSERTL0, Nektar::Utilities::ProcessMapping::GetMapping(), Nektar::iterator, Nektar::Utilities::Module::m_f, Nektar::GlobalMapping::MappingSharedPtr, Vmath::Vcopy(), and Vmath::Vsub().

66 {
67  if (m_f->m_verbose)
68  {
69  if(m_f->m_comm->GetRank() == 0)
70  {
71  cout << "ProcessVorticity: Calculating vorticity..." << endl;
72  }
73  }
74 
75  int i, j, s;
76  int expdim = m_f->m_graph->GetMeshDimension();
77  int spacedim = expdim;
78  if ((m_f->m_fielddef[0]->m_numHomogeneousDir) == 1 ||
79  (m_f->m_fielddef[0]->m_numHomogeneousDir) == 2)
80  {
81  spacedim = 3;
82  }
83  int nfields = m_f->m_fielddef[0]->m_fields.size();
84  if (spacedim == 1)
85  {
86  ASSERTL0(false, "Error: Vorticity for a 1D problem cannot "
87  "be computed")
88  }
89  int addfields = (spacedim == 2)? 1:3;
90 
91  int npoints = m_f->m_exp[0]->GetNpoints();
92  Array<OneD, Array<OneD, NekDouble> > grad(spacedim*spacedim);
93  Array<OneD, Array<OneD, NekDouble> > outfield(addfields);
94 
95  int nstrips;
96 
97  m_f->m_session->LoadParameter("Strip_Z",nstrips,1);
98 
99  m_f->m_exp.resize(nfields*nstrips);
100 
101  for (i = 0; i < spacedim*spacedim; ++i)
102  {
103  grad[i] = Array<OneD, NekDouble>(npoints);
104  }
105 
106  for (i = 0; i < addfields; ++i)
107  {
108  outfield[i] = Array<OneD, NekDouble>(npoints);
109  }
110 
111  Array<OneD, Array<OneD, NekDouble> > tmp(spacedim);
112  for( int i = 0; i<spacedim; i++)
113  {
114  tmp[i] = Array<OneD, NekDouble> (npoints);
115  }
116 
117  vector<MultiRegions::ExpListSharedPtr> Exp(nstrips*addfields);
118 
119  // Get mapping
122 
123  for(s = 0; s < nstrips; ++s) //homogeneous strip varient
124  {
125  // Get velocity and convert to Cartesian system,
126  // if it is still in transformed system
127  Array<OneD, Array<OneD, NekDouble> > vel (spacedim);
128  if (m_f->m_fieldMetaDataMap.count("MappingCartesianVel"))
129  {
130  if(m_f->m_fieldMetaDataMap["MappingCartesianVel"] == "False")
131  {
132  // Initialize arrays and copy velocity
133  for ( int i =0; i<spacedim; ++i )
134  {
135  vel[i] = Array<OneD, NekDouble> (npoints);
136  if (m_f->m_exp[0]->GetWaveSpace())
137  {
138  m_f->m_exp[0]->HomogeneousBwdTrans(
139  m_f->m_exp[s*nfields+i]->GetPhys(),
140  vel[i]);
141  }
142  else
143  {
144  Vmath::Vcopy(npoints, m_f->m_exp[s*nfields+i]->GetPhys(),1,
145  vel[i],1);
146  }
147 
148  }
149  // Convert velocity to cartesian system
150  mapping->ContravarToCartesian(vel, vel);
151  // Convert back to wavespace if necessary
152  if (m_f->m_exp[0]->GetWaveSpace())
153  {
154  for ( int i =0; i<spacedim; ++i )
155  {
156  m_f->m_exp[0]->HomogeneousFwdTrans(vel[i], vel[i]);
157  }
158  }
159  }
160  else
161  {
162  for ( int i =0; i<spacedim; ++i )
163  {
164  vel[i] = Array<OneD, NekDouble> (npoints);
165  Vmath::Vcopy(npoints, m_f->m_exp[s*nfields+i]->GetPhys(), 1,
166  vel[i], 1);
167  }
168  }
169  }
170  else
171  {
172  for ( int i =0; i<spacedim; ++i )
173  {
174  vel[i] = Array<OneD, NekDouble> (npoints);
175  Vmath::Vcopy(npoints, m_f->m_exp[s*nfields+i]->GetPhys(), 1,
176  vel[i], 1);
177  }
178  }
179 
180  // Calculate Gradient & Vorticity
181  if (spacedim == 2)
182  {
183  for (i = 0; i < spacedim; ++i)
184  {
185  m_f->m_exp[s*nfields+i]->PhysDeriv(vel[i],
186  tmp[0],
187  tmp[1]);
188  mapping->CovarToCartesian(tmp, tmp);
189  for( int j = 0; j<spacedim; j++)
190  {
191  Vmath::Vcopy(npoints, tmp[j], 1, grad[i*spacedim+j], 1 );
192  }
193  }
194  // W_z = Vx - Uy
195  Vmath::Vsub(npoints, grad[1*spacedim+0], 1,
196  grad[0*spacedim+1], 1,
197  outfield[0], 1);
198  }
199  else
200  {
201  for (i = 0; i < spacedim; ++i)
202  {
203  m_f->m_exp[s*nfields+i]->PhysDeriv(vel[i],
204  tmp[0],
205  tmp[1],
206  tmp[2]);
207  mapping->CovarToCartesian(tmp, tmp);
208  for( int j = 0; j<spacedim; j++)
209  {
210  Vmath::Vcopy(npoints, tmp[j], 1, grad[i*spacedim+j], 1 );
211  }
212  }
213 
214  // W_x = Wy - Vz
215  Vmath::Vsub(npoints, grad[2*spacedim+1], 1, grad[1*spacedim+2], 1,
216  outfield[0],1);
217  // W_y = Uz - Wx
218  Vmath::Vsub(npoints, grad[0*spacedim+2], 1, grad[2*spacedim+0], 1,
219  outfield[1], 1);
220  // W_z = Vx - Uy
221  Vmath::Vsub(npoints, grad[1*spacedim+0], 1, grad[0*spacedim+1], 1,
222  outfield[2], 1);
223  }
224 
225  for (i = 0; i < addfields; ++i)
226  {
227  int n = s*addfields + i;
228  Exp[n] = m_f->AppendExpList(m_f->m_fielddef[0]->m_numHomogeneousDir);
229  Exp[n]->UpdatePhys() = outfield[i];
230  Exp[n]->FwdTrans_IterPerExp(outfield[i],
231  Exp[n]->UpdateCoeffs());
232  }
233  }
234 
236  for(s = 0; s < nstrips; ++s)
237  {
238  for(i = 0; i < addfields; ++i)
239  {
240  it = m_f->m_exp.begin()+s*(nfields+addfields)+nfields+i;
241  m_f->m_exp.insert(it, Exp[s*addfields+i]);
242  }
243  }
244 
245  vector<string > outname;
246  if (addfields == 1)
247  {
248  outname.push_back("W_z");
249  }
250  else
251  {
252  outname.push_back("W_x");
253  outname.push_back("W_y");
254  outname.push_back("W_z");
255  }
256 
257  std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
258  = m_f->m_exp[0]->GetFieldDefinitions();
259  std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
260 
261  for(s = 0; s < nstrips; ++s) //homogeneous strip varient
262  {
263  for (j = 0; j < nfields + addfields; ++j)
264  {
265  for (i = 0; i < FieldDef.size()/nstrips; ++i)
266  {
267  int n = s * FieldDef.size()/nstrips + i;
268 
269  if (j >= nfields)
270  {
271  FieldDef[n]->m_fields.push_back(outname[j-nfields]);
272  }
273  else
274  {
275  FieldDef[n]->m_fields.push_back(m_f->m_fielddef[0]->m_fields[j]);
276  }
277  m_f->m_exp[s*(nfields + addfields)+j]->AppendFieldData(FieldDef[n], FieldData[n]);
278  }
279  }
280  }
281 
282  m_f->m_fielddef = FieldDef;
283  m_f->m_data = FieldData;
284 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:188
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
void Vsub(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Subtract vector z = x-y.
Definition: Vmath.cpp:329
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
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::ProcessVorticity::className
static
Initial value:

Definition at line 56 of file ProcessVorticity.h.