-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reporter that reports the nodal variable values at the elements locat…
…ed by the nearestElemsToLine. Also renamed the variable used to for filtering elements and updated tests. closes #108
- Loading branch information
1 parent
d4c068a
commit 3e7a13d
Showing
10 changed files
with
819 additions
and
6 deletions.
There are no files selected for viewing
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,33 @@ | ||
//* 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 "ClosestElemsToLine.h" | ||
#include "MooseVariableInterface.h" | ||
|
||
class ClosestElemsToLineNodalVarValue : public ClosestElemsToLine, | ||
public MooseVariableInterface<Real> | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
ClosestElemsToLineNodalVarValue(const InputParameters & parameters); | ||
|
||
virtual void initialSetup() override; | ||
|
||
virtual void initialize() override{}; | ||
virtual void execute() override; | ||
virtual void finalize() override; | ||
|
||
private: | ||
std::string _var_name; | ||
MooseVariable & _var; | ||
std::vector<Real> & _value; | ||
}; |
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,77 @@ | ||
//* 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 | ||
|
||
#include "ClosestElemsToLineNodalVarValue.h" | ||
#include "MooseMesh.h" | ||
#include "MooseVariable.h" | ||
|
||
registerMooseObject("FalconApp", ClosestElemsToLineNodalVarValue); | ||
|
||
InputParameters | ||
ClosestElemsToLineNodalVarValue::validParams() | ||
{ | ||
InputParameters params = ClosestElemsToLine::validParams(); | ||
params.addClassDescription("Creates a real_vector_names reporter that has each " | ||
"elements average nodal variable value."); | ||
params.addRequiredParam<VariableName>("variable_to_sample", "The nodal variable to monitor."); | ||
return params; | ||
} | ||
|
||
ClosestElemsToLineNodalVarValue::ClosestElemsToLineNodalVarValue(const InputParameters & parameters) | ||
: ClosestElemsToLine(parameters), | ||
MooseVariableInterface<Real>(this, | ||
false, | ||
"variable_to_sample", | ||
Moose::VarKindType::VAR_ANY, | ||
Moose::VarFieldType::VAR_FIELD_STANDARD), | ||
_var_name(parameters.get<VariableName>("variable_to_sample")), | ||
_var(_subproblem.getStandardVariable(_tid, _var_name)), | ||
_value(declareValueByName<std::vector<Real>>(_var_name, REPORTER_MODE_REPLICATED)) | ||
{ | ||
if (!_var.isNodal()) | ||
mooseError("variable_to_sample must be a nodal variable."); | ||
} | ||
|
||
void | ||
ClosestElemsToLineNodalVarValue::initialSetup() | ||
{ | ||
ClosestElemsToLine::initialSetup(); | ||
_value.resize(_eid.size(), std::numeric_limits<Real>::max()); | ||
} | ||
|
||
void | ||
ClosestElemsToLineNodalVarValue::execute() | ||
{ | ||
const MooseMesh & mesh = _subproblem.mesh(); | ||
for (size_t i = 0; i < _eid.size(); ++i) | ||
{ | ||
Real value = 0.0; | ||
const Elem * elem = mesh.getMesh().query_elem_ptr(_eid[i]); | ||
if (elem->processor_id() == processor_id()) | ||
{ | ||
size_t n = 0; | ||
for (auto & node : elem->node_ref_range()) | ||
{ | ||
value += _var.getNodalValue(node); | ||
n++; | ||
} | ||
if (n > 0) | ||
value /= (Real)n; | ||
} | ||
_value[i] = value; | ||
} | ||
} | ||
|
||
void | ||
ClosestElemsToLineNodalVarValue::finalize() | ||
{ | ||
//_value should be zero on every proc so this will just communicate it. | ||
for (size_t i = 0; i < _eid.size(); ++i) | ||
gatherSum(_value[i]); | ||
} |
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
72 changes: 72 additions & 0 deletions
72
test/tests/reporters/closest_elems_to_line_NodalVarValue/dfn_test.i
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,72 @@ | ||
[Mesh] | ||
[cluster34] | ||
type = FileMeshGenerator | ||
file = 'Cluster_34_zid.e' | ||
use_for_exodus_restart = true | ||
[] | ||
[] | ||
|
||
[Problem] | ||
solve = false | ||
[] | ||
|
||
[AuxVariables] | ||
[z_id] | ||
family = MONOMIAL | ||
order = CONSTANT | ||
initial_from_file_var = z_id | ||
initial_from_file_timestep = 'LATEST' | ||
[] | ||
[one] | ||
order = FIRST | ||
family = LAGRANGE | ||
initial_condition = 1 | ||
[] | ||
[] | ||
|
||
[Executioner] | ||
type = Steady | ||
[] | ||
|
||
[Reporters] | ||
[pt] | ||
type = ConstantReporter | ||
real_vector_names = 'pt1_x pt1_y pt1_z pt2_x pt2_y pt2_z' | ||
real_vector_values = '132.1; 97.5; 189.5; 136.5; 103.2; 50.6' | ||
outputs = none | ||
[] | ||
|
||
[no_var] | ||
block = "9 10" | ||
type = ClosestElemsToLineNodalVarValue | ||
projection_tolerance = 5 | ||
point_x1 = pt/pt1_x | ||
point_y1 = pt/pt1_y | ||
point_z1 = pt/pt1_z | ||
point_x2 = pt/pt2_x | ||
point_y2 = pt/pt2_y | ||
point_z2 = pt/pt2_z | ||
variable_to_sample = one | ||
outputs = out | ||
[] | ||
[domain_var] | ||
type = ClosestElemsToLineNodalVarValue | ||
projection_tolerance = 5 | ||
point_x1 = pt/pt1_x | ||
point_y1 = pt/pt1_y | ||
point_z1 = pt/pt1_z | ||
point_x2 = pt/pt2_x | ||
point_y2 = pt/pt2_y | ||
point_z2 = pt/pt2_z | ||
variable_filter = z_id | ||
variable_to_sample = one | ||
outputs = out | ||
[] | ||
[] | ||
|
||
[Outputs] | ||
[out] | ||
type = JSON | ||
execute_system_information_on = none | ||
[] | ||
[] |
Oops, something went wrong.