Line data Source code
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 : #include "neml2/models/solid_mechanics/GursonCavitation.h"
26 : #include "neml2/tensors/Scalar.h"
27 : #include "neml2/tensors/SR2.h"
28 : #include "neml2/tensors/SSR4.h"
29 :
30 : namespace neml2
31 : {
32 : register_NEML2_object(GursonCavitation);
33 :
34 : OptionSet
35 2 : GursonCavitation::expected_options()
36 : {
37 2 : OptionSet options = Model::expected_options();
38 2 : options.doc() = "Local mass balance used in conjunction with the GTNYieldFunction, \\f$ "
39 2 : "\\dot{\\phi} = (1-\\phi) \\dot{\\varepsilon}_p \\f$.";
40 :
41 6 : options.set_input("plastic_strain_rate") = VariableName(STATE, "internal", "Ep_rate");
42 2 : options.set("plastic_strain_rate").doc() = "Plastic strain rate";
43 :
44 6 : options.set_input("void_fraction") = VariableName(STATE, "internal", "f");
45 2 : options.set("void_fraction").doc() = "Void fraction (porosity)";
46 :
47 6 : options.set_output("void_fraction_rate") = VariableName(STATE, "internal", "f_rate");
48 2 : options.set("void_fraction_rate").doc() = "Rate of void evolution";
49 :
50 2 : return options;
51 0 : }
52 :
53 1 : GursonCavitation::GursonCavitation(const OptionSet & options)
54 : : Model(options),
55 1 : _phi_dot(declare_output_variable<Scalar>("void_fraction_rate")),
56 1 : _Ep_dot(declare_input_variable<SR2>("plastic_strain_rate")),
57 2 : _phi(declare_input_variable<Scalar>("void_fraction"))
58 : {
59 1 : }
60 :
61 : void
62 2 : GursonCavitation::set_value(bool out, bool dout_din, bool /*d2out_din2*/)
63 : {
64 2 : const auto ep_dot = SR2(_Ep_dot).tr();
65 :
66 2 : if (out)
67 1 : _phi_dot = (1 - _phi) * ep_dot;
68 :
69 2 : if (dout_din)
70 : {
71 1 : const auto I = SR2::identity(_phi.options());
72 :
73 1 : if (_phi.is_dependent())
74 1 : _phi_dot.d(_phi) = -ep_dot;
75 :
76 1 : if (_Ep_dot.is_dependent())
77 1 : _phi_dot.d(_Ep_dot) = I * (1 - _phi);
78 1 : }
79 2 : }
80 : } // namespace neml2
|