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 "GlobalDisplacementAux.h" 11 : #include "GlobalStrainUserObjectInterface.h" 12 : 13 : // MOOSE includes 14 : #include "Assembly.h" 15 : #include "SystemBase.h" 16 : #include "RankTwoTensor.h" 17 : 18 : registerMooseObject("TensorMechanicsApp", GlobalDisplacementAux); 19 : 20 : InputParameters 21 150 : GlobalDisplacementAux::validParams() 22 : { 23 150 : InputParameters params = AuxKernel::validParams(); 24 150 : params.addClassDescription( 25 : "AuxKernel to visualize the displacements generated by the global strain tensor"); 26 300 : params.addCoupledVar("scalar_global_strain", 27 : "Scalar variable providing global strain components"); 28 300 : params.addCoupledVar("displacements", "The name of the displacement variables"); 29 300 : params.addRequiredParam<unsigned int>("component", 30 : "The displacement component to consider for this kernel"); 31 300 : params.addParam<bool>( 32 300 : "output_global_displacement", false, "Option to output global displacement only"); 33 300 : params.addRequiredParam<UserObjectName>("global_strain_uo", 34 : "The name of the GlobalStrainUserObject"); 35 150 : params.addParam<Point>("reference_point", 36 150 : Point(0, 0, 0), 37 : "The coordinate of the center/fixed point of the simulation"); 38 : 39 : // Default this object to get executed before the displaced mesh update. 40 : // This way the AuxVars set by this object can be used as mesh displacements. 41 150 : params.set<ExecFlagEnum>("execute_on") = EXEC_PRE_DISPLACE; 42 : 43 150 : return params; 44 0 : } 45 : 46 75 : GlobalDisplacementAux::GlobalDisplacementAux(const InputParameters & parameters) 47 : : AuxKernel(parameters), 48 75 : _scalar_global_strain(coupledScalarValue("scalar_global_strain")), 49 150 : _component(getParam<unsigned int>("component")), 50 150 : _output_global_disp(getParam<bool>("output_global_displacement")), 51 75 : _pst(dynamic_cast<const GlobalStrainUserObjectInterface &>( 52 75 : getUserObjectBase("global_strain_uo"))), 53 75 : _periodic_dir(_pst.getPeriodicDirections()), 54 75 : _ref_point(parameters.get<Point>("reference_point")), 55 75 : _dim(_mesh.dimension()), 56 75 : _ndisp(coupledComponents("displacements")), 57 225 : _disp(coupledValues("displacements")) 58 : { 59 75 : if (!isNodal()) 60 0 : paramError("variable", "GlobalDisplacementAux must be used on a nodal auxiliary variable"); 61 : 62 75 : if (_component >= _dim) 63 0 : paramError("component", 64 : "The component ", 65 : _component, 66 : " does not exist for ", 67 : _dim, 68 : " dimensional problems"); 69 75 : } 70 : 71 : Real 72 14013 : GlobalDisplacementAux::computeValue() 73 : { 74 14013 : RankTwoTensor strain; 75 14013 : strain.fillFromScalarVariable(_scalar_global_strain); 76 : 77 49884 : for (unsigned int dir = 0; dir < _dim; ++dir) 78 35871 : if (!_periodic_dir(dir)) 79 35748 : for (unsigned int var = 0; var < _ndisp; ++var) 80 26721 : strain(dir, var) = 0.0; 81 : 82 14013 : const RealVectorValue & global_disp = strain * ((*_current_node) - _ref_point); 83 : 84 14013 : if (_output_global_disp) 85 324 : return global_disp(_component); 86 : else 87 13689 : return global_disp(_component) + (*_disp[_component])[_qp]; 88 : }