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