Skip to content

Commit

Permalink
Removed the ray id from the Particle data collector that will actuall…
Browse files Browse the repository at this point in the history
…y be used by end users since they do not care about particle meta data

Closes idaholab#63, idaholab#62, and constributes to idaholab#23, idaholab#27, idaholab#61
  • Loading branch information
gsgall committed Aug 2, 2024
1 parent a833086 commit 67d724c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
16 changes: 8 additions & 8 deletions src/vectorpostprocessors/ParticleDataVectorPostprocessor.C
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ ParticleDataVectorPostprocessor::ParticleDataVectorPostprocessor(const InputPara
_study.getRayDataIndex("v_z")
}),
_data_values({
&declareVector("id"),
&declareVector("t_pos"),
&declareVector("t_vel"),
&declareVector("x"),
Expand Down Expand Up @@ -71,15 +70,16 @@ ParticleDataVectorPostprocessor::execute()
const auto rays = _study.getBankedRays();
for (const auto & ray : rays)
{
_data_values[0]->push_back(ray->id());
_data_values[1]->push_back(_t);
_data_values[2]->push_back(_t - _dt / 2);
// storing the time at which the particle position is known
_data_values[0]->push_back(_t);
// storing the time at which the particle velocity is known
_data_values[1]->push_back(_t - _dt / 2);
const auto & point = ray->currentPoint();
for (const auto i : make_range(3, 6))
_data_values[i]->push_back(point(i - 3));
for (const auto i : make_range(2, 5))
_data_values[i]->push_back(point(i - 2));

for (const auto i : make_range(6, int(6 + _ray_data_indices.size())))
_data_values[i]->push_back(ray->data(_ray_data_indices[i - 6]));
for (const auto i : make_range(5, int(5 + _ray_data_indices.size())))
_data_values[i]->push_back(ray->data(_ray_data_indices[i - 5]));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ class TestParticleDataVectorPostprocessor : public ParticleDataVectorPostprocess

TestParticleDataVectorPostprocessor(const InputParameters & parameters);

/**
* adds the ray id to the particle data for sorting results
* This will help ensure testability
*/
virtual void execute() override;
/**
* In the testing version of this the finalize not only
* communicates between procs but also sorts the data by ray
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,22 @@ TestParticleDataVectorPostprocessor::validParams()
}

TestParticleDataVectorPostprocessor::TestParticleDataVectorPostprocessor(const InputParameters & parameters)
: ParticleDataVectorPostprocessor(parameters) {}
: ParticleDataVectorPostprocessor(parameters) {
_data_values.push_back(&declareVector("id"));
}

void
TestParticleDataVectorPostprocessor::execute()
{
// this does end up looping over the rays twice
// but since it will only be for testing this is fine
// helps to test the behaviour of the object people will actually
// use without requiring it to store meta data that is not important for them.
ParticleDataVectorPostprocessor::execute();
const auto rays = _study.getBankedRays();
for (const auto & ray : rays)
_data_values.back()->push_back(ray->id());
}

void
TestParticleDataVectorPostprocessor::finalize()
Expand All @@ -38,7 +52,7 @@ TestParticleDataVectorPostprocessor::finalize()
indicies.end(),
[&](size_t a, size_t b) -> bool
{
return (*_data_values.front())[a] < (*_data_values.front())[b];
return (*_data_values.back())[a] < (*_data_values.back())[b];
});

for (auto data : _data_values)
Expand Down

0 comments on commit 67d724c

Please sign in to comment.