Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GlobalLinSysXxt.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File GlobalLinSysXxt.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: GlobalLinSysXxt definition
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
38 
39 namespace Nektar
40 {
41  namespace MultiRegions
42  {
43  /**
44  * @class GlobalLinSysXxt
45  *
46  * Solves a linear system using direct methods.
47  */
48 
49  /// Constructor for full direct matrix solve.
51  const GlobalLinSysKey &pKey,
52  const boost::weak_ptr<ExpList> &pExp,
53  const boost::shared_ptr<AssemblyMap>
54  &pLocToGloMap)
55  : GlobalLinSys(pKey, pExp, pLocToGloMap)
56  {
57  m_crsData = 0;
58  }
59 
61  {
63  }
64 
65  /// Solve the linear system for given input and output vectors.
67  const int pNumRows,
68  const Array<OneD,const NekDouble> &pInput,
69  Array<OneD, NekDouble> &pOutput,
70  const AssemblyMapSharedPtr &pLocToGloMap,
71  const int pNumDir)
72  {
73  int nLocal = m_map.num_elements();
74  Array<OneD, NekDouble> vLocalIn(nLocal, 0.0);
75  Array<OneD, NekDouble> vLocalOut(nLocal, 0.0);
76  GlobalToLocalNoSign(pInput, vLocalIn);
77  Xxt::Solve(vLocalOut, m_crsData, vLocalIn);
78  LocalToGlobalNoSign(vLocalOut, pOutput);
79  }
80 
83  {
84  Vmath::Gathr(m_map.num_elements(), m_locToGloSignMult.get(), global.get(), m_map.get(), local.get());
85  }
86 
88  Array<OneD, NekDouble> &global)
89  {
90  Vmath::Scatr(m_map.num_elements(), local.get(), m_map.get(), global.get());
91  }
92 
93  }
94 }
95 
void Gathr(int n, const T *x, const int *y, T *z)
Gather vector z[i] = x[y[i]].
Definition: Vmath.cpp:630
boost::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
Definition: AssemblyMap.h:53
void LocalToGlobalNoSign(const Array< OneD, const NekDouble > &local, Array< OneD, NekDouble > &global)
static void Solve(Nektar::Array< OneD, NekDouble > pX, struct crs_data *pCrs, Nektar::Array< OneD, NekDouble > pB)
Solve the matrix system for a given input vector b.
Definition: Xxt.hpp:185
void Scatr(int n, const T *x, const int *y, T *z)
Scatter vector z[y[i]] = x[i].
Definition: Vmath.cpp:659
Describe a linear system.
void GlobalToLocalNoSign(const Array< OneD, const NekDouble > &global, Array< OneD, NekDouble > &local)
A global linear system.
Definition: GlobalLinSys.h:74
static void Finalise(crs_data *pCrs)
Deallocates the crs mapping data.
Definition: Xxt.hpp:201
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 the linear system for given input and output vectors.
GlobalLinSysXxt(const GlobalLinSysKey &pKey, const boost::weak_ptr< ExpList > &pExp, const boost::shared_ptr< AssemblyMap > &pLocToGloMap)
Constructor for full direct matrix solve.
Array< OneD, NekDouble > m_locToGloSignMult