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 "ComputeStrainBase.h" 11 : #include "MooseMesh.h" 12 : #include "Assembly.h" 13 : 14 : InputParameters 15 23058 : ComputeStrainBase::validParams() 16 : { 17 23058 : InputParameters params = Material::validParams(); 18 46116 : params.addRequiredCoupledVar( 19 : "displacements", 20 : "The displacements appropriate for the simulation geometry and coordinate system"); 21 46116 : params.addParam<std::string>("base_name", 22 : "Optional parameter that allows the user to define " 23 : "multiple mechanics material systems on the same " 24 : "block, i.e. for multiple phases"); 25 46116 : params.addParam<bool>( 26 46116 : "volumetric_locking_correction", false, "Flag to correct volumetric locking"); 27 46116 : params.addParam<std::vector<MaterialPropertyName>>( 28 : "eigenstrain_names", {}, "List of eigenstrains to be applied in this strain calculation"); 29 46116 : params.addParam<MaterialPropertyName>("global_strain", 30 : "Optional material property holding a global strain " 31 : "tensor applied to the mesh as a whole"); 32 23058 : params.suppressParameter<bool>("use_displaced_mesh"); 33 23058 : return params; 34 0 : } 35 : 36 17280 : ComputeStrainBase::ComputeStrainBase(const InputParameters & parameters) 37 : : DerivativeMaterialInterface<Material>(parameters), 38 17280 : _ndisp(coupledComponents("displacements")), 39 17280 : _disp(coupledValues("displacements")), 40 17280 : _grad_disp(coupledGradients("displacements")), 41 35136 : _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""), 42 17280 : _mechanical_strain(declareProperty<RankTwoTensor>(_base_name + "mechanical_strain")), 43 17280 : _total_strain(declareProperty<RankTwoTensor>(_base_name + "total_strain")), 44 34560 : _eigenstrain_names(getParam<std::vector<MaterialPropertyName>>("eigenstrain_names")), 45 17280 : _eigenstrains(_eigenstrain_names.size()), 46 17280 : _global_strain(isParamValid("global_strain") 47 17568 : ? &getMaterialProperty<RankTwoTensor>(_base_name + "global_strain") 48 : : nullptr), 49 51136 : _volumetric_locking_correction(getParam<bool>("volumetric_locking_correction") && 50 : !isBoundaryMaterial()), 51 34560 : _current_elem_volume(_assembly.elemVolume()) 52 : { 53 20706 : for (unsigned int i = 0; i < _eigenstrains.size(); ++i) 54 : { 55 3426 : _eigenstrain_names[i] = _base_name + _eigenstrain_names[i]; 56 3426 : _eigenstrains[i] = &getMaterialProperty<RankTwoTensor>(_eigenstrain_names[i]); 57 : } 58 : 59 : // set unused dimensions to zero 60 17280 : _disp.resize(3, &_zero); 61 17280 : _grad_disp.resize(3, &_grad_zero); 62 : 63 17280 : if (_ndisp == 1 && _volumetric_locking_correction) 64 0 : paramError("volumetric_locking_correction", "has to be set to false for 1-D problems."); 65 : 66 34560 : if (getParam<bool>("use_displaced_mesh")) 67 0 : paramError("use_displaced_mesh", "The strain calculator needs to run on the undisplaced mesh."); 68 : 69 : // Generate warning when volumetric locking correction is used with second order elements 70 17280 : if (_mesh.hasSecondOrderElements() && _volumetric_locking_correction) 71 0 : mooseWarning("Volumetric locking correction is not required for second order elements. Using " 72 : "volumetric locking with second order elements could cause zigzag patterns in " 73 : "stresses and strains."); 74 17280 : } 75 : 76 : void 77 14658 : ComputeStrainBase::initialSetup() 78 : { 79 14658 : displacementIntegrityCheck(); 80 14658 : } 81 : 82 : void 83 14514 : ComputeStrainBase::displacementIntegrityCheck() 84 : { 85 : // Checking for consistency between mesh size and length of the provided displacements vector 86 14514 : if (_ndisp != _mesh.dimension()) 87 0 : paramError( 88 : "displacements", 89 : "The number of variables supplied in 'displacements' must match the mesh dimension."); 90 14514 : } 91 : 92 : void 93 256 : ComputeStrainBase::initQpStatefulProperties() 94 : { 95 256 : _mechanical_strain[_qp].zero(); 96 256 : _total_strain[_qp].zero(); 97 256 : }