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 variable dimension (2d/3d) #58

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/crack_branching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ int main( int argc, char* argv[] )
using model_type =
CabanaPD::ForceModel<CabanaPD::PMB, CabanaPD::Fracture>;
model_type force_model( delta, K, G0 );
CabanaPD::Inputs inputs( num_cell, low_corner, high_corner, t_final, dt,
output_frequency );
CabanaPD::Inputs<3> inputs( num_cell, low_corner, high_corner, t_final,
dt, output_frequency );
inputs.read_args( argc, argv );

// Create particles from mesh.
Expand Down
4 changes: 2 additions & 2 deletions examples/elastic_wave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ int main( int argc, char* argv[] )
CabanaPD::ForceModel<CabanaPD::LinearLPS, CabanaPD::Elastic>;
model_type force_model( delta, K, G );

CabanaPD::Inputs inputs( num_cell, low_corner, high_corner, t_final, dt,
output_frequency );
CabanaPD::Inputs<3> inputs( num_cell, low_corner, high_corner, t_final,
dt, output_frequency );
inputs.read_args( argc, argv );

// Create particles from mesh.
Expand Down
4 changes: 2 additions & 2 deletions examples/kalthoff_winkler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ int main( int argc, char* argv[] )
// using model_type =
// CabanaPD::ForceModel<CabanaPD::LPS, CabanaPD::Fracture>;
// model_type force_model( delta, K, G, G0 );
CabanaPD::Inputs inputs( num_cell, low_corner, high_corner, t_final, dt,
output_frequency );
CabanaPD::Inputs<3> inputs( num_cell, low_corner, high_corner, t_final,
dt, output_frequency );
inputs.read_args( argc, argv );

// Create particles from mesh.
Expand Down
8 changes: 3 additions & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@ configure_file(CabanaPD_config.hpp.cmakein CabanaPD_config.hpp @ONLY)

file(GLOB HEADERS GLOB *.hpp)

file(GLOB SOURCES *.cpp)

install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CabanaPD_config.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

add_library(CabanaPD ${SOURCES})
streeve marked this conversation as resolved.
Show resolved Hide resolved
add_library(CabanaPD INTERFACE)

target_include_directories(CabanaPD PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
target_include_directories(CabanaPD INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)

target_link_libraries(CabanaPD Cabana::cabanacore Cabana::Cajita)
target_link_libraries(CabanaPD INTERFACE Cabana::cabanacore Cabana::Cajita)

install(TARGETS CabanaPD DESTINATION ${CMAKE_INSTALL_LIBDIR})
140 changes: 0 additions & 140 deletions src/CabanaPD_Input.cpp

This file was deleted.

83 changes: 75 additions & 8 deletions src/CabanaPD_Input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,21 @@

#include <string>

#include <CabanaPD_Output.hpp>

namespace CabanaPD
{
template <int Dim = 3>
class Inputs
{
public:
std::string output_file = "cabanaPD.out";
std::string error_file = "cabanaPD.err";
std::string device_type = "SERIAL";

std::array<int, 3> num_cells;
std::array<double, 3> low_corner;
std::array<double, 3> high_corner;
std::array<int, Dim> num_cells;
std::array<double, Dim> low_corner;
std::array<double, Dim> high_corner;

std::size_t num_steps;
double final_time;
Expand All @@ -34,11 +37,75 @@ class Inputs

bool half_neigh = false;

Inputs( const std::array<int, 3> nc, std::array<double, 3> lc,
std::array<double, 3> hc, const double t_f, const double dt,
const int output_freq );
~Inputs();
void read_args( int argc, char* argv[] );
Inputs( const std::array<int, Dim> nc, std::array<double, Dim> lc,
std::array<double, Dim> hc, const double t_f, const double dt,
const int of )
: num_cells( nc )
, low_corner( lc )
, high_corner( hc )
, final_time( t_f )
, timestep( dt )
, output_frequency( of )
{
num_steps = final_time / timestep;
}
~Inputs(){};

void read_args( int argc, char* argv[] )
{
for ( int i = 1; i < argc; i++ )
{
// Help command.
if ( ( strcmp( argv[i], "-h" ) == 0 ) ||
( strcmp( argv[i], "--help" ) == 0 ) )
{
if ( print_rank() )
{
log( std::cout, "CabanaPD\n", "Options:" );
log( std::cout, " -o [FILE] (OR)\n"
" --output-file [FILE]: Provide output "
"file name\n" );
log(
std::cout,
" -e [FILE] (OR)\n"
" --error-file [FILE]: Provide error file name\n" );
/* Not yet enabled.
log(
std::cout,
" --device-type [TYPE]: Kokkos device type to run
", "with\n", " (SERIAL,
PTHREAD, OPENMP, " "CUDA, HIP)" );
*/
}
}
// Output file names.
else if ( ( strcmp( argv[i], "-o" ) == 0 ) ||
( strcmp( argv[i], "--output-file" ) == 0 ) )
{
output_file = argv[i + 1];
++i;
}
else if ( ( strcmp( argv[i], "-e" ) == 0 ) ||
( strcmp( argv[i], "--error-file" ) == 0 ) )
{
error_file = argv[i + 1];
++i;
}

// Kokkos device type.
else if ( ( strcmp( argv[i], "--device-type" ) == 0 ) )
{
device_type = argv[i + 1];
++i;
}

else if ( ( strstr( argv[i], "--kokkos-" ) == NULL ) )
{
log_err( std::cout,
"Unknown command line argument: ", argv[i] );
}
}
}
};

} // namespace CabanaPD
Expand Down
Loading
Loading