-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24707 from maxnezdyur/Ele_Nodal_Reporters_24678
Create Element and Nodal Reporters
- Loading branch information
Showing
22 changed files
with
801 additions
and
2 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
framework/doc/content/source/reporters/ElementVariableStatistics.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# ElementVariableStatistics | ||
|
||
!syntax description /Reporters/ElementVariableStatistics | ||
|
||
## Overview | ||
|
||
ElementVariableStatistics produces the following statistics for a | ||
variable: Maximum, Minium, Average, Integral, Total Elements. The | ||
[!param](/Reporters/ElementVariableStatistics/base_name) can be used to prepend a | ||
name to each reporter. | ||
|
||
|
||
|
||
## Example Input File Syntax | ||
|
||
!listing element_reporter/elem_stats.i block=elem_stats | ||
indent=2 header=[Reporters] footer=[] | ||
|
||
!syntax parameters /Reporters/ElementVariableStatistics | ||
|
||
!syntax inputs /Reporters/ElementVariableStatistics | ||
|
||
!syntax children /Reporters/ElementVariableStatistics |
23 changes: 23 additions & 0 deletions
23
framework/doc/content/source/reporters/NodalVariableStatistics.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# NodalVariableStatistics | ||
|
||
!syntax description /Reporters/NodalVariableStatistics | ||
|
||
## Overview | ||
|
||
NodalVariableStatistics produces the following statistics for a | ||
variable: Maximum, Minium, Average, Total Nodes. The | ||
[!param](/Reporters/NodalVariableStatistics/base_name) can be used to prepend a | ||
name to each reporter. | ||
|
||
|
||
|
||
## Example Input File Syntax | ||
|
||
!listing nodal_reporter/nodal_stats.i block=nodal_stats | ||
indent=2 header=[Reporters] footer=[] | ||
|
||
!syntax parameters /Reporters/NodalVariableStatistics | ||
|
||
!syntax inputs /Reporters/NodalVariableStatistics | ||
|
||
!syntax children /Reporters/NodalVariableStatistics |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//* This file is part of the MOOSE framework | ||
//* https://www.mooseframework.org | ||
//* | ||
//* All rights reserved, see COPYRIGHT for full restrictions | ||
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT | ||
//* | ||
//* Licensed under LGPL 2.1, please see LICENSE for details | ||
//* https://www.gnu.org/licenses/lgpl-2.1.html | ||
|
||
#pragma once | ||
|
||
// MOOSE includes | ||
#include "ElementUserObject.h" | ||
#include "Reporter.h" | ||
|
||
/** | ||
*/ | ||
class ElementReporter : public ElementUserObject, public Reporter | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
ElementReporter(const InputParameters & parameters); | ||
|
||
/** | ||
* @returns Whether or not this Reporter should store its value at this specific time. | ||
* | ||
* If the private parameter '_always_store' is true, this will always return true. | ||
* Otherwise, it will return true if the current execute flag matches a flag | ||
* that this ElementReporter has in its 'execute_on' parameter. Otherwise, it will | ||
* return false. | ||
* | ||
* This enables ElementReporter objects that do not fill information ahead of time in | ||
* execute() but instead fill their information in the to_json implementation. | ||
* Without this, said ElementReporters would always output their information even though | ||
* the user requested that they do not execute on a specific flag. | ||
*/ | ||
bool shouldStore() const override final; | ||
|
||
private: | ||
/// Whether or not this ElementReporter should always store its information; see shouldStore() | ||
const bool _always_store; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
//* This file is part of the MOOSE framework | ||
//* https://www.mooseframework.org | ||
//* | ||
//* All rights reserved, see COPYRIGHT for full restrictions | ||
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT | ||
//* | ||
//* Licensed under LGPL 2.1, please see LICENSE for details | ||
//* https://www.gnu.org/licenses/lgpl-2.1.html | ||
|
||
#pragma once | ||
|
||
#include "ElementReporter.h" | ||
|
||
class ElementStatistics : public ElementReporter | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
ElementStatistics(const InputParameters & parameters); | ||
|
||
protected: | ||
virtual void initialize() override; | ||
virtual void execute() override; | ||
virtual void threadJoin(const UserObject &) override; | ||
virtual void finalize() override; | ||
|
||
virtual Real computeValue() = 0; | ||
|
||
private: | ||
const std::string _base_name; | ||
Real & _max; | ||
Real & _min; | ||
Real & _average; | ||
Real & _integral; | ||
int & _number_elements; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//* This file is part of the MOOSE framework | ||
//* https://www.mooseframework.org | ||
//* | ||
//* All rights reserved, see COPYRIGHT for full restrictions | ||
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT | ||
//* | ||
//* Licensed under LGPL 2.1, please see LICENSE for details | ||
//* https://www.gnu.org/licenses/lgpl-2.1.html | ||
|
||
#pragma once | ||
|
||
#include "ElementStatistics.h" | ||
|
||
class ElementVariableStatistics : public ElementStatistics | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
ElementVariableStatistics(const InputParameters & parameters); | ||
|
||
private: | ||
virtual Real computeValue() override; | ||
|
||
/// The coupled variable used. | ||
const VariableValue & _v; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//* This file is part of the MOOSE framework | ||
//* https://www.mooseframework.org | ||
//* | ||
//* All rights reserved, see COPYRIGHT for full restrictions | ||
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT | ||
//* | ||
//* Licensed under LGPL 2.1, please see LICENSE for details | ||
//* https://www.gnu.org/licenses/lgpl-2.1.html | ||
|
||
#pragma once | ||
|
||
// MOOSE includes | ||
#include "NodalUserObject.h" | ||
#include "Reporter.h" | ||
|
||
/** | ||
*/ | ||
class NodalReporter : public NodalUserObject, public Reporter | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
NodalReporter(const InputParameters & parameters); | ||
|
||
/** | ||
* @returns Whether or not this Reporter should store its value at this specific time. | ||
* | ||
* If the private parameter '_always_store' is true, this will always return true. | ||
* Otherwise, it will return true if the current execute flag matches a flag | ||
* that this NodalReporter has in its 'execute_on' parameter. Otherwise, it will | ||
* return false. | ||
* | ||
* This enables NodalReporter objects that do not fill information ahead of time in | ||
* execute() but instead fill their information in the to_json implementation. | ||
* Without this, said NodalReporters would always output their information even though | ||
* the user requested that they do not execute on a specific flag. | ||
*/ | ||
bool shouldStore() const override final; | ||
|
||
private: | ||
/// Whether or not this NodalReporter should always store its information; see shouldStore() | ||
const bool _always_store; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//* This file is part of the MOOSE framework | ||
//* https://www.mooseframework.org | ||
//* | ||
//* All rights reserved, see COPYRIGHT for full restrictions | ||
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT | ||
//* | ||
//* Licensed under LGPL 2.1, please see LICENSE for details | ||
//* https://www.gnu.org/licenses/lgpl-2.1.html | ||
|
||
#pragma once | ||
|
||
#include "NodalReporter.h" | ||
|
||
class NodalStatistics : public NodalReporter | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
NodalStatistics(const InputParameters & parameters); | ||
|
||
protected: | ||
virtual void initialize() override; | ||
virtual void execute() override; | ||
virtual void finalize() override; | ||
virtual void threadJoin(const UserObject &) override; | ||
virtual Real computeValue() = 0; | ||
|
||
private: | ||
const std::string _base_name; | ||
Real & _max; | ||
Real & _min; | ||
Real & _average; | ||
int & _number_nodes; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//* This file is part of the MOOSE framework | ||
//* https://www.mooseframework.org | ||
//* | ||
//* All rights reserved, see COPYRIGHT for full restrictions | ||
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT | ||
//* | ||
//* Licensed under LGPL 2.1, please see LICENSE for details | ||
//* https://www.gnu.org/licenses/lgpl-2.1.html | ||
|
||
#pragma once | ||
|
||
#include "NodalStatistics.h" | ||
|
||
class NodalVariableStatistics : public NodalStatistics | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
NodalVariableStatistics(const InputParameters & parameters); | ||
|
||
private: | ||
virtual Real computeValue() override; | ||
|
||
/// The coupled variable used. | ||
const VariableValue & _v; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
//* This file is part of the MOOSE framework | ||
//* https://www.mooseframework.org | ||
//* | ||
//* All rights reserved, see COPYRIGHT for full restrictions | ||
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT | ||
//* | ||
//* Licensed under LGPL 2.1, please see LICENSE for details | ||
//* https://www.gnu.org/licenses/lgpl-2.1.html | ||
|
||
// MOOSE includes | ||
#include "ElementReporter.h" | ||
|
||
InputParameters | ||
ElementReporter::validParams() | ||
{ | ||
InputParameters params = ElementUserObject::validParams(); | ||
params += Reporter::validParams(); | ||
// Whether or not to always store this object's value | ||
// See the override for shouldStore() for more information | ||
params.addPrivateParam<bool>("_always_store", true); | ||
|
||
return params; | ||
} | ||
|
||
ElementReporter::ElementReporter(const InputParameters & parameters) | ||
: ElementUserObject(parameters), Reporter(this), _always_store(getParam<bool>("_always_store")) | ||
{ | ||
} | ||
|
||
bool | ||
ElementReporter::shouldStore() const | ||
{ | ||
// Either we always store, or we store if the current execution flag matches | ||
// a flag that is within this ElementReporter's 'execute_on' | ||
return _always_store || getExecuteOnEnum().contains(_fe_problem.getCurrentExecuteOnFlag()); | ||
} |
Oops, something went wrong.