Skip to content

Commit

Permalink
to continue
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiangyu-Hu committed Sep 22, 2024
1 parent 5cac108 commit b7da9ba
Show file tree
Hide file tree
Showing 24 changed files with 77 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int main(int ac, char *av[])
// Define the main numerical methods used in the simulation.
// Note that there may be data dependence on the constructors of these methods.
//----------------------------------------------------------------------

SimpleDynamics<NormalDirectionFromBodyShape> diffusion_body_normal_direction(diffusion_body, diffusion_body_shape);
SimpleDynamics<NormalDirectionFromBodyShape> wall_boundary_normal_direction(wall_Neumann, wall_shape_Neumann);

DiffusionBodyRelaxation temperature_relaxation(
Expand Down
6 changes: 3 additions & 3 deletions tests/2d_examples/test_2d_stfb/stfb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ int main(int ac, char *av[])
wall_boundary.generateParticles<BaseParticles, Lattice>(wall_boundary_shape);

TransformShape<GeometricShapeBox> structure_shape(Transform(structure_translation), structure_halfsize, "Structure");
SolidBody structure(sph_system, structure_shape);
SolidBody structure(sph_system, structure_shape.getName());
structure.defineMaterial<Solid>(rho_s);
structure.generateParticles<BaseParticles, Lattice>(floating_structure_shape);
structure.generateParticles<BaseParticles, Lattice>(structure_shape);

ObserverBody observer(sph_system, "Observer");
observer.defineAdaptationRatios(1.15, 2.0);
Expand Down Expand Up @@ -66,7 +66,7 @@ int main(int ac, char *av[])
//----------------------------------------------------------------------
SimpleDynamics<OffsetInitialPosition> structure_offset_position(structure, offset);
SimpleDynamics<NormalDirectionFromBodyShape> wall_boundary_normal_direction(wall_boundary, wall_boundary_shape);
SimpleDynamics<NormalDirectionFromBodyShape> str_normal(structure);
SimpleDynamics<NormalDirectionFromBodyShape> str_normal(structure, structure_shape);

Gravity gravity(Vecd(0.0, -gravity_g));
SimpleDynamics<GravityForce<Gravity>> constant_gravity(water_block, gravity);
Expand Down
9 changes: 5 additions & 4 deletions tests/2d_examples/test_2d_stretching/stretching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,15 @@ int main(int ac, char *av[])
//----------------------------------------------------------------------
// Creating body, materials and particles.
//----------------------------------------------------------------------
SolidBody beam_body(system, makeShared<Beam>("StretchingBody"));
beam_body.defineBodyLevelSetShape();
Beam beam_body_shape("StretchingBody");
SolidBody beam_body(system, beam_body_shape.getName());
LevelSetShape level_set_shape(beam_body, beam_body_shape);
beam_body.defineMaterial<NonLinearHardeningPlasticSolid>(
rho0_s, Youngs_modulus, poisson, yield_stress, hardening_modulus, saturation_flow_stress, saturation_exponent);

(!system.RunParticleRelaxation() && system.ReloadParticles())
? beam_body.generateParticles<BaseParticles, Reload>(beam_body.getName())
: beam_body.generateParticles<BaseParticles, Lattice>(beam_body_shape);
: beam_body.generateParticles<BaseParticles, Lattice>(level_set_shape);

ObserverBody beam_observer(system, "BeamObserver");
beam_observer.generateParticles<ObserverParticles>(observation_location);
Expand All @@ -214,7 +215,7 @@ int main(int ac, char *av[])
//----------------------------------------------------------------------
using namespace relax_dynamics;
SimpleDynamics<RandomizeParticlePosition> beam_body_random_particles(beam_body);
RelaxationStepInner beam_body_relaxation_step_inner(beam_body_inner);
RelaxationStepInner beam_body_relaxation_step_inner(beam_body_inner, level_set_shape);
//----------------------------------------------------------------------
// Output for particle relaxation.
//----------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,18 @@ int main(int ac, char *av[])
//----------------------------------------------------------------------
// Creating bodies with corresponding materials and particles.
//----------------------------------------------------------------------
FluidBody water_block(sph_system, makeShared<WettingFluidBody>("WaterBody"));
WettingFluidBody water_block_shape("WaterBody");
FluidBody water_block(sph_system, water_block_shape.getName());
water_block.defineMaterial<WeaklyCompressibleFluid>(rho0_f, c_f, mu_f);
water_block.generateParticles<BaseParticles, Lattice>(water_block_shape);

SolidBody wall_boundary(sph_system, makeShared<WettingWallBody>("WallBoundary"));
WettingWallBody wall_boundary_shape("WallBoundary");
SolidBody wall_boundary(sph_system, wall_boundary_shape.getName());
wall_boundary.defineMaterial<Solid>();
wall_boundary.generateParticles<BaseParticles, Lattice>(wall_boundary_shape);

SolidBody cylinder(sph_system, makeShared<WettingCylinderBody>("Cylinder"));
WettingCylinderBody cylinder_shape("Cylinder");
SolidBody cylinder(sph_system, cylinder_shape.getName());
cylinder.defineAdaptationRatios(1.15, 1.0);
LevelSetShape cylinder_shape_level_set(cylinder, cylinder_shape);
cylinder.defineMaterial<Solid>(rho0_s);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ int main(int ac, char *av[])
// Define the main numerical methods used in the simulation.
// Note that there may be data dependence on the constructors of these methods.
//----------------------------------------------------------------------

SimpleDynamics<NormalDirectionFromBodyShape> diffusion_body_normal_direction(diffusion_body, diffusion_body_shape);
SimpleDynamics<NormalDirectionFromBodyShape> Robin_normal_direction_in(boundary_Robin_in, boundary_in_shape);
SimpleDynamics<NormalDirectionFromBodyShape> Robin_normal_direction_ex(boundary_Robin_ex, boundary_ex_shape);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ int main(int ac, char *av[])
// Define the main numerical methods used in the simulation.
// Note that there may be data dependence on the constructors of these methods.
//----------------------------------------------------------------------

SimpleDynamics<NormalDirectionFromBodyShape> diffusion_body_normal_direction(diffusion_body, diffusion_body_shape);
SimpleDynamics<NormalDirectionFromBodyShape> Robin_normal_direction_in(boundary_Robin_in, boundary_in_shape);
SimpleDynamics<NormalDirectionFromBodyShape> Robin_normal_direction_ex(boundary_Robin_ex, boundary_ex_shape);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ int main(int ac, char *av[])
IOEnvironment io_environment(sph_system);

/** Import a beam body, with corresponding material and particles. */
SolidBody beam_body(sph_system, makeShared<Beam>("beam"));
Beam beam_body_shape("Beam");
SolidBody beam_body(sph_system, beam_body_shape.getName());
beam_body.defineMaterial<LinearElasticSolid>(rho, Youngs_modulus, poisson_ratio);
beam_body.generateParticles<BaseParticles, Lattice>(beam_body_shape);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,10 @@ return_data bending_circular_plate(Real dp_ratio)
std::cout << "bb_system.first_: " << bb_system.first_ << std::endl;
std::cout << "bb_system.second_: " << bb_system.second_ << std::endl;

// shell
auto shell_shape = makeShared<ComplexShape>("shell_shape" + std::to_string(int(dp_ratio * 1e3))); // keep all data for parameter study

// starting the actual simulation
SPHSystem system(bb_system, dp);
system.setIOEnvironment(false);
SolidBody shell_body(system, shell_shape);
SolidBody shell_body(system, "shell_shape" + std::to_string(int(dp_ratio * 1e3)));
shell_body.defineMaterial<LinearElasticSolid>(rho, E, mu);
shell_body.generateParticles<SurfaceParticles, ShellCircle>(obj_vertices, sym_vec, particle_area, thickness);
auto shell_particles = dynamic_cast<SurfaceParticles *>(&shell_body.getBaseParticles());
Expand Down
4 changes: 2 additions & 2 deletions tests/3d_examples/test_3d_dambreak/dambreak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ int main(int ac, char *av[])
//----------------------------------------------------------------------
// Creating bodies with corresponding materials and particles.
//----------------------------------------------------------------------
WaterBlock initial_water_block("WaterBody");
FluidBody water_block(sph_system, initial_water_block.getName());
WaterBlock water_block_shape("WaterBody");
FluidBody water_block(sph_system, water_block_shape.getName());
water_block.defineMaterial<WeaklyCompressibleFluid>(rho0_f, c_f);
water_block.generateParticles<BaseParticles, Lattice>(water_block_shape);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,10 @@ int main(int ac, char *av[])
wall_boundary.defineMaterial<Solid>();
wall_boundary.generateParticles<BaseParticles, Lattice>(wall_boundary_shape);

SolidBody gate(sph_system, makeShared<MovingGate>("Gate"));
MovingGate gate_shape("Gate");
SolidBody gate(sph_system, gate_shape.getName());
gate.defineMaterial<Solid>();
gate.generateParticles<BaseParticles, Lattice>();
gate.generateParticles<BaseParticles, Lattice>(gate_shape);

SolidBody plate(sph_system, "Plate");
plate.defineAdaptation<SPHAdaptation>(1.15, resolution_ref / resolution_shell);
Expand Down Expand Up @@ -216,7 +217,7 @@ int main(int ac, char *av[])
//----------------------------------------------------------------------
// solid
SimpleDynamics<NormalDirectionFromBodyShape> wall_boundary_normal_direction(wall_boundary, wall_boundary_shape);
SimpleDynamics<NormalDirectionFromBodyShape> gate_normal_direction(gate);
SimpleDynamics<NormalDirectionFromBodyShape> gate_normal_direction(gate, gate_shape);
SimpleDynamics<GateMotionConstraint> update_gate_position(gate);
// Shell
InteractionDynamics<thin_structure_dynamics::ShellCorrectConfiguration> plate_corrected_configuration(plate_inner);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,18 @@ int main(int ac, char *av[])
shell.defineMaterial<Solid>();
shell.generateParticles<SurfaceParticles, Cylinder>();

SolidBody ball(sph_system, makeShared<GeometricShapeBall>(ball_center, ball_radius, "BallBody"));
GeometricShapeBall ball_shape(ball_center, ball_radius, "BallBody");
SolidBody ball(sph_system, ball_shape.getName());
LevelSetShape level_set_shape(ball, ball_shape);
level_set_shape.writeLevelSet(sph_system);
ball.defineMaterial<NeoHookeanSolid>(rho0_s, Youngs_modulus, poisson);
if (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles())
{
ball.generateParticles<BaseParticles, Reload>(ball.getName());
}
else
{
ball.defineBodyLevelSetShape()->writeLevelSet(sph_system);
ball.generateParticles<BaseParticles, Lattice>();
ball.generateParticles<BaseParticles, Lattice>(level_set_shape);
}

ObserverBody ball_observer(sph_system, "BallObserver");
Expand All @@ -106,7 +108,7 @@ int main(int ac, char *av[])
//----------------------------------------------------------------------
using namespace relax_dynamics;
SimpleDynamics<RandomizeParticlePosition> ball_random_particles(ball);
RelaxationStepInner ball_relaxation_step_inner(ball_inner);
RelaxationStepInner ball_relaxation_step_inner(ball_inner, level_set_shape);
//----------------------------------------------------------------------
// Output for particle relaxation.
//----------------------------------------------------------------------
Expand Down Expand Up @@ -143,7 +145,7 @@ int main(int ac, char *av[])
// Generally, we first define all the inner relations, then the contact relations.
//----------------------------------------------------------------------
InnerRelation ball_inner(ball);
ShellSurfaceContactRelation ball_contact(ball, {&shell});
ShellSurfaceContactRelation ball_contact(ball, level_set_shape, {&shell});
ContactRelation ball_observer_contact(ball_observer, {&ball});
//----------------------------------------------------------------------
// Define the main numerical methods used in the simulation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ int main(int ac, char *av[])
// Creating bodies with corresponding materials and particles.
//----------------------------------------------------------------------
TransformShape<GeometricShapeBox> muscle_body_shape(Transform(translation_myocardium), halfsize_myocardium, "MyocardiumMuscleBody");
SolidBody muscle_body(sph_system, muscle_body_shape);
SolidBody muscle_body(sph_system, muscle_body_shape.getName());
muscle_body.defineMaterial<ActiveMuscle<Muscle>>(rho0_s, bulk_modulus, fiber_direction, sheet_direction, a0, b0);
muscle_body.generateParticles<BaseParticles, Lattice>();
muscle_body.generateParticles<BaseParticles, Lattice>(muscle_body_shape);
//----------------------------------------------------------------------
// Define body relation map.
// The contact map gives the topological connections between the bodies.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,16 @@ int main(int ac, char *av[])
//----------------------------------------------------------------------
// Creating bodies with corresponding materials and particles.
//----------------------------------------------------------------------
SolidBody myocardium_body(sph_system, makeShared<Myocardium>("MyocardiumBody"));
Myocardium myocardium_body_shape("MyocardiumBody");
SolidBody myocardium_body(sph_system, myocardium_body_shape.getName());
myocardium_body.defineMaterial<NeoHookeanSolid>(rho0_s, Youngs_modulus, poisson);
myocardium_body.generateParticles<BaseParticles, Lattice>();
myocardium_body.generateParticles<BaseParticles, Lattice>(myocardium_body_shape);

SolidBody moving_plate(sph_system, makeShared<MovingPlate>("MovingPlate"));
MovingPlate moving_plate_shape("MovingPlate");
SolidBody moving_plate(sph_system, moving_plate_shape.getName());
moving_plate.defineAdaptationRatios(1.15, 1.5);
moving_plate.defineMaterial<NeoHookeanSolid>(rho0_s, Youngs_modulus, poisson);
moving_plate.generateParticles<BaseParticles, Lattice>();
moving_plate.generateParticles<BaseParticles, Lattice>(moving_plate_shape);
//----------------------------------------------------------------------
// Define body relation map.
// The contact map gives the topological connections between the bodies.
Expand All @@ -78,8 +80,8 @@ int main(int ac, char *av[])
//----------------------------------------------------------------------
InnerRelation myocardium_body_inner(myocardium_body);
InnerRelation moving_plate_inner(moving_plate);
SurfaceContactRelation myocardium_plate_contact(myocardium_body, {&moving_plate});
SurfaceContactRelation plate_myocardium_contact(moving_plate, {&myocardium_body});
SurfaceContactRelation myocardium_plate_contact(myocardium_body, myocardium_body_shape, {&moving_plate});
SurfaceContactRelation plate_myocardium_contact(moving_plate, moving_plate_shape, {&myocardium_body});
//----------------------------------------------------------------------
// Define the numerical methods used in the simulation.
// Note that there may be data dependence on the sequence of constructions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,24 @@ int main(int ac, char *av[])
//----------------------------------------------------------------------
// Creating bodies with corresponding materials and particles.
//----------------------------------------------------------------------
SolidBody myocardium_body(sph_system, makeShared<Myocardium>("MyocardiumBody"));
Myocardium myocardium_body_shape("MyocardiumBody");
SolidBody myocardium_body(sph_system, myocardium_body_shape.getName());
myocardium_body.defineMaterial<NeoHookeanSolid>(rho0_s, Youngs_modulus, poisson);
myocardium_body.generateParticles<BaseParticles, Lattice>();
myocardium_body.generateParticles<BaseParticles, Lattice>(myocardium_body_shape);

SolidBody moving_plate(sph_system, makeShared<MovingPlate>("MovingPlate"));
MovingPlate moving_plate_shape("MovingPlate");
SolidBody moving_plate(sph_system, moving_plate_shape.getName());
moving_plate.defineMaterial<SaintVenantKirchhoffSolid>(rho0_s, Youngs_modulus, poisson);
moving_plate.generateParticles<BaseParticles, Lattice>();
moving_plate.generateParticles<BaseParticles, Lattice>(moving_plate_shape);
//----------------------------------------------------------------------
// Define body relation map.
// The contact map gives the topological connections between the bodies.
// Basically the the range of bodies to build neighbor particle lists.
// Generally, we first define all the inner relations, then the contact relations.
//----------------------------------------------------------------------
InnerRelation myocardium_body_inner(myocardium_body);
SurfaceContactRelation myocardium_plate_contact(myocardium_body, {&moving_plate});
SurfaceContactRelation plate_myocardium_contact(moving_plate, {&myocardium_body});
SurfaceContactRelation myocardium_plate_contact(myocardium_body, myocardium_body_shape, {&moving_plate});
SurfaceContactRelation plate_myocardium_contact(moving_plate, moving_plate_shape, {&myocardium_body});
//----------------------------------------------------------------------
// Define the numerical methods used in the simulation.
// Note that there may be data dependence on the sequence of constructions.
Expand Down Expand Up @@ -117,8 +119,7 @@ int main(int ac, char *av[])
SimTK::GeneralForceSubsystem forces(MBsystem);
SimTK::CableTrackerSubsystem cables(MBsystem);
/** mass properties of the fixed spot. */
TransformShape<GeometricShapeBox> moving_plate_shape(Transform(translation_moving_plate), halfsize_moving_plate, "Plate");
SimpleDynamics<NormalDirectionFromBodyShape> moving_plate_normal_direction(moving_plate);
SimpleDynamics<NormalDirectionFromBodyShape> moving_plate_normal_direction(moving_plate, moving_plate_shape);
SolidBodyPartForSimbody plate_multibody(moving_plate, moving_plate_shape);
/** Mass properties of the constrained spot.
* SimTK::MassProperties(mass, center of mass, inertia)
Expand Down
8 changes: 5 additions & 3 deletions tests/3d_examples/test_3d_network/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ int main(int ac, char *av[])
SPHSystem sph_system(system_domain_bounds, dp_0);
sph_system.handleCommandlineOptions(ac, av)->setIOEnvironment();
/** Creat a body, corresponding material and particles. */
TreeBody tree_on_sphere(sph_system, makeShared<GeometricShapeBall>(Vec3d::Zero(), 1.0, "Sphere"));
tree_on_sphere.defineBodyLevelSetShape()->writeLevelSet(sph_system);
tree_on_sphere.generateParticles<BaseParticles, Network>(starting_point, second_point, iteration_levels, grad_factor);
GeometricShapeBall ball_shape(Vec3d::Zero(), 1.0, "Sphere");
TreeBody tree_on_sphere(sph_system, ball_shape.getName());
LevelSetShape level_set_shape(tree_on_sphere, ball_shape);
level_set_shape.writeLevelSet(sph_system);
tree_on_sphere.generateParticles<BaseParticles, Network>(ball_shape, starting_point, second_point, iteration_levels, grad_factor);
/** Write particle data. */
BodyStatesRecordingToVtp write_states(sph_system);
write_states.writeToFile(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ int main(int ac, char *av[])
SPHSystem sph_system(system_domain_bounds, resolution_ref);
sph_system.handleCommandlineOptions(ac, av);
/** create a Cantilever body, corresponding material, particles and reaction model. */
SolidBody cantilever_body(sph_system, makeShared<Cantilever>("CantileverBody"));
Cantilever cantilever_body_shape("CantileverBody");
SolidBody cantilever_body(sph_system, cantilever_body_shape.getName());
cantilever_body.defineMaterial<Muscle>(rho0_s, bulk_modulus, fiber_direction, sheet_direction, a0, b0);
cantilever_body.generateParticles<BaseParticles, Lattice>();
cantilever_body.generateParticles<BaseParticles, Lattice>(cantilever_body_shape);
/** Define Observer. */
ObserverBody cantilever_observer(sph_system, "CantileverObserver");
cantilever_observer.generateParticles<ObserverParticles>(observation_location);
Expand Down
Loading

0 comments on commit b7da9ba

Please sign in to comment.