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
60 /// Update the factor map in operator @param opType by input @param 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
99 {
100 return m_geomData;
101 }
102
103 inline int GetInputSize(const OperatorType &op, bool defaultIn = true)
104 {
105 return m_ops[op]->GetInputSize(defaultIn);
106 }
107
108 inline int GetOutputSize(const OperatorType &op, bool defaultOut = true)
109 {
110 return m_ops[op]->GetOutputSize(defaultOut);
111 }
112
113 /// Return the number of elements in collection attached to @param op
114 inline int GetNumElmt(const OperatorType &op)
115 {
116 return m_ops[op]->GetNumElmt();
117 }
118
119protected:
120 std::unordered_map<OperatorType, OperatorSharedPtr, EnumHash> m_ops;
122 // store details for initialisation on call rather than default
123 // initialisation
124 std::vector<StdRegions::StdExpansionSharedPtr> m_collExp;
126};
127
128typedef std::vector<Collection> CollectionVector;
129typedef std::shared_ptr<CollectionVector> CollectionVectorSharedPtr;
130
131/**
132 *
133 */
135 const OperatorType &op, const Array<OneD, const NekDouble> &inarray,
137{
138 Array<OneD, NekDouble> wsp(m_ops[op]->GetWspSize());
139 (*m_ops[op])(inarray, output, NullNekDouble1DArray, NullNekDouble1DArray,
140 wsp);
141}
142
143/**
144 *
145 */
147 const OperatorType &op, const Array<OneD, const NekDouble> &inarray,
149{
150 Array<OneD, NekDouble> wsp(m_ops[op]->GetWspSize());
151 (*m_ops[op])(inarray, output0, output1, NullNekDouble1DArray, wsp);
152}
153
154/**
155 *
156 */
158 const OperatorType &op, const Array<OneD, const NekDouble> &inarray,
160 Array<OneD, NekDouble> &output2)
161{
162 Array<OneD, NekDouble> wsp(m_ops[op]->GetWspSize());
163 (*m_ops[op])(inarray, output0, output1, output2, wsp);
164}
165
166/**
167 *
168 */
170 const OperatorType &op, int dir,
172{
173 Array<OneD, NekDouble> wsp(m_ops[op]->GetWspSize());
174 (*m_ops[op])(dir, inarray, output, wsp);
175}
176
178{
179 return (m_ops.find(op) != m_ops.end());
180}
181
182} // namespace Nektar::Collections
183
184#endif
#define COLLECTIONS_EXPORT
int GetNumElmt(const OperatorType &op)
Return the number of elements in collection attached to.
Definition: Collection.h:114
COLLECTIONS_EXPORT Collection(std::vector< StdRegions::StdExpansionSharedPtr > pCollExp, OperatorImpMap &impTypes)
Definition: Collection.cpp:46
bool HasOperator(const OperatorType &op)
Definition: Collection.h:177
std::vector< StdRegions::StdExpansionSharedPtr > m_collExp
Definition: Collection.h:124
std::unordered_map< OperatorType, OperatorSharedPtr, EnumHash > m_ops
Definition: Collection.h:120
COLLECTIONS_EXPORT void UpdateVarcoeffs(const OperatorType opType, StdRegions::VarCoeffMap &varcoeffs=StdRegions::NullVarCoeffMap)
Definition: Collection.cpp:60
COLLECTIONS_EXPORT void Initialise(const OperatorType opType, StdRegions::FactorMap factors=StdRegions::NullFactorMap)
Definition: Collection.cpp:66
CoalescedGeomDataSharedPtr GetGeomSharedPtr()
Definition: Collection.h:98
OperatorSharedPtr GetOpSharedPtr(const OperatorType &op)
Definition: Collection.h:93
CoalescedGeomDataSharedPtr m_geomData
Definition: Collection.h:121
void ApplyOperator(const OperatorType &op, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &output)
Definition: Collection.h:134
int GetInputSize(const OperatorType &op, bool defaultIn=true)
Definition: Collection.h:103
COLLECTIONS_EXPORT void UpdateFactors(const OperatorType opType, StdRegions::FactorMap factors)
Update the factor map in operator.
Definition: Collection.cpp:54
int GetOutputSize(const OperatorType &op, bool defaultOut=true)
Definition: Collection.h:108
std::map< OperatorType, ImplementationType > OperatorImpMap
Definition: Operator.h:131
std::shared_ptr< CollectionVector > CollectionVectorSharedPtr
Definition: Collection.h:129
std::shared_ptr< Operator > OperatorSharedPtr
Shared pointer to an Operator object.
Definition: Operator.h:235
std::shared_ptr< CoalescedGeomData > CoalescedGeomDataSharedPtr
std::vector< Collection > CollectionVector
Definition: Collection.h:128
static FactorMap NullFactorMap
Definition: StdRegions.hpp:435
ConstFactorMap FactorMap
Definition: StdRegions.hpp:434
static VarCoeffMap NullVarCoeffMap
Definition: StdRegions.hpp:376
std::map< StdRegions::VarCoeffType, VarCoeffEntry > VarCoeffMap
Definition: StdRegions.hpp:375
StdRegions::ConstFactorMap factors
static Array< OneD, NekDouble > NullNekDouble1DArray