Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GlobalMatrixKey.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File GlobalMatrixKey.cpp
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: Definition of GlobalMatrixKey
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 
38 
39 using namespace std;
40 
41 namespace Nektar
42 {
43  namespace MultiRegions
44  {
45  GlobalMatrixKey::GlobalMatrixKey(const StdRegions::MatrixType matrixType,
46  const AssemblyMapSharedPtr &locToGloMap,
47  const StdRegions::ConstFactorMap &factors,
48  const StdRegions::VarCoeffMap &varCoeffs) :
49  m_matrixType(matrixType),
50  m_shapeType(LibUtilities::eNoShapeType),
51  m_constFactors(factors),
52  m_varCoeffs(varCoeffs),
53  m_locToGloMap(locToGloMap)
54  {
55  }
56 
58  const LibUtilities::ShapeType shapeType):
59  m_matrixType(key.m_matrixType),
60  m_shapeType(shapeType),
61  m_constFactors(key.m_constFactors),
62  m_varCoeffs(key.m_varCoeffs),
63  m_locToGloMap(key.m_locToGloMap)
64  {
65  }
66 
68  m_matrixType(key.m_matrixType),
69  m_shapeType(key.m_shapeType),
70  m_constFactors(key.m_constFactors),
71  m_varCoeffs(key.m_varCoeffs),
72  m_locToGloMap(key.m_locToGloMap)
73  {
74  }
75 
77  {
78  }
79 
80  bool operator<(const GlobalMatrixKey &lhs, const GlobalMatrixKey &rhs)
81  {
82  if(lhs.m_matrixType < rhs.m_matrixType)
83  {
84  return true;
85  }
86 
87  if(lhs.m_matrixType > rhs.m_matrixType)
88  {
89  return false;
90  }
91 
92 
93  if(lhs.m_shapeType < rhs.m_shapeType)
94  {
95  return true;
96  }
97 
98 
99  if(lhs.m_shapeType > rhs.m_shapeType)
100  {
101  return false;
102  }
103 
104  if(lhs.m_constFactors.size() < rhs.m_constFactors.size())
105  {
106  return true;
107  }
108  else if(lhs.m_constFactors.size() > rhs.m_constFactors.size())
109  {
110  return false;
111  }
112  else
113  {
114  StdRegions::ConstFactorMap::const_iterator x, y;
115  for(x = lhs.m_constFactors.begin(), y = rhs.m_constFactors.begin();
116  x != lhs.m_constFactors.end(); ++x, ++y)
117  {
118  if (x->second < y->second)
119  {
120  return true;
121  }
122  if (x->second > y->second)
123  {
124  return false;
125  }
126  }
127  }
128 
129  if(lhs.m_varCoeffs.size() < rhs.m_varCoeffs.size())
130  {
131  return true;
132  }
133  else if(lhs.m_varCoeffs.size() > rhs.m_varCoeffs.size())
134  {
135  return false;
136  }
137 // else
138 // {
139 // StdRegions::VarCoeffMap::const_iterator x, y;
140 // for (x = lhs.m_varCoeffs.begin(), y = rhs.m_varCoeffs.begin();
141 // x != lhs.m_varCoeffs.end(); ++x, ++y)
142 // {
143 // if (x->second.get() < y->second.get())
144 // {
145 // return true;
146 // }
147 // if (x->second.get() > y->second.get())
148 // {
149 // return false;
150 // }
151 // }
152 // }
153 
154  if(!rhs.m_locToGloMap.get())
155  {
156  return false;
157  }
158  else if(!lhs.m_locToGloMap.get() && rhs.m_locToGloMap.get() )
159  {
160  return true;
161  }
162  if(lhs.m_locToGloMap->GetHash() < rhs.m_locToGloMap->GetHash())
163  {
164  return true;
165  }
166 
167  return false;
168  }
169 
170  std::ostream& operator<<(std::ostream& os, const GlobalMatrixKey& rhs)
171  {
172  os << "MatrixType: " << rhs.GetMatrixType() << endl;
173  os << "Number of constants: " << rhs.GetNConstFactors() << endl;
174  StdRegions::ConstFactorMap::const_iterator x;
175  for(x = rhs.GetConstFactors().begin(); x != rhs.GetConstFactors().end(); ++x)
176  {
177  os << " Constant " << StdRegions::ConstFactorTypeMap[x->first]
178  << ": " << x->second << endl;
179  }
180  os << "Number of variable coefficients: "
181  << rhs.GetNVarCoeffs() << endl;
182 
183  return os;
184  }
185  }
186 }
boost::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
Definition: AssemblyMap.h:53
bool operator<(const GlobalLinSysKey &lhs, const GlobalLinSysKey &rhs)
STL namespace.
std::map< ConstFactorType, NekDouble > ConstFactorMap
Definition: StdRegions.hpp:251
const StdRegions::ConstFactorMap & GetConstFactors() const
Returns all the constants.
const char *const ConstFactorTypeMap[]
Definition: StdRegions.hpp:241
GlobalMatrixKey()
Default constructor.
StandardMatrixTag & lhs
StdRegions::ConstFactorMap m_constFactors
std::ostream & operator<<(std::ostream &os, const GlobalLinSysKey &rhs)
Writes information about the object to a given stream.
std::map< StdRegions::VarCoeffType, Array< OneD, NekDouble > > VarCoeffMap
Definition: StdRegions.hpp:226
StdRegions::MatrixType GetMatrixType() const
Return the matrix type.
Describes a matrix with ordering defined by a local to global map.
int GetNConstFactors() const
Returns the number of constants defined for this matrix.
AssemblyMapSharedPtr m_locToGloMap
Pointer to the local to global mapping.
LibUtilities::ShapeType m_shapeType
Stores the expansion/shape type that the matrix is to be based on.
StdRegions::MatrixType m_matrixType
Stores the matrix type based on the enum StdRegions::MatrixType.