Line data Source code
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 : 10 : #include "R2IncrementToRate.h" 11 : 12 : #ifdef NEML2_ENABLED 13 : 14 : #include "neml2/tensors/R2.h" 15 : #include "neml2/tensors/functions/imap.h" 16 : 17 : namespace neml2 18 : { 19 : register_NEML2_object(R2IncrementToRate); 20 : 21 : OptionSet 22 173 : R2IncrementToRate::expected_options() 23 : { 24 173 : OptionSet options = Model::expected_options(); 25 : options.doc() = "Compute the rate of a rank two tensor given its increment and the time step."; 26 346 : options.add_input("increment", "Increment of the rank two tensor"); 27 346 : options.add_input("time", "t", "Current time"); 28 346 : options.add_output("rate", "Rate of the rank two tensor"); 29 173 : return options; 30 0 : } 31 : 32 20 : R2IncrementToRate::R2IncrementToRate(const OptionSet & options) 33 : : Model(options), 34 40 : _delta(declare_input_variable<R2>("increment")), 35 20 : _t(declare_input_variable<Scalar>("t")), 36 20 : _t_n(declare_input_variable<Scalar>(history_name(_t.name(), 1))), 37 40 : _rate(declare_output_variable<R2>("rate")) 38 : { 39 20 : } 40 : 41 : void 42 30 : R2IncrementToRate::set_value(bool out, bool dout_din, bool /*d2out_din2*/) 43 : { 44 30 : if (out) 45 60 : _rate = _delta / (_t - _t_n); 46 : 47 30 : if (dout_din) 48 : { 49 40 : _rate.d(_delta) = 1.0 / (_t - _t_n) * imap_v<R2>(); 50 60 : _rate.d(_t) = -_delta / (_t - _t_n) / (_t - _t_n); 51 40 : _rate.d(_t_n) = _delta / (_t - _t_n) / (_t - _t_n); 52 : } 53 30 : } 54 : } // namespace neml2 55 : 56 : #endif // NEML2_ENABLED