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 #12935 from permcody/dyanmic_point_sampler
Dynamic point sampler
- Loading branch information
Showing
13 changed files
with
310 additions
and
12 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
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
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
35 changes: 35 additions & 0 deletions
35
test/include/vectorpostprocessors/DynamicPointValueSampler.h
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,35 @@ | |||
//* 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 | |||
|
|||
#ifndef DYNAMICPOINTVALUESAMPLER_H | |||
#define DYNAMICPOINTVALUESAMPLER_H | |||
|
|||
// MOOSE includes | |||
#include "LineValueSampler.h" | |||
|
|||
// Forward Declarations | |||
class DynamicPointValueSampler; | |||
|
|||
template <> | |||
InputParameters validParams<DynamicPointValueSampler>(); | |||
|
|||
class DynamicPointValueSampler : public LineValueSampler | |||
{ | |||
public: | |||
DynamicPointValueSampler(const InputParameters & parameters); | |||
|
|||
virtual void initialize() override; | |||
|
|||
protected: | |||
const unsigned int _adder; | |||
|
|||
const bool _use_transfer; | |||
}; | |||
|
|||
#endif |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,53 @@ | |||
//* 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 "DynamicPointValueSampler.h" | |||
|
|||
registerMooseObject("MooseTestApp", DynamicPointValueSampler); | |||
|
|||
template <> | |||
InputParameters | |||
validParams<DynamicPointValueSampler>() | |||
{ | |||
InputParameters params = validParams<LineValueSampler>(); | |||
|
|||
params.addParam<unsigned int>( | |||
"num_points_adder", 2, "The number of new points to add each iteration"); | |||
|
|||
params.addParam<bool>( | |||
"test_transfer_points_vector", | |||
false, | |||
"Set to true to use the transferPointsVector API (Default setPointsVector)."); | |||
|
|||
return params; | |||
} | |||
|
|||
DynamicPointValueSampler::DynamicPointValueSampler(const InputParameters & parameters) | |||
: LineValueSampler(parameters), | |||
_adder(getParam<unsigned int>("num_points_adder")), | |||
_use_transfer(getParam<bool>("test_transfer_points_vector")) | |||
{ | |||
} | |||
|
|||
void | |||
DynamicPointValueSampler::initialize() | |||
{ | |||
_num_points = _num_points + _adder; | |||
|
|||
std::vector<Point> points; | |||
generatePointsAndIDs(_start_point, _end_point, _num_points, points, _ids); | |||
|
|||
// We don't need to use the public API here, but we are doing it for testing | |||
if (_use_transfer) | |||
transferPointsVector(std::move(points)); | |||
else | |||
setPointsVector(points); | |||
|
|||
LineValueSampler::initialize(); | |||
} |
120 changes: 120 additions & 0 deletions
120
test/tests/vectorpostprocessors/dynamic_point_sampler/dynamic_point_sampler.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,120 @@ | |||
[Mesh] | |||
type = GeneratedMesh | |||
nx = 5 | |||
ny = 5 | |||
dim = 2 | |||
[] | |||
|
|||
[Variables] | |||
[u] | |||
[] | |||
[] | |||
|
|||
[Functions] | |||
[forcing_func] | |||
type = ParsedFunction | |||
value = alpha*alpha*pi*pi*sin(alpha*pi*x) | |||
vars = 'alpha' | |||
vals = '4' | |||
[] | |||
|
|||
[u_func] | |||
type = ParsedGradFunction | |||
value = sin(alpha*pi*x) | |||
grad_x = alpha*pi*sin(alpha*pi*x) | |||
vars = 'alpha' | |||
vals = '4' | |||
[] | |||
[] | |||
|
|||
[Kernels] | |||
[diff] | |||
type = CoefDiffusion | |||
variable = u | |||
coef = 0.1 | |||
[] | |||
|
|||
[forcing] | |||
type = BodyForce | |||
variable = u | |||
function = forcing_func | |||
[] | |||
|
|||
[time] | |||
type = TimeDerivative | |||
variable = u | |||
[] | |||
[] | |||
|
|||
[BCs] | |||
[left] | |||
type = DirichletBC | |||
variable = 'u' | |||
boundary = 'left' | |||
value = 0 | |||
[] | |||
|
|||
[right] | |||
type = DirichletBC | |||
variable = 'u' | |||
boundary = 'right' | |||
value = 0 | |||
[] | |||
[] | |||
|
|||
[Executioner] | |||
type = Transient | |||
num_steps = 7 | |||
dt = 0.1 | |||
|
|||
petsc_options_iname = '-pc_type -pc_hypre_type' | |||
petsc_options_value = 'hypre boomeramg' | |||
[] | |||
|
|||
[Postprocessors] | |||
[l2_error] | |||
type = ElementL2Error | |||
variable = u | |||
function = u_func | |||
[] | |||
|
|||
[dofs] | |||
type = NumDOFs | |||
[] | |||
[] | |||
|
|||
[Adaptivity] | |||
max_h_level = 3 | |||
marker = error | |||
[Indicators] | |||
[jump] | |||
type = GradientJumpIndicator | |||
variable = u | |||
[] | |||
[] | |||
[Markers] | |||
[error] | |||
type = ErrorFractionMarker | |||
indicator = jump | |||
coarsen = 0.1 | |||
refine = 0.3 | |||
[] | |||
[] | |||
[] | |||
|
|||
[VectorPostprocessors] | |||
[dynamic_line_sampler] | |||
type = DynamicPointValueSampler | |||
variable = u | |||
start_point = '0 0.5 0' | |||
end_point = '1 0.5 0' | |||
num_points = 6 | |||
sort_by = x | |||
execute_on = 'initial timestep_end' | |||
[] | |||
[] | |||
|
|||
[Outputs] | |||
exodus = true | |||
csv = true | |||
[] |
11 changes: 11 additions & 0 deletions
11
...essors/dynamic_point_sampler/gold/dynamic_point_sampler_out_dynamic_line_sampler_0001.csv
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,11 @@ | |||
x,y,z,id,u | |||
0,0.5,0,0,0 | |||
0.11111111111111,0.5,0,0.11111111111111,2.3595199239821 | |||
0.22222222222222,0.5,0,0.22222222222222,3.0116751915442 | |||
0.33333333333333,0.5,0,0.33333333333333,-3.1656281665735 | |||
0.44444444444444,0.5,0,0.44444444444444,-3.8177834341356 | |||
0.55555555555556,0.5,0,0.55555555555556,3.8177834341355 | |||
0.66666666666667,0.5,0,0.66666666666667,3.1656281665734 | |||
0.77777777777778,0.5,0,0.77777777777778,-3.0116751915443 | |||
0.88888888888889,0.5,0,0.88888888888889,-2.3595199239821 | |||
1,0.5,0,1,-1.8861072096e-15 |
21 changes: 21 additions & 0 deletions
21
...essors/dynamic_point_sampler/gold/dynamic_point_sampler_out_dynamic_line_sampler_0006.csv
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,21 @@ | |||
x,y,z,id,u | |||
0,0.5,0,0,0 | |||
0.052631578947368,0.5,0,0.052631578947368,5.9788294723389 | |||
0.10526315789474,0.5,0,0.10526315789474,9.4011636294063 | |||
0.15789473684211,0.5,0,0.15789473684211,8.8365135832746 | |||
0.21052631578947,0.5,0,0.21052631578947,4.5300836212104 | |||
0.26315789473684,0.5,0,0.26315789473684,-1.7013726574824 | |||
0.31578947368421,0.5,0,0.31578947368421,-7.2587341323989 | |||
0.36842105263158,0.5,0,0.36842105263158,-9.8015204019932 | |||
0.42105263157895,0.5,0,0.42105263157895,-8.2408102762147 | |||
0.47368421052632,0.5,0,0.47368421052632,-3.2024426012765 | |||
0.52631578947368,0.5,0,0.52631578947368,3.2024426012618 | |||
0.57894736842105,0.5,0,0.57894736842105,8.2408102761943 | |||
0.63157894736842,0.5,0,0.63157894736842,9.8015204019903 | |||
0.68421052631579,0.5,0,0.68421052631579,7.2587341323924 | |||
0.73684210526316,0.5,0,0.73684210526316,1.701372657481 | |||
0.78947368421053,0.5,0,0.78947368421053,-4.5300836212134 | |||
0.84210526315789,0.5,0,0.84210526315789,-8.8365135832819 | |||
0.89473684210526,0.5,0,0.89473684210526,-9.4011636294108 | |||
0.94736842105263,0.5,0,0.94736842105263,-5.9788294723449 | |||
1,0.5,0,1,-3.3543535025412e-16 |
23 changes: 23 additions & 0 deletions
23
test/tests/vectorpostprocessors/dynamic_point_sampler/tests
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,23 @@ | |||
[Tests] | |||
[dynamic_point_sampler] | |||
type = CSVDiff | |||
input = dynamic_point_sampler.i | |||
csvdiff = 'dynamic_point_sampler_out_dynamic_line_sampler_0001.csv dynamic_point_sampler_out_dynamic_line_sampler_0006.csv' | |||
|
|||
issues = "#12934" | |||
design = "LineValueSampler.md" | |||
requirement = "The system shall support dynamic numbers of sample points during the simulation." | |||
[] | |||
|
|||
[dynamic_point_sampler_transfer] | |||
type = CSVDiff | |||
input = dynamic_point_sampler.i | |||
csvdiff = 'dynamic_point_sampler_out_dynamic_line_sampler_0001.csv dynamic_point_sampler_out_dynamic_line_sampler_0006.csv' | |||
cli_args = 'VectorPostprocessors/dynamic_line_sampler/test_transfer_points_vector=true' | |||
prereq = 'dynamic_point_sampler' | |||
|
|||
issues = "#12934" | |||
design = "LineValueSampler.md" | |||
requirement = "The system shall support dynamic numbers of sample points during the simulation with move semantics of the points vector." | |||
[] | |||
[] |