Skip to content

Commit

Permalink
Add current position option to solver and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
streeve committed Aug 29, 2023
1 parent 3885202 commit 944a20e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 7 deletions.
3 changes: 2 additions & 1 deletion examples/crack_branching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ int main( int argc, char* argv[] )
double t_final = 43e-6;
double dt = 5e-8;
double output_frequency = 5;
bool output_reference = true;

// Material constants
double E = 72e+9; // [Pa]
Expand Down Expand Up @@ -68,7 +69,7 @@ int main( int argc, char* argv[] )
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 );
output_frequency, output_reference );
inputs.read_args( argc, argv );

// Create particles from mesh.
Expand Down
3 changes: 2 additions & 1 deletion examples/elastic_wave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ int main( int argc, char* argv[] )
double t_final = 0.6;
double dt = 0.01;
int output_frequency = 5;
bool output_reference = true;
double K = 1.0;
double G = 0.5;
double delta = 0.075;
Expand All @@ -51,7 +52,7 @@ int main( int argc, char* argv[] )
model_type force_model( delta, K, G );

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

// Create particles from mesh.
Expand Down
3 changes: 2 additions & 1 deletion examples/kalthoff_winkler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ int main( int argc, char* argv[] )
double t_final = 70e-6;
double dt = 0.133e-6;
int output_frequency = 10;
bool output_reference = true;

// Material constants
double E = 191e+9; // [Pa]
Expand Down Expand Up @@ -82,7 +83,7 @@ int main( int argc, char* argv[] )
// 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 );
output_frequency, output_reference );
inputs.read_args( argc, argv );

// Create particles from mesh.
Expand Down
3 changes: 2 additions & 1 deletion src/CabanaPD_Input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,14 @@ namespace CabanaPD
// FIXME: hardcoded.
Inputs::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 of )
const int of, const bool ref )
: num_cells( nc )
, low_corner( lc )
, high_corner( hc )
, final_time( t_f )
, timestep( dt )
, output_frequency( of )
, output_reference( ref )
{
num_steps = final_time / timestep;
}
Expand Down
3 changes: 2 additions & 1 deletion src/CabanaPD_Input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ class Inputs
double final_time;
double timestep;
int output_frequency;
bool output_reference;

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 );
const int output_freq, const bool output_ref );
~Inputs();
void read_args( int argc, char* argv[] );
};
Expand Down
7 changes: 5 additions & 2 deletions src/CabanaPD_Solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class SolverElastic

num_steps = inputs->num_steps;
output_frequency = inputs->output_frequency;
output_reference = inputs->output_reference;

// Create integrator.
integrator = std::make_shared<integrator_type>( inputs->timestep );
Expand Down Expand Up @@ -236,7 +237,7 @@ class SolverElastic

step_output( step, W );
particles->output( step / output_frequency,
step * inputs->timestep );
step * inputs->timestep, output_reference );
}
other_time += other_timer.seconds();
}
Expand Down Expand Up @@ -303,6 +304,7 @@ class SolverElastic

int num_steps;
int output_frequency;
bool output_reference;

protected:
std::shared_ptr<particle_type> particles;
Expand Down Expand Up @@ -445,7 +447,7 @@ class SolverFracture

this->step_output( step, W );
particles->output( step / output_frequency,
step * inputs->timestep );
step * inputs->timestep, output_reference );
}
other_time += other_timer.seconds();
}
Expand All @@ -456,6 +458,7 @@ class SolverFracture

using base_type::num_steps;
using base_type::output_frequency;
using base_type::output_reference;

protected:
using base_type::comm;
Expand Down

0 comments on commit 944a20e

Please sign in to comment.