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

This processing module calculates the wall shear stress and adds it as an extra-field to the output file, and writes it to a surface output file. More...

#include <ProcessWSS.h>

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

Public Member Functions

 ProcessWSS (FieldSharedPtr f)
 
virtual ~ProcessWSS ()
 
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 wall shear stress and adds it as an extra-field to the output file, and writes it to a surface output file.

Definition at line 50 of file ProcessWSS.h.

Constructor & Destructor Documentation

Nektar::Utilities::ProcessWSS::ProcessWSS ( FieldSharedPtr  f)

Definition at line 56 of file ProcessWSS.cpp.

References Nektar::Utilities::Module::m_config, and Nektar::Utilities::Module::m_f.

56  : ProcessModule(f)
57 {
58  m_config["bnd"] = ConfigOption(false,"All","Boundary to be extracted");
59  m_config["addnormals"] = ConfigOption(true,"NotSet","Add normals to output");
60  f->m_writeBndFld = true;
61  f->m_declareExpansionAsContField = true;
62  f->m_requireBoundaryExpansion = true;
63  m_f->m_fldToBnd = false;
64 }
map< string, ConfigOption > m_config
List of configuration values.
FieldSharedPtr m_f
Field object.
Nektar::Utilities::ProcessWSS::~ProcessWSS ( )
virtual

Definition at line 66 of file ProcessWSS.cpp.

67 {
68 }

Member Function Documentation

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

Creates an instance of this class.

Definition at line 54 of file ProcessWSS.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::ProcessWSS::GetModuleName ( )
inlinevirtual

Implements Nektar::Utilities::Module.

Definition at line 65 of file ProcessWSS.h.

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

Write mesh to output file.

Implements Nektar::Utilities::Module.

Definition at line 70 of file ProcessWSS.cpp.

References ASSERTL0, Nektar::ParseUtils::GenerateOrderedVector(), Nektar::SpatialDomains::BoundaryConditions::GetBoundaryRegions(), Nektar::Utilities::Module::m_config, Nektar::Utilities::Module::m_f, Vmath::Neg(), Vmath::Smul(), Vmath::Vadd(), Vmath::Vsqrt(), Vmath::Vvtvp(), and Vmath::Zero().

