LifeV
MonolithicBlockComposedDN.cpp
Go to the documentation of this file.
1 /* -*- mode: c++ -*- */
2 //@HEADER
3 /*
4 *******************************************************************************
5 
6  Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
7  Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
8 
9  This file is part of LifeV.
10 
11  LifeV is free software; you can redistribute it and/or modify
12  it under the terms of the GNU Lesser General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  LifeV is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  Lesser General Public License for more details.
20 
21  You should have received a copy of the GNU Lesser General Public License
22  along with LifeV. If not, see <http://www.gnu.org/licenses/>.
23 
24 *******************************************************************************
25 */
26 //@HEADER
27 
28 #include <lifev/core/LifeV.hpp>
29 
30 #include <lifev/fsi/solver/MonolithicBlockComposedDN.hpp>
31 
32 namespace LifeV
33 {
34 
35 
36 // ===================================================
37 //! Public Methods
38 // ===================================================
39 
40 void MonolithicBlockComposedDN::setDataFromGetPot ( const GetPot& dataFile,
41  const std::string& section )
42 {
43  M_blockPrecs->setDataFromGetPot ( dataFile, section );
44 }
45 
46 
47 int MonolithicBlockComposedDN::solveSystem ( const vector_Type& rhs, vector_Type& step, solverPtr_Type& linearSolver )
48 {
49  assert (M_blockPrecs.get() );
50 
51  if (!set() )
52  {
53  for (UInt k = 0; k < M_blocks.size(); ++k)
54  {
55  push_back_precs (M_blocks[ (*M_blockReordering) [k]]);
56  }
57  }
58  else
59  {
60  for (UInt k = 0; k < M_blocks.size(); ++k)
61  {
62  if (M_recompute[ (*M_blockReordering) [k]])
63  {
64  linearSolver->displayer()->leaderPrint (" M- Computing preconditioner factor: ", k, "\n");
65  replace_precs (M_blocks[ (*M_blockReordering) [k]], k);
66  }
67  else
68  {
69  linearSolver->displayer()->leaderPrint (" M- Reusing preconditioner factor: ", k, "\n");
70  }
71  }
72  }
73  return linearSolver->solveSystem (rhs, step, std::static_pointer_cast<Preconditioner> (M_blockPrecs) );
74 }
75 
76 
77 void MonolithicBlockComposedDN::coupler (mapPtr_Type& map,
78  const std::map<ID, ID>& locDofMap,
79  const vectorPtr_Type& numerationInterface,
80  const Real& timeStep,
81  const Real& coefficient,
82  const Real& rescaleFactor)
83 {
84  UInt totalDofs ( map->map (Unique)->NumGlobalElements() );
85  UInt solidAndFluid (M_offset[solid] + M_FESpace[solid]->map().map (Unique)->NumGlobalElements() );
86 
87  matrixPtr_Type coupling (new matrix_Type (*map) );
88  couplingMatrix ( coupling, (*M_couplingFlags) [solid], M_FESpace, M_offset, locDofMap, numerationInterface, timeStep, 1., coefficient, rescaleFactor);
89  coupling->insertValueDiagonal ( 1., M_offset[fluid], M_offset[solid] );
90  coupling->insertValueDiagonal ( 1., solidAndFluid, totalDofs );
91  M_coupling.push_back (coupling);
92 
93  coupling.reset (new matrix_Type (*map) );
94  couplingMatrix ( coupling, (*M_couplingFlags) [fluid], M_FESpace, M_offset, locDofMap, numerationInterface, timeStep, 1., coefficient, rescaleFactor);
95  coupling->insertValueDiagonal ( 1. , M_offset[solid], solidAndFluid );
96  coupling->insertValueDiagonal ( 1. , solidAndFluid + nDimensions * numerationInterface->map().map (Unique)->NumGlobalElements(), totalDofs );
97  M_coupling.push_back (coupling);
98 
99 }
100 
101 void MonolithicBlockComposedDN::push_back_precs ( matrixPtr_Type& Mat )
102 {
103  M_blockPrecs->push_back (Mat);
104 }
105 
106 
107 // ===================================================
108 //! Protected Methods
109 // ===================================================
110 
111 
112 void MonolithicBlockComposedDN::replace_precs ( matrixPtr_Type& Mat, UInt position )
113 {
114  M_blockPrecs->replace (Mat, position);
115 }
116 
117 
118 } // Namespace LifeV
void updateInverseJacobian(const UInt &iQuadPt)
double Real
Generic real data.
Definition: LifeV.hpp:175
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191