Alien  1.3.0
Developer documentation
Loading...
Searching...
No Matches
LinearSolver.h
Go to the documentation of this file.
1/*
2 * Copyright 2020 IFPEN-CEA
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * SPDX-License-Identifier: Apache-2.0
17 */
18
23#pragma once
24
25#include <alien/utils/Precomp.h>
26
27#include <memory>
28
29#include <arccore/base/NotImplementedException.h>
30#include <arccore/base/TraceInfo.h>
31
32#include <alien/core/backend/BackEnd.h>
33#include <alien/core/backend/IInternalLinearSolverT.h>
34
36
37#include <alien/expression/solver/SolverStater.h>
38/*---------------------------------------------------------------------------*/
39/*---------------------------------------------------------------------------*/
40
41namespace Alien
42{
43
44/*---------------------------------------------------------------------------*/
45/*---------------------------------------------------------------------------*/
46
47class Space;
48class IVector;
49class IMatrix;
50
51/*---------------------------------------------------------------------------*/
52/*---------------------------------------------------------------------------*/
53
62template <class Tag>
64{
65 public:
68
69 public:
78 template <typename... T>
79 LinearSolver(T... args)
80 : m_solver(AlgebraTraits<Tag>::solver_factory(args...))
81 , m_stater(m_solver.get())
82 {}
83
85 virtual ~LinearSolver();
86
91 Arccore::String getBackEndName() const;
92
94 void init();
95
97 void end();
98
106 void updateParallelMng(Arccore::MessagePassing::IMessagePassingMng* pm);
107
115 bool solve(const IMatrix& A, const IVector& b, IVector& x);
116
125 const SolverStat& getSolverStat() const;
126
131 bool hasParallelSupport() const;
132
137 const SolverStatus& getStatus() const;
138
143 std::shared_ptr<ILinearAlgebra> algebra() const;
144
150
160 virtual void setNullSpaceConstantOption([[maybe_unused]] bool flag)
161 {
162 throw NotImplementedException(A_FUNCINFO);
163 }
164
165 private:
167 std::unique_ptr<KernelSolver> m_solver;
169};
170
171/*---------------------------------------------------------------------------*/
172/*---------------------------------------------------------------------------*/
173
174} // namespace Alien
175
176/*---------------------------------------------------------------------------*/
177/*---------------------------------------------------------------------------*/
ILinearSolver.h.
ILinearSolver()
Constructor.
Interface for all matrices.
Definition IMatrix.h:51
Interface for all vectors.
Definition IVector.h:51
void init()
Initialize the linear solver.
const SolverStatus & getStatus() const
Get solver resolution status.
std::unique_ptr< KernelSolver > m_solver
The linear solver kernel.
virtual ~LinearSolver()
Free resources.
void updateParallelMng(Arccore::MessagePassing::IMessagePassingMng *pm)
update parallel_mng, required for redistribution For some solver libraries, Solver is kind of a globa...
Arccore::String getBackEndName() const
Get package back end name.
LinearSolver(T... args)
Creates a linear solver.
KernelSolver * implem()
Get kernel solver implementation.
bool hasParallelSupport() const
Indicates if the kernel is parallel.
virtual void setNullSpaceConstantOption(bool flag)
Option to add an extra-equation.
void end()
Finalize the linear solver.
std::shared_ptr< ILinearAlgebra > algebra() const
Get compatible linear algebra.
const SolverStat & getSolverStat() const
Get statistics on the solve phase.
AlgebraTraits< Tag >::solver_type KernelSolver
The type of the solver.
bool solve(const IMatrix &A, const IVector &b, IVector &x)
Solve the linear system A * x = b.
Implementation of an algebraic space.
Definition Space.h:47
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17
Structure to store a solver status.