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