From b60470879321929e82ba6953632343883477ad65 Mon Sep 17 00:00:00 2001 From: Xiangyu Hu Date: Sat, 21 Sep 2024 14:47:06 +0000 Subject: [PATCH 01/13] to compile other tests --- .../structural_simulation_class.cpp | 20 +++++++----- src/shared/bodies/base_body.cpp | 26 ++-------------- src/shared/bodies/base_body.h | 25 --------------- src/shared/geometries/complex_shape.h | 14 ++++----- .../relax_dynamics/relax_stepping.cpp | 6 ++-- .../relax_dynamics/relax_stepping.h | 4 +-- .../solid_dynamics/constraint_dynamics.cpp | 12 +++---- .../solid_dynamics/constraint_dynamics.h | 4 +-- .../particle_generator_lattice.cpp | 31 ++++++++++--------- .../particle_generator_lattice.h | 16 +++++----- .../test_2d_dambreak_ck/dambreak_ck.cpp | 7 +++-- .../test_1d_shock_tube/shock_tube.cpp | 5 +-- .../channel_flow_shell.cpp | 5 +-- .../test_2d_diffusion/diffusion.cpp | 5 +-- .../2d_eulerian_taylor_green_LG.cpp | 7 +++-- .../2d_flow_around_cylinder.cpp | 16 +++++----- tests/2d_examples/test_2d_fsi2/fsi2.cpp | 20 +++++++----- .../test_2d_heat_transfer/heat_transfer.cpp | 12 ++++--- .../poiseuille_flow.cpp | 12 ++++--- .../test_2d_taylor_green/taylor_green.cpp | 9 +++--- .../src/tethered_dead_fish_in_flow.cpp | 20 +++++++----- tests/2d_examples/test_2d_throat/throat.cpp | 12 ++++--- .../2d_velocity_gradient.cpp | 7 +++-- 23 files changed, 139 insertions(+), 156 deletions(-) diff --git a/modules/structural_simulation/structural_simulation_class.cpp b/modules/structural_simulation/structural_simulation_class.cpp index 613c5fc27a..f81a24cb29 100755 --- a/modules/structural_simulation/structural_simulation_class.cpp +++ b/modules/structural_simulation/structural_simulation_class.cpp @@ -23,12 +23,12 @@ BodyPartFromMesh::BodyPartFromMesh(SPHBody &body, SharedPtr t SolidBodyFromMesh::SolidBodyFromMesh( SPHSystem &system, SharedPtr triangle_mesh_shape, Real resolution, SharedPtr material_model, Vecd *pos_0, Real *volume) - : SolidBody(system, triangle_mesh_shape) + : SolidBody(system, triangle_mesh_shape->getName()) { defineAdaptationRatios(1.15, system.resolution_ref_ / resolution); - defineBodyLevelSetShape()->cleanLevelSet(); + LevelSetShape level_set_shape(*this, *triangle_mesh_shape, 1.0); assignMaterial(material_model.get()); - generateParticles(); + generateParticles(*level_set_shape.cleanLevelSet()); } SolidBodyForSimulation::SolidBodyForSimulation( @@ -108,10 +108,10 @@ std::tuple generateAndRelaxParticlesFromMesh( { BoundingBox bb = triangle_mesh_shape->getBounds(); SPHSystem system(bb, resolution); - SolidBody model(system, triangle_mesh_shape); - model.defineBodyLevelSetShape()->cleanLevelSet(); + SolidBody model(system, triangle_mesh_shape->getName()); + LevelSetShape level_set_shape(model, *triangle_mesh_shape, 1.0); model.defineMaterial(); - model.generateParticles(); + model.generateParticles(*level_set_shape.cleanLevelSet()); if (particle_relaxation) { @@ -538,7 +538,9 @@ void StructuralSimulation::initializePositionSolidBody() Real end_time = std::get<2>(position_solid_body_tuple_[i]); Vecd pos_end_center = std::get<3>(position_solid_body_tuple_[i]); position_solid_body_.emplace_back(makeShared>( - *solid_body_list_[body_index]->getSolidBodyFromMesh(), start_time, end_time, pos_end_center)); + *solid_body_list_[body_index]->getSolidBodyFromMesh(), + body_mesh_list_[body_index]->getBounds(), + start_time, end_time, pos_end_center)); } } @@ -552,7 +554,9 @@ void StructuralSimulation::initializePositionScaleSolidBody() Real end_time = std::get<2>(position_scale_solid_body_tuple_[i]); Real scale = std::get<3>(position_scale_solid_body_tuple_[i]); position_scale_solid_body_.emplace_back(makeShared>( - *solid_body_list_[body_index]->getSolidBodyFromMesh(), start_time, end_time, scale)); + *solid_body_list_[body_index]->getSolidBodyFromMesh(), + body_mesh_list_[body_index]->getBounds(), + start_time, end_time, scale)); } } diff --git a/src/shared/bodies/base_body.cpp b/src/shared/bodies/base_body.cpp index 71edccef28..3789ccc06c 100644 --- a/src/shared/bodies/base_body.cpp +++ b/src/shared/bodies/base_body.cpp @@ -7,30 +7,15 @@ namespace SPH { //=================================================================================================// -SPHBody::SPHBody(SPHSystem &sph_system, Shape &shape, const std::string &name) +SPHBody::SPHBody(SPHSystem &sph_system, const std::string &name) : sph_system_(sph_system), body_name_(name), newly_updated_(true), - base_particles_(nullptr), is_bound_set_(false), initial_shape_(&shape), total_body_parts_(0), + base_particles_(nullptr), is_bound_set_(false), total_body_parts_(0), sph_adaptation_(sph_adaptation_ptr_keeper_.createPtr(sph_system.ReferenceResolution())), base_material_(base_material_ptr_keeper_.createPtr()) { sph_system_.sph_bodies_.push_back(this); } //=================================================================================================// -SPHBody::SPHBody(SPHSystem &sph_system, Shape &shape) - : SPHBody(sph_system, shape, shape.getName()) {} -//=================================================================================================// -SPHBody::SPHBody(SPHSystem &sph_system, const std::string &name) - : SPHBody(sph_system, makeShared(name)) {} -//=================================================================================================// -SPHBody::SPHBody(SPHSystem &sph_system, SharedPtr shape_ptr, const std::string &name) - : SPHBody(sph_system, *shape_ptr.get(), name) -{ - shape_ptr_keeper_.assignPtr(shape_ptr); -} -//=================================================================================================// -SPHBody::SPHBody(SPHSystem &sph_system, SharedPtr shape_ptr) - : SPHBody(sph_system, shape_ptr, shape_ptr->getName()) {} -//=================================================================================================// BoundingBox SPHBody::getSPHSystemBounds() { return sph_system_.system_domain_bounds_; @@ -51,7 +36,7 @@ BaseParticles &SPHBody::getBaseParticles() { if (base_particles_ == nullptr) { - std::cout << "\n Error: BaseParticle not generated yet! \n"; + std::cout << "\n Error: BaseParticle not constructed yet! \n"; std::cout << __FILE__ << ':' << __LINE__ << std::endl; exit(1); } @@ -75,11 +60,6 @@ void SPHBody::setSPHBodyBounds(const BoundingBox &bound) is_bound_set_ = true; } //=================================================================================================// -BoundingBox SPHBody::getSPHBodyBounds() -{ - return is_bound_set_ ? bound_ : initial_shape_->getBounds(); -} -//=================================================================================================// void SPHBody::registerComputingKernel(execution::Implementation *implementation) { all_simple_reduce_computing_kernels_.push_back(implementation); diff --git a/src/shared/bodies/base_body.h b/src/shared/bodies/base_body.h index 81639414a7..5a0f72b75f 100644 --- a/src/shared/bodies/base_body.h +++ b/src/shared/bodies/base_body.h @@ -63,7 +63,6 @@ class BodySurface; class SPHBody { private: - SharedPtrKeeper shape_ptr_keeper_; UniquePtrKeeper sph_adaptation_ptr_keeper_; UniquePtrKeeper base_particles_ptr_keeper_; UniquePtrKeeper base_material_ptr_keeper_; @@ -75,7 +74,6 @@ class SPHBody BaseParticles *base_particles_; /**< Base particles for dynamic cast DataDelegate */ bool is_bound_set_; /**< whether the bounding box is set */ BoundingBox bound_; /**< bounding box of the body */ - Shape *initial_shape_; /**< initial volumetric geometry enclosing the body */ int total_body_parts_; StdVec *> all_simple_reduce_computing_kernels_; /**< total number of body parts */ @@ -85,17 +83,12 @@ class SPHBody BaseMaterial *base_material_; /**< base material for dynamic cast in DataDelegate */ StdVec body_relations_; /**< all contact relations centered from this body **/ - SPHBody(SPHSystem &sph_system, Shape &shape, const std::string &name); - SPHBody(SPHSystem &sph_system, Shape &shape); SPHBody(SPHSystem &sph_system, const std::string &name); - SPHBody(SPHSystem &sph_system, SharedPtr shape_ptr, const std::string &name); - SPHBody(SPHSystem &sph_system, SharedPtr shape_ptr); virtual ~SPHBody(){}; std::string getName() { return body_name_; }; SPHSystem &getSPHSystem(); SPHBody &getSPHBody() { return *this; }; - Shape &getInitialShape() { return *initial_shape_; }; void assignBaseParticles(BaseParticles *base_particles) { base_particles_ = base_particles; }; BaseParticles &getBaseParticles(); BaseMaterial &getBaseMaterial(); @@ -107,7 +100,6 @@ class SPHBody void setNotNewlyUpdated() { newly_updated_ = false; }; bool checkNewlyUpdated() { return newly_updated_; }; void setSPHBodyBounds(const BoundingBox &bound); - BoundingBox getSPHBodyBounds(); BoundingBox getSPHSystemBounds(); void registerComputingKernel(execution::Implementation *implementation); int getNewBodyPartID(); @@ -124,23 +116,6 @@ class SPHBody .createPtr(sph_system_.ReferenceResolution(), std::forward(args)...); }; - template - LevelSetShape *defineComponentLevelSetShape(const std::string &shape_name, Args &&...args) - { - ComplexShape *complex_shape = DynamicCast(this, initial_shape_); - return complex_shape->defineLevelSetShape(*this, shape_name, std::forward(args)...); - }; - - template - LevelSetShape *defineBodyLevelSetShape(Args &&...args) - { - LevelSetShape *level_set_shape = - shape_ptr_keeper_.resetPtr(*this, *initial_shape_, std::forward(args)...); - - initial_shape_ = level_set_shape; - return level_set_shape; - }; - template void assignMaterial(MaterialType *material) { diff --git a/src/shared/geometries/complex_shape.h b/src/shared/geometries/complex_shape.h index da1ce20f63..34187955de 100644 --- a/src/shared/geometries/complex_shape.h +++ b/src/shared/geometries/complex_shape.h @@ -41,11 +41,11 @@ class LevelSetShape; /** * @class ComplexShape - * @brief For now, if the level set shape (for particle relaxation) - * will be generated from the complex shape, - * partially overlapped shapes are not allowed for 3D problems. + * @brief For now, if the level set shape (for particle relaxation) + * will be generated from the complex shape, + * partially overlapped shapes are not allowed for 3D problems. * However, if only the contain function - * is used, for example generating particles using lattice generator, + * is used, for example generating particles using lattice generator, * partially overlapped shapes are allowed. **/ class ComplexShape : public BinaryShapes @@ -56,7 +56,7 @@ class ComplexShape : public BinaryShapes virtual ~ComplexShape(){}; template - LevelSetShape *defineLevelSetShape(SPHBody &sph_body, const std::string &shape_name, Args &&... args) + LevelSetShape *defineLevelSetShape(SPHBody &sph_body, const std::string &shape_name, Args &&...args) { size_t index = getSubShapeIndexByName(shape_name); LevelSetShape *level_set_shape = sub_shape_ptrs_keeper_[index].createPtr( @@ -80,12 +80,12 @@ class AlignedBoxShape : public TransformShape public: /** construct directly */ template - explicit AlignedBoxShape(int upper_bound_axis, const Transform &transform, Args &&... args) + explicit AlignedBoxShape(int upper_bound_axis, const Transform &transform, Args &&...args) : TransformShape(transform, std::forward(args)...), alignment_axis_(upper_bound_axis){}; /** construct from a shape already has aligned boundaries */ template - explicit AlignedBoxShape(int upper_bound_axis, const Shape &shape, Args &&... args) + explicit AlignedBoxShape(int upper_bound_axis, const Shape &shape, Args &&...args) : TransformShape( Transform(Vecd(0.5 * (shape.bounding_box_.second_ + shape.bounding_box_.first_))), 0.5 * (shape.bounding_box_.second_ - shape.bounding_box_.first_), std::forward(args)...), diff --git a/src/shared/particle_dynamics/relax_dynamics/relax_stepping.cpp b/src/shared/particle_dynamics/relax_dynamics/relax_stepping.cpp index efcb34eda4..a0c8dd89c5 100644 --- a/src/shared/particle_dynamics/relax_dynamics/relax_stepping.cpp +++ b/src/shared/particle_dynamics/relax_dynamics/relax_stepping.cpp @@ -77,12 +77,12 @@ void PositionRelaxation::update(size_t index_i, Real dt_square) } //=================================================================================================// UpdateSmoothingLengthRatioByShape:: - UpdateSmoothingLengthRatioByShape(SPHBody &sph_body, Shape &target_shape) + UpdateSmoothingLengthRatioByShape(SPHBody &sph_body, Shape &adaptation_shape) : LocalDynamics(sph_body), h_ratio_(particles_->getVariableDataByName("SmoothingLengthRatio")), Vol_(particles_->getVariableDataByName("VolumetricMeasure")), pos_(particles_->getVariableDataByName("Position")), - target_shape_(target_shape), + adaptation_shape_(adaptation_shape), particle_adaptation_(DynamicCast(this, sph_body.sph_adaptation_)), reference_spacing_(particle_adaptation_->ReferenceSpacing()) {} //=================================================================================================// @@ -91,7 +91,7 @@ UpdateSmoothingLengthRatioByShape::UpdateSmoothingLengthRatioByShape(SPHBody &sp //=================================================================================================// void UpdateSmoothingLengthRatioByShape::update(size_t index_i, Real dt_square) { - Real local_spacing = particle_adaptation_->getLocalSpacing(target_shape_, pos_[index_i]); + Real local_spacing = particle_adaptation_->getLocalSpacing(adaptation_shape_, pos_[index_i]); h_ratio_[index_i] = reference_spacing_ / local_spacing; Vol_[index_i] = pow(local_spacing, Dimensions); } diff --git a/src/shared/particle_dynamics/relax_dynamics/relax_stepping.h b/src/shared/particle_dynamics/relax_dynamics/relax_stepping.h index adb0ebf606..4fe855d92e 100644 --- a/src/shared/particle_dynamics/relax_dynamics/relax_stepping.h +++ b/src/shared/particle_dynamics/relax_dynamics/relax_stepping.h @@ -148,12 +148,12 @@ class UpdateSmoothingLengthRatioByShape : public LocalDynamics protected: Real *h_ratio_, *Vol_; Vecd *pos_; - Shape &target_shape_; + Shape &adaptation_shape_; ParticleRefinementByShape *particle_adaptation_; Real reference_spacing_; public: - UpdateSmoothingLengthRatioByShape(SPHBody &sph_body, Shape &target_shape); + UpdateSmoothingLengthRatioByShape(SPHBody &sph_body, Shape &adaptation_shape); explicit UpdateSmoothingLengthRatioByShape(SPHBody &sph_body); virtual ~UpdateSmoothingLengthRatioByShape(){}; void update(size_t index_i, Real dt = 0.0); diff --git a/src/shared/particle_dynamics/solid_dynamics/constraint_dynamics.cpp b/src/shared/particle_dynamics/solid_dynamics/constraint_dynamics.cpp index 35a4165521..b9a9717ab8 100644 --- a/src/shared/particle_dynamics/solid_dynamics/constraint_dynamics.cpp +++ b/src/shared/particle_dynamics/solid_dynamics/constraint_dynamics.cpp @@ -28,15 +28,15 @@ void SpringConstrain::update(size_t index_i, Real dt) } //=================================================================================================// PositionSolidBody:: - PositionSolidBody(SPHBody &sph_body, Real start_time, Real end_time, Vecd pos_end_center) + PositionSolidBody(SPHBody &sph_body, BoundingBox body_bounds, + Real start_time, Real end_time, Vecd pos_end_center) : MotionConstraint(sph_body), start_time_(start_time), end_time_(end_time), physical_time_(sph_system_.getSystemVariableDataByName("PhysicalTime")), pos_end_center_(pos_end_center) { - BoundingBox bounds = sph_body.getSPHBodyBounds(); - pos_0_center_ = (bounds.first_ + bounds.second_) * 0.5; + pos_0_center_ = (body_bounds.first_ + body_bounds.second_) * 0.5; translation_ = pos_end_center_ - pos_0_center_; } //=================================================================================================// @@ -58,13 +58,13 @@ void PositionSolidBody::update(size_t index_i, Real dt) } //=================================================================================================// PositionScaleSolidBody:: - PositionScaleSolidBody(SPHBody &sph_body, Real start_time, Real end_time, Real end_scale) + PositionScaleSolidBody(SPHBody &sph_body, BoundingBox body_bounds, + Real start_time, Real end_time, Real end_scale) : MotionConstraint(sph_body), start_time_(start_time), end_time_(end_time), end_scale_(end_scale), physical_time_(sph_system_.getSystemVariableDataByName("PhysicalTime")) { - BoundingBox bounds = sph_body.getSPHBodyBounds(); - pos_0_center_ = (bounds.first_ + bounds.second_) * 0.5; + pos_0_center_ = (body_bounds.first_ + body_bounds.second_) * 0.5; } //=================================================================================================// Vecd PositionScaleSolidBody::getDisplacement(size_t index_i, Real dt) diff --git a/src/shared/particle_dynamics/solid_dynamics/constraint_dynamics.h b/src/shared/particle_dynamics/solid_dynamics/constraint_dynamics.h index 4b6d410360..723f218a02 100644 --- a/src/shared/particle_dynamics/solid_dynamics/constraint_dynamics.h +++ b/src/shared/particle_dynamics/solid_dynamics/constraint_dynamics.h @@ -68,7 +68,7 @@ class SpringConstrain : public MotionConstraint class PositionSolidBody : public MotionConstraint { public: - PositionSolidBody(SPHBody &sph_body, Real start_time, Real end_time, Vecd pos_end_center); + PositionSolidBody(SPHBody &sph_body, BoundingBox body_bounds, Real start_time, Real end_time, Vecd pos_end_center); virtual ~PositionSolidBody(){}; Vecd *GetParticlePos0() { return pos0_; }; Vecd *GetParticlePosN() { return pos_; }; @@ -90,7 +90,7 @@ class PositionSolidBody : public MotionConstraint class PositionScaleSolidBody : public MotionConstraint { public: - PositionScaleSolidBody(SPHBody &sph_body, Real start_time, Real end_time, Real end_scale); + PositionScaleSolidBody(SPHBody &sph_body, BoundingBox body_bounds, Real start_time, Real end_time, Real end_scale); virtual ~PositionScaleSolidBody(){}; Vecd *GetParticlePos0() { return pos0_; }; Vecd *GetParticlePosN() { return pos_; }; diff --git a/src/shared/particle_generator/particle_generator_lattice.cpp b/src/shared/particle_generator/particle_generator_lattice.cpp index 4663f4ef50..f5db14d260 100644 --- a/src/shared/particle_generator/particle_generator_lattice.cpp +++ b/src/shared/particle_generator/particle_generator_lattice.cpp @@ -7,42 +7,42 @@ namespace SPH { //=================================================================================================// -GeneratingMethod::GeneratingMethod(SPHBody &sph_body) +GeneratingMethod::GeneratingMethod(SPHBody &sph_body, Shape &contain_shape) : lattice_spacing_(sph_body.sph_adaptation_->ReferenceSpacing()), - domain_bounds_(sph_body.getSPHSystemBounds()), - initial_shape_(sph_body.getInitialShape()) + domain_bounds_(sph_body.getSPHSystemBounds()), contain_shape_(contain_shape) { - if (!initial_shape_.isValid()) + if (!contain_shape_.isValid()) { - std::cout << "\n BaseParticleGeneratorLattice Error: initial_shape_ is invalid." << std::endl; + std::cout << "\n BaseParticleGeneratorLattice Error: shape_ is invalid." << std::endl; std::cout << __FILE__ << ':' << __LINE__ << std::endl; throw; } } //=================================================================================================// ParticleGenerator:: - ParticleGenerator(SPHBody &sph_body, BaseParticles &base_particles) + ParticleGenerator(SPHBody &sph_body, BaseParticles &base_particles, Shape &contain_shape) : ParticleGenerator(sph_body, base_particles), - GeneratingMethod(sph_body) {} + GeneratingMethod(sph_body, contain_shape) {} //=================================================================================================// ParticleGenerator:: - ParticleGenerator(SPHBody &sph_body, BaseParticles &base_particles, Shape &target_shape) - : ParticleGenerator(sph_body, base_particles), - target_shape_(target_shape), + ParticleGenerator(SPHBody &sph_body, BaseParticles &base_particles, + Shape &contain_shape, Shape &adaptation_shape) + : ParticleGenerator(sph_body, base_particles, contain_shape), + adaptation_shape_(adaptation_shape), particle_adaptation_(DynamicCast(this, sph_body.sph_adaptation_)) { lattice_spacing_ = particle_adaptation_->MinimumSpacing(); } //=================================================================================================// ParticleGenerator:: - ParticleGenerator(SPHBody &sph_body, BaseParticles &base_particles) + ParticleGenerator(SPHBody &sph_body, BaseParticles &base_particles, Shape &common_shape) : ParticleGenerator( - sph_body, base_particles, sph_body.getInitialShape()) {} + sph_body, base_particles, common_shape, common_shape) {} //=================================================================================================// void ParticleGenerator:: addPositionAndVolumetricMeasure(const Vecd &position, Real volume) { - Real local_particle_spacing = particle_adaptation_->getLocalSpacing(target_shape_, position); + Real local_particle_spacing = particle_adaptation_->getLocalSpacing(adaptation_shape_, position); Real local_particle_volume_ratio = pow(lattice_spacing_ / local_particle_spacing, Dimensions); if (rand_uniform(0.0, 1.0) < local_particle_volume_ratio) { @@ -52,9 +52,10 @@ void ParticleGenerator:: } //=================================================================================================// ParticleGenerator:: - ParticleGenerator(SPHBody &sph_body, SurfaceParticles &surface_particles, Real thickness) + ParticleGenerator(SPHBody &sph_body, SurfaceParticles &surface_particles, + Shape &contain_shape, Real thickness) : ParticleGenerator(sph_body, surface_particles), - GeneratingMethod(sph_body), total_volume_(0), thickness_(thickness), + GeneratingMethod(sph_body, contain_shape), total_volume_(0), thickness_(thickness), particle_spacing_(sph_body.sph_adaptation_->ReferenceSpacing()), avg_particle_volume_(pow(particle_spacing_, Dimensions - 1) * thickness_), all_cells_(0), planned_number_of_particles_(0) diff --git a/src/shared/particle_generator/particle_generator_lattice.h b/src/shared/particle_generator/particle_generator_lattice.h index 65fba54890..da1d63ad64 100644 --- a/src/shared/particle_generator/particle_generator_lattice.h +++ b/src/shared/particle_generator/particle_generator_lattice.h @@ -43,13 +43,13 @@ template <> // Base class for generating particles from lattice positions class GeneratingMethod { public: - explicit GeneratingMethod(SPHBody &sph_body); + explicit GeneratingMethod(SPHBody &sph_body, Shape &contain_shape); virtual ~GeneratingMethod(){}; protected: Real lattice_spacing_; /**< Initial particle spacing. */ - BoundingBox domain_bounds_; /**< Domain bounds. */ - Shape &initial_shape_; /**< Geometry shape for body. */ + BoundingBox domain_bounds_; /**< System domain bounds. */ + Shape &contain_shape_; /**< Contain generated particles. */ }; template <> @@ -57,7 +57,7 @@ class ParticleGenerator : public ParticleGenerator, public GeneratingMethod { public: - explicit ParticleGenerator(SPHBody &sph_body, BaseParticles &base_particles); + explicit ParticleGenerator(SPHBody &sph_body, BaseParticles &base_particles, Shape &contain_shape); virtual ~ParticleGenerator(){}; virtual void prepareGeometricData() override; }; @@ -66,12 +66,12 @@ template <> // For generating particles with adaptive resolution from lattice po class ParticleGenerator : public ParticleGenerator { public: - ParticleGenerator(SPHBody &sph_body, BaseParticles &base_particles, Shape &target_shape); - explicit ParticleGenerator(SPHBody &sph_body, BaseParticles &base_particles); + ParticleGenerator(SPHBody &sph_body, BaseParticles &base_particles, Shape &contain_shape, Shape &adaptation_shape); + explicit ParticleGenerator(SPHBody &sph_body, BaseParticles &base_particles, Shape &common_shape); virtual ~ParticleGenerator(){}; protected: - Shape &target_shape_; + Shape &adaptation_shape_; ParticleRefinementByShape *particle_adaptation_; virtual void addPositionAndVolumetricMeasure(const Vecd &position, Real volume) override; }; @@ -81,7 +81,7 @@ class ParticleGenerator : public ParticleGenerator, public GeneratingMethod { public: - ParticleGenerator(SPHBody &sph_body, SurfaceParticles &surface_particles, Real thickness); + ParticleGenerator(SPHBody &sph_body, SurfaceParticles &surface_particles, Shape &contain_shape, Real thickness); virtual ~ParticleGenerator(){}; virtual void prepareGeometricData() override; diff --git a/tests/2d_examples/2d_examples_ck/test_2d_dambreak_ck/dambreak_ck.cpp b/tests/2d_examples/2d_examples_ck/test_2d_dambreak_ck/dambreak_ck.cpp index 87f0729d69..bf83c87b06 100644 --- a/tests/2d_examples/2d_examples_ck/test_2d_dambreak_ck/dambreak_ck.cpp +++ b/tests/2d_examples/2d_examples_ck/test_2d_dambreak_ck/dambreak_ck.cpp @@ -60,11 +60,12 @@ int main(int ac, char *av[]) TransformShape initial_water_block(Transform(water_block_translation), water_block_halfsize, "WaterBody"); FluidBody water_block(sph_system, initial_water_block); water_block.defineMaterial(rho0_f, c_f); - water_block.generateParticles(); + water_block.generateParticles(initial_water_block); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WallBoundary wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape); wall_boundary.defineMaterial(); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); ObserverBody fluid_observer(sph_system, "FluidObserver"); StdVec observation_location = {Vecd(DL, 0.2)}; diff --git a/tests/2d_examples/test_1d_shock_tube/shock_tube.cpp b/tests/2d_examples/test_1d_shock_tube/shock_tube.cpp index dcfe5dcb24..e07a939409 100644 --- a/tests/2d_examples/test_1d_shock_tube/shock_tube.cpp +++ b/tests/2d_examples/test_1d_shock_tube/shock_tube.cpp @@ -88,7 +88,8 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Create body, materials and particles. //---------------------------------------------------------------------- - FluidBody wave_body(sph_system, makeShared("WaveBody")); + WaveBlock wave_block_shape("WaveBlock"); + FluidBody wave_body(sph_system, wave_block_shape.getName()); wave_body.defineMaterial(rho0_l, heat_capacity_ratio); wave_body.generateParticles(); //---------------------------------------------------------------------- @@ -105,7 +106,7 @@ int main(int ac, char *av[]) InteractionWithUpdate density_and_energy_relaxation(wave_body_inner); SimpleDynamics waves_initial_condition(wave_body); - PeriodicAlongAxis periodic_along_y(wave_body.getSPHBodyBounds(), yAxis); + PeriodicAlongAxis periodic_along_y(wave_block_shape.getBounds(), yAxis); PeriodicConditionUsingCellLinkedList periodic_condition_y(wave_body, periodic_along_y); ReduceDynamics get_wave_time_step_size(wave_body); InteractionWithUpdate kernel_correction_matrix(wave_body_inner); diff --git a/tests/2d_examples/test_2d_channel_flow_fluid_shell/channel_flow_shell.cpp b/tests/2d_examples/test_2d_channel_flow_fluid_shell/channel_flow_shell.cpp index 056ced7ace..0e0da81710 100644 --- a/tests/2d_examples/test_2d_channel_flow_fluid_shell/channel_flow_shell.cpp +++ b/tests/2d_examples/test_2d_channel_flow_fluid_shell/channel_flow_shell.cpp @@ -166,7 +166,8 @@ void channel_flow_shell(const Real resolution_ref, const Real wall_thickness) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared(createWaterBlockShape(), "WaterBody")); + WaterBlock water_block_shape = WaterBlock(createWaterBlockShape(), "WaterBody"); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); water_block.generateParticles(); @@ -219,7 +220,7 @@ void channel_flow_shell(const Real resolution_ref, const Real wall_thickness) water_block, makeShared(xAxis, Transform(Vec2d(buffer_translation)), buffer_halfsize)); SimpleDynamics> parabolic_inflow(inflow_buffer); /** Periodic BCs in x direction. */ - PeriodicAlongAxis periodic_along_x(water_block.getSPHBodyBounds(), xAxis); + PeriodicAlongAxis periodic_along_x(water_block_shape.getBounds(), xAxis); PeriodicConditionUsingCellLinkedList periodic_condition(water_block, periodic_along_x); // Curvature calculation SimpleDynamics shell_curvature(shell_curvature_inner); diff --git a/tests/2d_examples/test_2d_diffusion/diffusion.cpp b/tests/2d_examples/test_2d_diffusion/diffusion.cpp index 889abec017..6f30cc09f6 100644 --- a/tests/2d_examples/test_2d_diffusion/diffusion.cpp +++ b/tests/2d_examples/test_2d_diffusion/diffusion.cpp @@ -103,7 +103,8 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - SolidBody diffusion_body(sph_system, makeShared("DiffusionBlock")); + DiffusionBlock diffusion_block("DiffusionBlock"); + SolidBody diffusion_body(sph_system, diffusion_block.getName()); DirectionalDiffusion *diffusion = diffusion_body.defineMaterial("Phi", diffusion_coeff, bias_coeff, bias_direction); diffusion_body.generateParticles(); @@ -132,7 +133,7 @@ int main(int ac, char *av[]) SimpleDynamics setup_diffusion_initial_condition(diffusion_body); GetDiffusionTimeStepSize get_time_step_size(diffusion_body, *diffusion); - PeriodicAlongAxis periodic_along_x(diffusion_body.getSPHBodyBounds(), xAxis); + PeriodicAlongAxis periodic_along_x(diffusion_block.getBounds(), xAxis); PeriodicConditionUsingCellLinkedList periodic_condition_y(diffusion_body, periodic_along_x); //---------------------------------------------------------------------- // Define the methods for I/O operations and observations of the simulation. diff --git a/tests/2d_examples/test_2d_eulerian_taylor_green_LG/2d_eulerian_taylor_green_LG.cpp b/tests/2d_examples/test_2d_eulerian_taylor_green_LG/2d_eulerian_taylor_green_LG.cpp index 87248a2d61..149e781166 100644 --- a/tests/2d_examples/test_2d_eulerian_taylor_green_LG/2d_eulerian_taylor_green_LG.cpp +++ b/tests/2d_examples/test_2d_eulerian_taylor_green_LG/2d_eulerian_taylor_green_LG.cpp @@ -82,7 +82,8 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody water_body(sph_system, makeShared("WaterBody")); + WaterBlock water_block_shape("WaterBody"); + FluidBody water_body(sph_system, water_block_shape.getName()); water_body.sph_adaptation_->resetKernel>(20); water_body.defineMaterial(rho0_f, heat_capacity_ratio, mu_f); water_body.generateParticles(); @@ -103,8 +104,8 @@ int main(int ac, char *av[]) InteractionWithUpdate density_and_energy_relaxation(water_body_inner); SimpleDynamics initial_condition(water_body); - PeriodicAlongAxis periodic_along_x(water_body.getSPHBodyBounds(), xAxis); - PeriodicAlongAxis periodic_along_y(water_body.getSPHBodyBounds(), yAxis); + PeriodicAlongAxis periodic_along_x(water_block_shape.getBounds(), xAxis); + PeriodicAlongAxis periodic_along_y(water_block_shape.getBounds(), yAxis); PeriodicConditionUsingCellLinkedList periodic_condition_x(water_body, periodic_along_x); PeriodicConditionUsingCellLinkedList periodic_condition_y(water_body, periodic_along_y); ReduceDynamics get_fluid_time_step_size(water_body); diff --git a/tests/2d_examples/test_2d_flow_around_cylinder/2d_flow_around_cylinder.cpp b/tests/2d_examples/test_2d_flow_around_cylinder/2d_flow_around_cylinder.cpp index 1bf1ba63cb..3e79598728 100644 --- a/tests/2d_examples/test_2d_flow_around_cylinder/2d_flow_around_cylinder.cpp +++ b/tests/2d_examples/test_2d_flow_around_cylinder/2d_flow_around_cylinder.cpp @@ -28,17 +28,19 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared("WaterBlock")); + WaterBlock water_block_shape("WaterBlock"); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(parameterization_io, rho0_f, c_f, mu_f); - water_block.generateParticles(); + water_block.generateParticles(water_block_shape); - SolidBody cylinder(sph_system, makeShared("Cylinder")); + Cylinder cylinder_shape("Cylinder"); + SolidBody cylinder(sph_system, cylinder_shape.getName()); cylinder.defineAdaptationRatios(1.15, 2.0); - cylinder.defineBodyLevelSetShape(); + LevelSetShape level_set_shape(cylinder, cylinder_shape, 1.0); cylinder.defineMaterial(); (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? cylinder.generateParticles(cylinder.getName()) - : cylinder.generateParticles(); + : cylinder.generateParticles(level_set_shape); ObserverBody fluid_observer(sph_system, "FluidObserver"); fluid_observer.generateParticles(observation_locations); @@ -112,8 +114,8 @@ int main(int ac, char *av[]) Dynamics1Level density_relaxation(water_block_inner, water_block_contact); InteractionWithUpdate update_density_by_summation(water_block_inner, water_block_contact); - PeriodicAlongAxis periodic_along_x(water_block.getSPHBodyBounds(), xAxis); - PeriodicAlongAxis periodic_along_y(water_block.getSPHBodyBounds(), yAxis); + PeriodicAlongAxis periodic_along_x(water_block_shape.getBounds(), xAxis); + PeriodicAlongAxis periodic_along_y(water_block_shape.getBounds(), yAxis); PeriodicConditionUsingCellLinkedList periodic_condition_x(water_block, periodic_along_x); PeriodicConditionUsingCellLinkedList periodic_condition_y(water_block, periodic_along_y); ReduceDynamics get_fluid_advection_time_step_size(water_block, U_f); diff --git a/tests/2d_examples/test_2d_fsi2/fsi2.cpp b/tests/2d_examples/test_2d_fsi2/fsi2.cpp index 850d2c0fea..31bb2b2015 100644 --- a/tests/2d_examples/test_2d_fsi2/fsi2.cpp +++ b/tests/2d_examples/test_2d_fsi2/fsi2.cpp @@ -28,21 +28,25 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared("WaterBody")); + WaterBlock water_block_shape("WaterBody"); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); - water_block.generateParticles(); + water_block.generateParticles(water_block_shape); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WallBoundary wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); - SolidBody insert_body(sph_system, makeShared("InsertedBody")); + Insert inserted_body_shape("InsertedBody"); + SolidBody insert_body(sph_system, inserted_body_shape.getName()); insert_body.defineAdaptationRatios(1.15, 2.0); - insert_body.defineBodyLevelSetShape()->writeLevelSet(sph_system); + LevelSetShape level_set_shape(insert_body, inserted_body_shape, 1.0); + level_set_shape.writeLevelSet(sph_system); insert_body.defineMaterial(rho0_s, Youngs_modulus, poisson); (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? insert_body.generateParticles(insert_body.getName()) - : insert_body.generateParticles(); + : insert_body.generateParticles(level_set_shape); ObserverBody beam_observer(sph_system, "BeamObserver"); StdVec beam_observation_location = {0.5 * (BRT + BRB)}; @@ -144,7 +148,7 @@ int main(int ac, char *av[]) BodyAlignedBoxByCell inflow_buffer(water_block, makeShared(xAxis, Transform(Vec2d(buffer_translation)), buffer_halfsize)); SimpleDynamics> parabolic_inflow(inflow_buffer); - PeriodicAlongAxis periodic_along_x(water_block.getSPHBodyBounds(), xAxis); + PeriodicAlongAxis periodic_along_x(water_block_shape.getBounds(), xAxis); PeriodicConditionUsingCellLinkedList periodic_condition(water_block, periodic_along_x); InteractionDynamics compute_vorticity(water_block_inner); diff --git a/tests/2d_examples/test_2d_heat_transfer/heat_transfer.cpp b/tests/2d_examples/test_2d_heat_transfer/heat_transfer.cpp index 6c5746ba32..d2bbe782f7 100644 --- a/tests/2d_examples/test_2d_heat_transfer/heat_transfer.cpp +++ b/tests/2d_examples/test_2d_heat_transfer/heat_transfer.cpp @@ -188,13 +188,15 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody thermofluid_body(sph_system, makeShared("ThermofluidBody")); + ThermofluidBody thermofluid_body_shape("ThermofluidBody"); + FluidBody thermofluid_body(sph_system, thermofluid_body_shape.getName()); thermofluid_body.defineMaterial(rho0_f, c_f, mu_f); - thermofluid_body.generateParticles(); + thermofluid_body.generateParticles(thermofluid_body_shape); - SolidBody thermosolid_body(sph_system, makeShared("ThermosolidBody")); + ThermosolidBody thermosolid_body_shape("ThermosolidBody"); + SolidBody thermosolid_body(sph_system, thermosolid_body_shape.getName()); thermosolid_body.defineMaterial(); - thermosolid_body.generateParticles(); + thermosolid_body.generateParticles(thermosolid_body_shape); ObserverBody temperature_observer(sph_system, "FluidObserver"); temperature_observer.generateParticles(observation_location); @@ -237,7 +239,7 @@ int main(int ac, char *av[]) ReduceDynamics get_fluid_advection_time_step(thermofluid_body, U_f); ReduceDynamics get_fluid_time_step(thermofluid_body); - PeriodicAlongAxis periodic_along_x(thermofluid_body.getSPHBodyBounds(), xAxis); + PeriodicAlongAxis periodic_along_x(thermofluid_body_shape.getBounds(), xAxis); PeriodicConditionUsingCellLinkedList periodic_condition(thermofluid_body, periodic_along_x); BodyAlignedBoxByCell inflow_buffer(thermofluid_body, makeShared(xAxis, Transform(Vec2d(buffer_translation)), buffer_halfsize)); SimpleDynamics> parabolic_inflow(inflow_buffer); diff --git a/tests/2d_examples/test_2d_poiseuille_flow/poiseuille_flow.cpp b/tests/2d_examples/test_2d_poiseuille_flow/poiseuille_flow.cpp index 742de5d786..0e6fb1103e 100644 --- a/tests/2d_examples/test_2d_poiseuille_flow/poiseuille_flow.cpp +++ b/tests/2d_examples/test_2d_poiseuille_flow/poiseuille_flow.cpp @@ -78,13 +78,15 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating bodies with corresponding materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared("WaterBody")); + WaterBlock water_block_shape("WaterBody"); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); - water_block.generateParticles(); + water_block.generateParticles(water_block_shape); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WallBoundary wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); //---------------------------------------------------------------------- // Define body relation map. // The contact map gives the topological connections between the bodies. @@ -121,7 +123,7 @@ int main(int ac, char *av[]) ReduceDynamics get_fluid_advection_time_step_size(water_block, U_f); ReduceDynamics get_fluid_time_step_size(water_block); - PeriodicAlongAxis periodic_along_x(water_block.getSPHBodyBounds(), xAxis); + PeriodicAlongAxis periodic_along_x(wall_boundary_shape.getBounds(), xAxis); PeriodicConditionUsingCellLinkedList periodic_condition(water_block, periodic_along_x); //---------------------------------------------------------------------- // Define the configuration related particles dynamics. diff --git a/tests/2d_examples/test_2d_taylor_green/taylor_green.cpp b/tests/2d_examples/test_2d_taylor_green/taylor_green.cpp index 97b2192cda..def1a08cd8 100644 --- a/tests/2d_examples/test_2d_taylor_green/taylor_green.cpp +++ b/tests/2d_examples/test_2d_taylor_green/taylor_green.cpp @@ -73,12 +73,13 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating bodies with corresponding materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared("WaterBody")); + WaterBlock water_block_shape("WaterBody"); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); // Using relaxed particle distribution if needed sph_system.ReloadParticles() ? water_block.generateParticles(water_block.getName()) - : water_block.generateParticles(); + : water_block.generateParticles(water_block_shape); //---------------------------------------------------------------------- // Define body relation map. // The contact map gives the topological connections between the bodies. @@ -109,8 +110,8 @@ int main(int ac, char *av[]) InteractionWithUpdate> transport_velocity_correction(water_block_inner); ReduceDynamics get_fluid_advection_time_step_size(water_block, U_f); ReduceDynamics get_fluid_time_step_size(water_block); - PeriodicAlongAxis periodic_along_x(water_block.getSPHBodyBounds(), xAxis); - PeriodicAlongAxis periodic_along_y(water_block.getSPHBodyBounds(), yAxis); + PeriodicAlongAxis periodic_along_x(water_block_shape.getBounds(), xAxis); + PeriodicAlongAxis periodic_along_y(water_block_shape.getBounds(), yAxis); PeriodicConditionUsingCellLinkedList periodic_condition_x(water_block, periodic_along_x); PeriodicConditionUsingCellLinkedList periodic_condition_y(water_block, periodic_along_y); //---------------------------------------------------------------------- diff --git a/tests/2d_examples/test_2d_tethered_dead_fish_in_flow/src/tethered_dead_fish_in_flow.cpp b/tests/2d_examples/test_2d_tethered_dead_fish_in_flow/src/tethered_dead_fish_in_flow.cpp index 22d90ef22c..3d06be6cc5 100644 --- a/tests/2d_examples/test_2d_tethered_dead_fish_in_flow/src/tethered_dead_fish_in_flow.cpp +++ b/tests/2d_examples/test_2d_tethered_dead_fish_in_flow/src/tethered_dead_fish_in_flow.cpp @@ -210,26 +210,30 @@ int main(int ac, char *av[]) /** * @brief Particles and body creation for water. */ - FluidBody water_block(system, makeShared("WaterBody")); + WaterBlock water_block_shape("WaterBody"); + FluidBody water_block(system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); - water_block.generateParticles(); + water_block.generateParticles(water_block_shape); /** * @brief Particles and body creation for wall boundary. */ - SolidBody wall_boundary(system, makeShared("Wall")); + WallBoundary wall_boundary_shape("Wall"); + SolidBody wall_boundary(system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); /** * @brief Particles and body creation for fish. */ - SolidBody fish_body(system, makeShared("FishBody")); + FishBody fish_body_shape("FishBody"); + SolidBody fish_body(system, fish_body_shape.getName()); fish_body.defineAdaptationRatios(1.15, 2.0); - fish_body.defineBodyLevelSetShape(); + LevelSetShape level_set_shape(fish_body, fish_body_shape, 1.0); + level_set_shape.writeLevelSet(system); fish_body.defineMaterial(rho0_s, Youngs_modulus, poisson); // Using relaxed particle distribution if needed (!system.RunParticleRelaxation() && system.ReloadParticles()) ? fish_body.generateParticles(fish_body.getName()) - : fish_body.generateParticles(); + : fish_body.generateParticles(level_set_shape); /** * @brief Particle and body creation of fish observer. */ @@ -294,7 +298,7 @@ int main(int ac, char *av[]) * @brief Methods used for updating data structure. */ /** Periodic BCs in x direction. */ - PeriodicAlongAxis periodic_along_x(water_block.getSPHBodyBounds(), xAxis); + PeriodicAlongAxis periodic_along_x(water_block_shape.getBounds(), xAxis); PeriodicConditionUsingCellLinkedList periodic_condition(water_block, periodic_along_x); SimpleDynamics wall_boundary_normal_direction(wall_boundary); SimpleDynamics fish_body_normal_direction(fish_body); diff --git a/tests/2d_examples/test_2d_throat/throat.cpp b/tests/2d_examples/test_2d_throat/throat.cpp index ca59181638..0ef326666d 100644 --- a/tests/2d_examples/test_2d_throat/throat.cpp +++ b/tests/2d_examples/test_2d_throat/throat.cpp @@ -130,14 +130,16 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody fluid_block(sph_system, makeShared("FluidBody")); + FluidBlock fluid_block_shape("FluidBody"); + FluidBody fluid_block(sph_system, fluid_block_shape.getName()); fluid_block.defineMaterial(rho0_f, c_f, mu_f, lambda_f, mu_p_f); - Ghost ghost_along_x(fluid_block.getSPHBodyBounds(), xAxis); - fluid_block.generateParticlesWithReserve(ghost_along_x); + Ghost ghost_along_x(fluid_block_shape.getBounds(), xAxis); + fluid_block.generateParticlesWithReserve(ghost_along_x, fluid_block_shape); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WallBoundary wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); ObserverBody fluid_observer(sph_system, "FluidObserver"); StdVec observation_location = {Vecd::Zero()}; diff --git a/tests/unit_tests_src/shared/particle_dynamics/fluid_dynamics/test_2d_velocity_gradient/2d_velocity_gradient.cpp b/tests/unit_tests_src/shared/particle_dynamics/fluid_dynamics/test_2d_velocity_gradient/2d_velocity_gradient.cpp index bc86f40458..da8858fe13 100644 --- a/tests/unit_tests_src/shared/particle_dynamics/fluid_dynamics/test_2d_velocity_gradient/2d_velocity_gradient.cpp +++ b/tests/unit_tests_src/shared/particle_dynamics/fluid_dynamics/test_2d_velocity_gradient/2d_velocity_gradient.cpp @@ -120,9 +120,10 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating bodies with corresponding materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared("WaterBody")); + WaterBlock water_block_shape("WaterBody"); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); - water_block.generateParticles(); + water_block.generateParticles(water_block_shape); SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); wall_boundary.defineMaterial(); @@ -146,7 +147,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- SimpleDynamics initial_condition(water_block); SimpleDynamics wall_boundary_normal_direction(wall_boundary); - PeriodicAlongAxis periodic_along_x(water_block.getSPHBodyBounds(), xAxis); + PeriodicAlongAxis periodic_along_x(water_block_shape.getBounds(), xAxis); PeriodicConditionUsingCellLinkedList periodic_condition(water_block, periodic_along_x); InteractionDynamics distance_to_wall(water_wall_contact); InteractionWithUpdate corrected_configuration_fluid(water_block_inner, water_wall_contact); From a614e9094f2303396eb252c0f2e6bc4564f1782b Mon Sep 17 00:00:00 2001 From: Xiangyu Hu Date: Sat, 21 Sep 2024 16:18:41 +0000 Subject: [PATCH 02/13] delete getInitialShape() --- .../opencascade/relax_dynamics_surface.cpp | 20 ++++----- .../opencascade/relax_dynamics_surface.h | 14 +++---- .../test_3d_aortic_valve/aortic_valve.cpp | 30 +++++++------- .../particle_generator_network.cpp | 13 +++--- .../particle_generator_network.h | 4 +- src/shared/bodies/base_body_part.cpp | 41 ++++--------------- src/shared/bodies/base_body_part.h | 11 +++-- .../eulerian_ghost_boundary.cpp | 8 ++-- .../eulerian_ghost_boundary.h | 4 +- .../general_dynamics/general_geometric.cpp | 23 +++++------ .../general_dynamics/general_geometric.h | 10 ++--- .../relax_dynamics/relax_stepping.cpp | 13 +----- .../relax_dynamics/relax_stepping.h | 4 +- .../relax_dynamics/relax_thick_shell.cpp | 17 ++++---- .../relax_dynamics/relax_thick_shell.h | 6 +-- .../general_dynamics/geometric_dynamics.cpp | 9 ++-- .../general_dynamics/geometric_dynamics.h | 6 +-- ...eulerian_supersonic_flow_around_cylinder.h | 12 +++--- .../excitation-contraction.cpp | 40 ++++++++++-------- .../excitation_contraction.h | 14 ++++--- .../pkj_lv_electrocontraction.h | 14 ++++--- 21 files changed, 145 insertions(+), 168 deletions(-) diff --git a/modules/opencascade/opencascade/relax_dynamics_surface.cpp b/modules/opencascade/opencascade/relax_dynamics_surface.cpp index 351e9f976c..a5ece1f9cb 100644 --- a/modules/opencascade/opencascade/relax_dynamics_surface.cpp +++ b/modules/opencascade/opencascade/relax_dynamics_surface.cpp @@ -10,14 +10,12 @@ namespace SPH namespace relax_dynamics { //=================================================================================================// -ShapeSurfaceBounding2::ShapeSurfaceBounding2(RealBody &real_body_) +ShapeSurfaceConstraint::ShapeSurfaceConstraint(RealBody &real_body_, Shape &shape) : LocalDynamics(real_body_), - pos_(particles_->getVariableDataByName("Position")) -{ - shape_ = &real_body_.getInitialShape(); -} + pos_(particles_->getVariableDataByName("Position")), + shape_(&shape) {} //=================================================================================================// -void ShapeSurfaceBounding2::update(size_t index_i, Real dt) +void ShapeSurfaceConstraint::update(size_t index_i, Real dt) { pos_[index_i] = shape_->findClosestPoint(pos_[index_i]); } @@ -36,12 +34,10 @@ void RelaxationStepInnerFirstHalf::exec(Real dt) //=================================================================================================// RelaxationStepInnerSecondHalf:: - RelaxationStepInnerSecondHalf(BaseInnerRelation &inner_relation) + RelaxationStepInnerSecondHalf(BaseInnerRelation &inner_relation, Shape &shape) : BaseDynamics(), real_body_(inner_relation.real_body_), get_time_step_square_(*real_body_), update_particle_position_(*real_body_), - surface_bounding_(*real_body_) -{ -} + surface_bounding_(*real_body_, shape) {} //=================================================================================================// void RelaxationStepInnerSecondHalf::exec(Real dt) { @@ -51,9 +47,9 @@ void RelaxationStepInnerSecondHalf::exec(Real dt) } //=================================================================================================// -SurfaceNormalDirection::SurfaceNormalDirection(SPHBody &sph_body) +SurfaceNormalDirection::SurfaceNormalDirection(SPHBody &sph_body, Shape &shape) : LocalDynamics(sph_body), - surface_shape_(DynamicCast(this, &sph_body.getInitialShape())), + surface_shape_(DynamicCast(this, &shape)), pos_(particles_->getVariableDataByName("Position")), n_(particles_->registerStateVariable("NormalDirection")) {} diff --git a/modules/opencascade/opencascade/relax_dynamics_surface.h b/modules/opencascade/opencascade/relax_dynamics_surface.h index 4d19b5de3d..c3992fcb5e 100644 --- a/modules/opencascade/opencascade/relax_dynamics_surface.h +++ b/modules/opencascade/opencascade/relax_dynamics_surface.h @@ -41,11 +41,11 @@ class SurfaceShape; namespace relax_dynamics { -class ShapeSurfaceBounding2 : public LocalDynamics +class ShapeSurfaceConstraint : public LocalDynamics { public: - ShapeSurfaceBounding2(RealBody &real_body_); - virtual ~ShapeSurfaceBounding2(){}; + ShapeSurfaceConstraint(RealBody &real_body, Shape &shape); + virtual ~ShapeSurfaceConstraint(){}; void update(size_t index_i, Real dt = 0.0); protected: @@ -69,16 +69,16 @@ class RelaxationStepInnerFirstHalf : public BaseDynamics class RelaxationStepInnerSecondHalf : public BaseDynamics { public: - explicit RelaxationStepInnerSecondHalf(BaseInnerRelation &inner_relation); + explicit RelaxationStepInnerSecondHalf(BaseInnerRelation &inner_relation, Shape &shape); virtual ~RelaxationStepInnerSecondHalf(){}; - SimpleDynamics &SurfaceBounding() { return surface_bounding_; }; + SimpleDynamics &SurfaceBounding() { return surface_bounding_; }; virtual void exec(Real dt = 0.0) override; protected: RealBody *real_body_; ReduceDynamics get_time_step_square_; SimpleDynamics update_particle_position_; - SimpleDynamics surface_bounding_; + SimpleDynamics surface_bounding_; }; /** @@ -88,7 +88,7 @@ class RelaxationStepInnerSecondHalf : public BaseDynamics class SurfaceNormalDirection : public LocalDynamics { public: - explicit SurfaceNormalDirection(SPHBody &sph_body); + explicit SurfaceNormalDirection(SPHBody &sph_body, Shape &shape); virtual ~SurfaceNormalDirection(){}; void update(size_t index_i, Real dt = 0.0); diff --git a/modules/opencascade/tests/test_3d_aortic_valve/aortic_valve.cpp b/modules/opencascade/tests/test_3d_aortic_valve/aortic_valve.cpp index 19b52bd049..f8807af435 100644 --- a/modules/opencascade/tests/test_3d_aortic_valve/aortic_valve.cpp +++ b/modules/opencascade/tests/test_3d_aortic_valve/aortic_valve.cpp @@ -59,12 +59,11 @@ template <> class ParticleGenerator : public ParticleGenerator { public: - explicit ParticleGenerator(SPHBody &sph_body, SurfaceParticles &surface_particles) - : ParticleGenerator(sph_body, surface_particles), sph_body_(sph_body){}; + explicit ParticleGenerator(SPHBody &sph_body, SurfaceParticles &surface_particles, Shape &shape) + : ParticleGenerator(sph_body, surface_particles), + surface_shape_(DynamicCast(this, &shape)){}; virtual void prepareGeometricData() override { - SurfaceShape *a = DynamicCast(this, &sph_body_.getInitialShape()); - Standard_Real u1 = 0; Standard_Real v1 = DELTA1; Standard_Real u2 = DELTA2; @@ -74,24 +73,24 @@ class ParticleGenerator : public ParticleGeneratorgetCartesianPoint(u, 0)); + points.push_back(surface_shape_->getCartesianPoint(u, 0)); } for (size_t k = 0; k <= 1 / DELTA1 - 1; k++) { Standard_Real v = v1 + k * DELTA1; - points.push_back(a->getCartesianPoint(0, v)); + points.push_back(surface_shape_->getCartesianPoint(0, v)); } for (size_t n = 0; n <= 1 / DELTA2 - 2; n++) { Standard_Real u = u2 + n * DELTA2; - points.push_back(a->getCartesianPoint(u, 1)); + points.push_back(surface_shape_->getCartesianPoint(u, 1)); } for (size_t n = 0; n <= 1 / DELTA2 - 1; n++) { Standard_Real v = v2 + n * DELTA2; - points.push_back(a->getCartesianPoint(1, v)); + points.push_back(surface_shape_->getCartesianPoint(1, v)); } for (size_t k = 0; k <= 8; k++) @@ -104,7 +103,7 @@ class ParticleGenerator : public ParticleGeneratorgetCartesianPoint(u, v)); + points.push_back(surface_shape_->getCartesianPoint(u, v)); } } @@ -115,7 +114,9 @@ class ParticleGenerator : public ParticleGenerator(full_path_to_geometry, "Leaflet")); + SurfaceShapeSTEP leaflet_shape(full_path_to_geometry, "Leaflet"); + SolidBody leaflet(sph_system, leaflet_shape.getName()); // here dummy linear elastic solid is use because no solid dynamics in particle relaxation leaflet.defineMaterial(); - leaflet.generateParticles(); + leaflet.generateParticles(leaflet_shape); //---------------------------------------------------------------------- // Define simple file input and outputs functions. //---------------------------------------------------------------------- @@ -155,10 +157,10 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- using namespace relax_dynamics; RelaxationStepInnerFirstHalf leaflet_relaxation_first_half(leaflet_inner); - RelaxationStepInnerSecondHalf leaflet_relaxation_second_half(leaflet_inner); + RelaxationStepInnerSecondHalf leaflet_relaxation_second_half(leaflet_inner, leaflet_shape); /** Constrain the boundary. */ BoundaryGeometry boundary_geometry(leaflet, "BoundaryGeometry"); - SimpleDynamics surface_normal_direction(leaflet); + SimpleDynamics surface_normal_direction(leaflet, leaflet_shape); //---------------------------------------------------------------------- // Particle relaxation starts here. //---------------------------------------------------------------------- diff --git a/src/for_3D_build/particle_generator/particle_generator_network.cpp b/src/for_3D_build/particle_generator/particle_generator_network.cpp index da6c9c3dc6..3f7a3e7517 100644 --- a/src/for_3D_build/particle_generator/particle_generator_network.cpp +++ b/src/for_3D_build/particle_generator/particle_generator_network.cpp @@ -10,13 +10,14 @@ namespace SPH { //=================================================================================================// ParticleGenerator:: - ParticleGenerator(SPHBody &sph_body, BaseParticles &base_particles, const Vecd &starting_pnt, + ParticleGenerator(SPHBody &sph_body, BaseParticles &base_particles, + Shape &shape, const Vecd &starting_pnt, const Vecd &second_pnt, int iterator, Real grad_factor) : ParticleGenerator(sph_body, base_particles), starting_pnt_(starting_pnt), second_pnt_(second_pnt), n_it_(iterator), fascicles_(true), segments_in_branch_(10), segment_length_(sph_body.sph_adaptation_->ReferenceSpacing()), - grad_factor_(grad_factor), sph_body_(sph_body), initial_shape_(sph_body.getInitialShape()), + grad_factor_(grad_factor), sph_body_(sph_body), shape_(shape), cell_linked_list_(DynamicCast(this, sph_body).getCellLinkedList()), tree_(DynamicCast(this, &sph_body)) { @@ -64,8 +65,8 @@ Vecd ParticleGenerator::createATentativeNewBranchPoint(V { Vecd pnt_to_project = init_point + dir * segment_length_; - Real phi = initial_shape_.findSignedDistance(pnt_to_project); - Vecd unit_normal = initial_shape_.findNormalDirection(pnt_to_project); + Real phi = shape_.findSignedDistance(pnt_to_project); + Vecd unit_normal = shape_.findNormalDirection(pnt_to_project); unit_normal /= unit_normal.norm() + TinyReal; Vecd new_point = pnt_to_project - phi * unit_normal; return new_point; @@ -110,7 +111,7 @@ bool ParticleGenerator:: Vecd init_point = position_[parent_elements.back()]; Vecd init_direction = parent_branch->end_direction_; - Vecd surface_norm = initial_shape_.findNormalDirection(init_point); + Vecd surface_norm = shape_.findNormalDirection(init_point); surface_norm /= surface_norm.norm() + TinyReal; Vecd in_plane = -init_direction.cross(surface_norm); @@ -130,7 +131,7 @@ bool ParticleGenerator:: for (size_t i = 1; i < number_segments; i++) { - surface_norm = initial_shape_.findNormalDirection(new_point); + surface_norm = shape_.findNormalDirection(new_point); surface_norm /= surface_norm.norm() + TinyReal; /** Project grad to surface. */ grad = getGradientFromNearestPoints(new_point, delta); diff --git a/src/for_3D_build/particle_generator/particle_generator_network.h b/src/for_3D_build/particle_generator/particle_generator_network.h index ddf724549c..4c4f547f3c 100644 --- a/src/for_3D_build/particle_generator/particle_generator_network.h +++ b/src/for_3D_build/particle_generator/particle_generator_network.h @@ -43,7 +43,7 @@ class ParticleGenerator : public ParticleGenerator : public ParticleGenerator fascicle_angles_ = {-1.25, 0.75}; /**< angles with respect to the initial edge of the fascicles.*/ Real fascicle_ratio_ = 15.0; /**< ratio of length of the fascicles. Include one per fascicle to include.*/ SPHBody &sph_body_; - Shape &initial_shape_; + Shape &shape_; BaseCellLinkedList &cell_linked_list_; TreeBody *tree_; /** diff --git a/src/shared/bodies/base_body_part.cpp b/src/shared/bodies/base_body_part.cpp index ec793229fc..c886300071 100644 --- a/src/shared/bodies/base_body_part.cpp +++ b/src/shared/bodies/base_body_part.cpp @@ -51,8 +51,9 @@ void BodyRegionByParticle::tagByContain(size_t particle_index) } } //=================================================================================================// -BodySurface::BodySurface(SPHBody &sph_body) +BodySurface::BodySurface(SPHBody &sph_body, Shape &body_shape) : BodyPartByParticle(sph_body, "BodySurface"), + body_shape_(body_shape), particle_spacing_min_(sph_body.sph_adaptation_->MinimumSpacing()) { TaggingParticleMethod tagging_particle_method = std::bind(&BodySurface::tagNearSurface, this, _1); @@ -62,13 +63,14 @@ BodySurface::BodySurface(SPHBody &sph_body) //=================================================================================================// void BodySurface::tagNearSurface(size_t particle_index) { - Real phi = sph_body_.getInitialShape().findSignedDistance(pos_[particle_index]); + Real phi = body_shape_.findSignedDistance(pos_[particle_index]); if (fabs(phi) < particle_spacing_min_) body_part_particles_.push_back(particle_index); } //=================================================================================================// -BodySurfaceLayer::BodySurfaceLayer(SPHBody &sph_body, Real layer_thickness) +BodySurfaceLayer::BodySurfaceLayer(SPHBody &sph_body, Shape &body_shape, Real layer_thickness) : BodyPartByParticle(sph_body, "InnerLayers"), + body_shape_(body_shape), thickness_threshold_(sph_body.sph_adaptation_->ReferenceSpacing() * layer_thickness) { TaggingParticleMethod tagging_particle_method = std::bind(&BodySurfaceLayer::tagSurfaceLayer, this, _1); @@ -78,7 +80,7 @@ BodySurfaceLayer::BodySurfaceLayer(SPHBody &sph_body, Real layer_thickness) //=================================================================================================// void BodySurfaceLayer::tagSurfaceLayer(size_t particle_index) { - Real distance = fabs(sph_body_.getInitialShape().findSignedDistance(pos_[particle_index])); + Real distance = fabs(body_shape_.findSignedDistance(pos_[particle_index])); if (distance < thickness_threshold_) { body_part_particles_.push_back(particle_index); @@ -104,34 +106,9 @@ bool BodyRegionByCell::checkNotFar(Vecd cell_position, Real threshold) return body_part_shape_.checkNotFar(cell_position, threshold); } //=================================================================================================// -NearShapeSurface::NearShapeSurface(RealBody &real_body, LevelSetShape &level_set_shape) - : BodyPartByCell(real_body, level_set_shape.getName()), level_set_shape_(level_set_shape) -{ - TaggingCellMethod tagging_cell_method = std::bind(&NearShapeSurface::checkNearSurface, this, _1, _2); - tagCells(tagging_cell_method); -} -//=================================================================================================// -NearShapeSurface::NearShapeSurface(RealBody &real_body, SharedPtr shape_ptr) - : BodyPartByCell(real_body, shape_ptr->getName()), - level_set_shape_(level_set_shape_keeper_.createRef(real_body, *shape_ptr.get(), true)) -{ - TaggingCellMethod tagging_cell_method = std::bind(&NearShapeSurface::checkNearSurface, this, _1, _2); - tagCells(tagging_cell_method); -} -//=================================================================================================// -NearShapeSurface::NearShapeSurface(RealBody &real_body) - : BodyPartByCell(real_body, "NearShapeSurface"), - level_set_shape_(DynamicCast(this, real_body.getInitialShape())) -{ - TaggingCellMethod tagging_cell_method = std::bind(&NearShapeSurface::checkNearSurface, this, _1, _2); - tagCells(tagging_cell_method); -} -//=================================================================================================// -NearShapeSurface::NearShapeSurface(RealBody &real_body, const std::string &sub_shape_name) - : BodyPartByCell(real_body, sub_shape_name), - level_set_shape_( - DynamicCast(this, *DynamicCast(this, real_body.getInitialShape()) - .getSubShapeByName(sub_shape_name))) +NearShapeSurface::NearShapeSurface(RealBody &real_body, Shape &shape) + : BodyPartByCell(real_body, shape.getName()), + level_set_shape_(DynamicCast(this, shape)) { TaggingCellMethod tagging_cell_method = std::bind(&NearShapeSurface::checkNearSurface, this, _1, _2); tagCells(tagging_cell_method); diff --git a/src/shared/bodies/base_body_part.h b/src/shared/bodies/base_body_part.h index ec490a8b31..8a29277ee0 100644 --- a/src/shared/bodies/base_body_part.h +++ b/src/shared/bodies/base_body_part.h @@ -150,10 +150,11 @@ class BodyRegionByParticle : public BodyPartByParticle class BodySurface : public BodyPartByParticle { public: - explicit BodySurface(SPHBody &sph_body); + explicit BodySurface(SPHBody &sph_body, Shape &body_shape); virtual ~BodySurface(){}; protected: + Shape &body_shape_; Real particle_spacing_min_; void tagNearSurface(size_t particle_index); }; @@ -165,10 +166,11 @@ class BodySurface : public BodyPartByParticle class BodySurfaceLayer : public BodyPartByParticle { public: - explicit BodySurfaceLayer(SPHBody &sph_body, Real layer_thickness = 3.0); + explicit BodySurfaceLayer(SPHBody &sph_body, Shape &body_shape, Real layer_thickness = 3.0); virtual ~BodySurfaceLayer(){}; private: + Shape &body_shape_; Real thickness_threshold_; void tagSurfaceLayer(size_t particle_index); }; @@ -206,10 +208,7 @@ class NearShapeSurface : public BodyPartByCell UniquePtrKeeper level_set_shape_keeper_; public: - NearShapeSurface(RealBody &real_body, SharedPtr shape_ptr); - NearShapeSurface(RealBody &real_body, LevelSetShape &level_set_shape); - explicit NearShapeSurface(RealBody &real_body); - NearShapeSurface(RealBody &real_body, const std::string &sub_shape_name); + NearShapeSurface(RealBody &real_body, Shape &shape); virtual ~NearShapeSurface(){}; LevelSetShape &getLevelSetShape() { return level_set_shape_; }; diff --git a/src/shared/particle_dynamics/general_dynamics/boundary_condition/eulerian_ghost_boundary.cpp b/src/shared/particle_dynamics/general_dynamics/boundary_condition/eulerian_ghost_boundary.cpp index 6b9688455a..96ae30b989 100644 --- a/src/shared/particle_dynamics/general_dynamics/boundary_condition/eulerian_ghost_boundary.cpp +++ b/src/shared/particle_dynamics/general_dynamics/boundary_condition/eulerian_ghost_boundary.cpp @@ -4,9 +4,11 @@ namespace SPH { //=================================================================================================// -GhostCreationInESPH::GhostCreationInESPH(BaseInnerRelation &inner_relation, Ghost &ghost_boundary) +GhostCreationInESPH::GhostCreationInESPH(BaseInnerRelation &inner_relation, + Shape &body_shape, Ghost &ghost_boundary) : LocalDynamics(inner_relation.getSPHBody()), DataDelegateInner(inner_relation), - ghost_boundary_(ghost_boundary), get_inner_neighbor_(&inner_relation.getSPHBody()), + body_shape_(body_shape), ghost_boundary_(ghost_boundary), + get_inner_neighbor_(&inner_relation.getSPHBody()), indicator_(particles_->getVariableDataByName("Indicator")), Vol_(particles_->getVariableDataByName("VolumetricMeasure")), pos_(particles_->getVariableDataByName("Position")), @@ -34,7 +36,7 @@ void GhostCreationInESPH::ghostGenerationAndAddToConfiguration() } Real ghost_particle_dW_ijV_j = -gradient_summation.norm(); Vecd ghost_particle_eij = -gradient_summation / ghost_particle_dW_ijV_j; - Real distance_to_ghost = fabs(sph_body_.getInitialShape().findSignedDistance(pos_[index_i])); + Real distance_to_ghost = fabs(body_shape_.findSignedDistance(pos_[index_i])); Vecd displacement_to_ghost = distance_to_ghost * ghost_particle_eij; Vecd ghost_position = pos_[index_i] - displacement_to_ghost; mutex_create_ghost_particle_.lock(); diff --git a/src/shared/particle_dynamics/general_dynamics/boundary_condition/eulerian_ghost_boundary.h b/src/shared/particle_dynamics/general_dynamics/boundary_condition/eulerian_ghost_boundary.h index 0114c8c8e0..cdfdfd2925 100644 --- a/src/shared/particle_dynamics/general_dynamics/boundary_condition/eulerian_ghost_boundary.h +++ b/src/shared/particle_dynamics/general_dynamics/boundary_condition/eulerian_ghost_boundary.h @@ -47,12 +47,14 @@ struct RealAndGhostParticleData class GhostCreationInESPH : public LocalDynamics, public DataDelegateInner { public: - explicit GhostCreationInESPH(BaseInnerRelation &inner_relation, Ghost &ghost_boundary); + explicit GhostCreationInESPH(BaseInnerRelation &inner_relation, Shape &body_shape, Ghost &ghost_boundary); virtual ~GhostCreationInESPH(){}; std::vector real_and_ghost_particle_data_; void ghostGenerationAndAddToConfiguration(); + Shape &getBodyShape() { return body_shape_; }; protected: + Shape &body_shape_; Ghost &ghost_boundary_; std::mutex mutex_create_ghost_particle_; /**< mutex exclusion for memory conflict */ NeighborBuilderInnerInFVM get_inner_neighbor_; diff --git a/src/shared/particle_dynamics/general_dynamics/general_geometric.cpp b/src/shared/particle_dynamics/general_dynamics/general_geometric.cpp index 289a920936..29adb54543 100644 --- a/src/shared/particle_dynamics/general_dynamics/general_geometric.cpp +++ b/src/shared/particle_dynamics/general_dynamics/general_geometric.cpp @@ -4,9 +4,8 @@ namespace SPH { //=============================================================================================// -NormalDirectionFromBodyShape::NormalDirectionFromBodyShape(SPHBody &sph_body) - : LocalDynamics(sph_body), - initial_shape_(sph_body.getInitialShape()), +NormalDirectionFromBodyShape::NormalDirectionFromBodyShape(SPHBody &sph_body, Shape &shape) + : LocalDynamics(sph_body), shape_(shape), pos_(particles_->getVariableDataByName("Position")), n_(particles_->registerStateVariable("NormalDirection")), n0_(particles_->registerStateVariableFrom("InitialNormalDirection", "NormalDirection")), @@ -15,19 +14,17 @@ NormalDirectionFromBodyShape::NormalDirectionFromBodyShape(SPHBody &sph_body) //=============================================================================================// void NormalDirectionFromBodyShape::update(size_t index_i, Real dt) { - Vecd normal_direction = initial_shape_.findNormalDirection(pos_[index_i]); + Vecd normal_direction = shape_.findNormalDirection(pos_[index_i]); n_[index_i] = normal_direction; n0_[index_i] = normal_direction; - Real signed_distance = initial_shape_.findSignedDistance(pos_[index_i]); + Real signed_distance = shape_.findSignedDistance(pos_[index_i]); phi_[index_i] = signed_distance; phi0_[index_i] = signed_distance; } //=============================================================================================// NormalDirectionFromSubShapeAndOp:: - NormalDirectionFromSubShapeAndOp(SPHBody &sph_body, const std::string &shape_name) - : LocalDynamics(sph_body), - shape_and_op_(DynamicCast(this, sph_body.getInitialShape()).getSubShapeAndOpByName(shape_name)), - shape_(shape_and_op_->first), + NormalDirectionFromSubShapeAndOp(SPHBody &sph_body, SubShapeAndOp *shape_and_op) + : LocalDynamics(sph_body), shape_and_op_(shape_and_op), shape_(shape_and_op_->first), switch_sign_(shape_and_op_->second == ShapeBooleanOps::add ? 1.0 : -1.0), pos_(particles_->getVariableDataByName("Position")), n_(particles_->registerStateVariable("NormalDirection")), @@ -45,10 +42,10 @@ void NormalDirectionFromSubShapeAndOp::update(size_t index_i, Real dt) phi0_[index_i] = signed_distance; } //=============================================================================================// -NormalDirectionFromParticles::NormalDirectionFromParticles(BaseInnerRelation &inner_relation) +NormalDirectionFromParticles:: + NormalDirectionFromParticles(BaseInnerRelation &inner_relation, Shape &shape) : LocalDynamics(inner_relation.getSPHBody()), DataDelegateInner(inner_relation), - initial_shape_(sph_body_.getInitialShape()), - pos_(particles_->getVariableDataByName("Position")), + shape_(shape), pos_(particles_->getVariableDataByName("Position")), n_(particles_->registerStateVariable("NormalDirection")), n0_(particles_->registerStateVariableFrom("InitialNormalDirection", "NormalDirection")), phi_(particles_->registerStateVariable("SignedDistance")), @@ -67,7 +64,7 @@ void NormalDirectionFromParticles::interaction(size_t index_i, Real dt) normal_direction = normal_direction / (normal_direction.norm() + TinyReal); n_[index_i] = normal_direction; n0_[index_i] = normal_direction; - Real signed_distance = initial_shape_.findSignedDistance(pos_[index_i]); + Real signed_distance = shape_.findSignedDistance(pos_[index_i]); phi_[index_i] = signed_distance; phi0_[index_i] = signed_distance; } diff --git a/src/shared/particle_dynamics/general_dynamics/general_geometric.h b/src/shared/particle_dynamics/general_dynamics/general_geometric.h index 90e9db266b..443390941f 100644 --- a/src/shared/particle_dynamics/general_dynamics/general_geometric.h +++ b/src/shared/particle_dynamics/general_dynamics/general_geometric.h @@ -40,12 +40,12 @@ namespace SPH class NormalDirectionFromBodyShape : public LocalDynamics { public: - explicit NormalDirectionFromBodyShape(SPHBody &sph_body); + explicit NormalDirectionFromBodyShape(SPHBody &sph_body, Shape &shape); virtual ~NormalDirectionFromBodyShape(){}; void update(size_t index_i, Real dt = 0.0); protected: - Shape &initial_shape_; + Shape &shape_; Vecd *pos_, *n_, *n0_; Real *phi_, *phi0_; }; @@ -57,7 +57,7 @@ class NormalDirectionFromBodyShape : public LocalDynamics class NormalDirectionFromSubShapeAndOp : public LocalDynamics { public: - explicit NormalDirectionFromSubShapeAndOp(SPHBody &sph_body, const std::string &shape_name); + explicit NormalDirectionFromSubShapeAndOp(SPHBody &sph_body, SubShapeAndOp *shape_and_op); virtual ~NormalDirectionFromSubShapeAndOp(){}; void update(size_t index_i, Real dt = 0.0); @@ -72,12 +72,12 @@ class NormalDirectionFromSubShapeAndOp : public LocalDynamics class NormalDirectionFromParticles : public LocalDynamics, public DataDelegateInner { public: - explicit NormalDirectionFromParticles(BaseInnerRelation &inner_relation); + explicit NormalDirectionFromParticles(BaseInnerRelation &inner_relation, Shape &shape); virtual ~NormalDirectionFromParticles(){}; void interaction(size_t index_i, Real dt = 0.0); protected: - Shape &initial_shape_; + Shape &shape_; Vecd *pos_, *n_, *n0_; Real *phi_, *phi0_, *Vol_; }; diff --git a/src/shared/particle_dynamics/relax_dynamics/relax_stepping.cpp b/src/shared/particle_dynamics/relax_dynamics/relax_stepping.cpp index a0c8dd89c5..a19256d943 100644 --- a/src/shared/particle_dynamics/relax_dynamics/relax_stepping.cpp +++ b/src/shared/particle_dynamics/relax_dynamics/relax_stepping.cpp @@ -5,15 +5,9 @@ namespace SPH namespace relax_dynamics { //=================================================================================================// -RelaxationResidue>::RelaxationResidue(BaseInnerRelation &inner_relation) +RelaxationResidue>::RelaxationResidue(BaseInnerRelation &inner_relation, Shape &relax_shape) : RelaxationResidue(inner_relation), - relax_shape_(sph_body_.getInitialShape()){}; -//=================================================================================================// -RelaxationResidue>:: - RelaxationResidue(BaseInnerRelation &inner_relation, const std::string &sub_shape_name) - : RelaxationResidue(inner_relation), - relax_shape_(*DynamicCast(this, sph_body_.getInitialShape()) - .getSubShapeByName(sub_shape_name)) {} + relax_shape_(relax_shape){}; //=================================================================================================// void RelaxationResidue>::interaction(size_t index_i, Real dt) { @@ -86,9 +80,6 @@ UpdateSmoothingLengthRatioByShape:: particle_adaptation_(DynamicCast(this, sph_body.sph_adaptation_)), reference_spacing_(particle_adaptation_->ReferenceSpacing()) {} //=================================================================================================// -UpdateSmoothingLengthRatioByShape::UpdateSmoothingLengthRatioByShape(SPHBody &sph_body) - : UpdateSmoothingLengthRatioByShape(sph_body, sph_body.getInitialShape()) {} -//=================================================================================================// void UpdateSmoothingLengthRatioByShape::update(size_t index_i, Real dt_square) { Real local_spacing = particle_adaptation_->getLocalSpacing(adaptation_shape_, pos_[index_i]); diff --git a/src/shared/particle_dynamics/relax_dynamics/relax_stepping.h b/src/shared/particle_dynamics/relax_dynamics/relax_stepping.h index 4fe855d92e..85fa504bbe 100644 --- a/src/shared/particle_dynamics/relax_dynamics/relax_stepping.h +++ b/src/shared/particle_dynamics/relax_dynamics/relax_stepping.h @@ -63,8 +63,7 @@ class RelaxationResidue> : public RelaxationResidue { public: - explicit RelaxationResidue(BaseInnerRelation &inner_relation); - RelaxationResidue(BaseInnerRelation &inner_relation, const std::string &sub_shape_name); + explicit RelaxationResidue(BaseInnerRelation &inner_relation, Shape &relax_shape); virtual ~RelaxationResidue(){}; Shape &getRelaxShape() { return relax_shape_; }; void interaction(size_t index_i, Real dt = 0.0); @@ -154,7 +153,6 @@ class UpdateSmoothingLengthRatioByShape : public LocalDynamics public: UpdateSmoothingLengthRatioByShape(SPHBody &sph_body, Shape &adaptation_shape); - explicit UpdateSmoothingLengthRatioByShape(SPHBody &sph_body); virtual ~UpdateSmoothingLengthRatioByShape(){}; void update(size_t index_i, Real dt = 0.0); }; diff --git a/src/shared/particle_dynamics/relax_dynamics/relax_thick_shell.cpp b/src/shared/particle_dynamics/relax_dynamics/relax_thick_shell.cpp index 6892467244..2d73e78c2f 100644 --- a/src/shared/particle_dynamics/relax_dynamics/relax_thick_shell.cpp +++ b/src/shared/particle_dynamics/relax_dynamics/relax_thick_shell.cpp @@ -10,7 +10,7 @@ ShellMidSurfaceBounding::ShellMidSurfaceBounding(NearShapeSurface &body_part) pos_(particles_->getVariableDataByName("Position")), constrained_distance_(0.5 * sph_body_.sph_adaptation_->MinimumSpacing()), particle_spacing_ref_(sph_body_.sph_adaptation_->MinimumSpacing()), - level_set_shape_(DynamicCast(this, &sph_body_.getInitialShape())) {} + level_set_shape_(&body_part.getLevelSetShape()) {} //=================================================================================================// void ShellMidSurfaceBounding::update(size_t index_i, Real dt) { @@ -21,12 +21,12 @@ void ShellMidSurfaceBounding::update(size_t index_i, Real dt) } //=================================================================================================// ShellNormalDirectionPrediction:: - ShellNormalDirectionPrediction(BaseInnerRelation &inner_relation, + ShellNormalDirectionPrediction(BaseInnerRelation &inner_relation, Shape &shape, Real thickness, Real consistency_criterion) : BaseDynamics(), convergence_criterion_(cos(0.01 * Pi)), consistency_criterion_(consistency_criterion), - normal_prediction_(inner_relation.getSPHBody(), thickness), + normal_prediction_(inner_relation.getSPHBody(), shape, thickness), normal_prediction_convergence_check_(inner_relation.getSPHBody(), convergence_criterion_), consistency_correction_(inner_relation, consistency_criterion_), consistency_updated_check_(inner_relation.getSPHBody()), @@ -79,9 +79,10 @@ void ShellNormalDirectionPrediction::correctNormalDirection() std::cout << "\n Information: normal consistency updated after '" << ite_updated << "' steps." << std::endl; } //=================================================================================================// -ShellNormalDirectionPrediction::NormalPrediction::NormalPrediction(SPHBody &sph_body, Real thickness) +ShellNormalDirectionPrediction::NormalPrediction:: + NormalPrediction(SPHBody &sph_body, Shape &shape, Real thickness) : LocalDynamics(sph_body), thickness_(thickness), - level_set_shape_(DynamicCast(this, &sph_body.getInitialShape())), + level_set_shape_(DynamicCast(this, &shape)), pos_(particles_->getVariableDataByName("Position")), n_(particles_->getVariableDataByName("NormalDirection")), n_temp_(particles_->registerStateVariable( @@ -168,11 +169,11 @@ void ShellNormalDirectionPrediction::SmoothingNormal::update(size_t index_i, Rea smoothed_[index_i] /= temp_[index_i].norm() + TinyReal; } //=================================================================================================// -ShellRelaxationStep::ShellRelaxationStep(BaseInnerRelation &inner_relation) +ShellRelaxationStep::ShellRelaxationStep(BaseInnerRelation &inner_relation, Shape &relax_shape) : BaseDynamics(), real_body_(DynamicCast(this, inner_relation.getSPHBody())), - inner_relation_(inner_relation), near_shape_surface_(real_body_), - relaxation_residue_(inner_relation), + inner_relation_(inner_relation), near_shape_surface_(real_body_, relax_shape), + relaxation_residue_(inner_relation, relax_shape), relaxation_scaling_(real_body_), position_relaxation_(real_body_), mid_surface_bounding_(near_shape_surface_) {} //=================================================================================================// diff --git a/src/shared/particle_dynamics/relax_dynamics/relax_thick_shell.h b/src/shared/particle_dynamics/relax_dynamics/relax_thick_shell.h index 59f551b200..d8b7905d6f 100644 --- a/src/shared/particle_dynamics/relax_dynamics/relax_thick_shell.h +++ b/src/shared/particle_dynamics/relax_dynamics/relax_thick_shell.h @@ -75,7 +75,7 @@ class ShellNormalDirectionPrediction : public BaseDynamics void correctNormalDirection(); public: - explicit ShellNormalDirectionPrediction(BaseInnerRelation &inner_relation, + explicit ShellNormalDirectionPrediction(BaseInnerRelation &inner_relation, Shape &shape, Real thickness, Real consistency_criterion = cos(Pi / 20.0)); virtual ~ShellNormalDirectionPrediction(){}; virtual void exec(Real dt = 0.0) override; @@ -88,7 +88,7 @@ class ShellNormalDirectionPrediction : public BaseDynamics Vecd *pos_, *n_, *n_temp_; public: - NormalPrediction(SPHBody &sph_body, Real thickness); + NormalPrediction(SPHBody &sph_body, Shape &shape, Real thickness); virtual ~NormalPrediction(){}; void update(size_t index_i, Real dt = 0.0); }; @@ -157,7 +157,7 @@ class ShellNormalDirectionPrediction : public BaseDynamics class ShellRelaxationStep : public BaseDynamics { public: - explicit ShellRelaxationStep(BaseInnerRelation &inner_relation); + explicit ShellRelaxationStep(BaseInnerRelation &inner_relation, Shape &relax_shape); virtual ~ShellRelaxationStep(){}; virtual void exec(Real dt = 0.0) override; SimpleDynamics &MidSurfaceBounding() { return mid_surface_bounding_; }; diff --git a/src/shared/shared_ck/particle_dynamics/general_dynamics/geometric_dynamics.cpp b/src/shared/shared_ck/particle_dynamics/general_dynamics/geometric_dynamics.cpp index 8d9d6366b3..fb432a3edb 100644 --- a/src/shared/shared_ck/particle_dynamics/general_dynamics/geometric_dynamics.cpp +++ b/src/shared/shared_ck/particle_dynamics/general_dynamics/geometric_dynamics.cpp @@ -3,9 +3,8 @@ namespace SPH { //=================================================================================================// -NormalFromBodyShapeCK::NormalFromBodyShapeCK(SPHBody &sph_body) - : LocalDynamics(sph_body), - initial_shape_(&sph_body.getInitialShape()), +NormalFromBodyShapeCK::NormalFromBodyShapeCK(SPHBody &sph_body, Shape &shape) + : LocalDynamics(sph_body), shape_(&shape), dv_pos_(particles_->getVariableByName("Position")), dv_n_(particles_->registerStateVariableOnly("NormalDirection")), dv_n0_(particles_->registerStateVariableOnly("InitialNormalDirection", dv_n_)), @@ -14,10 +13,10 @@ NormalFromBodyShapeCK::NormalFromBodyShapeCK(SPHBody &sph_body) //=============================================================================================// void NormalFromBodyShapeCK::UpdateKernel::update(size_t index_i, Real dt) { - Vecd normal_direction = initial_shape_->findNormalDirection(pos_[index_i]); + Vecd normal_direction = shape_->findNormalDirection(pos_[index_i]); n_[index_i] = normal_direction; n0_[index_i] = normal_direction; - Real signed_distance = initial_shape_->findSignedDistance(pos_[index_i]); + Real signed_distance = shape_->findSignedDistance(pos_[index_i]); phi_[index_i] = signed_distance; phi0_[index_i] = signed_distance; } diff --git a/src/shared/shared_ck/particle_dynamics/general_dynamics/geometric_dynamics.h b/src/shared/shared_ck/particle_dynamics/general_dynamics/geometric_dynamics.h index 3c8c4a4360..64e3261c57 100644 --- a/src/shared/shared_ck/particle_dynamics/general_dynamics/geometric_dynamics.h +++ b/src/shared/shared_ck/particle_dynamics/general_dynamics/geometric_dynamics.h @@ -36,7 +36,7 @@ namespace SPH class NormalFromBodyShapeCK : public LocalDynamics { public: - explicit NormalFromBodyShapeCK(SPHBody &sph_body); + explicit NormalFromBodyShapeCK(SPHBody &sph_body, Shape &shape); virtual ~NormalFromBodyShapeCK(){}; class UpdateKernel @@ -48,13 +48,13 @@ class NormalFromBodyShapeCK : public LocalDynamics void update(size_t index_i, Real dt = 0.0); protected: - Shape *initial_shape_; + Shape *shape_; Vecd *pos_, *n_, *n0_; Real *phi_, *phi0_; }; protected: - Shape *initial_shape_; + Shape *shape_; DiscreteVariable *dv_pos_, *dv_n_, *dv_n0_; DiscreteVariable *dv_phi_, *dv_phi0_; }; diff --git a/tests/2d_examples/test_2d_eulerian_supersonic_flow_new_BC/2d_eulerian_supersonic_flow_around_cylinder.h b/tests/2d_examples/test_2d_eulerian_supersonic_flow_new_BC/2d_eulerian_supersonic_flow_around_cylinder.h index 3e2f9c8c0e..c5e7832058 100644 --- a/tests/2d_examples/test_2d_eulerian_supersonic_flow_new_BC/2d_eulerian_supersonic_flow_around_cylinder.h +++ b/tests/2d_examples/test_2d_eulerian_supersonic_flow_new_BC/2d_eulerian_supersonic_flow_around_cylinder.h @@ -28,7 +28,7 @@ Real Mach_number = 2.0; //---------------------------------------------------------------------- // Define geometries and body shapes //---------------------------------------------------------------------- -std::vector Creatrightsqureshape() +std::vector CreatRightSquareShape() { // geometry std::vector right_square_shape; @@ -46,7 +46,7 @@ class FluidBlock : public MultiPolygonShape { multi_polygon_.addACircle(calculation_circle_center, calculation_circle_radius, 100, ShapeBooleanOps::add); multi_polygon_.addACircle(insert_circle_center, insert_circle_radius, 100, ShapeBooleanOps::sub); - multi_polygon_.addAPolygon(Creatrightsqureshape(), ShapeBooleanOps::sub); + multi_polygon_.addAPolygon(CreatRightSquareShape(), ShapeBooleanOps::sub); } }; //---------------------------------------------------------------------- @@ -82,6 +82,7 @@ class SupersonicFlowBoundaryConditionSetup : public GhostBoundaryConditionSetupI public: SupersonicFlowBoundaryConditionSetup(BaseInnerRelation &inner_relation, GhostCreationInESPH &ghost_creation) : GhostBoundaryConditionSetupInESPH(inner_relation, ghost_creation), + body_shape_(ghost_creation.getBodyShape()), p_(particles_->getVariableDataByName("Pressure")), E_(particles_->getVariableDataByName("TotalEnergy")) { @@ -108,7 +109,7 @@ class SupersonicFlowBoundaryConditionSetup : public GhostBoundaryConditionSetupI } }; - // For inner boundaries, we set the refective boundary conditions as boundary_type 3. + // For inner boundaries, we set the reflective boundary conditions as boundary_type 3. void applyReflectiveWallBoundary(size_t ghost_index, size_t index_i, Vecd e_ij) override { rho_[ghost_index] = rho_[index_i]; @@ -120,10 +121,10 @@ class SupersonicFlowBoundaryConditionSetup : public GhostBoundaryConditionSetupI E_[ghost_index] = rho_e * Vol_[ghost_index] + 0.5 * mass_[ghost_index] * vel_[ghost_index].squaredNorm(); } - // For outer boundaries, we set the non-refective far-field boundary conditions as boundary_type 9. + // For outer boundaries, we set the non-reflective far-field boundary conditions as boundary_type 9. void applyFarFieldBoundary(size_t ghost_index, size_t index_i) override { - Vecd normal_direction_index_i = sph_body_.getInitialShape().findNormalDirection(pos_[index_i]); + Vecd normal_direction_index_i = body_shape_.findNormalDirection(pos_[index_i]); Vecd velocity_farfield = Vecd::Zero(); Real sound_speed = sqrt(p_farfield * heat_capacity_ratio / rho_farfield); velocity_farfield[0] = Mach_number * sound_speed; @@ -229,5 +230,6 @@ class SupersonicFlowBoundaryConditionSetup : public GhostBoundaryConditionSetupI } protected: + Shape &body_shape_; Real *p_, *E_; }; diff --git a/tests/3d_examples/test_3d_heart_electromechanics/excitation-contraction.cpp b/tests/3d_examples/test_3d_heart_electromechanics/excitation-contraction.cpp index 089a52cc9d..f90cedc607 100644 --- a/tests/3d_examples/test_3d_heart_electromechanics/excitation-contraction.cpp +++ b/tests/3d_examples/test_3d_heart_electromechanics/excitation-contraction.cpp @@ -70,15 +70,15 @@ using FiberDirectionDiffusionRelaxation = class DiffusionBCs : public BaseLocalDynamics { public: - explicit DiffusionBCs(BodyPartByParticle &body_part, const std::string &species_name) - : BaseLocalDynamics(body_part), + explicit DiffusionBCs(BodyPartByParticle &body_part, Shape &body_shape, const std::string &species_name) + : BaseLocalDynamics(body_part), body_shape_(body_shape), pos_(particles_->getVariableDataByName("Position")), phi_(particles_->registerStateVariable(species_name)){}; virtual ~DiffusionBCs(){}; void update(size_t index_i, Real dt = 0.0) { - Vecd displacement = sph_body_.getInitialShape().findNormalDirection(pos_[index_i]); + Vecd displacement = body_shape_.findNormalDirection(pos_[index_i]); Vecd face_norm = displacement / (displacement.norm() + 1.0e-15); Vecd center_norm = pos_[index_i] / (pos_[index_i].norm() + 1.0e-15); @@ -95,6 +95,7 @@ class DiffusionBCs : public BaseLocalDynamics }; protected: + Shape &body_shape_; Vecd *pos_; Real *phi_; }; @@ -102,6 +103,7 @@ class DiffusionBCs : public BaseLocalDynamics class ComputeFiberAndSheetDirections : public LocalDynamics { protected: + Shape &body_shape_; LocallyOrthotropicMuscle &muscle_material_; Vecd *pos_; Real *phi_; @@ -109,8 +111,8 @@ class ComputeFiberAndSheetDirections : public LocalDynamics Vecd center_line_vector_; // parallel to the ventricular centerline and pointing apex-to-base public: - explicit ComputeFiberAndSheetDirections(SPHBody &sph_body, const std::string &species_name) - : LocalDynamics(sph_body), + explicit ComputeFiberAndSheetDirections(SPHBody &sph_body, Shape &body_shape, const std::string &species_name) + : LocalDynamics(sph_body), body_shape_(body_shape), muscle_material_(DynamicCast(this, sph_body_.getBaseMaterial())), pos_(particles_->getVariableDataByName("Position")), phi_(particles_->registerStateVariable(species_name)) @@ -128,7 +130,7 @@ class ComputeFiberAndSheetDirections : public LocalDynamics * Present doi.org/10.1016/j.cma.2016.05.031 */ /** Probe the face norm from level set field. */ - Vecd displacement = sph_body_.getInitialShape().findNormalDirection(pos_[index_i]); + Vecd displacement = body_shape_.findNormalDirection(pos_[index_i]); Vecd face_norm = displacement / (displacement.norm() + 1.0e-15); Vecd center_norm = pos_[index_i] / (pos_[index_i].norm() + 1.0e-15); if (face_norm.dot(center_norm) <= 0.0) @@ -259,15 +261,17 @@ int main(int ac, char *av[]) /** check whether run particle relaxation for body fitted particle distribution. */ if (sph_system.RunParticleRelaxation() && !sph_system.ReloadParticles()) { - SolidBody herat_model(sph_system, makeShared("HeartModel")); - herat_model.defineBodyLevelSetShape()->correctLevelSetSign()->writeLevelSet(sph_system); + Heart heart_shape("HeartModel"); + SolidBody herat_model(sph_system, heart_shape.getName()); + LevelSetShape level_set_shape(herat_model, heart_shape, 1.0); + level_set_shape.correctLevelSetSign()->writeLevelSet(sph_system); herat_model.defineMaterial(rho0_s, bulk_modulus, fiber_direction, sheet_direction, a0, b0); - herat_model.generateParticles(); + herat_model.generateParticles(level_set_shape); /** topology */ InnerRelation herat_model_inner(herat_model); using namespace relax_dynamics; SimpleDynamics random_particles(herat_model); - RelaxationStepInner relaxation_step_inner(herat_model_inner); + RelaxationStepInner relaxation_step_inner(herat_model_inner, heart_shape); //---------------------------------------------------------------------- // Relaxation output //---------------------------------------------------------------------- @@ -302,9 +306,9 @@ int main(int ac, char *av[]) IsotropicDiffusion diffusion("Phi", "Phi", diffusion_coeff); GetDiffusionTimeStepSize get_time_step_size(herat_model, diffusion); FiberDirectionDiffusionRelaxation diffusion_relaxation(herat_model_inner, &diffusion); - SimpleDynamics compute_fiber_sheet(herat_model, "Phi"); - BodySurface surface_part(herat_model); - SimpleDynamics impose_diffusion_bc(surface_part, "Phi"); + SimpleDynamics compute_fiber_sheet(herat_model, heart_shape, "Phi"); + BodySurface surface_part(herat_model, heart_shape); + SimpleDynamics impose_diffusion_bc(surface_part, heart_shape, "Phi"); impose_diffusion_bc.exec(); write_herat_model_state_to_vtp.addToWrite(herat_model, "Phi"); write_herat_model_state_to_vtp.writeToFile(ite); @@ -333,20 +337,22 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // SPH simulation section //---------------------------------------------------------------------- - SolidBody mechanics_heart(sph_system, makeShared("MechanicalHeart")); + Heart mechanic_heart_shape("MechanicalHeart"); + SolidBody mechanics_heart(sph_system, mechanic_heart_shape.getName()); mechanics_heart.defineMaterial>(rho0_s, bulk_modulus, fiber_direction, sheet_direction, a0, b0); (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? mechanics_heart.generateParticles("HeartModel") - : mechanics_heart.generateParticles(); + : mechanics_heart.generateParticles(mechanic_heart_shape); - SolidBody physiology_heart(sph_system, makeShared("PhysiologyHeart")); + Heart physiology_heart_shape("PhysiologyHeart"); + SolidBody physiology_heart(sph_system, physiology_heart_shape.getName()); AlievPanfilowModel aliev_panfilow_model(k_a, c_m, k, a, b, mu_1, mu_2, epsilon); MonoFieldElectroPhysiology *mono_field_electro_physiology = physiology_heart.defineMaterial>( aliev_panfilow_model, diffusion_coeff, bias_coeff, fiber_direction); (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? physiology_heart.generateParticles("HeartModel") - : physiology_heart.generateParticles(); + : physiology_heart.generateParticles(physiology_heart_shape); //---------------------------------------------------------------------- // SPH Observation section diff --git a/tests/3d_examples/test_3d_heart_volume_change/excitation_contraction.h b/tests/3d_examples/test_3d_heart_volume_change/excitation_contraction.h index 2db5a340e8..12c749ac5e 100644 --- a/tests/3d_examples/test_3d_heart_volume_change/excitation_contraction.h +++ b/tests/3d_examples/test_3d_heart_volume_change/excitation_contraction.h @@ -73,15 +73,15 @@ using FiberDirectionDiffusionRelaxation = class DiffusionBCs : public BaseLocalDynamics { public: - explicit DiffusionBCs(BodyPartByParticle &body_part, const std::string &species_name) - : BaseLocalDynamics(body_part), + explicit DiffusionBCs(BodyPartByParticle &body_part, Shape &body_shape, const std::string &species_name) + : BaseLocalDynamics(body_part), body_shape_(body_shape), pos_(particles_->getVariableDataByName("Position")), phi_(particles_->registerStateVariable(species_name)){}; virtual ~DiffusionBCs(){}; void update(size_t index_i, Real dt = 0.0) { - Vecd displacement = sph_body_.getInitialShape().findNormalDirection(pos_[index_i]); + Vecd displacement = body_shape_.findNormalDirection(pos_[index_i]); Vecd face_norm = displacement / (displacement.norm() + 1.0e-15); Vecd center_norm = pos_[index_i] / (pos_[index_i].norm() + 1.0e-15); @@ -99,6 +99,7 @@ class DiffusionBCs : public BaseLocalDynamics }; protected: + Shape &body_shape_; Vecd *pos_; Real *phi_; }; @@ -106,6 +107,7 @@ class DiffusionBCs : public BaseLocalDynamics class ComputeFiberAndSheetDirections : public LocalDynamics { protected: + Shape &body_shape_; LocallyOrthotropicMuscle &muscle_material_; Vecd *pos_; Real *phi_; @@ -113,8 +115,8 @@ class ComputeFiberAndSheetDirections : public LocalDynamics Vecd center_line_vector_; // parallel to the ventricular centerline and pointing apex-to-base public: - explicit ComputeFiberAndSheetDirections(SPHBody &sph_body, const std::string &species_name) - : LocalDynamics(sph_body), + explicit ComputeFiberAndSheetDirections(SPHBody &sph_body, Shape &body_shape, const std::string &species_name) + : LocalDynamics(sph_body), body_shape_(body_shape), muscle_material_(DynamicCast(this, sph_body_.getBaseMaterial())), pos_(particles_->getVariableDataByName("Position")), phi_(particles_->registerStateVariable(species_name)) @@ -132,7 +134,7 @@ class ComputeFiberAndSheetDirections : public LocalDynamics * Present doi.org/10.1016/j.cma.2016.05.031 */ /** Probe the face norm from Level set field. */ - Vecd displacement = sph_body_.getInitialShape().findNormalDirection(pos_[index_i]); + Vecd displacement = body_shape_.findNormalDirection(pos_[index_i]); Vecd face_norm = displacement / (displacement.norm() + 1.0e-15); Vecd center_norm = pos_[index_i] / (pos_[index_i].norm() + 1.0e-15); if (face_norm.dot(center_norm) <= 0.0) diff --git a/tests/3d_examples/test_3d_pkj_lv_electrocontraction/pkj_lv_electrocontraction.h b/tests/3d_examples/test_3d_pkj_lv_electrocontraction/pkj_lv_electrocontraction.h index d0c0b07dc0..f9c8a05f2b 100644 --- a/tests/3d_examples/test_3d_pkj_lv_electrocontraction/pkj_lv_electrocontraction.h +++ b/tests/3d_examples/test_3d_pkj_lv_electrocontraction/pkj_lv_electrocontraction.h @@ -103,15 +103,15 @@ using FiberDirectionDiffusionRelaxation = class DiffusionBCs : public BaseLocalDynamics { public: - explicit DiffusionBCs(BodyPartByParticle &body_part, const std::string &species_name) - : BaseLocalDynamics(body_part), + explicit DiffusionBCs(BodyPartByParticle &body_part, Shape &body_shape, const std::string &species_name) + : BaseLocalDynamics(body_part), body_shape_(body_shape), pos_(particles_->getVariableDataByName("Position")), phi_(particles_->registerStateVariable(species_name)){}; virtual ~DiffusionBCs(){}; void update(size_t index_i, Real dt = 0.0) { - Vecd displacement = sph_body_.getInitialShape().findNormalDirection(pos_[index_i]); + Vecd displacement = body_shape_.findNormalDirection(pos_[index_i]); Vecd face_norm = displacement / (displacement.norm() + 1.0e-15); Vecd center_norm = pos_[index_i] / (pos_[index_i].norm() + 1.0e-15); @@ -129,6 +129,7 @@ class DiffusionBCs : public BaseLocalDynamics }; protected: + Shape &body_shape_; Vecd *pos_; Real *phi_; }; @@ -137,6 +138,7 @@ class DiffusionBCs : public BaseLocalDynamics class ComputeFiberAndSheetDirections : public LocalDynamics { protected: + Shape &body_shape_; LocallyOrthotropicMuscle &muscle_material_; Vecd *pos_; Real *phi_; @@ -144,8 +146,8 @@ class ComputeFiberAndSheetDirections : public LocalDynamics Vecd center_line_vector_; // parallel to the ventricular centerline and pointing apex-to-base public: - explicit ComputeFiberAndSheetDirections(SPHBody &sph_body, const std::string &species_name) - : LocalDynamics(sph_body), + explicit ComputeFiberAndSheetDirections(SPHBody &sph_body, Shape &body_shape, const std::string &species_name) + : LocalDynamics(sph_body), body_shape_(body_shape), muscle_material_(DynamicCast(this, sph_body_.getBaseMaterial())), pos_(particles_->getVariableDataByName("Position")), phi_(particles_->registerStateVariable(species_name)) @@ -163,7 +165,7 @@ class ComputeFiberAndSheetDirections : public LocalDynamics * Present doi.org/10.1016/j.cma.2016.05.031 */ /** Probe the face norm from Level set field. */ - Vecd displacement = sph_body_.getInitialShape().findNormalDirection(pos_[index_i]); + Vecd displacement = body_shape_.findNormalDirection(pos_[index_i]); Vecd face_norm = displacement / (displacement.norm() + 1.0e-15); Vecd center_norm = pos_[index_i] / (pos_[index_i].norm() + 1.0e-15); if (face_norm.dot(center_norm) <= 0.0) From b44ccf0961d3f7f78c75b5ea227e7ee5e04b244c Mon Sep 17 00:00:00 2001 From: Xiangyu Hu Date: Sat, 21 Sep 2024 17:25:43 +0000 Subject: [PATCH 03/13] to compile cases --- .../opencascade/relax_dynamics_surface.cpp | 5 +++-- .../opencascade/relax_dynamics_surface.h | 2 +- .../test_3d_aortic_valve/aortic_valve.cpp | 2 +- .../structural_simulation_class.cpp | 21 +++++++++++-------- .../structural_simulation_class.h | 5 ----- .../particle_generator_lattice_2d.cpp | 14 ++++++------- .../particle_generator_lattice_3d.cpp | 14 ++++++------- .../body_relations/contact_body_relation.cpp | 10 +++++---- .../body_relations/contact_body_relation.h | 12 ++++++----- .../body_relations/inner_body_relation.cpp | 4 ++-- .../body_relations/inner_body_relation.h | 10 ++++----- .../solid_dynamics/loading_dynamics.cpp | 12 +++++------ .../solid_dynamics/loading_dynamics.h | 6 +++--- 13 files changed, 60 insertions(+), 57 deletions(-) diff --git a/modules/opencascade/opencascade/relax_dynamics_surface.cpp b/modules/opencascade/opencascade/relax_dynamics_surface.cpp index a5ece1f9cb..a87965d6cf 100644 --- a/modules/opencascade/opencascade/relax_dynamics_surface.cpp +++ b/modules/opencascade/opencascade/relax_dynamics_surface.cpp @@ -21,9 +21,10 @@ void ShapeSurfaceConstraint::update(size_t index_i, Real dt) } //=================================================================================================// RelaxationStepInnerFirstHalf:: - RelaxationStepInnerFirstHalf(BaseInnerRelation &inner_relation) + RelaxationStepInnerFirstHalf(BaseInnerRelation &inner_relation, Shape &shape) : BaseDynamics(), real_body_(inner_relation.real_body_), - inner_relation_(inner_relation), relaxation_acceleration_inner_(inner_relation) {} + inner_relation_(inner_relation), + relaxation_acceleration_inner_(inner_relation, shape) {} //=================================================================================================// void RelaxationStepInnerFirstHalf::exec(Real dt) { diff --git a/modules/opencascade/opencascade/relax_dynamics_surface.h b/modules/opencascade/opencascade/relax_dynamics_surface.h index c3992fcb5e..23d7db4405 100644 --- a/modules/opencascade/opencascade/relax_dynamics_surface.h +++ b/modules/opencascade/opencascade/relax_dynamics_surface.h @@ -56,7 +56,7 @@ class ShapeSurfaceConstraint : public LocalDynamics class RelaxationStepInnerFirstHalf : public BaseDynamics { public: - explicit RelaxationStepInnerFirstHalf(BaseInnerRelation &inner_relation); + explicit RelaxationStepInnerFirstHalf(BaseInnerRelation &inner_relation, Shape &shape); virtual ~RelaxationStepInnerFirstHalf(){}; virtual void exec(Real dt = 0.0) override; diff --git a/modules/opencascade/tests/test_3d_aortic_valve/aortic_valve.cpp b/modules/opencascade/tests/test_3d_aortic_valve/aortic_valve.cpp index f8807af435..7ebd57e243 100644 --- a/modules/opencascade/tests/test_3d_aortic_valve/aortic_valve.cpp +++ b/modules/opencascade/tests/test_3d_aortic_valve/aortic_valve.cpp @@ -156,7 +156,7 @@ int main(int ac, char *av[]) // Methods used for particle relaxation. //---------------------------------------------------------------------- using namespace relax_dynamics; - RelaxationStepInnerFirstHalf leaflet_relaxation_first_half(leaflet_inner); + RelaxationStepInnerFirstHalf leaflet_relaxation_first_half(leaflet_inner, leaflet_shape); RelaxationStepInnerSecondHalf leaflet_relaxation_second_half(leaflet_inner, leaflet_shape); /** Constrain the boundary. */ BoundaryGeometry boundary_geometry(leaflet, "BoundaryGeometry"); diff --git a/modules/structural_simulation/structural_simulation_class.cpp b/modules/structural_simulation/structural_simulation_class.cpp index f81a24cb29..481d967821 100755 --- a/modules/structural_simulation/structural_simulation_class.cpp +++ b/modules/structural_simulation/structural_simulation_class.cpp @@ -36,7 +36,7 @@ SolidBodyForSimulation::SolidBodyForSimulation( Real physical_viscosity, SharedPtr material_model, Vecd *pos_0, Real *volume) : solid_body_from_mesh_(system, triangle_mesh_shape, resolution, material_model, pos_0, volume), inner_body_relation_(solid_body_from_mesh_), - initial_normal_direction_(SimpleDynamics(solid_body_from_mesh_)), + initial_normal_direction_(SimpleDynamics(solid_body_from_mesh_, *triangle_mesh_shape)), correct_configuration_(inner_body_relation_), stress_relaxation_first_half_(inner_body_relation_), stress_relaxation_second_half_(inner_body_relation_), @@ -62,9 +62,10 @@ void expandBoundingBox(BoundingBox *original, BoundingBox *additional) } void relaxParticlesSingleResolution(bool write_particle_relaxation_data, - SolidBody &solid_body_from_mesh, - InnerRelation &solid_body_from_mesh_inner) + InnerRelation &solid_body_from_mesh_inner, + Shape &shape) { + RealBody &solid_body_from_mesh = dynamic_cast(solid_body_from_mesh_inner.getSPHBody()); BodyStatesRecordingToVtp write_solid_body_from_mesh_to_vtp(solid_body_from_mesh); //---------------------------------------------------------------------- @@ -72,7 +73,7 @@ void relaxParticlesSingleResolution(bool write_particle_relaxation_data, //---------------------------------------------------------------------- SimpleDynamics random_solid_body_from_mesh_particles(solid_body_from_mesh); /** A Physics relaxation step. */ - relax_dynamics::RelaxationStepLevelSetCorrectionInner relaxation_step_inner(solid_body_from_mesh_inner); + relax_dynamics::RelaxationStepLevelSetCorrectionInner relaxation_step_inner(solid_body_from_mesh_inner, shape); //---------------------------------------------------------------------- // Particle relaxation starts here. //---------------------------------------------------------------------- @@ -117,7 +118,7 @@ std::tuple generateAndRelaxParticlesFromMesh( { system.setIOEnvironment(); InnerRelation inner_relation(model); - relaxParticlesSingleResolution(write_particle_relaxation_data, model, inner_relation); + relaxParticlesSingleResolution(write_particle_relaxation_data, inner_relation, *triangle_mesh_shape); } return std::tuple(model.getBaseParticles().ParticlePositions(), model.getBaseParticles().VolumetricMeasures()); @@ -345,10 +346,12 @@ void StructuralSimulation::initializeElasticSolidBodies() void StructuralSimulation::initializeContactBetweenTwoBodies(int first, int second) { SolidBodyFromMesh *first_body = solid_body_list_[first]->getSolidBodyFromMesh(); + Shape &first_shape = *body_mesh_list_[first]; SolidBodyFromMesh *second_body = solid_body_list_[second]->getSolidBodyFromMesh(); + Shape &second_shape = *body_mesh_list_[second]; - contact_list_.emplace_back(makeShared(*first_body, RealBodyVector({second_body}))); - contact_list_.emplace_back(makeShared(*second_body, RealBodyVector({first_body}))); + contact_list_.emplace_back(makeShared(*first_body, first_shape, RealBodyVector({second_body}))); + contact_list_.emplace_back(makeShared(*second_body, second_shape, RealBodyVector({first_body}))); int last = contact_list_.size() - 1; contact_density_list_.push_back(makeShared>(*contact_list_[last - 1])); @@ -374,7 +377,7 @@ void StructuralSimulation::initializeAllContacts() target_list.emplace_back(solid_body_list_[target_i]->getSolidBodyFromMesh()); } - contact_list_.emplace_back(makeShared(*contact_body, target_list)); + contact_list_.emplace_back(makeShared(*contact_body, *body_mesh_list_[i], target_list)); int last = contact_list_.size() - 1; contact_density_list_.emplace_back(makeShared>(*contact_list_[last])); contact_force_list_.emplace_back(makeShared>(*contact_list_[last])); @@ -489,7 +492,7 @@ void StructuralSimulation::initializeSpringNormalOnSurfaceParticles() Real damping_coefficient = std::get<5>(surface_spring_tuple_[i]); surface_spring_.emplace_back(makeShared>( - *solid_body_list_[body_index]->getSolidBodyFromMesh(), + *solid_body_list_[body_index]->getSolidBodyFromMesh(), *body_mesh_list_[body_index], inner_outer, point, spring_stiffness, damping_coefficient)); } } diff --git a/modules/structural_simulation/structural_simulation_class.h b/modules/structural_simulation/structural_simulation_class.h index 4a3c15db25..a23ac9895d 100755 --- a/modules/structural_simulation/structural_simulation_class.h +++ b/modules/structural_simulation/structural_simulation_class.h @@ -116,11 +116,6 @@ class SolidBodyForSimulation void expandBoundingBox(BoundingBox *original, BoundingBox *additional); -void relaxParticlesSingleResolution(bool write_particles_to_file, - SolidBodyFromMesh &solid_body_from_mesh, - BaseParticles &solid_body_from_mesh_particles, - InnerRelation &solid_body_from_mesh_inner); - static inline Real getPhysicalViscosityGeneral(Real rho, Real youngs_modulus, Real length_scale, Real shape_constant = 1.0) { // the physical viscosity is defined in the paper pf prof. Hu diff --git a/src/for_2D_build/particle_generator/particle_generator_lattice_2d.cpp b/src/for_2D_build/particle_generator/particle_generator_lattice_2d.cpp index 062296cf2e..b7c393cde5 100644 --- a/src/for_2D_build/particle_generator/particle_generator_lattice_2d.cpp +++ b/src/for_2D_build/particle_generator/particle_generator_lattice_2d.cpp @@ -18,9 +18,9 @@ void ParticleGenerator::prepareGeometricData() for (int j = 0; j < number_of_lattices[1]; ++j) { Vecd particle_position = mesh.CellPositionFromIndex(Arrayi(i, j)); - if (initial_shape_.checkNotFar(particle_position, lattice_spacing_)) + if (contain_shape_.checkNotFar(particle_position, lattice_spacing_)) { - if (initial_shape_.checkContain(particle_position)) + if (contain_shape_.checkContain(particle_position)) { addPositionAndVolumetricMeasure(particle_position, particle_volume); } @@ -38,9 +38,9 @@ void ParticleGenerator::prepareGeometricData() for (int j = 0; j < number_of_lattices[1]; ++j) { Vecd particle_position = mesh.CellPositionFromIndex(Arrayi(i, j)); - if (initial_shape_.checkNotFar(particle_position, lattice_spacing_)) + if (contain_shape_.checkNotFar(particle_position, lattice_spacing_)) { - if (initial_shape_.checkContain(particle_position)) + if (contain_shape_.checkContain(particle_position)) { all_cells_++; total_volume_ += lattice_spacing_ * lattice_spacing_; @@ -64,16 +64,16 @@ void ParticleGenerator::prepareGeometricData() for (int j = 0; j < number_of_lattices[1]; ++j) { Vecd particle_position = mesh.CellPositionFromIndex(Arrayi(i, j)); - if (initial_shape_.checkNotFar(particle_position, lattice_spacing_)) + if (contain_shape_.checkNotFar(particle_position, lattice_spacing_)) { - if (initial_shape_.checkContain(particle_position)) + if (contain_shape_.checkContain(particle_position)) { Real random_real = unif(rng); // If the random_real is smaller than the interval, add a particle, only if we haven't reached the max. number of particles if (random_real <= interval && base_particles_.TotalRealParticles() < planned_number_of_particles_) { addPositionAndVolumetricMeasure(particle_position, avg_particle_volume_ / thickness_); - addSurfaceProperties(initial_shape_.findNormalDirection(particle_position), thickness_); + addSurfaceProperties(contain_shape_.findNormalDirection(particle_position), thickness_); } } } diff --git a/src/for_3D_build/particle_generator/particle_generator_lattice_3d.cpp b/src/for_3D_build/particle_generator/particle_generator_lattice_3d.cpp index 61e8e4ee92..d10d94d0e9 100644 --- a/src/for_3D_build/particle_generator/particle_generator_lattice_3d.cpp +++ b/src/for_3D_build/particle_generator/particle_generator_lattice_3d.cpp @@ -19,9 +19,9 @@ void ParticleGenerator::prepareGeometricData() for (int k = 0; k < number_of_lattices[2]; ++k) { Vecd particle_position = mesh.CellPositionFromIndex(Arrayi(i, j, k)); - if (initial_shape_.checkNotFar(particle_position, lattice_spacing_)) + if (contain_shape_.checkNotFar(particle_position, lattice_spacing_)) { - if (initial_shape_.checkContain(particle_position)) + if (contain_shape_.checkContain(particle_position)) { addPositionAndVolumetricMeasure(particle_position, particle_volume); } @@ -40,9 +40,9 @@ void ParticleGenerator::prepareGeometricData() for (int k = 0; k < number_of_lattices[2]; ++k) { Vecd particle_position = mesh.CellPositionFromIndex(Arrayi(i, j, k)); - if (initial_shape_.checkNotFar(particle_position, lattice_spacing_)) + if (contain_shape_.checkNotFar(particle_position, lattice_spacing_)) { - if (initial_shape_.checkContain(particle_position)) + if (contain_shape_.checkContain(particle_position)) { all_cells_++; total_volume_ += lattice_spacing_ * lattice_spacing_ * lattice_spacing_; @@ -67,16 +67,16 @@ void ParticleGenerator::prepareGeometricData() for (int k = 0; k < number_of_lattices[2]; ++k) { Vecd particle_position = mesh.CellPositionFromIndex(Arrayi(i, j, k)); - if (initial_shape_.checkNotFar(particle_position, lattice_spacing_)) + if (contain_shape_.checkNotFar(particle_position, lattice_spacing_)) { - if (initial_shape_.checkContain(particle_position)) + if (contain_shape_.checkContain(particle_position)) { Real random_real = uniform_distr(rng); // If the random_real is smaller than the interval, add a particle, only if we haven't reached the max. number of particles. if (random_real <= interval && base_particles_.TotalRealParticles() < planned_number_of_particles_) { addPositionAndVolumetricMeasure(particle_position, avg_particle_volume_ / thickness_); - addSurfaceProperties(initial_shape_.findNormalDirection(particle_position), thickness_); + addSurfaceProperties(contain_shape_.findNormalDirection(particle_position), thickness_); } } } diff --git a/src/shared/body_relations/contact_body_relation.cpp b/src/shared/body_relations/contact_body_relation.cpp index 62a5b68fed..4ee2d52571 100644 --- a/src/shared/body_relations/contact_body_relation.cpp +++ b/src/shared/body_relations/contact_body_relation.cpp @@ -28,9 +28,10 @@ void ContactRelation::updateConfiguration() } } //=================================================================================================// -ShellSurfaceContactRelation::ShellSurfaceContactRelation(SPHBody &sph_body, RealBodyVector contact_bodies) +ShellSurfaceContactRelation::ShellSurfaceContactRelation( + SPHBody &sph_body, Shape &body_shape, RealBodyVector contact_bodies) : ContactRelationCrossResolution(sph_body, contact_bodies), - body_surface_layer_(shape_surface_ptr_keeper_.createPtr(sph_body)), + body_surface_layer_(shape_surface_ptr_keeper_.createPtr(sph_body, body_shape)), body_part_particles_(body_surface_layer_->body_part_particles_) { for (size_t k = 0; k != contact_bodies_.size(); ++k) @@ -183,9 +184,10 @@ void ContactRelationFromFluidToShell::updateConfiguration() } } //=================================================================================================// -SurfaceContactRelation::SurfaceContactRelation(SPHBody &sph_body, RealBodyVector contact_bodies, StdVec normal_corrections) +SurfaceContactRelation::SurfaceContactRelation(SPHBody &sph_body, Shape &body_shape, + RealBodyVector contact_bodies, StdVec normal_corrections) : ContactRelationCrossResolution(sph_body, std::move(contact_bodies)), - body_surface_layer_(shape_surface_ptr_keeper_.createPtr(sph_body)), + body_surface_layer_(shape_surface_ptr_keeper_.createPtr(sph_body, body_shape)), body_part_particles_(body_surface_layer_->body_part_particles_) { // Check if the source body is a shell body diff --git a/src/shared/body_relations/contact_body_relation.h b/src/shared/body_relations/contact_body_relation.h index a37e208280..cf35bb9bce 100644 --- a/src/shared/body_relations/contact_body_relation.h +++ b/src/shared/body_relations/contact_body_relation.h @@ -100,10 +100,10 @@ class ShellSurfaceContactRelation : public ContactRelationCrossResolution public: BodySurfaceLayer *body_surface_layer_; - ShellSurfaceContactRelation(SPHBody &sph_body, RealBodyVector contact_bodies); + ShellSurfaceContactRelation(SPHBody &sph_body, Shape &body_shape, RealBodyVector contact_bodies); ShellSurfaceContactRelation(SelfSurfaceContactRelation &solid_body_relation_self_contact, - RealBodyVector contact_bodies) - : ShellSurfaceContactRelation(*solid_body_relation_self_contact.real_body_, contact_bodies){}; + Shape &body_shape, RealBodyVector contact_bodies) + : ShellSurfaceContactRelation(*solid_body_relation_self_contact.real_body_, body_shape, contact_bodies){}; virtual ~ShellSurfaceContactRelation(){}; virtual void updateConfiguration() override; @@ -205,11 +205,13 @@ class SurfaceContactRelation : public ContactRelationCrossResolution UniquePtrKeeper shape_surface_ptr_keeper_; public: - SurfaceContactRelation(SPHBody &sph_body, RealBodyVector contact_bodies, StdVec normal_corrections = {}); + SurfaceContactRelation(SPHBody &sph_body, Shape &body_shape, + RealBodyVector contact_bodies, StdVec normal_corrections = {}); SurfaceContactRelation(SelfSurfaceContactRelation &solid_body_relation_self_contact, - RealBodyVector contact_bodies, + Shape &body_shape, RealBodyVector contact_bodies, StdVec normal_corrections = {}) : SurfaceContactRelation(*solid_body_relation_self_contact.real_body_, + body_shape, std::move(contact_bodies), std::move(normal_corrections)){}; ~SurfaceContactRelation() override = default; diff --git a/src/shared/body_relations/inner_body_relation.cpp b/src/shared/body_relations/inner_body_relation.cpp index fefeaf4bac..24f0f71e9a 100644 --- a/src/shared/body_relations/inner_body_relation.cpp +++ b/src/shared/body_relations/inner_body_relation.cpp @@ -48,9 +48,9 @@ void AdaptiveInnerRelation::updateConfiguration() } //=================================================================================================// SelfSurfaceContactRelation:: - SelfSurfaceContactRelation(RealBody &real_body) + SelfSurfaceContactRelation(RealBody &real_body, Shape &body_shape) : BaseInnerRelation(real_body), - body_surface_layer_(real_body), + body_surface_layer_(real_body, body_shape), body_part_particles_(body_surface_layer_.body_part_particles_), get_self_contact_neighbor_(real_body), cell_linked_list_(DynamicCast(this, real_body.getCellLinkedList())) {} diff --git a/src/shared/body_relations/inner_body_relation.h b/src/shared/body_relations/inner_body_relation.h index 75925c90af..a9bedbc4fe 100644 --- a/src/shared/body_relations/inner_body_relation.h +++ b/src/shared/body_relations/inner_body_relation.h @@ -46,7 +46,7 @@ class InnerRelation : public BaseInnerRelation public: explicit InnerRelation(RealBody &real_body); - virtual ~InnerRelation() {}; + virtual ~InnerRelation(){}; CellLinkedList &getCellLinkedList() { return cell_linked_list_; }; virtual void updateConfiguration() override; @@ -69,7 +69,7 @@ class AdaptiveInnerRelation : public BaseInnerRelation public: explicit AdaptiveInnerRelation(RealBody &real_body); - virtual ~AdaptiveInnerRelation() {}; + virtual ~AdaptiveInnerRelation(){}; virtual void updateConfiguration() override; }; @@ -83,8 +83,8 @@ class SelfSurfaceContactRelation : public BaseInnerRelation public: BodySurfaceLayer body_surface_layer_; - explicit SelfSurfaceContactRelation(RealBody &real_body); - virtual ~SelfSurfaceContactRelation() {}; + explicit SelfSurfaceContactRelation(RealBody &real_body, Shape &body_shape); + virtual ~SelfSurfaceContactRelation(){}; virtual void updateConfiguration() override; protected: @@ -108,7 +108,7 @@ class TreeInnerRelation : public InnerRelation public: explicit TreeInnerRelation(RealBody &real_body); - virtual ~TreeInnerRelation() {}; + virtual ~TreeInnerRelation(){}; virtual void updateConfiguration() override; }; diff --git a/src/shared/particle_dynamics/solid_dynamics/loading_dynamics.cpp b/src/shared/particle_dynamics/solid_dynamics/loading_dynamics.cpp index 96e03942a3..5a26807eae 100644 --- a/src/shared/particle_dynamics/solid_dynamics/loading_dynamics.cpp +++ b/src/shared/particle_dynamics/solid_dynamics/loading_dynamics.cpp @@ -48,7 +48,7 @@ void SpringDamperConstraintParticleWise::update(size_t index_i, Real dt) } //=================================================================================================// SpringNormalOnSurfaceParticles:: - SpringNormalOnSurfaceParticles(SPHBody &sph_body, bool outer_surface, + SpringNormalOnSurfaceParticles(SPHBody &sph_body, Shape &body_shape, bool outer_surface, Vecd source_point, Real stiffness, Real damping_ratio) : LoadingForce(sph_body, "NormalSpringForceOnSurface"), pos_(particles_->getVariableDataByName("Position")), @@ -61,7 +61,7 @@ SpringNormalOnSurfaceParticles:: is_spring_force_applied_(particles_->addUniqueDiscreteVariable( "isSpringForceApplied", particles_->ParticlesBound(), false)) { - BodySurface surface_layer(sph_body); + BodySurface surface_layer(sph_body, body_shape); for (size_t index_i : surface_layer.body_part_particles_) { @@ -120,7 +120,7 @@ void SpringNormalOnSurfaceParticles::update(size_t index_i, Real dt) } //=================================================================================================// SpringOnSurfaceParticles:: - SpringOnSurfaceParticles(SPHBody &sph_body, Real stiffness, Real damping_ratio) + SpringOnSurfaceParticles(SPHBody &sph_body, Shape &body_shape, Real stiffness, Real damping_ratio) : LoadingForce(sph_body, "SpringForceOnSurface"), pos_(particles_->getVariableDataByName("Position")), pos0_(particles_->registerStateVariableFrom("InitialPosition", "Position")), @@ -130,7 +130,7 @@ SpringOnSurfaceParticles:: is_spring_force_applied_(particles_->addUniqueDiscreteVariable( "isSpringForceApplied", particles_->ParticlesBound(), false)) { - BodySurface surface_layer(sph_body); + BodySurface surface_layer(sph_body, body_shape); // select which particles the spring is applied to // if the particle is in the surface layer, the force is applied for (size_t index_i : surface_layer.body_part_particles_) @@ -198,7 +198,7 @@ void ForceInBodyRegion::update(size_t index_i, Real dt) } //=================================================================================================// SurfacePressureFromSource:: - SurfacePressureFromSource(BodyPartByParticle &body_part, Vecd source_point, + SurfacePressureFromSource(BodyPartByParticle &body_part, Shape &body_shape, Vecd source_point, StdVec> pressure_over_time) : BaseLoadingForce(body_part, "SurfacePressureForce"), pos0_(particles_->registerStateVariableFrom("InitialPosition", "Position")), @@ -210,7 +210,7 @@ SurfacePressureFromSource:: "isPressureApplied", particles_->ParticlesBound(), false)), physical_time_(sph_system_.getSystemVariableDataByName("PhysicalTime")) { - BodySurface surface_layer(body_part.getSPHBody()); + BodySurface surface_layer(body_part.getSPHBody(), body_shape); for (size_t index_i : surface_layer.body_part_particles_) { diff --git a/src/shared/particle_dynamics/solid_dynamics/loading_dynamics.h b/src/shared/particle_dynamics/solid_dynamics/loading_dynamics.h index 20da392680..e9f3381ae9 100644 --- a/src/shared/particle_dynamics/solid_dynamics/loading_dynamics.h +++ b/src/shared/particle_dynamics/solid_dynamics/loading_dynamics.h @@ -93,7 +93,7 @@ class SpringDamperConstraintParticleWise : public LoadingForce class SpringNormalOnSurfaceParticles : public LoadingForce { public: - SpringNormalOnSurfaceParticles(SPHBody &sph_body, bool outer_surface, + SpringNormalOnSurfaceParticles(SPHBody &sph_body, Shape &body_shape, bool outer_surface, Vecd source_point, Real stiffness, Real damping_ratio = 0.05); bool *getApplySpringForceToParticle() { return is_spring_force_applied_; } @@ -129,7 +129,7 @@ class SpringOnSurfaceParticles : public LoadingForce bool *is_spring_force_applied_; public: - SpringOnSurfaceParticles(SPHBody &sph_body, Real stiffness, Real damping_ratio = 0.05); + SpringOnSurfaceParticles(SPHBody &sph_body, Shape &body_shape, Real stiffness, Real damping_ratio = 0.05); bool *getApplySpringForceToParticle() { return is_spring_force_applied_; } void update(size_t index_i, Real dt = 0.0); @@ -179,7 +179,7 @@ class ForceInBodyRegion : public BaseLoadingForce class SurfacePressureFromSource : public BaseLoadingForce { public: - SurfacePressureFromSource(BodyPartByParticle &body_part, + SurfacePressureFromSource(BodyPartByParticle &body_part, Shape &body_shape, Vecd source_point, StdVec> pressure_over_time); bool *getApplyPressureToParticle() { return is_pressure_applied_; } From 055c3b16d191d87dee3e0a85a876b7a3a8df5f17 Mon Sep 17 00:00:00 2001 From: Xiangyu Hu Date: Sat, 21 Sep 2024 18:09:25 +0000 Subject: [PATCH 04/13] 4 cases --- .../structural_simulation_class.cpp | 3 +- .../test_2d_airfoil/airfoil_2d.cpp | 12 ++++--- .../ball_shell_collision.cpp | 31 ++++++++++--------- .../test_2d_collision/collision.cpp | 27 +++++++++------- 4 files changed, 40 insertions(+), 33 deletions(-) diff --git a/modules/structural_simulation/structural_simulation_class.cpp b/modules/structural_simulation/structural_simulation_class.cpp index 481d967821..94f730b086 100755 --- a/modules/structural_simulation/structural_simulation_class.cpp +++ b/modules/structural_simulation/structural_simulation_class.cpp @@ -464,7 +464,8 @@ void StructuralSimulation::initializeSurfacePressure() StdVec> pressure_over_time = std::get<3>(surface_pressure_tuple_[i]); BodyPartByParticle *bp = body_part_tri_mesh_ptr_keeper_.createPtr(*solid_body_list_[body_index]->getSolidBodyFromMesh(), tri_mesh); - surface_pressure_.emplace_back(makeShared>(*bp, point, pressure_over_time)); + surface_pressure_.emplace_back(makeShared>( + *bp, *body_mesh_list_[i], point, pressure_over_time)); } } diff --git a/tests/2d_examples/test_2d_airfoil/airfoil_2d.cpp b/tests/2d_examples/test_2d_airfoil/airfoil_2d.cpp index 7906e36364..2cbfbae323 100644 --- a/tests/2d_examples/test_2d_airfoil/airfoil_2d.cpp +++ b/tests/2d_examples/test_2d_airfoil/airfoil_2d.cpp @@ -48,10 +48,12 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - RealBody airfoil(sph_system, makeShared("AirFoil")); + ImportModel airfoil_shape("AirFoil"); + RealBody airfoil(sph_system, airfoil_shape.getName()); airfoil.defineAdaptation(1.15, 1.0, 3); - airfoil.defineBodyLevelSetShape()->cleanLevelSet()->writeLevelSet(sph_system); - airfoil.generateParticles(); + LevelSetShape airfoil_level_set(airfoil, airfoil_shape, 1.0); + airfoil_level_set.cleanLevelSet()->writeLevelSet(sph_system); + airfoil.generateParticles(airfoil_level_set); //---------------------------------------------------------------------- // Define outputs functions. //---------------------------------------------------------------------- @@ -69,8 +71,8 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- using namespace relax_dynamics; SimpleDynamics random_airfoil_particles(airfoil); - RelaxationStepLevelSetCorrectionInner relaxation_step(airfoil_inner); - SimpleDynamics update_smoothing_length_ratio(airfoil); + RelaxationStepLevelSetCorrectionInner relaxation_step(airfoil_inner, airfoil_level_set); + SimpleDynamics update_smoothing_length_ratio(airfoil, airfoil_level_set); //---------------------------------------------------------------------- // Prepare the simulation with cell linked list, configuration // and case specified initial condition if necessary. diff --git a/tests/2d_examples/test_2d_ball_shell_collision/ball_shell_collision.cpp b/tests/2d_examples/test_2d_ball_shell_collision/ball_shell_collision.cpp index 4231037789..a6a507af52 100644 --- a/tests/2d_examples/test_2d_ball_shell_collision/ball_shell_collision.cpp +++ b/tests/2d_examples/test_2d_ball_shell_collision/ball_shell_collision.cpp @@ -55,7 +55,8 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - SolidBody ball(sph_system, makeShared(ball_center, ball_radius, "BallBody")); + GeometricShapeBall ball_shape(ball_center, ball_radius, "BallBody"); + SolidBody ball(sph_system, ball_shape.getName()); ball.defineMaterial(rho0_s, Youngs_modulus, poisson); if (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) { @@ -63,11 +64,13 @@ int main(int ac, char *av[]) } else { - ball.defineBodyLevelSetShape()->writeLevelSet(sph_system); - ball.generateParticles(); + LevelSetShape level_set_shape(ball, ball_shape, 1.0); + level_set_shape.writeLevelSet(sph_system); + ball.generateParticles(level_set_shape); } - SolidBody rigid_shell(sph_system, makeShared("ShellShape")); + ShellShape shell_shape("ShellShape"); + SolidBody rigid_shell(sph_system, shell_shape.getName()); rigid_shell.defineAdaptation(1.15, 1.0); rigid_shell.defineMaterial(); if (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) @@ -78,13 +81,7 @@ int main(int ac, char *av[]) { std::cout << "Error: This case requires reload shell particles for simulation!" << std::endl; return 0; - } - else - { - Real level_set_refinement_ratio = resolution_ref / (0.1 * thickness); - rigid_shell.defineBodyLevelSetShape(level_set_refinement_ratio)->writeLevelSet(sph_system); - rigid_shell.generateParticles(thickness); - } + }; ObserverBody ball_observer(sph_system, "BallObserver"); ball_observer.generateParticles(StdVec{ball_center}); @@ -93,6 +90,10 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- if (sph_system.RunParticleRelaxation() && !sph_system.ReloadParticles()) { + Real level_set_refinement_ratio = resolution_ref / (0.1 * thickness); + LevelSetShape level_set_shell(rigid_shell, shell_shape, level_set_refinement_ratio); + level_set_shell.writeLevelSet(sph_system); + rigid_shell.generateParticles(level_set_shell, thickness); //---------------------------------------------------------------------- // Define body relation map used for particle relaxation. //---------------------------------------------------------------------- @@ -103,13 +104,13 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- using namespace relax_dynamics; SimpleDynamics ball_random_particles(ball); - RelaxationStepInner ball_relaxation_step(ball_inner); + RelaxationStepInner ball_relaxation_step(ball_inner, ball_shape); //---------------------------------------------------------------------- // Define the methods for particle relaxation for the rigid shell. //---------------------------------------------------------------------- SimpleDynamics rigid_shell_random_particles(rigid_shell); - ShellRelaxationStep rigid_shell_relaxation_step(rigid_shell_inner); - ShellNormalDirectionPrediction shell_normal_prediction(rigid_shell_inner, thickness, cos(Pi / 3.75)); + ShellRelaxationStep rigid_shell_relaxation_step(rigid_shell_inner, level_set_shell); + ShellNormalDirectionPrediction shell_normal_prediction(rigid_shell_inner, level_set_shell, thickness, cos(Pi / 3.75)); //---------------------------------------------------------------------- // Output for particle relaxation. //---------------------------------------------------------------------- @@ -156,7 +157,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, {&rigid_shell}); + ShellSurfaceContactRelation ball_contact(ball, ball_shape, {&rigid_shell}); ContactRelation ball_observer_contact(ball_observer, {&ball}); //---------------------------------------------------------------------- // Define the numerical methods used in the simulation. diff --git a/tests/2d_examples/test_2d_collision/collision.cpp b/tests/2d_examples/test_2d_collision/collision.cpp index fb003659d3..6813228b1e 100644 --- a/tests/2d_examples/test_2d_collision/collision.cpp +++ b/tests/2d_examples/test_2d_collision/collision.cpp @@ -88,23 +88,26 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - SolidBody free_ball(sph_system, makeShared("FreeBall")); - free_ball.defineBodyLevelSetShape(); + FreeBall free_ball_shape("FreeBall"); + SolidBody free_ball(sph_system, free_ball_shape.getName()); + LevelSetShape free_ball_level_set(free_ball, free_ball_shape, 1.0); free_ball.defineMaterial(rho0_s, Youngs_modulus, poisson); (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? free_ball.generateParticles(free_ball.getName()) - : free_ball.generateParticles(); + : free_ball.generateParticles(free_ball_level_set); - SolidBody damping_ball(sph_system, makeShared("DampingBall")); - damping_ball.defineBodyLevelSetShape(); + DampingBall damping_ball_shape("DampingBall"); + SolidBody damping_ball(sph_system, damping_ball_shape.getName()); + LevelSetShape damping_ball_level_set(damping_ball, damping_ball_shape, 1.0); damping_ball.defineMaterial(rho0_s, Youngs_modulus, poisson); (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? damping_ball.generateParticles(damping_ball.getName()) - : damping_ball.generateParticles(); + : damping_ball.generateParticles(damping_ball_level_set); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WallBoundary wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(rho0_s, Youngs_modulus, poisson); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); ObserverBody free_ball_observer(sph_system, "FreeBallObserver"); free_ball_observer.generateParticles(observation_location_1); @@ -126,8 +129,8 @@ int main(int ac, char *av[]) using namespace relax_dynamics; SimpleDynamics free_ball_random_particles(free_ball); SimpleDynamics damping_ball_random_particles(damping_ball); - RelaxationStepInner free_ball_relaxation_step(free_ball_inner); - RelaxationStepInner damping_ball_relaxation_step(damping_ball_inner); + RelaxationStepInner free_ball_relaxation_step(free_ball_inner, free_ball_shape); + RelaxationStepInner damping_ball_relaxation_step(damping_ball_inner, damping_ball_shape); //---------------------------------------------------------------------- // Output for particle relaxation. //---------------------------------------------------------------------- @@ -168,9 +171,9 @@ int main(int ac, char *av[]) // inner and contact relations. //---------------------------------------------------------------------- InnerRelation free_ball_inner(free_ball); - SurfaceContactRelation free_ball_contact(free_ball, {&wall_boundary}); + SurfaceContactRelation free_ball_contact(free_ball, free_ball_shape, {&wall_boundary}); InnerRelation damping_ball_inner(damping_ball); - SurfaceContactRelation damping_ball_contact(damping_ball, {&wall_boundary}); + SurfaceContactRelation damping_ball_contact(damping_ball, damping_ball_shape, {&wall_boundary}); ContactRelation free_ball_observer_contact(free_ball_observer, {&free_ball}); ContactRelation damping_all_observer_contact(damping_ball_observer, {&damping_ball}); //---------------------------------------------------------------------- From b0c50e5cc96e6724c43067c125b8155335001420 Mon Sep 17 00:00:00 2001 From: Xiangyu Hu Date: Sat, 21 Sep 2024 20:36:55 +0000 Subject: [PATCH 05/13] compiled 10 cases --- .../regression_test.cpp | 5 +++-- .../test_1d_shock_tube/shock_tube.cpp | 2 +- .../2d_examples/test_2d_dambreak/Dambreak.cpp | 9 ++++---- .../dambreak_python.cpp | 15 +++++++------ .../test_2d_depolarization/depolarization.cpp | 5 +++-- .../test_2d_diffusion/diffusion.cpp | 8 +++---- .../diffusion_NeumannBC.cpp | 19 ++++++++++------- .../diffusion_RobinBC.cpp | 21 +++++++++++-------- .../test_2d_elastic_gate/elastic_gate.cpp | 19 ++++++++++------- .../windows_frame_diffusion_D4.cpp | 21 +++++++++++-------- .../windows_frame_diffusion_D7.cpp | 21 +++++++++++-------- 11 files changed, 83 insertions(+), 62 deletions(-) diff --git a/tests/2d_examples/test_0d_regression_test/regression_test.cpp b/tests/2d_examples/test_0d_regression_test/regression_test.cpp index f703969dfd..211e3e68fd 100644 --- a/tests/2d_examples/test_0d_regression_test/regression_test.cpp +++ b/tests/2d_examples/test_0d_regression_test/regression_test.cpp @@ -159,10 +159,11 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Create body, materials and particles. //---------------------------------------------------------------------- - SolidBody diffusion_body(sph_system, makeShared(createDiffusionDomain(), "DiffusionBody")); + MultiPolygonShape diffusion_body_shape(createDiffusionDomain(), "DiffusionBody"); + SolidBody diffusion_body(sph_system, diffusion_body_shape.getName()); DirectionalDiffusion *diffusion = diffusion_body.defineMaterial("Phi", diffusion_coeff, bias_coeff, bias_direction); - diffusion_body.generateParticles(); + diffusion_body.generateParticles(diffusion_body_shape); //---------------------------------------------------------------------- // Observer body //---------------------------------------------------------------------- diff --git a/tests/2d_examples/test_1d_shock_tube/shock_tube.cpp b/tests/2d_examples/test_1d_shock_tube/shock_tube.cpp index e07a939409..fea7a0fdc4 100644 --- a/tests/2d_examples/test_1d_shock_tube/shock_tube.cpp +++ b/tests/2d_examples/test_1d_shock_tube/shock_tube.cpp @@ -91,7 +91,7 @@ int main(int ac, char *av[]) WaveBlock wave_block_shape("WaveBlock"); FluidBody wave_body(sph_system, wave_block_shape.getName()); wave_body.defineMaterial(rho0_l, heat_capacity_ratio); - wave_body.generateParticles(); + wave_body.generateParticles(wave_block_shape); //---------------------------------------------------------------------- // Define body relation map. // The inner relation defines the particle configuration for particles within a body. diff --git a/tests/2d_examples/test_2d_dambreak/Dambreak.cpp b/tests/2d_examples/test_2d_dambreak/Dambreak.cpp index a3d9b17ee0..7e9e2ab26d 100644 --- a/tests/2d_examples/test_2d_dambreak/Dambreak.cpp +++ b/tests/2d_examples/test_2d_dambreak/Dambreak.cpp @@ -60,13 +60,14 @@ int main(int ac, char *av[]) // Creating bodies with corresponding materials and particles. //---------------------------------------------------------------------- TransformShape initial_water_block(Transform(water_block_translation), water_block_halfsize, "WaterBody"); - FluidBody water_block(sph_system, initial_water_block); + FluidBody water_block(sph_system, initial_water_block.getName()); water_block.defineMaterial(rho0_f, c_f); - water_block.generateParticles(); + water_block.generateParticles(initial_water_block); + WallBoundary wall_boundary_shape("WallBoundary"); SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); wall_boundary.defineMaterial(); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); ObserverBody fluid_observer(sph_system, "FluidObserver"); StdVec observation_location = {Vecd(DL, 0.2)}; @@ -96,7 +97,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- Gravity gravity(Vecd(0.0, -gravity_g)); SimpleDynamics> constant_gravity(water_block, gravity); - SimpleDynamics wall_boundary_normal_direction(wall_boundary); + SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); Dynamics1Level fluid_pressure_relaxation(water_block_inner, water_wall_contact); Dynamics1Level fluid_density_relaxation(water_block_inner, water_wall_contact); diff --git a/tests/2d_examples/test_2d_dambreak_python/dambreak_python.cpp b/tests/2d_examples/test_2d_dambreak_python/dambreak_python.cpp index 2c22d92d0e..0723439cbd 100644 --- a/tests/2d_examples/test_2d_dambreak_python/dambreak_python.cpp +++ b/tests/2d_examples/test_2d_dambreak_python/dambreak_python.cpp @@ -60,7 +60,9 @@ class PreSettingCase : public Parameter BoundingBox system_domain_bounds; SPHSystem sph_system; IOEnvironment io_environment; + TransformShape water_block_shape; FluidBody water_block; + WallBoundary wall_boundary_shape; SolidBody wall_boundary; StdVec observation_location; ObserverBody fluid_observer; @@ -70,9 +72,10 @@ class PreSettingCase : public Parameter : system_domain_bounds(Vec2d(-BW, -BW), Vec2d(DL + BW, DH + BW)), sph_system(system_domain_bounds, particle_spacing_ref), io_environment(sph_system), - water_block(sph_system, makeShared>( - Transform(water_block_translation), water_block_halfsize, "WaterBody")), - wall_boundary(sph_system, makeShared("WallBoundary")), + water_block_shape(Transform(water_block_translation), water_block_halfsize, "WaterBody"), + water_block(sph_system, water_block_shape.getName()), + wall_boundary_shape("WallBoundary"), + wall_boundary(sph_system, wall_boundary_shape.getName()), observation_location({Vecd(DL, 0.2)}), fluid_observer(sph_system, "FluidObserver") { @@ -80,10 +83,10 @@ class PreSettingCase : public Parameter // Creating bodies with corresponding materials and particles. //---------------------------------------------------------------------- water_block.defineMaterial(rho0_f, c_f); - water_block.generateParticles(); + water_block.generateParticles(water_block_shape); wall_boundary.defineMaterial(); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); fluid_observer.generateParticles(observation_location); } @@ -162,7 +165,7 @@ class Environment : public PreSettingCase fluid_observer_contact(fluid_observer, {&water_block}), gravity(Vecd(0.0, -gravity_g)), constant_gravity(water_block, gravity), - wall_boundary_normal_direction(wall_boundary), + wall_boundary_normal_direction(wall_boundary, wall_boundary_shape), fluid_pressure_relaxation(water_block_inner, water_wall_contact), fluid_density_relaxation(water_block_inner, water_wall_contact), fluid_density_by_summation(water_block_inner, water_wall_contact), diff --git a/tests/2d_examples/test_2d_depolarization/depolarization.cpp b/tests/2d_examples/test_2d_depolarization/depolarization.cpp index 68ccd12f2e..411aef31a3 100644 --- a/tests/2d_examples/test_2d_depolarization/depolarization.cpp +++ b/tests/2d_examples/test_2d_depolarization/depolarization.cpp @@ -79,12 +79,13 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - SolidBody muscle_body(sph_system, makeShared("MuscleBlock")); + MuscleBlock muscle_block_shape("MuscleBlock"); + SolidBody muscle_body(sph_system, muscle_block_shape.getName()); AlievPanfilowModel muscle_reaction_model(k_a, c_m, k, a, b, mu_1, mu_2, epsilon); MonoFieldElectroPhysiology *mono_field_electro_physiology = muscle_body.defineMaterial>( muscle_reaction_model, diffusion_coeff, bias_coeff, fiber_direction); - muscle_body.generateParticles(); + muscle_body.generateParticles(muscle_block_shape); ObserverBody voltage_observer(sph_system, "VoltageObserver"); voltage_observer.generateParticles(observation_location); diff --git a/tests/2d_examples/test_2d_diffusion/diffusion.cpp b/tests/2d_examples/test_2d_diffusion/diffusion.cpp index 6f30cc09f6..4116e5a605 100644 --- a/tests/2d_examples/test_2d_diffusion/diffusion.cpp +++ b/tests/2d_examples/test_2d_diffusion/diffusion.cpp @@ -103,11 +103,11 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - DiffusionBlock diffusion_block("DiffusionBlock"); - SolidBody diffusion_body(sph_system, diffusion_block.getName()); + DiffusionBlock diffusion_block_shape("DiffusionBlock"); + SolidBody diffusion_body(sph_system, diffusion_block_shape.getName()); DirectionalDiffusion *diffusion = diffusion_body.defineMaterial("Phi", diffusion_coeff, bias_coeff, bias_direction); - diffusion_body.generateParticles(); + diffusion_body.generateParticles(diffusion_block_shape); //---------------------------------------------------------------------- // Particle and body creation of fluid observers. //---------------------------------------------------------------------- @@ -133,7 +133,7 @@ int main(int ac, char *av[]) SimpleDynamics setup_diffusion_initial_condition(diffusion_body); GetDiffusionTimeStepSize get_time_step_size(diffusion_body, *diffusion); - PeriodicAlongAxis periodic_along_x(diffusion_block.getBounds(), xAxis); + PeriodicAlongAxis periodic_along_x(diffusion_block_shape.getBounds(), xAxis); PeriodicConditionUsingCellLinkedList periodic_condition_y(diffusion_body, periodic_along_x); //---------------------------------------------------------------------- // Define the methods for I/O operations and observations of the simulation. diff --git a/tests/2d_examples/test_2d_diffusion_NeumannBC/diffusion_NeumannBC.cpp b/tests/2d_examples/test_2d_diffusion_NeumannBC/diffusion_NeumannBC.cpp index 67fa90dbb1..71401236f4 100644 --- a/tests/2d_examples/test_2d_diffusion_NeumannBC/diffusion_NeumannBC.cpp +++ b/tests/2d_examples/test_2d_diffusion_NeumannBC/diffusion_NeumannBC.cpp @@ -20,18 +20,21 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - SolidBody diffusion_body(sph_system, makeShared("DiffusionBody")); + DiffusionBody diffusion_body_shape("DiffusionBody"); + SolidBody diffusion_body(sph_system, diffusion_body_shape.getName()); IsotropicDiffusion *diffusion = diffusion_body.defineMaterial("Phi", "Phi", diffusion_coeff); - diffusion_body.generateParticles(); + diffusion_body.generateParticles(diffusion_body_shape); - SolidBody wall_Dirichlet(sph_system, makeShared("DirichletWallBoundary")); + DirichletWallBoundary wall_shape_Dirichlet("DirichletWallBoundary"); + SolidBody wall_Dirichlet(sph_system, wall_shape_Dirichlet.getName()); wall_Dirichlet.defineMaterial(); - wall_Dirichlet.generateParticles(); + wall_Dirichlet.generateParticles(wall_shape_Dirichlet); - SolidBody wall_Neumann(sph_system, makeShared("NeumannWallBoundary")); + NeumannWallBoundary wall_shape_Neumann("NeumannWallBoundary"); + SolidBody wall_Neumann(sph_system, wall_shape_Neumann.getName()); wall_Neumann.defineMaterial(); - wall_Neumann.generateParticles(); + wall_Neumann.generateParticles(wall_shape_Neumann); //---------------------------------------------------------------------- // Particle and body creation of temperature observers. //---------------------------------------------------------------------- @@ -50,8 +53,8 @@ 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 diffusion_body_normal_direction(diffusion_body); - SimpleDynamics wall_boundary_normal_direction(wall_Neumann); + SimpleDynamics diffusion_body_normal_direction(diffusion_body, diffusion_body_shape); + SimpleDynamics wall_boundary_normal_direction(wall_Neumann, wall_shape_Neumann); DiffusionBodyRelaxation temperature_relaxation( ConstructorArgs(diffusion_body_inner, diffusion), diff --git a/tests/2d_examples/test_2d_diffusion_RobinBC/diffusion_RobinBC.cpp b/tests/2d_examples/test_2d_diffusion_RobinBC/diffusion_RobinBC.cpp index d734ec33f0..c6d60a37b6 100644 --- a/tests/2d_examples/test_2d_diffusion_RobinBC/diffusion_RobinBC.cpp +++ b/tests/2d_examples/test_2d_diffusion_RobinBC/diffusion_RobinBC.cpp @@ -21,18 +21,21 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - SolidBody diffusion_body(sph_system, makeShared("DiffusionBody")); + DiffusionBody diffusion_body_shape("DiffusionBody"); + SolidBody diffusion_body(sph_system, diffusion_body_shape.getName()); IsotropicDiffusion *diffusion = diffusion_body.defineMaterial("Phi", "Phi", diffusion_coeff); - diffusion_body.generateParticles(); + diffusion_body.generateParticles(diffusion_body_shape); - SolidBody wall_boundary_Dirichlet(sph_system, makeShared("DirichletWallBoundary")); + DirichletWallBoundary wall_shape_Dirichlet("DirichletWallBoundary"); + SolidBody wall_boundary_Dirichlet(sph_system, wall_shape_Dirichlet.getName()); wall_boundary_Dirichlet.defineMaterial(); - wall_boundary_Dirichlet.generateParticles(); + wall_boundary_Dirichlet.generateParticles(wall_shape_Dirichlet); - SolidBody wall_boundary_Robin(sph_system, makeShared("RobinWallBoundary")); + RobinWallBoundary wall_shape_Robin("RobinWallBoundary"); + SolidBody wall_boundary_Robin(sph_system, wall_shape_Robin.getName()); wall_boundary_Robin.defineMaterial(); - wall_boundary_Robin.generateParticles(); + wall_boundary_Robin.generateParticles(wall_shape_Robin); //---------------------------------------------------------------------- // Particle and body creation of temperature observers. //---------------------------------------------------------------------- @@ -53,9 +56,9 @@ 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 diffusion_body_normal_direction(diffusion_body); - SimpleDynamics Dirichlet_normal_direction(wall_boundary_Dirichlet); - SimpleDynamics Robin_normal_direction(wall_boundary_Robin); + SimpleDynamics diffusion_body_normal_direction(diffusion_body, diffusion_body_shape); + SimpleDynamics Dirichlet_normal_direction(wall_boundary_Dirichlet, wall_shape_Dirichlet); + SimpleDynamics Robin_normal_direction(wall_boundary_Robin, wall_shape_Robin); DiffusionBodyRelaxation temperature_relaxation( ConstructorArgs(diffusion_inner, diffusion), diff --git a/tests/2d_examples/test_2d_elastic_gate/elastic_gate.cpp b/tests/2d_examples/test_2d_elastic_gate/elastic_gate.cpp index 279b4d501c..5dffa62b84 100644 --- a/tests/2d_examples/test_2d_elastic_gate/elastic_gate.cpp +++ b/tests/2d_examples/test_2d_elastic_gate/elastic_gate.cpp @@ -145,18 +145,21 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared("WaterBlock")); + WaterBlock water_block_shape("WaterBlock"); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f); - water_block.generateParticles(); + water_block.generateParticles(water_block_shape); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WallBoundary wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); - SolidBody gate(sph_system, makeShared(createGateShape(), "Gate")); + MultiPolygonShape gate_shape(createGateShape(), "Gate"); + SolidBody gate(sph_system, gate_shape.getName()); gate.defineAdaptationRatios(1.15, 2.0); gate.defineMaterial(rho0_s, Youngs_modulus, poisson); - gate.generateParticles(); + gate.generateParticles(gate_shape); ObserverBody gate_observer(sph_system, "Observer"); gate_observer.defineAdaptationRatios(1.15, 2.0); @@ -192,8 +195,8 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- SimpleDynamics gate_offset_position(gate, offset); InteractionWithUpdate gate_corrected_configuration(gate_inner); - SimpleDynamics wall_boundary_normal_direction(wall_boundary); - SimpleDynamics gate_normal_direction(gate); + SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); + SimpleDynamics gate_normal_direction(gate, gate_shape); Dynamics1Level gate_stress_relaxation_first_half(gate_inner); Dynamics1Level gate_stress_relaxation_second_half(gate_inner); diff --git a/tests/2d_examples/test_2d_windows_frame_diffusion_D4/windows_frame_diffusion_D4.cpp b/tests/2d_examples/test_2d_windows_frame_diffusion_D4/windows_frame_diffusion_D4.cpp index e19772f292..ce71920bf3 100644 --- a/tests/2d_examples/test_2d_windows_frame_diffusion_D4/windows_frame_diffusion_D4.cpp +++ b/tests/2d_examples/test_2d_windows_frame_diffusion_D4/windows_frame_diffusion_D4.cpp @@ -22,15 +22,18 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - SolidBody diffusion_body(sph_system, makeShared(createOverallStructureBody(), "DiffusionBody")); + MultiPolygonShape diffusion_body_shape(createOverallStructureBody(), "DiffusionBody"); + SolidBody diffusion_body(sph_system, diffusion_body_shape.getName()); LocalIsotropicDiffusion *frame_diffusion = diffusion_body.defineMaterial("Phi", "Phi", wood_cond); - diffusion_body.generateParticles(); + diffusion_body.generateParticles(diffusion_body_shape); - SolidBody boundary_Robin_in(sph_system, makeShared(createInternalAirBody(), "InternalConvectionBoundary")); - boundary_Robin_in.generateParticles(); + MultiPolygonShape boundary_in_shape(createInternalAirBody(), "InternalConvectionBoundary"); + SolidBody boundary_Robin_in(sph_system, boundary_in_shape.getName()); + boundary_Robin_in.generateParticles(boundary_in_shape); - SolidBody boundary_Robin_ex(sph_system, makeShared(createExternalAirBody(), "ExternalConvectionBoundary")); - boundary_Robin_ex.generateParticles(); + MultiPolygonShape boundary_ex_shape(createExternalAirBody(), "ExternalConvectionBoundary"); + SolidBody boundary_Robin_ex(sph_system, boundary_ex_shape.getName()); + boundary_Robin_ex.generateParticles(boundary_ex_shape); //---------------------------------------------------------------------- // Particle and body creation of temperature observers. //---------------------------------------------------------------------- @@ -48,9 +51,9 @@ 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 diffusion_body_normal_direction(diffusion_body); - SimpleDynamics Robin_normal_direction_in(boundary_Robin_in); - SimpleDynamics Robin_normal_direction_ex(boundary_Robin_ex); + SimpleDynamics diffusion_body_normal_direction(diffusion_body, diffusion_body_shape); + SimpleDynamics Robin_normal_direction_in(boundary_Robin_in, boundary_in_shape); + SimpleDynamics Robin_normal_direction_ex(boundary_Robin_ex, boundary_ex_shape); // Define body regions BodyRegionByParticle epdm_body(diffusion_body, makeShared(createEPDMBody())); diff --git a/tests/2d_examples/test_2d_windows_frame_diffusion_D7/windows_frame_diffusion_D7.cpp b/tests/2d_examples/test_2d_windows_frame_diffusion_D7/windows_frame_diffusion_D7.cpp index d1b3c826a2..027eac5a48 100644 --- a/tests/2d_examples/test_2d_windows_frame_diffusion_D7/windows_frame_diffusion_D7.cpp +++ b/tests/2d_examples/test_2d_windows_frame_diffusion_D7/windows_frame_diffusion_D7.cpp @@ -22,15 +22,18 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - SolidBody diffusion_body(sph_system, makeShared(createOverallStructureBody(), "DiffusionBody")); + MultiPolygonShape diffusion_body_shape(createOverallStructureBody(), "DiffusionBody"); + SolidBody diffusion_body(sph_system, diffusion_body_shape.getName()); LocalIsotropicDiffusion *frame_diffusion = diffusion_body.defineMaterial("Phi", "Phi", pvc_cond); - diffusion_body.generateParticles(); + diffusion_body.generateParticles(diffusion_body_shape); - SolidBody boundary_Robin_in(sph_system, makeShared(createInternalAirBody(), "InternalConvectionBoundary")); - boundary_Robin_in.generateParticles(); + MultiPolygonShape boundary_in_shape(createInternalAirBody(), "InternalConvectionBoundary"); + SolidBody boundary_Robin_in(sph_system, boundary_in_shape.getName()); + boundary_Robin_in.generateParticles(boundary_in_shape); - SolidBody boundary_Robin_ex(sph_system, makeShared(createExternalAirBody(), "ExternalConvectionBoundary")); - boundary_Robin_ex.generateParticles(); + MultiPolygonShape boundary_ex_shape(createExternalAirBody(), "ExternalConvectionBoundary"); + SolidBody boundary_Robin_ex(sph_system, boundary_ex_shape.getName()); + boundary_Robin_ex.generateParticles(boundary_ex_shape); //---------------------------------------------------------------------- // Particle and body creation of temperature observers. //---------------------------------------------------------------------- @@ -48,9 +51,9 @@ 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 diffusion_body_normal_direction(diffusion_body); - SimpleDynamics Robin_normal_direction_in(boundary_Robin_in); - SimpleDynamics Robin_normal_direction_ex(boundary_Robin_ex); + SimpleDynamics diffusion_body_normal_direction(diffusion_body, diffusion_body_shape); + SimpleDynamics Robin_normal_direction_in(boundary_Robin_in, boundary_in_shape); + SimpleDynamics Robin_normal_direction_ex(boundary_Robin_ex, boundary_ex_shape); // Define body regions BodyRegionByParticle epdm_body(diffusion_body, makeShared(createEPDMBody())); From 3cfdf81470d43132ceb0f5098a7efa101fad2167 Mon Sep 17 00:00:00 2001 From: Xiangyu Hu Date: Sat, 21 Sep 2024 21:42:31 +0000 Subject: [PATCH 06/13] batch replace --- .../2d_FVM_double_mach_reflection.cpp | 2 +- .../2d_FVM_double_mach_reflection.h | 9 --------- .../2d_FVM_flow_around_cylinder.cpp | 11 +--------- .../test_2d_T_shaped_pipe/T_shaped_pipe.cpp | 7 ++++--- .../column_collapse.cpp | 4 ++-- .../2d_eulerian_taylor_green_LG.cpp | 2 +- .../test_2d_filling_tank/filling_tank.cpp | 11 +++++----- .../2d_flow_stream_around_fish.cpp | 3 ++- .../2d_free_stream_around_cylinder.cpp | 3 ++- .../mr_free_stream_around_cylinder.cpp | 3 ++- tests/2d_examples/test_2d_fsi2/fsi2.cpp | 2 +- .../test_2d_heat_transfer/heat_transfer.cpp | 2 +- .../test_2d_hydrostatic_fluid_shell.cpp | 12 ++++++----- .../hydrostatic_fsi.cpp | 19 ++++++++++-------- .../test_2d_impact_patch/impact_patch.cpp | 5 +++-- .../lid_driven_cavity.cpp | 20 ++++++++++--------- .../nonlinear_wave_fsi.cpp | 7 ++++--- tests/2d_examples/test_2d_owsc/owsc.cpp | 7 ++++--- .../poiseuille_flow.cpp | 2 +- .../test_2d_rotation_patch/rotation_patch.cpp | 3 ++- tests/2d_examples/test_2d_sliding/sliding.cpp | 2 +- .../droplet_conservation.cpp | 7 ++++--- .../test_2d_standing_wave/standing_wave.cpp | 7 ++++--- .../static_confinement.cpp | 3 ++- tests/2d_examples/test_2d_stfb/stfb.cpp | 7 ++++--- tests/2d_examples/test_2d_stlw/stlw.cpp | 4 ++-- .../src/tethered_dead_fish_in_flow.cpp | 2 +- .../two_phase_dambreak.cpp | 5 +++-- .../test_2d_water_entry_exit.cpp | 4 ++-- .../3d_examples/test_3d_dambreak/dambreak.cpp | 4 ++-- .../test_3d_dambreak_elastic_plate_shell.cpp | 7 ++++--- .../nonlinear_wave_fsi.cpp | 10 ++++++---- .../test_3d_repose_angle/repose_angle.cpp | 4 ++-- tests/3d_examples/test_3d_stfb/stfb.cpp | 7 ++++--- tests/3d_examples/test_3d_stlw/stlw.cpp | 7 ++++--- .../test_3d_taylor_bar_UL/taylor_bar_UL.cpp | 4 ++-- .../T_pipe_VIPO_shell.cpp | 3 ++- .../mixed_poiseuille_flow.cpp | 7 ++++--- .../modified_T_flow.cpp | 7 ++++--- .../pulsatile_poiseuille_flow.cpp | 7 ++++--- .../VP_heat_flux_optimization.cpp | 4 ++-- .../VP_heat_flux_steady.cpp | 4 ++-- .../VP_same_sink_optimization.cpp | 4 ++-- .../VP_same_sink_steady.cpp | 4 ++-- .../test_2d_dambreak_sycl/dambreak_sycl.cpp | 2 +- .../2d_velocity_gradient.cpp | 4 ++-- 46 files changed, 138 insertions(+), 126 deletions(-) diff --git a/tests/2d_examples/test_2d_FVM_double_mach_reflection/2d_FVM_double_mach_reflection.cpp b/tests/2d_examples/test_2d_FVM_double_mach_reflection/2d_FVM_double_mach_reflection.cpp index a7087759a7..c0a110daf2 100644 --- a/tests/2d_examples/test_2d_FVM_double_mach_reflection/2d_FVM_double_mach_reflection.cpp +++ b/tests/2d_examples/test_2d_FVM_double_mach_reflection/2d_FVM_double_mach_reflection.cpp @@ -23,7 +23,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody wave_block(sph_system, makeShared("WaveBody")); + FluidBody wave_block(sph_system, "WaveBody"); wave_block.defineMaterial(rho0_another, heat_capacity_ratio); Ghost ghost_boundary(0.5); wave_block.generateParticlesWithReserve(ghost_boundary, ansys_mesh); diff --git a/tests/2d_examples/test_2d_FVM_double_mach_reflection/2d_FVM_double_mach_reflection.h b/tests/2d_examples/test_2d_FVM_double_mach_reflection/2d_FVM_double_mach_reflection.h index 0b4a1840ac..b206391d0f 100644 --- a/tests/2d_examples/test_2d_FVM_double_mach_reflection/2d_FVM_double_mach_reflection.h +++ b/tests/2d_examples/test_2d_FVM_double_mach_reflection/2d_FVM_double_mach_reflection.h @@ -49,15 +49,6 @@ std::vector CreatComputationDomain() computation_domain.push_back(Vecd(0.0, 0.0)); return computation_domain; } -class WaveBody : public ComplexShape -{ - public: - explicit WaveBody(const std::string &shape_name) : ComplexShape(shape_name) - { - MultiPolygon wave_block(CreatComputationDomain()); - add(wave_block, "WaveBlock"); - } -}; //---------------------------------------------------------------------- // Case-dependent initial condition. //---------------------------------------------------------------------- diff --git a/tests/2d_examples/test_2d_FVM_flow_around_cylinder/2d_FVM_flow_around_cylinder.cpp b/tests/2d_examples/test_2d_FVM_flow_around_cylinder/2d_FVM_flow_around_cylinder.cpp index 16581077f8..20aa4db3d8 100644 --- a/tests/2d_examples/test_2d_FVM_flow_around_cylinder/2d_FVM_flow_around_cylinder.cpp +++ b/tests/2d_examples/test_2d_FVM_flow_around_cylinder/2d_FVM_flow_around_cylinder.cpp @@ -41,15 +41,6 @@ std::vector createWaterBlockShape() return water_block_shape; } -class WaterBlock : public ComplexShape -{ - public: - explicit WaterBlock(const std::string &shape_name) : ComplexShape(shape_name) - { - MultiPolygon water_block(createWaterBlockShape()); - add(water_block, "WaterBlock"); - } -}; //---------------------------------------------------------------------- // Case dependent boundary condition //---------------------------------------------------------------------- @@ -97,7 +88,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared("WaterBlock")); + FluidBody water_block(sph_system, "WaterBlock"); water_block.defineMaterial(rho0_f, c_f, mu_f); Ghost ghost_boundary(0.5); water_block.generateParticlesWithReserve(ghost_boundary, ansys_mesh); diff --git a/tests/2d_examples/test_2d_T_shaped_pipe/T_shaped_pipe.cpp b/tests/2d_examples/test_2d_T_shaped_pipe/T_shaped_pipe.cpp index 1d7948a590..3690ad350f 100644 --- a/tests/2d_examples/test_2d_T_shaped_pipe/T_shaped_pipe.cpp +++ b/tests/2d_examples/test_2d_T_shaped_pipe/T_shaped_pipe.cpp @@ -99,13 +99,14 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles.cd //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared("WaterBody")); + WaterBlock water_block_shape("WaterBody"); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); ParticleBuffer inlet_particle_buffer(0.5); water_block.generateParticlesWithReserve(inlet_particle_buffer); SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); wall_boundary.defineMaterial(); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); //---------------------------------------------------------------------- // Define body relation map. // The contact map gives the topological connections between the bodies. @@ -125,7 +126,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 wall_boundary_normal_direction(wall_boundary); + SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); InteractionWithUpdate inlet_outlet_surface_particle_indicator(water_block_inner, water_wall_contact); Dynamics1Level pressure_relaxation(water_block_inner, water_wall_contact); diff --git a/tests/2d_examples/test_2d_column_collapse/column_collapse.cpp b/tests/2d_examples/test_2d_column_collapse/column_collapse.cpp index a99589fc47..bcf6bc0d16 100644 --- a/tests/2d_examples/test_2d_column_collapse/column_collapse.cpp +++ b/tests/2d_examples/test_2d_column_collapse/column_collapse.cpp @@ -79,7 +79,7 @@ int main(int ac, char *av[]) SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); wall_boundary.defineMaterial(); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); //---------------------------------------------------------------------- // Define body relation map. // The contact map gives the topological connections between the bodies. @@ -98,7 +98,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- Gravity gravity(Vecd(0.0, -gravity_g)); SimpleDynamics> constant_gravity(soil_block, gravity); - SimpleDynamics wall_boundary_normal_direction(wall_boundary); + SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); Dynamics1Level granular_stress_relaxation(soil_block_inner, soil_block_contact); Dynamics1Level granular_density_relaxation(soil_block_inner, soil_block_contact); InteractionWithUpdate soil_density_by_summation(soil_block_inner, soil_block_contact); diff --git a/tests/2d_examples/test_2d_eulerian_taylor_green_LG/2d_eulerian_taylor_green_LG.cpp b/tests/2d_examples/test_2d_eulerian_taylor_green_LG/2d_eulerian_taylor_green_LG.cpp index 149e781166..25d75a5d92 100644 --- a/tests/2d_examples/test_2d_eulerian_taylor_green_LG/2d_eulerian_taylor_green_LG.cpp +++ b/tests/2d_examples/test_2d_eulerian_taylor_green_LG/2d_eulerian_taylor_green_LG.cpp @@ -86,7 +86,7 @@ int main(int ac, char *av[]) FluidBody water_body(sph_system, water_block_shape.getName()); water_body.sph_adaptation_->resetKernel>(20); water_body.defineMaterial(rho0_f, heat_capacity_ratio, mu_f); - water_body.generateParticles(); + water_body.generateParticles(water_block_shape); //---------------------------------------------------------------------- // Define body relation map. // The contact map gives the topological connections between the bodies. diff --git a/tests/2d_examples/test_2d_filling_tank/filling_tank.cpp b/tests/2d_examples/test_2d_filling_tank/filling_tank.cpp index 491a8daa48..96e11944a8 100644 --- a/tests/2d_examples/test_2d_filling_tank/filling_tank.cpp +++ b/tests/2d_examples/test_2d_filling_tank/filling_tank.cpp @@ -94,15 +94,16 @@ int main(int ac, char *av[]) // Creating body, materials and particles. //---------------------------------------------------------------------- TransformShape water_inlet_shape(Transform(inlet_translation), inlet_halfsize); - FluidBody water_body(sph_system, water_inlet_shape, "WaterBody"); + FluidBody water_body(sph_system, "WaterBody"); water_body.sph_adaptation_->resetKernel>(20); water_body.defineMaterial(rho0_f, c_f); ParticleBuffer inlet_buffer(350.0); - water_body.generateParticlesWithReserve(inlet_buffer); + water_body.generateParticlesWithReserve(inlet_buffer, water_inlet_shape); - SolidBody wall(sph_system, makeShared("Wall")); + WallBoundary wall_boundary_shape("Wall"); + SolidBody wall(sph_system, wall_boundary_shape.getName()); wall.defineMaterial(); - wall.generateParticles(); + wall.generateParticles(wall_boundary_shape); ObserverBody fluid_observer(sph_system, "FluidObserver"); fluid_observer.generateParticles(observation_location); @@ -124,7 +125,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Define all numerical methods which are used in this case. //---------------------------------------------------------------------- - SimpleDynamics wall_normal_direction(wall); + SimpleDynamics wall_normal_direction(wall, wall_boundary_shape); InteractionWithUpdate indicate_free_surface(water_body_inner, water_body_contact); Dynamics1Level pressure_relaxation(water_body_inner, water_body_contact); diff --git a/tests/2d_examples/test_2d_flow_stream_around_fish/2d_flow_stream_around_fish.cpp b/tests/2d_examples/test_2d_flow_stream_around_fish/2d_flow_stream_around_fish.cpp index 14dd50f608..a3c64514d8 100644 --- a/tests/2d_examples/test_2d_flow_stream_around_fish/2d_flow_stream_around_fish.cpp +++ b/tests/2d_examples/test_2d_flow_stream_around_fish/2d_flow_stream_around_fish.cpp @@ -23,7 +23,8 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating bodies with corresponding materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared("WaterBody")); + WaterBlock water_block_shape("WaterBody"); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); ParticleBuffer inlet_particle_buffer(0.5); water_block.generateParticlesWithReserve(inlet_particle_buffer); diff --git a/tests/2d_examples/test_2d_free_stream_around_cylinder/2d_free_stream_around_cylinder.cpp b/tests/2d_examples/test_2d_free_stream_around_cylinder/2d_free_stream_around_cylinder.cpp index a60de206ea..722b962ebe 100644 --- a/tests/2d_examples/test_2d_free_stream_around_cylinder/2d_free_stream_around_cylinder.cpp +++ b/tests/2d_examples/test_2d_free_stream_around_cylinder/2d_free_stream_around_cylinder.cpp @@ -24,7 +24,8 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared("WaterBody")); + WaterBlock water_block_shape("WaterBody"); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); ParticleBuffer inlet_particle_buffer(0.5); water_block.generateParticlesWithReserve(inlet_particle_buffer); diff --git a/tests/2d_examples/test_2d_free_stream_around_cylinder_mr/mr_free_stream_around_cylinder.cpp b/tests/2d_examples/test_2d_free_stream_around_cylinder_mr/mr_free_stream_around_cylinder.cpp index a8c4ff425b..18222d35e2 100644 --- a/tests/2d_examples/test_2d_free_stream_around_cylinder_mr/mr_free_stream_around_cylinder.cpp +++ b/tests/2d_examples/test_2d_free_stream_around_cylinder_mr/mr_free_stream_around_cylinder.cpp @@ -24,7 +24,8 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared("WaterBody")); + WaterBlock water_block_shape("WaterBody"); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineAdaptation(1.3, 1.0, 1); water_block.defineComponentLevelSetShape("OuterBoundary")->writeLevelSet(sph_system); water_block.defineMaterial(rho0_f, c_f, mu_f); diff --git a/tests/2d_examples/test_2d_fsi2/fsi2.cpp b/tests/2d_examples/test_2d_fsi2/fsi2.cpp index 31bb2b2015..76aaaf05eb 100644 --- a/tests/2d_examples/test_2d_fsi2/fsi2.cpp +++ b/tests/2d_examples/test_2d_fsi2/fsi2.cpp @@ -124,7 +124,7 @@ int main(int ac, char *av[]) // Then fluid dynamics and the corresponding coupling dynamics. // The coupling with multi-body dynamics will be introduced at last. //---------------------------------------------------------------------- - SimpleDynamics wall_boundary_normal_direction(wall_boundary); + SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); SimpleDynamics insert_body_normal_direction(insert_body); InteractionWithUpdate insert_body_corrected_configuration(insert_body_inner); diff --git a/tests/2d_examples/test_2d_heat_transfer/heat_transfer.cpp b/tests/2d_examples/test_2d_heat_transfer/heat_transfer.cpp index d2bbe782f7..f1c5939bf1 100644 --- a/tests/2d_examples/test_2d_heat_transfer/heat_transfer.cpp +++ b/tests/2d_examples/test_2d_heat_transfer/heat_transfer.cpp @@ -229,7 +229,7 @@ int main(int ac, char *av[]) // Then fluid dynamics and the corresponding coupling dynamics. // The coupling with multi-body dynamics will be introduced at last. //---------------------------------------------------------------------- - SimpleDynamics thermosolid_body_normal_direction(thermosolid_body); + SimpleDynamics thermosolid_body_normal_direction(thermosolid_body, thermosolid_body_shape); Dynamics1Level pressure_relaxation(fluid_body_inner, fluid_body_contact); Dynamics1Level density_relaxation(fluid_body_inner, fluid_body_contact); diff --git a/tests/2d_examples/test_2d_hydrostatic_fluid_shell/test_2d_hydrostatic_fluid_shell.cpp b/tests/2d_examples/test_2d_hydrostatic_fluid_shell/test_2d_hydrostatic_fluid_shell.cpp index d972c48c93..098c2ff9ae 100644 --- a/tests/2d_examples/test_2d_hydrostatic_fluid_shell/test_2d_hydrostatic_fluid_shell.cpp +++ b/tests/2d_examples/test_2d_hydrostatic_fluid_shell/test_2d_hydrostatic_fluid_shell.cpp @@ -181,17 +181,19 @@ void hydrostatic_fsi(const Real particle_spacing_gate, const Real particle_spaci //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared(createWaterBlockShape(), "WaterBody")); - water_block.defineBodyLevelSetShape()->correctLevelSetSign()->cleanLevelSet(0); + WaterBlock water_block_shape(createWaterBlockShape(), "WaterBody"); + FluidBody water_block(sph_system, water_block_shape.getName()); + LevelSetShape water_block_shape_level_set(water_block, water_block_shape); + water_block_shape_level_set.cleanLevelSet(0); water_block.defineMaterial(rho0_f, c_f); - water_block.generateParticles(); + water_block.generateParticles(water_block_shape_level_set); - SolidBody wall_boundary(sph_system, makeShared("Wall")); + SolidBody wall_boundary(sph_system, "Wall"); wall_boundary.defineAdaptation(1.15, particle_spacing_ref / particle_spacing_gate); wall_boundary.defineMaterial(); wall_boundary.generateParticles(DH, DL, particle_spacing_gate); - SolidBody gate(sph_system, makeShared("Gate")); + SolidBody gate(sph_system, "Gate"); gate.defineAdaptation(1.15, particle_spacing_ref / particle_spacing_gate); gate.defineMaterial(rho0_s, Youngs_modulus, poisson); gate.generateParticles(DL, BW, particle_spacing_gate, Gate_thickness); diff --git a/tests/2d_examples/test_2d_hydrostatic_fsi/hydrostatic_fsi.cpp b/tests/2d_examples/test_2d_hydrostatic_fsi/hydrostatic_fsi.cpp index 69101fe3b2..2fc28a0b84 100644 --- a/tests/2d_examples/test_2d_hydrostatic_fsi/hydrostatic_fsi.cpp +++ b/tests/2d_examples/test_2d_hydrostatic_fsi/hydrostatic_fsi.cpp @@ -199,17 +199,20 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared("WaterBody")); + WaterBlock water_block_shape("WaterBody"); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f); - water_block.generateParticles(); + water_block.generateParticles(water_block_shape); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WallBoundary wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); - SolidBody gate(sph_system, makeShared("Gate")); + Gate gate_shape("Gate"); + SolidBody gate(sph_system, gate_shape.getName()); gate.defineMaterial(rho0_s, Youngs_modulus, poisson); - gate.generateParticles(); + gate.generateParticles(gate_shape); //---------------------------------------------------------------------- // Particle and body creation of gate observer. //---------------------------------------------------------------------- @@ -245,8 +248,8 @@ int main(int ac, char *av[]) // Then fluid dynamics and the corresponding coupling dynamics. // The coupling with multi-body dynamics will be introduced at last. //---------------------------------------------------------------------- - SimpleDynamics wall_boundary_normal_direction(wall_boundary); - SimpleDynamics gate_normal_direction(gate); + SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); + SimpleDynamics gate_normal_direction(gate, gate_shape); InteractionWithUpdate gate_corrected_configuration(gate_inner); Dynamics1Level gate_stress_relaxation_first_half(gate_inner); diff --git a/tests/2d_examples/test_2d_impact_patch/impact_patch.cpp b/tests/2d_examples/test_2d_impact_patch/impact_patch.cpp index 74813a2372..b692fed43b 100644 --- a/tests/2d_examples/test_2d_impact_patch/impact_patch.cpp +++ b/tests/2d_examples/test_2d_impact_patch/impact_patch.cpp @@ -104,13 +104,14 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating bodies with corresponding materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared("WaterBody")); + WaterBlock water_block_shape("WaterBody"); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineAdaptation(1.3, 1.0); water_block.defineMaterial(rho0_f, c_f); // Using relaxed particle distribution if needed (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? water_block.generateParticles(water_block.getName()) - : water_block.generateParticles(); + : water_block.generateParticles(water_block_shape); //---------------------------------------------------------------------- // Define body relation map. // The contact map gives the topological connections between the bodies. diff --git a/tests/2d_examples/test_2d_lid_driven_cavity_corrected/lid_driven_cavity.cpp b/tests/2d_examples/test_2d_lid_driven_cavity_corrected/lid_driven_cavity.cpp index 3660719f23..21960fefc0 100644 --- a/tests/2d_examples/test_2d_lid_driven_cavity_corrected/lid_driven_cavity.cpp +++ b/tests/2d_examples/test_2d_lid_driven_cavity_corrected/lid_driven_cavity.cpp @@ -97,8 +97,8 @@ StdVec VelocityXObserverParticle() for (size_t i = 0; i < number_of_observation_point; ++i) { - Vec2d point_corrdinate(range_of_measure * (Real)i / (Real)(number_of_observation_point - 1) + start_of_measure, 0.5 * DL); - observation_points.push_back(point_corrdinate); + Vec2d point_coordinate(range_of_measure * (Real)i / (Real)(number_of_observation_point - 1) + start_of_measure, 0.5 * DL); + observation_points.push_back(point_coordinate); } return observation_points; } @@ -111,10 +111,10 @@ StdVec VelocityYObserverParticle() Real start_of_measure = 0.5 * resolution_ref; for (size_t i = 0; i < number_of_observation_point; ++i) { - Vec2d point_corrdinate(0.5 * DH, range_of_measure * (Real)i / + Vec2d point_coordinate(0.5 * DH, range_of_measure * (Real)i / (Real)(number_of_observation_point - 1) + start_of_measure); - observation_points.push_back(point_corrdinate); + observation_points.push_back(point_coordinate); } return observation_points; } @@ -136,13 +136,15 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody water_body(sph_system, makeShared("WaterBody")); + WaterBlock water_body_shape("WaterBody"); + FluidBody water_body(sph_system, water_body_shape.getName()); water_body.defineMaterial(rho0_f, c_f, mu_f); - water_body.generateParticles(); + water_body.generateParticles(water_body_shape); - SolidBody wall_boundary(sph_system, makeShared("Wall")); + WallBoundary wall_boundary_shape("Wall"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); //---------------------------------------------------------------------- // Particle and body creation of fluid observers. //---------------------------------------------------------------------- @@ -164,7 +166,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 wall_boundary_normal_direction(wall_boundary); + SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); /** Initial condition with momentum field */ SimpleDynamics solid_initial_condition(wall_boundary); /** Kernel correction matrix and transport velocity formulation. */ diff --git a/tests/2d_examples/test_2d_nonlinear_wave_fsi/nonlinear_wave_fsi.cpp b/tests/2d_examples/test_2d_nonlinear_wave_fsi/nonlinear_wave_fsi.cpp index 4df7254e6d..cbe0dceb9e 100644 --- a/tests/2d_examples/test_2d_nonlinear_wave_fsi/nonlinear_wave_fsi.cpp +++ b/tests/2d_examples/test_2d_nonlinear_wave_fsi/nonlinear_wave_fsi.cpp @@ -17,13 +17,14 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared("WaterBody")); + WaterBlock water_block_shape("WaterBody"); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); water_block.generateParticles(); SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); wall_boundary.defineMaterial(); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); SolidBody structure(sph_system, makeShared("Structure")); structure.defineMaterial(rho_s); @@ -77,7 +78,7 @@ int main(int ac, char *av[]) SimpleDynamics wave_making(wave_maker); SimpleDynamics structure_offset_position(structure, offset); - SimpleDynamics wall_boundary_normal_direction(wall_boundary); + SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); SimpleDynamics structure_normal_direction(structure); Gravity gravity(Vecd(0.0, -gravity_g)); SimpleDynamics> constant_gravity(water_block, gravity); diff --git a/tests/2d_examples/test_2d_owsc/owsc.cpp b/tests/2d_examples/test_2d_owsc/owsc.cpp index 07e9d83425..0bdeff92eb 100644 --- a/tests/2d_examples/test_2d_owsc/owsc.cpp +++ b/tests/2d_examples/test_2d_owsc/owsc.cpp @@ -17,13 +17,14 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared("WaterBody")); + WaterBlock water_block_shape("WaterBody"); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); water_block.generateParticles(); SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); wall_boundary.defineMaterial(); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); SolidBody flap(sph_system, makeShared("Flap")); flap.defineMaterial(rho0_s); @@ -65,7 +66,7 @@ int main(int ac, char *av[]) Gravity gravity(Vecd(0.0, -gravity_g)); SimpleDynamics> constant_gravity(water_block, gravity); SimpleDynamics flap_offset_position(flap, offset); - SimpleDynamics wall_boundary_normal_direction(wall_boundary); + SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); SimpleDynamics flap_normal_direction(flap); Dynamics1Level pressure_relaxation(water_block_inner, water_block_contact); diff --git a/tests/2d_examples/test_2d_poiseuille_flow/poiseuille_flow.cpp b/tests/2d_examples/test_2d_poiseuille_flow/poiseuille_flow.cpp index 0e6fb1103e..6dd308fc5f 100644 --- a/tests/2d_examples/test_2d_poiseuille_flow/poiseuille_flow.cpp +++ b/tests/2d_examples/test_2d_poiseuille_flow/poiseuille_flow.cpp @@ -111,7 +111,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- Gravity gravity(Vecd(gravity_g, 0.0)); SimpleDynamics> constant_gravity(water_block, gravity); - SimpleDynamics wall_boundary_normal_direction(wall_boundary); + SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); InteractionWithUpdate kernel_correction_complex(water_block_inner, water_wall_contact); Dynamics1Level pressure_relaxation(water_block_inner, water_wall_contact); diff --git a/tests/2d_examples/test_2d_rotation_patch/rotation_patch.cpp b/tests/2d_examples/test_2d_rotation_patch/rotation_patch.cpp index 852ba7c254..972657855c 100644 --- a/tests/2d_examples/test_2d_rotation_patch/rotation_patch.cpp +++ b/tests/2d_examples/test_2d_rotation_patch/rotation_patch.cpp @@ -118,7 +118,8 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating bodies with corresponding materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared("WaterBody")); + WaterBlock water_block_shape("WaterBody"); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineAdaptation(1.3, 1.0); water_block.defineMaterial(rho0_f, c_f); // Using relaxed particle distribution if needed diff --git a/tests/2d_examples/test_2d_sliding/sliding.cpp b/tests/2d_examples/test_2d_sliding/sliding.cpp index 6ca9d0def5..8a9052cef9 100644 --- a/tests/2d_examples/test_2d_sliding/sliding.cpp +++ b/tests/2d_examples/test_2d_sliding/sliding.cpp @@ -80,7 +80,7 @@ int main(int ac, char *av[]) SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); wall_boundary.defineMaterial(rho0_s, Youngs_modulus, poisson); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); ObserverBody cube_observer(sph_system, "CubeObserver"); cube_observer.generateParticles(observation_location); diff --git a/tests/2d_examples/test_2d_square_droplet/droplet_conservation.cpp b/tests/2d_examples/test_2d_square_droplet/droplet_conservation.cpp index 84df3e549e..e645b8dbce 100644 --- a/tests/2d_examples/test_2d_square_droplet/droplet_conservation.cpp +++ b/tests/2d_examples/test_2d_square_droplet/droplet_conservation.cpp @@ -90,7 +90,8 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating bodies with corresponding materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared("WaterBody")); + WaterBlock water_block_shape("WaterBody"); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); water_block.generateParticles(); @@ -100,7 +101,7 @@ int main(int ac, char *av[]) SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); wall_boundary.defineMaterial(); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); //---------------------------------------------------------------------- // Define body relation map. // The contact map gives the topological connections between the bodies. @@ -122,7 +123,7 @@ int main(int ac, char *av[]) // Define the numerical methods used in the simulation. // Note that there may be data dependence on the sequence of constructions. //---------------------------------------------------------------------- - SimpleDynamics wall_boundary_normal_direction(wall_boundary); + SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); Dynamics1Level water_pressure_relaxation(water_inner, water_air_contact, water_wall_contact); Dynamics1Level water_density_relaxation(water_inner, water_air_contact, water_wall_contact); diff --git a/tests/2d_examples/test_2d_standing_wave/standing_wave.cpp b/tests/2d_examples/test_2d_standing_wave/standing_wave.cpp index f0ac30ae3c..19b410e010 100644 --- a/tests/2d_examples/test_2d_standing_wave/standing_wave.cpp +++ b/tests/2d_examples/test_2d_standing_wave/standing_wave.cpp @@ -112,7 +112,8 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating bodies with corresponding materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared("WaterBody")); + WaterBlock water_block_shape("WaterBody"); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineAdaptation(1.3, 1.0); water_block.defineMaterial(rho0_f, c_f); // Using relaxed particle distribution if needed @@ -124,7 +125,7 @@ int main(int ac, char *av[]) wall_boundary.defineMaterial(); (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? wall_boundary.generateParticles(wall_boundary.getName()) - : wall_boundary.generateParticles(); + : wall_boundary.generateParticles(wall_boundary_shape); //---------------------------------------------------------------------- // Define body relation map. // The contact map gives the topological connections between the bodies. @@ -146,7 +147,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- Gravity gravity(Vecd(0.0, -gravity_g)); SimpleDynamics> constant_gravity(water_block, gravity); - SimpleDynamics wall_boundary_normal_direction(wall_boundary); + SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); InteractionWithUpdate corrected_configuration_fluid(ConstructorArgs(water_block_inner, 0.5), water_wall_contact); Dynamics1Level fluid_pressure_relaxation_correct(water_block_inner, water_wall_contact); Dynamics1Level fluid_density_relaxation(water_block_inner, water_wall_contact); diff --git a/tests/2d_examples/test_2d_static_confinement/static_confinement.cpp b/tests/2d_examples/test_2d_static_confinement/static_confinement.cpp index 308a228eb8..e932a1f352 100644 --- a/tests/2d_examples/test_2d_static_confinement/static_confinement.cpp +++ b/tests/2d_examples/test_2d_static_confinement/static_confinement.cpp @@ -109,7 +109,8 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating bodies with corresponding materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared("WaterBody")); + WaterBlock water_block_shape("WaterBody"); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f); water_block.generateParticles(); diff --git a/tests/2d_examples/test_2d_stfb/stfb.cpp b/tests/2d_examples/test_2d_stfb/stfb.cpp index 74a933a26e..728e971170 100644 --- a/tests/2d_examples/test_2d_stfb/stfb.cpp +++ b/tests/2d_examples/test_2d_stfb/stfb.cpp @@ -18,13 +18,14 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared("WaterBody")); + WaterBlock water_block_shape("WaterBody"); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); water_block.generateParticles(); SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); wall_boundary.defineMaterial(); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); TransformShape structure_shape(Transform(structure_translation), structure_halfsize, "Structure"); SolidBody structure(sph_system, structure_shape); @@ -63,7 +64,7 @@ int main(int ac, char *av[]) // boundary condition and other constraints should be defined. //---------------------------------------------------------------------- SimpleDynamics structure_offset_position(structure, offset); - SimpleDynamics wall_boundary_normal_direction(wall_boundary); + SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); SimpleDynamics str_normal(structure); Gravity gravity(Vecd(0.0, -gravity_g)); diff --git a/tests/2d_examples/test_2d_stlw/stlw.cpp b/tests/2d_examples/test_2d_stlw/stlw.cpp index 70198f4412..5a0ce63b33 100644 --- a/tests/2d_examples/test_2d_stlw/stlw.cpp +++ b/tests/2d_examples/test_2d_stlw/stlw.cpp @@ -24,7 +24,7 @@ int main(int ac, char *av[]) SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); wall_boundary.defineMaterial(); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); //---------------------------------------------------------------------- // Define body relation map. // The contact map gives the topological connections between the bodies. @@ -43,7 +43,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Define all numerical methods which are used in this case. //---------------------------------------------------------------------- - SimpleDynamics wall_boundary_normal_direction(wall_boundary); + SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); Gravity gravity(Vecd(0.0, -gravity_g)); SimpleDynamics> constant_gravity(water_block, gravity); diff --git a/tests/2d_examples/test_2d_tethered_dead_fish_in_flow/src/tethered_dead_fish_in_flow.cpp b/tests/2d_examples/test_2d_tethered_dead_fish_in_flow/src/tethered_dead_fish_in_flow.cpp index 3d06be6cc5..baeae5a3b6 100644 --- a/tests/2d_examples/test_2d_tethered_dead_fish_in_flow/src/tethered_dead_fish_in_flow.cpp +++ b/tests/2d_examples/test_2d_tethered_dead_fish_in_flow/src/tethered_dead_fish_in_flow.cpp @@ -300,7 +300,7 @@ int main(int ac, char *av[]) /** Periodic BCs in x direction. */ PeriodicAlongAxis periodic_along_x(water_block_shape.getBounds(), xAxis); PeriodicConditionUsingCellLinkedList periodic_condition(water_block, periodic_along_x); - SimpleDynamics wall_boundary_normal_direction(wall_boundary); + SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); SimpleDynamics fish_body_normal_direction(fish_body); /** Corrected configuration.*/ InteractionWithUpdate fish_body_corrected_configuration(fish_body_inner); diff --git a/tests/2d_examples/test_2d_two_phase_dambreak/two_phase_dambreak.cpp b/tests/2d_examples/test_2d_two_phase_dambreak/two_phase_dambreak.cpp index 3e98e33f71..82afc0ed18 100644 --- a/tests/2d_examples/test_2d_two_phase_dambreak/two_phase_dambreak.cpp +++ b/tests/2d_examples/test_2d_two_phase_dambreak/two_phase_dambreak.cpp @@ -19,7 +19,8 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared("WaterBody")); + WaterBlock water_block_shape("WaterBody"); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f); water_block.generateParticles(); @@ -29,7 +30,7 @@ int main(int ac, char *av[]) SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); wall_boundary.defineMaterial(); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); ObserverBody fluid_observer(sph_system, "FluidObserver"); fluid_observer.generateParticles(observation_location); diff --git a/tests/2d_examples/test_2d_water_entry_exit/test_2d_water_entry_exit.cpp b/tests/2d_examples/test_2d_water_entry_exit/test_2d_water_entry_exit.cpp index ffa7fada1d..3f548dfd1c 100644 --- a/tests/2d_examples/test_2d_water_entry_exit/test_2d_water_entry_exit.cpp +++ b/tests/2d_examples/test_2d_water_entry_exit/test_2d_water_entry_exit.cpp @@ -195,7 +195,7 @@ int main(int ac, char *av[]) SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); wall_boundary.defineMaterial(); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); SolidBody cylinder(sph_system, makeShared("Cylinder")); cylinder.defineAdaptationRatios(1.15, 1.0); @@ -286,7 +286,7 @@ int main(int ac, char *av[]) Gravity gravity(Vecd(0.0, -gravity_g)); SimpleDynamics> constant_gravity(water_block, gravity); InteractionWithUpdate free_stream_surface_indicator(water_block_inner, water_block_contact); - SimpleDynamics wall_boundary_normal_direction(wall_boundary); + SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); SimpleDynamics cylinder_normal_direction(cylinder); Dynamics1Level fluid_pressure_relaxation(water_block_inner, water_block_contact); diff --git a/tests/3d_examples/test_3d_dambreak/dambreak.cpp b/tests/3d_examples/test_3d_dambreak/dambreak.cpp index fc66fb102f..9c8edb8cda 100644 --- a/tests/3d_examples/test_3d_dambreak/dambreak.cpp +++ b/tests/3d_examples/test_3d_dambreak/dambreak.cpp @@ -79,7 +79,7 @@ int main(int ac, char *av[]) SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); wall_boundary.defineMaterial(); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); ObserverBody fluid_observer(sph_system, "FluidObserver"); fluid_observer.generateParticles(createObservationPoints()); @@ -106,7 +106,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- Gravity gravity(Vec3d(0.0, -gravity_g, 0.0)); SimpleDynamics> constant_gravity(water_block, gravity); - SimpleDynamics wall_boundary_normal_direction(wall_boundary); + SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); Dynamics1Level pressure_relaxation(water_block_inner, water_wall_contact); Dynamics1Level density_relaxation(water_block_inner, water_wall_contact); diff --git a/tests/3d_examples/test_3d_dambreak_elastic_plate_shell/test_3d_dambreak_elastic_plate_shell.cpp b/tests/3d_examples/test_3d_dambreak_elastic_plate_shell/test_3d_dambreak_elastic_plate_shell.cpp index 6ccf0cd76c..de10aa1754 100644 --- a/tests/3d_examples/test_3d_dambreak_elastic_plate_shell/test_3d_dambreak_elastic_plate_shell.cpp +++ b/tests/3d_examples/test_3d_dambreak_elastic_plate_shell/test_3d_dambreak_elastic_plate_shell.cpp @@ -162,13 +162,14 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating bodies with corresponding materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared("WaterBody")); + WaterBlock water_block_shape("WaterBody"); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); water_block.generateParticles(); SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); wall_boundary.defineMaterial(); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); SolidBody gate(sph_system, makeShared("Gate")); gate.defineMaterial(); @@ -213,7 +214,7 @@ int main(int ac, char *av[]) // Note that there may be data dependence on the sequence of constructions. //---------------------------------------------------------------------- // solid - SimpleDynamics wall_boundary_normal_direction(wall_boundary); + SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); SimpleDynamics gate_normal_direction(gate); SimpleDynamics update_gate_position(gate); // Shell diff --git a/tests/3d_examples/test_3d_nonlinear_wave_fsi/nonlinear_wave_fsi.cpp b/tests/3d_examples/test_3d_nonlinear_wave_fsi/nonlinear_wave_fsi.cpp index df702653f5..0ddbe7d656 100644 --- a/tests/3d_examples/test_3d_nonlinear_wave_fsi/nonlinear_wave_fsi.cpp +++ b/tests/3d_examples/test_3d_nonlinear_wave_fsi/nonlinear_wave_fsi.cpp @@ -73,13 +73,15 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared("WaterBody")); + WaterBlock water_block_shape("WaterBody"); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); water_block.generateParticles(); - SolidBody wall_boundary(sph_system, makeShared("Wall")); + WallBoundary wall_boundary_shape("Wall"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); SolidBody structure(sph_system, makeShared("Structure")); structure.defineMaterial(StructureDensity); @@ -145,7 +147,7 @@ int main(int ac, char *av[]) Gravity gravity(Vecd(0.0, 0.0, -gravity_g)); SimpleDynamics> constant_gravity_to_fluid(water_block, gravity); SimpleDynamics structure_offset_position(structure, offset); - SimpleDynamics wall_boundary_normal_direction(wall_boundary); + SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); SimpleDynamics structure_normal_direction(structure); InteractionWithUpdate structure_corrected_configuration(structure_inner); diff --git a/tests/3d_examples/test_3d_repose_angle/repose_angle.cpp b/tests/3d_examples/test_3d_repose_angle/repose_angle.cpp index dae594254e..66b526cec1 100644 --- a/tests/3d_examples/test_3d_repose_angle/repose_angle.cpp +++ b/tests/3d_examples/test_3d_repose_angle/repose_angle.cpp @@ -93,7 +93,7 @@ int main(int ac, char *av[]) SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); wall_boundary.defineMaterial(); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); //---------------------------------------------------------------------- // Define body relation map. // The contact map gives the topological connections between the bodies. @@ -155,7 +155,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- Gravity gravity(Vec3d(0.0, -gravity_g, 0.0)); SimpleDynamics> constant_gravity(soil_block, gravity); - SimpleDynamics wall_boundary_normal_direction(wall_boundary); + SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); SimpleDynamics soil_initial_condition(soil_block); Dynamics1Level granular_stress_relaxation(soil_block_inner, soil_block_contact); diff --git a/tests/3d_examples/test_3d_stfb/stfb.cpp b/tests/3d_examples/test_3d_stfb/stfb.cpp index b2daf54623..c471c59818 100644 --- a/tests/3d_examples/test_3d_stfb/stfb.cpp +++ b/tests/3d_examples/test_3d_stfb/stfb.cpp @@ -18,13 +18,14 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared("WaterBody")); + WaterBlock water_block_shape("WaterBody"); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); water_block.generateParticles(); SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); wall_boundary.defineMaterial(); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); SolidBody structure(sph_system, makeShared("Structure")); structure.defineMaterial(rho_s); @@ -66,7 +67,7 @@ int main(int ac, char *av[]) // The coupling with multi-body dynamics will be introduced at last. //---------------------------------------------------------------------- SimpleDynamics structure_offset_position(structure, offset); - SimpleDynamics wall_boundary_normal_direction(wall_boundary); + SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); SimpleDynamics str_normal(structure); Gravity gravity(Vec3d(0.0, 0.0, -gravity_g)); diff --git a/tests/3d_examples/test_3d_stlw/stlw.cpp b/tests/3d_examples/test_3d_stlw/stlw.cpp index 7bc81232e7..31fed0c503 100644 --- a/tests/3d_examples/test_3d_stlw/stlw.cpp +++ b/tests/3d_examples/test_3d_stlw/stlw.cpp @@ -17,13 +17,14 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared("WaterBody")); + WaterBlock water_block_shape("WaterBody"); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); water_block.generateParticles(); SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); wall_boundary.defineMaterial(); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); //---------------------------------------------------------------------- // Define body relation map. // The contact map gives the topological connections between the bodies. @@ -51,7 +52,7 @@ int main(int ac, char *av[]) // Then fluid dynamics and the corresponding coupling dynamics. // The coupling with multi-body dynamics will be introduced at last. //---------------------------------------------------------------------- - SimpleDynamics wall_boundary_normal_direction(wall_boundary); + SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); Gravity gravity(Vecd(0.0, 0.0, -gravity_g)); SimpleDynamics> constant_gravity_to_fluid(water_block, gravity); diff --git a/tests/3d_examples/test_3d_taylor_bar_UL/taylor_bar_UL.cpp b/tests/3d_examples/test_3d_taylor_bar_UL/taylor_bar_UL.cpp index 943e53bc6f..6d45f764f4 100644 --- a/tests/3d_examples/test_3d_taylor_bar_UL/taylor_bar_UL.cpp +++ b/tests/3d_examples/test_3d_taylor_bar_UL/taylor_bar_UL.cpp @@ -21,8 +21,8 @@ int main(int ac, char *av[]) SolidBody wall_boundary(system, makeShared("Wall")); wall_boundary.defineMaterial(rho0_s, Youngs_modulus, poisson); - wall_boundary.generateParticles(); - + wall_boundary.generateParticles(wall_boundary_shape); + ObserverBody my_observer(system, "MyObserver"); StdVec observation_location = {Vecd(0.0, 0.0, PW)}; my_observer.generateParticles(observation_location); diff --git a/tests/extra_source_and_tests/test_2d_T_pipe_VIPO_shell/T_pipe_VIPO_shell.cpp b/tests/extra_source_and_tests/test_2d_T_pipe_VIPO_shell/T_pipe_VIPO_shell.cpp index 64e7bbc479..8aaa8ff2cb 100644 --- a/tests/extra_source_and_tests/test_2d_T_pipe_VIPO_shell/T_pipe_VIPO_shell.cpp +++ b/tests/extra_source_and_tests/test_2d_T_pipe_VIPO_shell/T_pipe_VIPO_shell.cpp @@ -257,7 +257,8 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared("WaterBody")); + WaterBlock water_block_shape("WaterBody"); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); ParticleBuffer in_outlet_particle_buffer(0.5); water_block.generateParticlesWithReserve(in_outlet_particle_buffer); diff --git a/tests/extra_source_and_tests/test_2d_mixed_poiseuille_flow/mixed_poiseuille_flow.cpp b/tests/extra_source_and_tests/test_2d_mixed_poiseuille_flow/mixed_poiseuille_flow.cpp index ad66a467f8..5cd9ddbd2e 100644 --- a/tests/extra_source_and_tests/test_2d_mixed_poiseuille_flow/mixed_poiseuille_flow.cpp +++ b/tests/extra_source_and_tests/test_2d_mixed_poiseuille_flow/mixed_poiseuille_flow.cpp @@ -149,14 +149,15 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating bodies with corresponding materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared("WaterBody")); + WaterBlock water_block_shape("WaterBody"); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); ParticleBuffer in_outlet_particle_buffer(0.5); water_block.generateParticlesWithReserve(in_outlet_particle_buffer); SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); wall_boundary.defineMaterial(); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); ObserverBody velocity_observer(sph_system, "VelocityObserver"); velocity_observer.generateParticles(observer_location); @@ -183,7 +184,7 @@ int main(int ac, char *av[]) // Finally, the auxillary models such as time step estimator, initial condition, // boundary condition and other constraints should be defined. //---------------------------------------------------------------------- - SimpleDynamics wall_boundary_normal_direction(wall_boundary); + SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); InteractionDynamics kernel_summation(water_block_inner, water_block_contact); InteractionWithUpdate boundary_indicator(water_block_inner, water_block_contact); diff --git a/tests/extra_source_and_tests/test_2d_modified_T_flow/modified_T_flow.cpp b/tests/extra_source_and_tests/test_2d_modified_T_flow/modified_T_flow.cpp index 932c2eb41b..bc0ea476c3 100644 --- a/tests/extra_source_and_tests/test_2d_modified_T_flow/modified_T_flow.cpp +++ b/tests/extra_source_and_tests/test_2d_modified_T_flow/modified_T_flow.cpp @@ -150,14 +150,15 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating bodies with corresponding materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared("WaterBody")); + WaterBlock water_block_shape("WaterBody"); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); ParticleBuffer in_outlet_particle_buffer(0.5); water_block.generateParticlesWithReserve(in_outlet_particle_buffer); SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); wall_boundary.defineMaterial(); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); ObserverBody velocity_observer(sph_system, "VelocityObserver"); velocity_observer.generateParticles(observer_location); @@ -184,7 +185,7 @@ int main(int ac, char *av[]) // Finally, the auxillary models such as time step estimator, initial condition, // boundary condition and other constraints should be defined. //---------------------------------------------------------------------- - SimpleDynamics wall_boundary_normal_direction(wall_boundary); + SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); InteractionDynamics kernel_summation(water_block_inner, water_block_contact); InteractionWithUpdate boundary_indicator(water_block_inner, water_block_contact); diff --git a/tests/extra_source_and_tests/test_2d_pulsatile_poiseuille_flow/pulsatile_poiseuille_flow.cpp b/tests/extra_source_and_tests/test_2d_pulsatile_poiseuille_flow/pulsatile_poiseuille_flow.cpp index e93beb62b9..42c6e8ce1f 100644 --- a/tests/extra_source_and_tests/test_2d_pulsatile_poiseuille_flow/pulsatile_poiseuille_flow.cpp +++ b/tests/extra_source_and_tests/test_2d_pulsatile_poiseuille_flow/pulsatile_poiseuille_flow.cpp @@ -132,14 +132,15 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating bodies with corresponding materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared("WaterBody")); + WaterBlock water_block_shape("WaterBody"); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); ParticleBuffer in_outlet_particle_buffer(0.5); water_block.generateParticlesWithReserve(in_outlet_particle_buffer); SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); wall_boundary.defineMaterial(); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); ObserverBody velocity_observer(sph_system, "VelocityObserver"); velocity_observer.generateParticles(observer_location); @@ -166,7 +167,7 @@ int main(int ac, char *av[]) // Finally, the auxillary models such as time step estimator, initial condition, // boundary condition and other constraints should be defined. //---------------------------------------------------------------------- - SimpleDynamics wall_boundary_normal_direction(wall_boundary); + SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); InteractionDynamics kernel_summation(water_block_inner, water_block_contact); InteractionWithUpdate boundary_indicator(water_block_inner, water_block_contact); diff --git a/tests/optimization/test_2d_VP_heat_flux_optimization/VP_heat_flux_optimization.cpp b/tests/optimization/test_2d_VP_heat_flux_optimization/VP_heat_flux_optimization.cpp index 49e9972201..5df0717db1 100644 --- a/tests/optimization/test_2d_VP_heat_flux_optimization/VP_heat_flux_optimization.cpp +++ b/tests/optimization/test_2d_VP_heat_flux_optimization/VP_heat_flux_optimization.cpp @@ -214,7 +214,7 @@ TEST(test_optimization, test_problem4_optimized) diffusion_body.generateParticles(); SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); //---------------------------------------------------------------------- // Define body relation map. @@ -280,7 +280,7 @@ TEST(test_optimization, test_problem4_optimized) // Note that there may be data dependence on the constructors of these methods. //---------------------------------------------------------------------- SimpleDynamics diffusion_body_normal_direction(diffusion_body); - SimpleDynamics wall_boundary_normal_direction(wall_boundary); + SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); InteractionSplit> temperature_splitting_pde_complex(diffusion_body_inner, diffusion_body_contact, "Phi"); diff --git a/tests/optimization/test_2d_VP_heat_flux_steady/VP_heat_flux_steady.cpp b/tests/optimization/test_2d_VP_heat_flux_steady/VP_heat_flux_steady.cpp index 0cde3ee29c..e2f6f2bfdb 100644 --- a/tests/optimization/test_2d_VP_heat_flux_steady/VP_heat_flux_steady.cpp +++ b/tests/optimization/test_2d_VP_heat_flux_steady/VP_heat_flux_steady.cpp @@ -175,7 +175,7 @@ TEST(test_optimization, test_problem4_non_optimization) SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); wall_boundary.defineMaterial(); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); //---------------------------- ------------------------------------------ // Particle and body creation of temperature observers. //---------------------------------------------------------------------- @@ -199,7 +199,7 @@ TEST(test_optimization, test_problem4_non_optimization) // Note that there may be data dependence on the constructors of these methods. //---------------------------------------------------------------------- SimpleDynamics diffusion_body_normal_direction(diffusion_body); - SimpleDynamics wall_boundary_normal_direction(wall_boundary); + SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); InteractionSplit> temperature_splitting(diffusion_body_inner, diffusion_body_contact, "Phi"); diff --git a/tests/optimization/test_2d_VP_same_sink_optimization/VP_same_sink_optimization.cpp b/tests/optimization/test_2d_VP_same_sink_optimization/VP_same_sink_optimization.cpp index 0ac854c144..7ddf798a79 100644 --- a/tests/optimization/test_2d_VP_same_sink_optimization/VP_same_sink_optimization.cpp +++ b/tests/optimization/test_2d_VP_same_sink_optimization/VP_same_sink_optimization.cpp @@ -196,7 +196,7 @@ TEST(test_optimization, test_problem1_optimized) diffusion_body.generateParticles(); SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); //---------------------------------------------------------------------- // Define body relation map. // The contact map gives the topological connections between the bodies. @@ -259,7 +259,7 @@ TEST(test_optimization, test_problem1_optimized) // Note that there may be data dependence on the constructors of tested methods. //---------------------------------------------------------------------- SimpleDynamics diffusion_body_normal_direction(diffusion_body); - SimpleDynamics wall_boundary_normal_direction(wall_boundary); + SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); InteractionSplit> temperature_splitting_pde_complex(diffusion_body_inner, diffusion_body_contact, "Phi"); diff --git a/tests/optimization/test_2d_VP_same_sink_steady/VP_same_sink_steady.cpp b/tests/optimization/test_2d_VP_same_sink_steady/VP_same_sink_steady.cpp index 2a182cb18a..f4fdc38e92 100644 --- a/tests/optimization/test_2d_VP_same_sink_steady/VP_same_sink_steady.cpp +++ b/tests/optimization/test_2d_VP_same_sink_steady/VP_same_sink_steady.cpp @@ -162,7 +162,7 @@ TEST(test_optimization, test_problem1_non_optimized) diffusion_body.generateParticles(); SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); //---------------------------- ------------------------------------------ // Particle and body creation of temperature observers. //---------------------------------------------------------------------- @@ -185,7 +185,7 @@ TEST(test_optimization, test_problem1_non_optimized) // Note that there may be data dependence on the constructors of these methods. //---------------------------------------------------------------------- SimpleDynamics diffusion_body_normal_direction(diffusion_body); - SimpleDynamics wall_boundary_normal_direction(wall_boundary); + SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); InteractionSplit> temperature_splitting(diffusion_body_inner, diffusion_body_contact, "Phi"); diff --git a/tests/tests_sycl/2d_examples/test_2d_dambreak_sycl/dambreak_sycl.cpp b/tests/tests_sycl/2d_examples/test_2d_dambreak_sycl/dambreak_sycl.cpp index 47380f39c7..30c3c868e8 100644 --- a/tests/tests_sycl/2d_examples/test_2d_dambreak_sycl/dambreak_sycl.cpp +++ b/tests/tests_sycl/2d_examples/test_2d_dambreak_sycl/dambreak_sycl.cpp @@ -64,7 +64,7 @@ int main(int ac, char *av[]) SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); wall_boundary.defineMaterial(); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); ObserverBody fluid_observer(sph_system, "FluidObserver"); StdVec observation_location = {Vecd(DL, 0.2)}; diff --git a/tests/unit_tests_src/shared/particle_dynamics/fluid_dynamics/test_2d_velocity_gradient/2d_velocity_gradient.cpp b/tests/unit_tests_src/shared/particle_dynamics/fluid_dynamics/test_2d_velocity_gradient/2d_velocity_gradient.cpp index da8858fe13..bbc4521a29 100644 --- a/tests/unit_tests_src/shared/particle_dynamics/fluid_dynamics/test_2d_velocity_gradient/2d_velocity_gradient.cpp +++ b/tests/unit_tests_src/shared/particle_dynamics/fluid_dynamics/test_2d_velocity_gradient/2d_velocity_gradient.cpp @@ -127,7 +127,7 @@ int main(int ac, char *av[]) SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); wall_boundary.defineMaterial(); - wall_boundary.generateParticles(); + wall_boundary.generateParticles(wall_boundary_shape); //---------------------------------------------------------------------- // Define body relation map. // The contact map gives the topological connections between the bodies. @@ -146,7 +146,7 @@ int main(int ac, char *av[]) // Note that there may be data dependence on the sequence of constructions. //---------------------------------------------------------------------- SimpleDynamics initial_condition(water_block); - SimpleDynamics wall_boundary_normal_direction(wall_boundary); + SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); PeriodicAlongAxis periodic_along_x(water_block_shape.getBounds(), xAxis); PeriodicConditionUsingCellLinkedList periodic_condition(water_block, periodic_along_x); InteractionDynamics distance_to_wall(water_wall_contact); From 20adb4fb0af02f281ac8ae0bb690d3e7857b0c8e Mon Sep 17 00:00:00 2001 From: Xiangyu Hu Date: Sat, 21 Sep 2024 21:58:29 +0000 Subject: [PATCH 07/13] batch replace --- .../test_2d_T_shaped_pipe/T_shaped_pipe.cpp | 3 ++- .../channel_flow_shell.cpp | 2 +- .../test_2d_column_collapse/column_collapse.cpp | 3 ++- tests/2d_examples/test_2d_dambreak/Dambreak.cpp | 2 +- .../2d_eulerian_flow_around_cylinder_LG.cpp | 2 +- .../nonlinear_wave_fsi.cpp | 12 +++++++----- tests/2d_examples/test_2d_owsc/owsc.cpp | 10 ++++++---- .../test_2d_rotation_patch/rotation_patch.cpp | 2 +- tests/2d_examples/test_2d_sliding/sliding.cpp | 3 ++- .../test_2d_square_droplet/droplet_conservation.cpp | 5 +++-- .../test_2d_standing_wave/standing_wave.cpp | 5 +++-- .../static_confinement.cpp | 2 +- tests/2d_examples/test_2d_stfb/stfb.cpp | 7 ++++--- tests/2d_examples/test_2d_stlw/stlw.cpp | 5 +++-- .../two_phase_dambreak.cpp | 5 +++-- .../test_2d_water_entry_exit.cpp | 2 +- tests/3d_examples/test_3d_dambreak/dambreak.cpp | 5 +++-- .../test_3d_dambreak_elastic_plate_shell.cpp | 5 +++-- .../nonlinear_wave_fsi.cpp | 7 ++++--- .../test_3d_repose_angle/repose_angle.cpp | 3 ++- tests/3d_examples/test_3d_stfb/stfb.cpp | 10 ++++++---- tests/3d_examples/test_3d_stlw/stlw.cpp | 5 +++-- .../mixed_poiseuille_flow.cpp | 3 ++- .../test_2d_modified_T_flow/modified_T_flow.cpp | 3 ++- .../pulsatile_poiseuille_flow.cpp | 3 ++- .../VP_heat_flux_optimization.cpp | 3 ++- .../VP_heat_flux_steady.cpp | 3 ++- .../VP_same_sink_optimization.cpp | 3 ++- .../VP_same_sink_steady.cpp | 3 ++- .../test_2d_dambreak_sycl/dambreak_sycl.cpp | 5 +++-- .../2d_velocity_gradient.cpp | 3 ++- 31 files changed, 81 insertions(+), 53 deletions(-) diff --git a/tests/2d_examples/test_2d_T_shaped_pipe/T_shaped_pipe.cpp b/tests/2d_examples/test_2d_T_shaped_pipe/T_shaped_pipe.cpp index 3690ad350f..66f7b2f8e5 100644 --- a/tests/2d_examples/test_2d_T_shaped_pipe/T_shaped_pipe.cpp +++ b/tests/2d_examples/test_2d_T_shaped_pipe/T_shaped_pipe.cpp @@ -104,7 +104,8 @@ int main(int ac, char *av[]) water_block.defineMaterial(rho0_f, c_f, mu_f); ParticleBuffer inlet_particle_buffer(0.5); water_block.generateParticlesWithReserve(inlet_particle_buffer); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WallBoundary wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); wall_boundary.generateParticles(wall_boundary_shape); //---------------------------------------------------------------------- diff --git a/tests/2d_examples/test_2d_channel_flow_fluid_shell/channel_flow_shell.cpp b/tests/2d_examples/test_2d_channel_flow_fluid_shell/channel_flow_shell.cpp index 0e0da81710..b35dbcf5a6 100644 --- a/tests/2d_examples/test_2d_channel_flow_fluid_shell/channel_flow_shell.cpp +++ b/tests/2d_examples/test_2d_channel_flow_fluid_shell/channel_flow_shell.cpp @@ -169,7 +169,7 @@ void channel_flow_shell(const Real resolution_ref, const Real wall_thickness) WaterBlock water_block_shape = WaterBlock(createWaterBlockShape(), "WaterBody"); FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); - water_block.generateParticles(); + water_block.generateParticles(water_block_shape); SolidBody wall_boundary(sph_system, makeShared("Wall")); wall_boundary.defineMaterial(); diff --git a/tests/2d_examples/test_2d_column_collapse/column_collapse.cpp b/tests/2d_examples/test_2d_column_collapse/column_collapse.cpp index bcf6bc0d16..17069a76ed 100644 --- a/tests/2d_examples/test_2d_column_collapse/column_collapse.cpp +++ b/tests/2d_examples/test_2d_column_collapse/column_collapse.cpp @@ -77,7 +77,8 @@ int main(int ac, char *av[]) soil_block.defineMaterial(rho0_s, c_s, Youngs_modulus, poisson, friction_angle); soil_block.generateParticles(); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WallBoundary wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); wall_boundary.generateParticles(wall_boundary_shape); //---------------------------------------------------------------------- diff --git a/tests/2d_examples/test_2d_dambreak/Dambreak.cpp b/tests/2d_examples/test_2d_dambreak/Dambreak.cpp index 7e9e2ab26d..d679d00bf1 100644 --- a/tests/2d_examples/test_2d_dambreak/Dambreak.cpp +++ b/tests/2d_examples/test_2d_dambreak/Dambreak.cpp @@ -65,7 +65,7 @@ int main(int ac, char *av[]) water_block.generateParticles(initial_water_block); WallBoundary wall_boundary_shape("WallBoundary"); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); wall_boundary.generateParticles(wall_boundary_shape); diff --git a/tests/2d_examples/test_2d_eulerian_flow_around_cylinder_LG/2d_eulerian_flow_around_cylinder_LG.cpp b/tests/2d_examples/test_2d_eulerian_flow_around_cylinder_LG/2d_eulerian_flow_around_cylinder_LG.cpp index 85fd7c2009..68b0ef196a 100644 --- a/tests/2d_examples/test_2d_eulerian_flow_around_cylinder_LG/2d_eulerian_flow_around_cylinder_LG.cpp +++ b/tests/2d_examples/test_2d_eulerian_flow_around_cylinder_LG/2d_eulerian_flow_around_cylinder_LG.cpp @@ -96,7 +96,7 @@ int main(int ac, char *av[]) water_block.defineMaterial(rho0_f, c_f, mu_f); (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? water_block.generateParticles(water_block.getName()) - : water_block.generateParticles(); + : water_block.generateParticles(water_block_shape); SolidBody cylinder(sph_system, makeShared("Cylinder")); cylinder.defineAdaptationRatios(1.3, 2.0); diff --git a/tests/2d_examples/test_2d_nonlinear_wave_fsi/nonlinear_wave_fsi.cpp b/tests/2d_examples/test_2d_nonlinear_wave_fsi/nonlinear_wave_fsi.cpp index cbe0dceb9e..16a139bbaa 100644 --- a/tests/2d_examples/test_2d_nonlinear_wave_fsi/nonlinear_wave_fsi.cpp +++ b/tests/2d_examples/test_2d_nonlinear_wave_fsi/nonlinear_wave_fsi.cpp @@ -20,15 +20,17 @@ int main(int ac, char *av[]) WaterBlock water_block_shape("WaterBody"); FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); - water_block.generateParticles(); + water_block.generateParticles(water_block_shape); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WallBoundary wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); wall_boundary.generateParticles(wall_boundary_shape); - SolidBody structure(sph_system, makeShared("Structure")); + FloatingStructure floating_structure_shape("Structure"); + SolidBody structure(sph_system, floating_structure_shape.getName()); structure.defineMaterial(rho_s); - structure.generateParticles(); + structure.generateParticles(floating_structure_shape); ObserverBody observer(sph_system, "Observer"); observer.defineAdaptationRatios(1.15, 2.0); @@ -79,7 +81,7 @@ int main(int ac, char *av[]) SimpleDynamics structure_offset_position(structure, offset); SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); - SimpleDynamics structure_normal_direction(structure); + SimpleDynamics structure_normal_direction(structure, floating_structure_shape); Gravity gravity(Vecd(0.0, -gravity_g)); SimpleDynamics> constant_gravity(water_block, gravity); diff --git a/tests/2d_examples/test_2d_owsc/owsc.cpp b/tests/2d_examples/test_2d_owsc/owsc.cpp index 0bdeff92eb..2d29736de3 100644 --- a/tests/2d_examples/test_2d_owsc/owsc.cpp +++ b/tests/2d_examples/test_2d_owsc/owsc.cpp @@ -20,15 +20,17 @@ int main(int ac, char *av[]) WaterBlock water_block_shape("WaterBody"); FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); - water_block.generateParticles(); + water_block.generateParticles(water_block_shape); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WallBoundary wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); wall_boundary.generateParticles(wall_boundary_shape); - SolidBody flap(sph_system, makeShared("Flap")); + Flap flap_shape("Flap"); + SolidBody flap(sph_system, flap_shape.getName()); flap.defineMaterial(rho0_s); - flap.generateParticles(); + flap.generateParticles(flap_shape); ObserverBody observer(sph_system, "Observer"); observer.generateParticles(creatObserverPositions()); diff --git a/tests/2d_examples/test_2d_rotation_patch/rotation_patch.cpp b/tests/2d_examples/test_2d_rotation_patch/rotation_patch.cpp index 972657855c..91fffb0d56 100644 --- a/tests/2d_examples/test_2d_rotation_patch/rotation_patch.cpp +++ b/tests/2d_examples/test_2d_rotation_patch/rotation_patch.cpp @@ -125,7 +125,7 @@ int main(int ac, char *av[]) // Using relaxed particle distribution if needed (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? water_block.generateParticles(water_block.getName()) - : water_block.generateParticles(); + : water_block.generateParticles(water_block_shape); ObserverBody fluid_observer(sph_system, "FluidObserver"); StdVec observation_location = {Vecd(0.0, 0.0)}; diff --git a/tests/2d_examples/test_2d_sliding/sliding.cpp b/tests/2d_examples/test_2d_sliding/sliding.cpp index 8a9052cef9..60d1e91e09 100644 --- a/tests/2d_examples/test_2d_sliding/sliding.cpp +++ b/tests/2d_examples/test_2d_sliding/sliding.cpp @@ -78,7 +78,8 @@ int main(int ac, char *av[]) free_cube.defineMaterial(rho0_s, Youngs_modulus, poisson); free_cube.generateParticles(); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WallBoundary wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(rho0_s, Youngs_modulus, poisson); wall_boundary.generateParticles(wall_boundary_shape); diff --git a/tests/2d_examples/test_2d_square_droplet/droplet_conservation.cpp b/tests/2d_examples/test_2d_square_droplet/droplet_conservation.cpp index e645b8dbce..55695d19fd 100644 --- a/tests/2d_examples/test_2d_square_droplet/droplet_conservation.cpp +++ b/tests/2d_examples/test_2d_square_droplet/droplet_conservation.cpp @@ -93,13 +93,14 @@ int main(int ac, char *av[]) WaterBlock water_block_shape("WaterBody"); FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); - water_block.generateParticles(); + water_block.generateParticles(water_block_shape); FluidBody air_block(sph_system, makeShared("AirBody")); air_block.defineMaterial(rho0_a, c_f, mu_a); air_block.generateParticles(); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WallBoundary wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); wall_boundary.generateParticles(wall_boundary_shape); //---------------------------------------------------------------------- diff --git a/tests/2d_examples/test_2d_standing_wave/standing_wave.cpp b/tests/2d_examples/test_2d_standing_wave/standing_wave.cpp index 19b410e010..461b5db67d 100644 --- a/tests/2d_examples/test_2d_standing_wave/standing_wave.cpp +++ b/tests/2d_examples/test_2d_standing_wave/standing_wave.cpp @@ -119,9 +119,10 @@ int main(int ac, char *av[]) // Using relaxed particle distribution if needed (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? water_block.generateParticles(water_block.getName()) - : water_block.generateParticles(); + : water_block.generateParticles(water_block_shape); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WallBoundary wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? wall_boundary.generateParticles(wall_boundary.getName()) diff --git a/tests/2d_examples/test_2d_static_confinement/static_confinement.cpp b/tests/2d_examples/test_2d_static_confinement/static_confinement.cpp index e932a1f352..a17645162f 100644 --- a/tests/2d_examples/test_2d_static_confinement/static_confinement.cpp +++ b/tests/2d_examples/test_2d_static_confinement/static_confinement.cpp @@ -112,7 +112,7 @@ int main(int ac, char *av[]) WaterBlock water_block_shape("WaterBody"); FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f); - water_block.generateParticles(); + water_block.generateParticles(water_block_shape); ObserverBody fluid_observer(sph_system, "FluidObserver"); fluid_observer.generateParticles(observation_location); diff --git a/tests/2d_examples/test_2d_stfb/stfb.cpp b/tests/2d_examples/test_2d_stfb/stfb.cpp index 728e971170..3fb2120146 100644 --- a/tests/2d_examples/test_2d_stfb/stfb.cpp +++ b/tests/2d_examples/test_2d_stfb/stfb.cpp @@ -21,16 +21,17 @@ int main(int ac, char *av[]) WaterBlock water_block_shape("WaterBody"); FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); - water_block.generateParticles(); + water_block.generateParticles(water_block_shape); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WallBoundary wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); wall_boundary.generateParticles(wall_boundary_shape); TransformShape structure_shape(Transform(structure_translation), structure_halfsize, "Structure"); SolidBody structure(sph_system, structure_shape); structure.defineMaterial(rho_s); - structure.generateParticles(); + structure.generateParticles(floating_structure_shape); ObserverBody observer(sph_system, "Observer"); observer.defineAdaptationRatios(1.15, 2.0); diff --git a/tests/2d_examples/test_2d_stlw/stlw.cpp b/tests/2d_examples/test_2d_stlw/stlw.cpp index 5a0ce63b33..daeab58ed1 100644 --- a/tests/2d_examples/test_2d_stlw/stlw.cpp +++ b/tests/2d_examples/test_2d_stlw/stlw.cpp @@ -20,9 +20,10 @@ int main(int ac, char *av[]) TransformShape water_block_shape(Transform(water_block_translation), water_block_halfsize, "WaterBody"); FluidBody water_block(sph_system, water_block_shape); water_block.defineMaterial(rho0_f, c_f, mu_f); - water_block.generateParticles(); + water_block.generateParticles(water_block_shape); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WallBoundary wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); wall_boundary.generateParticles(wall_boundary_shape); //---------------------------------------------------------------------- diff --git a/tests/2d_examples/test_2d_two_phase_dambreak/two_phase_dambreak.cpp b/tests/2d_examples/test_2d_two_phase_dambreak/two_phase_dambreak.cpp index 82afc0ed18..99e1819d56 100644 --- a/tests/2d_examples/test_2d_two_phase_dambreak/two_phase_dambreak.cpp +++ b/tests/2d_examples/test_2d_two_phase_dambreak/two_phase_dambreak.cpp @@ -22,13 +22,14 @@ int main(int ac, char *av[]) WaterBlock water_block_shape("WaterBody"); FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f); - water_block.generateParticles(); + water_block.generateParticles(water_block_shape); FluidBody air_block(sph_system, makeShared("AirBody")); air_block.defineMaterial(rho0_a, c_f); air_block.generateParticles(); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WallBoundary wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); wall_boundary.generateParticles(wall_boundary_shape); diff --git a/tests/2d_examples/test_2d_water_entry_exit/test_2d_water_entry_exit.cpp b/tests/2d_examples/test_2d_water_entry_exit/test_2d_water_entry_exit.cpp index 3f548dfd1c..3b4aa9eb2a 100644 --- a/tests/2d_examples/test_2d_water_entry_exit/test_2d_water_entry_exit.cpp +++ b/tests/2d_examples/test_2d_water_entry_exit/test_2d_water_entry_exit.cpp @@ -191,7 +191,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- FluidBody water_block(sph_system, makeShared("WaterBody")); water_block.defineMaterial(rho0_f, c_f, mu_f); - water_block.generateParticles(); + water_block.generateParticles(water_block_shape); SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); wall_boundary.defineMaterial(); diff --git a/tests/3d_examples/test_3d_dambreak/dambreak.cpp b/tests/3d_examples/test_3d_dambreak/dambreak.cpp index 9c8edb8cda..29c5221e5a 100644 --- a/tests/3d_examples/test_3d_dambreak/dambreak.cpp +++ b/tests/3d_examples/test_3d_dambreak/dambreak.cpp @@ -75,9 +75,10 @@ int main(int ac, char *av[]) WaterBlock initial_water_block("WaterBody"); FluidBody water_block(sph_system, initial_water_block); water_block.defineMaterial(rho0_f, c_f); - water_block.generateParticles(); + water_block.generateParticles(water_block_shape); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WallBoundary wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); wall_boundary.generateParticles(wall_boundary_shape); diff --git a/tests/3d_examples/test_3d_dambreak_elastic_plate_shell/test_3d_dambreak_elastic_plate_shell.cpp b/tests/3d_examples/test_3d_dambreak_elastic_plate_shell/test_3d_dambreak_elastic_plate_shell.cpp index de10aa1754..00f803f3dd 100644 --- a/tests/3d_examples/test_3d_dambreak_elastic_plate_shell/test_3d_dambreak_elastic_plate_shell.cpp +++ b/tests/3d_examples/test_3d_dambreak_elastic_plate_shell/test_3d_dambreak_elastic_plate_shell.cpp @@ -165,9 +165,10 @@ int main(int ac, char *av[]) WaterBlock water_block_shape("WaterBody"); FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); - water_block.generateParticles(); + water_block.generateParticles(water_block_shape); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WallBoundary wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); wall_boundary.generateParticles(wall_boundary_shape); diff --git a/tests/3d_examples/test_3d_nonlinear_wave_fsi/nonlinear_wave_fsi.cpp b/tests/3d_examples/test_3d_nonlinear_wave_fsi/nonlinear_wave_fsi.cpp index 0ddbe7d656..6c3961b525 100644 --- a/tests/3d_examples/test_3d_nonlinear_wave_fsi/nonlinear_wave_fsi.cpp +++ b/tests/3d_examples/test_3d_nonlinear_wave_fsi/nonlinear_wave_fsi.cpp @@ -76,14 +76,15 @@ int main(int ac, char *av[]) WaterBlock water_block_shape("WaterBody"); FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); - water_block.generateParticles(); + water_block.generateParticles(water_block_shape); WallBoundary wall_boundary_shape("Wall"); SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); wall_boundary.generateParticles(wall_boundary_shape); - SolidBody structure(sph_system, makeShared("Structure")); + FloatingStructure floating_structure_shape("Structure"); + SolidBody structure(sph_system, floating_structure_shape.getName()); structure.defineMaterial(StructureDensity); structure.generateParticles("Structure_Fit"); @@ -148,7 +149,7 @@ int main(int ac, char *av[]) SimpleDynamics> constant_gravity_to_fluid(water_block, gravity); SimpleDynamics structure_offset_position(structure, offset); SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); - SimpleDynamics structure_normal_direction(structure); + SimpleDynamics structure_normal_direction(structure, floating_structure_shape); InteractionWithUpdate structure_corrected_configuration(structure_inner); InteractionWithUpdate corrected_configuration_fluid(ConstructorArgs(water_block_inner, 0.1), water_block_contact); diff --git a/tests/3d_examples/test_3d_repose_angle/repose_angle.cpp b/tests/3d_examples/test_3d_repose_angle/repose_angle.cpp index 66b526cec1..8709c0161f 100644 --- a/tests/3d_examples/test_3d_repose_angle/repose_angle.cpp +++ b/tests/3d_examples/test_3d_repose_angle/repose_angle.cpp @@ -91,7 +91,8 @@ int main(int ac, char *av[]) ? soil_block.generateParticles(soil_block.getName()) : soil_block.generateParticles(); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WallBoundary wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); wall_boundary.generateParticles(wall_boundary_shape); //---------------------------------------------------------------------- diff --git a/tests/3d_examples/test_3d_stfb/stfb.cpp b/tests/3d_examples/test_3d_stfb/stfb.cpp index c471c59818..6c0a479762 100644 --- a/tests/3d_examples/test_3d_stfb/stfb.cpp +++ b/tests/3d_examples/test_3d_stfb/stfb.cpp @@ -21,15 +21,17 @@ int main(int ac, char *av[]) WaterBlock water_block_shape("WaterBody"); FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); - water_block.generateParticles(); + water_block.generateParticles(water_block_shape); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WallBoundary wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); wall_boundary.generateParticles(wall_boundary_shape); - SolidBody structure(sph_system, makeShared("Structure")); + FloatingStructure floating_structure_shape("Structure"); + SolidBody structure(sph_system, floating_structure_shape.getName()); structure.defineMaterial(rho_s); - structure.generateParticles(); + structure.generateParticles(floating_structure_shape); ObserverBody observer(sph_system, "Observer"); observer.defineAdaptationRatios(1.15, 2.0); diff --git a/tests/3d_examples/test_3d_stlw/stlw.cpp b/tests/3d_examples/test_3d_stlw/stlw.cpp index 31fed0c503..de1c958b38 100644 --- a/tests/3d_examples/test_3d_stlw/stlw.cpp +++ b/tests/3d_examples/test_3d_stlw/stlw.cpp @@ -20,9 +20,10 @@ int main(int ac, char *av[]) WaterBlock water_block_shape("WaterBody"); FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); - water_block.generateParticles(); + water_block.generateParticles(water_block_shape); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WallBoundary wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); wall_boundary.generateParticles(wall_boundary_shape); //---------------------------------------------------------------------- diff --git a/tests/extra_source_and_tests/test_2d_mixed_poiseuille_flow/mixed_poiseuille_flow.cpp b/tests/extra_source_and_tests/test_2d_mixed_poiseuille_flow/mixed_poiseuille_flow.cpp index 5cd9ddbd2e..1b680964c3 100644 --- a/tests/extra_source_and_tests/test_2d_mixed_poiseuille_flow/mixed_poiseuille_flow.cpp +++ b/tests/extra_source_and_tests/test_2d_mixed_poiseuille_flow/mixed_poiseuille_flow.cpp @@ -155,7 +155,8 @@ int main(int ac, char *av[]) ParticleBuffer in_outlet_particle_buffer(0.5); water_block.generateParticlesWithReserve(in_outlet_particle_buffer); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WallBoundary wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); wall_boundary.generateParticles(wall_boundary_shape); diff --git a/tests/extra_source_and_tests/test_2d_modified_T_flow/modified_T_flow.cpp b/tests/extra_source_and_tests/test_2d_modified_T_flow/modified_T_flow.cpp index bc0ea476c3..354e7b966f 100644 --- a/tests/extra_source_and_tests/test_2d_modified_T_flow/modified_T_flow.cpp +++ b/tests/extra_source_and_tests/test_2d_modified_T_flow/modified_T_flow.cpp @@ -156,7 +156,8 @@ int main(int ac, char *av[]) ParticleBuffer in_outlet_particle_buffer(0.5); water_block.generateParticlesWithReserve(in_outlet_particle_buffer); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WallBoundary wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); wall_boundary.generateParticles(wall_boundary_shape); diff --git a/tests/extra_source_and_tests/test_2d_pulsatile_poiseuille_flow/pulsatile_poiseuille_flow.cpp b/tests/extra_source_and_tests/test_2d_pulsatile_poiseuille_flow/pulsatile_poiseuille_flow.cpp index 42c6e8ce1f..a2c73e688d 100644 --- a/tests/extra_source_and_tests/test_2d_pulsatile_poiseuille_flow/pulsatile_poiseuille_flow.cpp +++ b/tests/extra_source_and_tests/test_2d_pulsatile_poiseuille_flow/pulsatile_poiseuille_flow.cpp @@ -138,7 +138,8 @@ int main(int ac, char *av[]) ParticleBuffer in_outlet_particle_buffer(0.5); water_block.generateParticlesWithReserve(in_outlet_particle_buffer); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WallBoundary wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); wall_boundary.generateParticles(wall_boundary_shape); diff --git a/tests/optimization/test_2d_VP_heat_flux_optimization/VP_heat_flux_optimization.cpp b/tests/optimization/test_2d_VP_heat_flux_optimization/VP_heat_flux_optimization.cpp index 5df0717db1..703b6ce46f 100644 --- a/tests/optimization/test_2d_VP_heat_flux_optimization/VP_heat_flux_optimization.cpp +++ b/tests/optimization/test_2d_VP_heat_flux_optimization/VP_heat_flux_optimization.cpp @@ -213,7 +213,8 @@ TEST(test_optimization, test_problem4_optimized) diffusion_body.defineMaterial("Phi", "Phi", diffusion_coeff); diffusion_body.generateParticles(); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WallBoundary wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.generateParticles(wall_boundary_shape); //---------------------------------------------------------------------- diff --git a/tests/optimization/test_2d_VP_heat_flux_steady/VP_heat_flux_steady.cpp b/tests/optimization/test_2d_VP_heat_flux_steady/VP_heat_flux_steady.cpp index e2f6f2bfdb..9796380852 100644 --- a/tests/optimization/test_2d_VP_heat_flux_steady/VP_heat_flux_steady.cpp +++ b/tests/optimization/test_2d_VP_heat_flux_steady/VP_heat_flux_steady.cpp @@ -173,7 +173,8 @@ TEST(test_optimization, test_problem4_non_optimization) diffusion_body.defineMaterial("Phi", "Phi", diffusion_coeff); diffusion_body.generateParticles(); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WallBoundary wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); wall_boundary.generateParticles(wall_boundary_shape); //---------------------------- ------------------------------------------ diff --git a/tests/optimization/test_2d_VP_same_sink_optimization/VP_same_sink_optimization.cpp b/tests/optimization/test_2d_VP_same_sink_optimization/VP_same_sink_optimization.cpp index 7ddf798a79..e42395dc3d 100644 --- a/tests/optimization/test_2d_VP_same_sink_optimization/VP_same_sink_optimization.cpp +++ b/tests/optimization/test_2d_VP_same_sink_optimization/VP_same_sink_optimization.cpp @@ -195,7 +195,8 @@ TEST(test_optimization, test_problem1_optimized) diffusion_body.defineMaterial("Phi", "Phi", diffusion_coeff); diffusion_body.generateParticles(); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WallBoundary wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.generateParticles(wall_boundary_shape); //---------------------------------------------------------------------- // Define body relation map. diff --git a/tests/optimization/test_2d_VP_same_sink_steady/VP_same_sink_steady.cpp b/tests/optimization/test_2d_VP_same_sink_steady/VP_same_sink_steady.cpp index f4fdc38e92..267343e91b 100644 --- a/tests/optimization/test_2d_VP_same_sink_steady/VP_same_sink_steady.cpp +++ b/tests/optimization/test_2d_VP_same_sink_steady/VP_same_sink_steady.cpp @@ -161,7 +161,8 @@ TEST(test_optimization, test_problem1_non_optimized) diffusion_body.defineMaterial("Phi", "Phi", diffusion_coeff); diffusion_body.generateParticles(); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WallBoundary wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.generateParticles(wall_boundary_shape); //---------------------------- ------------------------------------------ // Particle and body creation of temperature observers. diff --git a/tests/tests_sycl/2d_examples/test_2d_dambreak_sycl/dambreak_sycl.cpp b/tests/tests_sycl/2d_examples/test_2d_dambreak_sycl/dambreak_sycl.cpp index 30c3c868e8..9e6ec22473 100644 --- a/tests/tests_sycl/2d_examples/test_2d_dambreak_sycl/dambreak_sycl.cpp +++ b/tests/tests_sycl/2d_examples/test_2d_dambreak_sycl/dambreak_sycl.cpp @@ -60,9 +60,10 @@ int main(int ac, char *av[]) TransformShape initial_water_block(Transform(water_block_translation), water_block_halfsize, "WaterBody"); FluidBody water_block(sph_system, initial_water_block); water_block.defineMaterial(rho0_f, c_f); - water_block.generateParticles(); + water_block.generateParticles(water_block_shape); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WallBoundary wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); wall_boundary.generateParticles(wall_boundary_shape); diff --git a/tests/unit_tests_src/shared/particle_dynamics/fluid_dynamics/test_2d_velocity_gradient/2d_velocity_gradient.cpp b/tests/unit_tests_src/shared/particle_dynamics/fluid_dynamics/test_2d_velocity_gradient/2d_velocity_gradient.cpp index bbc4521a29..39b031c5e4 100644 --- a/tests/unit_tests_src/shared/particle_dynamics/fluid_dynamics/test_2d_velocity_gradient/2d_velocity_gradient.cpp +++ b/tests/unit_tests_src/shared/particle_dynamics/fluid_dynamics/test_2d_velocity_gradient/2d_velocity_gradient.cpp @@ -125,7 +125,8 @@ int main(int ac, char *av[]) water_block.defineMaterial(rho0_f, c_f, mu_f); water_block.generateParticles(water_block_shape); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WallBoundary wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); wall_boundary.generateParticles(wall_boundary_shape); //---------------------------------------------------------------------- From d559da2f2b2563d1a31401cee8103c83f2ed2d38 Mon Sep 17 00:00:00 2001 From: Xiangyu Hu Date: Sat, 21 Sep 2024 23:33:57 +0000 Subject: [PATCH 08/13] to continue --- .../structural_simulation_class.cpp | 6 +++--- .../relax_dynamics/relax_stepping.cpp | 6 ++++++ .../relax_dynamics/relax_stepping.h | 3 +-- .../relax_dynamics/relax_stepping.hpp | 6 ------ .../test_2d_T_shaped_pipe/T_shaped_pipe.cpp | 2 +- .../test_2d_airfoil/airfoil_2d.cpp | 2 +- .../test_2d_anisotropic_beam.cpp | 18 +++-------------- .../column_collapse.cpp | 5 +++-- .../2d_eulerian_flow_around_cylinder_LG.cpp | 20 ++++++++++--------- ...lerian_supersonic_flow_around_cylinder.cpp | 11 +++++----- .../2d_flow_around_cylinder.cpp | 8 ++++---- .../2d_flow_stream_around_fish.cpp | 14 +++++++------ .../2d_free_stream_around_cylinder.cpp | 13 ++++++------ .../mr_free_stream_around_cylinder.cpp | 18 +++++++++-------- .../test_2d_water_entry_exit.cpp | 8 ++++---- .../poiseuille_flow_shell.cpp | 2 +- 16 files changed, 69 insertions(+), 73 deletions(-) diff --git a/modules/structural_simulation/structural_simulation_class.cpp b/modules/structural_simulation/structural_simulation_class.cpp index 94f730b086..3ee3ba571f 100755 --- a/modules/structural_simulation/structural_simulation_class.cpp +++ b/modules/structural_simulation/structural_simulation_class.cpp @@ -63,7 +63,7 @@ void expandBoundingBox(BoundingBox *original, BoundingBox *additional) void relaxParticlesSingleResolution(bool write_particle_relaxation_data, InnerRelation &solid_body_from_mesh_inner, - Shape &shape) + LevelSetShape *level_set_shape) { RealBody &solid_body_from_mesh = dynamic_cast(solid_body_from_mesh_inner.getSPHBody()); BodyStatesRecordingToVtp write_solid_body_from_mesh_to_vtp(solid_body_from_mesh); @@ -73,7 +73,7 @@ void relaxParticlesSingleResolution(bool write_particle_relaxation_data, //---------------------------------------------------------------------- SimpleDynamics random_solid_body_from_mesh_particles(solid_body_from_mesh); /** A Physics relaxation step. */ - relax_dynamics::RelaxationStepLevelSetCorrectionInner relaxation_step_inner(solid_body_from_mesh_inner, shape); + relax_dynamics::RelaxationStepLevelSetCorrectionInner relaxation_step_inner(solid_body_from_mesh_inner, level_set_shape); //---------------------------------------------------------------------- // Particle relaxation starts here. //---------------------------------------------------------------------- @@ -118,7 +118,7 @@ std::tuple generateAndRelaxParticlesFromMesh( { system.setIOEnvironment(); InnerRelation inner_relation(model); - relaxParticlesSingleResolution(write_particle_relaxation_data, inner_relation, *triangle_mesh_shape); + relaxParticlesSingleResolution(write_particle_relaxation_data, inner_relation, &level_set_shape); } return std::tuple(model.getBaseParticles().ParticlePositions(), model.getBaseParticles().VolumetricMeasures()); diff --git a/src/shared/particle_dynamics/relax_dynamics/relax_stepping.cpp b/src/shared/particle_dynamics/relax_dynamics/relax_stepping.cpp index a19256d943..182259db37 100644 --- a/src/shared/particle_dynamics/relax_dynamics/relax_stepping.cpp +++ b/src/shared/particle_dynamics/relax_dynamics/relax_stepping.cpp @@ -21,6 +21,12 @@ void RelaxationResidue>::interaction(size_t index_i, Real dt) residue_[index_i] = residue; }; //=================================================================================================// +RelaxationResidue>:: + RelaxationResidue(BaseInnerRelation &inner_relation, LevelSetShape *level_set_shape) + : RelaxationResidue>(inner_relation, *level_set_shape), + pos_(particles_->getVariableDataByName("Position")), + level_set_shape_(*level_set_shape){}; +//=================================================================================================// void RelaxationResidue>::interaction(size_t index_i, Real dt) { RelaxationResidue>::interaction(index_i, dt); diff --git a/src/shared/particle_dynamics/relax_dynamics/relax_stepping.h b/src/shared/particle_dynamics/relax_dynamics/relax_stepping.h index 85fa504bbe..903be844d2 100644 --- a/src/shared/particle_dynamics/relax_dynamics/relax_stepping.h +++ b/src/shared/particle_dynamics/relax_dynamics/relax_stepping.h @@ -76,8 +76,7 @@ template <> class RelaxationResidue> : public RelaxationResidue> { public: - template - RelaxationResidue(Args &&...args); + RelaxationResidue(BaseInnerRelation &inner_relation, LevelSetShape *level_set_shape); template explicit RelaxationResidue(ConstructorArgs parameters) : RelaxationResidue(parameters.body_relation_, std::get<0>(parameters.others_)){}; diff --git a/src/shared/particle_dynamics/relax_dynamics/relax_stepping.hpp b/src/shared/particle_dynamics/relax_dynamics/relax_stepping.hpp index 51c9761532..09ada70f00 100644 --- a/src/shared/particle_dynamics/relax_dynamics/relax_stepping.hpp +++ b/src/shared/particle_dynamics/relax_dynamics/relax_stepping.hpp @@ -16,12 +16,6 @@ RelaxationResidue::RelaxationResidue(BaseRelationType Vol_(this->particles_->template getVariableDataByName("VolumetricMeasure")), residue_(this->particles_->template registerStateVariable("ZeroOrderResidue")) {} //=================================================================================================// -template -RelaxationResidue>::RelaxationResidue(Args &&...args) - : RelaxationResidue>(std::forward(args)...), - pos_(particles_->getVariableDataByName("Position")), - level_set_shape_(DynamicCast(this, this->getRelaxShape())){}; -//=================================================================================================// template template RelaxationStep:: diff --git a/tests/2d_examples/test_2d_T_shaped_pipe/T_shaped_pipe.cpp b/tests/2d_examples/test_2d_T_shaped_pipe/T_shaped_pipe.cpp index 66f7b2f8e5..c3edd5a27e 100644 --- a/tests/2d_examples/test_2d_T_shaped_pipe/T_shaped_pipe.cpp +++ b/tests/2d_examples/test_2d_T_shaped_pipe/T_shaped_pipe.cpp @@ -103,7 +103,7 @@ int main(int ac, char *av[]) FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); ParticleBuffer inlet_particle_buffer(0.5); - water_block.generateParticlesWithReserve(inlet_particle_buffer); + water_block.generateParticlesWithReserve(inlet_particle_buffer, water_block_shape); WallBoundary wall_boundary_shape("WallBoundary"); SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); diff --git a/tests/2d_examples/test_2d_airfoil/airfoil_2d.cpp b/tests/2d_examples/test_2d_airfoil/airfoil_2d.cpp index 2cbfbae323..f83a6dfca4 100644 --- a/tests/2d_examples/test_2d_airfoil/airfoil_2d.cpp +++ b/tests/2d_examples/test_2d_airfoil/airfoil_2d.cpp @@ -71,7 +71,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- using namespace relax_dynamics; SimpleDynamics random_airfoil_particles(airfoil); - RelaxationStepLevelSetCorrectionInner relaxation_step(airfoil_inner, airfoil_level_set); + RelaxationStepLevelSetCorrectionInner relaxation_step(airfoil_inner, &airfoil_level_set); SimpleDynamics update_smoothing_length_ratio(airfoil, airfoil_level_set); //---------------------------------------------------------------------- // Prepare the simulation with cell linked list, configuration diff --git a/tests/2d_examples/test_2d_anisotropic_beam/test_2d_anisotropic_beam.cpp b/tests/2d_examples/test_2d_anisotropic_beam/test_2d_anisotropic_beam.cpp index ead5e31dfe..8e56d8535b 100644 --- a/tests/2d_examples/test_2d_anisotropic_beam/test_2d_anisotropic_beam.cpp +++ b/tests/2d_examples/test_2d_anisotropic_beam/test_2d_anisotropic_beam.cpp @@ -55,22 +55,10 @@ StdVec observation_location = {Vecd(PL, 0.0)}; namespace SPH { //---------------------------------------------------------------------- -// Define the beam body -//---------------------------------------------------------------------- -class Beam : public MultiPolygonShape -{ - public: - explicit Beam(const std::string &shape_name) : MultiPolygonShape(shape_name) - { - multi_polygon_.addAPolygon(beam_base_shape, ShapeBooleanOps::add); - multi_polygon_.addAPolygon(beam_shape, ShapeBooleanOps::add); - } -}; -//---------------------------------------------------------------------- // particle generation considering the anisotropic resolution //---------------------------------------------------------------------- template <> -class ParticleGenerator : public ParticleGenerator +class ParticleGenerator : public ParticleGenerator { public: ParticleGenerator(SPHBody &sph_body, BaseParticles &base_particles) @@ -195,10 +183,10 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - SolidBody beam_body(system, makeShared("BeamBody")); + SolidBody beam_body(system, "BeamBody"); beam_body.sph_adaptation_->resetKernel>(scaling_vector); beam_body.defineMaterial(rho0_s, Youngs_modulus, poisson); - beam_body.generateParticles(); + beam_body.generateParticles(); ObserverBody beam_observer(system, "BeamObserver"); beam_observer.sph_adaptation_->resetKernel>(scaling_vector); diff --git a/tests/2d_examples/test_2d_column_collapse/column_collapse.cpp b/tests/2d_examples/test_2d_column_collapse/column_collapse.cpp index 17069a76ed..67812a9968 100644 --- a/tests/2d_examples/test_2d_column_collapse/column_collapse.cpp +++ b/tests/2d_examples/test_2d_column_collapse/column_collapse.cpp @@ -73,9 +73,10 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating bodies with corresponding materials and particles. //---------------------------------------------------------------------- - RealBody soil_block(sph_system, makeShared("GranularBody")); + Soil soil_block_shape("GranularBody"); + RealBody soil_block(sph_system, soil_block_shape.getName()); soil_block.defineMaterial(rho0_s, c_s, Youngs_modulus, poisson, friction_angle); - soil_block.generateParticles(); + soil_block.generateParticles(soil_block_shape); WallBoundary wall_boundary_shape("WallBoundary"); SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); diff --git a/tests/2d_examples/test_2d_eulerian_flow_around_cylinder_LG/2d_eulerian_flow_around_cylinder_LG.cpp b/tests/2d_examples/test_2d_eulerian_flow_around_cylinder_LG/2d_eulerian_flow_around_cylinder_LG.cpp index 68b0ef196a..4c4fcca328 100644 --- a/tests/2d_examples/test_2d_eulerian_flow_around_cylinder_LG/2d_eulerian_flow_around_cylinder_LG.cpp +++ b/tests/2d_examples/test_2d_eulerian_flow_around_cylinder_LG/2d_eulerian_flow_around_cylinder_LG.cpp @@ -90,22 +90,24 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared("WaterBlock")); + WaterBlock water_block_shape("WaterBlock"); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.sph_adaptation_->resetKernel>(20); - water_block.defineComponentLevelSetShape("OuterBoundary"); + LevelSetShape level_set_shape(water_block, *water_block_shape.getSubShapeByName("OuterBoundary")); water_block.defineMaterial(rho0_f, c_f, mu_f); (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? water_block.generateParticles(water_block.getName()) : water_block.generateParticles(water_block_shape); - SolidBody cylinder(sph_system, makeShared("Cylinder")); + Cylinder cylinder_shape("Cylinder"); + SolidBody cylinder(sph_system, cylinder_shape.getName()); cylinder.defineAdaptationRatios(1.3, 2.0); cylinder.sph_adaptation_->resetKernel>(20); - cylinder.defineBodyLevelSetShape(); + LevelSetShape cylinder_shape_level_set(cylinder, cylinder_shape); cylinder.defineMaterial(); (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? cylinder.generateParticles(cylinder.getName()) - : cylinder.generateParticles(); + : cylinder.generateParticles(cylinder_shape_level_set); //---------------------------------------------------------------------- // Define body relation map. // The contact map gives the topological connections between the bodies. @@ -135,9 +137,9 @@ int main(int ac, char *av[]) SimpleDynamics random_water_body_particles(water_block); BodyStatesRecordingToVtp write_real_body_states(sph_system); ReloadParticleIO write_real_body_particle_reload_files({&cylinder, &water_block}); - RelaxationStepLevelSetCorrectionInner relaxation_step_inner(cylinder_inner); + RelaxationStepLevelSetCorrectionInner relaxation_step_inner(cylinder_inner, &cylinder_shape_level_set); RelaxationStepLevelSetCorrectionComplex relaxation_step_complex( - ConstructorArgs(water_block_inner, std::string("OuterBoundary")), water_block_contact); + ConstructorArgs(water_block_inner, &level_set_shape), water_block_contact); //---------------------------------------------------------------------- // Particle relaxation starts here. //---------------------------------------------------------------------- @@ -174,13 +176,13 @@ int main(int ac, char *av[]) InteractionWithUpdate cylinder_kernel_correction_matrix(cylinder_inner, cylinder_contact); InteractionWithUpdate water_block_kernel_correction_matrix(water_block_inner, water_block_contact); InteractionDynamics kernel_gradient_update(water_block_inner, water_block_contact); - SimpleDynamics cylinder_normal_direction(cylinder); + SimpleDynamics cylinder_normal_direction(cylinder, cylinder_shape_level_set); InteractionWithUpdate pressure_relaxation(water_block_inner, water_block_contact); InteractionWithUpdate density_relaxation(water_block_inner, water_block_contact); InteractionWithUpdate viscous_force(water_block_inner, water_block_contact); - SimpleDynamics water_block_normal_direction(water_block); + SimpleDynamics water_block_normal_direction(water_block, water_block_shape); ReduceDynamics get_fluid_time_step_size(water_block, 0.5); InteractionWithUpdate variable_reset_in_boundary_condition(water_block_inner); //---------------------------------------------------------------------- diff --git a/tests/2d_examples/test_2d_eulerian_supersonic_flow_new_BC/2d_eulerian_supersonic_flow_around_cylinder.cpp b/tests/2d_examples/test_2d_eulerian_supersonic_flow_new_BC/2d_eulerian_supersonic_flow_around_cylinder.cpp index d3001ca094..6639276599 100644 --- a/tests/2d_examples/test_2d_eulerian_supersonic_flow_new_BC/2d_eulerian_supersonic_flow_around_cylinder.cpp +++ b/tests/2d_examples/test_2d_eulerian_supersonic_flow_new_BC/2d_eulerian_supersonic_flow_around_cylinder.cpp @@ -25,14 +25,15 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody fluid_block(sph_system, makeShared("FluidBlock")); + FluidBlock fluid_block_shape("FluidBlock"); + FluidBody fluid_block(sph_system, fluid_block_shape.getName()); fluid_block.sph_adaptation_->resetKernel>(20); - fluid_block.defineBodyLevelSetShape(); + LevelSetShape level_set_shape(fluid_block, fluid_block_shape); fluid_block.defineMaterial(rho_reference, heat_capacity_ratio); Ghost ghost_boundary(0.5); (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? fluid_block.generateParticlesWithReserve(ghost_boundary, fluid_block.getName()) - : fluid_block.generateParticlesWithReserve(ghost_boundary); + : fluid_block.generateParticlesWithReserve(ghost_boundary, level_set_shape); //---------------------------------------------------------------------- // Define body relation map. // The contact map gives the topological connections between the bodies. @@ -52,7 +53,7 @@ int main(int ac, char *av[]) SimpleDynamics random_water_body_particles(fluid_block); BodyStatesRecordingToVtp write_real_body_states(fluid_block); ReloadParticleIO write_real_body_particle_reload_files(fluid_block); - RelaxationStepLevelSetCorrectionInner relaxation_step_inner(fluid_block_inner); + RelaxationStepLevelSetCorrectionInner relaxation_step_inner(fluid_block_inner, &level_set_shape); //---------------------------------------------------------------------- // Particle relaxation starts here. //---------------------------------------------------------------------- @@ -101,7 +102,7 @@ int main(int ac, char *av[]) // Ghost kernel gradient update is to make the boundary particles strictly achieve zero-order consistency. // strictly achieve zero-order consistency //---------------------------------------------------------------------- - GhostCreationInESPH ghost_creation_for_boundary_condition(fluid_block_inner, ghost_boundary); + GhostCreationInESPH ghost_creation_for_boundary_condition(fluid_block_inner, level_set_shape, ghost_boundary); SupersonicFlowBoundaryConditionSetup boundary_condition_setup(fluid_block_inner, ghost_creation_for_boundary_condition); InteractionWithUpdate ghost_kernel_gradient_update(fluid_block_inner); boundary_condition_setup.resetBoundaryConditions(); diff --git a/tests/2d_examples/test_2d_flow_around_cylinder/2d_flow_around_cylinder.cpp b/tests/2d_examples/test_2d_flow_around_cylinder/2d_flow_around_cylinder.cpp index 3e79598728..f15cb6c982 100644 --- a/tests/2d_examples/test_2d_flow_around_cylinder/2d_flow_around_cylinder.cpp +++ b/tests/2d_examples/test_2d_flow_around_cylinder/2d_flow_around_cylinder.cpp @@ -36,11 +36,11 @@ int main(int ac, char *av[]) Cylinder cylinder_shape("Cylinder"); SolidBody cylinder(sph_system, cylinder_shape.getName()); cylinder.defineAdaptationRatios(1.15, 2.0); - LevelSetShape level_set_shape(cylinder, cylinder_shape, 1.0); + LevelSetShape cylinder_shape_level_set(cylinder, cylinder_shape, 1.0); cylinder.defineMaterial(); (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? cylinder.generateParticles(cylinder.getName()) - : cylinder.generateParticles(level_set_shape); + : cylinder.generateParticles(cylinder_shape_level_set); ObserverBody fluid_observer(sph_system, "FluidObserver"); fluid_observer.generateParticles(observation_locations); @@ -79,7 +79,7 @@ int main(int ac, char *av[]) /** Write the particle reload files. */ ReloadParticleIO write_particle_reload_files(cylinder); /** A Physics relaxation step. */ - RelaxationStepInner relaxation_step_inner(cylinder_inner); + RelaxationStepInner relaxation_step_inner(cylinder_inner, cylinder_shape_level_set); //---------------------------------------------------------------------- // Particle relaxation starts here. //---------------------------------------------------------------------- @@ -108,7 +108,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 cylinder_normal_direction(cylinder); + SimpleDynamics cylinder_normal_direction(cylinder, cylinder_shape_level_set); Dynamics1Level pressure_relaxation(water_block_inner, water_block_contact); Dynamics1Level density_relaxation(water_block_inner, water_block_contact); diff --git a/tests/2d_examples/test_2d_flow_stream_around_fish/2d_flow_stream_around_fish.cpp b/tests/2d_examples/test_2d_flow_stream_around_fish/2d_flow_stream_around_fish.cpp index a3c64514d8..23466e87dd 100644 --- a/tests/2d_examples/test_2d_flow_stream_around_fish/2d_flow_stream_around_fish.cpp +++ b/tests/2d_examples/test_2d_flow_stream_around_fish/2d_flow_stream_around_fish.cpp @@ -27,16 +27,18 @@ int main(int ac, char *av[]) FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); ParticleBuffer inlet_particle_buffer(0.5); - water_block.generateParticlesWithReserve(inlet_particle_buffer); + water_block.generateParticlesWithReserve(inlet_particle_buffer, water_block_shape); - SolidBody fish_body(sph_system, makeShared("FishBody")); + FishBody fish_body_shape("FishBody"); + SolidBody fish_body(sph_system, fish_body.getName()); fish_body.defineAdaptationRatios(1.15, 2.0); - fish_body.defineBodyLevelSetShape()->writeLevelSet(sph_system); + LevelSetShape fish_body_level_set_shape(fish_body, fish_body_shape); + fish_body_level_set_shape.writeLevelSet(sph_system); fish_body.defineMaterial(); // Using relaxed particle distribution if needed (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? fish_body.generateParticles(fish_body.getName()) - : fish_body.generateParticles(); + : fish_body.generateParticles(fish_body_level_set_shape); //---------------------------------------------------------------------- // Define body relation map. // The contact map gives the topological connections between the bodies. @@ -64,7 +66,7 @@ int main(int ac, char *av[]) SimpleDynamics random_fish_body_particles(fish_body); BodyStatesRecordingToVtp write_fish_body(fish_body); ReloadParticleIO write_particle_reload_files(fish_body); - RelaxationStepInner relaxation_step_inner(fish_inner); + RelaxationStepInner relaxation_step_inner(fish_inner, fish_body_level_set_shape); //---------------------------------------------------------------------- // Particle relaxation starts here. //---------------------------------------------------------------------- @@ -99,7 +101,7 @@ int main(int ac, char *av[]) // Then fluid dynamics and the corresponding coupling dynamics. // The coupling with multi-body dynamics will be introduced at last. //---------------------------------------------------------------------- - SimpleDynamics fish_body_normal_direction(fish_body); + SimpleDynamics fish_body_normal_direction(fish_body, fish_body_level_set_shape); InteractionWithUpdate fish_body_corrected_configuration(fish_inner); SimpleDynamics composite_material_id(fish_body); InteractionWithUpdate free_stream_surface_indicator(water_block_inner, water_block_contact); diff --git a/tests/2d_examples/test_2d_free_stream_around_cylinder/2d_free_stream_around_cylinder.cpp b/tests/2d_examples/test_2d_free_stream_around_cylinder/2d_free_stream_around_cylinder.cpp index 722b962ebe..7114c5f0b0 100644 --- a/tests/2d_examples/test_2d_free_stream_around_cylinder/2d_free_stream_around_cylinder.cpp +++ b/tests/2d_examples/test_2d_free_stream_around_cylinder/2d_free_stream_around_cylinder.cpp @@ -28,15 +28,16 @@ int main(int ac, char *av[]) FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); ParticleBuffer inlet_particle_buffer(0.5); - water_block.generateParticlesWithReserve(inlet_particle_buffer); + water_block.generateParticlesWithReserve(inlet_particle_buffer, water_block_shape); - SolidBody cylinder(sph_system, makeShared("Cylinder")); + Cylinder cylinder_shape("Cylinder"); + SolidBody cylinder(sph_system, cylinder_shape.getName()); cylinder.defineAdaptationRatios(1.15, 2.0); - cylinder.defineBodyLevelSetShape(); + LevelSetShape cylinder_shape_level_set(cylinder, cylinder_shape); cylinder.defineMaterial(); (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? cylinder.generateParticles(cylinder.getName()) - : cylinder.generateParticles(); + : cylinder.generateParticles(cylinder_shape_level_set); ObserverBody fluid_observer(sph_system, "FluidObserver"); fluid_observer.generateParticles(observation_locations); @@ -75,7 +76,7 @@ int main(int ac, char *av[]) /** Write the particle reload files. */ ReloadParticleIO write_particle_reload_files(cylinder); /** A Physics relaxation step. */ - RelaxationStepInner relaxation_step_inner(cylinder_inner); + RelaxationStepInner relaxation_step_inner(cylinder_inner, cylinder_shape_level_set); //---------------------------------------------------------------------- // Particle relaxation starts here. //---------------------------------------------------------------------- @@ -108,7 +109,7 @@ int main(int ac, char *av[]) StartupAcceleration time_dependent_acceleration(Vec2d(U_f, 0.0), 2.0); SimpleDynamics> apply_gravity_force(water_block, time_dependent_acceleration); InteractionWithUpdate free_stream_surface_indicator(water_block_inner, water_block_contact); - SimpleDynamics cylinder_normal_direction(cylinder); + SimpleDynamics cylinder_normal_direction(cylinder, cylinder_shape_level_set); Dynamics1Level pressure_relaxation(water_block_inner, water_block_contact); Dynamics1Level density_relaxation(water_block_inner, water_block_contact); diff --git a/tests/2d_examples/test_2d_free_stream_around_cylinder_mr/mr_free_stream_around_cylinder.cpp b/tests/2d_examples/test_2d_free_stream_around_cylinder_mr/mr_free_stream_around_cylinder.cpp index 18222d35e2..4d5d7203c5 100644 --- a/tests/2d_examples/test_2d_free_stream_around_cylinder_mr/mr_free_stream_around_cylinder.cpp +++ b/tests/2d_examples/test_2d_free_stream_around_cylinder_mr/mr_free_stream_around_cylinder.cpp @@ -27,21 +27,23 @@ int main(int ac, char *av[]) WaterBlock water_block_shape("WaterBody"); FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineAdaptation(1.3, 1.0, 1); - water_block.defineComponentLevelSetShape("OuterBoundary")->writeLevelSet(sph_system); + LevelSetShape water_block_level_set_shape(water_block, *water_block_shape.getSubShapeByName("OuterBoundary")); + water_block_level_set_shape.writeLevelSet(sph_system); water_block.defineMaterial(rho0_f, c_f, mu_f); MultiPolygonShape refinement_region(MultiPolygon(initial_refinement_region), "RefinementRegion"); ParticleBuffer inlet_particle_buffer(0.5); (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? water_block.generateParticlesWithReserve(inlet_particle_buffer, water_block.getName()) - : water_block.generateParticles(refinement_region); + : water_block.generateParticles(water_block_shape, refinement_region); - SolidBody cylinder(sph_system, makeShared("Cylinder")); + Cylinder cylinder_shape("Cylinder"); + SolidBody cylinder(sph_system, cylinder_shape.getName()); cylinder.defineAdaptationRatios(1.15, 4.0); - cylinder.defineBodyLevelSetShape(); + LevelSetShape cylinder_shape_level_set(cylinder, cylinder_shape); cylinder.defineMaterial(); (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? cylinder.generateParticles(cylinder.getName()) - : cylinder.generateParticles(); + : cylinder.generateParticles(cylinder_shape_level_set); ObserverBody fluid_observer(sph_system, "FluidObserver"); fluid_observer.generateParticles(observation_locations); @@ -78,9 +80,9 @@ int main(int ac, char *av[]) BodyStatesRecordingToVtp write_real_body_states(sph_system); ReloadParticleIO write_real_body_particle_reload_files({&water_block, &cylinder}); /** A Physics relaxation step. */ - RelaxationStepLevelSetCorrectionInner relaxation_step_inner(cylinder_inner); + RelaxationStepLevelSetCorrectionInner relaxation_step_inner(cylinder_inner, &cylinder_shape_level_set); RelaxationStepLevelSetCorrectionComplex relaxation_step_complex( - ConstructorArgs(water_block_inner, std::string("OuterBoundary")), water_contact); + ConstructorArgs(water_block_inner, &water_block_level_set_shape), water_contact); SimpleDynamics update_smoothing_length_ratio(water_block, refinement_region); //---------------------------------------------------------------------- // Particle relaxation starts here. @@ -117,7 +119,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- StartupAcceleration time_dependent_acceleration(Vec2d(U_f, 0.0), 2.0); SimpleDynamics> apply_gravity_force(water_block, time_dependent_acceleration); - SimpleDynamics cylinder_normal_direction(cylinder); + SimpleDynamics cylinder_normal_direction(cylinder, cylinder_shape_level_set); InteractionWithUpdate free_stream_surface_indicator(water_block_inner, water_contact); Dynamics1Level pressure_relaxation(water_block_inner, water_contact); diff --git a/tests/2d_examples/test_2d_water_entry_exit/test_2d_water_entry_exit.cpp b/tests/2d_examples/test_2d_water_entry_exit/test_2d_water_entry_exit.cpp index 3b4aa9eb2a..6e5ae353d2 100644 --- a/tests/2d_examples/test_2d_water_entry_exit/test_2d_water_entry_exit.cpp +++ b/tests/2d_examples/test_2d_water_entry_exit/test_2d_water_entry_exit.cpp @@ -199,11 +199,11 @@ int main(int ac, char *av[]) SolidBody cylinder(sph_system, makeShared("Cylinder")); cylinder.defineAdaptationRatios(1.15, 1.0); - cylinder.defineBodyLevelSetShape(); + LevelSetShape cylinder_shape_level_set(cylinder, cylinder_shape); cylinder.defineMaterial(rho0_s); (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? cylinder.generateParticles(cylinder.getName()) - : cylinder.generateParticles(); + : cylinder.generateParticles(cylinder_shape_level_set); ObserverBody cylinder_observer(sph_system, "CylinderObserver"); cylinder_observer.generateParticles(observer_location); @@ -246,7 +246,7 @@ int main(int ac, char *av[]) /** Write the particle reload files. */ ReloadParticleIO write_particle_reload_files(cylinder); /** A Physics relaxation step. */ - RelaxationStepInner relaxation_step_inner(cylinder_inner); + RelaxationStepInner relaxation_step_inner(cylinder_inner, cylinder_shape_level_set); //---------------------------------------------------------------------- // Particle relaxation starts here. //---------------------------------------------------------------------- @@ -287,7 +287,7 @@ int main(int ac, char *av[]) SimpleDynamics> constant_gravity(water_block, gravity); InteractionWithUpdate free_stream_surface_indicator(water_block_inner, water_block_contact); SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); - SimpleDynamics cylinder_normal_direction(cylinder); + SimpleDynamics cylinder_normal_direction(cylinder, cylinder_shape_level_set); Dynamics1Level fluid_pressure_relaxation(water_block_inner, water_block_contact); Dynamics1Level fluid_density_relaxation(water_block_inner, water_block_contact); diff --git a/tests/3d_examples/test_3d_poiseuille_flow_shell/poiseuille_flow_shell.cpp b/tests/3d_examples/test_3d_poiseuille_flow_shell/poiseuille_flow_shell.cpp index 419f41183f..29cea1bad6 100644 --- a/tests/3d_examples/test_3d_poiseuille_flow_shell/poiseuille_flow_shell.cpp +++ b/tests/3d_examples/test_3d_poiseuille_flow_shell/poiseuille_flow_shell.cpp @@ -177,7 +177,7 @@ void poiseuille_flow(const Real resolution_ref, const Real resolution_shell, con FluidBody water_block(system, water_block_shape); water_block.defineMaterial(rho0_f, c_f, mu_f); ParticleBuffer inlet_particle_buffer(0.5); - water_block.generateParticlesWithReserve(inlet_particle_buffer); + water_block.generateParticlesWithReserve(inlet_particle_buffer, water_block_shape); SolidBody shell_boundary(system, makeShared("Shell")); shell_boundary.defineAdaptation(1.15, resolution_ref / resolution_shell); From 2d4d00143661f925ccf8db06b6a7a0d6da4897db Mon Sep 17 00:00:00 2001 From: Xiangyu Hu Date: Sun, 22 Sep 2024 10:28:58 +0000 Subject: [PATCH 09/13] several cases --- .../oscillating_beam.cpp | 5 ++-- .../oscillating_beam_UL.cpp | 5 ++-- .../cauchy_oscillating_beam.cpp | 5 ++-- .../particle_generator_single_resolution.cpp | 10 ++++--- .../test_2d_self_contact/self_contact.cpp | 5 ++-- .../test_2d_stretching/stretching.cpp | 2 +- .../test_2d_three_ring_impact.cpp | 27 ++++++++++--------- .../beam_pulling_pressure_load.cpp | 2 +- .../test_3d_load_image/load_image.cpp | 12 +++++---- .../nonlinear_wave_fsi.cpp | 13 +++++---- .../particle_relaxation.cpp | 12 +++++---- ...rticle_relaxation_single_resolution_3D.cpp | 24 +++++++++-------- .../test_3d_taylor_bar_UL/taylor_bar_UL.cpp | 17 +++++++----- .../test_2d_membrane/2d_membrane.cpp | 2 +- 14 files changed, 81 insertions(+), 60 deletions(-) diff --git a/tests/2d_examples/test_2d_oscillating_beam/oscillating_beam.cpp b/tests/2d_examples/test_2d_oscillating_beam/oscillating_beam.cpp index f8506d6d99..a862869901 100644 --- a/tests/2d_examples/test_2d_oscillating_beam/oscillating_beam.cpp +++ b/tests/2d_examples/test_2d_oscillating_beam/oscillating_beam.cpp @@ -109,9 +109,10 @@ int main(int ac, char *av[]) #endif //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - SolidBody beam_body(sph_system, makeShared("BeamBody")); + Beam beam_body_shape("BeamBody"); + SolidBody beam_body(sph_system, beam_body_shape.getName()); beam_body.defineMaterial(rho0_s, Youngs_modulus, poisson); - beam_body.generateParticles(); + beam_body.generateParticles(beam_body_shape); ObserverBody beam_observer(sph_system, "BeamObserver"); beam_observer.defineAdaptationRatios(1.15, 2.0); diff --git a/tests/2d_examples/test_2d_oscillating_beam_UL/oscillating_beam_UL.cpp b/tests/2d_examples/test_2d_oscillating_beam_UL/oscillating_beam_UL.cpp index aca9b8b2e9..d15dfd0198 100644 --- a/tests/2d_examples/test_2d_oscillating_beam_UL/oscillating_beam_UL.cpp +++ b/tests/2d_examples/test_2d_oscillating_beam_UL/oscillating_beam_UL.cpp @@ -107,9 +107,10 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - RealBody beam_body(sph_system, makeShared("BeamBody")); + Beam beam_body_shape("BeamBody"); + RealBody beam_body(sph_system, beam_body_shape.getName()); beam_body.defineMaterial(rho0_s, c0, Youngs_modulus, poisson); - beam_body.generateParticles(); + beam_body.generateParticles(beam_body_shape); ObserverBody beam_observer(sph_system, "BeamObserver"); beam_observer.sph_adaptation_->resetAdaptationRatios(1.15, 2.0); diff --git a/tests/2d_examples/test_2d_oscillating_beam_cauchy/cauchy_oscillating_beam.cpp b/tests/2d_examples/test_2d_oscillating_beam_cauchy/cauchy_oscillating_beam.cpp index ed1b7d6e08..1236e18c27 100644 --- a/tests/2d_examples/test_2d_oscillating_beam_cauchy/cauchy_oscillating_beam.cpp +++ b/tests/2d_examples/test_2d_oscillating_beam_cauchy/cauchy_oscillating_beam.cpp @@ -110,9 +110,10 @@ int main(int ac, char *av[]) #endif //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - SolidBody beam_body(sph_system, makeShared("BeamBody")); + Beam beam_body_shape("BeamBody"); + SolidBody beam_body(sph_system, beam_body_shape.getName()); beam_body.defineMaterial(rho0_s, Youngs_modulus, poisson); - beam_body.generateParticles(); + beam_body.generateParticles(beam_body_shape); ObserverBody beam_observer(sph_system, "BeamObserver"); beam_observer.defineAdaptationRatios(1.15, 2.0); diff --git a/tests/2d_examples/test_2d_particle_generator_single_resolution/particle_generator_single_resolution.cpp b/tests/2d_examples/test_2d_particle_generator_single_resolution/particle_generator_single_resolution.cpp index 62ae0041af..20adb67941 100644 --- a/tests/2d_examples/test_2d_particle_generator_single_resolution/particle_generator_single_resolution.cpp +++ b/tests/2d_examples/test_2d_particle_generator_single_resolution/particle_generator_single_resolution.cpp @@ -50,9 +50,11 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - RealBody input_body(sph_system, makeShared("SPHInXsysLogo")); - input_body.defineBodyLevelSetShape()->writeLevelSet(sph_system); - input_body.generateParticles(); + InputBody input_body_shape("SPHInXsysLogo"); + RealBody input_body(sph_system, input_body_shape.getName()); + LevelSetShape level_set_shape(input_body, input_body_shape); + level_set_shape.writeLevelSet(sph_system); + input_body.generateParticles(level_set_shape); //---------------------------------------------------------------------- // Define body relation map. // The contact map gives the topological connections between the bodies. @@ -67,7 +69,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- using namespace relax_dynamics; SimpleDynamics random_input_body_particles(input_body); - RelaxationStepLevelSetCorrectionInner relaxation_step_inner(input_body_inner); + RelaxationStepLevelSetCorrectionInner relaxation_step_inner(input_body_inner, &level_set_shape); //---------------------------------------------------------------------- // Define simple file input and outputs functions. //---------------------------------------------------------------------- diff --git a/tests/2d_examples/test_2d_self_contact/self_contact.cpp b/tests/2d_examples/test_2d_self_contact/self_contact.cpp index 358a60effa..d1cabb8d30 100644 --- a/tests/2d_examples/test_2d_self_contact/self_contact.cpp +++ b/tests/2d_examples/test_2d_self_contact/self_contact.cpp @@ -120,9 +120,10 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - SolidBody beam_body(sph_system, makeShared("BeamBody")); + Beam beam_body_shape("BeamBody"); + SolidBody beam_body(sph_system, beam_body_shape.getName()); beam_body.defineMaterial(rho0_s, Youngs_modulus, poisson); - beam_body.generateParticles(); + beam_body.generateParticles(beam_body_shape); ObserverBody beam_observer(sph_system, "BeamObserver"); beam_observer.defineAdaptationRatios(1.15, 2.0); diff --git a/tests/2d_examples/test_2d_stretching/stretching.cpp b/tests/2d_examples/test_2d_stretching/stretching.cpp index 3697e55204..3e9b41f636 100644 --- a/tests/2d_examples/test_2d_stretching/stretching.cpp +++ b/tests/2d_examples/test_2d_stretching/stretching.cpp @@ -191,7 +191,7 @@ int main(int ac, char *av[]) (!system.RunParticleRelaxation() && system.ReloadParticles()) ? beam_body.generateParticles(beam_body.getName()) - : beam_body.generateParticles(); + : beam_body.generateParticles(beam_body_shape); ObserverBody beam_observer(system, "BeamObserver"); beam_observer.generateParticles(observation_location); diff --git a/tests/2d_examples/test_2d_three_ring_impact/test_2d_three_ring_impact.cpp b/tests/2d_examples/test_2d_three_ring_impact/test_2d_three_ring_impact.cpp index 506444c249..e981cef854 100644 --- a/tests/2d_examples/test_2d_three_ring_impact/test_2d_three_ring_impact.cpp +++ b/tests/2d_examples/test_2d_three_ring_impact/test_2d_three_ring_impact.cpp @@ -9,14 +9,14 @@ #include "sphinxsys.h" using namespace SPH; -void relax_solid(RealBody &body, InnerRelation &inner) +void relax_solid(InnerRelation &inner, LevelSetShape &level_set_shape) { //---------------------------------------------------------------------- // Methods used for particle relaxation. //---------------------------------------------------------------------- using namespace relax_dynamics; - SimpleDynamics random_particles(body); - RelaxationStepLevelSetCorrectionInner relaxation_step_inner(inner); + SimpleDynamics random_particles(inner.getSPHBody()); + RelaxationStepLevelSetCorrectionInner relaxation_step_inner(inner, &level_set_shape); //---------------------------------------------------------------------- // Particle relaxation starts here. //---------------------------------------------------------------------- @@ -189,19 +189,22 @@ void three_ring_impact(int resolution_factor_l, int resolution_factor_m, int res IOEnvironment io_environment(system); // Body - SolidBody ring_l_body(system, makeShared("RingLarge", center_l, 0.5 * diameter_inner_l, 0.5 * diameter_outer_l)); - ring_l_body.defineBodyLevelSetShape(); + Ring ring_l_body_shape("RingLarge", center_l, 0.5 * diameter_inner_l, 0.5 * diameter_outer_l); + SolidBody ring_l_body(system, ring_l_body_shape.getName()); + LevelSetShape level_set_shape(ring_l_body, ring_l_body_shape); ring_l_body.assignMaterial(material_l.get()); - ring_l_body.generateParticles(); + ring_l_body.generateParticles(level_set_shape); auto particles_l = &ring_l_body.getBaseParticles(); - SolidBody ring_m_body(system, makeShared("RingMedium")); + DefaultShape ring_m_default_shape("RingMedium"); + SolidBody ring_m_body(system, ring_m_default_shape.getName()); ring_m_body.defineAdaptationRatios(1.15, dp_l / dp_m); ring_m_body.assignMaterial(material_m.get()); ring_m_body.generateParticles(center_m, 0.5 * mid_srf_diameter_m, dp_m, thickness_m); auto particles_m = &ring_m_body.getBaseParticles(); - SolidBody ring_s_body(system, makeShared("RingSmall")); + DefaultShape ring_s_default_shape("RingSmall"); + SolidBody ring_s_body(system, ring_s_default_shape.getName()); ring_s_body.defineAdaptationRatios(1.15, dp_l / dp_s); ring_s_body.assignMaterial(material_s.get()); ring_s_body.generateParticles(center_s, 0.5 * mid_srf_diameter_s, dp_s, thickness_s); @@ -213,7 +216,7 @@ void three_ring_impact(int resolution_factor_l, int resolution_factor_m, int res InnerRelation ring_s_inner(ring_s_body); // relaxation - relax_solid(ring_l_body, ring_l_inner); + relax_solid(ring_l_inner, level_set_shape); // Methods InteractionWithUpdate corrected_configuration_l(ring_l_inner); @@ -247,9 +250,9 @@ void three_ring_impact(int resolution_factor_l, int resolution_factor_m, int res ShellSelfContactRelation self_contact_m(ring_m_body); // Contact relation - SurfaceContactRelation contact_s(ring_s_body, {&ring_m_body}, {true}); - SurfaceContactRelation contact_m(ring_m_body, {&ring_s_body, &ring_l_body}, {true, false}); - SurfaceContactRelation contact_l(ring_l_body, {&ring_m_body}, {true}); + SurfaceContactRelation contact_s(ring_s_body, ring_s_default_shape, {&ring_m_body}, {true}); + SurfaceContactRelation contact_m(ring_m_body, ring_m_default_shape, {&ring_s_body, &ring_l_body}, {true, false}); + SurfaceContactRelation contact_l(ring_l_body, ring_l_body_shape, {&ring_m_body}, {true}); // Inner relation of curvature ShellInnerRelationWithContactKernel curvature_inner_m_with_s_kernel(ring_m_body, ring_s_body); diff --git a/tests/3d_examples/test_3d_beam_pulling_pressure_load/beam_pulling_pressure_load.cpp b/tests/3d_examples/test_3d_beam_pulling_pressure_load/beam_pulling_pressure_load.cpp index ecc9442a4a..89f671cf87 100644 --- a/tests/3d_examples/test_3d_beam_pulling_pressure_load/beam_pulling_pressure_load.cpp +++ b/tests/3d_examples/test_3d_beam_pulling_pressure_load/beam_pulling_pressure_load.cpp @@ -119,7 +119,7 @@ int main(int ac, char *av[]) /** Import a beam body, with corresponding material and particles. */ SolidBody beam_body(sph_system, makeShared("beam")); beam_body.defineMaterial(rho, Youngs_modulus, poisson_ratio); - beam_body.generateParticles(); + beam_body.generateParticles(beam_body_shape); // Define Observer ObserverBody beam_observer(sph_system, "BeamObserver"); diff --git a/tests/3d_examples/test_3d_load_image/load_image.cpp b/tests/3d_examples/test_3d_load_image/load_image.cpp index 5f43303ba7..1b37a0e7a6 100644 --- a/tests/3d_examples/test_3d_load_image/load_image.cpp +++ b/tests/3d_examples/test_3d_load_image/load_image.cpp @@ -44,10 +44,12 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - RealBody imported_model(sph_system, makeShared("SolidBodyFromMesh")); + SolidBodyFromMesh imported_model_shape("SolidBodyFromMesh"); + RealBody imported_model(sph_system, imported_model_shape.getName()); imported_model.defineAdaptation(1.15, 1.0, 2); - imported_model.defineBodyLevelSetShape()->writeLevelSet(sph_system); - imported_model.generateParticles(); + LevelSetShape level_set_shape(imported_model, imported_model_shape); + level_set_shape.writeLevelSet(sph_system); + imported_model.generateParticles(level_set_shape); //---------------------------------------------------------------------- // Define simple file input and outputs functions. //---------------------------------------------------------------------- @@ -70,8 +72,8 @@ int main(int ac, char *av[]) using namespace relax_dynamics; SimpleDynamics random_imported_model_particles(imported_model); /** A Physics relaxation step. */ - RelaxationStepLevelSetCorrectionInner relaxation_step_inner(imported_model_inner); - SimpleDynamics update_smoothing_length_ratio(imported_model); + RelaxationStepLevelSetCorrectionInner relaxation_step_inner(imported_model_inner, &level_set_shape); + SimpleDynamics update_smoothing_length_ratio(imported_model, level_set_shape); //---------------------------------------------------------------------- // Particle relaxation starts here. //---------------------------------------------------------------------- diff --git a/tests/3d_examples/test_3d_nonlinear_wave_fsi/nonlinear_wave_fsi.cpp b/tests/3d_examples/test_3d_nonlinear_wave_fsi/nonlinear_wave_fsi.cpp index 6c3961b525..5d3ebb9f2d 100644 --- a/tests/3d_examples/test_3d_nonlinear_wave_fsi/nonlinear_wave_fsi.cpp +++ b/tests/3d_examples/test_3d_nonlinear_wave_fsi/nonlinear_wave_fsi.cpp @@ -16,11 +16,14 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- SPHSystem system_fit(system_domain_bounds, particle_spacing_structure); system_fit.handleCommandlineOptions(ac, av)->setIOEnvironment(); - SolidBody structure_fit(system_fit, makeShared("Structure_Fit")); + + FloatingStructure structure_fit_shape("Structure_Fit"); + SolidBody structure_fit(system_fit, structure_fit_shape.getName()); structure_fit.defineAdaptation(1.3, 0.7, 3); - structure_fit.defineBodyLevelSetShape()->correctLevelSetSign()->writeLevelSet(system_fit); + LevelSetShape level_set_shape(structure_fit, structure_fit_shape); + level_set_shape.correctLevelSetSign()->writeLevelSet(system_fit); structure_fit.defineMaterial(StructureDensity); - structure_fit.generateParticles(); + structure_fit.generateParticles(level_set_shape); //---------------------------------------------------------------------- // Define body relation map. @@ -33,8 +36,8 @@ int main(int ac, char *av[]) using namespace relax_dynamics; SimpleDynamics random_imported_model_particles(structure_fit); /** A Physics relaxation step. */ - RelaxationStepLevelSetCorrectionInner relaxation_step_inner(structure_adaptive_inner); - SimpleDynamics update_smoothing_length_ratio(structure_fit); + RelaxationStepLevelSetCorrectionInner relaxation_step_inner(structure_adaptive_inner, &level_set_shape); + SimpleDynamics update_smoothing_length_ratio(structure_fit, level_set_shape); /** Write the particle reload files. */ ReloadParticleIO write_particle_reload_files(structure_fit); diff --git a/tests/3d_examples/test_3d_particle_relaxation/particle_relaxation.cpp b/tests/3d_examples/test_3d_particle_relaxation/particle_relaxation.cpp index 3a63cae19f..f649789936 100644 --- a/tests/3d_examples/test_3d_particle_relaxation/particle_relaxation.cpp +++ b/tests/3d_examples/test_3d_particle_relaxation/particle_relaxation.cpp @@ -46,10 +46,12 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - RealBody imported_model(sph_system, makeShared("SolidBodyFromMesh")); + SolidBodyFromMesh import_model_shape("SolidBodyFromMesh"); + RealBody imported_model(sph_system, import_model_shape.getName()); imported_model.defineAdaptation(1.15, 1.0, 3); - imported_model.defineBodyLevelSetShape()->correctLevelSetSign()->writeLevelSet(sph_system); - imported_model.generateParticles(); + LevelSetShape level_set_shape(imported_model, import_model_shape); + level_set_shape.correctLevelSetSign()->writeLevelSet(sph_system); + imported_model.generateParticles(level_set_shape); //---------------------------------------------------------------------- // Define simple file input and outputs functions. //---------------------------------------------------------------------- @@ -71,8 +73,8 @@ int main(int ac, char *av[]) using namespace relax_dynamics; SimpleDynamics random_imported_model_particles(imported_model); /** A Physics relaxation step. */ - RelaxationStepLevelSetCorrectionInner relaxation_step_inner(imported_model_inner); - SimpleDynamics update_smoothing_length_ratio(imported_model); + RelaxationStepLevelSetCorrectionInner relaxation_step_inner(imported_model_inner, &level_set_shape); + SimpleDynamics update_smoothing_length_ratio(imported_model, level_set_shape); //---------------------------------------------------------------------- // Particle relaxation starts here. //---------------------------------------------------------------------- diff --git a/tests/3d_examples/test_3d_particle_relaxation_single_resolution/particle_relaxation_single_resolution_3D.cpp b/tests/3d_examples/test_3d_particle_relaxation_single_resolution/particle_relaxation_single_resolution_3D.cpp index 4b3e812d1f..2cd2bc97ac 100644 --- a/tests/3d_examples/test_3d_particle_relaxation_single_resolution/particle_relaxation_single_resolution_3D.cpp +++ b/tests/3d_examples/test_3d_particle_relaxation_single_resolution/particle_relaxation_single_resolution_3D.cpp @@ -55,24 +55,24 @@ class SolidBodyFromMesh : public ComplexShape // Setting for the second geometry. // To use this, please commenting the setting for the first geometry. //---------------------------------------------------------------------- -//std::string full_path_to_file = "./input/fluid.stl"; +// std::string full_path_to_file = "./input/fluid.stl"; //---------------------------------------------------------------------- // Basic geometry parameters and numerical setup. //---------------------------------------------------------------------- -//Vec3d domain_lower_bound(-0.036, -0.046, -0.011); -//Vec3d domain_upper_bound(0.036, 0.093, 0.072); -//Vecd translation(0.0, 0.0, 0.0); -//Real scaling = 1.0; +// Vec3d domain_lower_bound(-0.036, -0.046, -0.011); +// Vec3d domain_upper_bound(0.036, 0.093, 0.072); +// Vecd translation(0.0, 0.0, 0.0); +// Real scaling = 1.0; //---------------------------------------------------------------------- // Below are common parts for the two test geometries. //---------------------------------------------------------------------- -//BoundingBox system_domain_bounds(domain_lower_bound, domain_upper_bound); -//Real dp_0 = (domain_upper_bound[0] - domain_lower_bound[0]) / 100.0; +// BoundingBox system_domain_bounds(domain_lower_bound, domain_upper_bound); +// Real dp_0 = (domain_upper_bound[0] - domain_lower_bound[0]) / 100.0; //---------------------------------------------------------------------- // define the imported model. //---------------------------------------------------------------------- -//class SolidBodyFromMesh : public ComplexShape +// class SolidBodyFromMesh : public ComplexShape //{ // public: // explicit SolidBodyFromMesh(const std::string &shape_name) : ComplexShape(shape_name) @@ -93,9 +93,11 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - RealBody imported_model(sph_system, makeShared("SolidBodyFromMesh")); + SolidBodyFromMesh import_model_shape("SolidBodyFromMesh"); + RealBody imported_model(sph_system, import_model_shape.getName()); // level set shape is used for particle relaxation - imported_model.defineBodyLevelSetShape()->correctLevelSetSign()->writeLevelSet(sph_system); + LevelSetShape level_set_shape(imported_model, import_model_shape); + level_set_shape.correctLevelSetSign()->writeLevelSet(sph_system); imported_model.generateParticles(); //---------------------------------------------------------------------- // Define simple file input and outputs functions. @@ -117,7 +119,7 @@ int main(int ac, char *av[]) using namespace relax_dynamics; SimpleDynamics random_imported_model_particles(imported_model); /** A Physics relaxation step. */ - RelaxationStepLevelSetCorrectionInner relaxation_step_inner(imported_model_inner); + RelaxationStepLevelSetCorrectionInner relaxation_step_inner(imported_model_inner, &level_set_shape); //---------------------------------------------------------------------- // Particle relaxation starts here. //---------------------------------------------------------------------- diff --git a/tests/3d_examples/test_3d_taylor_bar_UL/taylor_bar_UL.cpp b/tests/3d_examples/test_3d_taylor_bar_UL/taylor_bar_UL.cpp index 6d45f764f4..1519bbc2a2 100644 --- a/tests/3d_examples/test_3d_taylor_bar_UL/taylor_bar_UL.cpp +++ b/tests/3d_examples/test_3d_taylor_bar_UL/taylor_bar_UL.cpp @@ -12,14 +12,17 @@ int main(int ac, char *av[]) system.setReloadParticles(true); system.handleCommandlineOptions(ac, av)->setIOEnvironment(); - RealBody column(system, makeShared("Column")); - column.defineBodyLevelSetShape()->writeLevelSet(system); + Column column_shape("Column"); + RealBody column(system, column_shape.getName()); + LevelSetShape level_set_shape(column, column_shape); + level_set_shape.writeLevelSet(system); column.defineMaterial(rho0_s, c0, Youngs_modulus, poisson, yield_stress); (!system.RunParticleRelaxation() && system.ReloadParticles()) ? column.generateParticles(column.getName()) - : column.generateParticles(); + : column.generateParticles(level_set_shape); - SolidBody wall_boundary(system, makeShared("Wall")); + WallBoundary wall_boundary_shape("Wall"); + SolidBody wall_boundary(system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(rho0_s, Youngs_modulus, poisson); wall_boundary.generateParticles(wall_boundary_shape); @@ -30,7 +33,7 @@ int main(int ac, char *av[]) /**body relation topology */ InnerRelation column_inner(column); ContactRelation my_observer_contact(my_observer, {&column}); - SurfaceContactRelation column_wall_contact(column, {&wall_boundary}); + SurfaceContactRelation column_wall_contact(column, level_set_shape, {&wall_boundary}); //---------------------------------------------------------------------- // Run particle relaxation for body-fitted distribution if chosen. //---------------------------------------------------------------------- @@ -44,7 +47,7 @@ int main(int ac, char *av[]) /** Write the particle reload files. */ ReloadParticleIO write_particle_reload_files(column); /** A Physics relaxation step. */ - RelaxationStepLevelSetCorrectionInner relaxation_step_inner(column_inner); + RelaxationStepLevelSetCorrectionInner relaxation_step_inner(column_inner, &level_set_shape); /** * @brief Particle relaxation starts here. */ @@ -72,7 +75,7 @@ int main(int ac, char *av[]) // All numerical methods will be used in this case. //---------------------------------------------------------------------- SimpleDynamics initial_condition(column); - SimpleDynamics wall_normal_direction(wall_boundary); + SimpleDynamics wall_normal_direction(wall_boundary, level_set_shape); InteractionWithUpdate corrected_configuration(column_inner); Dynamics1Level column_pressure_relaxation(column_inner); Dynamics1Level column_density_relaxation(column_inner); diff --git a/tests/extra_source_and_tests/test_2d_membrane/2d_membrane.cpp b/tests/extra_source_and_tests/test_2d_membrane/2d_membrane.cpp index 980e016ab7..0ea65f3ae6 100644 --- a/tests/extra_source_and_tests/test_2d_membrane/2d_membrane.cpp +++ b/tests/extra_source_and_tests/test_2d_membrane/2d_membrane.cpp @@ -141,7 +141,7 @@ int main(int ac, char *av[]) SolidBody beam_body(sph_system, makeShared("2dMembrane")); beam_body.defineMaterial( rho_0, Youngs_modulus, poisson, diffusivity_constant_, fluid_initial_density_, water_pressure_constant_); - beam_body.generateParticles(); + beam_body.generateParticles(beam_body_shape); ObserverBody beam_observer(sph_system, "MembraneObserver"); beam_observer.defineAdaptationRatios(1.15, 2.0); From c2a90b954508bbda2ff60213b358563ea570b52a Mon Sep 17 00:00:00 2001 From: Xiangyu Hu Date: Sun, 22 Sep 2024 11:58:05 +0000 Subject: [PATCH 10/13] to continue --- src/shared/bodies/base_body_part.cpp | 5 ++--- src/shared/bodies/base_body_part.h | 5 +---- .../relax_dynamics/relax_thick_shell.cpp | 2 +- .../relax_dynamics/relax_thick_shell.h | 2 +- .../general_dynamics/geometric_dynamics.hpp | 2 +- .../test_2d_dambreak_ck/dambreak_ck.cpp | 6 +++--- .../channel_flow_shell.cpp | 2 +- tests/2d_examples/test_2d_owsc/owsc.cpp | 2 +- tests/2d_examples/test_2d_plate/2d_plate.cpp | 2 +- .../test_2d_self_contact/self_contact.cpp | 2 +- tests/2d_examples/test_2d_shell/2d_shell.cpp | 2 +- .../shell_beam_collision.cpp | 20 ++++++++++--------- .../test_2d_shell_particle_relaxation.cpp | 12 ++++++----- tests/2d_examples/test_2d_sliding/sliding.cpp | 7 ++++--- .../test_2d_sliding_solid_shell.cpp | 12 ++++++----- .../static_confinement.cpp | 11 +++++++--- tests/3d_examples/test_3d_arch/3d_arch.cpp | 2 +- .../3d_examples/test_3d_dambreak/dambreak.cpp | 2 +- .../test_3d_dambreak_elastic_plate_shell.cpp | 2 +- .../test_3d_dynamic_plate.cpp | 2 +- .../3d_elasticSolid_shell_collision.cpp | 2 +- .../poiseuille_flow_shell.cpp | 2 +- tests/3d_examples/test_3d_roof/3d_roof.cpp | 2 +- .../test_3d_slender_beam.cpp | 2 +- .../test_3d_thin_plate/test_3d_thin_plate.cpp | 2 +- .../thin_plate_python.cpp | 2 +- .../test_2d_dambreak_sycl/dambreak_sycl.cpp | 4 ++-- .../test_thin_structure_dynamics.cpp | 2 +- 28 files changed, 64 insertions(+), 56 deletions(-) diff --git a/src/shared/bodies/base_body_part.cpp b/src/shared/bodies/base_body_part.cpp index c886300071..7597d4ca49 100644 --- a/src/shared/bodies/base_body_part.cpp +++ b/src/shared/bodies/base_body_part.cpp @@ -106,9 +106,8 @@ bool BodyRegionByCell::checkNotFar(Vecd cell_position, Real threshold) return body_part_shape_.checkNotFar(cell_position, threshold); } //=================================================================================================// -NearShapeSurface::NearShapeSurface(RealBody &real_body, Shape &shape) - : BodyPartByCell(real_body, shape.getName()), - level_set_shape_(DynamicCast(this, shape)) +NearShapeSurface::NearShapeSurface(RealBody &real_body, LevelSetShape &level_set_shape) + : BodyPartByCell(real_body, level_set_shape.getName()), level_set_shape_(level_set_shape) { TaggingCellMethod tagging_cell_method = std::bind(&NearShapeSurface::checkNearSurface, this, _1, _2); tagCells(tagging_cell_method); diff --git a/src/shared/bodies/base_body_part.h b/src/shared/bodies/base_body_part.h index 8a29277ee0..f27309899b 100644 --- a/src/shared/bodies/base_body_part.h +++ b/src/shared/bodies/base_body_part.h @@ -204,11 +204,8 @@ class BodyRegionByCell : public BodyPartByCell */ class NearShapeSurface : public BodyPartByCell { - private: - UniquePtrKeeper level_set_shape_keeper_; - public: - NearShapeSurface(RealBody &real_body, Shape &shape); + NearShapeSurface(RealBody &real_body, LevelSetShape &level_set_shape); virtual ~NearShapeSurface(){}; LevelSetShape &getLevelSetShape() { return level_set_shape_; }; diff --git a/src/shared/particle_dynamics/relax_dynamics/relax_thick_shell.cpp b/src/shared/particle_dynamics/relax_dynamics/relax_thick_shell.cpp index 2d73e78c2f..f9627d1030 100644 --- a/src/shared/particle_dynamics/relax_dynamics/relax_thick_shell.cpp +++ b/src/shared/particle_dynamics/relax_dynamics/relax_thick_shell.cpp @@ -169,7 +169,7 @@ void ShellNormalDirectionPrediction::SmoothingNormal::update(size_t index_i, Rea smoothed_[index_i] /= temp_[index_i].norm() + TinyReal; } //=================================================================================================// -ShellRelaxationStep::ShellRelaxationStep(BaseInnerRelation &inner_relation, Shape &relax_shape) +ShellRelaxationStep::ShellRelaxationStep(BaseInnerRelation &inner_relation, LevelSetShape &relax_shape) : BaseDynamics(), real_body_(DynamicCast(this, inner_relation.getSPHBody())), inner_relation_(inner_relation), near_shape_surface_(real_body_, relax_shape), diff --git a/src/shared/particle_dynamics/relax_dynamics/relax_thick_shell.h b/src/shared/particle_dynamics/relax_dynamics/relax_thick_shell.h index d8b7905d6f..deda3ab634 100644 --- a/src/shared/particle_dynamics/relax_dynamics/relax_thick_shell.h +++ b/src/shared/particle_dynamics/relax_dynamics/relax_thick_shell.h @@ -157,7 +157,7 @@ class ShellNormalDirectionPrediction : public BaseDynamics class ShellRelaxationStep : public BaseDynamics { public: - explicit ShellRelaxationStep(BaseInnerRelation &inner_relation, Shape &relax_shape); + explicit ShellRelaxationStep(BaseInnerRelation &inner_relation, LevelSetShape &relax_shape); virtual ~ShellRelaxationStep(){}; virtual void exec(Real dt = 0.0) override; SimpleDynamics &MidSurfaceBounding() { return mid_surface_bounding_; }; diff --git a/src/shared/shared_ck/particle_dynamics/general_dynamics/geometric_dynamics.hpp b/src/shared/shared_ck/particle_dynamics/general_dynamics/geometric_dynamics.hpp index fad79b5f11..9fdb78292b 100644 --- a/src/shared/shared_ck/particle_dynamics/general_dynamics/geometric_dynamics.hpp +++ b/src/shared/shared_ck/particle_dynamics/general_dynamics/geometric_dynamics.hpp @@ -10,7 +10,7 @@ namespace SPH template NormalFromBodyShapeCK::UpdateKernel:: UpdateKernel(const ExecutionPolicy &ex_policy, NormalFromBodyShapeCK &encloser) - : initial_shape_(encloser.initial_shape_), + : shape_(encloser.shape_), pos_(encloser.dv_pos_->DelegatedDataField(ex_policy)), n_(encloser.dv_n_->DelegatedDataField(ex_policy)), n0_(encloser.dv_n0_->DelegatedDataField(ex_policy)), diff --git a/tests/2d_examples/2d_examples_ck/test_2d_dambreak_ck/dambreak_ck.cpp b/tests/2d_examples/2d_examples_ck/test_2d_dambreak_ck/dambreak_ck.cpp index bf83c87b06..1bdfc134d4 100644 --- a/tests/2d_examples/2d_examples_ck/test_2d_dambreak_ck/dambreak_ck.cpp +++ b/tests/2d_examples/2d_examples_ck/test_2d_dambreak_ck/dambreak_ck.cpp @@ -58,12 +58,12 @@ int main(int ac, char *av[]) // Creating bodies with corresponding materials and particles. //---------------------------------------------------------------------- TransformShape initial_water_block(Transform(water_block_translation), water_block_halfsize, "WaterBody"); - FluidBody water_block(sph_system, initial_water_block); + FluidBody water_block(sph_system, initial_water_block.getName()); water_block.defineMaterial(rho0_f, c_f); water_block.generateParticles(initial_water_block); WallBoundary wall_boundary_shape("WallBoundary"); - SolidBody wall_boundary(sph_system, wall_boundary_shape); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); wall_boundary.generateParticles(wall_boundary_shape); @@ -99,7 +99,7 @@ int main(int ac, char *av[]) ParticleSortCK particle_sort(water_block); Gravity gravity(Vecd(0.0, -gravity_g)); StateDynamics> constant_gravity(water_block, gravity); - StateDynamics wall_boundary_normal_direction(wall_boundary); + StateDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); StateDynamics water_advection_step_setup(water_block); StateDynamics water_advection_step_close(water_block); diff --git a/tests/2d_examples/test_2d_channel_flow_fluid_shell/channel_flow_shell.cpp b/tests/2d_examples/test_2d_channel_flow_fluid_shell/channel_flow_shell.cpp index b35dbcf5a6..e051511ab9 100644 --- a/tests/2d_examples/test_2d_channel_flow_fluid_shell/channel_flow_shell.cpp +++ b/tests/2d_examples/test_2d_channel_flow_fluid_shell/channel_flow_shell.cpp @@ -171,7 +171,7 @@ void channel_flow_shell(const Real resolution_ref, const Real wall_thickness) water_block.defineMaterial(rho0_f, c_f, mu_f); water_block.generateParticles(water_block_shape); - SolidBody wall_boundary(sph_system, makeShared("Wall")); + SolidBody wall_boundary(sph_system, "Wall"); wall_boundary.defineMaterial(); wall_boundary.generateParticles(resolution_ref, wall_thickness); diff --git a/tests/2d_examples/test_2d_owsc/owsc.cpp b/tests/2d_examples/test_2d_owsc/owsc.cpp index 2d29736de3..0e2a8697b7 100644 --- a/tests/2d_examples/test_2d_owsc/owsc.cpp +++ b/tests/2d_examples/test_2d_owsc/owsc.cpp @@ -69,7 +69,7 @@ int main(int ac, char *av[]) SimpleDynamics> constant_gravity(water_block, gravity); SimpleDynamics flap_offset_position(flap, offset); SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); - SimpleDynamics flap_normal_direction(flap); + SimpleDynamics flap_normal_direction(flap, flap_shape); Dynamics1Level pressure_relaxation(water_block_inner, water_block_contact); Dynamics1Level density_relaxation(water_block_inner, water_block_contact); diff --git a/tests/2d_examples/test_2d_plate/2d_plate.cpp b/tests/2d_examples/test_2d_plate/2d_plate.cpp index af0390dda9..0f1d1564db 100644 --- a/tests/2d_examples/test_2d_plate/2d_plate.cpp +++ b/tests/2d_examples/test_2d_plate/2d_plate.cpp @@ -93,7 +93,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - SolidBody plate_body(sph_system, makeShared("PlateBody")); + SolidBody plate_body(sph_system, "PlateBody"); plate_body.defineMaterial(rho0_s, Youngs_modulus, poisson); plate_body.generateParticles(); diff --git a/tests/2d_examples/test_2d_self_contact/self_contact.cpp b/tests/2d_examples/test_2d_self_contact/self_contact.cpp index d1cabb8d30..0ae2b788ee 100644 --- a/tests/2d_examples/test_2d_self_contact/self_contact.cpp +++ b/tests/2d_examples/test_2d_self_contact/self_contact.cpp @@ -139,7 +139,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- InnerRelation beam_body_inner(beam_body); ContactRelation beam_observer_contact(beam_observer, {&beam_body}); - SelfSurfaceContactRelation beam_self_contact(beam_body); + SelfSurfaceContactRelation beam_self_contact(beam_body, beam_body_shape); //----------------------------------------------------------------------------- // this section define all numerical methods will be used in this case //----------------------------------------------------------------------------- diff --git a/tests/2d_examples/test_2d_shell/2d_shell.cpp b/tests/2d_examples/test_2d_shell/2d_shell.cpp index e9eb754234..3f93b1f0ac 100644 --- a/tests/2d_examples/test_2d_shell/2d_shell.cpp +++ b/tests/2d_examples/test_2d_shell/2d_shell.cpp @@ -92,7 +92,7 @@ int main(int ac, char *av[]) sph_system.handleCommandlineOptions(ac, av); /** Create a Cylinder body. */ - SolidBody cylinder_body(sph_system, makeShared("CylinderBody")); + SolidBody cylinder_body(sph_system, "CylinderBody"); cylinder_body.defineMaterial(rho0_s, Youngs_modulus, poisson); cylinder_body.generateParticles(); diff --git a/tests/2d_examples/test_2d_shell_beam_collision/shell_beam_collision.cpp b/tests/2d_examples/test_2d_shell_beam_collision/shell_beam_collision.cpp index 68224e3b37..87d9ea7fd7 100644 --- a/tests/2d_examples/test_2d_shell_beam_collision/shell_beam_collision.cpp +++ b/tests/2d_examples/test_2d_shell_beam_collision/shell_beam_collision.cpp @@ -90,8 +90,10 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - SolidBody shell(sph_system, makeShared("Shell")); + Shell shell_shape("Shell"); + SolidBody shell(sph_system, shell_shape.getName()); shell.defineAdaptation(1.15, 1.0); + LevelSetShape level_set_shape(shell, shell_shape, level_set_refinement_ratio); shell.defineMaterial(); if (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) { @@ -99,8 +101,7 @@ int main(int ac, char *av[]) } else { - shell.defineBodyLevelSetShape(level_set_refinement_ratio)->writeLevelSet(sph_system); - shell.generateParticles(thickness); + shell.generateParticles(level_set_shape, thickness); } if (!sph_system.RunParticleRelaxation() && !sph_system.ReloadParticles()) @@ -109,9 +110,10 @@ int main(int ac, char *av[]) return 0; } - SolidBody beam(sph_system, makeShared("Beam")); + Beam beam_shape("Beam"); + SolidBody beam(sph_system, beam_shape.getName()); beam.defineMaterial(rho0_s, Youngs_modulus, poisson); - beam.generateParticles(); + beam.generateParticles(beam_shape); //---------------------------------------------------------------------- // Define body relation map. // The contact map gives the topological connections between the bodies. @@ -121,8 +123,8 @@ int main(int ac, char *av[]) // inner and contact relations. //---------------------------------------------------------------------- InnerRelation beam_inner(beam); - SurfaceContactRelation shell_contact(shell, {&beam}); - ShellSurfaceContactRelation beam_contact(beam, {&shell}); + SurfaceContactRelation shell_contact(shell, shell_shape, {&beam}); + ShellSurfaceContactRelation beam_contact(beam, beam_shape, {&shell}); //---------------------------------------------------------------------- // Run particle relaxation for body-fitted distribution if chosen. //---------------------------------------------------------------------- @@ -137,8 +139,8 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- using namespace relax_dynamics; SimpleDynamics shell_random_particles(shell); - ShellRelaxationStep relaxation_step_shell_inner(shell_inner); - ShellNormalDirectionPrediction shell_normal_prediction(shell_inner, thickness, cos(Pi / 3.75)); + ShellRelaxationStep relaxation_step_shell_inner(shell_inner, level_set_shape); + ShellNormalDirectionPrediction shell_normal_prediction(shell_inner, level_set_shape, thickness, cos(Pi / 3.75)); //---------------------------------------------------------------------- // Output for particle relaxation. //---------------------------------------------------------------------- diff --git a/tests/2d_examples/test_2d_shell_particle_relaxation/test_2d_shell_particle_relaxation.cpp b/tests/2d_examples/test_2d_shell_particle_relaxation/test_2d_shell_particle_relaxation.cpp index fef5499521..2ebe4f1f2d 100644 --- a/tests/2d_examples/test_2d_shell_particle_relaxation/test_2d_shell_particle_relaxation.cpp +++ b/tests/2d_examples/test_2d_shell_particle_relaxation/test_2d_shell_particle_relaxation.cpp @@ -40,17 +40,19 @@ int main(int ac, char *av[]) sph_system.handleCommandlineOptions(ac, av)->setIOEnvironment(); /** Creating body, materials and particles. */ - SolidBody pipe_body(sph_system, makeShared("PipeBody")); + Pipe pipe_body_shape("PipeBody"); + SolidBody pipe_body(sph_system, pipe_body_shape.getName()); pipe_body.defineAdaptation(1.15, 1.0); - pipe_body.defineBodyLevelSetShape(level_set_refinement_ratio)->writeLevelSet(sph_system); - pipe_body.generateParticles(thickness); + LevelSetShape level_set_shape(pipe_body, pipe_body_shape, level_set_refinement_ratio); + level_set_shape.writeLevelSet(sph_system); + pipe_body.generateParticles(level_set_shape, thickness); InnerRelation pipe_body_inner(pipe_body); using namespace relax_dynamics; SimpleDynamics random_pipe_body_particles(pipe_body); /** A Physics relaxation step. */ - ShellRelaxationStep relaxation_step_pipe_body_inner(pipe_body_inner); - ShellNormalDirectionPrediction shell_normal_prediction(pipe_body_inner, thickness); + ShellRelaxationStep relaxation_step_pipe_body_inner(pipe_body_inner, level_set_shape); + ShellNormalDirectionPrediction shell_normal_prediction(pipe_body_inner, level_set_shape, thickness); /** * @brief define simple data file input and outputs functions. */ diff --git a/tests/2d_examples/test_2d_sliding/sliding.cpp b/tests/2d_examples/test_2d_sliding/sliding.cpp index 60d1e91e09..9d0a00a6ea 100644 --- a/tests/2d_examples/test_2d_sliding/sliding.cpp +++ b/tests/2d_examples/test_2d_sliding/sliding.cpp @@ -74,9 +74,10 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles //---------------------------------------------------------------------- - SolidBody free_cube(sph_system, makeShared("FreeCube")); + Cube cube_shape("FreeCube"); + SolidBody free_cube(sph_system, cube_shape.getName()); free_cube.defineMaterial(rho0_s, Youngs_modulus, poisson); - free_cube.generateParticles(); + free_cube.generateParticles(cube_shape); WallBoundary wall_boundary_shape("WallBoundary"); SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); @@ -94,7 +95,7 @@ int main(int ac, char *av[]) // inner and contact relations. //---------------------------------------------------------------------- InnerRelation free_cube_inner(free_cube); - SurfaceContactRelation free_cube_contact(free_cube, {&wall_boundary}); + SurfaceContactRelation free_cube_contact(free_cube, cube_shape, {&wall_boundary}); ContactRelation cube_observer_contact(cube_observer, {&free_cube}); //---------------------------------------------------------------------- // Define the main numerical methods used in the simulation. diff --git a/tests/2d_examples/test_2d_sliding_solid_shell/test_2d_sliding_solid_shell.cpp b/tests/2d_examples/test_2d_sliding_solid_shell/test_2d_sliding_solid_shell.cpp index c588eef7e2..fa4741313b 100644 --- a/tests/2d_examples/test_2d_sliding_solid_shell/test_2d_sliding_solid_shell.cpp +++ b/tests/2d_examples/test_2d_sliding_solid_shell/test_2d_sliding_solid_shell.cpp @@ -83,12 +83,14 @@ void run_simulation() //---------------------------------------------------------------------- // Creating body, materials and particles //---------------------------------------------------------------------- - SolidBody free_cube(sph_system, makeShared("FreeCube")); - free_cube.defineBodyLevelSetShape()->cleanLevelSet(0); + Cube cube_shape("FreeCube"); + SolidBody free_cube(sph_system, cube_shape.getName()); + LevelSetShape level_set_shape(free_cube, cube_shape); + level_set_shape.cleanLevelSet(0); free_cube.defineMaterial(rho0_s, Youngs_modulus, poisson); - free_cube.generateParticles(); + free_cube.generateParticles(level_set_shape); - SolidBody wall_boundary(sph_system, makeShared("Wall")); + SolidBody wall_boundary(sph_system, "Wall"); wall_boundary.defineAdaptation(1.15, resolution_ref / resolution_shell); wall_boundary.defineMaterial(rho0_s, Youngs_modulus, poisson); wall_boundary.generateParticles(); @@ -104,7 +106,7 @@ void run_simulation() // inner and contact relations. //---------------------------------------------------------------------- InnerRelation free_cube_inner(free_cube); - SurfaceContactRelation free_cube_contact(free_cube, {&wall_boundary}, {false}); + SurfaceContactRelation free_cube_contact(free_cube, level_set_shape, {&wall_boundary}, {false}); ShellInnerRelationWithContactKernel wall_curvature_inner(wall_boundary, free_cube); ContactRelation cube_observer_contact(cube_observer, {&free_cube}); //---------------------------------------------------------------------- diff --git a/tests/2d_examples/test_2d_static_confinement/static_confinement.cpp b/tests/2d_examples/test_2d_static_confinement/static_confinement.cpp index a17645162f..eb6ce05e9c 100644 --- a/tests/2d_examples/test_2d_static_confinement/static_confinement.cpp +++ b/tests/2d_examples/test_2d_static_confinement/static_confinement.cpp @@ -141,11 +141,16 @@ int main(int ac, char *av[]) ReduceDynamics get_fluid_time_step_size(water_block); /** Define the confinement condition for wall. */ - NearShapeSurface near_surface_wall(water_block, makeShared("Wall")); - near_surface_wall.getLevelSetShape().writeLevelSet(sph_system); + WallShape wall_shape("Wall"); + LevelSetShape wall_level_set_shape(water_block, wall_shape); + wall_level_set_shape.writeLevelSet(sph_system); + NearShapeSurface near_surface_wall(water_block, wall_level_set_shape); fluid_dynamics::StaticConfinement confinement_condition_wall(near_surface_wall); /** Define the confinement condition for structure. */ - NearShapeSurface near_surface_triangle(water_block, makeShared>("Triangle")); + InverseShape structure_shape("Triangle"); + LevelSetShape structure_level_set_shape(water_block, structure_shape); + structure_level_set_shape.writeLevelSet(sph_system); + NearShapeSurface near_surface_triangle(water_block, structure_level_set_shape); near_surface_triangle.getLevelSetShape().writeLevelSet(sph_system); fluid_dynamics::StaticConfinement confinement_condition_triangle(near_surface_triangle); /** Push back the static confinement condition to corresponding dynamics. */ diff --git a/tests/3d_examples/test_3d_arch/3d_arch.cpp b/tests/3d_examples/test_3d_arch/3d_arch.cpp index fe88e91087..921bec1ab9 100644 --- a/tests/3d_examples/test_3d_arch/3d_arch.cpp +++ b/tests/3d_examples/test_3d_arch/3d_arch.cpp @@ -148,7 +148,7 @@ int main(int ac, char *av[]) #endif IOEnvironment io_environment(sph_system); /** create a cylinder body with shell particles and linear elasticity. */ - SolidBody cylinder_body(sph_system, makeShared("CylinderBody")); + SolidBody cylinder_body(sph_system, "CylinderBody"); cylinder_body.defineMaterial(rho0_s, Youngs_modulus, poisson); cylinder_body.generateParticles(); diff --git a/tests/3d_examples/test_3d_dambreak/dambreak.cpp b/tests/3d_examples/test_3d_dambreak/dambreak.cpp index 29c5221e5a..ab9d01a8fa 100644 --- a/tests/3d_examples/test_3d_dambreak/dambreak.cpp +++ b/tests/3d_examples/test_3d_dambreak/dambreak.cpp @@ -73,7 +73,7 @@ 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); + FluidBody water_block(sph_system, initial_water_block.getName()); water_block.defineMaterial(rho0_f, c_f); water_block.generateParticles(water_block_shape); diff --git a/tests/3d_examples/test_3d_dambreak_elastic_plate_shell/test_3d_dambreak_elastic_plate_shell.cpp b/tests/3d_examples/test_3d_dambreak_elastic_plate_shell/test_3d_dambreak_elastic_plate_shell.cpp index 00f803f3dd..b12b7e97a7 100644 --- a/tests/3d_examples/test_3d_dambreak_elastic_plate_shell/test_3d_dambreak_elastic_plate_shell.cpp +++ b/tests/3d_examples/test_3d_dambreak_elastic_plate_shell/test_3d_dambreak_elastic_plate_shell.cpp @@ -176,7 +176,7 @@ int main(int ac, char *av[]) gate.defineMaterial(); gate.generateParticles(); - SolidBody plate(sph_system, makeShared("Plate")); + SolidBody plate(sph_system, "Plate"); plate.defineAdaptation(1.15, resolution_ref / resolution_shell); plate.defineMaterial(rho0_s, youngs_modulus, poisson_ratio); plate.generateParticles(); diff --git a/tests/3d_examples/test_3d_dynamic_plate/test_3d_dynamic_plate.cpp b/tests/3d_examples/test_3d_dynamic_plate/test_3d_dynamic_plate.cpp index b7bf44a514..17e93c0995 100644 --- a/tests/3d_examples/test_3d_dynamic_plate/test_3d_dynamic_plate.cpp +++ b/tests/3d_examples/test_3d_dynamic_plate/test_3d_dynamic_plate.cpp @@ -94,7 +94,7 @@ int main(int ac, char *av[]) SPHSystem sph_system(system_domain_bounds, particle_spacing_ref); sph_system.handleCommandlineOptions(ac, av); /** create a plate body. */ - SolidBody plate_body(sph_system, makeShared("PlateBody")); + SolidBody plate_body(sph_system, "PlateBody"); plate_body.defineMaterial(rho0_s, Youngs_modulus, poisson); plate_body.generateParticles(); diff --git a/tests/3d_examples/test_3d_elasticSolid_shell_collision/3d_elasticSolid_shell_collision.cpp b/tests/3d_examples/test_3d_elasticSolid_shell_collision/3d_elasticSolid_shell_collision.cpp index 4dc191beee..c50a2a98f6 100644 --- a/tests/3d_examples/test_3d_elasticSolid_shell_collision/3d_elasticSolid_shell_collision.cpp +++ b/tests/3d_examples/test_3d_elasticSolid_shell_collision/3d_elasticSolid_shell_collision.cpp @@ -74,7 +74,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - SolidBody shell(sph_system, makeShared("shell")); + SolidBody shell(sph_system, "shell"); shell.defineMaterial(); shell.generateParticles(); diff --git a/tests/3d_examples/test_3d_poiseuille_flow_shell/poiseuille_flow_shell.cpp b/tests/3d_examples/test_3d_poiseuille_flow_shell/poiseuille_flow_shell.cpp index 29cea1bad6..8e35a23543 100644 --- a/tests/3d_examples/test_3d_poiseuille_flow_shell/poiseuille_flow_shell.cpp +++ b/tests/3d_examples/test_3d_poiseuille_flow_shell/poiseuille_flow_shell.cpp @@ -179,7 +179,7 @@ void poiseuille_flow(const Real resolution_ref, const Real resolution_shell, con ParticleBuffer inlet_particle_buffer(0.5); water_block.generateParticlesWithReserve(inlet_particle_buffer, water_block_shape); - SolidBody shell_boundary(system, makeShared("Shell")); + SolidBody shell_boundary(system, "Shell"); shell_boundary.defineAdaptation(1.15, resolution_ref / resolution_shell); shell_boundary.defineMaterial(1, 1e3, 0.45); shell_boundary.generateParticles(resolution_shell, wall_thickness, shell_thickness); diff --git a/tests/3d_examples/test_3d_roof/3d_roof.cpp b/tests/3d_examples/test_3d_roof/3d_roof.cpp index 79ea610955..3ec0c0781e 100644 --- a/tests/3d_examples/test_3d_roof/3d_roof.cpp +++ b/tests/3d_examples/test_3d_roof/3d_roof.cpp @@ -106,7 +106,7 @@ int main(int ac, char *av[]) SPHSystem sph_system(system_domain_bounds, particle_spacing_ref); sph_system.handleCommandlineOptions(ac, av); // handle command line arguments /** Create a Cylinder body. */ - SolidBody cylinder_body(sph_system, makeShared("CylinderBody")); + SolidBody cylinder_body(sph_system, "CylinderBody"); cylinder_body.defineMaterial(rho0_s, Youngs_modulus, poisson); cylinder_body.generateParticles(); /** Define Observer. */ diff --git a/tests/3d_examples/test_3d_slender_beam/test_3d_slender_beam.cpp b/tests/3d_examples/test_3d_slender_beam/test_3d_slender_beam.cpp index b800e1d9e7..e51ae592cf 100644 --- a/tests/3d_examples/test_3d_slender_beam/test_3d_slender_beam.cpp +++ b/tests/3d_examples/test_3d_slender_beam/test_3d_slender_beam.cpp @@ -127,7 +127,7 @@ int main(int ac, char *av[]) SPHSystem sph_system(system_domain_bounds, resolution_ref); /** create a bar body. */ - SolidBody bar_body(sph_system, makeShared("BarBody")); + SolidBody bar_body(sph_system, "BarBody"); bar_body.defineMaterial(rho0_s, Youngs_modulus, poisson); bar_body.generateParticles(); diff --git a/tests/3d_examples/test_3d_thin_plate/test_3d_thin_plate.cpp b/tests/3d_examples/test_3d_thin_plate/test_3d_thin_plate.cpp index c1167b8995..60728eb6e4 100644 --- a/tests/3d_examples/test_3d_thin_plate/test_3d_thin_plate.cpp +++ b/tests/3d_examples/test_3d_thin_plate/test_3d_thin_plate.cpp @@ -124,7 +124,7 @@ int main(int ac, char *av[]) SPHSystem sph_system(system_domain_bounds, resolution_ref); /** create a plate body. */ - SolidBody plate_body(sph_system, makeShared("PlateBody")); + SolidBody plate_body(sph_system, "PlateBody"); plate_body.defineMaterial(rho0_s, Youngs_modulus, poisson); plate_body.generateParticles(); diff --git a/tests/extra_source_and_tests/test_3d_thin_plate_python/thin_plate_python.cpp b/tests/extra_source_and_tests/test_3d_thin_plate_python/thin_plate_python.cpp index 0643863e1b..1c906963c0 100644 --- a/tests/extra_source_and_tests/test_3d_thin_plate_python/thin_plate_python.cpp +++ b/tests/extra_source_and_tests/test_3d_thin_plate_python/thin_plate_python.cpp @@ -128,7 +128,7 @@ class PreSettingCase : public Parameter PreSettingCase() : system_domain_bounds(Vec3d(-BW, -BW, -0.5 * resolution_ref), Vec3d(PL + BW, PH + BW, 0.5 * resolution_ref)), system(system_domain_bounds, resolution_ref), - plate_body(system, makeShared("PlateBody")), + plate_body(system, "PlateBody"), plate_observer(system, "PlateObserver") { //---------------------------------------------------------------------- diff --git a/tests/tests_sycl/2d_examples/test_2d_dambreak_sycl/dambreak_sycl.cpp b/tests/tests_sycl/2d_examples/test_2d_dambreak_sycl/dambreak_sycl.cpp index 9e6ec22473..5d4d3858ff 100644 --- a/tests/tests_sycl/2d_examples/test_2d_dambreak_sycl/dambreak_sycl.cpp +++ b/tests/tests_sycl/2d_examples/test_2d_dambreak_sycl/dambreak_sycl.cpp @@ -58,7 +58,7 @@ int main(int ac, char *av[]) // Creating bodies with corresponding materials and particles. //---------------------------------------------------------------------- TransformShape initial_water_block(Transform(water_block_translation), water_block_halfsize, "WaterBody"); - FluidBody water_block(sph_system, initial_water_block); + FluidBody water_block(sph_system, initial_water_block.getName()); water_block.defineMaterial(rho0_f, c_f); water_block.generateParticles(water_block_shape); @@ -99,7 +99,7 @@ int main(int ac, char *av[]) ParticleSortCK particle_sort(water_block); Gravity gravity(Vecd(0.0, -gravity_g)); StateDynamics> constant_gravity(water_block, gravity); - StateDynamics wall_boundary_normal_direction(wall_boundary); + StateDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); StateDynamics water_advection_step_setup(water_block); StateDynamics water_advection_step_close(water_block); diff --git a/tests/unit_tests_src/shared/particle_dynamics/solid_dynamics/test_thin_structure_dynamics/test_thin_structure_dynamics.cpp b/tests/unit_tests_src/shared/particle_dynamics/solid_dynamics/test_thin_structure_dynamics/test_thin_structure_dynamics.cpp index 96e0bc27fc..002da09026 100644 --- a/tests/unit_tests_src/shared/particle_dynamics/solid_dynamics/test_thin_structure_dynamics/test_thin_structure_dynamics.cpp +++ b/tests/unit_tests_src/shared/particle_dynamics/solid_dynamics/test_thin_structure_dynamics/test_thin_structure_dynamics.cpp @@ -132,7 +132,7 @@ int main(int ac, char *av[]) SPHSystem system(system_domain_bounds, resolution_ref); /** create a plate body. */ - SolidBody plate_body(system, makeShared("PlateBody")); + SolidBody plate_body(system, "PlateBody"); plate_body.defineMaterial(rho0_s, Youngs_modulus, poisson); plate_body.generateParticles(); auto shell_particles = dynamic_cast(&plate_body.getBaseParticles()); From 5cac10873c9cec88cc9546ae97c9d801a1d20ec2 Mon Sep 17 00:00:00 2001 From: Xiangyu Hu Date: Sun, 22 Sep 2024 13:04:16 +0000 Subject: [PATCH 11/13] to continue --- .../diffusion_NeumannBC.cpp | 2 +- tests/2d_examples/test_2d_fsi2/fsi2.cpp | 4 +-- .../droplet_conservation.cpp | 5 ++-- tests/2d_examples/test_2d_stlw/stlw.cpp | 2 +- .../src/tethered_dead_fish_in_flow.cpp | 4 +-- tests/2d_examples/test_2d_throat/throat.cpp | 2 +- .../two_phase_dambreak.cpp | 5 ++-- .../viscous_cream_drop.cpp | 9 +++--- .../windows_frame_diffusion_D4.cpp | 2 +- .../windows_frame_diffusion_D7.cpp | 2 +- .../excitation_contraction.cpp | 29 +++++++++++-------- .../VP_heat_flux_optimization.cpp | 7 +++-- .../VP_heat_flux_steady.cpp | 7 +++-- .../VP_same_sink_optimization.cpp | 7 +++-- .../VP_same_sink_steady.cpp | 7 +++-- 15 files changed, 53 insertions(+), 41 deletions(-) diff --git a/tests/2d_examples/test_2d_diffusion_NeumannBC/diffusion_NeumannBC.cpp b/tests/2d_examples/test_2d_diffusion_NeumannBC/diffusion_NeumannBC.cpp index 71401236f4..724d4f15e2 100644 --- a/tests/2d_examples/test_2d_diffusion_NeumannBC/diffusion_NeumannBC.cpp +++ b/tests/2d_examples/test_2d_diffusion_NeumannBC/diffusion_NeumannBC.cpp @@ -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 diffusion_body_normal_direction(diffusion_body, diffusion_body_shape); + SimpleDynamics wall_boundary_normal_direction(wall_Neumann, wall_shape_Neumann); DiffusionBodyRelaxation temperature_relaxation( diff --git a/tests/2d_examples/test_2d_fsi2/fsi2.cpp b/tests/2d_examples/test_2d_fsi2/fsi2.cpp index 76aaaf05eb..7a0fe8af7b 100644 --- a/tests/2d_examples/test_2d_fsi2/fsi2.cpp +++ b/tests/2d_examples/test_2d_fsi2/fsi2.cpp @@ -67,7 +67,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- using namespace relax_dynamics; SimpleDynamics random_insert_body_particles(insert_body); - RelaxationStepInner relaxation_step_inner(insert_body_inner); + RelaxationStepInner relaxation_step_inner(insert_body_inner, level_set_shape); BodyStatesRecordingToVtp write_insert_body_to_vtp(insert_body); ReloadParticleIO write_particle_reload_files(insert_body); //---------------------------------------------------------------------- @@ -125,7 +125,7 @@ int main(int ac, char *av[]) // The coupling with multi-body dynamics will be introduced at last. //---------------------------------------------------------------------- SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); - SimpleDynamics insert_body_normal_direction(insert_body); + SimpleDynamics insert_body_normal_direction(insert_body, level_set_shape); InteractionWithUpdate insert_body_corrected_configuration(insert_body_inner); Dynamics1Level insert_body_stress_relaxation_first_half(insert_body_inner); diff --git a/tests/2d_examples/test_2d_square_droplet/droplet_conservation.cpp b/tests/2d_examples/test_2d_square_droplet/droplet_conservation.cpp index 55695d19fd..d789d6024d 100644 --- a/tests/2d_examples/test_2d_square_droplet/droplet_conservation.cpp +++ b/tests/2d_examples/test_2d_square_droplet/droplet_conservation.cpp @@ -95,9 +95,10 @@ int main(int ac, char *av[]) water_block.defineMaterial(rho0_f, c_f, mu_f); water_block.generateParticles(water_block_shape); - FluidBody air_block(sph_system, makeShared("AirBody")); + AirBlock air_block_shape("AirBody"); + FluidBody air_block(sph_system, air_block_shape.getName()); air_block.defineMaterial(rho0_a, c_f, mu_a); - air_block.generateParticles(); + air_block.generateParticles(air_block_shape); WallBoundary wall_boundary_shape("WallBoundary"); SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); diff --git a/tests/2d_examples/test_2d_stlw/stlw.cpp b/tests/2d_examples/test_2d_stlw/stlw.cpp index daeab58ed1..cd952c95c4 100644 --- a/tests/2d_examples/test_2d_stlw/stlw.cpp +++ b/tests/2d_examples/test_2d_stlw/stlw.cpp @@ -18,7 +18,7 @@ int main(int ac, char *av[]) // Creating body, materials and particles. //---------------------------------------------------------------------- TransformShape water_block_shape(Transform(water_block_translation), water_block_halfsize, "WaterBody"); - FluidBody water_block(sph_system, water_block_shape); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); water_block.generateParticles(water_block_shape); diff --git a/tests/2d_examples/test_2d_tethered_dead_fish_in_flow/src/tethered_dead_fish_in_flow.cpp b/tests/2d_examples/test_2d_tethered_dead_fish_in_flow/src/tethered_dead_fish_in_flow.cpp index baeae5a3b6..b87d26950f 100644 --- a/tests/2d_examples/test_2d_tethered_dead_fish_in_flow/src/tethered_dead_fish_in_flow.cpp +++ b/tests/2d_examples/test_2d_tethered_dead_fish_in_flow/src/tethered_dead_fish_in_flow.cpp @@ -264,7 +264,7 @@ int main(int ac, char *av[]) ReloadParticleIO write_particle_reload_files(fish_body); /** A Physics relaxation step. */ - RelaxationStepInner relaxation_step_inner(fish_body_inner); + RelaxationStepInner relaxation_step_inner(fish_body_inner, level_set_shape); /** * @brief Particle relaxation starts here. */ @@ -301,7 +301,7 @@ int main(int ac, char *av[]) PeriodicAlongAxis periodic_along_x(water_block_shape.getBounds(), xAxis); PeriodicConditionUsingCellLinkedList periodic_condition(water_block, periodic_along_x); SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); - SimpleDynamics fish_body_normal_direction(fish_body); + SimpleDynamics fish_body_normal_direction(fish_body, level_set_shape); /** Corrected configuration.*/ InteractionWithUpdate fish_body_corrected_configuration(fish_body_inner); /** diff --git a/tests/2d_examples/test_2d_throat/throat.cpp b/tests/2d_examples/test_2d_throat/throat.cpp index 0ef326666d..214adf1d86 100644 --- a/tests/2d_examples/test_2d_throat/throat.cpp +++ b/tests/2d_examples/test_2d_throat/throat.cpp @@ -166,7 +166,7 @@ int main(int ac, char *av[]) //------------------------------------------------------------------- Gravity gravity(Vecd(gravity_g, 0.0)); SimpleDynamics> constant_gravity(fluid_block, gravity); - InteractionDynamics wall_boundary_normal_direction(wall_boundary_inner); + InteractionDynamics wall_boundary_normal_direction(wall_boundary_inner, wall_boundary_shape); InteractionDynamics distance_to_wall(fluid_block_contact); Dynamics1Level pressure_relaxation(fluid_block_inner, fluid_block_contact); diff --git a/tests/2d_examples/test_2d_two_phase_dambreak/two_phase_dambreak.cpp b/tests/2d_examples/test_2d_two_phase_dambreak/two_phase_dambreak.cpp index 99e1819d56..1e518a06b8 100644 --- a/tests/2d_examples/test_2d_two_phase_dambreak/two_phase_dambreak.cpp +++ b/tests/2d_examples/test_2d_two_phase_dambreak/two_phase_dambreak.cpp @@ -24,9 +24,10 @@ int main(int ac, char *av[]) water_block.defineMaterial(rho0_f, c_f); water_block.generateParticles(water_block_shape); - FluidBody air_block(sph_system, makeShared("AirBody")); + AirBlock air_block_shape("AirBody"); + FluidBody air_block(sph_system, air_block_shape.getName()); air_block.defineMaterial(rho0_a, c_f); - air_block.generateParticles(); + air_block.generateParticles(air_block_shape); WallBoundary wall_boundary_shape("WallBoundary"); SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); diff --git a/tests/2d_examples/test_2d_viscous_cream_drop/viscous_cream_drop.cpp b/tests/2d_examples/test_2d_viscous_cream_drop/viscous_cream_drop.cpp index 54e307bc17..5392f76095 100644 --- a/tests/2d_examples/test_2d_viscous_cream_drop/viscous_cream_drop.cpp +++ b/tests/2d_examples/test_2d_viscous_cream_drop/viscous_cream_drop.cpp @@ -91,13 +91,14 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - SolidBody cream(sph_system, makeShared("Cream")); - cream.defineBodyLevelSetShape(); + Cream cream_shape("Cream"); + SolidBody cream(sph_system, cream_shape.getName()); + LevelSetShape level_set_shape(cream, cream_shape); cream.defineMaterial(rho0_s, Youngs_modulus, poisson, yield_stress, viscosity, Herschel_Bulkley_power); (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? cream.generateParticles(cream.getName()) - : cream.generateParticles(); + : cream.generateParticles(level_set_shape); ObserverBody cream_observer(sph_system, "CreamObserver"); cream_observer.generateParticles(observation_location); @@ -115,7 +116,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- using namespace relax_dynamics; SimpleDynamics cream_random_particles(cream); - RelaxationStepInner cream_relaxation_step_inner(cream_inner); + RelaxationStepInner cream_relaxation_step_inner(cream_inner, level_set_shape); //---------------------------------------------------------------------- // Output for particle relaxation. //---------------------------------------------------------------------- diff --git a/tests/2d_examples/test_2d_windows_frame_diffusion_D4/windows_frame_diffusion_D4.cpp b/tests/2d_examples/test_2d_windows_frame_diffusion_D4/windows_frame_diffusion_D4.cpp index ce71920bf3..709eae4a1a 100644 --- a/tests/2d_examples/test_2d_windows_frame_diffusion_D4/windows_frame_diffusion_D4.cpp +++ b/tests/2d_examples/test_2d_windows_frame_diffusion_D4/windows_frame_diffusion_D4.cpp @@ -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 diffusion_body_normal_direction(diffusion_body, diffusion_body_shape); + SimpleDynamics Robin_normal_direction_in(boundary_Robin_in, boundary_in_shape); SimpleDynamics Robin_normal_direction_ex(boundary_Robin_ex, boundary_ex_shape); diff --git a/tests/2d_examples/test_2d_windows_frame_diffusion_D7/windows_frame_diffusion_D7.cpp b/tests/2d_examples/test_2d_windows_frame_diffusion_D7/windows_frame_diffusion_D7.cpp index 027eac5a48..90cc6c3615 100644 --- a/tests/2d_examples/test_2d_windows_frame_diffusion_D7/windows_frame_diffusion_D7.cpp +++ b/tests/2d_examples/test_2d_windows_frame_diffusion_D7/windows_frame_diffusion_D7.cpp @@ -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 diffusion_body_normal_direction(diffusion_body, diffusion_body_shape); + SimpleDynamics Robin_normal_direction_in(boundary_Robin_in, boundary_in_shape); SimpleDynamics Robin_normal_direction_ex(boundary_Robin_ex, boundary_ex_shape); diff --git a/tests/3d_examples/test_3d_heart_volume_change/excitation_contraction.cpp b/tests/3d_examples/test_3d_heart_volume_change/excitation_contraction.cpp index def260a521..25e8a984bf 100644 --- a/tests/3d_examples/test_3d_heart_volume_change/excitation_contraction.cpp +++ b/tests/3d_examples/test_3d_heart_volume_change/excitation_contraction.cpp @@ -35,15 +35,17 @@ int main(int ac, char *av[]) /** check whether run particle relaxation for body fitted particle distribution. */ if (sph_system.RunParticleRelaxation() && !sph_system.ReloadParticles()) { - SolidBody herat_model(sph_system, makeShared("HeartModel")); - herat_model.defineBodyLevelSetShape()->correctLevelSetSign()->writeLevelSet(sph_system); + Heart heart_shape("HeartModel"); + SolidBody herat_model(sph_system, heart_shape.getName()); + LevelSetShape level_set_shape(herat_model, heart_shape); + level_set_shape.correctLevelSetSign()->writeLevelSet(sph_system); herat_model.defineMaterial(rho0_s, bulk_modulus, fiber_direction, sheet_direction, a0, b0); - herat_model.generateParticles(); + herat_model.generateParticles(level_set_shape); /** topology */ InnerRelation herat_model_inner(herat_model); using namespace relax_dynamics; SimpleDynamics random_particles(herat_model); - RelaxationStepInner relaxation_step_inner(herat_model_inner); + RelaxationStepInner relaxation_step_inner(herat_model_inner, level_set_shape); BodyStatesRecordingToVtp write_herat_model_state_to_vtp({herat_model}); ReloadParticleIO write_particle_reload_files(herat_model); write_particle_reload_files.addToReload(herat_model, "Fiber"); @@ -75,9 +77,9 @@ int main(int ac, char *av[]) IsotropicDiffusion diffusion("Phi", "Phi", diffusion_coeff); GetDiffusionTimeStepSize get_time_step_size(herat_model, diffusion); FiberDirectionDiffusionRelaxation diffusion_relaxation(herat_model_inner, &diffusion); - SimpleDynamics compute_fiber_sheet(herat_model, "Phi"); - BodySurface surface_part(herat_model); - SimpleDynamics impose_diffusion_bc(surface_part, "Phi"); + SimpleDynamics compute_fiber_sheet(herat_model, level_set_shape, "Phi"); + BodySurface surface_part(herat_model, level_set_shape); + SimpleDynamics impose_diffusion_bc(surface_part, level_set_shape, "Phi"); impose_diffusion_bc.exec(); write_herat_model_state_to_vtp.addToWrite(herat_model, "Phi"); write_herat_model_state_to_vtp.writeToFile(ite); @@ -106,20 +108,22 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // SPH simulation section //---------------------------------------------------------------------- - SolidBody mechanics_heart(sph_system, makeShared("MechanicalHeart")); + Heart mechanic_heart_shape("MechanicalHeart"); + SolidBody mechanics_heart(sph_system, mechanic_heart_shape.getName()); mechanics_heart.defineMaterial>(rho0_s, bulk_modulus, fiber_direction, sheet_direction, a0, b0); (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? mechanics_heart.generateParticles("HeartModel") - : mechanics_heart.generateParticles(); + : mechanics_heart.generateParticles(mechanic_heart_shape); - SolidBody physiology_heart(sph_system, makeShared("PhysiologyHeart")); + Heart physiology_heart_shape("PhysiologyHeart"); + SolidBody physiology_heart(sph_system, physiology_heart_shape.getName()); AlievPanfilowModel aliev_panfilow_model(k_a, c_m, k, a, b, mu_1, mu_2, epsilon); MonoFieldElectroPhysiology *mono_field_electro_physiology = physiology_heart.defineMaterial>( aliev_panfilow_model, diffusion_coeff, bias_coeff, fiber_direction); (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? physiology_heart.generateParticles("HeartModel") - : physiology_heart.generateParticles(); + : physiology_heart.generateParticles(physiology_heart_shape); //---------------------------------------------------------------------- // SPH Observation section @@ -168,7 +172,7 @@ int main(int ac, char *av[]) Dynamics1Level stress_relaxation_first_half(mechanics_body_inner); Dynamics1Level stress_relaxation_second_half(mechanics_body_inner); // initialize and update of normal direction - SimpleDynamics(mechanics_heart).exec(); + SimpleDynamics body_update_initial_normal(mechanics_heart, mechanic_heart_shape); SimpleDynamics body_update_normal(mechanics_heart); /** Time step size calculation. */ ReduceDynamics get_mechanics_time_step(mechanics_heart); @@ -196,6 +200,7 @@ int main(int ac, char *av[]) correct_configuration_excitation.exec(); correct_configuration_contraction.exec(); correct_kernel_weights_for_interpolation.exec(); + body_update_initial_normal.exec(); //---------------------------------------------------------------------- // Surfaces and operations - must be after system initialized diff --git a/tests/optimization/test_2d_VP_heat_flux_optimization/VP_heat_flux_optimization.cpp b/tests/optimization/test_2d_VP_heat_flux_optimization/VP_heat_flux_optimization.cpp index 703b6ce46f..697b553428 100644 --- a/tests/optimization/test_2d_VP_heat_flux_optimization/VP_heat_flux_optimization.cpp +++ b/tests/optimization/test_2d_VP_heat_flux_optimization/VP_heat_flux_optimization.cpp @@ -208,10 +208,11 @@ TEST(test_optimization, test_problem4_optimized) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - SolidBody diffusion_body(sph_system, makeShared("DiffusionBody")); + DiffusionBody diffusion_body_shape("DiffusionBody"); + SolidBody diffusion_body(sph_system, diffusion_body_shape.getName()); LocalIsotropicDiffusion *local_isotropic_diffusion = diffusion_body.defineMaterial("Phi", "Phi", diffusion_coeff); - diffusion_body.generateParticles(); + diffusion_body.generateParticles(diffusion_body_shape); WallBoundary wall_boundary_shape("WallBoundary"); SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); @@ -280,7 +281,7 @@ TEST(test_optimization, test_problem4_optimized) // Define the main numerical methods used in the simulation. // Note that there may be data dependence on the constructors of these methods. //---------------------------------------------------------------------- - SimpleDynamics diffusion_body_normal_direction(diffusion_body); + SimpleDynamics diffusion_body_normal_direction(diffusion_body, diffusion_body_shape); SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); InteractionSplit> diff --git a/tests/optimization/test_2d_VP_heat_flux_steady/VP_heat_flux_steady.cpp b/tests/optimization/test_2d_VP_heat_flux_steady/VP_heat_flux_steady.cpp index 9796380852..4f05749c1d 100644 --- a/tests/optimization/test_2d_VP_heat_flux_steady/VP_heat_flux_steady.cpp +++ b/tests/optimization/test_2d_VP_heat_flux_steady/VP_heat_flux_steady.cpp @@ -168,10 +168,11 @@ TEST(test_optimization, test_problem4_non_optimization) // Creating body, materials and particles. //---------------------------------------------------------------------- //---------------------------------------------------------------------- - SolidBody diffusion_body(sph_system, makeShared("DiffusionBody")); + DiffusionBody diffusion_body_shape("DiffusionBody"); + SolidBody diffusion_body(sph_system, diffusion_body_shape.getName()); LocalIsotropicDiffusion *local_isotropic_diffusion = diffusion_body.defineMaterial("Phi", "Phi", diffusion_coeff); - diffusion_body.generateParticles(); + diffusion_body.generateParticles(diffusion_body_shape); WallBoundary wall_boundary_shape("WallBoundary"); SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); @@ -199,7 +200,7 @@ TEST(test_optimization, test_problem4_non_optimization) // Define the main numerical methods used in the simulation. // Note that there may be data dependence on the constructors of these methods. //---------------------------------------------------------------------- - SimpleDynamics diffusion_body_normal_direction(diffusion_body); + SimpleDynamics diffusion_body_normal_direction(diffusion_body, diffusion_body_shape); SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); InteractionSplit> diff --git a/tests/optimization/test_2d_VP_same_sink_optimization/VP_same_sink_optimization.cpp b/tests/optimization/test_2d_VP_same_sink_optimization/VP_same_sink_optimization.cpp index e42395dc3d..29a4891aa5 100644 --- a/tests/optimization/test_2d_VP_same_sink_optimization/VP_same_sink_optimization.cpp +++ b/tests/optimization/test_2d_VP_same_sink_optimization/VP_same_sink_optimization.cpp @@ -190,10 +190,11 @@ TEST(test_optimization, test_problem1_optimized) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - SolidBody diffusion_body(sph_system, makeShared("DiffusionBody")); + DiffusionBody diffusion_body_shape("DiffusionBody"); + SolidBody diffusion_body(sph_system, diffusion_body_shape.getName()); LocalIsotropicDiffusion *local_isotropic_diffusion = diffusion_body.defineMaterial("Phi", "Phi", diffusion_coeff); - diffusion_body.generateParticles(); + diffusion_body.generateParticles(diffusion_body_shape); WallBoundary wall_boundary_shape("WallBoundary"); SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); @@ -259,7 +260,7 @@ TEST(test_optimization, test_problem1_optimized) // Define the main numerical methods used for optimization // Note that there may be data dependence on the constructors of tested methods. //---------------------------------------------------------------------- - SimpleDynamics diffusion_body_normal_direction(diffusion_body); + SimpleDynamics diffusion_body_normal_direction(diffusion_body, diffusion_body_shape); SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); InteractionSplit> diff --git a/tests/optimization/test_2d_VP_same_sink_steady/VP_same_sink_steady.cpp b/tests/optimization/test_2d_VP_same_sink_steady/VP_same_sink_steady.cpp index 267343e91b..4aa7db254e 100644 --- a/tests/optimization/test_2d_VP_same_sink_steady/VP_same_sink_steady.cpp +++ b/tests/optimization/test_2d_VP_same_sink_steady/VP_same_sink_steady.cpp @@ -156,10 +156,11 @@ TEST(test_optimization, test_problem1_non_optimized) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - SolidBody diffusion_body(sph_system, makeShared("DiffusionBody")); + DiffusionBody diffusion_body_shape("DiffusionBody"); + SolidBody diffusion_body(sph_system, diffusion_body_shape.getName()); LocalIsotropicDiffusion *local_isotropic_diffusion = diffusion_body.defineMaterial("Phi", "Phi", diffusion_coeff); - diffusion_body.generateParticles(); + diffusion_body.generateParticles(diffusion_body_shape); WallBoundary wall_boundary_shape("WallBoundary"); SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); @@ -185,7 +186,7 @@ TEST(test_optimization, test_problem1_non_optimized) // Define the main numerical methods used in the simulation. // Note that there may be data dependence on the constructors of these methods. //---------------------------------------------------------------------- - SimpleDynamics diffusion_body_normal_direction(diffusion_body); + SimpleDynamics diffusion_body_normal_direction(diffusion_body, diffusion_body_shape); SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); InteractionSplit> From b7da9bae2607ccabcb68139ac520008976d6eaf8 Mon Sep 17 00:00:00 2001 From: Xiangyu Hu Date: Sun, 22 Sep 2024 14:29:43 +0000 Subject: [PATCH 12/13] to continue --- .../diffusion_NeumannBC.cpp | 2 +- tests/2d_examples/test_2d_stfb/stfb.cpp | 6 +++--- .../test_2d_stretching/stretching.cpp | 9 +++++---- .../test_2d_water_entry_exit.cpp | 9 ++++++--- .../windows_frame_diffusion_D4.cpp | 2 +- .../windows_frame_diffusion_D7.cpp | 2 +- .../beam_pulling_pressure_load.cpp | 3 ++- ...3d_bending_circular_plate_parametric_cvt.cpp | 5 +---- tests/3d_examples/test_3d_dambreak/dambreak.cpp | 4 ++-- .../test_3d_dambreak_elastic_plate_shell.cpp | 7 ++++--- .../3d_elasticSolid_shell_collision.cpp | 12 +++++++----- .../src/muscle_activation.cpp | 4 ++-- .../muscle_soft_body_contact.cpp | 14 ++++++++------ .../muscle_solid_contact.cpp | 17 +++++++++-------- tests/3d_examples/test_3d_network/network.cpp | 8 +++++--- .../passive_cantilever.cpp | 5 +++-- .../passive_cantilever_neohookean.cpp | 5 +++-- .../T_pipe_VIPO_shell.cpp | 5 ++--- .../test_2d_membrane/2d_membrane.cpp | 3 ++- .../mixed_poiseuille_flow.cpp | 2 +- .../test_2d_modified_T_flow/modified_T_flow.cpp | 2 +- .../pulsatile_poiseuille_flow.cpp | 2 +- .../passive_cantilever_LG.cpp | 5 +++-- .../test_particle_for_split.cpp | 8 ++++---- 24 files changed, 77 insertions(+), 64 deletions(-) diff --git a/tests/2d_examples/test_2d_diffusion_NeumannBC/diffusion_NeumannBC.cpp b/tests/2d_examples/test_2d_diffusion_NeumannBC/diffusion_NeumannBC.cpp index 724d4f15e2..71401236f4 100644 --- a/tests/2d_examples/test_2d_diffusion_NeumannBC/diffusion_NeumannBC.cpp +++ b/tests/2d_examples/test_2d_diffusion_NeumannBC/diffusion_NeumannBC.cpp @@ -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 diffusion_body_normal_direction(diffusion_body, diffusion_body_shape); SimpleDynamics wall_boundary_normal_direction(wall_Neumann, wall_shape_Neumann); DiffusionBodyRelaxation temperature_relaxation( diff --git a/tests/2d_examples/test_2d_stfb/stfb.cpp b/tests/2d_examples/test_2d_stfb/stfb.cpp index 3fb2120146..4cdcec4e15 100644 --- a/tests/2d_examples/test_2d_stfb/stfb.cpp +++ b/tests/2d_examples/test_2d_stfb/stfb.cpp @@ -29,9 +29,9 @@ int main(int ac, char *av[]) wall_boundary.generateParticles(wall_boundary_shape); TransformShape structure_shape(Transform(structure_translation), structure_halfsize, "Structure"); - SolidBody structure(sph_system, structure_shape); + SolidBody structure(sph_system, structure_shape.getName()); structure.defineMaterial(rho_s); - structure.generateParticles(floating_structure_shape); + structure.generateParticles(structure_shape); ObserverBody observer(sph_system, "Observer"); observer.defineAdaptationRatios(1.15, 2.0); @@ -66,7 +66,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- SimpleDynamics structure_offset_position(structure, offset); SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); - SimpleDynamics str_normal(structure); + SimpleDynamics str_normal(structure, structure_shape); Gravity gravity(Vecd(0.0, -gravity_g)); SimpleDynamics> constant_gravity(water_block, gravity); diff --git a/tests/2d_examples/test_2d_stretching/stretching.cpp b/tests/2d_examples/test_2d_stretching/stretching.cpp index 3e9b41f636..636c449dcc 100644 --- a/tests/2d_examples/test_2d_stretching/stretching.cpp +++ b/tests/2d_examples/test_2d_stretching/stretching.cpp @@ -184,14 +184,15 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - SolidBody beam_body(system, makeShared("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( rho0_s, Youngs_modulus, poisson, yield_stress, hardening_modulus, saturation_flow_stress, saturation_exponent); (!system.RunParticleRelaxation() && system.ReloadParticles()) ? beam_body.generateParticles(beam_body.getName()) - : beam_body.generateParticles(beam_body_shape); + : beam_body.generateParticles(level_set_shape); ObserverBody beam_observer(system, "BeamObserver"); beam_observer.generateParticles(observation_location); @@ -214,7 +215,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- using namespace relax_dynamics; SimpleDynamics 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. //---------------------------------------------------------------------- diff --git a/tests/2d_examples/test_2d_water_entry_exit/test_2d_water_entry_exit.cpp b/tests/2d_examples/test_2d_water_entry_exit/test_2d_water_entry_exit.cpp index 6e5ae353d2..3d8c7a124c 100644 --- a/tests/2d_examples/test_2d_water_entry_exit/test_2d_water_entry_exit.cpp +++ b/tests/2d_examples/test_2d_water_entry_exit/test_2d_water_entry_exit.cpp @@ -189,15 +189,18 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating bodies with corresponding materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(sph_system, makeShared("WaterBody")); + WettingFluidBody water_block_shape("WaterBody"); + FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); water_block.generateParticles(water_block_shape); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + WettingWallBody wall_boundary_shape("WallBoundary"); + SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); wall_boundary.defineMaterial(); wall_boundary.generateParticles(wall_boundary_shape); - SolidBody cylinder(sph_system, makeShared("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(rho0_s); diff --git a/tests/2d_examples/test_2d_windows_frame_diffusion_D4/windows_frame_diffusion_D4.cpp b/tests/2d_examples/test_2d_windows_frame_diffusion_D4/windows_frame_diffusion_D4.cpp index 709eae4a1a..ce71920bf3 100644 --- a/tests/2d_examples/test_2d_windows_frame_diffusion_D4/windows_frame_diffusion_D4.cpp +++ b/tests/2d_examples/test_2d_windows_frame_diffusion_D4/windows_frame_diffusion_D4.cpp @@ -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 diffusion_body_normal_direction(diffusion_body, diffusion_body_shape); SimpleDynamics Robin_normal_direction_in(boundary_Robin_in, boundary_in_shape); SimpleDynamics Robin_normal_direction_ex(boundary_Robin_ex, boundary_ex_shape); diff --git a/tests/2d_examples/test_2d_windows_frame_diffusion_D7/windows_frame_diffusion_D7.cpp b/tests/2d_examples/test_2d_windows_frame_diffusion_D7/windows_frame_diffusion_D7.cpp index 90cc6c3615..027eac5a48 100644 --- a/tests/2d_examples/test_2d_windows_frame_diffusion_D7/windows_frame_diffusion_D7.cpp +++ b/tests/2d_examples/test_2d_windows_frame_diffusion_D7/windows_frame_diffusion_D7.cpp @@ -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 diffusion_body_normal_direction(diffusion_body, diffusion_body_shape); SimpleDynamics Robin_normal_direction_in(boundary_Robin_in, boundary_in_shape); SimpleDynamics Robin_normal_direction_ex(boundary_Robin_ex, boundary_ex_shape); diff --git a/tests/3d_examples/test_3d_beam_pulling_pressure_load/beam_pulling_pressure_load.cpp b/tests/3d_examples/test_3d_beam_pulling_pressure_load/beam_pulling_pressure_load.cpp index 89f671cf87..345b49d929 100644 --- a/tests/3d_examples/test_3d_beam_pulling_pressure_load/beam_pulling_pressure_load.cpp +++ b/tests/3d_examples/test_3d_beam_pulling_pressure_load/beam_pulling_pressure_load.cpp @@ -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_body_shape("Beam"); + SolidBody beam_body(sph_system, beam_body_shape.getName()); beam_body.defineMaterial(rho, Youngs_modulus, poisson_ratio); beam_body.generateParticles(beam_body_shape); diff --git a/tests/3d_examples/test_3d_bending_circular_plate_parametric_cvt/test_3d_bending_circular_plate_parametric_cvt.cpp b/tests/3d_examples/test_3d_bending_circular_plate_parametric_cvt/test_3d_bending_circular_plate_parametric_cvt.cpp index bfd949c59d..eb321c76db 100644 --- a/tests/3d_examples/test_3d_bending_circular_plate_parametric_cvt/test_3d_bending_circular_plate_parametric_cvt.cpp +++ b/tests/3d_examples/test_3d_bending_circular_plate_parametric_cvt/test_3d_bending_circular_plate_parametric_cvt.cpp @@ -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("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(rho, E, mu); shell_body.generateParticles(obj_vertices, sym_vec, particle_area, thickness); auto shell_particles = dynamic_cast(&shell_body.getBaseParticles()); diff --git a/tests/3d_examples/test_3d_dambreak/dambreak.cpp b/tests/3d_examples/test_3d_dambreak/dambreak.cpp index ab9d01a8fa..696d5c8919 100644 --- a/tests/3d_examples/test_3d_dambreak/dambreak.cpp +++ b/tests/3d_examples/test_3d_dambreak/dambreak.cpp @@ -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(rho0_f, c_f); water_block.generateParticles(water_block_shape); diff --git a/tests/3d_examples/test_3d_dambreak_elastic_plate_shell/test_3d_dambreak_elastic_plate_shell.cpp b/tests/3d_examples/test_3d_dambreak_elastic_plate_shell/test_3d_dambreak_elastic_plate_shell.cpp index b12b7e97a7..8a1c58a156 100644 --- a/tests/3d_examples/test_3d_dambreak_elastic_plate_shell/test_3d_dambreak_elastic_plate_shell.cpp +++ b/tests/3d_examples/test_3d_dambreak_elastic_plate_shell/test_3d_dambreak_elastic_plate_shell.cpp @@ -172,9 +172,10 @@ int main(int ac, char *av[]) wall_boundary.defineMaterial(); wall_boundary.generateParticles(wall_boundary_shape); - SolidBody gate(sph_system, makeShared("Gate")); + MovingGate gate_shape("Gate"); + SolidBody gate(sph_system, gate_shape.getName()); gate.defineMaterial(); - gate.generateParticles(); + gate.generateParticles(gate_shape); SolidBody plate(sph_system, "Plate"); plate.defineAdaptation(1.15, resolution_ref / resolution_shell); @@ -216,7 +217,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // solid SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); - SimpleDynamics gate_normal_direction(gate); + SimpleDynamics gate_normal_direction(gate, gate_shape); SimpleDynamics update_gate_position(gate); // Shell InteractionDynamics plate_corrected_configuration(plate_inner); diff --git a/tests/3d_examples/test_3d_elasticSolid_shell_collision/3d_elasticSolid_shell_collision.cpp b/tests/3d_examples/test_3d_elasticSolid_shell_collision/3d_elasticSolid_shell_collision.cpp index c50a2a98f6..2137c4a7ba 100644 --- a/tests/3d_examples/test_3d_elasticSolid_shell_collision/3d_elasticSolid_shell_collision.cpp +++ b/tests/3d_examples/test_3d_elasticSolid_shell_collision/3d_elasticSolid_shell_collision.cpp @@ -78,7 +78,10 @@ int main(int ac, char *av[]) shell.defineMaterial(); shell.generateParticles(); - SolidBody ball(sph_system, makeShared(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(rho0_s, Youngs_modulus, poisson); if (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) { @@ -86,8 +89,7 @@ int main(int ac, char *av[]) } else { - ball.defineBodyLevelSetShape()->writeLevelSet(sph_system); - ball.generateParticles(); + ball.generateParticles(level_set_shape); } ObserverBody ball_observer(sph_system, "BallObserver"); @@ -106,7 +108,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- using namespace relax_dynamics; SimpleDynamics 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. //---------------------------------------------------------------------- @@ -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. diff --git a/tests/3d_examples/test_3d_muscle_activation/src/muscle_activation.cpp b/tests/3d_examples/test_3d_muscle_activation/src/muscle_activation.cpp index 7ca8162c22..cf0b734624 100644 --- a/tests/3d_examples/test_3d_muscle_activation/src/muscle_activation.cpp +++ b/tests/3d_examples/test_3d_muscle_activation/src/muscle_activation.cpp @@ -66,9 +66,9 @@ int main(int ac, char *av[]) // Creating bodies with corresponding materials and particles. //---------------------------------------------------------------------- TransformShape 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>(rho0_s, bulk_modulus, fiber_direction, sheet_direction, a0, b0); - muscle_body.generateParticles(); + muscle_body.generateParticles(muscle_body_shape); //---------------------------------------------------------------------- // Define body relation map. // The contact map gives the topological connections between the bodies. diff --git a/tests/3d_examples/test_3d_muscle_soft_body_contact/muscle_soft_body_contact.cpp b/tests/3d_examples/test_3d_muscle_soft_body_contact/muscle_soft_body_contact.cpp index 740ed399d3..7b62cf10ef 100644 --- a/tests/3d_examples/test_3d_muscle_soft_body_contact/muscle_soft_body_contact.cpp +++ b/tests/3d_examples/test_3d_muscle_soft_body_contact/muscle_soft_body_contact.cpp @@ -62,14 +62,16 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating bodies with corresponding materials and particles. //---------------------------------------------------------------------- - SolidBody myocardium_body(sph_system, makeShared("MyocardiumBody")); + Myocardium myocardium_body_shape("MyocardiumBody"); + SolidBody myocardium_body(sph_system, myocardium_body_shape.getName()); myocardium_body.defineMaterial(rho0_s, Youngs_modulus, poisson); - myocardium_body.generateParticles(); + myocardium_body.generateParticles(myocardium_body_shape); - SolidBody moving_plate(sph_system, makeShared("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(rho0_s, Youngs_modulus, poisson); - moving_plate.generateParticles(); + moving_plate.generateParticles(moving_plate_shape); //---------------------------------------------------------------------- // Define body relation map. // The contact map gives the topological connections between the bodies. @@ -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. diff --git a/tests/3d_examples/test_3d_muscle_solid_contact/muscle_solid_contact.cpp b/tests/3d_examples/test_3d_muscle_solid_contact/muscle_solid_contact.cpp index 4eeb4b0cd6..79ccb4ac0e 100644 --- a/tests/3d_examples/test_3d_muscle_solid_contact/muscle_solid_contact.cpp +++ b/tests/3d_examples/test_3d_muscle_solid_contact/muscle_solid_contact.cpp @@ -62,13 +62,15 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating bodies with corresponding materials and particles. //---------------------------------------------------------------------- - SolidBody myocardium_body(sph_system, makeShared("MyocardiumBody")); + Myocardium myocardium_body_shape("MyocardiumBody"); + SolidBody myocardium_body(sph_system, myocardium_body_shape.getName()); myocardium_body.defineMaterial(rho0_s, Youngs_modulus, poisson); - myocardium_body.generateParticles(); + myocardium_body.generateParticles(myocardium_body_shape); - SolidBody moving_plate(sph_system, makeShared("MovingPlate")); + MovingPlate moving_plate_shape("MovingPlate"); + SolidBody moving_plate(sph_system, moving_plate_shape.getName()); moving_plate.defineMaterial(rho0_s, Youngs_modulus, poisson); - moving_plate.generateParticles(); + moving_plate.generateParticles(moving_plate_shape); //---------------------------------------------------------------------- // Define body relation map. // The contact map gives the topological connections between the bodies. @@ -76,8 +78,8 @@ int main(int ac, char *av[]) // 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. @@ -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 moving_plate_shape(Transform(translation_moving_plate), halfsize_moving_plate, "Plate"); - SimpleDynamics moving_plate_normal_direction(moving_plate); + SimpleDynamics 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) diff --git a/tests/3d_examples/test_3d_network/network.cpp b/tests/3d_examples/test_3d_network/network.cpp index 26984ed6fd..5a2611edde 100644 --- a/tests/3d_examples/test_3d_network/network.cpp +++ b/tests/3d_examples/test_3d_network/network.cpp @@ -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(Vec3d::Zero(), 1.0, "Sphere")); - tree_on_sphere.defineBodyLevelSetShape()->writeLevelSet(sph_system); - tree_on_sphere.generateParticles(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(ball_shape, starting_point, second_point, iteration_levels, grad_factor); /** Write particle data. */ BodyStatesRecordingToVtp write_states(sph_system); write_states.writeToFile(0); diff --git a/tests/3d_examples/test_3d_passive_cantilever/passive_cantilever.cpp b/tests/3d_examples/test_3d_passive_cantilever/passive_cantilever.cpp index 4e86c3aa8f..b1155a52d0 100644 --- a/tests/3d_examples/test_3d_passive_cantilever/passive_cantilever.cpp +++ b/tests/3d_examples/test_3d_passive_cantilever/passive_cantilever.cpp @@ -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("CantileverBody")); + Cantilever cantilever_body_shape("CantileverBody"); + SolidBody cantilever_body(sph_system, cantilever_body_shape.getName()); cantilever_body.defineMaterial(rho0_s, bulk_modulus, fiber_direction, sheet_direction, a0, b0); - cantilever_body.generateParticles(); + cantilever_body.generateParticles(cantilever_body_shape); /** Define Observer. */ ObserverBody cantilever_observer(sph_system, "CantileverObserver"); cantilever_observer.generateParticles(observation_location); diff --git a/tests/3d_examples/test_3d_passive_cantilever_neohookean/passive_cantilever_neohookean.cpp b/tests/3d_examples/test_3d_passive_cantilever_neohookean/passive_cantilever_neohookean.cpp index 8df0a264aa..08610f6767 100644 --- a/tests/3d_examples/test_3d_passive_cantilever_neohookean/passive_cantilever_neohookean.cpp +++ b/tests/3d_examples/test_3d_passive_cantilever_neohookean/passive_cantilever_neohookean.cpp @@ -54,9 +54,10 @@ int main(int ac, char *av[]) #endif /** output environment. */ /** create a Cantilever body, corresponding material, particles and reaction model. */ - SolidBody cantilever_body(sph_system, makeShared("CantileverBody")); + Cantilever cantilever_body_shape("CantileverBody"); + SolidBody cantilever_body(sph_system, cantilever_body_shape.getName()); cantilever_body.defineMaterial(rho0_s, Youngs_modulus, poisson); - cantilever_body.generateParticles(); + cantilever_body.generateParticles(cantilever_body_shape); /** Define Observer. */ ObserverBody cantilever_observer(sph_system, "CantileverObserver"); cantilever_observer.generateParticles(observation_location); diff --git a/tests/extra_source_and_tests/test_2d_T_pipe_VIPO_shell/T_pipe_VIPO_shell.cpp b/tests/extra_source_and_tests/test_2d_T_pipe_VIPO_shell/T_pipe_VIPO_shell.cpp index 8aaa8ff2cb..48515c41b2 100644 --- a/tests/extra_source_and_tests/test_2d_T_pipe_VIPO_shell/T_pipe_VIPO_shell.cpp +++ b/tests/extra_source_and_tests/test_2d_T_pipe_VIPO_shell/T_pipe_VIPO_shell.cpp @@ -261,11 +261,10 @@ int main(int ac, char *av[]) FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); ParticleBuffer in_outlet_particle_buffer(0.5); - water_block.generateParticlesWithReserve(in_outlet_particle_buffer); + water_block.generateParticlesWithReserve(in_outlet_particle_buffer, water_block_shape); - SolidBody shell_body(sph_system, makeShared("ShellBody")); + SolidBody shell_body(sph_system, "ShellBody"); shell_body.defineAdaptation(1.15, resolution_ref / resolution_shell); - shell_body.defineBodyLevelSetShape(level_set_refinement_ratio)->writeLevelSet(sph_system); shell_body.defineMaterial(rho0_s, Youngs_modulus, poisson); shell_body.generateParticles(resolution_shell, BW); diff --git a/tests/extra_source_and_tests/test_2d_membrane/2d_membrane.cpp b/tests/extra_source_and_tests/test_2d_membrane/2d_membrane.cpp index 0ea65f3ae6..f7a3ebc47c 100644 --- a/tests/extra_source_and_tests/test_2d_membrane/2d_membrane.cpp +++ b/tests/extra_source_and_tests/test_2d_membrane/2d_membrane.cpp @@ -138,7 +138,8 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - SolidBody beam_body(sph_system, makeShared("2dMembrane")); + Beam beam_body_shape("2dMembraneBase"); + SolidBody beam_body(sph_system, beam_body_shape.getName()); beam_body.defineMaterial( rho_0, Youngs_modulus, poisson, diffusivity_constant_, fluid_initial_density_, water_pressure_constant_); beam_body.generateParticles(beam_body_shape); diff --git a/tests/extra_source_and_tests/test_2d_mixed_poiseuille_flow/mixed_poiseuille_flow.cpp b/tests/extra_source_and_tests/test_2d_mixed_poiseuille_flow/mixed_poiseuille_flow.cpp index 1b680964c3..8dbc2d049b 100644 --- a/tests/extra_source_and_tests/test_2d_mixed_poiseuille_flow/mixed_poiseuille_flow.cpp +++ b/tests/extra_source_and_tests/test_2d_mixed_poiseuille_flow/mixed_poiseuille_flow.cpp @@ -153,7 +153,7 @@ int main(int ac, char *av[]) FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); ParticleBuffer in_outlet_particle_buffer(0.5); - water_block.generateParticlesWithReserve(in_outlet_particle_buffer); + water_block.generateParticlesWithReserve(in_outlet_particle_buffer, water_block_shape); WallBoundary wall_boundary_shape("WallBoundary"); SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); diff --git a/tests/extra_source_and_tests/test_2d_modified_T_flow/modified_T_flow.cpp b/tests/extra_source_and_tests/test_2d_modified_T_flow/modified_T_flow.cpp index 354e7b966f..297ae78282 100644 --- a/tests/extra_source_and_tests/test_2d_modified_T_flow/modified_T_flow.cpp +++ b/tests/extra_source_and_tests/test_2d_modified_T_flow/modified_T_flow.cpp @@ -154,7 +154,7 @@ int main(int ac, char *av[]) FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); ParticleBuffer in_outlet_particle_buffer(0.5); - water_block.generateParticlesWithReserve(in_outlet_particle_buffer); + water_block.generateParticlesWithReserve(in_outlet_particle_buffer, water_block_shape); WallBoundary wall_boundary_shape("WallBoundary"); SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); diff --git a/tests/extra_source_and_tests/test_2d_pulsatile_poiseuille_flow/pulsatile_poiseuille_flow.cpp b/tests/extra_source_and_tests/test_2d_pulsatile_poiseuille_flow/pulsatile_poiseuille_flow.cpp index a2c73e688d..f57c71b65d 100644 --- a/tests/extra_source_and_tests/test_2d_pulsatile_poiseuille_flow/pulsatile_poiseuille_flow.cpp +++ b/tests/extra_source_and_tests/test_2d_pulsatile_poiseuille_flow/pulsatile_poiseuille_flow.cpp @@ -136,7 +136,7 @@ int main(int ac, char *av[]) FluidBody water_block(sph_system, water_block_shape.getName()); water_block.defineMaterial(rho0_f, c_f, mu_f); ParticleBuffer in_outlet_particle_buffer(0.5); - water_block.generateParticlesWithReserve(in_outlet_particle_buffer); + water_block.generateParticlesWithReserve(in_outlet_particle_buffer, water_block_shape); WallBoundary wall_boundary_shape("WallBoundary"); SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); diff --git a/tests/extra_source_and_tests/test_3d_passive_cantilever_LG/passive_cantilever_LG.cpp b/tests/extra_source_and_tests/test_3d_passive_cantilever_LG/passive_cantilever_LG.cpp index 148e449045..e92c3698fd 100644 --- a/tests/extra_source_and_tests/test_3d_passive_cantilever_LG/passive_cantilever_LG.cpp +++ b/tests/extra_source_and_tests/test_3d_passive_cantilever_LG/passive_cantilever_LG.cpp @@ -73,11 +73,12 @@ 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("CantileverBody")); + Cantilever cantilever_body_shape("CantileverBody"); + SolidBody cantilever_body(sph_system, cantilever_body_shape.getName()); cantilever_body.defineAdaptationRatios(1.3, 1.0); cantilever_body.sph_adaptation_->resetKernel>(20); cantilever_body.defineMaterial(rho0_s, bulk_modulus, fiber_direction, sheet_direction, a0, b0); - cantilever_body.generateParticles(); + cantilever_body.generateParticles(cantilever_body_shape); /** Define Observer. */ ObserverBody cantilever_observer(sph_system, "CantileverObserver"); cantilever_observer.generateParticles(observation_location); diff --git a/tests/unit_tests_src/for_3D_build/meshes/test_3d_particle_for_split/test_particle_for_split.cpp b/tests/unit_tests_src/for_3D_build/meshes/test_3d_particle_for_split/test_particle_for_split.cpp index ef4c9264e4..ed6ac9d0e2 100644 --- a/tests/unit_tests_src/for_3D_build/meshes/test_3d_particle_for_split/test_particle_for_split.cpp +++ b/tests/unit_tests_src/for_3D_build/meshes/test_3d_particle_for_split/test_particle_for_split.cpp @@ -8,15 +8,15 @@ TEST(test_meshes, split_for) Real length = 10; Real dp = 1; - auto shape = makeShared(0.5 * length * Vec3d::Ones(), "Shape"); + GeometricShapeBox shape(0.5 * length * Vec3d::Ones(), "Shape"); - BoundingBox bb_system = shape->getBounds(); + BoundingBox bb_system = shape.getBounds(); SPHSystem system(bb_system, dp); - SolidBody body(system, shape); + SolidBody body(system, shape.getName()); body.defineMaterial(); - body.generateParticles(); + body.generateParticles(shape); auto &particles = body.getBaseParticles(); const auto pos = particles.registerStateVariable("Position"); auto quantity = particles.registerStateVariable("Quantity", [&](size_t i) -> Real From 73d89e3cea459bff6fa6e80f6c2f605768b69825 Mon Sep 17 00:00:00 2001 From: Xiangyu Hu Date: Sun, 22 Sep 2024 15:48:23 +0000 Subject: [PATCH 13/13] all compiled, to test --- .../two_phase_dambreak.cpp | 4 +- .../test_3d_incompressible_channel_flow.cpp | 2 +- .../test_3d_incompressible_channel_flow.h | 14 ------- ...rticle_relaxation_single_resolution_3D.cpp | 2 +- .../pkj_lv_electrocontraction.cpp | 29 +++++++------- .../pkj_lv_electrocontraction.h | 4 +- .../poiseuille_flow_shell.cpp | 9 ++--- .../test_3d_repose_angle/repose_angle.cpp | 10 +++-- .../test_3d_roof_parametric_cvt.cpp | 40 +------------------ .../test_3d_self_contact/3d_self_contact.cpp | 19 +++++---- .../test_3d_shell_particle_relaxation.cpp | 12 +++--- .../test_3d_shell_stability_half_sphere.cpp | 5 +-- .../test_3d_sliding/test_3d_sliding.cpp | 14 +++---- tests/3d_examples/test_3d_stfb/stfb.cpp | 2 +- .../test_3d_taylor_bar/taylor_bar.cpp | 19 +++++---- .../twisting_column.cpp | 5 ++- .../lid_driven_cavity.cpp | 16 ++++---- .../test_particle_for_split.cpp | 8 ++-- 18 files changed, 85 insertions(+), 129 deletions(-) diff --git a/tests/2d_examples/test_2d_two_phase_dambreak/two_phase_dambreak.cpp b/tests/2d_examples/test_2d_two_phase_dambreak/two_phase_dambreak.cpp index 1e518a06b8..5edb885a71 100644 --- a/tests/2d_examples/test_2d_two_phase_dambreak/two_phase_dambreak.cpp +++ b/tests/2d_examples/test_2d_two_phase_dambreak/two_phase_dambreak.cpp @@ -60,8 +60,8 @@ 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. //---------------------------------------------------------------------- - /** Initialize particle acceleration. */ - SimpleDynamics inner_normal_direction(wall_boundary, "InnerWall"); + SubShapeAndOp *inner_wall_shape_and_op = wall_boundary_shape.getSubShapeAndOpByName("InnerWall"); + SimpleDynamics inner_normal_direction(wall_boundary, inner_wall_shape_and_op); Gravity gravity(Vecd(0.0, -gravity_g)); SimpleDynamics> constant_gravity_to_water(water_block, gravity); diff --git a/tests/3d_examples/test_3d_incompressible_channel_flow/test_3d_incompressible_channel_flow.cpp b/tests/3d_examples/test_3d_incompressible_channel_flow/test_3d_incompressible_channel_flow.cpp index 6522351371..2d6aac108b 100644 --- a/tests/3d_examples/test_3d_incompressible_channel_flow/test_3d_incompressible_channel_flow.cpp +++ b/tests/3d_examples/test_3d_incompressible_channel_flow/test_3d_incompressible_channel_flow.cpp @@ -22,7 +22,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody air_block(sph_system, makeShared("AirBody")); + FluidBody air_block(sph_system, "AirBody"); air_block.defineMaterial(rho0_f, c_f, mu_f); Ghost ghost_boundary(0.5); air_block.generateParticlesWithReserve(ghost_boundary, read_mesh_data); diff --git a/tests/3d_examples/test_3d_incompressible_channel_flow/test_3d_incompressible_channel_flow.h b/tests/3d_examples/test_3d_incompressible_channel_flow/test_3d_incompressible_channel_flow.h index 475740bbea..7c0b7dca50 100644 --- a/tests/3d_examples/test_3d_incompressible_channel_flow/test_3d_incompressible_channel_flow.h +++ b/tests/3d_examples/test_3d_incompressible_channel_flow/test_3d_incompressible_channel_flow.h @@ -33,20 +33,6 @@ Real mu_f = 0.0; /**< Dynamics viscosity. */ //---------------------------------------------------------------------- std::string mesh_fullpath = "./input/Channel_ICEM.msh"; //---------------------------------------------------------------------- -// Define geometries and body shapes -//---------------------------------------------------------------------- - -class AirBody : public ComplexShape -{ - public: - explicit AirBody(const std::string &shape_name) : ComplexShape(shape_name) - { - Vecd halfsize_wave(0.5 * DH, 0.5 * DL, 0.5 * DW); - Transform translation_wave(halfsize_wave); - add>(Transform(translation_wave), halfsize_wave); - } -}; -///---------------------------------------------------------------------- // Initialization //---------------------------------------------------------------------- class InvCFInitialCondition diff --git a/tests/3d_examples/test_3d_particle_relaxation_single_resolution/particle_relaxation_single_resolution_3D.cpp b/tests/3d_examples/test_3d_particle_relaxation_single_resolution/particle_relaxation_single_resolution_3D.cpp index 2cd2bc97ac..a8514d0eeb 100644 --- a/tests/3d_examples/test_3d_particle_relaxation_single_resolution/particle_relaxation_single_resolution_3D.cpp +++ b/tests/3d_examples/test_3d_particle_relaxation_single_resolution/particle_relaxation_single_resolution_3D.cpp @@ -98,7 +98,7 @@ int main(int ac, char *av[]) // level set shape is used for particle relaxation LevelSetShape level_set_shape(imported_model, import_model_shape); level_set_shape.correctLevelSetSign()->writeLevelSet(sph_system); - imported_model.generateParticles(); + imported_model.generateParticles(level_set_shape); //---------------------------------------------------------------------- // Define simple file input and outputs functions. //---------------------------------------------------------------------- diff --git a/tests/3d_examples/test_3d_pkj_lv_electrocontraction/pkj_lv_electrocontraction.cpp b/tests/3d_examples/test_3d_pkj_lv_electrocontraction/pkj_lv_electrocontraction.cpp index fe0f076b52..c95fa3c08c 100644 --- a/tests/3d_examples/test_3d_pkj_lv_electrocontraction/pkj_lv_electrocontraction.cpp +++ b/tests/3d_examples/test_3d_pkj_lv_electrocontraction/pkj_lv_electrocontraction.cpp @@ -34,23 +34,22 @@ int main(int ac, char *av[]) IOEnvironment io_environment(sph_system); Heart triangle_mesh_heart_model("HeartModel"); - SharedPtr level_set_heart_model = - makeShared(triangle_mesh_heart_model, makeShared(dp_0)); - level_set_heart_model->correctLevelSetSign()->writeLevelSet(sph_system); + LevelSetShape level_set_heart_model(triangle_mesh_heart_model, makeShared(dp_0)); + level_set_heart_model.correctLevelSetSign()->writeLevelSet(sph_system); //---------------------------------------------------------------------- // SPH Particle relaxation section //---------------------------------------------------------------------- /** check whether run particle relaxation for body fitted particle distribution. */ if (sph_system.RunParticleRelaxation() && !sph_system.ReloadParticles()) { - SolidBody herat_model(sph_system, level_set_heart_model); + SolidBody herat_model(sph_system, level_set_heart_model.getName()); herat_model.defineMaterial(rho0_s, bulk_modulus, fiber_direction, sheet_direction, a0, b0); - herat_model.generateParticles(); + herat_model.generateParticles(level_set_heart_model); /** topology */ InnerRelation herat_model_inner(herat_model); using namespace relax_dynamics; SimpleDynamics random_particles(herat_model); - RelaxationStepInner relaxation_step_inner(herat_model_inner); + RelaxationStepInner relaxation_step_inner(herat_model_inner, level_set_heart_model); BodyStatesRecordingToVtp write_herat_model_state_to_vtp({herat_model}); ReloadParticleIO write_particle_reload_files(herat_model); write_particle_reload_files.addToReload(herat_model, "Fiber"); @@ -82,9 +81,9 @@ int main(int ac, char *av[]) IsotropicDiffusion diffusion("Phi", "Phi", diffusion_coeff); GetDiffusionTimeStepSize get_time_step_size(herat_model, diffusion); FiberDirectionDiffusionRelaxation diffusion_relaxation(herat_model_inner, &diffusion); - SimpleDynamics compute_fiber_sheet(herat_model, "Phi"); - BodySurface surface_part(herat_model); - SimpleDynamics impose_diffusion_bc(surface_part, "Phi"); + SimpleDynamics compute_fiber_sheet(herat_model, level_set_heart_model, "Phi"); + BodySurface surface_part(herat_model, level_set_heart_model); + SimpleDynamics impose_diffusion_bc(surface_part, level_set_heart_model, "Phi"); impose_diffusion_bc.exec(); write_herat_model_state_to_vtp.addToWrite(herat_model, "Phi"); write_herat_model_state_to_vtp.writeToFile(ite); @@ -114,28 +113,28 @@ int main(int ac, char *av[]) // SPH simulation section //---------------------------------------------------------------------- /** create a SPH body, material and particles */ - SolidBody physiology_heart(sph_system, level_set_heart_model, "PhysiologyHeart"); + SolidBody physiology_heart(sph_system, "PhysiologyHeart"); AlievPanfilowModel aliev_panfilow_model(k_a, c_m, k, a, b, mu_1, mu_2, epsilon); MonoFieldElectroPhysiology *myocardium_physiology = physiology_heart.defineMaterial>( aliev_panfilow_model, diffusion_coeff, bias_coeff, fiber_direction); (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? physiology_heart.generateParticles("HeartModel") - : physiology_heart.generateParticles(); + : physiology_heart.generateParticles(level_set_heart_model); /** create a SPH body, material and particles */ - SolidBody mechanics_heart(sph_system, level_set_heart_model, "MechanicalHeart"); + SolidBody mechanics_heart(sph_system, "MechanicalHeart"); mechanics_heart.defineMaterial>(rho0_s, bulk_modulus, fiber_direction, sheet_direction, a0, b0); (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? mechanics_heart.generateParticles("HeartModel") - : mechanics_heart.generateParticles(); + : mechanics_heart.generateParticles(level_set_heart_model); /** Creat a Purkinje network for fast diffusion, material and particles */ - TreeBody pkj_body(sph_system, level_set_heart_model, "Purkinje"); + TreeBody pkj_body(sph_system, "Purkinje"); MonoFieldElectroPhysiology *pkj_physiology = pkj_body.defineMaterial>( aliev_panfilow_model, diffusion_coeff * acceleration_factor); - pkj_body.generateParticles(starting_point, second_point, 50, 1.0); + pkj_body.generateParticles(level_set_heart_model, starting_point, second_point, 50, 1.0); TreeTerminates pkj_leaves(pkj_body); //---------------------------------------------------------------------- // SPH Observation section diff --git a/tests/3d_examples/test_3d_pkj_lv_electrocontraction/pkj_lv_electrocontraction.h b/tests/3d_examples/test_3d_pkj_lv_electrocontraction/pkj_lv_electrocontraction.h index f9c8a05f2b..bea4c29ce4 100644 --- a/tests/3d_examples/test_3d_pkj_lv_electrocontraction/pkj_lv_electrocontraction.h +++ b/tests/3d_examples/test_3d_pkj_lv_electrocontraction/pkj_lv_electrocontraction.h @@ -290,9 +290,9 @@ class ParticleGenerator }; public: - ParticleGenerator(SPHBody &sph_body, BaseParticles &base_particles, + ParticleGenerator(SPHBody &sph_body, BaseParticles &base_particles, LevelSetShape &level_set_shape, Vecd starting_pnt, Vecd second_pnt, int iterator, Real grad_factor) : ParticleGenerator( - sph_body, base_particles, starting_pnt, second_pnt, iterator, grad_factor){}; + sph_body, base_particles, level_set_shape, starting_pnt, second_pnt, iterator, grad_factor){}; }; } // namespace SPH diff --git a/tests/3d_examples/test_3d_poiseuille_flow_shell/poiseuille_flow_shell.cpp b/tests/3d_examples/test_3d_poiseuille_flow_shell/poiseuille_flow_shell.cpp index 8e35a23543..69eb5504d6 100644 --- a/tests/3d_examples/test_3d_poiseuille_flow_shell/poiseuille_flow_shell.cpp +++ b/tests/3d_examples/test_3d_poiseuille_flow_shell/poiseuille_flow_shell.cpp @@ -160,10 +160,9 @@ void poiseuille_flow(const Real resolution_ref, const Real resolution_shell, con //---------------------------------------------------------------------- // Define water shape //---------------------------------------------------------------------- - auto water_block_shape = makeShared("WaterBody"); - water_block_shape->add(SimTK::UnitVec3(0., 1., 0.), fluid_radius, - full_length * 0.5, SimTK_resolution, - translation_fluid); + TriangleMeshShapeCylinder water_block_shape(SimTK::UnitVec3(0., 1., 0.), fluid_radius, + full_length * 0.5, SimTK_resolution, + translation_fluid); //---------------------------------------------------------------------- // Build up -- a SPHSystem -- @@ -174,7 +173,7 @@ void poiseuille_flow(const Real resolution_ref, const Real resolution_shell, con //---------------------------------------------------------------------- // Creating bodies with corresponding materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(system, water_block_shape); + FluidBody water_block(system, "WaterBody"); water_block.defineMaterial(rho0_f, c_f, mu_f); ParticleBuffer inlet_particle_buffer(0.5); water_block.generateParticlesWithReserve(inlet_particle_buffer, water_block_shape); diff --git a/tests/3d_examples/test_3d_repose_angle/repose_angle.cpp b/tests/3d_examples/test_3d_repose_angle/repose_angle.cpp index 8709c0161f..631c8d75a9 100644 --- a/tests/3d_examples/test_3d_repose_angle/repose_angle.cpp +++ b/tests/3d_examples/test_3d_repose_angle/repose_angle.cpp @@ -84,12 +84,14 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating bodies with corresponding materials and particles. //---------------------------------------------------------------------- - RealBody soil_block(sph_system, makeShared("GranularBody")); - soil_block.defineBodyLevelSetShape()->writeLevelSet(sph_system); + SoilBlock soil_block_shape("GranularBody"); + RealBody soil_block(sph_system, soil_block_shape.getName()); + LevelSetShape level_set_shape(soil_block, soil_block_shape); + level_set_shape.writeLevelSet(sph_system); soil_block.defineMaterial(rho0_s, c_s, Youngs_modulus, poisson, friction_angle); (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? soil_block.generateParticles(soil_block.getName()) - : soil_block.generateParticles(); + : soil_block.generateParticles(level_set_shape); WallBoundary wall_boundary_shape("WallBoundary"); SolidBody wall_boundary(sph_system, wall_boundary_shape.getName()); @@ -120,7 +122,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- using namespace relax_dynamics; SimpleDynamics random_column_particles(soil_block); - RelaxationStepInner relaxation_step_inner(soil_block_inner); + RelaxationStepInner relaxation_step_inner(soil_block_inner, level_set_shape); //---------------------------------------------------------------------- // Output for particle relaxation. //---------------------------------------------------------------------- diff --git a/tests/3d_examples/test_3d_roof_parametric_cvt/test_3d_roof_parametric_cvt.cpp b/tests/3d_examples/test_3d_roof_parametric_cvt/test_3d_roof_parametric_cvt.cpp index b6ed5dce87..882f38c6a3 100644 --- a/tests/3d_examples/test_3d_roof_parametric_cvt/test_3d_roof_parametric_cvt.cpp +++ b/tests/3d_examples/test_3d_roof_parametric_cvt/test_3d_roof_parametric_cvt.cpp @@ -13,37 +13,6 @@ using namespace SPH; Real to_rad(Real angle) { return angle * Pi / 180; } -void relax_shell(RealBody &plate_body, Real thickness) -{ - // BUG: apparently only works if dp > thickness, otherwise ShellNormalDirectionPrediction::correctNormalDirection() throws error - using namespace relax_dynamics; - InnerRelation imported_model_inner(plate_body); - SimpleDynamics random_imported_model_particles(plate_body); - ShellRelaxationStep relaxation_step_inner(imported_model_inner); - ShellNormalDirectionPrediction shell_normal_prediction(imported_model_inner, thickness); - //---------------------------------------------------------------------- - // Particle relaxation starts here. - //---------------------------------------------------------------------- - random_imported_model_particles.exec(0.25); - relaxation_step_inner.MidSurfaceBounding().exec(); - plate_body.updateCellLinkedList(); - //---------------------------------------------------------------------- - // Particle relaxation time stepping start here. - //---------------------------------------------------------------------- - int ite_p = 0; - while (ite_p < 1000) - { - if (ite_p % 100 == 0) - { - std::cout << std::fixed << std::setprecision(9) << "Relaxation steps for the inserted body N = " << ite_p << "\n"; - } - relaxation_step_inner.exec(); - ite_p += 1; - } - shell_normal_prediction.exec(); - std::cout << "The physics relaxation process of imported model finish !" << std::endl; -} - namespace SPH { class ShellRoof; @@ -331,13 +300,10 @@ return_data roof_under_self_weight(Real dp, bool cvt = true, int particle_number bb_system = get_particles_bounding_box(obj_vertices); // store this } - // shell - auto shell_shape = makeShared("shell_shape" + std::to_string(dp_cm)); // 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(dp_cm)); shell_body.defineMaterial(rho, E, mu); if (cvt) { @@ -354,10 +320,6 @@ return_data roof_under_self_weight(Real dp, bool cvt = true, int particle_number system.system_domain_bounds_ = bb_system; std::cout << "bb_system.first_: " << bb_system.first_ << std::endl; std::cout << "bb_system.second_: " << bb_system.second_ << std::endl; - { // recalculate the volume/area after knowing the particle positions - // for (auto& vol: shell_particles->Vol_) vol = total_area / shell_particles->TotalRealParticles(); - // for (auto& mass: shell_particles->mass_) mass = total_area*rho / shell_particles->TotalRealParticles(); - } // methods InnerRelation shell_body_inner(shell_body); diff --git a/tests/3d_examples/test_3d_self_contact/3d_self_contact.cpp b/tests/3d_examples/test_3d_self_contact/3d_self_contact.cpp index 5095b01536..77cedba25c 100644 --- a/tests/3d_examples/test_3d_self_contact/3d_self_contact.cpp +++ b/tests/3d_examples/test_3d_self_contact/3d_self_contact.cpp @@ -69,16 +69,19 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - SolidBody coil(sph_system, makeShared("Coil")); - coil.defineBodyLevelSetShape()->writeLevelSet(sph_system); + Coil coil_shape("Coil"); + SolidBody coil(sph_system, coil_shape.getName()); + LevelSetShape level_set_shape(coil, coil_shape); + level_set_shape.writeLevelSet(sph_system); coil.defineMaterial(rho0_s, Youngs_modulus, poisson); (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? coil.generateParticles(coil.getName()) - : coil.generateParticles(); + : coil.generateParticles(level_set_shape); - SolidBody stationary_plate(sph_system, makeShared("StationaryPlate")); + StationaryPlate stationary_plate_shape("StationaryPlate"); + SolidBody stationary_plate(sph_system, stationary_plate_shape.getName()); stationary_plate.defineMaterial(rho0_s, Youngs_modulus, poisson); - stationary_plate.generateParticles(); + stationary_plate.generateParticles(stationary_plate_shape); //---------------------------------------------------------------------- // Define body relation map. // The contact map gives the topological connections between the bodies. @@ -88,8 +91,8 @@ int main(int ac, char *av[]) // inner and contact relations. //---------------------------------------------------------------------- InnerRelation coil_inner(coil); - SelfSurfaceContactRelation coil_self_contact(coil); - SurfaceContactRelation coil_contact(coil_self_contact, {&stationary_plate}); + SelfSurfaceContactRelation coil_self_contact(coil, level_set_shape); + SurfaceContactRelation coil_contact(coil_self_contact, level_set_shape, {&stationary_plate}); //---------------------------------------------------------------------- // Define simple file input and outputs functions. //---------------------------------------------------------------------- @@ -107,7 +110,7 @@ int main(int ac, char *av[]) // Write the particle reload files. ReloadParticleIO write_particle_reload_files(coil); // A Physics relaxation step. - RelaxationStepInner relaxation_step_inner(coil_inner); + RelaxationStepInner relaxation_step_inner(coil_inner, level_set_shape); //---------------------------------------------------------------------- // Particle relaxation starts here. //---------------------------------------------------------------------- diff --git a/tests/3d_examples/test_3d_shell_particle_relaxation/test_3d_shell_particle_relaxation.cpp b/tests/3d_examples/test_3d_shell_particle_relaxation/test_3d_shell_particle_relaxation.cpp index e096c174f9..9fc8af7b30 100644 --- a/tests/3d_examples/test_3d_shell_particle_relaxation/test_3d_shell_particle_relaxation.cpp +++ b/tests/3d_examples/test_3d_shell_particle_relaxation/test_3d_shell_particle_relaxation.cpp @@ -48,9 +48,11 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - RealBody imported_model(sph_system, makeShared("ImportedShellModel")); - imported_model.defineBodyLevelSetShape(level_set_refinement_ratio)->correctLevelSetSign()->writeLevelSet(sph_system); - imported_model.generateParticles(thickness); + ImportedShellModel imported_model_shape("ImportedShellModel"); + RealBody imported_model(sph_system, imported_model_shape.getName()); + LevelSetShape level_set_shape(imported_model, imported_model_shape, level_set_refinement_ratio); + level_set_shape.correctLevelSetSign()->writeLevelSet(sph_system); + imported_model.generateParticles(level_set_shape, thickness); //---------------------------------------------------------------------- // Define simple file input and outputs functions. //---------------------------------------------------------------------- @@ -72,8 +74,8 @@ int main(int ac, char *av[]) using namespace relax_dynamics; SimpleDynamics random_imported_model_particles(imported_model); /** A Physics relaxation step. */ - ShellRelaxationStep relaxation_step_inner(imported_model_inner); - ShellNormalDirectionPrediction shell_normal_prediction(imported_model_inner, thickness); + ShellRelaxationStep relaxation_step_inner(imported_model_inner, level_set_shape); + ShellNormalDirectionPrediction shell_normal_prediction(imported_model_inner, level_set_shape, thickness); //---------------------------------------------------------------------- // Particle relaxation starts here. //---------------------------------------------------------------------- diff --git a/tests/3d_examples/test_3d_shell_stability_half_sphere/test_3d_shell_stability_half_sphere.cpp b/tests/3d_examples/test_3d_shell_stability_half_sphere/test_3d_shell_stability_half_sphere.cpp index 526d514fb0..564cf65fdb 100644 --- a/tests/3d_examples/test_3d_shell_stability_half_sphere/test_3d_shell_stability_half_sphere.cpp +++ b/tests/3d_examples/test_3d_shell_stability_half_sphere/test_3d_shell_stability_half_sphere.cpp @@ -134,13 +134,10 @@ void sphere_compression(int dp_ratio, Real pressure, Real gravity_z) 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("shell_shape" + std::to_string(dp_ratio)); // 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(dp_ratio)); shell_body.defineMaterial(rho, E, mu); shell_body.generateParticles(obj_vertices, center, particle_area, thickness); auto shell_particles = dynamic_cast(&shell_body.getBaseParticles()); diff --git a/tests/3d_examples/test_3d_sliding/test_3d_sliding.cpp b/tests/3d_examples/test_3d_sliding/test_3d_sliding.cpp index 91d462414d..74e3834e55 100644 --- a/tests/3d_examples/test_3d_sliding/test_3d_sliding.cpp +++ b/tests/3d_examples/test_3d_sliding/test_3d_sliding.cpp @@ -94,26 +94,26 @@ void block_sliding( // Import meshes auto cube_translation = Vec3d(0.5 * cube_length + 2 * resolution_cube, 0.5 * cube_length, 0.0); - auto mesh_cube = std::make_shared(0.5 * cube_length * Vec3d::Ones(), 5, cube_translation, "Cube"); + TriangleMeshShapeBrick mesh_cube(0.5 * cube_length * Vec3d::Ones(), 5, cube_translation, "Cube"); auto slope_translation = Vec3d(0.5 * slope_length, -(0.65 * resolution_cube + 1.15 * resolution_slope), 0); - auto mesh_slope = std::make_shared(0.5 * Vec3d(slope_length, resolution_slope, slope_width), 5, slope_translation, "Slope"); + TriangleMeshShapeBrick mesh_slope(0.5 * Vec3d(slope_length, resolution_slope, slope_width), 5, slope_translation, "Slope"); // Material models auto material_cube = makeShared(rho0_s, Youngs_modulus, poisson); // System bounding box - BoundingBox bb_system = union_bounding_box(mesh_cube->getBounds(), mesh_slope->getBounds()); + BoundingBox bb_system = union_bounding_box(mesh_cube.getBounds(), mesh_slope.getBounds()); // System SPHSystem system(bb_system, resolution_cube); IOEnvironment io_environment(system); // Create objects - SolidBody cube_body(system, mesh_cube); + SolidBody cube_body(system, mesh_cube.getName()); cube_body.assignMaterial(material_cube.get()); - cube_body.generateParticles(); + cube_body.generateParticles(mesh_cube); - SolidBody slope_body(system, mesh_slope); + SolidBody slope_body(system, mesh_slope.getName()); slope_body.defineAdaptationRatios(1.15, resolution_cube / resolution_slope); slope_body.assignMaterial(material_cube.get()); slope_body.generateParticles(slope_translation, slope_length, slope_width, resolution_slope); @@ -130,7 +130,7 @@ void block_sliding( ReduceDynamics computing_time_step_size(cube_body); // Contact relation - SurfaceContactRelation contact_cube_to_slope(cube_body, {&slope_body}, {true}); + SurfaceContactRelation contact_cube_to_slope(cube_body, mesh_cube, {&slope_body}, {true}); // Contact density InteractionDynamics contact_factor(contact_cube_to_slope); // Contact Force diff --git a/tests/3d_examples/test_3d_stfb/stfb.cpp b/tests/3d_examples/test_3d_stfb/stfb.cpp index 6c0a479762..7fc0f2cf2a 100644 --- a/tests/3d_examples/test_3d_stfb/stfb.cpp +++ b/tests/3d_examples/test_3d_stfb/stfb.cpp @@ -70,7 +70,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- SimpleDynamics structure_offset_position(structure, offset); SimpleDynamics wall_boundary_normal_direction(wall_boundary, wall_boundary_shape); - SimpleDynamics str_normal(structure); + SimpleDynamics str_normal(structure, floating_structure_shape); Gravity gravity(Vec3d(0.0, 0.0, -gravity_g)); SimpleDynamics> constant_gravity(water_block, gravity); diff --git a/tests/3d_examples/test_3d_taylor_bar/taylor_bar.cpp b/tests/3d_examples/test_3d_taylor_bar/taylor_bar.cpp index ca6d161f72..10a639ed5d 100644 --- a/tests/3d_examples/test_3d_taylor_bar/taylor_bar.cpp +++ b/tests/3d_examples/test_3d_taylor_bar/taylor_bar.cpp @@ -23,18 +23,21 @@ int main(int ac, char *av[]) IOEnvironment io_environment(sph_system); /** create a body with corresponding material, particles and reaction model. */ - SolidBody column(sph_system, makeShared("Column")); + Column column_shape("Column"); + SolidBody column(sph_system, column_shape.getName()); column.defineAdaptationRatios(1.3, 1.0); - column.defineBodyLevelSetShape()->writeLevelSet(sph_system); + LevelSetShape level_set_shape(column, column_shape); + level_set_shape.writeLevelSet(sph_system); column.defineMaterial( rho0_s, Youngs_modulus, poisson, yield_stress, hardening_modulus); (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? column.generateParticles(column.getName()) - : column.generateParticles(); + : column.generateParticles(level_set_shape); - SolidBody wall(sph_system, makeShared("Wall")); + WallShape wall_shape("Wall"); + SolidBody wall(sph_system, wall_shape.getName()); wall.defineMaterial(rho0_s, Youngs_modulus, poisson); - wall.generateParticles(); + wall.generateParticles(wall_shape); /** Define Observer. */ ObserverBody my_observer(sph_system, "MyObserver"); @@ -44,7 +47,7 @@ int main(int ac, char *av[]) /**body relation topology */ InnerRelation column_inner(column); ContactRelation my_observer_contact(my_observer, {&column}); - SurfaceContactRelation column_wall_contact(column, {&wall}); + SurfaceContactRelation column_wall_contact(column, level_set_shape, {&wall}); /**define simple data file input and outputs functions. */ BodyStatesRecordingToVtp write_states(sph_system); @@ -59,7 +62,7 @@ int main(int ac, char *av[]) ReloadParticleIO write_particle_reload_files(column); /** A Physics relaxation step. */ - RelaxationStepInner relaxation_step_inner(column_inner); + RelaxationStepInner relaxation_step_inner(column_inner, level_set_shape); /** * @brief Particle relaxation starts here. */ @@ -88,7 +91,7 @@ int main(int ac, char *av[]) // All numerical methods will be used in this case. //---------------------------------------------------------------------- SimpleDynamics initial_condition(column); - SimpleDynamics wall_normal_direction(wall); + SimpleDynamics wall_normal_direction(wall, wall_shape); InteractionWithUpdate corrected_configuration(column_inner); Dynamics1Level stress_relaxation_first_half(column_inner); diff --git a/tests/3d_examples/test_3d_twisting_column/twisting_column.cpp b/tests/3d_examples/test_3d_twisting_column/twisting_column.cpp index 29a0a52c20..9bb1d9145f 100644 --- a/tests/3d_examples/test_3d_twisting_column/twisting_column.cpp +++ b/tests/3d_examples/test_3d_twisting_column/twisting_column.cpp @@ -83,9 +83,10 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Creating bodies with corresponding materials and particles. //---------------------------------------------------------------------- - SolidBody column(sph_system, makeShared("Column")); + Column column_shape("Column"); + SolidBody column(sph_system, column_shape.getName()); column.defineMaterial(rho0_s, Youngs_modulus, poisson); - column.generateParticles(); + column.generateParticles(column_shape); ObserverBody my_observer(sph_system, "MyObserver"); StdVec observation_location = {Vecd(PL, 0.0, 0.0)}; diff --git a/tests/extra_source_and_tests/test_2d_lid_driven_cavity/lid_driven_cavity.cpp b/tests/extra_source_and_tests/test_2d_lid_driven_cavity/lid_driven_cavity.cpp index 0d1426e46c..8b26e75107 100644 --- a/tests/extra_source_and_tests/test_2d_lid_driven_cavity/lid_driven_cavity.cpp +++ b/tests/extra_source_and_tests/test_2d_lid_driven_cavity/lid_driven_cavity.cpp @@ -132,16 +132,18 @@ int main(int ac, char *av[]) sph_system.handleCommandlineOptions(ac, av)->setIOEnvironment(); // Creating bodies with corresponding materials and particles - FluidBody fluid(sph_system, makeShared("FluidBody")); + FluidFilling fluid_body_shape("FluidBody"); + FluidBody fluid(sph_system, fluid_body_shape.getName()); fluid.defineMaterial(rho, SOS, min_shear_rate, max_shear_rate, K, n, tau_y); - fluid.generateParticles(); + fluid.generateParticles(fluid_body_shape); - SolidBody no_slip_boundary(sph_system, makeShared("NoSlipWall")); + No_Slip_Boundary no_slip_boundary_shape("NoSlipWall"); + SolidBody no_slip_boundary(sph_system, no_slip_boundary_shape.getName()); no_slip_boundary.defineMaterial(); - no_slip_boundary.generateParticles(); + no_slip_boundary.generateParticles(no_slip_boundary_shape); - ObserverBody observer_body(sph_system, makeShared("ObserverBody")); - observer_body.generateParticles(); + ObserverBody observer_body(sph_system, "ObserverBody"); + observer_body.generateParticles(fluid_body_shape); // Define body relation map InnerRelation fluid_inner(fluid); @@ -150,7 +152,7 @@ int main(int ac, char *av[]) ComplexRelation fluid_walls_complex(fluid_inner, fluid_all_walls); // Define the numerical methods used in the simulation - SimpleDynamics wall_boundary_normal_direction(no_slip_boundary); + SimpleDynamics wall_boundary_normal_direction(no_slip_boundary, no_slip_boundary_shape); InteractionWithUpdate corrected_configuration_fluid(ConstructorArgs(fluid_inner, 0.3), fluid_all_walls); Dynamics1Level> pressure_relaxation(fluid_inner, fluid_all_walls); Dynamics1Level> density_relaxation(fluid_inner, fluid_all_walls); diff --git a/tests/unit_tests_src/for_2D_build/meshes/test_2d_particle_for_split/test_particle_for_split.cpp b/tests/unit_tests_src/for_2D_build/meshes/test_2d_particle_for_split/test_particle_for_split.cpp index e0eb37daa0..299f49b343 100644 --- a/tests/unit_tests_src/for_2D_build/meshes/test_2d_particle_for_split/test_particle_for_split.cpp +++ b/tests/unit_tests_src/for_2D_build/meshes/test_2d_particle_for_split/test_particle_for_split.cpp @@ -10,15 +10,15 @@ TEST(test_meshes, split_for) MultiPolygon shape; shape.addABox(Transform(0.5 * length * Vec2d::Ones()), 0.5 * length * Vec2d::Ones(), ShapeBooleanOps::add); - auto polygon_shape = makeShared(shape, "PolygonShape"); + MultiPolygonShape polygon_shape(shape, "PolygonShape"); - BoundingBox bb_system = polygon_shape->getBounds(); + BoundingBox bb_system = polygon_shape.getBounds(); SPHSystem system(bb_system, dp); - SolidBody body(system, polygon_shape); + SolidBody body(system, polygon_shape.getName()); body.defineMaterial(); - body.generateParticles(); + body.generateParticles(polygon_shape); auto &particles = body.getBaseParticles(); const auto pos = particles.registerStateVariable("Position"); auto quantity = particles.registerStateVariable("Quantity", [&](size_t i) -> Real