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 definiitin for matrrix free type
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#ifndef NEKTAR_LIBRARY_COLLECTIONS_MATRIXFREEBASE_H
36#define NEKTAR_LIBRARY_COLLECTIONS_MATRIXFREEBASE_H
37
39#include <boost/core/ignore_unused.hpp>
40
41namespace Nektar
42{
43namespace Collections
44{
45
47{
48public:
49 // Default constructor
51 {
52 }
53
54 MatrixFreeBase(const unsigned int nIn, const unsigned int nOut,
55 const unsigned int nCollSize)
56 : m_nIn(nIn * nCollSize), m_nOut(nOut * nCollSize)
57 {
58 }
59
60protected:
61 /// flag for padding
62 bool m_isPadded{false};
63 /// size after padding
64 unsigned int m_nElmtPad;
65 unsigned int m_nIn;
66 unsigned int m_nOut;
67};
68
70{
71public:
72 /// Constructor
73 MatrixFreeOneInOneOut(const unsigned int nIn, const unsigned int nOut,
74 const unsigned int nCollSize)
75 : MatrixFreeBase(nIn, nOut, nCollSize)
76 {
77 // Padding if needed
79 const auto nElmtNoPad = nCollSize;
80 m_nElmtPad = nElmtNoPad;
81
82 if (nElmtNoPad % vec_t::width != 0)
83 {
84 m_isPadded = true;
86 nElmtNoPad + vec_t::width - (nElmtNoPad % vec_t::width);
89 }
90 }
91
92protected:
93 /// padded input/output vectors
95};
96
98{
99public:
100 /// Constructor
101 MatrixFreeMultiInOneOut(const unsigned int coordim, const unsigned int nIn,
102 const unsigned int nOut,
103 const unsigned int nCollSize)
104 : MatrixFreeBase(nIn, nOut, nCollSize)
105 {
106 m_coordim = coordim;
107
108 // Padding if needed
110 const auto nElmtNoPad = nCollSize;
111 m_nElmtPad = nElmtNoPad;
112
113 if (nElmtNoPad % vec_t::width != 0)
114 {
115 m_isPadded = true;
116 m_nElmtPad =
117 nElmtNoPad + vec_t::width - (nElmtNoPad % vec_t::width);
118
121 if (m_coordim == 2)
122 {
124 }
125 else if (m_coordim == 3)
126 {
129 }
131 }
132 }
133
134protected:
135 /// coordinates dimension
136 unsigned short m_coordim;
137 /// padded input/output vectors
140};
141
143{
144public:
145 /// Constructor
146 MatrixFreeOneInMultiOut(const unsigned int coordim, const unsigned int nIn,
147 const unsigned int nOut,
148 const unsigned int nCollSize)
149 : MatrixFreeBase(nIn, nOut, nCollSize)
150 {
151 m_coordim = coordim;
152
153 // Padding if needed
155 const auto nElmtNoPad = nCollSize;
156 m_nElmtPad = nElmtNoPad;
157
158 if (nElmtNoPad % vec_t::width != 0)
159 {
160 m_isPadded = true;
161 m_nElmtPad =
162 nElmtNoPad + vec_t::width - (nElmtNoPad % vec_t::width);
163
165
168 if (m_coordim == 2)
169 {
171 }
172 else if (m_coordim == 3)
173 {
176 }
177 }
178 }
179
180protected:
181 /// coordinates dimension
182 unsigned short m_coordim;
183 /// padded input/output vectors
186};
187} // namespace Collections
188} // namespace Nektar
189#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
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
typename abi< ScalarType, width >::type simd
Definition: tinysimd.hpp:80