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 
61  inline void ApplyOperator(
62  const OperatorType &op,
63  const Array<OneD, const NekDouble> &inarray,
64  Array<OneD, NekDouble> &output);
65 
66  inline void ApplyOperator(
67  const OperatorType &op,
68  const Array<OneD, const NekDouble> &inarray,
69  Array<OneD, NekDouble> &output0,
70  Array<OneD, NekDouble> &output1);
71 
72  inline void ApplyOperator(
73  const OperatorType &op,
74  const Array<OneD, const NekDouble> &inarray,
75  Array<OneD, NekDouble> &output0,
76  Array<OneD, NekDouble> &output1,
77  Array<OneD, NekDouble> &output2);
78 
79  inline void ApplyOperator(
80  const OperatorType &op,
81  int dir,
82  const Array<OneD, const NekDouble> &inarray,
83  Array<OneD, NekDouble> &output);
84 
85  inline bool HasOperator(const OperatorType &op);
86 
87  protected:
89  std::vector<SpatialDomains::GeometrySharedPtr> m_geom;
90  std::unordered_map<OperatorType, OperatorSharedPtr, EnumHash> m_ops;
92 
93 };
94 
95 typedef std::vector<Collection> CollectionVector;
96 typedef std::shared_ptr<CollectionVector> CollectionVectorSharedPtr;
97 
98 
99 /**
100  *
101  */
103  const OperatorType &op,
104  const Array<OneD, const NekDouble> &inarray,
105  Array<OneD, NekDouble> &output)
106 {
107  Array<OneD, NekDouble> wsp(m_ops[op]->GetWspSize());
108  (*m_ops[op])(inarray, output, NullNekDouble1DArray,
109  NullNekDouble1DArray, wsp);
110 }
111 
112 
113 /**
114  *
115  */
117  const OperatorType &op,
118  const Array<OneD, const NekDouble> &inarray,
119  Array<OneD, NekDouble> &output0,
120  Array<OneD, NekDouble> &output1)
121 {
122  Array<OneD, NekDouble> wsp(m_ops[op]->GetWspSize());
123  (*m_ops[op])(inarray, output0, output1, NullNekDouble1DArray, wsp);
124 }
125 
126 
127 /**
128  *
129  */
131  const OperatorType &op,
132  const Array<OneD, const NekDouble> &inarray,
133  Array<OneD, NekDouble> &output0,
134  Array<OneD, NekDouble> &output1,
135  Array<OneD, NekDouble> &output2)
136 {
137  Array<OneD, NekDouble> wsp(m_ops[op]->GetWspSize());
138  (*m_ops[op])(inarray, output0, output1, output2, wsp);
139 }
140 
141 /**
142  *
143  */
145  const OperatorType &op,
146  int dir,
147  const Array<OneD, const NekDouble> &inarray,
148  Array<OneD, NekDouble> &output)
149 {
150  Array<OneD, NekDouble> wsp(m_ops[op]->GetWspSize());
151  (*m_ops[op])(dir, inarray, output, wsp);
152 }
153 
154 inline bool Collection::HasOperator(const OperatorType &op)
155 {
156  return (m_ops.find(op) != m_ops.end());
157 }
158 
159 }
160 }
161 
162 #endif
std::shared_ptr< CoalescedGeomData > CoalescedGeomDataSharedPtr
CoalescedGeomDataSharedPtr m_geomData
Definition: Collection.h:91
static Array< OneD, NekDouble > NullNekDouble1DArray
bool HasOperator(const OperatorType &op)
Definition: Collection.h:154
std::vector< SpatialDomains::GeometrySharedPtr > m_geom
Definition: Collection.h:89
std::vector< Collection > CollectionVector
Definition: Collection.h:95
void ApplyOperator(const OperatorType &op, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &output)
Definition: Collection.h:102
std::unordered_map< OperatorType, OperatorSharedPtr, EnumHash > m_ops
Definition: Collection.h:90
std::shared_ptr< CollectionVector > CollectionVectorSharedPtr
Definition: Collection.h:96
std::shared_ptr< StdExpansion > StdExpansionSharedPtr
std::map< OperatorType, ImplementationType > OperatorImpMap
Definition: Operator.h:103
COLLECTIONS_EXPORT Collection(std::vector< StdRegions::StdExpansionSharedPtr > pCollExp, OperatorImpMap &impTypes)
Definition: Collection.cpp:46
#define COLLECTIONS_EXPORT
StdRegions::StdExpansionSharedPtr m_stdExp
Definition: Collection.h:88