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