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

This processing module calculates the scalar gradient field and writes it to a surface output file. More...

#include <ProcessScalGrad.h>

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

Public Member Functions

 ProcessScalGrad (FieldSharedPtr f)
 
virtual ~ProcessScalGrad ()
 
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 scalar gradient field and writes it to a surface output file.

Definition at line 50 of file ProcessScalGrad.h.

Constructor & Destructor Documentation

Nektar::Utilities::ProcessScalGrad::ProcessScalGrad ( FieldSharedPtr  f)

Definition at line 56 of file ProcessScalGrad.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  f->m_writeBndFld = true;
60  f->m_declareExpansionAsContField = true;
61  m_f->m_fldToBnd = false;
62 }
map< string, ConfigOption > m_config
List of configuration values.
FieldSharedPtr m_f
Field object.
Nektar::Utilities::ProcessScalGrad::~ProcessScalGrad ( )
virtual

Definition at line 64 of file ProcessScalGrad.cpp.

65 {
66 }

Member Function Documentation

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

Creates an instance of this class.

Definition at line 54 of file ProcessScalGrad.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::ProcessScalGrad::Process ( po::variables_map &  vm)
virtual

Write mesh to output file.

Implements Nektar::Utilities::Module.

Definition at line 68 of file ProcessScalGrad.cpp.

References ASSERTL0, Nektar::SpatialDomains::eDeformed, Nektar::ParseUtils::GenerateOrderedVector(), Nektar::StdRegions::StdExpansion::GetTotPoints(), Nektar::Utilities::Module::m_config, Nektar::Utilities::Module::m_f, Vmath::Svtvp(), Vmath::Vvtvp(), and Vmath::Zero().