71 {
72  if (m_f->m_verbose)
73  {
74  if(m_f->m_comm->TreatAsRankZero())
75  {
76  cout << "ProcessWSS: Calculating wall shear stress..." << endl;
77  }
78  }
79 
80  m_f->m_addNormals = m_config["addnormals"].m_beenSet;
81 
82  // Set up Field options to output boundary fld
83  string bvalues = m_config["bnd"].as<string>();
84 
85  if(bvalues.compare("All") == 0)
86  {
87  Array<OneD, const MultiRegions::ExpListSharedPtr>
88  BndExp = m_f->m_exp[0]->GetBndCondExpansions();
89 
90  for(int i = 0; i < BndExp.num_elements(); ++i)
91  {
92  m_f->m_bndRegionsToWrite.push_back(i);
93  }
94  }
95  else
96  {
98  m_f->m_bndRegionsToWrite),"Failed to interpret range string");
99  }
100 
101  NekDouble kinvis = m_f->m_session->GetParameter("Kinvis");
102 
103  int i, j;
104  int spacedim = m_f->m_graph->GetSpaceDimension();
105  if ((m_f->m_fielddef[0]->m_numHomogeneousDir) == 1 ||
106  (m_f->m_fielddef[0]->m_numHomogeneousDir) == 2)
107  {
108  spacedim += m_f->m_fielddef[0]->m_numHomogeneousDir;
109  }
110 
111  int nfields = m_f->m_fielddef[0]->m_fields.size();
112  ASSERTL0(m_f->m_fielddef[0]->m_fields[0] == "u","Implicit assumption that input is in incompressible format of (u,v,p) or (u,v,w,p)");
113 
114  if (spacedim == 1)
115  {
116  ASSERTL0(false, "Error: wss for a 1D problem cannot "
117  "be computed");
118  }
119 
120  int newfields = spacedim + 1;
121  int nshear = spacedim + 1;
122  int nstress = spacedim*spacedim;
123  int ngrad = spacedim*spacedim;
124 
125  Array<OneD, Array<OneD, NekDouble> > velocity(nfields), grad(ngrad), fgrad(ngrad);
126  Array<OneD, Array<OneD, NekDouble> > stress(nstress), fstress(nstress);
127  Array<OneD, Array<OneD, NekDouble> > fshear(nshear);
128 
129  Array<OneD, MultiRegions::ExpListSharedPtr> BndExp(newfields);
130  Array<OneD, MultiRegions::ExpListSharedPtr> BndElmtExp(spacedim);
131 
132  // Extract original fields to boundary (for output)
133  for (int i = 0; i < m_f->m_exp.size(); ++i)
134  {
135  m_f->m_exp[i]->FillBndCondFromField();
136  }
137 
138  m_f->m_exp.resize(nfields + newfields);
139  string var = "u";
140  for(i = 0; i < newfields; ++i)
141  {
142  m_f->m_exp[nfields + i] = m_f->AppendExpList(m_f->m_fielddef[0]->m_numHomogeneousDir, var);
143  }
144 
145  if(spacedim == 2)
146  {
147  m_f->m_fielddef[0]->m_fields.push_back("Shear_x");
148  m_f->m_fielddef[0]->m_fields.push_back("Shear_y");
149  m_f->m_fielddef[0]->m_fields.push_back("Shear_mag");
150  }
151  else
152  {
153  m_f->m_fielddef[0]->m_fields.push_back("Shear_x");
154  m_f->m_fielddef[0]->m_fields.push_back("Shear_y");
155  m_f->m_fielddef[0]->m_fields.push_back("Shear_z");
156  m_f->m_fielddef[0]->m_fields.push_back("Shear_mag");
157  }
158 
159  // Create map of boundary ids for partitioned domains
160  SpatialDomains::BoundaryConditions bcs(m_f->m_session,
161  m_f->m_exp[0]->GetGraph());
163  bcs.GetBoundaryRegions();
164  SpatialDomains::BoundaryRegionCollection::const_iterator breg_it;
165  map<int,int> BndRegionMap;
166  int cnt =0;
167  for(breg_it = bregions.begin(); breg_it != bregions.end();
168  ++breg_it, ++cnt)
169  {
170  BndRegionMap[breg_it->first] = cnt;
171  }
172  // Loop over boundaries to Write
173  for(int b = 0; b < m_f->m_bndRegionsToWrite.size(); ++b)
174  {
175  if(BndRegionMap.count(m_f->m_bndRegionsToWrite[b]) == 1)
176  {
177  int bnd = BndRegionMap[m_f->m_bndRegionsToWrite[b]];
178  // Get expansion list for boundary and for elements containing this bnd
179  for(i = 0; i < newfields; i++)
180  {
181  BndExp[i] = m_f->m_exp[nfields + i]->UpdateBndCondExpansion(bnd);
182  }
183  for(i = 0; i < spacedim; i++)
184  {
185  m_f->m_exp[i]->GetBndElmtExpansion(bnd, BndElmtExp[i]);
186  }
187 
188  // Get number of points in expansions
189  int nqb = BndExp[0]->GetTotPoints();
190  int nqe = BndElmtExp[0]->GetTotPoints();
191 
192  // Initialise local arrays for the velocity gradients, and stress components
193  // size of total number of quadrature points for elements in this bnd
194  for(i = 0; i < ngrad; ++i)
195  {
196  grad[i] = Array<OneD, NekDouble>(nqe);
197  }
198 
199  for(i = 0; i < nstress; ++i)
200  {
201  stress[i] = Array<OneD, NekDouble>(nqe);
202  }
203 
204  // initialise arrays in the boundary
205  for(i = 0; i < nstress; ++i)
206  {
207  fstress[i] = Array<OneD, NekDouble>(nqb);
208  }
209 
210  for(i = 0; i < ngrad; ++i)
211  {
212  fgrad[i] = Array<OneD, NekDouble>(nqb);
213  }
214 
215  for(i = 0; i < nshear; ++i)
216  {
217  fshear[i] = Array<OneD, NekDouble>(nqb, 0.0);
218  }
219 
220  //Extract Velocities
221  for(i = 0; i < spacedim; ++i)
222  {
223  velocity[i] = BndElmtExp[i]->GetPhys();
224  }
225 
226  //Compute gradients (velocity correction scheme method)
227  for(i = 0; i < spacedim; ++i)
228  {
229  if (spacedim == 2)
230  {
231  BndElmtExp[i]->PhysDeriv(velocity[i],grad[i*spacedim+0],
232  grad[i*spacedim+1]);
233  }
234  else
235  {
236  BndElmtExp[i]->PhysDeriv(velocity[i],grad[i*spacedim+0],
237  grad[i*spacedim+1],
238  grad[i*spacedim+2]);
239  }
240  }
241 
242  //Compute stress component terms tau_ij = mu*(u_i,j + u_j,i)
243  for(i = 0; i < spacedim; ++i)
244  {
245  for(j = 0; j < spacedim; ++j)
246  {
247  Vmath::Vadd(nqe, grad[i*spacedim+j], 1,
248  grad[j*spacedim+i], 1,
249  stress[i*spacedim+j], 1);
250 
251  Vmath::Smul(nqe, kinvis, stress[i*spacedim+j], 1,
252  stress[i*spacedim+j], 1);
253  }
254  }
255 
256  // Get boundary stress values.
257  for(j = 0; j < nstress; ++j)
258  {
259  m_f->m_exp[0]->ExtractElmtToBndPhys(bnd, stress[j],fstress[j]);
260  }
261 
262  //Get normals
263  Array<OneD, Array<OneD, NekDouble> > normals;
264  m_f->m_exp[0]->GetBoundaryNormals(bnd, normals);
265  // Reverse normals, to get correct orientation for the body
266  for(i = 0; i < spacedim; ++i)
267  {
268  Vmath::Neg(nqb, normals[i], 1);
269  }
270 
271  //calculate wss, and update coeffs in the boundary expansion
272  // S = tau_ij * n_j
273  for(i = 0; i < spacedim; ++i)
274  {
275  for(j = 0; j < spacedim; ++j)
276  {
277  Vmath::Vvtvp(nqb,normals[j],1,fstress[i*spacedim+j],1,
278  fshear[i],1,
279  fshear[i],1);
280  }
281  }
282 
283  // T = S - (S.n)n
284  for(i = 0; i < spacedim; ++i)
285  {
286  Vmath::Vvtvp(nqb,normals[i],1,fshear[i],1,
287  fshear[nshear-1],1,
288  fshear[nshear-1],1);
289  }
290  Vmath::Smul(nqb, -1.0, fshear[nshear-1], 1, fshear[nshear-1], 1);
291 
292  for (i = 0; i < spacedim; i++)
293  {
294  Vmath::Vvtvp(nqb,normals[i], 1, fshear[nshear-1], 1,
295  fshear[i], 1,
296  fshear[i], 1);
297  BndExp[i]->FwdTrans(fshear[i],
298  BndExp[i]->UpdateCoeffs());
299  }
300 
301  // Tw
302  Vmath::Zero(nqb, fshear[nshear-1], 1);
303  for(i = 0; i < spacedim; ++i)
304  {
305  Vmath::Vvtvp(nqb,fshear[i],1,fshear[i],1,
306  fshear[nshear-1],1,
307  fshear[nshear-1],1);
308  }
309  Vmath::Vsqrt(nqb, fshear[nshear-1], 1, fshear[nshear-1], 1);
310  BndExp[nshear-1]->FwdTrans(fshear[nshear-1],
311  BndExp[nshear-1]->UpdateCoeffs());
312  }
313  }
314 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:188
static bool GenerateOrderedVector(const char *const str, std::vector< unsigned int > &vec)
Definition: ParseUtils.hpp:97
void Vsqrt(int n, const T *x, const int incx, T *y, const int incy)
sqrt y = sqrt(x)
Definition: Vmath.cpp:394
map< string, ConfigOption > m_config
List of configuration values.
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Definition: Vmath.cpp:428
FieldSharedPtr m_f
Field object.
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
Definition: Vmath.cpp:199
std::map< int, BoundaryRegionShPtr > BoundaryRegionCollection
Definition: Conditions.h:206
void Neg(int n, T *x, const int incx)
Negate x = -x.
Definition: Vmath.cpp:382
double NekDouble
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.cpp:359
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
Definition: Vmath.cpp:285

Member Data Documentation

ModuleKey Nektar::Utilities::ProcessWSS::className
static
Initial value:
=
ProcessWSS::create, "Computes wall shear stress field.")

Definition at line 57 of file ProcessWSS.h.