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/elasticity/IsotropicElasticityTensor.h"
26 : #include "neml2/tensors/SSR4.h"
27 :
28 : namespace neml2
29 : {
30 : register_NEML2_object(IsotropicElasticityTensor);
31 :
32 : OptionSet
33 2 : IsotropicElasticityTensor::expected_options()
34 : {
35 2 : OptionSet options = ElasticityInterface<Model, 2>::expected_options();
36 2 : options.doc() = "This class defines an isotropic elasticity tensor using two parameters."
37 2 : " Various options are available for which two parameters to provide.";
38 :
39 2 : return options;
40 0 : }
41 :
42 2 : IsotropicElasticityTensor::IsotropicElasticityTensor(const OptionSet & options)
43 : : ElasticityInterface<Model, 2>(options),
44 2 : _converter(_constant_types, _need_derivs),
45 2 : _C(declare_output_variable<SSR4>(VariableName(PARAMETERS, name())))
46 : {
47 2 : }
48 :
49 : void
50 4 : IsotropicElasticityTensor::set_value(bool out, bool dout_din, bool /*d2out_din2*/)
51 : {
52 4 : const auto [K_and_dK, G_and_dG] = _converter.convert(_constants);
53 4 : const auto & [K, dK] = K_and_dK;
54 4 : const auto & [G, dG] = G_and_dG;
55 :
56 4 : const auto Iv = SSR4::identity_vol(K.options());
57 4 : const auto Id = SSR4::identity_dev(G.options());
58 :
59 4 : if (out)
60 4 : _C = 3.0 * K * Iv + 2.0 * G * Id;
61 :
62 4 : if (dout_din)
63 : {
64 2 : if (const auto * const p1 = nl_param(neml2::name(_constant_types[0])))
65 2 : _C.d(*p1) = 3.0 * dK[0] * Iv + 2.0 * dG[0] * Id;
66 :
67 2 : if (const auto * const p2 = nl_param(neml2::name(_constant_types[1])))
68 2 : _C.d(*p2) = 3.0 * dK[1] * Iv + 2.0 * dG[1] * Id;
69 : }
70 4 : }
71 :
72 : } // namespace neml2
|