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...
 
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 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.
virtual std::string Nektar::Utilities::ProcessScalGrad::GetModuleName ( )
inlinevirtual

Implements Nektar::Utilities::Module.

Definition at line 65 of file ProcessScalGrad.h.

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