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 "AsymptoticExpansionHomogenizationElasticConstants.h"
11 : #include "MooseMesh.h"
12 :
13 : registerMooseObject("SolidMechanicsApp", AsymptoticExpansionHomogenizationElasticConstants);
14 :
15 : InputParameters
16 80 : AsymptoticExpansionHomogenizationElasticConstants::validParams()
17 : {
18 80 : InputParameters params = ElementIntegralPostprocessor::validParams();
19 80 : params.addClassDescription(
20 : "Postprocessor for asymptotic expansion homogenization for elasticity");
21 160 : params.addRequiredCoupledVar("dx_xx", "solution in xx");
22 160 : params.addRequiredCoupledVar("dy_xx", "solution in xx");
23 160 : params.addCoupledVar("dz_xx", "solution in xx");
24 160 : params.addRequiredCoupledVar("dx_yy", "solution in yy");
25 160 : params.addRequiredCoupledVar("dy_yy", "solution in yy");
26 160 : params.addCoupledVar("dz_yy", "solution in yy");
27 160 : params.addCoupledVar("dx_zz", "solution in zz");
28 160 : params.addCoupledVar("dy_zz", "solution in zz");
29 160 : params.addCoupledVar("dz_zz", "solution in zz");
30 160 : params.addRequiredCoupledVar("dx_xy", "solution in xy");
31 160 : params.addRequiredCoupledVar("dy_xy", "solution in xy");
32 160 : params.addCoupledVar("dz_xy", "solution in xy");
33 160 : params.addCoupledVar("dx_yz", "solution in yz");
34 160 : params.addCoupledVar("dy_yz", "solution in yz");
35 160 : params.addCoupledVar("dz_yz", "solution in yz");
36 160 : params.addCoupledVar("dx_zx", "solution in zx");
37 160 : params.addCoupledVar("dy_zx", "solution in zx");
38 160 : params.addCoupledVar("dz_zx", "solution in zx");
39 160 : params.addParam<std::string>("base_name",
40 : "Optional parameter that allows the user to define "
41 : "multiple mechanics material systems on the same "
42 : "block, i.e. for multiple phases");
43 160 : MooseEnum column("xx yy zz yz xz xy");
44 160 : params.addRequiredParam<MooseEnum>("column",
45 : column,
46 : "The column of the material matrix this kernel acts in. "
47 : "(xx, yy, zz, yz, xz, or xy)");
48 160 : params.addRequiredParam<MooseEnum>("row",
49 : column,
50 : "The row of the material matrix this kernel acts in. "
51 : "(xx, yy, zz, yz, xz, or xy)");
52 80 : return params;
53 80 : }
54 :
55 40 : AsymptoticExpansionHomogenizationElasticConstants::
56 40 : AsymptoticExpansionHomogenizationElasticConstants(const InputParameters & parameters)
57 : : ElementIntegralPostprocessor(parameters),
58 120 : _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
59 40 : _grad({{{{&coupledGradient("dx_xx"),
60 80 : &coupledGradient("dy_xx"),
61 80 : (_subproblem.mesh().dimension() == 3 ? &coupledGradient("dz_xx") : &_grad_zero)}},
62 80 : {{&coupledGradient("dx_yy"),
63 80 : &coupledGradient("dy_yy"),
64 80 : (_subproblem.mesh().dimension() == 3 ? &coupledGradient("dz_yy") : &_grad_zero)}},
65 80 : {{(_subproblem.mesh().dimension() == 3 ? &coupledGradient("dx_zz") : &_grad_zero),
66 80 : (_subproblem.mesh().dimension() == 3 ? &coupledGradient("dy_zz") : &_grad_zero),
67 80 : (_subproblem.mesh().dimension() == 3 ? &coupledGradient("dz_zz") : &_grad_zero)}},
68 80 : {{(_subproblem.mesh().dimension() == 3 ? &coupledGradient("dx_yz") : &_grad_zero),
69 80 : (_subproblem.mesh().dimension() == 3 ? &coupledGradient("dy_yz") : &_grad_zero),
70 80 : (_subproblem.mesh().dimension() == 3 ? &coupledGradient("dz_yz") : &_grad_zero)}},
71 80 : {{(_subproblem.mesh().dimension() == 3 ? &coupledGradient("dx_zx") : &_grad_zero),
72 80 : (_subproblem.mesh().dimension() == 3 ? &coupledGradient("dy_zx") : &_grad_zero),
73 80 : (_subproblem.mesh().dimension() == 3 ? &coupledGradient("dz_zx") : &_grad_zero)}},
74 80 : {{(&coupledGradient("dx_xy")),
75 80 : (&coupledGradient("dy_xy")),
76 40 : (_subproblem.mesh().dimension() == 3 ? &coupledGradient("dz_xy") : &_grad_zero)}}}}),
77 80 : _elasticity_tensor(getMaterialPropertyByName<RankFourTensor>(_base_name + "elasticity_tensor")),
78 80 : _column(getParam<MooseEnum>("column")),
79 80 : _row(getParam<MooseEnum>("row")),
80 40 : _ik_index({{0, 1, 2, 1, 0, 0}}),
81 40 : _jl_index({{0, 1, 2, 2, 2, 1}}),
82 40 : _i(_ik_index[_row]),
83 40 : _j(_jl_index[_row]),
84 40 : _k(_ik_index[_column]),
85 40 : _l(_jl_index[_column]),
86 40 : _volume(0),
87 40 : _integral_value(0)
88 : {
89 40 : }
90 :
91 : void
92 90 : AsymptoticExpansionHomogenizationElasticConstants::initialize()
93 : {
94 90 : _integral_value = 0;
95 90 : _volume = 0;
96 90 : }
97 :
98 : void
99 17920 : AsymptoticExpansionHomogenizationElasticConstants::execute()
100 : {
101 17920 : _integral_value += computeIntegral();
102 17920 : _volume += _current_elem_volume;
103 17920 : }
104 :
105 : Real
106 90 : AsymptoticExpansionHomogenizationElasticConstants::getValue() const
107 : {
108 90 : return (_integral_value / _volume);
109 : }
110 :
111 : void
112 90 : AsymptoticExpansionHomogenizationElasticConstants::finalize()
113 : {
114 90 : gatherSum(_integral_value);
115 90 : gatherSum(_volume);
116 90 : }
117 :
118 : void
119 0 : AsymptoticExpansionHomogenizationElasticConstants::threadJoin(const UserObject & y)
120 : {
121 : const AsymptoticExpansionHomogenizationElasticConstants & pps =
122 0 : dynamic_cast<const AsymptoticExpansionHomogenizationElasticConstants &>(y);
123 :
124 0 : _integral_value += pps._integral_value;
125 0 : _volume += pps._volume;
126 0 : }
127 :
128 : Real
129 71680 : AsymptoticExpansionHomogenizationElasticConstants::computeQpIntegral()
130 : {
131 : Real value = 0;
132 286720 : for (unsigned p = 0; p < 3; ++p)
133 860160 : for (unsigned q = 0; q < 3; ++q)
134 645120 : value += _elasticity_tensor[_qp](_i, _j, p, q) * (*_grad[_column][p])[_qp](q);
135 :
136 71680 : return _elasticity_tensor[_qp](_i, _j, _k, _l) + value;
137 : }
|