DenseVector<Number> FDKernel::perturbedResidual(unsigned int varnum, unsigned int perturbationj, Real perturbation_scale, Real& perturbation) { DenseVector<Number> re; re.resize(_var.dofIndices().size()); re.zero(); MooseVariable& var = _sys.getVariable(_tid,varnum); var.computePerturbedElemValues(perturbationj,perturbation_scale,perturbation); precalculateResidual(); for (_i = 0; _i < _test.size(); _i++) for (_qp = 0; _qp < _qrule->n_points(); _qp++) re(_i) += _JxW[_qp] * _coord[_qp] * computeQpResidual(); var.restoreUnperturbedElemValues(); return re; }
void StressDivergenceRZ::computeResidual() { DenseVector<Number> & re = _assembly.residualBlock(_var.number()); _local_re.resize(re.size()); _local_re.zero(); if (_volumetric_locking_correction) { // calculate volume averaged value of shape function derivative _avg_grad_test.resize(_test.size()); for (_i = 0; _i < _test.size(); _i++) { _avg_grad_test[_i].resize(2); _avg_grad_test[_i][_component] = 0.0; for (_qp = 0; _qp < _qrule->n_points(); _qp++) { if (_component == 0) _avg_grad_test[_i][_component] += (_grad_test[_i][_qp](_component) + _test[_i][_qp] / _q_point[_qp](0)) * _JxW[_qp] * _coord[_qp]; else _avg_grad_test[_i][_component] += _grad_test[_i][_qp](_component) * _JxW[_qp] * _coord[_qp]; } _avg_grad_test[_i][_component] /= _current_elem_volume; } } precalculateResidual(); for (_i = 0; _i < _test.size(); _i++) for (_qp = 0; _qp < _qrule->n_points(); _qp++) _local_re(_i) += _JxW[_qp] * _coord[_qp] * computeQpResidual(); re += _local_re; if (_has_save_in) { Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx); for (const auto & var : _save_in) var->sys().solution().add_vector(_local_re, var->dofIndices()); } }
void Kernel::computeResidual() { DenseVector<Number> & re = _assembly.residualBlock(_var.index()); _local_re.resize(re.size()); _local_re.zero(); precalculateResidual(); for (_i = 0; _i < _test.size(); _i++) for (_qp = 0; _qp < _qrule->n_points(); _qp++) _local_re(_i) += _JxW[_qp] * _coord[_qp] * computeQpResidual(); re += _local_re; if (_has_save_in) { Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx); for(unsigned int i=0; i<_save_in.size(); i++) _save_in[i]->sys().solution().add_vector(_local_re, _save_in[i]->dofIndices()); } }
void PorousFlowFluxLimitedTVDAdvection::computeResidual() { prepareVectorTag(_assembly, _var.number()); precalculateResidual(); // get the residual contributions from _fluo for (unsigned i = 0; i < _current_elem->n_nodes(); ++i) { const dof_id_type node_id_i = _current_elem->node_id(i); _local_re(i) = _fluo.getFluxOut(node_id_i) / _fluo.getValence(node_id_i); } accumulateTaggedLocalResidual(); if (_has_save_in) { Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx); for (unsigned int i = 0; i < _save_in.size(); i++) _save_in[i]->sys().solution().add_vector(_local_re, _save_in[i]->dofIndices()); } }
void StressDivergenceTensors::computeResidual() { DenseVector<Number> & re = _assembly.residualBlock(_var.number()); _local_re.resize(re.size()); _local_re.zero(); if (_volumetric_locking_correction) computeAverageGradientTest(); precalculateResidual(); for (_i = 0; _i < _test.size(); ++_i) for (_qp = 0; _qp < _qrule->n_points(); ++_qp) _local_re(_i) += _JxW[_qp] * _coord[_qp] * computeQpResidual(); re += _local_re; if (_has_save_in) { Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx); for (const auto & var : _save_in) var->sys().solution().add_vector(_local_re, var->dofIndices()); } }