Nektar++
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Nektar::NekOptimize::GlobalOptParam Class Reference

Processes global optimisation parameters from a session. More...

#include <GlobalOptimizationParameters.h>

Public Member Functions

 GlobalOptParam (const int nel)
 Default constructor requires nel be given. More...
 
 GlobalOptParam (const LibUtilities::SessionReaderSharedPtr &pSession, const int dim, const Array< OneD, const int > &NumShapeElements)
 Read optimisation parameters from a given file. More...
 
bool DoGlobalMatOp (const StdRegions::MatrixType i) const
 For a given matrix type, determines if the operation should be done globally. More...
 
const Array< OneD, const bool > & DoBlockMatOp (const StdRegions::MatrixType i) const
 For a given matrix type, determines if the operation should be done with a block matrix. More...
 
const Array< OneD, const LibUtilities::ShapeType > & GetShapeList () const
 
const Array< OneD, const int > & GetShapeNumElements () const
 

Private Member Functions

 GlobalOptParam ()
 Default constructor should not be called. More...
 

Private Attributes

Array< OneD, bool > m_doGlobalMatOp
 Flags indicating if different matrices should be evaluated globally. More...
 
Array< OneD, Array< OneD, bool > > m_doBlockMatOp
 Array of Flags of first dimension of the number of shapes within the space dimension, indicating if different matrices should be evaluated using a block matrix. More...
 
Array< OneD, LibUtilities::ShapeTypem_shapeList
 A list ExpansionTypes indicating the order in which shapes are listed to call the appropriate key for the block matrices. More...
 
Array< OneD, const int > m_shapeNumElements
 A list of number of elements contained within each shape type. More...
 

Detailed Description

Processes global optimisation parameters from a session.

Global optimisation parameters determines how the various matrices in the spectral/hp element formulation are evaluated. For details see the page on optimisation Optimisation.

Definition at line 77 of file GlobalOptimizationParameters.h.

Constructor & Destructor Documentation

◆ GlobalOptParam() [1/3]

Nektar::NekOptimize::GlobalOptParam::GlobalOptParam ( const int  nel)

Default constructor requires nel be given.

No global optimisation parameters present.

Definition at line 56 of file GlobalOptimizationParameters.cpp.

References m_doBlockMatOp, and Nektar::NekOptimize::SIZE_OptimizeOperationType.

56  :
59  m_shapeNumElements(1,nel)
60  {
61  Array<OneD, bool> set_false(1,false);
62  m_doBlockMatOp = Array<OneD, Array<OneD, bool > >
63  (SIZE_OptimizeOperationType,set_false);
64  }
Array< OneD, const int > m_shapeNumElements
A list of number of elements contained within each shape type.
Array< OneD, Array< OneD, bool > > m_doBlockMatOp
Array of Flags of first dimension of the number of shapes within the space dimension, indicating if different matrices should be evaluated using a block matrix.
Array< OneD, bool > m_doGlobalMatOp
Flags indicating if different matrices should be evaluated globally.
Array< OneD, LibUtilities::ShapeType > m_shapeList
A list ExpansionTypes indicating the order in which shapes are listed to call the appropriate key for...

◆ GlobalOptParam() [2/3]

Nektar::NekOptimize::GlobalOptParam::GlobalOptParam ( const LibUtilities::SessionReaderSharedPtr pSession,
const int  dim,
const Array< OneD, const int > &  NumShapeElements 
)

Read optimisation parameters from a given file.

Read global optimisation parameters from a file and set up flags.

Parameters
fileNameFile to read parameters from.

Definition at line 70 of file GlobalOptimizationParameters.cpp.

References ASSERTL0, Nektar::LibUtilities::eHexahedron, Nektar::LibUtilities::ePrism, Nektar::LibUtilities::ePyramid, Nektar::LibUtilities::eQuadrilateral, Nektar::LibUtilities::eTetrahedron, Nektar::LibUtilities::eTriangle, m_doBlockMatOp, m_doGlobalMatOp, m_shapeList, m_shapeNumElements, Nektar::NekOptimize::OptimizationOperationTypeMap, and Nektar::NekOptimize::SIZE_OptimizeOperationType.

