IgANet
IGAnets - Isogeometric Analysis Networks
Loading...
Searching...
No Matches
igasolver.hpp
Go to the documentation of this file.
1
15#pragma once
16
21
22namespace iganet {
23
27template <typename Inputs, typename Outputs, typename CollPts = void>
28class IgASolver : public IgABase<Inputs, Outputs, CollPts>,
30
31protected:
33 torch::Tensor lhs_;
34
36 torch::Tensor rhs_;
37
38public:
41
43 using Base::IgABase;
44
47 inline constexpr const auto &lhs() const { return lhs_; }
48
51 inline constexpr auto &lhs() { return lhs_; }
52
55 inline constexpr const auto &rhs() const { return rhs_; }
56
59 inline constexpr auto &rhs() { return rhs_; }
60
62 virtual void init() = 0;
63
65 virtual void assemble() {
68 }
69
71 virtual void assembleLhs() = 0;
72
74 virtual void assembleRhs() = 0;
75
78 torch::Tensor solve() const {
79 auto [x, iter, res] = utils::bicgstab(lhs(), rhs());
80 return x;
81 }
82
85 inline void pretty_print(std::ostream &os) const noexcept override {
86 os << name() << "(\n";
87
88 os << "inputs[" << Base::ninputs() << "] = (";
89 std::apply([&os](const auto &...elems) { ((os << elems << "\n"), ...); },
90 Base::inputs());
91 os << ")";
92
93 os << "outputs [" << Base::noutputs() << "]= (";
94 std::apply([&os](const auto &...elems) { ((os << elems << "\n"), ...); },
95 Base::inputs());
96 os << ")";
97
98 os << "collPts [" << Base::ncollPts() << "]= (";
99 std::apply([&os](const auto &...elems) { ((os << elems << "\n"), ...); },
100 Base::collPts());
101 os << ")";
102 }
103};
104
112template <typename Inputs, typename Outputs, typename CollPts>
113inline std::ostream &
114operator<<(std::ostream &os,
116 obj.pretty_print(os);
117 return os;
118}
119
120} // namespace iganet
Boundary treatment.
IgA base class.
Definition iganet.hpp:51
IgA solver.
Definition igasolver.hpp:29
torch::Tensor lhs_
Left-hand side tensor.
Definition igasolver.hpp:33
torch::Tensor rhs_
Right-hand side tensor.
Definition igasolver.hpp:36
virtual void assembleLhs()=0
Assembles the left-hand side of the solver.
constexpr const auto & rhs() const
Returns a constant reference to the right-hand side object.
Definition igasolver.hpp:55
virtual void assembleRhs()=0
Assembles the right-hand side of the solver.
virtual void assemble()
Assembles the solver.
Definition igasolver.hpp:65
torch::Tensor solve() const
Computes the solution vector.
Definition igasolver.hpp:78
constexpr auto & rhs()
Returns a non-constant reference to the right-hand side object.
Definition igasolver.hpp:59
constexpr const auto & lhs() const
Returns a constant reference to the left-hand side object.
Definition igasolver.hpp:47
constexpr auto & lhs()
Returns a non-constant reference to the left-hand side object.
Definition igasolver.hpp:51
virtual void init()=0
Initializes the solver.
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the IgASolver object.
Definition igasolver.hpp:85
Full qualified name descriptor.
Definition fqn.hpp:22
virtual const std::string & name() const noexcept
Returns the full qualified name of the object.
Definition fqn.hpp:28
Function spaces.
IgANet base.
auto bicgstab(const torch::Tensor &A, const torch::Tensor b, int max_iter=1000, double tol=1e-10)
Solves the linear system A * x = b using the Bi-Conjugate Gradient Stabilized (BiCGStab) method.
Definition solver.hpp:323
Definition core.hpp:73
std::ostream & operator<<(std::ostream &os, const MemoryDebugger< id > &obj)
Prints a memory debugger object.
Definition memory.hpp:145
Solver utility functions.