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 
42 #include <Collections/Operator.h>
46 
47 namespace Nektar
48 {
49 namespace Collections
50 {
51 
52 /**
53  * @brief Collection
54  */
56 {
57 public:
59  std::vector<StdRegions::StdExpansionSharedPtr> pCollExp,
60  OperatorImpMap &impTypes);
61 
63  StdRegions::FactorMap factors,
64  int coll_phys_offset = 0);
65 
67  const OperatorType opType,
69 
70  inline void ApplyOperator(const OperatorType &op,
71  const Array<OneD, const NekDouble> &inarray,
72  Array<OneD, NekDouble> &output);
73 
74  inline void ApplyOperator(const OperatorType &op,
75  const Array<OneD, const NekDouble> &inarray,
76  Array<OneD, NekDouble> &output0,
77  Array<OneD, NekDouble> &output1);
78 
79  inline void ApplyOperator(const OperatorType &op,
80  const Array<OneD, const NekDouble> &inarray,
81  Array<OneD, NekDouble> &output0,
82  Array<OneD, NekDouble> &output1,
83  Array<OneD, NekDouble> &output2);
84 
85  inline void ApplyOperator(const OperatorType &op, int dir,
86  const Array<OneD, const NekDouble> &inarray,
87  Array<OneD, NekDouble> &output);
88 
89  inline bool HasOperator(const OperatorType &op);
90 
92  {
93  return m_ops[op];
94  }
95 
97  {
98  return m_geomData;
99  }
100 
101 protected:
102  std::unordered_map<OperatorType, OperatorSharedPtr, EnumHash> m_ops;
104  // store details for initialisation on call rather than default
105  // initialisation
106  std::vector<StdRegions::StdExpansionSharedPtr> m_collExp;
108 };
109 
110 typedef std::vector<Collection> CollectionVector;
111 typedef std::shared_ptr<CollectionVector> CollectionVectorSharedPtr;
112 
113 /**
114  *
115  */
117  const OperatorType &op, const Array<OneD, const NekDouble> &inarray,
118  Array<OneD, NekDouble> &output)
119 {
120  Array<OneD, NekDouble> wsp(m_ops[op]->GetWspSize());
121  (*m_ops[op])(inarray, output, NullNekDouble1DArray, NullNekDouble1DArray,
122  wsp);
123 }
124 
125 /**
126  *
127  */
129  const OperatorType &op, const Array<OneD, const NekDouble> &inarray,
131 {
132  Array<OneD, NekDouble> wsp(m_ops[op]->GetWspSize());
133  (*m_ops[op])(inarray, output0, output1, NullNekDouble1DArray, wsp);
134 }
135 
136 /**
137  *
138  */
140  const OperatorType &op, const Array<OneD, const NekDouble> &inarray,
142  Array<OneD, NekDouble> &output2)
143 {
144  Array<OneD, NekDouble> wsp(m_ops[op]->GetWspSize());
145  (*m_ops[op])(inarray, output0, output1, output2, wsp);
146 }
147 
148 /**
149  *
150  */
152  const OperatorType &op, int dir,
154 {
155  Array<OneD, NekDouble> wsp(m_ops[op]->GetWspSize());
156  (*m_ops[op])(dir, inarray, output, wsp);
157 }
158 
159 inline bool Collection::HasOperator(const OperatorType &op)
160 {
161  return (m_ops.find(op) != m_ops.end());
162 }
163 
164 } // namespace Collections
165 } // namespace Nektar
166 
167 #endif
#define COLLECTIONS_EXPORT
COLLECTIONS_EXPORT Collection(std::vector< StdRegions::StdExpansionSharedPtr > pCollExp, OperatorImpMap &impTypes)
Definition: Collection.cpp:48
bool HasOperator(const OperatorType &op)
Definition: Collection.h:159
std::vector< StdRegions::StdExpansionSharedPtr > m_collExp
Definition: Collection.h:106
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:102
COLLECTIONS_EXPORT void Initialise(const OperatorType opType, StdRegions::FactorMap factors=StdRegions::NullFactorMap)
Definition: Collection.cpp:63
CoalescedGeomDataSharedPtr GetGeomSharedPtr()
Definition: Collection.h:96
OperatorSharedPtr GetOpSharedPtr(const OperatorType &op)
Definition: Collection.h:91
CoalescedGeomDataSharedPtr m_geomData
Definition: Collection.h:103
void ApplyOperator(const OperatorType &op, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &output)
Definition: Collection.h:116
std::map< OperatorType, ImplementationType > OperatorImpMap
Definition: Operator.h:112
std::shared_ptr< CollectionVector > CollectionVectorSharedPtr
Definition: Collection.h:111
std::shared_ptr< Operator > OperatorSharedPtr
Shared pointer to an Operator object.
Definition: Operator.h:172
std::shared_ptr< CoalescedGeomData > CoalescedGeomDataSharedPtr
std::vector< Collection > CollectionVector
Definition: Collection.h:110
static FactorMap NullFactorMap
Definition: StdRegions.hpp:404
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