Nektar++
Collection.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: Collection.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: Collection top class definition
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #ifndef NEKTAR_LIBRARY_COLLECTIONS_COLLECTION_H
36 #define NEKTAR_LIBRARY_COLLECTIONS_COLLECTION_H
37 
38 #include <vector>
39 
44 #include <Collections/Operator.h>
46 
47 namespace Nektar {
48 namespace Collections {
49 
50 /**
51  * @brief Collection
52  */
54 {
55  public:
56 
58  std::vector<StdRegions::StdExpansionSharedPtr> pCollExp,
59  OperatorImpMap &impTypes);
60 
62  StdRegions::FactorMap factors,
63  int coll_phys_offset = 0);
64 
65  COLLECTIONS_EXPORT void Initialise(const OperatorType opType,
66  StdRegions::FactorMap factors =
68 
69  inline void ApplyOperator(
70  const OperatorType &op,
71  const Array<OneD, const NekDouble> &inarray,
72  Array<OneD, NekDouble> &output);
73 
74  inline void ApplyOperator(
75  const OperatorType &op,
76  const Array<OneD, const NekDouble> &inarray,
77  Array<OneD, NekDouble> &output0,
78  Array<OneD, NekDouble> &output1);
79 
80  inline void ApplyOperator(
81  const OperatorType &op,
82  const Array<OneD, const NekDouble> &inarray,
83  Array<OneD, NekDouble> &output0,
84  Array<OneD, NekDouble> &output1,
85  Array<OneD, NekDouble> &output2);
86 
87  inline void ApplyOperator(
88  const OperatorType &op,
89  int dir,
90  const Array<OneD, const NekDouble> &inarray,
91  Array<OneD, NekDouble> &output);
92 
93  inline bool HasOperator(const OperatorType &op);
94 
96  {
97  return m_ops[op];
98  }
99 
101  {
102  return m_geomData;
103  }
104 
105 
106  protected:
107  std::unordered_map<OperatorType, OperatorSharedPtr, EnumHash> m_ops;
109  // store details for initialisation on call rather than default initialisation
110  std::vector<StdRegions::StdExpansionSharedPtr> m_collExp;
112 };
113 
114 typedef std::vector<Collection> CollectionVector;
115 typedef std::shared_ptr<CollectionVector> CollectionVectorSharedPtr;
116 
117 /**
118  *
119  */
121  const OperatorType &op,
122  const Array<OneD, const NekDouble> &inarray,
123  Array<OneD, NekDouble> &output)
124 {
125  Array<OneD, NekDouble> wsp(m_ops[op]->GetWspSize());
126  (*m_ops[op])(inarray, output, NullNekDouble1DArray,
127  NullNekDouble1DArray, wsp);
128 }
129 
130 
131 /**
132  *
133  */
135  const OperatorType &op,
136  const Array<OneD, const NekDouble> &inarray,
137  Array<OneD, NekDouble> &output0,
138  Array<OneD, NekDouble> &output1)
139 {
140  Array<OneD, NekDouble> wsp(m_ops[op]->GetWspSize());
141  (*m_ops[op])(inarray, output0, output1, NullNekDouble1DArray, wsp);
142 }
143 
144 
145 /**
146  *
147  */
149  const OperatorType &op,
150  const Array<OneD, const NekDouble> &inarray,
151  Array<OneD, NekDouble> &output0,
152  Array<OneD, NekDouble> &output1,
153  Array<OneD, NekDouble> &output2)
154 {
155  Array<OneD, NekDouble> wsp(m_ops[op]->GetWspSize());
156  (*m_ops[op])(inarray, output0, output1, output2, wsp);
157 }
158 
159 /**
160  *
161  */
163  const OperatorType &op,
164  int dir,
165  const Array<OneD, const NekDouble> &inarray,
166  Array<OneD, NekDouble> &output)
167 {
168  Array<OneD, NekDouble> wsp(m_ops[op]->GetWspSize());
169  (*m_ops[op])(dir, inarray, output, wsp);
170 }
171 
172 inline bool Collection::HasOperator(const OperatorType &op)
173 {
174  return (m_ops.find(op) != m_ops.end());
175 }
176 
177 
178 }
179 }
180 
181 #endif
#define COLLECTIONS_EXPORT
COLLECTIONS_EXPORT Collection(std::vector< StdRegions::StdExpansionSharedPtr > pCollExp, OperatorImpMap &impTypes)
Definition: Collection.cpp:46
bool HasOperator(const OperatorType &op)
Definition: Collection.h:172
std::vector< StdRegions::StdExpansionSharedPtr > m_collExp
Definition: Collection.h:110
COLLECTIONS_EXPORT void CheckFactors(const OperatorType opType, StdRegions::FactorMap factors, int coll_phys_offset=0)
Definition: Collection.cpp:56
std::unordered_map< OperatorType, OperatorSharedPtr, EnumHash > m_ops
Definition: Collection.h:107
COLLECTIONS_EXPORT void Initialise(const OperatorType opType, StdRegions::FactorMap factors=StdRegions::NullFactorMap)
Definition: Collection.cpp:64
CoalescedGeomDataSharedPtr GetGeomSharedPtr()
Definition: Collection.h:100
OperatorSharedPtr GetOpSharedPtr(const OperatorType &op)
Definition: Collection.h:95
CoalescedGeomDataSharedPtr m_geomData
Definition: Collection.h:108
void ApplyOperator(const OperatorType &op, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &output)
Definition: Collection.h:120
std::map< OperatorType, ImplementationType > OperatorImpMap
Definition: Operator.h:108
std::shared_ptr< CollectionVector > CollectionVectorSharedPtr
Definition: Collection.h:115
std::shared_ptr< Operator > OperatorSharedPtr
Shared pointer to an Operator object.
Definition: Operator.h:174
std::shared_ptr< CoalescedGeomData > CoalescedGeomDataSharedPtr
std::vector< Collection > CollectionVector
Definition: Collection.h:114
static FactorMap NullFactorMap
Definition: StdRegions.hpp:319
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