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 // 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: Operator top class definition
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef NEKTAR_LIBRARY_COLLECTIONS_OPERATOR_H
37 #define NEKTAR_LIBRARY_COLLECTIONS_OPERATOR_H
38 
43 
44 #define OPERATOR_CREATE(cname) \
45  static OperatorKey m_type; \
46  static OperatorKey m_typeArr[]; \
47  friend class MemoryManager<cname>; \
48  static OperatorSharedPtr create( \
49  std::vector<StdRegions::StdExpansionSharedPtr> pCollExp,\
50  boost::shared_ptr<CoalescedGeomData> GeomData) \
51  { \
52  return MemoryManager<cname> \
53  ::AllocateSharedPtr(pCollExp, GeomData); \
54  }
55 
56 namespace Nektar
57 {
58 namespace Collections
59 {
60 
61 class CoalescedGeomData;
62 typedef boost::shared_ptr<CoalescedGeomData> CoalescedGeomDataSharedPtr;
63 
65 {
71 };
72 
73 const char* const OperatorTypeMap[] =
74 {
75  "BwdTrans",
76  "IProductWRTBase",
77  "IProductWRTDerivBase",
78  "PhysDeriv"
79 };
80 
82 {
89 };
90 
91 const char* const ImplementationTypeMap[] =
92 {
93  "NoImplementationType",
94  "NoCollection",
95  "IterPerExp",
96  "StdMat",
97  "SumFac"
98 };
99 
100 typedef bool ExpansionIsNodal;
101 
102 typedef std::map<OperatorType, ImplementationType> OperatorImpMap;
103 
104 /// simple Operator Implementation Map generator
105 OperatorImpMap SetFixedImpType(ImplementationType defaultType);
106 
107 /// Base class for operators on a collection of elements
108 class Operator
109 {
110  public:
111  /// Constructor
113  std::vector<StdRegions::StdExpansionSharedPtr> pCollExp,
114  boost::shared_ptr<CoalescedGeomData> GeomData)
115  : m_stdExp(pCollExp[0]->GetStdExp()),
116  m_numElmt(pCollExp.size()),
117  m_wspSize(0)
118  {
119  }
120 
121  /// Perform operation
122  COLLECTIONS_EXPORT virtual void operator()(
123  const Array<OneD, const NekDouble> &input,
124  Array<OneD, NekDouble> &output0,
125  Array<OneD, NekDouble> &output1,
126  Array<OneD, NekDouble> &output2,
128  = NullNekDouble1DArray) = 0;
129 
130  COLLECTIONS_EXPORT virtual void operator()(
131  int dir,
132  const Array<OneD, const NekDouble> &input,
133  Array<OneD, NekDouble> &output,
135  = NullNekDouble1DArray) = 0;
136 
137  COLLECTIONS_EXPORT virtual ~Operator();
138 
139  /// Get the size of the required workspace
141  {
142  return m_wspSize;
143  }
144 
145  protected:
147  unsigned int m_numElmt;
148  unsigned int m_wspSize;
149 };
150 
151 /// Shared pointer to an Operator object
152 typedef boost::shared_ptr<Operator> OperatorSharedPtr;
153 
154 /// Key for describing an Operator
155 typedef boost::tuple<
157  OperatorType,
159  ExpansionIsNodal> OperatorKey;
160 
161 /// Less-than comparison operator for OperatorKey objects
162 bool operator< (OperatorKey const &p1, OperatorKey const &p2);
163 
164 /// Stream output operator for OperatorKey objects
165 std::ostream &operator<<(std::ostream &os, OperatorKey const &p);
166 
167 /// Operator factory definition
169  OperatorKey,
170  Operator,
171  std::vector<StdRegions::StdExpansionSharedPtr>,
172  CoalescedGeomDataSharedPtr> OperatorFactory;
173 
174 /// Returns the singleton Operator factory object
175 OperatorFactory& GetOperatorFactory();
176 
177 }
178 }
179 #endif
Operator(std::vector< StdRegions::StdExpansionSharedPtr > pCollExp, boost::shared_ptr< CoalescedGeomData > GeomData)
Constructor.
Definition: Operator.h:112
static Array< OneD, NekDouble > NullNekDouble1DArray
const char *const ImplementationTypeMap[]
Definition: Operator.h:91
boost::tuple< LibUtilities::ShapeType, OperatorType, ImplementationType, ExpansionIsNodal > OperatorKey
Key for describing an Operator.
Definition: Operator.h:159
bool operator<(OperatorKey const &p1, OperatorKey const &p2)
Less-than comparison operator for OperatorKey objects.
Definition: Operator.cpp:46
StdRegions::StdExpansionSharedPtr GetStdExp(StdRegions::StdExpansionSharedPtr exp)
Definition: ExpList.cpp:3081
Base class for operators on a collection of elements.
Definition: Operator.h:108
const char *const OperatorTypeMap[]
Definition: Operator.h:73
int GetWspSize()
Get the size of the required workspace.
Definition: Operator.h:140
std::ostream & operator<<(std::ostream &os, OperatorKey const &p)
Stream output operator for OperatorKey objects.
Definition: Operator.cpp:89
std::map< OperatorType, ImplementationType > OperatorImpMap
Definition: Operator.h:102
boost::shared_ptr< Operator > OperatorSharedPtr
Shared pointer to an Operator object.
Definition: Operator.h:152
OperatorFactory & GetOperatorFactory()
Returns the singleton Operator factory object.
Definition: Operator.cpp:110
StdRegions::StdExpansionSharedPtr m_stdExp
Definition: Operator.h:146
#define COLLECTIONS_EXPORT
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.
Nektar::LibUtilities::NekFactory< OperatorKey, Operator, std::vector< StdRegions::StdExpansionSharedPtr >, CoalescedGeomDataSharedPtr > OperatorFactory
Operator factory definition.
Definition: Operator.h:172
boost::shared_ptr< CoalescedGeomData > CoalescedGeomDataSharedPtr
virtual COLLECTIONS_EXPORT ~Operator()
Definition: Operator.cpp:102
OperatorImpMap SetFixedImpType(ImplementationType defaultType)
simple Operator Implementation Map generator
Definition: Operator.cpp:122
boost::shared_ptr< StdExpansion > StdExpansionSharedPtr
Provides a generic Factory class.
Definition: NekFactory.hpp:116