Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: Header file of global optimisation parameters class
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef NEKTAR_LIB_MULTIREGIONS_GLOBALOPTIMIZATIONPARAMETERS_H
37 #define NEKTAR_LIB_MULTIREGIONS_GLOBALOPTIMIZATIONPARAMETERS_H
42 
43 namespace Nektar
44 {
45  namespace NekOptimize
46  {
47  // enumeration of all operations that are optimisable
49  {
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  };
74 
75  /// Processes global optimisation parameters from a session.
77  {
78  public:
79  /// Default constructor requires nel be given
80  MULTI_REGIONS_EXPORT GlobalOptParam(const int nel);
81 
82  /// Read optimisation parameters from a given file.
83  MULTI_REGIONS_EXPORT GlobalOptParam(const LibUtilities::SessionReaderSharedPtr& pSession, const int dim, const Array<OneD, const int> &NumShapeElements);
84 
85  /// For a given matrix type, determines if the operation should
86  /// be done globally.
87  // inline
89 
90 
91  /// For a given matrix type, determines if the operation should be
92  /// done with a block matrix
93  // inline
94  inline const Array<OneD, const bool> &DoBlockMatOp(const StdRegions::MatrixType i) const;
95 
96  inline const Array<OneD, const LibUtilities::ShapeType> &GetShapeList() const;
97  inline const Array<OneD, const int> &GetShapeNumElements() const;
98 
99  private:
100  /// Default constructor should not be called
102 
103  /// Flags indicating if different matrices should be evaluated
104  /// globally.
105  Array<OneD,bool> m_doGlobalMatOp;
106 
107  /// Array of Flags of first dimension of the number of
108  /// shapes within the space dimension, indicating if
109  /// different matrices should be evaluated using a block
110  /// matrix
111  Array<OneD, Array<OneD,bool> > m_doBlockMatOp;
112 
113  /// A list ExpansionTypes indicating the order in which
114  /// shapes are listed to call the appropriate key for the
115  /// block matrices.
116  Array<OneD, LibUtilities::ShapeType> m_shapeList;
117 
118  /// A list of number of elements contained within each shape type
119  Array<OneD, const int> m_shapeNumElements;
120  };
121 
122  /// Pointer to a GlobalOptParam object.
123  typedef boost::shared_ptr<GlobalOptParam> GlobalOptParamSharedPtr;
124 
125  /// Pointer to an empty GlobalOptParam object.
127 
128 
129  /**
130  * Determines the elemental optimisation type enum, given the
131  * MatrixType and returns the corresponding entry in the table.
132  * @param i Type of matrix.
133  * @returns True if this type of matrix should be evaluated globally.
134  */
136  {
138  switch(i)
139  {
141  {
142  type = eBwdTrans;
143  }
144  break;
146  {
147  type = eIProductWRTBase;
148  }
149  break;
150  case StdRegions::eMass:
151  {
152  type = eMassMatrixOp;
153  }
154  break;
156  {
157  type = eHelmholtzMatrixOp;
158  }
159  break;
161  {
162  type = eLaplacianMatrixOp;
163  }
164  break;
166  {
168  }
169  break;
170  default:
171  {
172  ASSERTL0(false,"Optimisation suite not set up for this type"
173  " of matrix");
174  }
175  }
176  return m_doGlobalMatOp[type];
177  }
178 
179  /**
180  * Determines the elemental optimisation type enum, given the
181  * MatrixType and returns the corresponding entry in the table.
182  * @param i Type of matrix.
183  * @returns True if this type of matrix should be evaluated in block
184  * form.
185  */
186  inline const Array<OneD, const bool> &GlobalOptParam::DoBlockMatOp(const StdRegions::MatrixType i) const
187  {
189  switch(i)
190  {
192  {
193  type = eBwdTrans;
194  }
195  break;
197  {
198  type = eIProductWRTBase;
199  }
200  break;
201  case StdRegions::eMass:
202  {
203  type = eMassMatrixOp;
204  }
205  break;
207  {
208  type = eHelmholtzMatrixOp;
209  }
210  break;
212  {
213  type = eLaplacianMatrixOp;
214  }
215  break;
217  {
219  }
220  break;
221  default:
222  {
223  ASSERTL0(false,"Optimisation suite not set up for this type"
224  " of matrix");
225  }
226  }
227 
228  return m_doBlockMatOp[type];
229  }
230 
231  inline const Array<OneD, const int> &GlobalOptParam::GetShapeNumElements() const
232  {
233  return m_shapeNumElements;
234  }
235 
236  inline const Array<OneD, const LibUtilities::ShapeType> &GlobalOptParam::GetShapeList() const
237  {
238  return m_shapeList;
239  }
240 
241 
242 
243  } // end of namespace
244 } // end of namespace
245 
246 #endif //NEKTAR_LIB_STDREGIONS_OPTIMIZATIONPARAMETERSACCESS_H
247 
248