Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable frozen points for boundaries #160

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

streeve
Copy link
Collaborator

@streeve streeve commented Dec 16, 2024

Also adds particle class methods for owned, ghost, and global sizes (separate commit)

@streeve streeve requested a review from abisner December 16, 2024 19:03
@streeve streeve self-assigned this Dec 16, 2024
src/CabanaPD_Particles.hpp Outdated Show resolved Hide resolved
src/CabanaPD_Force.hpp Outdated Show resolved Hide resolved
@streeve streeve requested a review from abisner December 18, 2024 21:22
@streeve
Copy link
Collaborator Author

streeve commented Dec 19, 2024

@abisner tests added, mistakes fixed, and multiple sets of particles now possible

Copy link
Collaborator

@abisner abisner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried to give it another pretty thorough pass. Just a few minor suggestions/fixes is all. One big takeaway in createParticles() is that the localOffset should always be updated to the final resized size, whereas the frozenOffset can sometimes be updated to "point" to the same localOffset.

return false;
};
// Create more, starting from the current number of frozen points.
particles.createParticles( exec_space{}, init_top, particles.numFrozen() );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
particles.createParticles( exec_space{}, init_top, particles.numFrozen() );
particles.createParticles( exec_space{}, init_top, particles.frozenOffset() );

x = particles.sliceReferencePosition();
rank = particles.sliceVolume();
auto x_host = Cabana::slice<0>( aosoa_host );
auto rank_host = Cabana::slice<1>( aosoa_host );
Cabana::deep_copy( x_host, x );
Cabana::deep_copy( rank_host, rank );

EXPECT_EQ( particles.n_local, init_num_particles );
EXPECT_EQ( particles.localOffset(), init_num_particles );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this line actually testing? Do either particles.localOffset() or init_num_particles change from line 70? Are there side effects in the construction call comm( particles ) on line 82?


_neigh_timer.start();
_neigh_list.build( y, 0, n_local, Rc, 1.0, mesh_min, mesh_max );
_neigh_list.build( y, n_frozen, n_local, Rc, 1.0, mesh_min, mesh_max );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By design, this is now offset to build the neighbor lists for the local particles only, but all the particles (including the frozen ones) are still considered as potential neighbors during the construction, correct?

// neigh_op_tag );

// Forces only atomic if using team threading.
if ( std::is_same<decltype( neigh_op_tag ), Cabana::TeamOpTag>::value )
force.computeForceFull( f_a, x, u, particles, n_local, neigh_op_tag );
force.computeForceFull( f_a, x, u, particles, neigh_op_tag );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a thought: the frozen particles will never accrue forces themselves, and so this is fundamentally different from an essential displacement BC, I think?

@@ -239,7 +240,6 @@ template <class ForceType, class ParticleType, class ParallelType>
void computeForce( ForceType& force, ParticleType& particles,
const ParallelType& neigh_op_tag, const bool reset = true )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the reset flag now have finer granularity as well, to distinguish between the frozen and local particles?

@@ -496,15 +540,15 @@ class Particles<MemorySpace, PMB, TemperatureIndependent, BaseOutput, Dimension>
#ifdef Cabana_ENABLE_HDF5
Cabana::Experimental::HDF5ParticleOutput::writeTimeStep(
h5_config, "particles", MPI_COMM_WORLD, output_step, output_time,
n_local, getPosition( use_reference ), sliceForce(),
local_offset, getPosition( use_reference ), sliceForce(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
local_offset, getPosition( use_reference ), sliceForce(),
localOffset(), getPosition( use_reference ), sliceForce(),

sliceDisplacement(), sliceVelocity(),
std::forward<OtherFields>( other )... );
#else
#ifdef Cabana_ENABLE_SILO
Cabana::Grid::Experimental::SiloParticleOutput::
writePartialRangeTimeStep(
"particles", local_grid->globalGrid(), output_step, output_time,
0, n_local, getPosition( use_reference ), sliceForce(),
0, local_offset, getPosition( use_reference ), sliceForce(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
0, local_offset, getPosition( use_reference ), sliceForce(),
0, localOffset(), getPosition( use_reference ), sliceForce(),

@@ -887,7 +917,7 @@ class Particles<MemorySpace, ModelType, ThermalType, EnergyOutput, Dimension>
void resize( int new_local, int new_ghost )
{
base_type::resize( new_local, new_ghost );
_aosoa_output.resize( new_local + new_ghost );
_aosoa_output.resize( base_type::localOffset() );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_aosoa_output.resize( base_type::localOffset() );
_aosoa_output.resize( base_type::referenceOffset() );

_aosoa_u.resize( referenceOffset() );
_aosoa_y.resize( referenceOffset() );
_aosoa_vol.resize( referenceOffset() );
_plist_f.aosoa().resize( localOffset() );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason these two only use localOffset rather than referenceOffset like the rest?

@@ -343,14 +357,16 @@ class Particles<MemorySpace, PMB, TemperatureIndependent, BaseOutput, Dimension>
memory_space, typename PositionType::execution_space>::value );

Kokkos::parallel_for(
"copy_to_particles", Kokkos::RangePolicy<ExecSpace>( 0, n_local ),
"copy_to_particles",
Kokkos::RangePolicy<ExecSpace>( num_previous, localOffset() ),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be an assert that num_previous does not exceed localOffset, unless this is caught by the RangePolicy? On second thought, there should also be an assert that the size of the x and vol slices is congruous with the index range (or at least as large).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants