Skip to content

Commit

Permalink
Support ability to append data to StochasticResults
Browse files Browse the repository at this point in the history
(closes #14412)

(refs #14410)
  • Loading branch information
aeslaughter committed Nov 27, 2019
1 parent 84d3f94 commit d06a6dc
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 4 deletions.
Expand Up @@ -61,8 +61,13 @@ SamplerPostprocessorTransfer::initializeFromMultiapp()
VectorPostprocessorValue & vpp =
_fe_problem.getVectorPostprocessorValue(_master_vpp_name, _sampler_ptr->name(), false);

vpp.clear();
vpp.reserve(_sampler_ptr->getNumberOfLocalRows());
if (_results->containsCompleteHistory())
vpp.reserve(vpp.size() + _sampler_ptr->getNumberOfLocalRows());
else
{
vpp.clear();
vpp.reserve(_sampler_ptr->getNumberOfLocalRows());
}
}

void
Expand Down Expand Up @@ -93,8 +98,13 @@ SamplerPostprocessorTransfer::execute()
VectorPostprocessorValue & vpp =
_fe_problem.getVectorPostprocessorValue(_master_vpp_name, _sampler_ptr->name(), false);

vpp.clear();
vpp.reserve(_sampler_ptr->getNumberOfLocalRows());
if (_results->containsCompleteHistory())
vpp.reserve(vpp.size() + _sampler_ptr->getNumberOfLocalRows());
else
{
vpp.clear();
vpp.reserve(_sampler_ptr->getNumberOfLocalRows());
}

for (dof_id_type i = _sampler_ptr->getLocalRowBegin(); i < _sampler_ptr->getLocalRowEnd(); ++i)
{
Expand Down
@@ -0,0 +1,7 @@
sample
0.21807618260197
0.29861301975328
0.26436928795656
0.27233202431949
0.37553147478812
0.35621162097419
@@ -0,0 +1,84 @@
[Mesh]
type = GeneratedMesh
dim = 1
nx = 1
ny = 1
[]

[Variables]
[u]
[]
[]

[Distributions]
[uniform_left]
type = UniformDistribution
lower_bound = 0
upper_bound = 0.5
[]
[uniform_right]
type = UniformDistribution
lower_bound = 1
upper_bound = 2
[]
[]

[Samplers]
[sample]
type = MonteCarloSampler
num_rows = 3
distributions = 'uniform_left uniform_right'
execute_on = 'INITIAL TIMESTEP_END'
[]
[]

[MultiApps]
[sub]
type = SamplerTransientMultiApp
input_files = sub.i
sampler = sample
[]
[]

[Transfers]
[runner]
type = SamplerParameterTransfer
multi_app = sub
sampler = sample
parameters = 'BCs/left/value BCs/right/value'
to_control = 'stochastic'
[]
[data]
type = SamplerPostprocessorTransfer
multi_app = sub
sampler = sample
vector_postprocessor = storage
postprocessor = avg
[]
[]

[VectorPostprocessors]
[storage]
type = StochasticResults
parallel_type = DISTRIBUTED
samplers = sample
contains_complete_history = true
[]
[]

[Executioner]
type = Transient
num_steps = 2
[]

[Problem]
solve = false
kernel_coverage_check = false
[]

[Outputs]
[out]
type = CSV
execute_on = FINAL
[]
[]
@@ -0,0 +1,61 @@
[Mesh]
type = GeneratedMesh
dim = 1
nx = 10
[]

[Variables]
[u]
[]
[]

[Kernels]
[diff]
type = Diffusion
variable = u
[]
[time]
type = TimeDerivative
variable = u
[]
[]

[BCs]
[left]
type = DirichletBC
variable = u
boundary = left
value = 0
[]
[right]
type = DirichletBC
variable = u
boundary = right
value = 1
[]
[]

[Executioner]
type = Transient
num_steps = 2
dt = 0.01
solve_type = PJFNK
petsc_options_iname = '-pc_type -pc_hypre_type'
petsc_options_value = 'hypre boomeramg'
[]

[Controls]
[stochastic]
type = SamplerReceiver
[]
[]

[Postprocessors]
[avg]
type = AverageNodalVariableValue
variable = u
[]
[]

[Outputs]
[]
@@ -0,0 +1,13 @@
[Tests]
issues = '#14412'
design = 'StochasticResults.md'

[test]
type = CSVDiff
input = master.i
csvdiff = master_out_storage.csv

requirement = "The system shall support the collection of stochastic data that can be appended "
"into a single data set."
[]
[]

0 comments on commit d06a6dc

Please sign in to comment.