| 1 |
// Copyright (C) 2008-2011 Anders Logg and Garth N. Wells |
| 2 |
// |
| 3 |
// This file is part of DOLFIN. |
| 4 |
// |
| 5 |
// DOLFIN is free software: you can redistribute it and/or modify |
| 6 |
// it under the terms of the GNU Lesser General Public License as published by |
| 7 |
// the Free Software Foundation, either version 3 of the License, or |
| 8 |
// (at your option) any later version. |
| 9 |
// |
| 10 |
// DOLFIN is distributed in the hope that it will be useful, |
| 11 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
// GNU Lesser General Public License for more details. |
| 14 |
// |
| 15 |
// You should have received a copy of the GNU Lesser General Public License |
| 16 |
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
// |
| 18 |
// Modified by Cecile Daversin-Catty, 2017. |
| 19 |
// |
| 20 |
// First added: 2017-07-21 |
| 21 |
// Last changed: 2017-07-21 |
| 22 |
|
| 23 |
#ifndef __MIXED_LINEAR_VARIATIONAL_SOLVER_H |
| 24 |
#define __MIXED_LINEAR_VARIATIONAL_SOLVER_H |
| 25 |
|
| 26 |
#include <dolfin/common/Variable.h> |
| 27 |
#include <dolfin/la/LUSolver.h> |
| 28 |
#include <dolfin/la/KrylovSolver.h> |
| 29 |
|
| 30 |
namespace dolfin |
| 31 |
{ |
| 32 |
|
| 33 |
// Forward declarations |
| 34 |
class MixedLinearVariationalProblem; |
| 35 |
class PETScNestMatrix; |
| 36 |
|
| 37 |
/// This class implements a solver for mixed linear variational problems. |
| 38 |
|
| 39 |
class MixedLinearVariationalSolver : public Variable |
| 40 |
{ |
| 41 |
public: |
| 42 |
typedef std::tuple<std::vector<std::shared_ptr<GenericMatrix>>, |
| 43 |
std::vector<std::shared_ptr<GenericVector>>, |
| 44 |
std::vector<std::shared_ptr<GenericVector>> > assembled_system_type; |
| 45 |
|
| 46 |
/// Create linear variational solver for given problem |
| 47 |
explicit MixedLinearVariationalSolver(); |
| 48 |
explicit MixedLinearVariationalSolver(std::shared_ptr<MixedLinearVariationalProblem> problem); |
| 49 |
|
| 50 |
/// Block-by-block assembly |
| 51 |
assembled_system_type assemble_system(); |
| 52 |
|
| 53 |
/// Solve variational problem |
| 54 |
void solve(); |
| 55 |
void solve(assembled_system_type assembled_system); |
| 56 |
|
| 57 |
/// Default parameter values |
| 58 |
static Parameters default_parameters() |
| 59 |
{ |
| 60 |
Parameters p("linear_variational_solver"); |
| 61 |
|
| 62 |
p.add("linear_solver", "default"); |
| 63 |
p.add("preconditioner", "default"); |
| 64 |
p.add("symmetric", false); |
| 65 |
|
| 66 |
p.add("print_rhs", false); |
| 67 |
p.add("print_matrix", false); |
| 68 |
p.add(LUSolver::default_parameters()); |
| 69 |
p.add(KrylovSolver::default_parameters()); |
| 70 |
|
| 71 |
return p; |
| 72 |
} |
| 73 |
|
| 74 |
private: |
| 75 |
|
| 76 |
// The linear problem |
| 77 |
std::shared_ptr<MixedLinearVariationalProblem> _problem; |
| 78 |
|
| 79 |
}; |
| 80 |
|
| 81 |
} |
| 82 |
|
| 83 |
#endif |