Nektar++
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 namespace Nektar
40 {
41  namespace MultiRegions
42  {
44  const AssemblyMapSharedPtr &locToGloMap,
45  const StdRegions::ConstFactorMap &factors,
46  const StdRegions::VarCoeffMap &varCoeffs) :
47  m_matrixType(matrixType),
48  m_shapeType(LibUtilities::eNoShapeType),
49  m_constFactors(factors),
50  m_varCoeffs(varCoeffs),
51  m_locToGloMap(locToGloMap)
52  {
53  }
54 
56  const LibUtilities::ShapeType shapeType):
57  m_matrixType(key.m_matrixType),
58  m_shapeType(shapeType),
59  m_constFactors(key.m_constFactors),
60  m_varCoeffs(key.m_varCoeffs),
61  m_locToGloMap(key.m_locToGloMap)
62  {
63  }
64 
66  m_matrixType(key.m_matrixType),
67  m_shapeType(key.m_shapeType),
68  m_constFactors(key.m_constFactors),
69  m_varCoeffs(key.m_varCoeffs),
70  m_locToGloMap(key.m_locToGloMap)
71  {
72  }
73 
75  {
76  }
77 
78  bool operator<(const GlobalMatrixKey &lhs, const GlobalMatrixKey &rhs)
79  {
80  if(lhs.m_matrixType < rhs.m_matrixType)
81  {
82  return true;
83  }
84 
85  if(lhs.m_matrixType > rhs.m_matrixType)
86  {
87  return false;
88  }
89 
90 
91  if(lhs.m_shapeType < rhs.m_shapeType)
92  {
93  return true;
94  }
95 
96 
97  if(lhs.m_shapeType > rhs.m_shapeType)
98  {
99  return false;
100  }
101 
102  if(lhs.m_constFactors.size() < rhs.m_constFactors.size())
103  {
104  return true;
105  }
106  else if(lhs.m_constFactors.size() > rhs.m_constFactors.size())
107  {
108  return false;
109  }
110  else
111  {
112  StdRegions::ConstFactorMap::const_iterator x, y;
113  for(x = lhs.m_constFactors.begin(), y = rhs.m_constFactors.begin();
114  x != lhs.m_constFactors.end(); ++x, ++y)
115  {
116  if (x->second < y->second)
117  {
118  return true;
119  }
120  if (x->second > y->second)
121  {
122  return false;
123  }
124  }
125  }
126 
127  if(lhs.m_varCoeffs.size() < rhs.m_varCoeffs.size())
128  {
129  return true;
130  }
131  else if(lhs.m_varCoeffs.size() > rhs.m_varCoeffs.size())
132  {
133  return false;
134  }
135 // else
136 // {
137 // StdRegions::VarCoeffMap::const_iterator x, y;
138 // for (x = lhs.m_varCoeffs.begin(), y = rhs.m_varCoeffs.begin();
139 // x != lhs.m_varCoeffs.end(); ++x, ++y)
140 // {
141 // if (x->second.get() < y->second.get())
142 // {
143 // return true;
144 // }
145 // if (x->second.get() > y->second.get())
146 // {
147 // return false;
148 // }
149 // }
150 // }
151 
152  if(!rhs.m_locToGloMap.get())
153  {
154  return false;
155  }
156  else if(!lhs.m_locToGloMap.get() && rhs.m_locToGloMap.get() )
157  {
158  return true;
159  }
160  if(lhs.m_locToGloMap->GetHash() < rhs.m_locToGloMap->GetHash())
161  {
162  return true;
163  }
164 
165  return false;
166  }
167 
168  std::ostream& operator<<(std::ostream& os, const GlobalMatrixKey& rhs)
169  {
170  os << "MatrixType: " << rhs.GetMatrixType() << endl;
171  os << "Number of constants: " << rhs.GetNConstFactors() << endl;
172  StdRegions::ConstFactorMap::const_iterator x;
173  for(x = rhs.GetConstFactors().begin(); x != rhs.GetConstFactors().end(); ++x)
174  {
175  os << " Constant " << StdRegions::ConstFactorTypeMap[x->first]
176  << ": " << x->second << endl;
177  }
178  os << "Number of variable coefficients: "
179  << rhs.GetNVarCoeffs() << endl;
180 
181  return os;
182  }
183  }
184 }
boost::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
Definition: AssemblyMap.h:53
bool operator<(const GlobalLinSysKey &lhs, const GlobalLinSysKey &rhs)
std::map< ConstFactorType, NekDouble > ConstFactorMap
Definition: StdRegions.hpp:248
const StdRegions::ConstFactorMap & GetConstFactors() const
Returns all the constants.
const char *const ConstFactorTypeMap[]
Definition: StdRegions.hpp:239
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:225
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.