NEML2 1.4.0
Loading...
Searching...
No Matches
ForwardEulerTimeIntegration.cxx
1// Copyright 2023, 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#include "neml2/models/ForwardEulerTimeIntegration.h"
26#include "neml2/tensors/SSR4.h"
27
28namespace neml2
29{
30register_NEML2_object(ScalarForwardEulerTimeIntegration);
31register_NEML2_object(SR2ForwardEulerTimeIntegration);
32
33template <typename T>
36{
38 options.doc() =
39 "Perform forward Euler time integration defined as \\f$ s = s_n + (t - t_n) \\dot{s} "
40 "\\f$, where \\f$s\\f$ is the variable being integrated, \\f$\\dot{s}\\f$ is the variable "
41 "rate, and \\f$t\\f$ is time. Subscripts \\f$n\\f$ denote quantities from the previous time "
42 "step.";
43
44 options.set<VariableName>("variable");
45 options.set("variable").doc() = "Variable being integrated";
46
47 options.set<VariableName>("time") = VariableName("t");
48 options.set("time").doc() = "Time";
49
50 return options;
51}
52
53template <typename T>
55 : Model(options),
56 _var_name(options.get<VariableName>("variable")),
57 _var_rate_name(_var_name.with_suffix("_rate")),
58 _s(declare_output_variable<T>(_var_name.on("state"))),
59 _ds_dt(declare_input_variable<T>(_var_rate_name.on("state"))),
60 _sn(declare_input_variable<T>(_var_name.on("old_state"))),
61 _t(declare_input_variable<Scalar>(options.get<VariableName>("time").on("forces"))),
62 _tn(declare_input_variable<Scalar>(options.get<VariableName>("time").on("old_forces")))
63{
64}
65
66template <typename T>
67void
69{
70 if (out)
71 _s = _sn + _ds_dt * (_t - _tn);
72
73 if (dout_din || d2out_din2)
74 {
75 auto I = T::identity_map(options());
76
77 if (dout_din)
78 {
79 _s.d(_ds_dt) = I * (_t - _tn);
81 {
82 _s.d(_sn) = I;
83 _s.d(_t) = _ds_dt;
84 _s.d(_tn) = -_ds_dt;
85 }
86 }
87
88 if (d2out_din2)
90 {
91 _s.d(_ds_dt, _t) = I;
92 _s.d(_ds_dt, _tn) = -I;
93 _s.d(_t, _ds_dt) = I;
94 _s.d(_tn, _ds_dt) = -I;
95 }
96 }
97}
98
101} // namespace neml2
The wrapper (decorator) for cross-referencing unresolved values at parse time.
Definition CrossRef.h:52
CrossRef()=default
static OptionSet expected_options()
Definition ForwardEulerTimeIntegration.cxx:35
ForwardEulerTimeIntegration(const OptionSet &options)
Definition ForwardEulerTimeIntegration.cxx:54
void set_value(bool out, bool dout_din, bool d2out_din2) override
The map between input -> output, and optionally its derivatives.
Definition ForwardEulerTimeIntegration.cxx:68
The accessor containing all the information needed to access an item in a LabeledAxis.
Definition LabeledAxisAccessor.h:44
The base class for all constitutive models.
Definition Model.h:53
@ UPDATING
Definition Model.h:188
static OptionSet expected_options()
Definition Model.cxx:32
static enum neml2::Model::Stage stage
Definition Model.cxx:29
A custom map-like data structure. The keys are strings, and the values can be nonhomogeneously typed.
Definition OptionSet.h:59
const std::string & doc() const
A readonly reference to the option set's docstring.
Definition OptionSet.h:91
T & set(const std::string &)
Definition OptionSet.h:436
The (logical) scalar.
Definition Scalar.h:38
Definition CrossRef.cxx:32
LabeledAxisAccessor VariableName
Definition Variable.h:35