Nalu
Nalu: a generalized unstructured massively parallel low Mach flow code designed to support a variety of energy applications of interest (most notably Wind ECP) built on the Sierra Toolkit and Trilinos solver Tpetra/Epetra stack. The open source BSD, clause 3 license model has been chosen for the code base. See LICENSE for more information. http://NaluCFD.org
AuxFunction.h
Go to the documentation of this file.
1 /*------------------------------------------------------------------------*/
2 /* Copyright 2014 Sandia Corporation. */
3 /* This software is released under the license detailed */
4 /* in the file, LICENSE, which is located in the top-level Nalu */
5 /* directory structure */
6 /*------------------------------------------------------------------------*/
7 
8 
9 #ifndef AuxFunction_h
10 #define AuxFunction_h
11 
12 namespace sierra{
13 namespace nalu{
14 
16 {
17 public:
18  AuxFunction(const unsigned beginPos, const unsigned endPos)
19  : beginPos_(beginPos),
20  endPos_(endPos) {}
21  virtual ~AuxFunction() {}
22 
23  // coords:
24  // coordinates at each point, (x,y) for 2d, (x,y,z) for 3d
25  // time:
26  // time value
27  // spatial_dimension:
28  // 1 for 1d, 2 for 2d, 3 for 3d
29  // num_points:
30  // number of points to evaluate (e.g., length of coords should be 3*num_points for 3d)
31  // field:
32  // where to write the values
33  // field_dimension:
34  // number of field values at each point (scalar=1, vector=spatial_dimension)
35  // begin_pos:
36  // end_pos:
37  // to only write a subset of the field values, specify these values
38  //
39  // For example, the set the 2nd and 3rd components of a 3d vector, use:
40  // spatial_dimension=3
41  // field_dimension=3
42  // begin_pos=1
43  // end_pos=3
44 
45  void evaluate(
46  const double * coords,
47  const double time,
48  const unsigned spatialDimension,
49  const unsigned numPoints,
50  double * fieldPtr,
51  const unsigned fieldSize) const
52  {
53  if(beginPos_ == 0 && endPos_ == fieldSize)
54  do_evaluate(coords, time, spatialDimension, numPoints, fieldPtr, fieldSize);
55  else
56  do_evaluate(coords, time, spatialDimension, numPoints, fieldPtr, fieldSize, beginPos_, endPos_);
57  }
58  virtual void setup(const double time) {}
59 
60 private:
61 
62  // Derived classes must at_least implement this method
63  virtual void do_evaluate(
64  const double * coords,
65  const double time,
66  const unsigned spatialDimension,
67  const unsigned numPoints,
68  double * fieldPtr,
69  const unsigned fieldSize,
70  const unsigned beginPos,
71  const unsigned endPos) const = 0;
72 
73  // Derived classes may override this form for efficiency (all field values being assigned)
74  virtual void do_evaluate(
75  const double * coords,
76  const double time,
77  const unsigned spatialDimension,
78  const unsigned numPoints,
79  double * fieldPtr,
80  const unsigned fieldSize) const
81  {
82  do_evaluate(coords, time, spatialDimension, numPoints, fieldPtr, fieldSize, 0, fieldSize);
83  }
84 
85 protected:
86  const unsigned beginPos_;
87  const unsigned endPos_;
88 };
89 
90 } // namespace nalu
91 } // namespace Sierra
92 
93 #endif
Definition: ABLForcingAlgorithm.C:26
const unsigned endPos_
Definition: AuxFunction.h:87
virtual ~AuxFunction()
Definition: AuxFunction.h:21
virtual void do_evaluate(const double *coords, const double time, const unsigned spatialDimension, const unsigned numPoints, double *fieldPtr, const unsigned fieldSize) const
Definition: AuxFunction.h:74
virtual void setup(const double time)
Definition: AuxFunction.h:58
const unsigned beginPos_
Definition: AuxFunction.h:86
void evaluate(const double *coords, const double time, const unsigned spatialDimension, const unsigned numPoints, double *fieldPtr, const unsigned fieldSize) const
Definition: AuxFunction.h:45
virtual void do_evaluate(const double *coords, const double time, const unsigned spatialDimension, const unsigned numPoints, double *fieldPtr, const unsigned fieldSize, const unsigned beginPos, const unsigned endPos) const =0
AuxFunction(const unsigned beginPos, const unsigned endPos)
Definition: AuxFunction.h:18
Definition: AuxFunction.h:15