svMultiPhysics
All Classes Namespaces Files Functions Variables Pages
LinearAlgebra.h
1/* Copyright (c) Stanford University, The Regents of the University of California, and others.
2 *
3 * All Rights Reserved.
4 *
5 * See Copyright-SimVascular.txt for additional details.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining
8 * a copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sublicense, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject
13 * to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
19 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
22 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#ifndef LINEAR_ALGEBRA_H
32#define LINEAR_ALGEBRA_H
33
34#include "ComMod.h"
35#include "consts.h"
36
37/// @brief The LinearAlgebra class provides an abstract interface to linear algebra
38/// frameworks: FSILS, Trilinos, PETSc, etc.
39//
41 public:
42 static const std::map<std::string, consts::LinearAlgebraType> name_to_type;
43 static const std::map<consts::LinearAlgebraType, std::string> type_to_name;
44 static void check_equation_compatibility(const consts::EquationType eq_phys,
45 const consts::LinearAlgebraType lin_alg_type, const consts::LinearAlgebraType assembly_type);
46
48 virtual ~LinearAlgebra() { };
49 virtual void alloc(ComMod& com_mod, eqType& lEq) = 0;
50 virtual void assemble(ComMod& com_mod, const int num_elem_nodes, const Vector<int>& eqN,
51 const Array3<double>& lK, const Array<double>& lR) = 0;
52 virtual void check_options(const consts::PreconditionerType prec_cond_type, const consts::LinearAlgebraType assembly_type) = 0;
53 virtual void initialize(ComMod& com_mod, eqType& lEq) = 0;
54 virtual void set_assembly(consts::LinearAlgebraType assembly_type) = 0;
55 virtual void set_preconditioner(consts::PreconditionerType prec_type) = 0;
56 virtual void solve(ComMod& com_mod, eqType& lEq, const Vector<int>& incL, const Vector<double>& res) = 0;
57
58 virtual consts::LinearAlgebraType get_interface_type() { return interface_type; }
59
60 consts::LinearAlgebraType interface_type = consts::LinearAlgebraType::none;
61 consts::LinearAlgebraType assembly_type = consts::LinearAlgebraType::none;
62 consts::PreconditionerType preconditioner_type = consts::PreconditionerType::PREC_NONE;
63};
64
65/// @brief The LinearAlgebraFactory class provides a factory used to create objects derived from LinearAlgebra.
67 public:
68 static LinearAlgebra* create_interface(consts::LinearAlgebraType interface_type);
69};
70
71
72#endif
73
The Array3 template class implements a simple interface to 3D arrays.
Definition Array3.h:52
The ComMod class duplicates the data structures in the Fortran COMMOD module defined in MOD....
Definition ComMod.h:1354
The LinearAlgebraFactory class provides a factory used to create objects derived from LinearAlgebra.
Definition LinearAlgebra.h:66
static LinearAlgebra * create_interface(consts::LinearAlgebraType interface_type)
Create objects derived from LinearAlgebra.
Definition LinearAlgebra.cpp:72
The LinearAlgebra class provides an abstract interface to linear algebra frameworks: FSILS,...
Definition LinearAlgebra.h:40
static void check_equation_compatibility(const consts::EquationType eq_phys, const consts::LinearAlgebraType lin_alg_type, const consts::LinearAlgebraType assembly_type)
Check that equation physics is compatible with LinearAlgebra type.
Definition LinearAlgebra.cpp:52
The Vector template class is used for storing int and double data.
Definition Vector.h:50
Equation type.
Definition ComMod.h:1022