Nektar++
GlobalLinSys.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: GlobalLinSys.h
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: GlobalLinSys header
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 #ifndef NEKTAR_LIB_MULTIREGIONS_GLOBALLINSYS_H
36 #define NEKTAR_LIB_MULTIREGIONS_GLOBALLINSYS_H
37 
41 #include <boost/enable_shared_from_this.hpp>
42 #include <MultiRegions/ExpList.h>
44 
45 namespace Nektar
46 {
47  namespace MultiRegions
48  {
49  // Forward declarations
50  class ExpList;
51  class GlobalLinSys;
52 
53  /// Pointer to a GlobalLinSys object.
54  typedef boost::shared_ptr<GlobalLinSys> GlobalLinSysSharedPtr;
55  /// Mapping between GlobalLinSys objects and their associated keys.
56  typedef map<GlobalLinSysKey,GlobalLinSysSharedPtr> GlobalLinSysMap;
57  /// Pointer to a GlobalLinSys/key map.
58  typedef boost::shared_ptr<GlobalLinSysMap> GlobalLinSysMapShPtr;
59 
60  /// Datatype of the NekFactory used to instantiate classes derived from
61  /// the EquationSystem class.
62  typedef LibUtilities::NekFactory< std::string, GlobalLinSys,
63  const GlobalLinSysKey&,
64  const boost::weak_ptr<ExpList>&,
65  const boost::shared_ptr<AssemblyMap>& > GlobalLinSysFactory;
66  GlobalLinSysFactory& GetGlobalLinSysFactory();
67 
68 
69  /// A global linear system.
70  class GlobalLinSys: public boost::enable_shared_from_this<GlobalLinSys>
71  {
72  public:
73  /// Constructor for full direct matrix solve.
75  const GlobalLinSysKey &pKey,
76  const boost::weak_ptr<ExpList> &pExpList,
77  const boost::shared_ptr<AssemblyMap> &pLocToGloMap);
78 
80  virtual ~GlobalLinSys() {}
81 
82  /// Returns the key associated with the system.
83  const inline GlobalLinSysKey &GetKey(void) const;
84 
85  //Returns the local matrix associated with the system
86  const inline boost::weak_ptr<ExpList> &GetLocMat(void) const;
87 
88  inline void InitObject();
89  inline void Initialise(
90  const boost::shared_ptr<AssemblyMap>& pLocToGloMap);
91 
92  /// Solve the linear system for given input and output vectors
93  /// using a specified local to global map.
95  inline void Solve(
98  const AssemblyMapSharedPtr &locToGloMap,
99  const Array<OneD, const NekDouble> &dirForcing
101 
102  /// Returns a shared pointer to the current object.
103  boost::shared_ptr<GlobalLinSys> GetSharedThisPtr()
104  {
105  return shared_from_this();
106  }
107 
108  inline int GetNumBlocks ();
109  inline DNekScalMatSharedPtr GetBlock (unsigned int n);
110  inline DNekScalBlkMatSharedPtr GetStaticCondBlock(unsigned int n);
111  inline void DropStaticCondBlock(unsigned int n);
112 
113  /// Solve the linear system for given input and output vectors.
114  inline void SolveLinearSystem(
115  const int pNumRows,
116  const Array<OneD,const NekDouble> &pInput,
117  Array<OneD, NekDouble> &pOutput,
118  const AssemblyMapSharedPtr &locToGloMap,
119  const int pNumDir = 0);
120 
121  protected:
122  /// Key associated with this linear system.
123  const GlobalLinSysKey m_linSysKey;
124  /// Local Matrix System
125  const boost::weak_ptr<ExpList> m_expList;
126  /// Robin boundary info
127  const map<int, RobinBCInfoSharedPtr> m_robinBCInfo;
128 
129  virtual int v_GetNumBlocks ();
130  virtual DNekScalMatSharedPtr v_GetBlock (unsigned int n);
131  virtual DNekScalBlkMatSharedPtr v_GetStaticCondBlock(unsigned int n);
132  virtual void v_DropStaticCondBlock(unsigned int n);
133 
134  private:
135  /// Solve a linear system based on mapping.
136  virtual void v_Solve(
139  const AssemblyMapSharedPtr &locToGloMap,
140  const Array<OneD, const NekDouble> &dirForcing
141  = NullNekDouble1DArray) = 0;
142 
143  /// Solve a basic matrix system.
144  virtual void v_SolveLinearSystem(
145  const int pNumRows,
146  const Array<OneD,const NekDouble> &pInput,
147  Array<OneD, NekDouble> &pOutput,
148  const AssemblyMapSharedPtr &locToGloMap,
149  const int pNumDir) = 0;
150 
151  virtual void v_InitObject();
152  virtual void v_Initialise(
153  const boost::shared_ptr<AssemblyMap>& pLocToGloMap);
154 
155  static std::string lookupIds[];
156  static std::string def;
157  };
158 
159 
160  /**
161  *
162  */
163  const inline GlobalLinSysKey &GlobalLinSys::GetKey(void) const
164  {
165  return m_linSysKey;
166  }
167 
168  /**
169  *
170  */
171  const inline boost::weak_ptr<ExpList> &GlobalLinSys::GetLocMat(void) const
172  {
173  return m_expList;
174  }
175 
176 
177  /**
178  *
179  */
180  inline void GlobalLinSys::Solve(
183  const AssemblyMapSharedPtr &locToGloMap,
184  const Array<OneD, const NekDouble> &dirForcing)
185  {
186  v_Solve(in,out,locToGloMap,dirForcing);
187  }
188 
189 
190  /**
191  *
192  */
194  const int pNumRows,
195  const Array<OneD,const NekDouble> &pInput,
196  Array<OneD, NekDouble> &pOutput,
197  const AssemblyMapSharedPtr &locToGloMap,
198  const int pNumDir)
199  {
200  v_SolveLinearSystem(pNumRows, pInput, pOutput, locToGloMap, pNumDir);
201  }
202 
204  {
205  v_InitObject();
206  }
207 
209  const boost::shared_ptr<AssemblyMap>& pLocToGloMap)
210  {
211  v_Initialise(pLocToGloMap);
212  }
213 
215  {
216  return v_GetBlock(n);
217  }
218 
220  {
221  return v_GetStaticCondBlock(n);
222  }
223 
224  inline void GlobalLinSys::DropStaticCondBlock(unsigned int n)
225  {
226  return v_DropStaticCondBlock(n);
227  }
228 
230  {
231  return v_GetNumBlocks();
232  }
233  } //end of namespace
234 } //end of namespace
235 
236 #endif
LibUtilities::NekFactory< std::string, GlobalLinSys, const GlobalLinSysKey &, const boost::weak_ptr< ExpList > &, const boost::shared_ptr< AssemblyMap > & > GlobalLinSysFactory
Datatype of the NekFactory used to instantiate classes derived from the EquationSystem class...
Definition: GlobalLinSys.h:65
const GlobalLinSysKey & GetKey(void) const
Returns the key associated with the system.
Definition: GlobalLinSys.h:163
static Array< OneD, NekDouble > NullNekDouble1DArray
boost::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
Definition: AssemblyMap.h:53
virtual void v_SolveLinearSystem(const int pNumRows, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const AssemblyMapSharedPtr &locToGloMap, const int pNumDir)=0
Solve a basic matrix system.
void SolveLinearSystem(const int pNumRows, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const AssemblyMapSharedPtr &locToGloMap, const int pNumDir=0)
Solve the linear system for given input and output vectors.
Definition: GlobalLinSys.h:193
map< GlobalLinSysKey, GlobalLinSysSharedPtr > GlobalLinSysMap
Mapping between GlobalLinSys objects and their associated keys.
Definition: GlobalLinSys.h:56
#define MULTI_REGIONS_EXPORT
void DropStaticCondBlock(unsigned int n)
Definition: GlobalLinSys.h:224
void Initialise(const boost::shared_ptr< AssemblyMap > &pLocToGloMap)
Definition: GlobalLinSys.h:208
virtual DNekScalBlkMatSharedPtr v_GetStaticCondBlock(unsigned int n)
Retrieves a the static condensation block matrices from n-th expansion using the matrix key provided ...
boost::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
virtual void v_Initialise(const boost::shared_ptr< AssemblyMap > &pLocToGloMap)
DNekScalMatSharedPtr GetBlock(unsigned int n)
Definition: GlobalLinSys.h:214
virtual void v_Solve(const Array< OneD, const NekDouble > &in, Array< OneD, NekDouble > &out, const AssemblyMapSharedPtr &locToGloMap, const Array< OneD, const NekDouble > &dirForcing=NullNekDouble1DArray)=0
Solve a linear system based on mapping.
virtual DNekScalMatSharedPtr v_GetBlock(unsigned int n)
Retrieves the block matrix from n-th expansion using the matrix key provided by the m_linSysKey...
const map< int, RobinBCInfoSharedPtr > m_robinBCInfo
Robin boundary info.
Definition: GlobalLinSys.h:127
boost::shared_ptr< GlobalLinSys > GetSharedThisPtr()
Returns a shared pointer to the current object.
Definition: GlobalLinSys.h:103
boost::shared_ptr< DNekScalBlkMat > DNekScalBlkMatSharedPtr
Definition: NekTypeDefs.hpp:74
boost::shared_ptr< GlobalLinSysMap > GlobalLinSysMapShPtr
Pointer to a GlobalLinSys/key map.
Definition: GlobalLinSys.h:58
virtual int v_GetNumBlocks()
Get the number of blocks in this system.
GlobalLinSys(const GlobalLinSysKey &pKey, const boost::weak_ptr< ExpList > &pExpList, const boost::shared_ptr< AssemblyMap > &pLocToGloMap)
Constructor for full direct matrix solve.
Describe a linear system.
const GlobalLinSysKey m_linSysKey
Key associated with this linear system.
Definition: GlobalLinSys.h:123
A global linear system.
Definition: GlobalLinSys.h:70
virtual void v_DropStaticCondBlock(unsigned int n)
Releases the static condensation block matrices from NekManager of n-th expansion using the matrix ke...
boost::shared_ptr< GlobalLinSys > GlobalLinSysSharedPtr
Pointer to a GlobalLinSys object.
Definition: GlobalLinSys.h:51
static std::string lookupIds[]
Definition: GlobalLinSys.h:155
DNekScalBlkMatSharedPtr GetStaticCondBlock(unsigned int n)
Definition: GlobalLinSys.h:219
void Solve(const Array< OneD, const NekDouble > &in, Array< OneD, NekDouble > &out, const AssemblyMapSharedPtr &locToGloMap, const Array< OneD, const NekDouble > &dirForcing=NullNekDouble1DArray)
Solve the linear system for given input and output vectors using a specified local to global map...
Definition: GlobalLinSys.h:180
GlobalLinSysFactory & GetGlobalLinSysFactory()
const boost::weak_ptr< ExpList > & GetLocMat(void) const
Definition: GlobalLinSys.h:171
Provides a generic Factory class.
Definition: NekFactory.hpp:116
const boost::weak_ptr< ExpList > m_expList
Local Matrix System.
Definition: GlobalLinSys.h:125