Skip to content

Commit

Permalink
Rearrange boundary conditions after solver init;
Browse files Browse the repository at this point in the history
remove zero boundary
  • Loading branch information
streeve committed May 28, 2024
1 parent b61246d commit 3a0923e
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 103 deletions.
6 changes: 3 additions & 3 deletions examples/mechanics/crack_branching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ void crackBranchingExample( const std::string filename )
// Simulation run
// ====================================================
auto cabana_pd = CabanaPD::createSolverFracture<memory_space>(
inputs, particles, force_model, bc, prenotch );
cabana_pd->init_force();
cabana_pd->run();
inputs, particles, force_model, prenotch );
cabana_pd->init();
cabana_pd->run( bc );
}

// Initialize MPI+Kokkos.
Expand Down
10 changes: 2 additions & 8 deletions examples/mechanics/elastic_wave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@ void elasticWaveExample( const std::string filename )
typename model_type::thermal_type>>(
exec_space(), low_corner, high_corner, num_cells, halo_width );

// ====================================================
// Boundary conditions
// ====================================================
auto bc = CabanaPD::createBoundaryCondition<memory_space>(
CabanaPD::ZeroBCTag{} );

// ====================================================
// Custom particle initialization
// ====================================================
Expand Down Expand Up @@ -111,8 +105,8 @@ void elasticWaveExample( const std::string filename )
// Simulation run
// ====================================================
auto cabana_pd = CabanaPD::createSolverElastic<memory_space>(
inputs, particles, force_model, bc );
cabana_pd->init_force();
inputs, particles, force_model );
cabana_pd->init();
cabana_pd->run();

// ====================================================
Expand Down
6 changes: 3 additions & 3 deletions examples/mechanics/kalthoff_winkler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ void kalthoffWinklerExample( const std::string filename )
// Simulation run
// ====================================================
auto cabana_pd = CabanaPD::createSolverFracture<memory_space>(
inputs, particles, force_model, bc, prenotch );
cabana_pd->init_force();
cabana_pd->run();
inputs, particles, force_model, prenotch );
cabana_pd->init();
cabana_pd->run( bc );
}

// Initialize MPI+Kokkos.
Expand Down
38 changes: 22 additions & 16 deletions examples/thermomechanics/thermal_deformation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,6 @@ void thermalDeformationExample( const std::string filename )
CabanaPD::Particles<memory_space, model_type, thermal_type>>(
exec_space(), low_corner, high_corner, num_cells, halo_width );

// ====================================================
// Imposed field
// ====================================================
auto x = particles->sliceReferencePosition();
auto temp = particles->sliceTemperature();
const double low_corner_y = low_corner[1];
auto temp_func = KOKKOS_LAMBDA( const int pid, const double t )
{
temp( pid ) = 5000.0 * ( x( pid, 1 ) - low_corner_y ) * t;
};
auto body_term = CabanaPD::createBodyTerm( temp_func );

// ====================================================
// Custom particle initialization
// ====================================================
Expand All @@ -98,12 +86,30 @@ void thermalDeformationExample( const std::string filename )
*particles, delta, K, alpha, temp0 );

// ====================================================
// Simulation run
// Create solver
// ====================================================
auto cabana_pd = CabanaPD::createSolverElastic<memory_space>(
inputs, particles, force_model, body_term );
cabana_pd->init_force();
cabana_pd->run();
inputs, particles, force_model );
cabana_pd->init();

// ====================================================
// Imposed field
// ====================================================
auto x = particles->sliceReferencePosition();
auto temp = particles->sliceTemperature();
const double low_corner_y = low_corner[1];
// This is purposely delayed until after solver init so that ghosted
// particles are correctly taken into account for lambda capture here.
auto temp_func = KOKKOS_LAMBDA( const int pid, const double t )
{
temp( pid ) = 5000.0 * ( x( pid, 1 ) - low_corner_y ) * t;
};
auto body_term = CabanaPD::createBodyTerm( temp_func );

// ====================================================
// Simulation run
// ====================================================
cabana_pd->run( body_term );
}

// Initialize MPI+Kokkos.
Expand Down
25 changes: 0 additions & 25 deletions src/CabanaPD_Boundary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,6 @@ struct ForceUpdateBCTag
{
};

struct ZeroBCTag
{
};

template <class BCIndexSpace, class UserFunctor>
struct BoundaryCondition
{
Expand Down Expand Up @@ -168,20 +164,6 @@ struct BoundaryCondition
}
};

template <class BCIndexSpace>
struct BoundaryCondition<BCIndexSpace, ZeroBCTag>
{
template <class ExecSpace, class Particles>
void update( ExecSpace, Particles, RegionBoundary )
{
}

template <class ExecSpace, class ParticleType>
void apply( ExecSpace, ParticleType, double )
{
}
};

template <class BCIndexSpace>
struct BoundaryCondition<BCIndexSpace, ForceValueBCTag>
{
Expand Down Expand Up @@ -282,13 +264,6 @@ auto createBoundaryCondition( UserFunctor user_functor, ExecSpace exec_space,
user_functor );
}

template <class MemorySpace>
auto createBoundaryCondition( ZeroBCTag )
{
using bc_index_type = BoundaryIndexSpace<MemorySpace, RegionBoundary>;
return BoundaryCondition<bc_index_type, ZeroBCTag>();
}

} // namespace CabanaPD

#endif
Loading

0 comments on commit 3a0923e

Please sign in to comment.