Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
StdMatrixKey.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File StdMatrixKeys.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 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: Headers for StdMatrixKey
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef STDMATRIXKEY_H
37 #define STDMATRIXKEY_H
38 
41 #include <LibUtilities/Foundations/Foundations.hpp> // for PointsType, etc
43 
44 
45 namespace Nektar
46 {
47  namespace StdRegions
48  {
49 
50  class StdExpansion;
51 
53  {
54  public:
56  const LibUtilities::ShapeType shapeType,
57  const StdRegions::StdExpansion &stdExpansion,
58  const ConstFactorMap &factorMap = NullConstFactorMap,
59  const VarCoeffMap &varCoeffMap = NullVarCoeffMap,
61 
62  STD_REGIONS_EXPORT StdMatrixKey(const StdMatrixKey& rhs,
63  const StdRegions::MatrixType matrixType);
64 
65  STD_REGIONS_EXPORT StdMatrixKey(const StdMatrixKey& rhs);
66 
67  virtual ~StdMatrixKey()
68  {
69  }
70 
71  /// Used to lookup the create function in NekManager.
72  struct opLess
73  {
74  STD_REGIONS_EXPORT bool operator()(const StdMatrixKey &lhs, const StdMatrixKey &rhs) const;
75  };
76 
77  /// Used for finding value given the key in NekManager.
78  STD_REGIONS_EXPORT friend bool operator<(const StdMatrixKey &lhs, const StdMatrixKey &rhs);
79  STD_REGIONS_EXPORT friend bool operator==(const StdMatrixKey &lhs, const StdMatrixKey &rhs);
80  STD_REGIONS_EXPORT friend bool opLess::operator()(const StdMatrixKey &lhs, const StdMatrixKey &rhs) const;
81 
83  {
84  return m_matrixType;
85  }
86 
88  {
89  return m_shapeType;
90  }
91 
93  {
94  return m_nodalPointsType;
95  }
96 
97  int GetNcoeffs() const
98  {
99  return m_ncoeffs;
100  }
101 
102  inline const Array<OneD, const LibUtilities::BasisSharedPtr>& GetBase() const
103  {
104  return m_base;
105  }
106 
107  std::vector<std::size_t> GetVarCoeffHashes() const
108  {
109  return m_varcoeff_hashes;
110  }
111 
112  inline const LibUtilities::BasisSharedPtr GetBasis(int dir) const
113  {
114  return(m_base[dir]);
115  }
116 
117  inline int GetNConstFactors() const
118  {
119  return m_factors.size();
120  }
121 
122  inline NekDouble GetConstFactor(const ConstFactorType& factor) const
123  {
124  ConstFactorMap::const_iterator x = m_factors.find(factor);
125  ASSERTL1(x != m_factors.end(),
126  "Constant factor not defined: "
127  + std::string(StdRegions::ConstFactorTypeMap[factor]));
128  return x->second;
129  }
130 
131  inline bool ConstFactorExists(const ConstFactorType& factor) const
132  {
133  ConstFactorMap::const_iterator x = m_factors.find(factor);
134  if(x != m_factors.end())
135  {
136  return true;
137  }
138 
139  return false;
140  }
141 
142  inline const ConstFactorMap& GetConstFactors() const
143  {
144  return m_factors;
145  }
146 
147  inline int GetNVarCoeff() const
148  {
149  return m_varcoeffs.size();
150  }
151 
152  inline const Array<OneD, const NekDouble> &GetVarCoeff(const StdRegions::VarCoeffType & coeff) const
153  {
154  VarCoeffMap::const_iterator x = m_varcoeffs.find(coeff);
155  ASSERTL1(x != m_varcoeffs.end(),
156  "Variable coefficient not defined: "
157  + std::string(StdRegions::VarCoeffTypeMap[coeff]));
158  return x->second;
159  }
160 
161  inline const VarCoeffMap GetVarCoeffAsMap(const VarCoeffType & coeff) const
162  {
163  VarCoeffMap m;
164  m[coeff] = GetVarCoeff(coeff);
165  return m;
166  }
167 
168  inline const VarCoeffMap& GetVarCoeffs() const
169  {
170  return m_varcoeffs;
171  }
172 
173  inline bool HasVarCoeff(const StdRegions::VarCoeffType & coeff) const
174  {
175  return (m_varcoeffs.find(coeff) != m_varcoeffs.end());
176  }
177 
178  protected:
180  Array<OneD, const LibUtilities::BasisSharedPtr> m_base;
181 
182  unsigned int m_ncoeffs;
185 
188 
189  std::vector<std::size_t> m_varcoeff_hashes;
190  private:
191  StdMatrixKey();
192  };
193 
194  STD_REGIONS_EXPORT std::ostream& operator<<(std::ostream& os, const StdMatrixKey& rhs);
195 
196  typedef boost::shared_ptr<StdMatrixKey> StdMatrixKeySharedPtr;
197 
198  } // end of namespace
199 } // end of namespace
200 
201 #endif