Nektar++
GlobalOptimizationParameters.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File GlobalOptimizationParameters.h
4 //
5 // For more information, please see: http://www.nektar.info
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // Permission is hereby granted, free of charge, to any person obtaining a
14 // copy of this software and associated documentation files (the "Software"),
15 // to deal in the Software without restriction, including without limitation
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 // and/or sell copies of the Software, and to permit persons to whom the
18 // Software is furnished to do so, subject to the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be included
21 // in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 // DEALINGS IN THE SOFTWARE.
30 //
31 // Description: Header file of global optimisation parameters class
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #ifndef NEKTAR_LIB_MULTIREGIONS_GLOBALOPTIMIZATIONPARAMETERS_H
36 #define NEKTAR_LIB_MULTIREGIONS_GLOBALOPTIMIZATIONPARAMETERS_H
41 
42 namespace Nektar
43 {
44  namespace NekOptimize
45  {
46  // enumeration of all operations that are optimisable
48  {
60  };
61 
62  const char* const OptimizationOperationTypeMap[] =
63  {
64  "BwdTrans",
65  "IProductWRTBase",
66  "IProductWRTDerivBase",
67  "MassMatrixOp",
68  "LaplacianMatrixOp",
69  "LaplacianMatrixIJOp",
70  "WeakDerivMatrixOp",
71  "HelmholtzMatrixOp",
72  "HybridDGHelmBndLamMatrixOp",
73  "LinearAdvectionReactionOp"
74  };
75 
76  /// Processes global optimisation parameters from a session.
78  {
79  public:
80  /// Default constructor requires nel be given
81  MULTI_REGIONS_EXPORT GlobalOptParam(const int nel);
82 
83  /// Read optimisation parameters from a given file.
84  MULTI_REGIONS_EXPORT GlobalOptParam(const LibUtilities::SessionReaderSharedPtr& pSession, const int dim, const Array<OneD, const int> &NumShapeElements);
85 
86  /// For a given matrix type, determines if the operation should
87  /// be done globally.
88  // inline
90 
91 
92  /// For a given matrix type, determines if the operation should be
93  /// done with a block matrix
94  // inline
95  inline const Array<OneD, const bool> &DoBlockMatOp(const StdRegions::MatrixType i) const;
96 
98  inline const Array<OneD, const int> &GetShapeNumElements() const;
99 
100  private:
101  /// Default constructor should not be called
103 
104  /// Flags indicating if different matrices should be evaluated
105  /// globally.
107 
108  /// Array of Flags of first dimension of the number of
109  /// shapes within the space dimension, indicating if
110  /// different matrices should be evaluated using a block
111  /// matrix
113 
114  /// A list ExpansionTypes indicating the order in which
115  /// shapes are listed to call the appropriate key for the
116  /// block matrices.
118 
119  /// A list of number of elements contained within each shape type
121  };
122 
123  /// Pointer to a GlobalOptParam object.
124  typedef std::shared_ptr<GlobalOptParam> GlobalOptParamSharedPtr;
125 
126  /// Pointer to an empty GlobalOptParam object.
127  static GlobalOptParamSharedPtr NullGlobalOptParamSharedPtr;
128 
129 
130  /**
131  * Determines the elemental optimisation type enum, given the
132  * MatrixType and returns the corresponding entry in the table.
133  * @param i Type of matrix.
134  * @returns True if this type of matrix should be evaluated globally.
135  */
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  }
184 
185  /**
186  * Determines the elemental optimisation type enum, given the
187  * MatrixType and returns the corresponding entry in the table.
188  * @param i Type of matrix.
189  * @returns True if this type of matrix should be evaluated in block
190  * form.
191  */
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  }
241 
243  {
244  return m_shapeNumElements;
245  }
246 
248  {
249  return m_shapeList;
250  }
251 
252 
253 
254  } // end of namespace
255 } // end of namespace
256 
257 #endif //NEKTAR_LIB_STDREGIONS_OPTIMIZATIONPARAMETERSACCESS_H
258 
259 
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.
std::shared_ptr< GlobalOptParam > GlobalOptParamSharedPtr
Pointer to a GlobalOptParam object.
const Array< OneD, const LibUtilities::ShapeType > & GetShapeList() const
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.
#define MULTI_REGIONS_EXPORT
Array< OneD, bool > m_doGlobalMatOp
Flags indicating if different matrices should be evaluated globally.
const Array< OneD, const int > & GetShapeNumElements() const
Processes global optimisation parameters from a session.
bool DoGlobalMatOp(const StdRegions::MatrixType i) const
For a given matrix type, determines if the operation should be done globally.
static GlobalOptParamSharedPtr NullGlobalOptParamSharedPtr
Pointer to an empty GlobalOptParam object.
Array< OneD, LibUtilities::ShapeType > m_shapeList
A list ExpansionTypes indicating the order in which shapes are listed to call the appropriate key for...
GlobalOptParam()
Default constructor should not be called.
std::shared_ptr< SessionReader > SessionReaderSharedPtr