Nektar++
Operator.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: Operator.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: Operator top class definition
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #ifndef NEKTAR_LIBRARY_COLLECTIONS_OPERATOR_H
36 #define NEKTAR_LIBRARY_COLLECTIONS_OPERATOR_H
37 
38 #include <boost/core/ignore_unused.hpp>
39 
44 
45 #define OPERATOR_CREATE(cname) \
46  static OperatorKey m_type; \
47  static OperatorKey m_typeArr[]; \
48  friend class MemoryManager<cname>; \
49  static OperatorSharedPtr create( \
50  std::vector<StdRegions::StdExpansionSharedPtr> pCollExp, \
51  std::shared_ptr<CoalescedGeomData> GeomData, \
52  StdRegions::FactorMap factors) \
53  { \
54  return MemoryManager<cname>::AllocateSharedPtr(pCollExp, GeomData, \
55  factors); \
56  }
57 
58 namespace Nektar
59 {
60 namespace Collections
61 {
62 
63 class CoalescedGeomData;
64 typedef std::shared_ptr<CoalescedGeomData> CoalescedGeomDataSharedPtr;
65 
67 {
74 };
75 
76 const char *const OperatorTypeMap[] = {"BwdTrans", "Helmholtz",
77  "IProductWRTBase",
78  "IProductWRTDerivBase", "PhysDeriv"};
79 
80 const char *const OperatorTypeMap1[] = {"BwdTrans", "Helmholtz", "IPWrtBase",
81  "IPWrtDBase", "PhysDeriv "};
82 
84 {
92 };
93 
94 const char *const ImplementationTypeMap[] = {"NoImplementationType",
95  "NoCollection",
96  "IterPerExp",
97  "StdMat",
98  "SumFac",
99  "MatrixFree"};
100 
101 const char *const ImplementationTypeMap1[] = {
102  "NoImplementationType",
103  "IterLocExp", // formerly "NoCollection"
104  "IterStdExp", // formerly "IterPerExp"
105  "StdMat ",
106  "SumFac ",
107  "MatFree " // formerly "MatrixFree"
108 };
109 
110 typedef bool ExpansionIsNodal;
111 
112 typedef std::map<OperatorType, ImplementationType> OperatorImpMap;
113 
114 /// simple Operator Implementation Map generator
116 
117 /// Base class for operators on a collection of elements
118 class Operator
119 {
120 public:
121  /// Constructor
122  Operator(std::vector<StdRegions::StdExpansionSharedPtr> pCollExp,
123  std::shared_ptr<CoalescedGeomData> GeomData,
124  StdRegions::FactorMap factors);
125 
126  /// Perform operation
127 
129  const Array<OneD, const NekDouble> &input,
131  Array<OneD, NekDouble> &output2,
133 
135  int dir, const Array<OneD, const NekDouble> &input,
136  Array<OneD, NekDouble> &output,
138 
139  COLLECTIONS_EXPORT virtual ~Operator();
140 
141  /// Check the validity of the supplied factor map
143  int coll_phys_offset) = 0;
144 
145  /// Get the size of the required workspace
146  unsigned int GetWspSize()
147  {
148  return m_wspSize;
149  }
150 
151  /// Get expansion pointer
152  unsigned int GetNumElmt()
153  {
154  return m_numElmt;
155  }
156 
157  /// Get expansion pointer
159  {
160  return m_stdExp;
161  }
162 
163 protected:
166  unsigned int m_numElmt;
167  unsigned int m_nqe;
168  unsigned int m_wspSize;
169 };
170 
171 /// Shared pointer to an Operator object
172 typedef std::shared_ptr<Operator> OperatorSharedPtr;
173 
174 /// Key for describing an Operator
178 
179 /// Less-than comparison operator for OperatorKey objects
180 bool operator<(OperatorKey const &p1, OperatorKey const &p2);
181 
182 /// Stream output operator for OperatorKey objects
183 std::ostream &operator<<(std::ostream &os, OperatorKey const &p);
184 
185 /// Operator factory definition
187  OperatorKey, Operator, std::vector<StdRegions::StdExpansionSharedPtr>,
190 
191 /// Returns the singleton Operator factory object
193 
194 } // namespace Collections
195 } // namespace Nektar
196 #endif
#define COLLECTIONS_EXPORT
Base class for operators on a collection of elements.
Definition: Operator.h:119
unsigned int GetNumElmt()
Get expansion pointer.
Definition: Operator.h:152
virtual COLLECTIONS_EXPORT void operator()(int dir, const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &wsp=NullNekDouble1DArray)=0
virtual COLLECTIONS_EXPORT void operator()(const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output0, Array< OneD, NekDouble > &output1, Array< OneD, NekDouble > &output2, Array< OneD, NekDouble > &wsp=NullNekDouble1DArray)=0
Perform operation.
virtual COLLECTIONS_EXPORT void CheckFactors(StdRegions::FactorMap factors, int coll_phys_offset)=0
Check the validity of the supplied factor map.
StdRegions::StdExpansionSharedPtr m_stdExp
Definition: Operator.h:165
unsigned int GetWspSize()
Get the size of the required workspace.
Definition: Operator.h:146
virtual COLLECTIONS_EXPORT ~Operator()
Definition: Operator.cpp:110
StdRegions::StdExpansionSharedPtr GetExpSharedPtr()
Get expansion pointer.
Definition: Operator.h:158
Operator(std::vector< StdRegions::StdExpansionSharedPtr > pCollExp, std::shared_ptr< CoalescedGeomData > GeomData, StdRegions::FactorMap factors)
Constructor.
Definition: Operator.cpp:43
Provides a generic Factory class.
Definition: NekFactory.hpp:105
bool operator<(OperatorKey const &p1, OperatorKey const &p2)
Less-than comparison operator for OperatorKey objects.
Definition: Operator.cpp:56
std::map< OperatorType, ImplementationType > OperatorImpMap
Definition: Operator.h:112
const char *const ImplementationTypeMap[]
Definition: Operator.h:94
std::shared_ptr< Operator > OperatorSharedPtr
Shared pointer to an Operator object.
Definition: Operator.h:172
const char *const ImplementationTypeMap1[]
Definition: Operator.h:101
std::ostream & operator<<(std::ostream &os, OperatorKey const &p)
Stream output operator for OperatorKey objects.
Definition: Operator.cpp:98
const char *const OperatorTypeMap[]
Definition: Operator.h:76
std::tuple< LibUtilities::ShapeType, OperatorType, ImplementationType, ExpansionIsNodal > OperatorKey
Key for describing an Operator.
Definition: Operator.h:177
std::shared_ptr< CoalescedGeomData > CoalescedGeomDataSharedPtr
OperatorFactory & GetOperatorFactory()
Returns the singleton Operator factory object.
Definition: Operator.cpp:117
OperatorImpMap SetFixedImpType(ImplementationType defaultType)
simple Operator Implementation Map generator
Definition: Operator.cpp:124
Nektar::LibUtilities::NekFactory< OperatorKey, Operator, std::vector< StdRegions::StdExpansionSharedPtr >, CoalescedGeomDataSharedPtr, StdRegions::FactorMap > OperatorFactory
Operator factory definition.
Definition: Operator.h:189
const char *const OperatorTypeMap1[]
Definition: Operator.h:80
std::shared_ptr< StdExpansion > StdExpansionSharedPtr
ConstFactorMap FactorMap
Definition: StdRegions.hpp:403
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
static Array< OneD, NekDouble > NullNekDouble1DArray