https://mooseframework.inl.gov
Loading...
Searching...
No Matches
R2IncrementToRate.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9#if 0 // NEML2 v2->v3 migration: superseded by the Python model
10 // modules/solid_mechanics/data/neml2/R2IncrementToRate.py (loaded via the NEML2Action 'load'
11 // parameter)
12
13#include "R2IncrementToRate.h"
14
15#ifdef NEML2_ENABLED
16
17#include "neml2/tensors/R2.h"
18#include "neml2/tensors/functions/imap.h"
19
20namespace neml2
21{
23
24OptionSet
26{
27 OptionSet options = Model::expected_options();
28 options.doc() = "Compute the rate of a rank two tensor given its increment and the time step.";
29 options.add_input("increment", "Increment of the rank two tensor");
30 options.add_input("time", "t", "Current time");
31 options.add_output("rate", "Rate of the rank two tensor");
32 return options;
33}
34
35R2IncrementToRate::R2IncrementToRate(const OptionSet & options)
36 : Model(options),
37 _delta(declare_input_variable<R2>("increment")),
38 _t(declare_input_variable<Scalar>("t")),
39 _t_n(declare_input_variable<Scalar>(history_name(_t.name(), 1))),
40 _rate(declare_output_variable<R2>("rate"))
41{
42}
43
44void
45R2IncrementToRate::set_value(bool out, bool dout_din, bool /*d2out_din2*/)
46{
47 if (out)
48 _rate = _delta / (_t - _t_n);
49
50 if (dout_din)
51 {
52 _rate.d(_delta) = 1.0 / (_t - _t_n) * imap_v<R2>();
53 _rate.d(_t) = -_delta / (_t - _t_n) / (_t - _t_n);
54 _rate.d(_t_n) = _delta / (_t - _t_n) / (_t - _t_n);
55 }
56}
57} // namespace neml2
58
59#endif // NEML2_ENABLED
60
61#endif // NEML2 v2->v3 migration: DEFERRED
const std::string name
Definition Setup.h:21
Get the rate of a rank two tensor given its increment.
const Variable< Scalar > & _t_n
static OptionSet expected_options()
R2IncrementToRate(const OptionSet &options)
void set_value(bool out, bool dout_din, bool d2out_din2) override
Variable< R2 > & _rate
Rate.
const Variable< Scalar > & _t
Time.
const Variable< R2 > & _delta
Increment of the rank two tensor.
register_NEML2_object(LibtorchModel)