Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiangyu-Hu committed Jul 30, 2023
1 parent a1c8c7f commit dfc701f
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ Real AcousticTimeStepSize::outputResult(Real reduced_value)
}
//=================================================================================================//
AdvectionTimeStepSizeForImplicitViscosity::
AdvectionTimeStepSizeForImplicitViscosity(SPHBody &sph_body, Real U_max, Real advectionCFL)
: LocalDynamicsReduce<Real, ReduceMax>(sph_body, U_max * U_max),
AdvectionTimeStepSizeForImplicitViscosity(SPHBody &sph_body, Real U_ref, Real advectionCFL)
: LocalDynamicsReduce<Real, ReduceMax>(sph_body, Real(0)),
FluidDataSimple(sph_body), vel_(particles_->vel_),
smoothing_length_min_(sph_body.sph_adaptation_->MinimumSmoothingLength()),
advectionCFL_(advectionCFL) {}
speed_ref_(U_ref), advectionCFL_(advectionCFL) {}
//=================================================================================================//
Real AdvectionTimeStepSizeForImplicitViscosity::reduce(size_t index_i, Real dt)
{
Expand All @@ -91,15 +91,15 @@ Real AdvectionTimeStepSizeForImplicitViscosity::reduce(size_t index_i, Real dt)
Real AdvectionTimeStepSizeForImplicitViscosity::outputResult(Real reduced_value)
{
Real speed_max = sqrt(reduced_value);
return advectionCFL_ * smoothing_length_min_ / (speed_max + TinyReal);
return advectionCFL_ * smoothing_length_min_ / (SMAX(speed_max, speed_ref_) + TinyReal);
}
//=================================================================================================//
AdvectionTimeStepSize::AdvectionTimeStepSize(SPHBody &sph_body, Real U_max, Real advectionCFL)
: AdvectionTimeStepSizeForImplicitViscosity(sph_body, U_max, advectionCFL),
AdvectionTimeStepSize::AdvectionTimeStepSize(SPHBody &sph_body, Real U_ref, Real advectionCFL)
: AdvectionTimeStepSizeForImplicitViscosity(sph_body, U_ref, advectionCFL),
fluid_(DynamicCast<Fluid>(this, particles_->getBaseMaterial()))
{
Real viscous_speed = fluid_.ReferenceViscosity() / fluid_.ReferenceDensity() / smoothing_length_min_;
reference_ = SMAX(viscous_speed * viscous_speed, reference_);
speed_ref_ = SMAX(viscous_speed, speed_ref_);
}
//=================================================================================================//
Real AdvectionTimeStepSize::reduce(size_t index_i, Real dt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,15 @@ class AdvectionTimeStepSizeForImplicitViscosity
{
public:
explicit AdvectionTimeStepSizeForImplicitViscosity(
SPHBody &sph_body, Real U_max, Real advectionCFL = 0.25);
SPHBody &sph_body, Real U_ref, Real advectionCFL = 0.25);
virtual ~AdvectionTimeStepSizeForImplicitViscosity(){};
Real reduce(size_t index_i, Real dt = 0.0);
virtual Real outputResult(Real reduced_value) override;

protected:
StdLargeVec<Vecd> &vel_;
Real smoothing_length_min_;
Real advectionCFL_;
Real speed_ref_, advectionCFL_;
};

/**
Expand All @@ -252,7 +252,7 @@ class AdvectionTimeStepSizeForImplicitViscosity
class AdvectionTimeStepSize : public AdvectionTimeStepSizeForImplicitViscosity
{
public:
explicit AdvectionTimeStepSize(SPHBody &sph_body, Real U_max, Real advectionCFL = 0.25);
explicit AdvectionTimeStepSize(SPHBody &sph_body, Real U_ref, Real advectionCFL = 0.25);
virtual ~AdvectionTimeStepSize(){};
Real reduce(size_t index_i, Real dt = 0.0);

Expand Down
6 changes: 3 additions & 3 deletions tests/2d_examples/test_2d_dambreak/Dambreak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Real BW = particle_spacing_ref * 4; /**< Thickness of tank wall. */
//----------------------------------------------------------------------
Real rho0_f = 1.0; /**< Reference density of fluid. */
Real gravity_g = 1.0; /**< Gravity. */
Real U_max = 2.0 * sqrt(gravity_g * LH); /**< Characteristic velocity. */
Real c_f = 10.0 * U_max; /**< Reference sound speed. */
Real U_ref = 2.0 * sqrt(gravity_g * LH); /**< Characteristic velocity. */
Real c_f = 10.0 * U_ref; /**< Reference sound speed. */
//----------------------------------------------------------------------
// Geometric shapes used in this case.
//----------------------------------------------------------------------
Expand Down Expand Up @@ -91,7 +91,7 @@ int main(int ac, char *av[])
SimpleDynamics<NormalDirectionFromBodyShape> wall_boundary_normal_direction(wall_boundary);
SharedPtr<Gravity> gravity_ptr = makeShared<Gravity>(Vecd(0.0, -gravity_g));
SimpleDynamics<TimeStepInitialization> fluid_step_initialization(water_block, gravity_ptr);
ReduceDynamics<fluid_dynamics::AdvectionTimeStepSize> fluid_advection_time_step(water_block, U_max);
ReduceDynamics<fluid_dynamics::AdvectionTimeStepSize> fluid_advection_time_step(water_block, U_ref);
ReduceDynamics<fluid_dynamics::AcousticTimeStepSize> fluid_acoustic_time_step(water_block);
//----------------------------------------------------------------------
// Define the methods for I/O operations, observations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ StdVec<Vecd> observation_location = {Vecd(DL, 0.2)};
*/
Real rho0_f = 1.0; /**< Reference density of fluid. */
Real gravity_g = 1.0; /**< Gravity force of fluid. */
Real U_max = 2.0 * sqrt(gravity_g * LH); /**< Characteristic velocity. */
Real c_f = 10.0 * U_max; /**< Reference sound speed. */
Real U_ref = 2.0 * sqrt(gravity_g * LH); /**< Characteristic velocity. */
Real c_f = 10.0 * U_ref; /**< Reference sound speed. */
//----------------------------------------------------------------------
// Geometric shapes used in this case.
//----------------------------------------------------------------------
Expand Down Expand Up @@ -123,7 +123,7 @@ int main(int ac, char *av[])
SimpleDynamics<NormalDirectionFromBodyShape> wall_boundary_normal_direction(wall_boundary);
SharedPtr<Gravity> gravity_ptr = makeShared<Gravity>(Vecd(0.0, -gravity_g));
SimpleDynamics<TimeStepInitialization> fluid_step_initialization(water_block, gravity_ptr);
ReduceDynamics<fluid_dynamics::AdvectionTimeStepSize> fluid_advection_time_step(water_block, U_max);
ReduceDynamics<fluid_dynamics::AdvectionTimeStepSize> fluid_advection_time_step(water_block, U_ref);
ReduceDynamics<fluid_dynamics::AcousticTimeStepSize> fluid_acoustic_time_step(water_block);

//----------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions tests/2d_examples/test_2d_dambreak_python/dambreak_python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class Parameter
//----------------------------------------------------------------------
Real rho0_f = 1.0; /**< Reference density of fluid. */
Real gravity_g = 1.0; /**< Gravity. */
Real U_max = 2.0 * sqrt(gravity_g * LH); /**< Characteristic velocity. */
Real c_f = 10.0 * U_max; /**< Reference sound speed. */
Real U_ref = 2.0 * sqrt(gravity_g * LH); /**< Characteristic velocity. */
Real c_f = 10.0 * U_ref; /**< Reference sound speed. */
//----------------------------------------------------------------------
// Geometric shapes used in this case.
//----------------------------------------------------------------------
Expand Down Expand Up @@ -150,7 +150,7 @@ class Environment : public PreSettingCase
wall_boundary_normal_direction(wall_boundary),
gravity_ptr(makeShared<Gravity>(Vecd(0.0, -gravity_g))),
fluid_step_initialization(water_block, gravity_ptr),
fluid_advection_time_step(water_block, U_max),
fluid_advection_time_step(water_block, U_ref),
fluid_acoustic_time_step(water_block),
body_states_recording(io_environment, sph_system.real_bodies_),
restart_io(io_environment, sph_system.real_bodies_),
Expand Down
8 changes: 4 additions & 4 deletions tests/2d_examples/test_2d_hydrostatic_fsi/hydrostatic_fsi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ StdVec<Vecd> observation_location = {Vecd(0.5 * Dam_L, -0.5 * Gate_width)};
//----------------------------------------------------------------------
Real rho0_f = 1000.0; /**< Reference density of fluid. */
Real gravity_g = 9.81; /**< Value of gravity. */
Real U_max = 2.0 * sqrt(Dam_H * gravity_g);
Real U_ref = 2.0 * sqrt(Dam_H * gravity_g);
; /**< Characteristic velocity. */
Real c_f = 10.0 * U_max; /**< Reference sound speed. */
Real c_f = 10.0 * U_ref; /**< Reference sound speed. */
Real Re = 0.1; /**< Reynolds number. */
Real mu_f = rho0_f * U_max * DL / Re; /**< Dynamics viscosity. */
Real mu_f = rho0_f * U_ref * DL / Re; /**< Dynamics viscosity. */
//----------------------------------------------------------------------
// Material properties of the elastic gate.
//----------------------------------------------------------------------
Expand Down Expand Up @@ -235,7 +235,7 @@ int main()
/** Evaluation of fluid density by summation approach. */
InteractionWithUpdate<fluid_dynamics::DensitySummationFreeSurfaceComplex> update_fluid_density(water_block_complex);
/** Compute time step size without considering sound wave speed. */
ReduceDynamics<fluid_dynamics::AdvectionTimeStepSize> get_fluid_advection_time_step_size(water_block, U_max);
ReduceDynamics<fluid_dynamics::AdvectionTimeStepSize> get_fluid_advection_time_step_size(water_block, U_ref);
/** Compute time step size with considering sound wave speed. */
ReduceDynamics<fluid_dynamics::AcousticTimeStepSize> get_fluid_time_step_size(water_block);
/** Pressure relaxation using verlet time stepping. */
Expand Down
8 changes: 4 additions & 4 deletions tests/2d_examples/test_2d_square_droplet/src/droplet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Real BW = particle_spacing_ref * 2; /**< Extending width for BCs. */
//----------------------------------------------------------------------
Real rho0_f = 1.0; /**< Reference density of water. */
Real rho0_a = 0.001; /**< Reference density of air. */
Real U_max = 1.0; /**< Characteristic velocity. */
Real c_f = 10.0 * U_max; /**< Reference sound speed. */
Real U_ref = 1.0; /**< Characteristic velocity. */
Real c_f = 10.0 * U_ref; /**< Reference sound speed. */
Real mu_f = 0.2; /**< Water viscosity. */
Real mu_a = 0.002; /**< Air viscosity. */
//----------------------------------------------------------------------
Expand Down Expand Up @@ -149,8 +149,8 @@ int main()
InteractionDynamics<fluid_dynamics::TransportVelocityCorrectionComplex>
air_transport_correction(air_wall_contact, air_water_complex, 0.05);
/** Time step size without considering sound wave speed. */
ReduceDynamics<fluid_dynamics::AdvectionTimeStepSize> get_water_advection_time_step_size(water_block, U_max);
ReduceDynamics<fluid_dynamics::AdvectionTimeStepSize> get_air_advection_time_step_size(air_block, U_max);
ReduceDynamics<fluid_dynamics::AdvectionTimeStepSize> get_water_advection_time_step_size(water_block, U_ref);
ReduceDynamics<fluid_dynamics::AdvectionTimeStepSize> get_air_advection_time_step_size(air_block, U_ref);
/** Time step size with considering sound wave speed. */
ReduceDynamics<fluid_dynamics::AcousticTimeStepSize> get_water_time_step_size(water_block);
ReduceDynamics<fluid_dynamics::AcousticTimeStepSize> get_air_time_step_size(air_block);
Expand Down
6 changes: 3 additions & 3 deletions tests/2d_examples/test_2d_standing_wave/standing_wave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ BoundingBox system_domain_bounds(Vec2d(-BW, -BW), Vec2d(DL + BW, DH + BW));
//----------------------------------------------------------------------
Real rho0_f = 1000.0; /**< Reference density of fluid. */
Real gravity_g = 9.81; /**< Gravity force of fluid. */
Real U_max = 2.0 * sqrt(gravity_g * LH); /**< Characteristic velocity. */
Real c_f = 10.0 * U_max; /**< Reference sound speed. */
Real U_ref = 2.0 * sqrt(gravity_g * LH); /**< Characteristic velocity. */
Real c_f = 10.0 * U_ref; /**< Reference sound speed. */
//----------------------------------------------------------------------
// Geometric shapes used in this case.
//----------------------------------------------------------------------
Expand Down Expand Up @@ -198,7 +198,7 @@ int main(int ac, char *av[])
SimpleDynamics<NormalDirectionFromBodyShape> wall_boundary_normal_direction(wall_boundary);
SharedPtr<Gravity> gravity_ptr = makeShared<Gravity>(Vecd(0.0, -gravity_g));
SimpleDynamics<TimeStepInitialization> fluid_step_initialization(water_block, gravity_ptr);
ReduceDynamics<fluid_dynamics::AdvectionTimeStepSize> fluid_advection_time_step(water_block, U_max);
ReduceDynamics<fluid_dynamics::AdvectionTimeStepSize> fluid_advection_time_step(water_block, U_ref);
ReduceDynamics<fluid_dynamics::AcousticTimeStepSize> fluid_acoustic_time_step(water_block);
/** We can output a method-specific particle data for debug */
water_block.addBodyStateForRecording<Real>("Pressure");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ StdVec<Vecd> observation_location = {Vecd(DL, 0.2)};
//----------------------------------------------------------------------
Real rho0_f = 1.0; /**< Reference density of fluid. */
Real gravity_g = 1.0; /**< Gravity force of fluid. */
Real U_max = 2.0 * sqrt(gravity_g * LH); /**< Characteristic velocity. */
Real c_f = 10.0 * U_max; /**< Reference sound speed. */
Real U_ref = 2.0 * sqrt(gravity_g * LH); /**< Characteristic velocity. */
Real c_f = 10.0 * U_ref; /**< Reference sound speed. */
//----------------------------------------------------------------------
// Geometric shapes used in this case.
//----------------------------------------------------------------------
Expand Down Expand Up @@ -134,7 +134,7 @@ int main(int ac, char *av[])
/** Evaluation of density by summation approach. */
InteractionWithUpdate<fluid_dynamics::DensitySummationFreeSurfaceInner> update_density_by_summation(water_block_inner);
/** Time step size without considering sound wave speed. */
ReduceDynamics<fluid_dynamics::AdvectionTimeStepSize> get_fluid_advection_time_step_size(water_block, U_max);
ReduceDynamics<fluid_dynamics::AdvectionTimeStepSize> get_fluid_advection_time_step_size(water_block, U_ref);
/** Time step size with considering sound wave speed. */
ReduceDynamics<fluid_dynamics::AcousticTimeStepSize> get_fluid_time_step_size(water_block);
/** Pressure relaxation algorithm by using position verlet time stepping. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ int main()
InteractionDynamics<fluid_dynamics::TransportVelocityCorrectionComplex>
air_transport_correction(air_wall_contact, air_water_complex);
/** Time step size without considering sound wave speed. */
ReduceDynamics<fluid_dynamics::AdvectionTimeStepSize> get_water_advection_time_step_size(water_block, U_max);
ReduceDynamics<fluid_dynamics::AdvectionTimeStepSize> get_air_advection_time_step_size(air_block, U_max);
ReduceDynamics<fluid_dynamics::AdvectionTimeStepSize> get_water_advection_time_step_size(water_block, U_ref);
ReduceDynamics<fluid_dynamics::AdvectionTimeStepSize> get_air_advection_time_step_size(air_block, U_ref);
/** Time step size with considering sound wave speed. */
ReduceDynamics<fluid_dynamics::AcousticTimeStepSize> get_water_time_step_size(water_block);
ReduceDynamics<fluid_dynamics::AcousticTimeStepSize> get_air_time_step_size(air_block);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ StdVec<Vecd> observation_location = {Vecd(DL, 0.2)};
Real rho0_f = 1.0; /**< Reference density of water. */
Real rho0_a = 0.001; /**< Reference density of air. */
Real gravity_g = 1.0; /**< Gravity force of fluid. */
Real U_max = 2.0 * sqrt(gravity_g * LH); /**< Characteristic velocity. */
Real c_f = 10.0 * U_max; /**< Reference sound speed. */
Real U_ref = 2.0 * sqrt(gravity_g * LH); /**< Characteristic velocity. */
Real c_f = 10.0 * U_ref; /**< Reference sound speed. */
//----------------------------------------------------------------------
// Geometric elements used in shape modeling.
//----------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions tests/2d_examples/test_2d_wetting_effects/src/wetting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ int main()
InteractionDynamics<fluid_dynamics::TransportVelocityCorrectionComplex>
air_transport_correction(air_wall_contact, air_water_complex, 0.05);
/** Time step size without considering sound wave speed. */
ReduceDynamics<fluid_dynamics::AdvectionTimeStepSize> get_water_advection_time_step_size(water_block, U_max);
ReduceDynamics<fluid_dynamics::AdvectionTimeStepSize> get_air_advection_time_step_size(air_block, U_max);
ReduceDynamics<fluid_dynamics::AdvectionTimeStepSize> get_water_advection_time_step_size(water_block, U_ref);
ReduceDynamics<fluid_dynamics::AdvectionTimeStepSize> get_air_advection_time_step_size(air_block, U_ref);
/** Time step size with considering sound wave speed. */
ReduceDynamics<fluid_dynamics::AcousticTimeStepSize> get_water_time_step_size(water_block);
ReduceDynamics<fluid_dynamics::AcousticTimeStepSize> get_air_time_step_size(air_block);
Expand Down
4 changes: 2 additions & 2 deletions tests/2d_examples/test_2d_wetting_effects/src/wetting.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ BoundingBox system_domain_bounds(Vec2d(-BW, -BW), Vec2d(DL + BW, DH + BW));
//----------------------------------------------------------------------
Real rho0_f = 1.0; /**< Reference density of water. */
Real rho0_a = 1.0e-3; /**< Reference density of air. */
Real U_max = 1.0; /**< Characteristic velocity. */
Real c_f = 10.0 * U_max; /**< Reference sound speed. */
Real U_ref = 1.0; /**< Characteristic velocity. */
Real c_f = 10.0 * U_ref; /**< Reference sound speed. */
Real mu_f = 5.0e-2; /**< Water viscosity. */
Real mu_a = 5.0e-4; /**< Air viscosity. */
Real contact_angle = (150.0 / 180.0) * 3.1415926; /**< Contact angle with Wall. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Real Q = 2.0 * (cos(kl) * sinh(kl) - sin(kl) * cosh(kl));
Real vf = 0.05;
Real R = PL / (0.5 * Pi);
//for dual time-step
Real U_max = vf * c0 * (M * (cos(kl) - cosh(kl)) - N * (sin(kl) - sinh(kl))) / Q;
Real U_ref = vf * c0 * (M * (cos(kl) - cosh(kl)) - N * (sin(kl) - sinh(kl))) / Q;
//----------------------------------------------------------------------
// Geometric shapes used in the system.
//----------------------------------------------------------------------
Expand Down Expand Up @@ -145,7 +145,7 @@ int main(int ac, char* av[])
InteractionWithUpdate<CorrectedConfigurationInner> correcttion_matrix(beam_body_inner);
Dynamics1Level<continuum_dynamics::ShearStressRelaxation> beam_shear_stress_relaxation(beam_body_inner);
//for dula timestep
ReduceDynamics<fluid_dynamics::AdvectionTimeStepSize> fluid_advection_time_step(beam_body, U_max, 0.2);
ReduceDynamics<fluid_dynamics::AdvectionTimeStepSize> fluid_advection_time_step(beam_body, U_ref, 0.2);
ReduceDynamics<fluid_dynamics::AcousticTimeStepSize> fluid_acoustic_time_step(beam_body, 0.4);
// clamping a solid body part.
BodyRegionByParticle beam_base(beam_body, makeShared<MultiPolygonShape>(createBeamConstrainShape()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Real gravity_g = 0.0;

Real governing_vibration_integer_x = 2.0;
Real governing_vibration_integer_y = 2.0;
Real U_max = 1.0; //Maximum velocity
Real U_ref = 1.0; //Maximum velocity
/** Define application dependent particle generator for thin structure. */
class PlateParticleGenerator : public ParticleGenerator
{
Expand Down Expand Up @@ -135,7 +135,7 @@ int main()
*/
SimpleDynamics<BeamInitialCondition> initial_velocity(plate_body);
/** Time step size calculation. */
ReduceDynamics<fluid_dynamics::AdvectionTimeStepSize> fluid_advection_time_step(plate_body, U_max, 0.2);
ReduceDynamics<fluid_dynamics::AdvectionTimeStepSize> fluid_advection_time_step(plate_body, U_ref, 0.2);
ReduceDynamics<fluid_dynamics::AcousticTimeStepSize> fluid_acoustic_time_step(plate_body, 0.4);
/** stress relaxation. */
Dynamics1Level<continuum_dynamics::Integration1stHalf> plate_pressure_relaxation(plate_body_inner);
Expand Down

0 comments on commit dfc701f

Please sign in to comment.