Nektar++
MatrixFreeBase.h
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: MatrixFreeBase.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: base class definition for matrrix free type
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#ifndef NEKTAR_LIBRARY_COLLECTIONS_MATRIXFREEBASE_H
36#define NEKTAR_LIBRARY_COLLECTIONS_MATRIXFREEBASE_H
37
39
40namespace Nektar::Collections
41{
42
44{
45public:
46 // Default constructor
47 MatrixFreeBase() = default;
48
49 MatrixFreeBase(const unsigned int nIn, const unsigned int nOut,
50 const unsigned int nCollSize)
51 : m_nIn(nIn * nCollSize), m_nOut(nOut * nCollSize)
52 {
53 }
54
55protected:
56 /// flag for padding
57 bool m_isPadded{false};
58 /// size after padding
59 unsigned int m_nElmtPad;
60 unsigned int m_nIn;
61 unsigned int m_nOut;
62};
63
65{
66public:
67 /// Constructor
68 MatrixFreeOneInOneOut(const unsigned int nIn, const unsigned int nOut,
69 const unsigned int nCollSize)
70 : MatrixFreeBase(nIn, nOut, nCollSize)
71 {
72 // Padding if needed
74 const auto nElmtNoPad = nCollSize;
75 m_nElmtPad = nElmtNoPad;
76
77 if (nElmtNoPad % vec_t::width != 0)
78 {
79 m_isPadded = true;
81 nElmtNoPad + vec_t::width - (nElmtNoPad % vec_t::width);
84 }
85 }
86
87protected:
88 /// padded input/output vectors
90};
91
93{
94public:
95 /// Constructor
96 MatrixFreeMultiInOneOut(const unsigned int coordim, const unsigned int nIn,
97 const unsigned int nOut,
98 const unsigned int nCollSize)
99 : MatrixFreeBase(nIn, nOut, nCollSize)
100 {
101 m_coordim = coordim;
102
103 // Padding if needed
105 const auto nElmtNoPad = nCollSize;
106 m_nElmtPad = nElmtNoPad;
107
108 if (nElmtNoPad % vec_t::width != 0)
109 {
110 m_isPadded = true;
111 m_nElmtPad =
112 nElmtNoPad + vec_t::width - (nElmtNoPad % vec_t::width);
113
116 if (m_coordim == 2)
117 {
119 }
120 else if (m_coordim == 3)
121 {
124 }
126 }
127 }
128
129protected:
130 /// coordinates dimension
131 unsigned short m_coordim;
132 /// padded input/output vectors
135};
136
138{
139public:
140 /// Constructor
141 MatrixFreeOneInMultiOut(const unsigned int coordim, const unsigned int nIn,
142 const unsigned int nOut,
143 const unsigned int nCollSize)
144 : MatrixFreeBase(nIn, nOut, nCollSize)
145 {
146 m_coordim = coordim;
147
148 // Padding if needed
150 const auto nElmtNoPad = nCollSize;
151 m_nElmtPad = nElmtNoPad;
152
153 if (nElmtNoPad % vec_t::width != 0)
154 {
155 m_isPadded = true;
156 m_nElmtPad =
157 nElmtNoPad + vec_t::width - (nElmtNoPad % vec_t::width);
158
160
163 if (m_coordim == 2)
164 {
166 }
167 else if (m_coordim == 3)
168 {
171 }
172 }
173 }
174
175protected:
176 /// coordinates dimension
177 unsigned short m_coordim;
178 /// padded input/output vectors
181};
182} // namespace Nektar::Collections
183#endif // NEKTAR_LIBRARY_COLLECTIONS_MATRIXFREEBASE_H
MatrixFreeBase(const unsigned int nIn, const unsigned int nOut, const unsigned int nCollSize)
unsigned int m_nElmtPad
size after padding
unsigned short m_coordim
coordinates dimension
MatrixFreeMultiInOneOut(const unsigned int coordim, const unsigned int nIn, const unsigned int nOut, const unsigned int nCollSize)
Constructor.
Array< OneD, Array< OneD, NekDouble > > m_input
padded input/output vectors
Array< OneD, NekDouble > m_input
padded input/output vectors
unsigned short m_coordim
coordinates dimension
MatrixFreeOneInMultiOut(const unsigned int coordim, const unsigned int nIn, const unsigned int nOut, const unsigned int nCollSize)
Constructor.
Array< OneD, Array< OneD, NekDouble > > m_output
MatrixFreeOneInOneOut(const unsigned int nIn, const unsigned int nOut, const unsigned int nCollSize)
Constructor.
Array< OneD, NekDouble > m_input
padded input/output vectors
simd< NekDouble > vec_t
typename abi< ScalarType, width >::type simd
Definition: tinysimd.hpp:80