Skip to content

Commit

Permalink
Rework --sparse option
Browse files Browse the repository at this point in the history
  • Loading branch information
cz4rs committed Sep 16, 2024
1 parent c779d48 commit 066cb1f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
18 changes: 14 additions & 4 deletions src/inputCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

#include <Cabana_Core.hpp>

#include <cstdlib>
#include <inputCL.h>
#include <output.h>
#include <types.h>
Expand Down Expand Up @@ -116,8 +117,12 @@ void InputCL::read_args( int argc, char *argv[] )
" (N = positive integer)\n",
" (PATH = location of ",
"directory)\n" );
log( std::cout, " --sparse : "
"create a vacuum for an unbalanced system\n" );
log( std::cout,
" --vacuum [N]: Create a vacuum for "
"an unbalanced system, enlarging the simulation "
"box N times\n"
" (N = floating-point "
"multiplier, must be bigger than 1.0)\n" );
}

// Read Lammps input deck
Expand Down Expand Up @@ -235,9 +240,14 @@ void InputCL::read_args( int argc, char *argv[] )
i += 3;
}

else if ( ( strcmp( argv[i], "--sparse" ) == 0 ) )
else if ( ( strcmp( argv[i], "--vacuum" ) == 0 ) )
{
sparse = true;
vacuum = true;
vacuum_rate = std::atof( argv[i + 1] );
if ( vacuum_rate <= 1.0 )
log_err( std::cout,
"Vacuum multiplier must be bigger than 1.0" );
i += 2;
}

else if ( ( strstr( argv[i], "--kokkos-" ) == NULL ) )
Expand Down
3 changes: 2 additions & 1 deletion src/inputCL.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class InputCL
int layout_type;
int nnp_layout_type;
int device_type;
bool sparse = false;
bool vacuum = false;
double vacuum_rate = 1.0;

int dumpbinary_rate, correctness_rate;
bool dumpbinaryflag, correctnessflag;
Expand Down
8 changes: 4 additions & 4 deletions src/inputFile_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -512,12 +512,12 @@ void InputFile<t_System>::create_lattice( Comm<t_System> *comm )
T_X_FLOAT max_z = lattice_constant * lattice_nz;
std::array<T_X_FLOAT, 3> global_low = { 0.0, 0.0, 0.0 };
std::array<T_X_FLOAT, 3> global_high = { max_x, max_y, max_z };
if ( commandline.sparse )
if ( commandline.vacuum )
{
// Create a vacuum for an unbalanced system.
global_high[0] *= 2;
global_high[1] *= 2;
global_high[2] *= 2;
global_high[0] *= commandline.vacuum_rate;
global_high[1] *= commandline.vacuum_rate;
global_high[2] *= commandline.vacuum_rate;
}
system->create_domain( global_low, global_high, comm_ghost_cutoff );
s = *system;
Expand Down

0 comments on commit 066cb1f

Please sign in to comment.