Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
Nektar::FieldUtils::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::FieldUtils::ProcessScalGrad:
Inheritance graph
[legend]
Collaboration diagram for Nektar::FieldUtils::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...
 
virtual std::string GetModuleName ()
 
- Public Member Functions inherited from Nektar::FieldUtils::ProcessModule
 ProcessModule ()
 
 ProcessModule (FieldSharedPtr p_f)
 
- Public Member Functions inherited from Nektar::FieldUtils::Module
FIELD_UTILS_EXPORT Module (FieldSharedPtr p_f)
 
FIELD_UTILS_EXPORT void RegisterConfig (string key, string value)
 Register a configuration option with a module. More...
 
FIELD_UTILS_EXPORT void PrintConfig ()
 Print out all configuration options for a module. More...
 
FIELD_UTILS_EXPORT void SetDefaults ()
 Sets default configuration options for those which have not been set. More...
 
FIELD_UTILS_EXPORT bool GetRequireEquiSpaced (void)
 
FIELD_UTILS_EXPORT void SetRequireEquiSpaced (bool pVal)
 
FIELD_UTILS_EXPORT void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 

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::FieldUtils::Module
 Module ()
 
- Protected Attributes inherited from Nektar::FieldUtils::Module
FieldSharedPtr m_f
 Field object. More...
 
map< string, ConfigOptionm_config
 List of configuration values. More...
 
bool m_requireEquiSpaced
 

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::FieldUtils::ProcessScalGrad::ProcessScalGrad ( FieldSharedPtr  f)

Definition at line 57 of file ProcessScalGrad.cpp.

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

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

Definition at line 65 of file ProcessScalGrad.cpp.

66 {
67 }

Member Function Documentation

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

Creates an instance of this class.

Definition at line 54 of file ProcessScalGrad.h.

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

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

Implements Nektar::FieldUtils::Module.

Definition at line 66 of file ProcessScalGrad.h.

67  {
68  return "ProcessScalGrad";
69  }
void Nektar::FieldUtils::ProcessScalGrad::Process ( po::variables_map &  vm)
virtual

Write mesh to output file.

Implements Nektar::FieldUtils::Module.

Definition at line 69 of file ProcessScalGrad.cpp.

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

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

Member Data Documentation

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

Definition at line 58 of file ProcessScalGrad.h.