hp-FEM
Adaptive hp-FEM suite for nano-optics
Loading...
Searching...
No Matches
kept_factorisation.hpp
Go to the documentation of this file.
1#pragma once
18
19#include <memory>
20#include <optional>
21#include <vector>
22
24#include "hpfem/core/types.hpp"
27
28namespace hpfem::physics {
29
33 public:
35 struct Parts {
36 std::unique_ptr<solvers::LinearSolver> solver;
39 std::vector<Index> selection;
40 std::optional<fespace::Constraints> constraints;
42 std::vector<Index> dirichlet;
44 std::shared_ptr<const assembly::StaticCondensation> condensation;
45 };
46
48 explicit KeptFactorisation(Parts parts);
49
53 [[nodiscard]] Vector solve(const Vector& load) const;
55 [[nodiscard]] Matrix solve_many(const Matrix& loads) const;
63 [[nodiscard]] Matrix solve_many(const Matrix& loads, const Matrix& system_loads) const;
67 [[nodiscard]] Vector solve_adjoint(const Vector& functional) const;
69 [[nodiscard]] Matrix solve_adjoint_many(const Matrix& functionals) const;
70
72 [[nodiscard]] Index num_dofs() const noexcept { return num_dofs_; }
74 [[nodiscard]] Index size() const noexcept { return solver_->size(); }
75 [[nodiscard]] const solvers::LinearSolver& solver() const noexcept { return *solver_; }
76
77 private:
78 [[nodiscard]] Matrix to_system(const Matrix& full, bool transposed,
79 const Matrix* system_loads = nullptr) const;
80 [[nodiscard]] Matrix from_system(const Matrix& reduced, const Matrix& full,
81 bool transposed) const;
82
83 std::unique_ptr<solvers::LinearSolver> solver_;
84 Index num_dofs_;
85 std::vector<Index> selection_;
86 std::optional<SparseMatrix> prolongation_;
87 std::optional<SparseMatrix> test_prolongation_;
88 std::vector<Index> dirichlet_;
89 std::shared_ptr<const assembly::StaticCondensation> condensation_;
90};
91
92} // namespace hpfem::physics
Definition kept_factorisation.hpp:32
Matrix solve_adjoint_many(const Matrix &functionals) const
Several functionals at once (one per column, one multi-rhs transposed solve).
Index size() const noexcept
Unknowns of the factorised system.
Definition kept_factorisation.hpp:74
Matrix solve_many(const Matrix &loads) const
Several loads at once (one per column, one multi-rhs solve).
Matrix solve_many(const Matrix &loads, const Matrix &system_loads) const
Vector solve_adjoint(const Vector &functional) const
Vector solve(const Vector &load) const
Index num_dofs() const noexcept
Size of the full vectors.
Definition kept_factorisation.hpp:72
const solvers::LinearSolver & solver() const noexcept
Definition kept_factorisation.hpp:75
Factorise once, solve for many right-hand sides.
Definition linear_solver.hpp:17
Definition absorption.hpp:21
Eigen::Matrix< Complex, Eigen::Dynamic, Eigen::Dynamic > Matrix
Definition types.hpp:22
std::int64_t Index
global indices (DoFs, entities)
Definition types.hpp:17
Eigen::Matrix< Complex, Eigen::Dynamic, 1 > Vector
Definition types.hpp:20
What the solve hands over.
Definition kept_factorisation.hpp:35
Index num_dofs
Definition kept_factorisation.hpp:37
std::shared_ptr< const assembly::StaticCondensation > condensation
Interior elimination of the assembly (null without condensation).
Definition kept_factorisation.hpp:44
std::unique_ptr< solvers::LinearSolver > solver
factorised system matrix
Definition kept_factorisation.hpp:36
std::optional< fespace::Constraints > constraints
Definition kept_factorisation.hpp:40
std::vector< Index > selection
Full indices of the unknowns before the constraints, in system order; empty: all.
Definition kept_factorisation.hpp:39
std::vector< Index > dirichlet
Unknowns of the factorised system whose (homogeneous) data was eliminated.
Definition kept_factorisation.hpp:42