NEML2 2.1.0
Loading...
Searching...
No Matches
LinearSystem.h
1// Copyright 2024, UChicago Argonne, LLC
2// All Rights Reserved
3// Software Name: NEML2 -- the New Engineering material Model Library, version 2
4// By: Argonne National Laboratory
5// OPEN SOURCE LICENSE (MIT)
6//
7// Permission is hereby granted, free of charge, to any person obtaining a copy
8// of this software and associated documentation files (the "Software"), to deal
9// in the Software without restriction, including without limitation the rights
10// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11// copies of the Software, and to permit persons to whom the Software is
12// furnished to do so, subject to the following conditions:
13//
14// The above copyright notice and this permission notice shall be included in
15// all copies or substantial portions of the Software.
16//
17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23// THE SOFTWARE.
24
25#pragma once
26
27#include "neml2/equation_systems/AxisLayout.h"
28
29namespace neml2
30{
31struct AssembledVector;
32struct AssembledMatrix;
33
39{
40public:
41 LinearSystem() = default;
42 LinearSystem(const LinearSystem &) = default;
43 LinearSystem(LinearSystem &&) noexcept = default;
44 LinearSystem & operator=(const LinearSystem &) = default;
45 LinearSystem & operator=(LinearSystem &&) noexcept = default;
46 virtual ~LinearSystem() = default;
47
49 virtual void init();
50
52 virtual void set_u(const AssembledVector &) = 0;
54 virtual void set_g(const AssembledVector &) = 0;
56 virtual AssembledVector u() const = 0;
58 virtual AssembledVector g() const = 0;
59
61 virtual void u_changed();
63 virtual void g_changed();
64
75
82
83protected:
85 virtual std::shared_ptr<AxisLayout> setup_ulayout() = 0;
87 virtual std::shared_ptr<AxisLayout> setup_glayout() = 0;
89 virtual std::shared_ptr<AxisLayout> setup_blayout() = 0;
90
99
109 virtual void pre_assemble(bool A, bool B, bool b);
110
121 virtual void post_assemble(bool A, bool B, bool b);
122
124 bool _A_up_to_date = false;
126 bool _B_up_to_date = false;
128 bool _b_up_to_date = false;
129
131 std::shared_ptr<AxisLayout> _ulayout;
133 std::shared_ptr<AxisLayout> _glayout;
135 std::shared_ptr<AxisLayout> _blayout;
136};
137
138} // namespace neml2
LinearSystem(const LinearSystem &)=default
virtual AssembledVector g() const =0
Get the given variables g from the current step.
virtual void post_assemble(bool A, bool B, bool b)
Callback after assembly to perform.
AxisLayout ulayout() const
Get the unknown-variable layout.
bool _A_up_to_date
Flag indicating if the system matrix is up to date. Setters invalidate this.
Definition LinearSystem.h:124
std::shared_ptr< AxisLayout > _ulayout
Layout of unknowns, partitioned by variable groups.
Definition LinearSystem.h:131
virtual void set_g(const AssembledVector &)=0
Set the given variables g from the current step.
virtual void set_u(const AssembledVector &)=0
Set the unknown u.
bool _B_up_to_date
Flag indicating if the auxiliary matrix is up to date. Setters invalidate this.
Definition LinearSystem.h:126
std::tuple< AssembledMatrix, AssembledMatrix, AssembledVector > A_and_B_and_b()
Assemble the auxiliary matrix B = dr/dg along with A and b.
virtual std::shared_ptr< AxisLayout > setup_blayout()=0
Setup the RHS variable layout.
std::tuple< AssembledMatrix, AssembledVector > A_and_b()
Assemble and return the right-hand side and operator.
std::shared_ptr< AxisLayout > _blayout
Layout of RHS variables, partitioned by variable groups.
Definition LinearSystem.h:135
virtual void init()
Setup axis layouts.
virtual AssembledVector u() const =0
Get the unknown u.
virtual void assemble(AssembledMatrix *A, AssembledMatrix *B, AssembledVector *b)=0
Compute the operator and right-hand side.
virtual void u_changed()
Trigger when unknown variables changed.
AssembledMatrix A()
Assemble and return the operator, A.
LinearSystem(LinearSystem &&) noexcept=default
LinearSystem()=default
bool _b_up_to_date
Flag indicating if the system RHS is up to date. Setters invalidate this.
Definition LinearSystem.h:128
std::shared_ptr< AxisLayout > _glayout
Layout of given variables.
Definition LinearSystem.h:133
virtual std::shared_ptr< AxisLayout > setup_glayout()=0
Setup the given variable layout.
AxisLayout blayout() const
Get the RHS variable layout.
AssembledVector b()
Assemble and return the right-hand side, b.
virtual void pre_assemble(bool A, bool B, bool b)
Callback before assembly to perform.
virtual void g_changed()
Trigger when given variables changed.
AxisLayout glayout() const
Get the given-variable layout.
std::tuple< AssembledMatrix, AssembledMatrix > A_and_B()
Assemble the auxiliary matrix B = dr/dg along with A.
virtual std::shared_ptr< AxisLayout > setup_ulayout()=0
Setup the unknown layout, partitioned by variable group.
Definition DiagnosticsInterface.h:31
Dense representation of a matrix assembled from a 2D-list of tensors and their layout.
Definition AssembledMatrix.h:37
Dense representation of a tensor assembled from a list of tensors and their layout.
Definition AssembledVector.h:36
Definition AxisLayout.h:34