Nektar++
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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> \
55  ::AllocateSharedPtr(pCollExp, GeomData, 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[] =
77 {
78  "BwdTrans",
79  "Helmholtz",
80  "IProductWRTBase",
81  "IProductWRTDerivBase",
82  "PhysDeriv"
83 };
84 
86 {
94 };
95 
96 const char* const ImplementationTypeMap[] =
97 {
98  "NoImplementationType",
99  "NoCollection",
100  "IterPerExp",
101  "StdMat",
102  "SumFac",
103  "MatrixFree"
104 };
105 
106 typedef bool ExpansionIsNodal;
107 
108 typedef std::map<OperatorType, ImplementationType> OperatorImpMap;
109 
110 /// simple Operator Implementation Map generator
112 
113 /// Base class for operators on a collection of elements
114 class Operator
115 {
116  public:
117  /// Constructor
118  Operator(
119  std::vector<StdRegions::StdExpansionSharedPtr> pCollExp,
120  std::shared_ptr<CoalescedGeomData> GeomData,
121  StdRegions::FactorMap factors);
122 
123  /// Perform operation
124 
126  const Array<OneD, const NekDouble> &input,
127  Array<OneD, NekDouble> &output0,
128  Array<OneD, NekDouble> &output1,
129  Array<OneD, NekDouble> &output2,
131  = NullNekDouble1DArray) = 0;
132 
134  int dir,
135  const Array<OneD, const NekDouble> &input,
136  Array<OneD, NekDouble> &output,
138  = NullNekDouble1DArray) = 0;
139 
140  COLLECTIONS_EXPORT virtual ~Operator();
141 
142  /// Check the validity of the supplied factor map
144  StdRegions::FactorMap factors,
145  int coll_phys_offset) = 0;
146 
147  /// Get the size of the required workspace
148  unsigned int GetWspSize()
149  {
150  return m_wspSize;
151  }
152 
153  /// Get expansion pointer
154  unsigned int GetNumElmt()
155  {
156  return m_numElmt;
157  }
158 
159  /// Get expansion pointer
161  {
162  return m_stdExp;
163  }
164 
165  protected:
168  unsigned int m_numElmt;
169  unsigned int m_nqe;
170  unsigned int m_wspSize;
171  };
172 
173 /// Shared pointer to an Operator object
174 typedef std::shared_ptr<Operator> OperatorSharedPtr;
175 
176 /// Key for describing an Operator
177 typedef std::tuple<
179  OperatorType,
182 
183 /// Less-than comparison operator for OperatorKey objects
184 bool operator< (OperatorKey const &p1, OperatorKey const &p2);
185 
186 /// Stream output operator for OperatorKey objects
187 std::ostream &operator<<(std::ostream &os, OperatorKey const &p);
188 
189 /// Operator factory definition
191  OperatorKey,
192  Operator,
193  std::vector<StdRegions::StdExpansionSharedPtr>,
196 
197 /// Returns the singleton Operator factory object
199 
200 }
201 }
202 #endif
#define COLLECTIONS_EXPORT
Base class for operators on a collection of elements.
Definition: Operator.h:115
unsigned int GetNumElmt()
Get expansion pointer.
Definition: Operator.h:154
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:167
unsigned int GetWspSize()
Get the size of the required workspace.
Definition: Operator.h:148
virtual COLLECTIONS_EXPORT ~Operator()
Definition: Operator.cpp:113
StdRegions::StdExpansionSharedPtr GetExpSharedPtr()
Get expansion pointer.
Definition: Operator.h:160
Operator(std::vector< StdRegions::StdExpansionSharedPtr > pCollExp, std::shared_ptr< CoalescedGeomData > GeomData, StdRegions::FactorMap factors)
Constructor.
Definition: Operator.cpp:41
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:57
std::map< OperatorType, ImplementationType > OperatorImpMap
Definition: Operator.h:108
const char *const ImplementationTypeMap[]
Definition: Operator.h:96
std::shared_ptr< Operator > OperatorSharedPtr
Shared pointer to an Operator object.
Definition: Operator.h:174
std::ostream & operator<<(std::ostream &os, OperatorKey const &p)
Stream output operator for OperatorKey objects.
Definition: Operator.cpp:100
const char *const OperatorTypeMap[]
Definition: Operator.h:76
std::tuple< LibUtilities::ShapeType, OperatorType, ImplementationType, ExpansionIsNodal > OperatorKey
Key for describing an Operator.
Definition: Operator.h:181
std::shared_ptr< CoalescedGeomData > CoalescedGeomDataSharedPtr
OperatorFactory & GetOperatorFactory()
Returns the singleton Operator factory object.
Definition: Operator.cpp:121
OperatorImpMap SetFixedImpType(ImplementationType defaultType)
simple Operator Implementation Map generator
Definition: Operator.cpp:130
Nektar::LibUtilities::NekFactory< OperatorKey, Operator, std::vector< StdRegions::StdExpansionSharedPtr >, CoalescedGeomDataSharedPtr, StdRegions::FactorMap > OperatorFactory
Operator factory definition.
Definition: Operator.h:195
std::shared_ptr< StdExpansion > StdExpansionSharedPtr
ConstFactorMap FactorMap
Definition: StdRegions.hpp:318
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
static Array< OneD, NekDouble > NullNekDouble1DArray