Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://www.mooseframework.org 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 10981 : ComputeStrainBase::validParams() 16 : { 17 10981 : InputParameters params = Material::validParams(); 18 21962 : params.addRequiredCoupledVar( 19 : "displacements", 20 : "The displacements appropriate for the simulation geometry and coordinate system"); 21 21962 : 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 21962 : params.addParam<bool>( 26 21962 : "volumetric_locking_correction", false, "Flag to correct volumetric locking"); 27 21962 : params.addParam<std::vector<MaterialPropertyName>>( 28 : "eigenstrain_names", {}, "List of eigenstrains to be applied in this strain calculation"); 29 21962 : params.addParam<MaterialPropertyName>("global_strain", 30 : "Optional material property holding a global strain " 31 : "tensor applied to the mesh as a whole"); 32 10981 : params.suppressParameter<bool>("use_displaced_mesh"); 33 10981 : return params; 34 0 : } 35 : 36 8229 : ComputeStrainBase::ComputeStrainBase(const InputParameters & parameters) 37 : : DerivativeMaterialInterface<Material>(parameters), 38 8229 : _ndisp(coupledComponents("displacements")), 39 8229 : _disp(coupledValues("displacements")), 40 8229 : _grad_disp(coupledGradients("displacements")), 41 16710 : _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""), 42 8229 : _mechanical_strain(declareProperty<RankTwoTensor>(_base_name + "mechanical_strain")), 43 8229 : _total_strain(declareProperty<RankTwoTensor>(_base_name + "total_strain")), 44 16458 : _eigenstrain_names(getParam<std::vector<MaterialPropertyName>>("eigenstrain_names")), 45 8229 : _eigenstrains(_eigenstrain_names.size()), 46 8229 : _global_strain(isParamValid("global_strain") 47 8373 : ? &getMaterialProperty<RankTwoTensor>(_base_name + "global_strain") 48 : : nullptr), 49 24343 : _volumetric_locking_correction(getParam<bool>("volumetric_locking_correction") && 50 : !isBoundaryMaterial()), 51 16458 : _current_elem_volume(_assembly.elemVolume()) 52 : { 53 9924 : for (unsigned int i = 0; i < _eigenstrains.size(); ++i) 54 : { 55 1695 : _eigenstrain_names[i] = _base_name + _eigenstrain_names[i]; 56 1695 : _eigenstrains[i] = &getMaterialProperty<RankTwoTensor>(_eigenstrain_names[i]); 57 : } 58 : 59 : // set unused dimensions to zero 60 8229 : _disp.resize(3, &_zero); 61 8229 : _grad_disp.resize(3, &_grad_zero); 62 : 63 8229 : if (_ndisp == 1 && _volumetric_locking_correction) 64 0 : paramError("volumetric_locking_correction", "has to be set to false for 1-D problems."); 65 : 66 16458 : 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 8229 : 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 8229 : } 75 : 76 : void 77 6957 : ComputeStrainBase::initialSetup() 78 : { 79 6957 : displacementIntegrityCheck(); 80 6957 : } 81 : 82 : void 83 6885 : ComputeStrainBase::displacementIntegrityCheck() 84 : { 85 : // Checking for consistency between mesh size and length of the provided displacements vector 86 6885 : if (_ndisp != _mesh.dimension()) 87 0 : paramError( 88 : "displacements", 89 : "The number of variables supplied in 'displacements' must match the mesh dimension."); 90 6885 : } 91 : 92 : void 93 5552 : ComputeStrainBase::initQpStatefulProperties() 94 : { 95 5552 : _mechanical_strain[_qp].zero(); 96 5552 : _total_strain[_qp].zero(); 97 5552 : }