diff --git a/src/for_2D_build/common/data_type.h b/src/for_2D_build/common/data_type.h index f1a425efa4..4f93dc7720 100644 --- a/src/for_2D_build/common/data_type.h +++ b/src/for_2D_build/common/data_type.h @@ -61,8 +61,11 @@ const Matd reduced_unit_matrix{ /** initial local normal, only works for thin structure dynamics. */ const Vecd local_pseudo_n_0 = Vecd(0.0, 1.0); - const Vecd ZeroVecd = Vec2d::Zero(); + +inline Vecd degradeToVecd(const Vec3d &input) { return Vecd(input[0], input[1]); }; +inline Matd degradeToMatd(const Mat3d &input) { return input.block<2, 2>(0, 0); }; + } // namespace SPH #endif // DATA_TYPE_2D_H \ No newline at end of file diff --git a/src/for_2D_build/common/vector_functions_2d.cpp b/src/for_2D_build/common/vector_functions_2d.cpp deleted file mode 100644 index 0bc0ec9ed9..0000000000 --- a/src/for_2D_build/common/vector_functions_2d.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "vector_functions.h" - -namespace SPH -{ -//=================================================================================================// -Vec2d degradeToVecd(const Vec3d &input) -{ - Vec2d output = Vec2d::Zero(); - for (int i = 0; i != Dimensions; i++) - output[i] = input[i]; - return output; -} -//=================================================================================================// -Mat2d degradeToMatd(const Mat3d &input) -{ - Mat2d output = Mat2d::Zero(); - for (int i = 0; i != Dimensions; i++) - for (int j = 0; j != Dimensions; j++) - output(i, j) = input(i, j); - return output; -} -//=================================================================================================// -} // namespace SPH diff --git a/src/for_3D_build/common/data_type.h b/src/for_3D_build/common/data_type.h index 288fc2d852..540ceb3975 100644 --- a/src/for_3D_build/common/data_type.h +++ b/src/for_3D_build/common/data_type.h @@ -61,7 +61,9 @@ const Matd reduced_unit_matrix{ /** initial local normal, only works for thin structure dynamics. */ const Vecd local_pseudo_n_0 = Vecd(0.0, 0.0, 1.0); const Vecd local_pseudo_b_n_0 = Vecd(0.0, 1.0, 0.0); - const Vecd ZeroVecd = Vec3d::Zero(); + +inline Vecd degradeToVecd(const Vec3d &input) { return input; }; +inline Matd degradeToMatd(const Mat3d &input) { return input; }; } // namespace SPH #endif // DATA_TYPE_3D_H \ No newline at end of file diff --git a/src/for_3D_build/common/scalar_functions_3d.cpp b/src/for_3D_build/common/scalar_functions_3d.cpp index 13687003a4..47c495481c 100644 --- a/src/for_3D_build/common/scalar_functions_3d.cpp +++ b/src/for_3D_build/common/scalar_functions_3d.cpp @@ -7,4 +7,5 @@ int NextAxis(int first_axis) { return first_axis == 2 ? 0 : first_axis + 1; } +//=================================================================================================// } // namespace SPH diff --git a/src/for_3D_build/common/vector_functions_3d.cpp b/src/for_3D_build/common/vector_functions_3d.cpp deleted file mode 100644 index c77196c40e..0000000000 --- a/src/for_3D_build/common/vector_functions_3d.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "vector_functions.h" - -namespace SPH -{ -//=================================================================================================// -Vec3d degradeToVecd(const Vec3d &input) -{ - return input; -} -//=================================================================================================// -Mat3d degradeToMatd(const Mat3d &input) -{ - return input; -} -//=================================================================================================// -} // namespace SPH diff --git a/src/for_3D_build/particle_dynamics/solid_dynamics/slender_structure_dynamics.h b/src/for_3D_build/particle_dynamics/solid_dynamics/slender_structure_dynamics.h index 75cd7f9ef4..cdf03b2e6a 100644 --- a/src/for_3D_build/particle_dynamics/solid_dynamics/slender_structure_dynamics.h +++ b/src/for_3D_build/particle_dynamics/solid_dynamics/slender_structure_dynamics.h @@ -260,7 +260,7 @@ class BarStressRelaxationFirstHalf : public BaseBarRelaxation /** * @class BarStressRelaxationSecondHalf - * @brief computing stress relaxation process by verlet time stepping + * @brief computing stress relaxation process by Verlet time stepping * This is the second step */ class BarStressRelaxationSecondHalf : public BaseBarRelaxation diff --git a/src/shared/bodies/base_body.cpp b/src/shared/bodies/base_body.cpp index 71edccef28..40a1a81e44 100644 --- a/src/shared/bodies/base_body.cpp +++ b/src/shared/bodies/base_body.cpp @@ -80,11 +80,6 @@ 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); -} -//=================================================================================================// void SPHBody::defineAdaptationRatios(Real h_spacing_ratio, Real new_system_refinement_ratio) { sph_adaptation_->resetAdaptationRatios(h_spacing_ratio, new_system_refinement_ratio); diff --git a/src/shared/bodies/base_body.h b/src/shared/bodies/base_body.h index 81639414a7..1fe128b969 100644 --- a/src/shared/bodies/base_body.h +++ b/src/shared/bodies/base_body.h @@ -38,11 +38,11 @@ #include "adaptation.h" #include "all_geometries.h" #include "base_data_package.h" +#include "base_implementation.h" #include "base_material.h" #include "base_particle_generator.h" #include "base_particles.h" #include "cell_linked_list.h" -#include "execution.h" #include "sph_system.h" #include "sphinxsys_containers.h" @@ -76,9 +76,7 @@ class SPHBody 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 */ + int total_body_parts_; /**< total number of body parts */ public: SPHAdaptation *sph_adaptation_; /**< numerical adaptation policy */ @@ -109,7 +107,6 @@ class SPHBody void setSPHBodyBounds(const BoundingBox &bound); BoundingBox getSPHBodyBounds(); BoundingBox getSPHSystemBounds(); - void registerComputingKernel(execution::Implementation *implementation); int getNewBodyPartID(); int getTotalBodyParts() { return total_body_parts_; }; //---------------------------------------------------------------------- diff --git a/src/shared/bodies/base_body_part.cpp b/src/shared/bodies/base_body_part.cpp index ec793229fc..b524348b69 100644 --- a/src/shared/bodies/base_body_part.cpp +++ b/src/shared/bodies/base_body_part.cpp @@ -4,12 +4,28 @@ namespace SPH { //=================================================================================================// +BodyPart::BodyPart(SPHBody &sph_body, const std::string &body_part_name) + : sph_body_(sph_body), part_id_(sph_body.getNewBodyPartID()), + body_part_name_(body_part_name), + base_particles_(sph_body.getBaseParticles()), + dv_index_list_(nullptr), sv_range_size_(nullptr), + pos_(base_particles_.getVariableDataByName("Position")) {} +//=================================================================================================// +BodyPartByParticle::BodyPartByParticle(SPHBody &sph_body, const std::string &body_part_name) + : BodyPart(sph_body, body_part_name), + body_part_bounds_(Vecd::Zero(), Vecd::Zero()), body_part_bounds_set_(false) {} +//=================================================================================================// void BodyPartByParticle::tagParticles(TaggingParticleMethod &tagging_particle_method) { for (size_t i = 0; i < base_particles_.TotalRealParticles(); ++i) { tagging_particle_method(i); } + dv_index_list_ = base_particles_.addUniqueDiscreteVariableOnly( + body_part_name_, body_part_particles_.size(), [&](size_t i) -> Real + { return body_part_particles_[i]; }); + sv_range_size_ = base_particles_.addUniqueSingularVariableOnly( + body_part_name_ + "_Size", body_part_particles_.size()); }; //=============================================================================================// size_t BodyPartByCell::SizeOfLoopRange() @@ -41,7 +57,6 @@ BodyRegionByParticle::BodyRegionByParticle(SPHBody &sph_body, SharedPtr s { shape_ptr_keeper_.assignRef(shape_ptr); } -//== //=================================================================================================// void BodyRegionByParticle::tagByContain(size_t particle_index) { diff --git a/src/shared/bodies/base_body_part.h b/src/shared/bodies/base_body_part.h index 9e9812ffaf..83acfac919 100644 --- a/src/shared/bodies/base_body_part.h +++ b/src/shared/bodies/base_body_part.h @@ -44,23 +44,22 @@ using namespace std::placeholders; class BodyPart { public: - BodyPart(SPHBody &sph_body, const std::string &body_part_name) - : sph_body_(sph_body), part_id_(sph_body.getNewBodyPartID()), - body_part_name_(body_part_name), - base_particles_(sph_body.getBaseParticles()), - pos_(base_particles_.getVariableDataByName("Position")){}; + BodyPart(SPHBody &sph_body, const std::string &body_part_name); virtual ~BodyPart(){}; - SPHBody &getSPHBody() { return sph_body_; }; SPHSystem &getSPHSystem() { return sph_body_.getSPHSystem(); }; std::string getName() { return body_part_name_; }; int getPartID() { return part_id_; }; + DiscreteVariable *dvIndexList() { return dv_index_list_; }; + SingularVariable *svRangeSize() { return sv_range_size_; }; protected: SPHBody &sph_body_; int part_id_; std::string body_part_name_; BaseParticles &base_particles_; + DiscreteVariable *dv_index_list_; + SingularVariable *sv_range_size_; Vecd *pos_; }; @@ -75,10 +74,7 @@ class BodyPartByParticle : public BodyPart BaseParticles &getBaseParticles() { return base_particles_; }; IndexVector &LoopRange() { return body_part_particles_; }; size_t SizeOfLoopRange() { return body_part_particles_.size(); }; - - BodyPartByParticle(SPHBody &sph_body, const std::string &body_part_name) - : BodyPart(sph_body, body_part_name), - body_part_bounds_(Vecd::Zero(), Vecd::Zero()), body_part_bounds_set_(false){}; + BodyPartByParticle(SPHBody &sph_body, const std::string &body_part_name); virtual ~BodyPartByParticle(){}; void setBodyPartBounds(BoundingBox bbox) diff --git a/src/shared/body_relations/base_body_relation.h b/src/shared/body_relations/base_body_relation.h index a348dddc59..c4f85c6c73 100644 --- a/src/shared/body_relations/base_body_relation.h +++ b/src/shared/body_relations/base_body_relation.h @@ -34,7 +34,7 @@ #include "base_geometry.h" #include "base_particles.h" #include "cell_linked_list.h" -#include "execution.h" +#include "base_implementation.h" #include "neighborhood.h" namespace SPH diff --git a/src/shared/body_relations/contact_body_relation.cpp b/src/shared/body_relations/contact_body_relation.cpp index 62a5b68fed..769bbf9f77 100644 --- a/src/shared/body_relations/contact_body_relation.cpp +++ b/src/shared/body_relations/contact_body_relation.cpp @@ -3,6 +3,8 @@ #include "base_particle_dynamics.h" #include "cell_linked_list.hpp" +#include + namespace SPH { //=================================================================================================// diff --git a/src/shared/common/base_data_package.h b/src/shared/common/base_data_package.h index d86d55636f..7eae97a163 100644 --- a/src/shared/common/base_data_package.h +++ b/src/shared/common/base_data_package.h @@ -72,38 +72,6 @@ using DataContainerAddressAssemble = DataAssemble typename ContainerType> using DataContainerUniquePtrAssemble = DataAssemble; -/** a type irrelevant operation on the data assembles */ -template