Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GlobalLinSysKey.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File GlobalLinSysKey.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 GlobalLinSysKey
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 
38 
39 namespace Nektar
40 {
41  namespace MultiRegions
42  {
43  /**
44  * @class GlobalLinSysKey
45  *
46  * This class represents a global linear system and is in essence a
47  * wrapper around a global matrix key, augmenting it with a specific
48  * solution type from GlobalSysSolnType. Each constructor accepts a
49  * MatrixType, describing the matrix to be constructed, a
50  * AssemblyMap, defining the mapping from the local elemental
51  * expansions to a global system, and a GlobalSysSolnType, defining the
52  * type of solution (e.g. full matrix, static condenstation). Some
53  * constructors include additional parameters for customising the
54  * global operator matrix.
55  */
56 
58  const AssemblyMapSharedPtr &locToGloMap,
59  const StdRegions::ConstFactorMap &factors,
60  const StdRegions::VarCoeffMap &varCoeffs) :
61  GlobalMatrixKey(matrixType, locToGloMap, factors, varCoeffs),
62  m_solnType(locToGloMap->GetGlobalSysSolnType())
63  {
64 
65  }
66 
67 
68  /**
69  * @param key Existing key to duplicate.
70  */
72  GlobalMatrixKey(key),
73  m_solnType(key.m_solnType)
74  {
75  }
76 
77 
78  /**
79  *
80  */
82  {
83  }
84 
85 
86  /**
87  * Compares two GlobalLinSysKeys by comparing their solution types and
88  * matrix keys.
89  * @param lhs First operand.
90  * @param rhs Second operand.
91  * @returns true if the first operand is considered less than the
92  * second operand.
93  */
94  bool operator<(const GlobalLinSysKey &lhs, const GlobalLinSysKey &rhs)
95  {
96  if(lhs.m_solnType < rhs.m_solnType)
97  {
98  return true;
99  }
100 
101  if(lhs.m_solnType > rhs.m_solnType)
102  {
103  return false;
104  }
105 
106  return (*dynamic_cast<const GlobalMatrixKey*>(&lhs)
107  < *dynamic_cast<const GlobalMatrixKey*>(&rhs));
108  }
109 
110 
111  /**
112  * Writes the vital statistics of a global linear system to a stream.
113  * @param os Output stream.
114  * @param rhs GlobalLinSys object to use.
115  * @returns Reference to the output stream \a os.
116  */
117  std::ostream& operator<<(std::ostream& os, const GlobalLinSysKey& rhs)
118  {
119  os << "MatrixType: " << StdRegions::MatrixTypeMap[rhs.GetMatrixType()] << ", ShapeType: "
121  << std::endl;
122  os << "Solution Type: "
123  << GlobalSysSolnTypeMap[rhs.GetGlobalSysSolnType()] << endl;
124  os << "Number of constants: " << rhs.GetNConstFactors() << endl;
125  StdRegions::ConstFactorMap::const_iterator x;
126  for (x = rhs.GetConstFactors().begin(); x != rhs.GetConstFactors().end(); ++x)
127  {
128  os << " Constant " << StdRegions::ConstFactorTypeMap[x->first]
129  << ": " << x->second << endl;
130  }
131  os << "Number of variable coefficients: "
132  << rhs.GetNVarCoeffs() << endl;
133 
134  return os;
135  }
136  }
137 }
GlobalSysSolnType GetGlobalSysSolnType() const
Return the associated solution type.
GlobalLinSysKey(const StdRegions::MatrixType matrixType, const AssemblyMapSharedPtr &locToGloMap=NullAssemblyMapSharedPtr, const StdRegions::ConstFactorMap &factors=StdRegions::NullConstFactorMap, const StdRegions::VarCoeffMap &varCoeffs=StdRegions::NullVarCoeffMap)
boost::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
Definition: AssemblyMap.h:53
bool operator<(const GlobalLinSysKey &lhs, const GlobalLinSysKey &rhs)
GlobalSysSolnType m_solnType
Store the solution type associated with the linear system. This may be none, full matrix...
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
const char *const ShapeTypeMap[]
Definition: ShapeType.hpp:66
StandardMatrixTag & lhs
const char *const GlobalSysSolnTypeMap[]
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
LibUtilities::ShapeType GetShapeType() const
Return the expansion type associated with key.
const char *const MatrixTypeMap[]
Definition: StdRegions.hpp:152
Describe a linear system.
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.