69 {
70  int i, j, k;
71  if (m_f->m_verbose)
72  {
73  cout << "ProcessScalGrad: Calculating scalar gradient..." << endl;
74  }
75 
76  // Set up Field options to output boundary fld
77  string bvalues = m_config["bnd"].as<string>();
78 
79  if(bvalues.compare("All") == 0)
80  {
82  BndExp = m_f->m_exp[0]->GetBndCondExpansions();
83 
84  for(i = 0; i < BndExp.num_elements(); ++i)
85  {
86  m_f->m_bndRegionsToWrite.push_back(i);
87  }
88  }
89  else
90  {
92  m_f->m_bndRegionsToWrite),"Failed to interpret range string");
93  }
94 
95  int spacedim = m_f->m_graph->GetSpaceDimension();
96  if ((m_f->m_fielddef[0]->m_numHomogeneousDir) == 1 ||
97  (m_f->m_fielddef[0]->m_numHomogeneousDir) == 2)
98  {
99  spacedim = 3;
100  }
101 
102  int nfields = m_f->m_fielddef[0]->m_fields.size();
103  //ASSERTL0(nfields == 1,"Implicit assumption that input is in ADR format of (u)");
104 
105  if (spacedim == 1)
106  {
107  ASSERTL0(false, "Error: scalar gradient for a 1D problem cannot "
108  "be computed");
109  }
110 
111 
112  int ngrad = spacedim;
113  int n, cnt, elmtid, nq, offset, boundary, nfq;
114  int npoints = m_f->m_exp[0]->GetNpoints();
115  string var;
116  Array<OneD, NekDouble> scalar;
117  Array<OneD, Array<OneD, NekDouble> > grad(ngrad), fgrad(ngrad), outfield(nfields);
118 
121  Array<OneD, int> BoundarytoElmtID, BoundarytoTraceID;
123 
124  m_f->m_exp[0]->GetBoundaryToElmtMap(BoundarytoElmtID, BoundarytoTraceID);
125 
126  for (i = 0; i < nfields; i++)
127  {
128  var = m_f->m_fielddef[0]->m_fields[i];
129  stringstream filename;
130  filename << var << "_scalar_gradient";
131  filename >> var;
132  m_f->m_fielddef[0]->m_fields[i] = var;
133 
134  BndExp[i] = m_f->m_exp[i]->GetBndCondExpansions();
135  outfield[i] = Array<OneD, NekDouble>(npoints);
136  }
137 
138  // loop over the types of boundary conditions
139  for(cnt = n = 0; n < BndExp[0].num_elements(); ++n)
140  {
141  bool doneBnd = false;
142  // identify if boundary has been defined
143  for(int b = 0; b < m_f->m_bndRegionsToWrite.size(); ++b)
144  {
145  if(n == m_f->m_bndRegionsToWrite[b])
146  {
147  doneBnd = true;
148  for(i = 0; i < BndExp[0][n]->GetExpSize(); ++i, cnt++)
149  {
150  // find element and face of this expansion.
151  elmtid = BoundarytoElmtID[cnt];
152  elmt = m_f->m_exp[0]->GetExp(elmtid);
153  nq = elmt->GetTotPoints();
154  offset = m_f->m_exp[0]->GetPhys_Offset(elmtid);
155 
156  // Initialise local arrays for the velocity gradients, and stress components
157  // size of total number of quadrature points for each element (hence local).
158  for(j = 0; j < ngrad; ++j)
159  {
160  grad[j] = Array<OneD, NekDouble>(nq);
161  }
162 
163  if(spacedim == 2)
164  {
165  //Not implemented in 2D.
166  }
167  else
168  {
169  for(j = 0; j < nfields; j++)
170  {
171  outfield[j] = BndExp[j][n]->UpdateCoeffs() + BndExp[j][n]->GetCoeff_Offset(i);
172  }
173 
174  // Get face 2D expansion from element expansion
175  bc = boost::dynamic_pointer_cast<StdRegions::StdExpansion2D> (BndExp[0][n]->GetExp(i));
176  nfq = bc->GetTotPoints();
177 
178  //identify boundary of element looking at.
179  boundary = BoundarytoTraceID[cnt];
180 
181  //Get face normals
182  const SpatialDomains::GeomFactorsSharedPtr m_metricinfo = bc->GetMetricInfo();
183 
185  = elmt->GetFaceNormal(boundary);
186 
187  // initialise arrays
188  for(j = 0; j < ngrad; ++j)
189  {
190  fgrad[j] = Array<OneD, NekDouble>(nfq);
191  }
192  Array<OneD, NekDouble> gradnorm(nfq);
193 
194  for(k = 0; k < nfields; k++)
195  {
196  Vmath::Zero(nfq, gradnorm, 1);
197 
198  scalar = m_f->m_exp[k]->GetPhys() + offset;
199  elmt->PhysDeriv(scalar, grad[0],grad[1],grad[2]);
200 
201  for(j = 0; j < ngrad; ++j)
202  {
203  elmt->GetFacePhysVals(boundary,bc,grad[j],fgrad[j]);
204  }
205 
206  //surface curved
207  if (m_metricinfo->GetGtype() == SpatialDomains::eDeformed)
208  {
209  for (j=0; j<ngrad; j++)
210  {
211  Vmath::Vvtvp(nfq, normals[j], 1, fgrad[j], 1, gradnorm, 1, gradnorm, 1);
212  }
213  }
214  else
215  {
216  for (j=0; j<ngrad; j++)
217  {
218  Vmath::Svtvp(nfq, normals[j][0], fgrad[j], 1, gradnorm, 1, gradnorm, 1);
219  }
220  }
221  bc->FwdTrans(gradnorm, outfield[k]);
222  }
223 
224  }
225  }
226  }
227  }
228  if(doneBnd == false)
229  {
230  cnt += BndExp[0][n]->GetExpSize();
231  }
232  }
233 
234  for(j = 0; j < nfields; ++j)
235  {
236  for(int b = 0; b < m_f->m_bndRegionsToWrite.size(); ++b)
237  {
238  m_f->m_exp[j]->UpdateBndCondExpansion(m_f->m_bndRegionsToWrite[b]) = BndExp[j][m_f->m_bndRegionsToWrite[b]];
239  }
240 
241  }
242 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
static bool GenerateOrderedVector(const char *const str, std::vector< unsigned int > &vec)
Definition: ParseUtils.hpp:97
void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
svtvp (scalar times vector plus vector): z = alpha*x + y
Definition: Vmath.cpp:471
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
map< string, ConfigOption > m_config
List of configuration values.
FieldSharedPtr m_f
Field object.
int GetTotPoints() const
This function returns the total number of quadrature points used in the element.
Definition: StdExpansion.h:141
boost::shared_ptr< StdExpansion2D > StdExpansion2DSharedPtr
boost::shared_ptr< GeomFactors > GeomFactorsSharedPtr
Pointer to a GeomFactors object.
Definition: GeomFactors.h:62
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.cpp:359
boost::shared_ptr< StdExpansion > StdExpansionSharedPtr
Geometry is curved or has non-constant factors.

Member Data Documentation

ModuleKey Nektar::Utilities::ProcessScalGrad::className
static
Initial value:
=
ModuleKey(eProcessModule, "scalargrad"),
ProcessScalGrad::create, "Computes scalar gradient field.")

Definition at line 57 of file ProcessScalGrad.h.