https://mooseframework.inl.gov
Loading...
Searching...
No Matches
NodalDisplacementDifferenceL2NormPD.C
Go to the documentation of this file.
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
11#include "MooseVariable.h"
12#include "Function.h"
13
15
18{
20 params.addClassDescription("Class for computing the L2 norm of the difference between "
21 "displacements and their analytic solutions");
22
23 params.addRequiredParam<std::vector<FunctionName>>(
24 "analytic_functions", "The known analytic functions for displacements");
25 params.addRequiredParam<std::vector<NonlinearVariableName>>(
26 "displacements", "Nonlinear variable name for the displacements");
27
28 return params;
29}
30
32 const InputParameters & parameters)
34{
35 const std::vector<NonlinearVariableName> & nl_vnames(
36 getParam<std::vector<NonlinearVariableName>>("displacements"));
37
38 const std::vector<FunctionName> & func_names(
39 getParam<std::vector<FunctionName>>("analytic_functions"));
40
41 _n_disps = nl_vnames.size();
42 if (_n_disps > _dim)
43 mooseError("Number of displacements components should not greater than problem dimension!");
44
45 if (_n_disps != func_names.size())
46 mooseError("Number of analytic_functions components should be the same as the number of "
47 "displacements components!");
48
49 for (unsigned int i = 0; i < _n_disps; ++i)
50 {
51 _disp_var.push_back(&_subproblem.getStandardVariable(_tid, nl_vnames[i]));
52 _funcs.push_back(&getFunctionByName(func_names[i]));
53 }
54}
55
56Real
61
62Real
64{
65 Real diff = 0;
66 for (unsigned int i = 0; i < _n_disps; ++i)
67 diff += (_disp_var[i]->getNodalValue(*_current_node) - _funcs[i]->value(_t, *_current_node)) *
68 (_disp_var[i]->getNodalValue(*_current_node) - _funcs[i]->value(_t, *_current_node));
69
70 return diff;
71}
registerMooseObject("PeridynamicsApp", NodalDisplacementDifferenceL2NormPD)
const Function & getFunctionByName(const FunctionName &name) const
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void mooseError(Args &&... args) const
const T & getParam(const std::string &name) const
Postprocessor class to compute L2 norm of displacements difference between prediction and analytical ...
virtual Real computeNodalValue() override
Function to evaluate the given function at each material point.
NodalDisplacementDifferenceL2NormPD(const InputParameters &parameters)
std::vector< const Function * > _funcs
Known analytic displacement functions.
Postprocessor class to compute a volume integral of the specified variable Note that specializations ...
const unsigned int _dim
Mesh dimension.
const Node *const & _current_node
virtual MooseVariable & getStandardVariable(const THREAD_ID tid, const std::string &var_name)=0
SubProblem & _subproblem
const THREAD_ID _tid