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 "MortarConstraint.h" 11 : 12 : // MOOSE includes 13 : #include "Assembly.h" 14 : #include "MooseVariable.h" 15 : #include "SystemBase.h" 16 : 17 : InputParameters 18 72147 : MortarConstraint::validParams() 19 : { 20 72147 : InputParameters params = MortarConstraintBase::validParams(); 21 72147 : return params; 22 : } 23 : 24 410 : MortarConstraint::MortarConstraint(const InputParameters & parameters) 25 : : MortarConstraintBase(parameters), 26 410 : _lambda_dummy(), 27 410 : _lambda(_var ? _var->slnLower() : _lambda_dummy), 28 410 : _u_secondary(_secondary_var.sln()), 29 410 : _u_primary(_primary_var.slnNeighbor()), 30 410 : _grad_u_secondary(_secondary_var.gradSln()), 31 410 : _grad_u_primary(_primary_var.gradSlnNeighbor()), 32 410 : _phi(nullptr), 33 410 : _grad_phi(nullptr) 34 : { 35 410 : } 36 : 37 : void 38 127000 : MortarConstraint::computeResidual(Moose::MortarType mortar_type) 39 : { 40 127000 : unsigned int test_space_size = 0; 41 127000 : switch (mortar_type) 42 : { 43 61882 : case Moose::MortarType::Secondary: 44 61882 : prepareVectorTag(_assembly, _secondary_var.number()); 45 61882 : test_space_size = _test_secondary.size(); 46 61882 : break; 47 : 48 61882 : case Moose::MortarType::Primary: 49 61882 : prepareVectorTagNeighbor(_assembly, _primary_var.number()); 50 61882 : test_space_size = _test_primary.size(); 51 61882 : break; 52 : 53 3236 : case Moose::MortarType::Lower: 54 : mooseAssert(_var, "LM variable is null"); 55 3236 : prepareVectorTagLower(_assembly, _var->number()); 56 3236 : test_space_size = _test.size(); 57 3236 : break; 58 : } 59 : 60 796608 : for (_qp = 0; _qp < _qrule_msm->n_points(); _qp++) 61 10186792 : for (_i = 0; _i < test_space_size; _i++) 62 9517184 : _local_re(_i) += _JxW_msm[_qp] * _coord[_qp] * computeQpResidual(mortar_type); 63 : 64 127000 : accumulateTaggedLocalResidual(); 65 127000 : } 66 : 67 : void 68 73770 : MortarConstraint::computeJacobian(Moose::MortarType mortar_type) 69 : { 70 73770 : std::size_t test_space_size = 0; 71 : typedef Moose::ConstraintJacobianType JType; 72 : typedef Moose::MortarType MType; 73 : std::array<JType, 3> jacobian_types; 74 : 75 73770 : switch (mortar_type) 76 : { 77 35855 : case MType::Secondary: 78 35855 : test_space_size = _secondary_var.dofIndices().size(); 79 35855 : jacobian_types = { 80 : {JType::SecondarySecondary, JType::SecondaryPrimary, JType::SecondaryLower}}; 81 35855 : break; 82 : 83 35855 : case MType::Primary: 84 35855 : test_space_size = _primary_var.dofIndicesNeighbor().size(); 85 35855 : jacobian_types = {{JType::PrimarySecondary, JType::PrimaryPrimary, JType::PrimaryLower}}; 86 35855 : break; 87 : 88 2060 : case MType::Lower: 89 2060 : test_space_size = _var ? _var->dofIndicesLower().size() : 0; 90 2060 : jacobian_types = {{JType::LowerSecondary, JType::LowerPrimary, JType::LowerLower}}; 91 2060 : break; 92 : } 93 : 94 73770 : auto & ce = _assembly.couplingEntries(); 95 233268 : for (const auto & it : ce) 96 : { 97 159498 : MooseVariableFEBase & ivariable = *(it.first); 98 159498 : MooseVariableFEBase & jvariable = *(it.second); 99 : 100 159498 : unsigned int ivar = ivariable.number(); 101 159498 : unsigned int jvar = jvariable.number(); 102 : 103 159498 : switch (mortar_type) 104 : { 105 64431 : case MType::Secondary: 106 64431 : if (ivar != _secondary_var.number()) 107 68184 : continue; 108 41703 : break; 109 : 110 64431 : case MType::Primary: 111 64431 : if (ivar != _primary_var.number()) 112 22728 : continue; 113 41703 : break; 114 : 115 30636 : case MType::Lower: 116 30636 : if (!_var || _var->number() != ivar) 117 22728 : continue; 118 7908 : break; 119 : } 120 : 121 91314 : std::array<size_t, 3> shape_space_sizes{{jvariable.dofIndices().size(), 122 91314 : jvariable.dofIndicesNeighbor().size(), 123 182628 : jvariable.dofIndicesLower().size()}}; 124 : std::array<const VariablePhiValue *, 3> phis; 125 : std::array<const VariablePhiGradient *, 3> grad_phis; 126 : std::array<const VectorVariablePhiValue *, 3> vector_phis; 127 : std::array<const VectorVariablePhiGradient *, 3> vector_grad_phis; 128 91314 : if (jvariable.isVector()) 129 : { 130 0 : const auto & temp_var = static_cast<MooseVariableFE<RealVectorValue> &>(jvariable); 131 0 : vector_phis = {{&temp_var.phiFace(), &temp_var.phiFaceNeighbor(), &temp_var.phiLower()}}; 132 0 : vector_grad_phis = { 133 0 : {&temp_var.gradPhiFace(), &temp_var.gradPhiFaceNeighbor(), &temp_var.gradPhiLower()}}; 134 : } 135 : else 136 : { 137 91314 : const auto & temp_var = static_cast<MooseVariableFE<Real> &>(jvariable); 138 91314 : phis = {{&temp_var.phiFace(), &temp_var.phiFaceNeighbor(), &temp_var.phiLower()}}; 139 91314 : grad_phis = { 140 91314 : {&temp_var.gradPhiFace(), &temp_var.gradPhiFaceNeighbor(), &temp_var.gradPhiLower()}}; 141 : } 142 : 143 365256 : for (MooseIndex(3) type_index = 0; type_index < 3; ++type_index) 144 : { 145 273942 : const auto jacobian_type = jacobian_types[type_index]; 146 : 147 273942 : prepareMatrixTagLower(_assembly, ivar, jvar, jacobian_type); 148 : 149 : /// Set the proper phis 150 273942 : if (jvariable.isVector()) 151 : { 152 0 : _vector_phi = vector_phis[type_index]; 153 0 : _vector_grad_phi = vector_grad_phis[type_index]; 154 : } 155 : else 156 : { 157 273942 : _phi = phis[type_index]; 158 273942 : _grad_phi = grad_phis[type_index]; 159 : } 160 : 161 3898350 : for (_i = 0; _i < test_space_size; _i++) 162 33116264 : for (_j = 0; _j < shape_space_sizes[type_index]; _j++) 163 223553408 : for (_qp = 0; _qp < _qrule_msm->n_points(); _qp++) 164 194061552 : _local_ke(_i, _j) += 165 194061552 : _JxW_msm[_qp] * _coord[_qp] * computeQpJacobian(jacobian_type, jvar); 166 273942 : accumulateTaggedLocalMatrix(); 167 : } 168 : } 169 73770 : }