Skip to content

Commit

Permalink
Make ElementCentroidRays do the right thing in parallel closes #5 ida…
Browse files Browse the repository at this point in the history
  • Loading branch information
friedmud committed Sep 26, 2018
1 parent e16f6e2 commit 806e3a5
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 12 deletions.
16 changes: 12 additions & 4 deletions modules/ray_tracing/include/ray_tracing/Ray.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,10 @@ class Packing<std::shared_ptr<Ray>>
// Points
total_size += LIBMESH_DIM * 2;

// Starting element, incoming side, processor crosssings, intersections, distance,
// Starting element, ends within mesh, incoming side, processor crosssings, intersections,
// distance,
// integrated_distance, azimuthal_spacing, azimuthal_weight, polar_spacing, id
total_size += 10;
total_size += 11;

return total_size;
}
Expand Down Expand Up @@ -292,9 +293,10 @@ class Packing<std::shared_ptr<Ray>>
// Points
total_size += LIBMESH_DIM * 2;

// Starting element, incoming side, processor crosssings, intersections, distance,
// Starting element, ends within mesh, incoming side, processor crosssings, intersections,
// distance,
// integrated_distance, azimuthal_spacing, azimuthal_weight, polar_spacing, id
total_size += 10;
total_size += 11;

return total_size;
}
Expand Down Expand Up @@ -326,6 +328,9 @@ class Packing<std::shared_ptr<Ray>>
// Starting element
data_out = b->startingElem()->id();

// Ends within mesh
data_out = b->endsWithinMesh();

// Incoming side
data_out = b->incomingSide();

Expand Down Expand Up @@ -395,6 +400,9 @@ class Packing<std::shared_ptr<Ray>>
auto mesh = static_cast<MeshBase *>(mesh_context);
ray->setStartingElem(mesh->elem((*in++)));

// Ends Within Mesh
ray->setEndsWithinMesh((*in++));

// Incoming side
ray->setIncomingSide((*in++));

Expand Down
3 changes: 2 additions & 1 deletion modules/ray_tracing/src/ray_tracing/Ray.C
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ Ray::operator==(const Ray & other)
_integrated_distance == other._integrated_distance &&
_azimuthal_spacing == other._azimuthal_spacing &&
_azimuthal_weight == other._azimuthal_weight && _polar_spacing == other._polar_spacing &&
_polar_sins == other._polar_sins && _polar_weights == other._polar_weights;
_polar_sins == other._polar_sins && _polar_weights == other._polar_weights &&
_ends_within_mesh == other._ends_within_mesh;
}
17 changes: 15 additions & 2 deletions modules/ray_tracing/src/ray_tracing/TraceRay.C
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ namespace TraceRay

unsigned long int ray_count = 0;

unsigned int debug_ray = 9999999;
unsigned int debug_ray = 0;

unsigned int debug_ray_id = 55;
unsigned int debug_ray_id = 0;

unsigned int debug_ray_pid = 0;

Expand Down Expand Up @@ -815,8 +815,17 @@ traceRay(const std::shared_ptr<Ray> & ray,
// If the ray ends within the mesh... let's see if it ends within this element!
if (ray->endsWithinMesh())
{
#ifdef USE_DEBUG_RAY
if (ray->id() == debug_ray_id)
std::cerr << "ends within mesh!" << std::endl;
#endif

if (current_elem->contains_point(ray->end()))
{
#ifdef USE_DEBUG_RAY
if (ray->id() == debug_ray_id)
std::cerr << " ends within current elem!" << std::endl;
#endif
ends_in_elem = true;
intersection_point = ray->end();
}
Expand Down Expand Up @@ -1205,6 +1214,10 @@ traceRay(const std::shared_ptr<Ray> & ray,

if (halo_count == halo_size)
{
#ifdef USE_DEBUG_RAY
if (ray->id() == debug_ray_id)
std::cerr << "Ray going off processor!" << std::endl;
#endif
ray->setStartingElem(neighbor);
ray->setIncomingSide(incoming_side);
ray->setStart(incoming_point);
Expand Down
19 changes: 14 additions & 5 deletions modules/ray_tracing/src/userobjects/ElementCentroidRays.C
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ validParams<ElementCentroidRays>()
params.addRequiredParam<std::vector<dof_id_type>>("start_elems",
"The elements to start the Rays from");
params.addRequiredParam<std::vector<dof_id_type>>("end_elems",
"The elements to start the Rays from");
"The elements tco start the Rays from");
return params;
}

Expand All @@ -30,6 +30,8 @@ ElementCentroidRays::generateRays()
{
std::vector<std::shared_ptr<Ray>> rays;

auto pid = processor_id();

for (auto i = beginIndex(_start_elems); i < _start_elems.size(); i++)
{
auto start_elem_id = _start_elems[i];
Expand All @@ -38,12 +40,19 @@ ElementCentroidRays::generateRays()
auto start_elem = _mesh.elemPtr(start_elem_id);
auto end_elem = _mesh.elemPtr(end_elem_id);

auto ray = std::make_shared<Ray>(
start_elem->centroid(), end_elem->centroid(), _num_groups, start_elem);
if (start_elem->processor_id() == pid)
{
_rays_started++;

auto ray = std::make_shared<Ray>(
start_elem->centroid(), end_elem->centroid(), _num_groups, start_elem);

ray->setID(i);

ray->setEndsWithinMesh();
ray->setEndsWithinMesh();

rays.emplace_back(ray);
rays.emplace_back(ray);
}
}

chunkyTraceAndBuffer(rays);
Expand Down

0 comments on commit 806e3a5

Please sign in to comment.