void NodeFaceConstraint::computeResidual() { DenseVector<Number> & re = _assembly.residualBlock(_var.number()); DenseVector<Number> & neighbor_re = _assembly.residualBlockNeighbor(_master_var.number()); _qp=0; for (_i=0; _i<_test_master.size(); _i++) neighbor_re(_i) += computeQpResidual(Moose::Master); _i=0; re(0) = computeQpResidual(Moose::Slave); }
void NodalConstraint::computeResidual(NumericVector<Number> & residual) { if ((_weights.size() == 0) && (_master_node_vector.size() == 1)) _weights.push_back(1.0); std::vector<dof_id_type> masterdof = _var.dofIndices(); std::vector<dof_id_type> slavedof = _var.dofIndicesNeighbor(); DenseVector<Number> re(masterdof.size()); DenseVector<Number> neighbor_re(slavedof.size()); re.zero(); neighbor_re.zero(); for (_i = 0; _i < slavedof.size(); ++_i) { for (_j = 0; _j < masterdof.size(); ++_j) { switch (_formulation) { case Moose::Penalty: re(_j) += computeQpResidual(Moose::Master) * _var.scalingFactor(); neighbor_re(_i) += computeQpResidual(Moose::Slave) * _var.scalingFactor(); break; case Moose::Kinematic: // Transfer the current residual of the slave node to the master nodes Real res = residual(slavedof[_i]); re(_j) += res * _weights[_j]; neighbor_re(_i) += -res / _master_node_vector.size() + computeQpResidual(Moose::Slave); break; } } } _assembly.cacheResidualNodes(re, masterdof); _assembly.cacheResidualNodes(neighbor_re, slavedof); }