Skip to content

Commit

Permalink
Add BC convenience interface for single plane
Browse files Browse the repository at this point in the history
  • Loading branch information
streeve committed Jul 3, 2024
1 parent ed9b752 commit 97e70bc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
4 changes: 1 addition & 3 deletions examples/mechanics/fragmenting_cylinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ void fragmentingCylinderExample( const std::string filename )

CabanaPD::RegionBoundary<CabanaPD::Cylinder> plane(
Rin - dx / 0.5, Rin + dx / 0.5, -0.5 * height, 0.5 * height );
std::vector<CabanaPD::RegionBoundary<CabanaPD::Cylinder>> planes = {
plane };
auto bc = createBoundaryCondition( CabanaPD::ForceValueBCTag{}, 0.0,
exec_space{}, *particles, planes );
exec_space{}, *particles, plane );

// ====================================================
// Custom particle initialization
Expand Down
4 changes: 1 addition & 3 deletions examples/mechanics/kalthoff_winkler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,8 @@ void kalthoffWinklerExample( const std::string filename )
CabanaPD::RegionBoundary<CabanaPD::Rectilinear> plane(
x_bc - dx, x_bc + dx * 1.25, y_prenotch1 - dx * 0.25,
y_prenotch2 + dx * 0.25, -thickness, thickness );
std::vector<CabanaPD::RegionBoundary<CabanaPD::Rectilinear>> planes = {
plane };
auto bc = createBoundaryCondition( CabanaPD::ForceValueBCTag{}, 0.0,
exec_space{}, *particles, planes );
exec_space{}, *particles, plane );

// ====================================================
// Custom particle initialization
Expand Down
23 changes: 23 additions & 0 deletions src/CabanaPD_Boundary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,29 @@ auto createBoundaryCondition( UserFunctor user_functor, ExecSpace exec_space,
bc_indices, user_functor, force_update );
}

template <class BoundaryType, class BCTag, class ExecSpace, class Particles>
auto createBoundaryCondition( BCTag tag, const double value,
ExecSpace exec_space, Particles particles,
BoundaryType plane,
const double initial_guess = 0.5 )
{
std::vector<BoundaryType> plane_vec = { plane };
return createBoundaryCondition( tag, value, exec_space, particles,
plane_vec, initial_guess );
}

template <class UserFunctor, class BoundaryType, class ExecSpace,
class Particles>
auto createBoundaryCondition( UserFunctor user_functor, ExecSpace exec_space,
Particles particles, BoundaryType plane,
const bool force_update,
const double initial_guess = 0.5 )
{
std::vector<BoundaryType> plane_vec = { plane };
return createBoundaryCondition( user_functor, exec_space, particles,
plane_vec, force_update, initial_guess );
}

} // namespace CabanaPD

#endif

0 comments on commit 97e70bc

Please sign in to comment.