Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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>

Collaboration diagram for Nektar::NekOptimize::GlobalOptParam:
Collaboration graph
[legend]

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::ShapeType
m_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 78 of file GlobalOptimizationParameters.h.

Constructor & Destructor Documentation

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

Default constructor requires nel be given.

No global optimisation parameters present.

Definition at line 57 of file GlobalOptimizationParameters.cpp.

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

57  :
60  m_shapeNumElements(1,nel)
61  {
62  Array<OneD, bool> set_false(1,false);
63  m_doBlockMatOp = Array<OneD, Array<OneD, bool > >
64  (SIZE_OptimizeOperationType,set_false);
65  }
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...
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 71 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.

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

Default constructor should not be called.

Definition at line 103 of file GlobalOptimizationParameters.h.

103 {};

Member Function Documentation

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 193 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.

194  {
196  switch(i)
197  {
199  {
200  type = eBwdTrans;
201  }
202  break;
204  {
205  type = eIProductWRTBase;
206  }
207  break;
208  case StdRegions::eMass:
209  {
210  type = eMassMatrixOp;
211  }
212  break;
214  {
215  type = eHelmholtzMatrixOp;
216  }
217  break;
219  {
220  type = eLaplacianMatrixOp;
221  }
222  break;
224  {
226  }
227  break;
229  {
231  }
232  break;
233  default:
234  {
235  ASSERTL0(false,"Optimisation suite not set up for this type"
236  " of matrix");
237  }
238  }
239 
240  return m_doBlockMatOp[type];
241  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:188
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.
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 137 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.

138  {
140  switch(i)
141  {
143  {
144  type = eBwdTrans;
145  }
146  break;
148  {
149  type = eIProductWRTBase;
150  }
151  break;
152  case StdRegions::eMass:
153  {
154  type = eMassMatrixOp;
155  }
156  break;
158  {
159  type = eHelmholtzMatrixOp;
160  }
161  break;
163  {
164  type = eLaplacianMatrixOp;
165  }
166  break;
168  {
170  }
171  break;
173  {
175  }
176  break;
177  default:
178  {
179  ASSERTL0(false,"Optimisation suite not set up for this type"
180  " of matrix");
181  }
182  }
183  return m_doGlobalMatOp[type];
184  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:188
Array< OneD, bool > m_doGlobalMatOp
Flags indicating if different matrices should be evaluated globally.
const Array< OneD, const LibUtilities::ShapeType > & Nektar::NekOptimize::GlobalOptParam::GetShapeList ( ) const
inline

Definition at line 248 of file GlobalOptimizationParameters.h.

References m_shapeList.

249  {
250  return m_shapeList;
251  }
Array< OneD, LibUtilities::ShapeType > m_shapeList
A list ExpansionTypes indicating the order in which shapes are listed to call the appropriate key for...
const Array< OneD, const int > & Nektar::NekOptimize::GlobalOptParam::GetShapeNumElements ( ) const
inline

Definition at line 243 of file GlobalOptimizationParameters.h.

References m_shapeNumElements.

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

Member Data Documentation

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 113 of file GlobalOptimizationParameters.h.

Referenced by DoBlockMatOp(), and GlobalOptParam().

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

Flags indicating if different matrices should be evaluated globally.

Definition at line 103 of file GlobalOptimizationParameters.h.

Referenced by DoGlobalMatOp(), and GlobalOptParam().

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 118 of file GlobalOptimizationParameters.h.

Referenced by GetShapeList(), and GlobalOptParam().

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

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

Definition at line 121 of file GlobalOptimizationParameters.h.

Referenced by GetShapeNumElements(), and GlobalOptParam().