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 
38 #include <boost/core/ignore_unused.hpp>
40 
41 namespace Nektar
42 {
43 namespace Collections
44 {
45 
47  {
48  public:
49  // Default constructor
51 
52  MatrixFreeBase(const unsigned int nIn,
53  const unsigned int nOut,
54  const unsigned int nCollSize):
55  m_nIn(nIn*nCollSize),
56  m_nOut(nOut*nCollSize)
57  {}
58 
59  protected:
60  /// flag for padding
61  bool m_isPadded{false};
62  /// size after padding
63  unsigned int m_nElmtPad;
64  unsigned int m_nIn;
65  unsigned int m_nOut;
66  };
67 
69  {
70  public:
71  /// Constructor
72  MatrixFreeOneInOneOut(const unsigned int nIn, const unsigned int nOut,
73  const unsigned int nCollSize):
74  MatrixFreeBase(nIn,nOut,nCollSize)
75  {
76  // Padding if needed
78  const auto nElmtNoPad = nCollSize;
79  m_nElmtPad = nElmtNoPad;
80 
81  if (nElmtNoPad % vec_t::width != 0)
82  {
83  m_isPadded = true;
84  m_nElmtPad = nElmtNoPad + vec_t::width -
85  (nElmtNoPad % vec_t::width);
88  }
89  }
90  protected:
91  /// padded input/output vectors
93  };
94 
95 
97  {
98  public:
99  /// Constructor
100  MatrixFreeMultiInOneOut(const unsigned int coordim,
101  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 = nElmtNoPad + vec_t::width -
117  (nElmtNoPad % vec_t::width);
118 
120  m_input[0] = Array<OneD, NekDouble>{nIn * m_nElmtPad, 0.0};
121  if (m_coordim == 2)
122  {
123  m_input[1] = Array<OneD, NekDouble>{nIn * m_nElmtPad, 0.0};
124  }
125  else if (m_coordim == 3)
126  {
127  m_input[1] = Array<OneD, NekDouble>{nIn * m_nElmtPad, 0.0};
128  m_input[2] = Array<OneD, NekDouble>{nIn * m_nElmtPad, 0.0};
129  }
131  }
132  }
133  protected:
134  /// coordinates dimension
135  unsigned short m_coordim;
136  /// padded input/output vectors
139  };
140 
142  {
143  public:
144  /// Constructor
145  MatrixFreeOneInMultiOut(const unsigned int coordim,
146  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 
159  if (nElmtNoPad % vec_t::width != 0)
160  {
161  m_isPadded = true;
162  m_nElmtPad = nElmtNoPad + vec_t::width -
163  (nElmtNoPad % vec_t::width);
164 
166 
168  m_output[0] = Array<OneD, NekDouble>{nOut * m_nElmtPad, 0.0};
169  if(m_coordim == 2)
170  {
171  m_output[1] = Array<OneD, NekDouble>{nOut * m_nElmtPad, 0.0};
172  }
173  else if (m_coordim == 3)
174  {
175  m_output[1] = Array<OneD, NekDouble>{nOut * m_nElmtPad, 0.0};
176  m_output[2] = Array<OneD, NekDouble>{nOut * m_nElmtPad, 0.0};
177  }
178  }
179  }
180  protected:
181  /// coordinates dimension
182  unsigned short m_coordim;
183  /// padded input/output vectors
186  };
187 }
188 }
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:1
typename abi< ScalarType >::type simd
Definition: tinysimd.hpp:83