71  :
73  {
74  int i;
75  int numShapes = 0;
76  TiXmlDocument& doc = pSession->GetDocument();
77 
78  m_shapeNumElements = NumShapeElements;
79 
80  switch (dim)
81  {
82  case 1:
83  numShapes = 1;
84  ASSERTL0(false,"Needs setting up for dimension 1");
85  break;
86  case 2:
87  numShapes = 2;
88  m_shapeList = Array<OneD, LibUtilities::ShapeType>(numShapes);
90  m_shapeList[1] = LibUtilities::eQuadrilateral;
91  break;
92  case 3:
93  numShapes = 4;
94  m_shapeList = Array<OneD, LibUtilities::ShapeType>(numShapes);
95  m_shapeList[0] = LibUtilities::eTetrahedron;
96  m_shapeList[1] = LibUtilities::ePyramid;
97  m_shapeList[2] = LibUtilities::ePrism;
98  m_shapeList[3] = LibUtilities::eHexahedron;
99  break;
100  }
101 
102  m_doBlockMatOp = Array<OneD, Array<OneD,bool> > (SIZE_OptimizeOperationType);
103  for(i = 0; i < SIZE_OptimizeOperationType; ++i)
104  {
105  m_doBlockMatOp[i] = Array<OneD, bool> (numShapes,false);
106  }
107 
108  TiXmlHandle docHandle(&doc);
109  TiXmlElement* master
110  = docHandle.FirstChildElement("NEKTAR").Element();
111  ASSERTL0(master , "Unable to find NEKTAR tag in file.");
112 
113  TiXmlElement* paramList
114  = docHandle.FirstChildElement("NEKTAR")
115  .FirstChildElement("GLOBALOPTIMIZATIONPARAMETERS")
116  .Element();
117 
118  // If no global optimisation parameters set, we're done
119  if (!paramList)
120  {
121  return;
122  }
123 
124  // Check if there is a reference an external file and if so, load it
125  TiXmlElement* source
126  = paramList->FirstChildElement("SOURCE");
127  if (source)
128  {
129  std::string sourceFile = source->Attribute("FILE");
130  TiXmlDocument docSource;
131  bool loadOkay = docSource.LoadFile(sourceFile);
132  ASSERTL0(loadOkay, (std::string("Unable to load file: ") +
133  sourceFile).c_str());
134  TiXmlHandle docSourceHandle(&docSource);
135  master = docHandle.FirstChildElement("NEKTAR").Element();
136  ASSERTL0(master , "Unable to find NEKTAR tag in file.");
137 
138  paramList = docHandle.FirstChildElement("NEKTAR")
139  .FirstChildElement("GLOBALOPTIMIZATIONPARAMETERS")
140  .Element();
141  ASSERTL0(paramList, std::string("Specified source file '"
142  + sourceFile + "' is missing an "
143  "GLOBALOPTIMIZATIONPARAMETERS tag.").c_str());
144  }
145 
146  int n;
147  for(n = 0; n < SIZE_OptimizeOperationType; n++)
148  {
149  TiXmlElement* operationType = paramList->FirstChildElement(
151 
152  if(operationType)
153  {
154  TiXmlElement* arrayElement = operationType
155  ->FirstChildElement("DO_GLOBAL_MAT_OP");
156  if(arrayElement)
157  {
158  int value;
159  int err;
160 
161  err = arrayElement->QueryIntAttribute("VALUE", &value);
162  ASSERTL0(err == TIXML_SUCCESS,(
163  std::string("Unable to read DO_GLOBAL_MAT_OP "
164  "attribute VALUE for ")
165  + std::string(OptimizationOperationTypeMap[n])
166  + std::string(".")
167  ));
168 
169  m_doGlobalMatOp[n] = (bool) value;
170  }
171 
172  arrayElement
173  = operationType->FirstChildElement("DO_BLOCK_MAT_OP");
174  if(arrayElement)
175  {
176  int value;
177  int err;
178 
179  switch (dim)
180  {
181  case 1:
182  break;
183  case 2:
184  err = arrayElement->QueryIntAttribute("TRI", &value);
185  ASSERTL0(err == TIXML_SUCCESS, (
186  std::string("Unable to read DO_BLOCK_MAT_OP "
187  "attribute TRI for ")
188  + std::string(OptimizationOperationTypeMap[n])
189  + std::string(".")));
190 
191  m_doBlockMatOp[n][0] = (bool) value;
192 
193  err = arrayElement->QueryIntAttribute("QUAD", &value);
194  ASSERTL0(err == TIXML_SUCCESS, (
195  std::string("Unable to read DO_BLOCK_MAT_OP "
196  "attribute QUAD for ")
197  + std::string(OptimizationOperationTypeMap[n])
198  + std::string(".")));
199 
200  m_doBlockMatOp[n][1] = (bool) value;
201  break;
202  case 3:
203  err = arrayElement->QueryIntAttribute("TET", &value);
204  ASSERTL0(err == TIXML_SUCCESS, (
205  std::string("Unable to read DO_BLOCK_MAT_OP "
206  "attribute TET for ")
207  + std::string(OptimizationOperationTypeMap[n])
208  + std::string(".")));
209 
210  m_doBlockMatOp[n][0] = (bool) value;
211 
212  err = arrayElement->QueryIntAttribute("PYR", &value);
213  ASSERTL0(err == TIXML_SUCCESS, (
214  std::string("Unable to read DO_BLOCK_MAT_OP "
215  "attribute PYR for ")
216  + std::string(OptimizationOperationTypeMap[n])
217  + std::string(".")));
218 
219  m_doBlockMatOp[n][1] = (bool) value;
220 
221  err = arrayElement->QueryIntAttribute("PRISM", &value);
222  ASSERTL0(err == TIXML_SUCCESS, (
223  std::string("Unable to read DO_BLOCK_MAT_OP "
224  "attribute PRISM for ")
225  + std::string(OptimizationOperationTypeMap[n])
226  + std::string(".")));
227 
228  m_doBlockMatOp[n][2] = (bool) value;
229 
230  err = arrayElement->QueryIntAttribute("HEX", &value);
231  ASSERTL0(err == TIXML_SUCCESS, (
232  std::string("Unable to read DO_BLOCK_MAT_OP "
233  "attribute HEX for ")
234  + std::string(OptimizationOperationTypeMap[n])
235  + std::string(".")));
236 
237  m_doBlockMatOp[n][3] = (bool) value;
238  break;
239 
240  break;
241 
242  }
243  }
244  }
245  }
246  }
const char *const OptimizationOperationTypeMap[]
Array< OneD, const int > m_shapeNumElements
A list of number of elements contained within each shape type.
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
Array< OneD, Array< OneD, bool > > m_doBlockMatOp
Array of Flags of first dimension of the number of shapes within the space dimension, indicating if different matrices should be evaluated using a block matrix.
Array< OneD, bool > m_doGlobalMatOp
Flags indicating if different matrices should be evaluated globally.
Array< OneD, LibUtilities::ShapeType > m_shapeList
A list ExpansionTypes indicating the order in which shapes are listed to call the appropriate key for...

◆ GlobalOptParam() [3/3]

Nektar::NekOptimize::GlobalOptParam::GlobalOptParam ( )
inlineprivate

Default constructor should not be called.

Definition at line 102 of file GlobalOptimizationParameters.h.

102 {};

Member Function Documentation

◆ DoBlockMatOp()

const Array< OneD, const bool > & Nektar::NekOptimize::GlobalOptParam::DoBlockMatOp ( const StdRegions::MatrixType  i) const
inline

For a given matrix type, determines if the operation should be done with a block matrix.

Determines the elemental optimisation type enum, given the MatrixType and returns the corresponding entry in the table.

Parameters
iType of matrix.
Returns
True if this type of matrix should be evaluated in block form.

Definition at line 192 of file GlobalOptimizationParameters.h.

References ASSERTL0, Nektar::NekOptimize::eBwdTrans, Nektar::StdRegions::eBwdTrans, Nektar::StdRegions::eHelmholtz, Nektar::NekOptimize::eHelmholtzMatrixOp, Nektar::StdRegions::eHybridDGHelmBndLam, Nektar::NekOptimize::eHybridDGHelmBndLamMatrixOp, Nektar::NekOptimize::eIProductWRTBase, Nektar::StdRegions::eIProductWRTBase, Nektar::StdRegions::eLaplacian, Nektar::NekOptimize::eLaplacianMatrixOp, Nektar::StdRegions::eLinearAdvectionReaction, Nektar::NekOptimize::eLinearAdvectionReactionOp, Nektar::StdRegions::eMass, Nektar::NekOptimize::eMassMatrixOp, and m_doBlockMatOp.

193  {
195  switch(i)
196  {
198  {
199  type = eBwdTrans;
200  }
201  break;
203  {
204  type = eIProductWRTBase;
205  }
206  break;
207  case StdRegions::eMass:
208  {
209  type = eMassMatrixOp;
210  }
211  break;
213  {
214  type = eHelmholtzMatrixOp;
215  }
216  break;
218  {
219  type = eLaplacianMatrixOp;
220  }
221  break;
223  {
225  }
226  break;
228  {
230  }
231  break;
232  default:
233  {
234  ASSERTL0(false,"Optimisation suite not set up for this type"
235  " of matrix");
236  }
237  }
238 
239  return m_doBlockMatOp[type];
240  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
Array< OneD, Array< OneD, bool > > m_doBlockMatOp
Array of Flags of first dimension of the number of shapes within the space dimension, indicating if different matrices should be evaluated using a block matrix.

◆ DoGlobalMatOp()

bool Nektar::NekOptimize::GlobalOptParam::DoGlobalMatOp ( const StdRegions::MatrixType  i) const
inline

For a given matrix type, determines if the operation should be done globally.

Determines the elemental optimisation type enum, given the MatrixType and returns the corresponding entry in the table.

Parameters
iType of matrix.
Returns
True if this type of matrix should be evaluated globally.

Definition at line 136 of file GlobalOptimizationParameters.h.

References ASSERTL0, Nektar::NekOptimize::eBwdTrans, Nektar::StdRegions::eBwdTrans, Nektar::StdRegions::eHelmholtz, Nektar::NekOptimize::eHelmholtzMatrixOp, Nektar::StdRegions::eHybridDGHelmBndLam, Nektar::NekOptimize::eHybridDGHelmBndLamMatrixOp, Nektar::NekOptimize::eIProductWRTBase, Nektar::StdRegions::eIProductWRTBase, Nektar::StdRegions::eLaplacian, Nektar::NekOptimize::eLaplacianMatrixOp, Nektar::StdRegions::eLinearAdvectionReaction, Nektar::NekOptimize::eLinearAdvectionReactionOp, Nektar::StdRegions::eMass, Nektar::NekOptimize::eMassMatrixOp, and m_doGlobalMatOp.

137  {
139  switch(i)
140  {
142  {
143  type = eBwdTrans;
144  }
145  break;
147  {
148  type = eIProductWRTBase;
149  }
150  break;
151  case StdRegions::eMass:
152  {
153  type = eMassMatrixOp;
154  }
155  break;
157  {
158  type = eHelmholtzMatrixOp;
159  }
160  break;
162  {
163  type = eLaplacianMatrixOp;
164  }
165  break;
167  {
169  }
170  break;
172  {
174  }
175  break;
176  default:
177  {
178  ASSERTL0(false,"Optimisation suite not set up for this type"
179  " of matrix");
180  }
181  }
182  return m_doGlobalMatOp[type];
183  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
Array< OneD, bool > m_doGlobalMatOp
Flags indicating if different matrices should be evaluated globally.

◆ GetShapeList()

const Array< OneD, const LibUtilities::ShapeType > & Nektar::NekOptimize::GlobalOptParam::GetShapeList ( ) const
inline

Definition at line 247 of file GlobalOptimizationParameters.h.

References m_shapeList.

248  {
249  return m_shapeList;
250  }
Array< OneD, LibUtilities::ShapeType > m_shapeList
A list ExpansionTypes indicating the order in which shapes are listed to call the appropriate key for...

◆ GetShapeNumElements()

const Array< OneD, const int > & Nektar::NekOptimize::GlobalOptParam::GetShapeNumElements ( ) const
inline

Definition at line 242 of file GlobalOptimizationParameters.h.

References m_shapeNumElements.

243  {
244  return m_shapeNumElements;
245  }
Array< OneD, const int > m_shapeNumElements
A list of number of elements contained within each shape type.

Member Data Documentation

◆ m_doBlockMatOp

Array<OneD, Array<OneD,bool> > Nektar::NekOptimize::GlobalOptParam::m_doBlockMatOp
private

Array of Flags of first dimension of the number of shapes within the space dimension, indicating if different matrices should be evaluated using a block matrix.

Definition at line 112 of file GlobalOptimizationParameters.h.

Referenced by DoBlockMatOp(), and GlobalOptParam().

◆ m_doGlobalMatOp

Array<OneD,bool> Nektar::NekOptimize::GlobalOptParam::m_doGlobalMatOp
private

Flags indicating if different matrices should be evaluated globally.

Definition at line 102 of file GlobalOptimizationParameters.h.

Referenced by DoGlobalMatOp(), and GlobalOptParam().

◆ m_shapeList

Array<OneD, LibUtilities::ShapeType> Nektar::NekOptimize::GlobalOptParam::m_shapeList
private

A list ExpansionTypes indicating the order in which shapes are listed to call the appropriate key for the block matrices.

Definition at line 117 of file GlobalOptimizationParameters.h.

Referenced by GetShapeList(), and GlobalOptParam().

◆ m_shapeNumElements

Array<OneD, const int> Nektar::NekOptimize::GlobalOptParam::m_shapeNumElements
private

A list of number of elements contained within each shape type.

Definition at line 120 of file GlobalOptimizationParameters.h.

Referenced by GetShapeNumElements(), and GlobalOptParam().