https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ElementVariablesDifferenceMax.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
12// MOOSE includes
13#include "MooseVariableFE.h"
14
15#include "libmesh/quadrature.h"
16
18
21{
23 params.addClassDescription("Computes the largest difference between two variable fields.");
25 "compare_a",
26 "The first variable to evaluate the difference with, performed as \"compare_a - compare_b\"");
27 params.addRequiredCoupledVar("compare_b",
28 "The second variable to evaluate the difference with, "
29 "performed as \"compare_a - compare_b\"");
30
31 params.addParam<bool>(
32 "furthest_from_zero", false, "Find the difference with the highest absolute value");
33
34 // The value from this VPP is naturally already on every processor
35 // TODO: Make this not the case! See #11415
36 params.set<bool>("_auto_broadcast") = false;
37
38 return params;
39}
40
51
53 : ElementVectorPostprocessor(parameters),
54 _a(coupledValue("compare_a")),
55 _b(coupledValue("compare_b")),
56 _a_value(declareVector(coupledName("compare_a"))),
57 _b_value(declareVector(coupledName("compare_b"))),
58 _max_difference(declareVector("Difference")),
59 _position_x(declareVector("X")),
60 _position_y(declareVector("Y")),
61 _position_z(declareVector("Z")),
62 _furthest_from_zero(getParam<bool>("furthest_from_zero"))
63{
64 // These are all single-value arrays
65 _a_value.resize(1);
66 _b_value.resize(1);
67 _max_difference.resize(1);
68 _position_x.resize(1);
69 _position_y.resize(1);
70 _position_z.resize(1);
71
73}
74
75void
77{
78 for (unsigned int qp = 0; qp < _qrule->n_points(); ++qp)
79 {
80 // Get the difference
81 const Real difference = _furthest_from_zero ? std::abs(_a[qp] - _b[qp]) : _a[qp] - _b[qp];
82
83 // Assign the appropriate values if a new maximum is found
84 if (difference > _all[MAXIMUM_DIFFERENCE])
85 {
86 _all[MAXIMUM_DIFFERENCE] = difference;
89
93 }
94 }
95}
96
97void
110
111void
121
122void
124{
125 const auto & sibling = static_cast<const ElementVariablesDifferenceMax &>(s);
126
127 if (_all[MAXIMUM_DIFFERENCE] < sibling._all[MAXIMUM_DIFFERENCE])
128 _all = sibling._all;
129}
registerMooseObject("MooseApp", ElementVariablesDifferenceMax)
const QBase *const & _qrule
const MooseArray< Point > & _q_point
Finds the largest difference between two variable fields.
std::vector< Real > _all
Collection of all the items so only one MPI call is required, these will be spread to the actual Vect...
VectorPostprocessorValue & _a_value
The value of _a that produced the maximum difference.
const bool _furthest_from_zero
Internal flag to indicate we are seeking the largest absolute value.
VectorPostprocessorValue & _position_y
The y position of the associated quadrature point.
VectorPostprocessorValue & _position_z
The z position of the associated quadrature point.
VectorPostprocessorValue & _max_difference
The actual maximum difference.
ElementVariablesDifferenceMax(const InputParameters &parameters)
virtual void threadJoin(const UserObject &s) override
Must override.
const VariableValue & _b
The second variable, operated to produce a difference as: _a - _b.
virtual void execute() override
Execute method.
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
const VariableValue & _a
The first variable, operated to produce a difference as: _a - _b.
virtual void finalize() override
Finalize.
VectorPostprocessorValue & _b_value
The value of _b that produced the maximum difference.
VectorPostprocessorValue & _position_x
The x position of the associated quadrature point.
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
void gatherProxyValueMax(T1 &proxy, T2 &value)
Deteremine the value of a variable according to the parallel maximum of the provided proxy.
Base class for user-specific data.
Definition UserObject.h:20