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 "StrainGradDispDerivatives.h" 11 : #include "RankTwoTensor.h" 12 : 13 : registerMooseObject("PhaseFieldApp", StrainGradDispDerivatives); 14 : 15 : InputParameters 16 0 : StrainGradDispDerivatives::validParams() 17 : { 18 0 : InputParameters params = Material::validParams(); 19 0 : params.addClassDescription( 20 : "Provide the constant derivatives of strain w.r.t. the displacement gradient components."); 21 0 : params.addCoupledVar("displacement_gradients", 22 : "List of displacement gradient component variables"); 23 0 : return params; 24 0 : } 25 : 26 0 : StrainGradDispDerivatives::StrainGradDispDerivatives(const InputParameters & parameters) 27 : : DerivativeMaterialInterface<Material>(parameters), 28 0 : _nvar(coupledComponents("displacement_gradients")), 29 0 : _dstrain(_nvar) 30 : { 31 0 : switch (_nvar) 32 : { 33 0 : case 1: 34 0 : _gdim = 1; 35 0 : break; 36 : 37 0 : case 4: 38 0 : _gdim = 2; 39 0 : break; 40 : 41 0 : case 9: 42 0 : _gdim = 3; 43 0 : break; 44 : 45 0 : default: 46 0 : mooseError("Supply 1, 4, or 9 displacement_gradient component variables"); 47 : } 48 : 49 0 : if (_gdim > LIBMESH_DIM) 50 0 : mooseError("Too many gradient component variables for the current LIBMESH_DIM"); 51 : 52 0 : for (unsigned int i = 0; i < _nvar; ++i) 53 0 : _dstrain[i] = &declarePropertyDerivative<RankTwoTensor>( 54 0 : "elastic_strain", coupledName("displacement_gradients", i)); 55 0 : } 56 : 57 : void 58 0 : StrainGradDispDerivatives::computeQpProperties() 59 : { 60 : unsigned int i = 0; 61 0 : for (unsigned int j = 0; j < _gdim; ++j) 62 0 : for (unsigned int k = 0; k < _gdim; ++k) 63 : { 64 0 : (*_dstrain[i])[_qp].zero(); 65 0 : (*_dstrain[i])[_qp](j, k) += 0.5; 66 0 : (*_dstrain[i])[_qp](k, j) += 0.5; 67 0 : ++i; 68 : } 69 0 : }