NEML2 2.1.0
Loading...
Searching...
No Matches
ModelNonlinearSystem.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/EquationSystem.h"
28#include "neml2/equation_systems/NonlinearSystem.h"
29#include "neml2/equation_systems/SparseTensorList.h"
30#include "neml2/models/ParameterStore.h"
31#include "neml2/models/BufferStore.h"
32
33namespace neml2
34{
35class Model;
36
39 public NonlinearSystem,
40 public ParameterStore,
41 public BufferStore
42{
43public:
45
47
48 const std::shared_ptr<Model> & model_ptr() const { return _model; }
49 const Model & model() const { return *_model; }
50 Model & model() { return *_model; }
51
52 void setup() override;
53
54 void to(const TensorOptions &) override;
55
56 void set_u(const SparseTensorList &) override;
57 void set_g(const SparseTensorList &) override;
58
59 SparseTensorList u() const override;
60 SparseTensorList g() const override;
61
62protected:
63 std::vector<LabeledAxisAccessor> setup_umap() override;
64 std::vector<TensorShape> setup_intmd_ulayout() override;
65 std::vector<TensorShape> setup_ulayout() override;
66
67 std::vector<LabeledAxisAccessor> setup_bmap() override;
68 std::vector<TensorShape> setup_intmd_blayout() override;
69 std::vector<TensorShape> setup_blayout() override;
70
71 std::vector<LabeledAxisAccessor> setup_gmap() override;
72 std::vector<TensorShape> setup_intmd_glayout() override;
73 std::vector<TensorShape> setup_glayout() override;
74
76 void pre_assemble(bool A, bool B, bool b) override;
77 void post_assemble(bool A, bool B, bool b) override;
78
79private:
80 std::shared_ptr<Model> _model;
81};
82
83} // namespace neml2
BufferStore(NEML2Object *object)
EquationSystem(const OptionSet &options)
SparseTensorList A()
Assemble and return the operator, A.
SparseTensorList b()
Assemble and return the right-hand side, b.
const Model & model() const
Definition ModelNonlinearSystem.h:49
void post_assemble(bool A, bool B, bool b) override
Callback after assembly to perform.
std::vector< TensorShape > setup_intmd_blayout() override
Setup the RHS intermediate layout.
std::vector< LabeledAxisAccessor > setup_umap() override
Setup the unknown map.
SparseTensorList u() const override
Get the unknown u.
void set_u(const SparseTensorList &) override
Set the unknown u.
std::vector< LabeledAxisAccessor > setup_bmap() override
Setup the RHS map.
std::vector< TensorShape > setup_intmd_glayout() override
Setup the given variable intermediate layout.
std::vector< TensorShape > setup_blayout() override
Setup the RHS layout.
void set_g(const SparseTensorList &) override
Set the given variables g from the current step.
SparseTensorList g() const override
Get the given variables g from the current step.
void to(const TensorOptions &) override
Change the device and dtype of the equation system's internal data.
std::vector< TensorShape > setup_glayout() override
Setup the given variable base layout.
std::vector< TensorShape > setup_ulayout() override
Setup the unknown layout.
std::vector< LabeledAxisAccessor > setup_gmap() override
Setup the given variable map.
void assemble(SparseTensorList *A, SparseTensorList *B, SparseTensorList *b) override
Compute the operator and right-hand side.
void setup() override
Setup this object.
std::vector< TensorShape > setup_intmd_ulayout() override
Setup the unknown intermediate layout.
static OptionSet expected_options()
ModelNonlinearSystem(const OptionSet &options)
void pre_assemble(bool A, bool B, bool b) override
Callback before assembly to perform.
Model & model()
Definition ModelNonlinearSystem.h:50
const std::shared_ptr< Model > & model_ptr() const
Definition ModelNonlinearSystem.h:48
The base class for all constitutive models.
Definition Model.h:83
Definition of a nonlinear system of equations, r(u) = 0.
Definition NonlinearSystem.h:44
A custom map-like data structure. The keys are strings, and the values can be nonhomogeneously typed.
Definition OptionSet.h:52
ParameterStore(NEML2Object *object)
Definition DiagnosticsInterface.h:31
c10::TensorOptions TensorOptions
Definition types.h:66
Alias for a list of Tensors.
Definition SparseTensorList.h:42