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