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 "NodalFunctionsL2NormPD.h" 11 : #include "Function.h" 12 : 13 : registerMooseObject("PeridynamicsApp", NodalFunctionsL2NormPD); 14 : 15 : InputParameters 16 11 : NodalFunctionsL2NormPD::validParams() 17 : { 18 11 : InputParameters params = NodalIntegralPostprocessorBasePD::validParams(); 19 11 : params.addClassDescription("Class for computing the L2 norm of functions"); 20 : 21 22 : params.addRequiredParam<std::vector<FunctionName>>("functions", "The known functions"); 22 : 23 11 : return params; 24 0 : } 25 : 26 6 : NodalFunctionsL2NormPD::NodalFunctionsL2NormPD(const InputParameters & parameters) 27 6 : : NodalIntegralPostprocessorBasePD(parameters) 28 : { 29 12 : const std::vector<FunctionName> & func_names(getParam<std::vector<FunctionName>>("functions")); 30 : 31 6 : _n_funcs = func_names.size(); 32 : 33 18 : for (unsigned int i = 0; i < _n_funcs; ++i) 34 12 : _funcs.push_back(&getFunctionByName(func_names[i])); 35 6 : } 36 : 37 : Real 38 6 : NodalFunctionsL2NormPD::getValue() const 39 : { 40 6 : return std::sqrt(NodalIntegralPostprocessorBasePD::getValue()); 41 : } 42 : 43 : Real 44 80 : NodalFunctionsL2NormPD::computeNodalValue() 45 : { 46 : Real func_val = 0; 47 : 48 240 : for (unsigned int i = 0; i < _n_funcs; ++i) 49 160 : func_val += _funcs[i]->value(_t, *_current_node) * _funcs[i]->value(_t, *_current_node); 50 : 51 80 : return func_val; 52 : }