Nektar++
Loading...
Searching...
No Matches
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<LocalRegions::ExpansionSharedPtr> pCollExp,
58 OperatorImpMap &impTypes);
59
60 /// Update the factor map in operator @param opType by input @param factors
62 StdRegions::FactorMap factors);
63
65 const OperatorType opType,
67
69 const OperatorType opType,
71
72 inline void ApplyOperator(const OperatorType &op,
73 const Array<OneD, const NekDouble> &inarray,
75
76 inline void ApplyOperator(const OperatorType &op,
77 const Array<OneD, const NekDouble> &inarray,
79 Array<OneD, NekDouble> &output1);
80
81 inline void ApplyOperator(const OperatorType &op,
82 const Array<OneD, const NekDouble> &inarray,
85 Array<OneD, NekDouble> &output2);
86
87 inline void ApplyOperator(const OperatorType &op, int dir,
88 const Array<OneD, const NekDouble> &inarray,
90
91 inline bool HasOperator(const OperatorType &op);
92
94 {
95 return m_ops[op];
96 }
97
102 inline std::vector<LocalRegions::ExpansionSharedPtr> &GetExpVector()
103 {
104 return m_collExp;
105 }
106
107 inline int GetInputSize(const OperatorType &op)
108 {
109 return m_ops[op]->GetInputSize();
110 }
111
112 inline int GetOutputSize(const OperatorType &op)
113 {
114 return m_ops[op]->GetOutputSize();
115 }
116
117 inline int GetPhysSize(const OperatorType &op)
118 {
119 return m_ops[op]->GetPhysSize();
120 }
121
122 inline int GetCoeffSize(const OperatorType &op)
123 {
124 return m_ops[op]->GetCoeffSize();
125 }
126
127 /// Return the number of elements in collection attached to @param op
128 inline int GetNumElmt(const OperatorType &op)
129 {
130 return m_ops[op]->GetNumElmt();
131 }
132
133protected:
134 std::unordered_map<OperatorType, OperatorSharedPtr> m_ops;
136 // store details for initialisation on call rather than default
137 // initialisation
138 std::vector<LocalRegions::ExpansionSharedPtr> m_collExp;
140};
141
142typedef std::vector<Collection> CollectionVector;
143typedef std::shared_ptr<CollectionVector> CollectionVectorSharedPtr;
144
145/**
146 *
147 */
149 const OperatorType &op, const Array<OneD, const NekDouble> &inarray,
151{
152 Array<OneD, NekDouble> wsp(m_ops[op]->GetWspSize());
153 (*m_ops[op])(inarray, output, NullNekDouble1DArray, NullNekDouble1DArray,
154 wsp);
155}
156
157/**
158 *
159 */
161 const OperatorType &op, const Array<OneD, const NekDouble> &inarray,
163{
164 Array<OneD, NekDouble> wsp(m_ops[op]->GetWspSize());
165 (*m_ops[op])(inarray, output0, output1, NullNekDouble1DArray, wsp);
166}
167
168/**
169 *
170 */
172 const OperatorType &op, const Array<OneD, const NekDouble> &inarray,
174 Array<OneD, NekDouble> &output2)
175{
176 Array<OneD, NekDouble> wsp(m_ops[op]->GetWspSize());
177 (*m_ops[op])(inarray, output0, output1, output2, wsp);
178}
179
180/**
181 *
182 */
184 const OperatorType &op, int dir,
186{
187 Array<OneD, NekDouble> wsp(m_ops[op]->GetWspSize());
188 (*m_ops[op])(dir, inarray, output, wsp);
189}
190
192{
193 return (m_ops.find(op) != m_ops.end());
194}
195
196} // namespace Nektar::Collections
197
198#endif
#define COLLECTIONS_EXPORT
int GetNumElmt(const OperatorType &op)
Return the number of elements in collection attached to.
Definition Collection.h:128
std::vector< LocalRegions::ExpansionSharedPtr > & GetExpVector()
Definition Collection.h:102
int GetCoeffSize(const OperatorType &op)
Definition Collection.h:122
bool HasOperator(const OperatorType &op)
Definition Collection.h:191
COLLECTIONS_EXPORT void UpdateVarcoeffs(const OperatorType opType, StdRegions::VarCoeffMap &varcoeffs=StdRegions::NullVarCoeffMap)
std::unordered_map< OperatorType, OperatorSharedPtr > m_ops
Definition Collection.h:134
int GetOutputSize(const OperatorType &op)
Definition Collection.h:112
COLLECTIONS_EXPORT void Initialise(const OperatorType opType, StdRegions::FactorMap factors=StdRegions::NullFactorMap)
int GetInputSize(const OperatorType &op)
Definition Collection.h:107
CoalescedGeomDataSharedPtr GetGeomSharedPtr()
Definition Collection.h:98
OperatorSharedPtr GetOpSharedPtr(const OperatorType &op)
Definition Collection.h:93
int GetPhysSize(const OperatorType &op)
Definition Collection.h:117
CoalescedGeomDataSharedPtr m_geomData
Definition Collection.h:135
std::vector< LocalRegions::ExpansionSharedPtr > m_collExp
Definition Collection.h:138
void ApplyOperator(const OperatorType &op, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &output)
Definition Collection.h:148
COLLECTIONS_EXPORT void UpdateFactors(const OperatorType opType, StdRegions::FactorMap factors)
Update the factor map in operator.
std::map< OperatorType, ImplementationType > OperatorImpMap
Definition Operator.h:131
std::shared_ptr< CollectionVector > CollectionVectorSharedPtr
Definition Collection.h:143
std::shared_ptr< Operator > OperatorSharedPtr
Shared pointer to an Operator object.
Definition Operator.h:244
std::shared_ptr< CoalescedGeomData > CoalescedGeomDataSharedPtr
std::vector< Collection > CollectionVector
Definition Collection.h:142
static FactorMap NullFactorMap
ConstFactorMap FactorMap
static VarCoeffMap NullVarCoeffMap
std::map< StdRegions::VarCoeffType, VarCoeffEntry > VarCoeffMap
static Array< OneD, NekDouble > NullNekDouble1DArray