Skip to content

Commit

Permalink
Translate body part (#45)
Browse files Browse the repository at this point in the history
* Feature/contact stent 2 (#10)

* PositionSolidBody added

* boundary condition works but breaks numerically

* no message

* first unit test added

* indentation change

* PositionSolidBody test

* remove file

* small fixes

* position constraint changed
works between start and end time

* scaling boundary condition

* PositionScaleSolidBody unit test

* particel adaptation changed

* system resolution ratio added to particle adaptation

* add googletest to docker and workflow

* unit test removed temporarily

* unit rest removed

* SolidParticleRelaxation added to update initial particle position

* gtest added again

* gtest install changed

* gtest

* gtest

* gtest

* gtest

* cd path updated

* change to shared pointers

* unit test pointers changed

* gtest added to docker

* initialization changed

* disable tests for simbody

* errors fixed

* TranslationSolidBody added; translation cylinder

* whitespace

* fixes

* TranslateSolidBody corrected

* writeToFile update

* change SET to set

* catch(out_of_range& e) added

* change to size_t

* cmake minimum removed

* BoundingBox test changed

* fix writeToFIle

* test change

* Feature/position bc stent (#34)

* PositionSolidBody added

* boundary condition works but breaks numerically

* no message

* first unit test added

* indentation change

* PositionSolidBody test

* remove file

* small fixes

* position constraint changed
works between start and end time

* scaling boundary condition

* PositionScaleSolidBody unit test

* particel adaptation changed

* system resolution ratio added to particle adaptation

* add googletest to docker and workflow

* unit test removed temporarily

* unit rest removed

* SolidParticleRelaxation added to update initial particle position

* gtest added again

* gtest install changed

* gtest

* gtest

* gtest

* gtest

* cd path updated

* change to shared pointers

* unit test pointers changed

* gtest added to docker

* initialization changed

* errors fixed

* TranslationSolidBody added; translation cylinder

* whitespace

* fixes

* TranslateSolidBody corrected

* writeToFile update

* change SET to set

* catch(out_of_range& e) added

* change to size_t

* cmake minimum removed

* BoundingBox test changed

* fix writeToFIle

* test change

Co-authored-by: JohnVirtonomy <[email protected]>

* -Werror only works for linux

* TEST TranslateSolidBodyTuple

* Update CMakeLists.txt

remove werror flag for msvc

* update from bitbucket 01.07.2021

* delete repeated files

* brief information on google test in repo readme

* delete clapack and simbody folder in root

* google test works for windows but the unit test case did not copy stl file right in windows

* now test_3d_unit works in windows.

* information on installing google test in windows

* add a comment on install ing for VS in windows

* translation with same scale&unit test update

* skip testing when [ci skip] in the commit message

* update test_3d_unit - TranslateSolidBody not work

* time-dependent-contact

* number of time dep. contacts fixed

* setup unit test for time dependent contact

* Translate Solid Body fixed
but tolerance is only 0.01

* output changed to 100 files always

* 07.13.2021 update

* typo

* new files from bitbucket

* update 07.13.2021

* time dependent contact fixed

* time dep contact fixed

* remove cout

* time dep. contact tests finished

* renaming

* fix naming

* move test class into seperate header

* cmake changes

* changing function names to lower case

* change cmake list

* small fix

Co-authored-by: Ubuntu <virtonomy@SPHsimulation2.qg4qjrxycqxetcothedhm1ylih.ax.internal.cloudapp.net>
Co-authored-by: JohnVirtonomy <[email protected]>
Co-authored-by: Xiangyu Hu <[email protected]>
Co-authored-by: Wen-Yang Chu <[email protected]>
Co-authored-by: Xiangyu Hu <xiangyu.hu@tum>
Co-authored-by: Xiangyu Hu <[email protected]>

* TranslateSolidBodyPart added

* particle relaxation fixed

* change Get_ to get_

* checkIfPointInBoundingBox moved

Co-authored-by: Ubuntu <virtonomy@SPHsimulation2.qg4qjrxycqxetcothedhm1ylih.ax.internal.cloudapp.net>
Co-authored-by: JohnVirtonomy <[email protected]>
Co-authored-by: Xiangyu Hu <[email protected]>
Co-authored-by: Wen-Yang Chu <[email protected]>
Co-authored-by: Xiangyu Hu <xiangyu.hu@tum>
Co-authored-by: Xiangyu Hu <[email protected]>
  • Loading branch information
7 people authored Jul 30, 2021
1 parent 3845048 commit 66343ad
Show file tree
Hide file tree
Showing 21 changed files with 276 additions and 118 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void expandBoundingBox(BoundingBox* original, BoundingBox* additional)
}

void relaxParticlesSingleResolution(In_Output* in_output,
bool write_particles_to_file,
bool write_particle_relaxation_data,
ImportedModel* imported_model,
ElasticSolidParticles* imported_model_particles,
BodyRelationInner* imported_model_inner)
Expand All @@ -78,15 +78,11 @@ void relaxParticlesSingleResolution(In_Output* in_output,
//----------------------------------------------------------------------
random_imported_model_particles.parallel_exec(0.25);
relaxation_step_inner.surface_bounding_.parallel_exec();
if (write_particles_to_file)
if (write_particle_relaxation_data)
{
write_imported_model_to_vtu.writeToFile(0.0);
}
imported_model->updateCellLinkedList();
if (write_particles_to_file)
{
mesh_cell_linked_list_recording.writeToFile(0.0);
}
//----------------------------------------------------------------------
// Particle relaxation time stepping start here.
//----------------------------------------------------------------------
Expand All @@ -97,14 +93,14 @@ void relaxParticlesSingleResolution(In_Output* in_output,
ite_p += 1;
if (ite_p % 100 == 0)
{
cout << fixed << setprecision(9) << "Relaxation steps for the imported model N = " << ite_p << "\n";
if (write_particles_to_file)
std::cout << std::fixed << std::setprecision(9) << "Relaxation steps for the imported model N = " << ite_p << "\n";
if (write_particle_relaxation_data)
{
write_imported_model_to_vtu.writeToFile(Real(ite_p) * 1.0e-4);
write_imported_model_to_vtu.writeToFile(ite_p);
}
}
}
cout << "The physics relaxation process of imported model finish !" << endl;
std::cout << "The physics relaxation process of the imported model finished !" << std::endl;
}

StructuralSimulationInput::StructuralSimulationInput(
Expand All @@ -131,6 +127,7 @@ StructuralSimulationInput::StructuralSimulationInput(
// particle_relaxation option
particle_relaxation_list_ = {};
for (size_t i = 0; i < resolution_list_.size(); i++){ particle_relaxation_list_.push_back(true); }
write_particle_relaxation_data_ = false;
// scale system boundaries
scale_system_boundaries_ = 1;
// boundary conditions
Expand All @@ -141,6 +138,7 @@ StructuralSimulationInput::StructuralSimulationInput(
position_solid_body_tuple_ = {};
position_scale_solid_body_tuple_ = {};
translation_solid_body_tuple_ = {};
translation_solid_body_part_tuple_ = {};
};

///////////////////////////////////////
Expand All @@ -161,6 +159,7 @@ StructuralSimulation::StructuralSimulation(StructuralSimulationInput& input):

// default system, optional: particle relaxation, scale_system_boundaries
particle_relaxation_list_(input.particle_relaxation_list_),
write_particle_relaxation_data_(input.write_particle_relaxation_data_),
system_resolution_(0.0),
system_(SPHSystem(BoundingBox(Vec3d(0), Vec3d(0)), system_resolution_)),
scale_system_boundaries_(input.scale_system_boundaries_),
Expand All @@ -173,7 +172,8 @@ StructuralSimulation::StructuralSimulation(StructuralSimulationInput& input):
body_indeces_fixed_constraint_(input.body_indeces_fixed_constraint_),
position_solid_body_tuple_(input.position_solid_body_tuple_),
position_scale_solid_body_tuple_(input.position_scale_solid_body_tuple_),
translation_solid_body_tuple_(input.translation_solid_body_tuple_)
translation_solid_body_tuple_(input.translation_solid_body_tuple_),
translation_solid_body_part_tuple_(input.translation_solid_body_part_tuple_)
{
// scaling of translation and resolution
scaleTranslationAndResolution();
Expand All @@ -199,6 +199,7 @@ StructuralSimulation::StructuralSimulation(StructuralSimulationInput& input):
initializePositionSolidBody();
initializePositionScaleSolidBody();
initializeTranslateSolidBody();
initializeTranslateSolidBodyPart();

// initialize simulation
initializeSimulation();
Expand Down Expand Up @@ -282,7 +283,7 @@ void StructuralSimulation::initializeElasticSolidBodies()
solid_body_list_.emplace_back(make_shared<SolidBodyForSimulation>(system_, imported_stl_list_[i], body_mesh_list_[i], particle_adaptation_list_[i], physical_viscosity_, material_model_list_[i]));
if (particle_relaxation_list_[i])
{
relaxParticlesSingleResolution(&in_output_, false, solid_body_list_[i]->getImportedModel(), solid_body_list_[i]->getElasticSolidParticles(), solid_body_list_[i]->getInnerBodyRelation());
relaxParticlesSingleResolution(&in_output_, write_particle_relaxation_data_, solid_body_list_[i]->getImportedModel(), solid_body_list_[i]->getElasticSolidParticles(), solid_body_list_[i]->getInnerBodyRelation());
}
}
}
Expand Down Expand Up @@ -355,7 +356,7 @@ void StructuralSimulation::initializeAccelerationForBodyPartInBoundingBox()
{
SolidBody* solid_body = solid_body_list_[get<0>(acceleration_bounding_box_tuple_[i])]->getImportedModel();
acceleration_bounding_box_.emplace_back(make_shared<solid_dynamics::AccelerationForBodyPartInBoundingBox>
(solid_body, &get<1>(acceleration_bounding_box_tuple_[i]), get<2>(acceleration_bounding_box_tuple_[i])));
(solid_body, get<1>(acceleration_bounding_box_tuple_[i]), get<2>(acceleration_bounding_box_tuple_[i])));
}
}

Expand Down Expand Up @@ -419,9 +420,29 @@ void StructuralSimulation::initializeTranslateSolidBody()
Real start_time = get<1>(translation_solid_body_tuple_[i]);
Real end_time = get<2>(translation_solid_body_tuple_[i]);
Vecd translation = get<3>(translation_solid_body_tuple_[i]);
BodyPartByParticleTriMesh* bp = new BodyPartByParticleTriMesh(solid_body_list_[body_index]->getImportedModel(), imported_stl_list_[body_index], &body_mesh_list_[body_index]);
BodyPartByParticleTriMesh* bp = new BodyPartByParticleTriMesh(
solid_body_list_[body_index]->getImportedModel(), imported_stl_list_[body_index], &body_mesh_list_[body_index]);

translation_solid_body_.emplace_back(make_shared<solid_dynamics::TranslateSolidBody>(
solid_body_list_[body_index]->getImportedModel(), bp, start_time, end_time, translation));
}
}

void StructuralSimulation::initializeTranslateSolidBodyPart()
{
translation_solid_body_part_ = {};
for (size_t i = 0; i < translation_solid_body_part_tuple_.size(); i++)
{
int body_index = get<0>(translation_solid_body_part_tuple_[i]);
Real start_time = get<1>(translation_solid_body_part_tuple_[i]);
Real end_time = get<2>(translation_solid_body_part_tuple_[i]);
Vecd translation = get<3>(translation_solid_body_part_tuple_[i]);
BoundingBox bbox = get<4>(translation_solid_body_part_tuple_[i]);
BodyPartByParticleTriMesh* bp = new BodyPartByParticleTriMesh(
solid_body_list_[body_index]->getImportedModel(), imported_stl_list_[body_index], &body_mesh_list_[body_index]);

translation_solid_body_.emplace_back(make_shared<solid_dynamics::TranslateSolidBody>(solid_body_list_[body_index]->getImportedModel(), bp, start_time, end_time, translation));
translation_solid_body_part_.emplace_back(make_shared<solid_dynamics::TranslateSolidBodyPart>(
solid_body_list_[body_index]->getImportedModel(), bp, start_time, end_time, translation, bbox));
}
}

Expand Down Expand Up @@ -547,6 +568,14 @@ void StructuralSimulation::executeTranslateSolidBody(Real dt)
}
}

void StructuralSimulation::executeTranslateSolidBodyPart(Real dt)
{
for (size_t i = 0; i < translation_solid_body_part_.size(); i++)
{
translation_solid_body_part_[i]->parallel_exec(dt);
}
}

void StructuralSimulation::executeDamping(Real dt)
{
for (size_t i = 0; i < solid_body_list_.size(); i++)
Expand Down Expand Up @@ -603,9 +632,12 @@ void StructuralSimulation::runSimulationStep(int &ite, Real &dt, Real &integrati
if (ite % 100 == 0) cout << "N=" << ite << " Time: " << GlobalStaticVariables::physical_time_ << " dt: " << dt << "\n";

/** ACTIVE BOUNDARY CONDITIONS */
// force (acceleration) based
executeinitializeATimeStep();
executeAccelerationForBodyPartInBoundingBox();
executeSpringDamperConstraintParticleWise();
// velocity based
executeTranslateSolidBodyPart(dt);

/** CONTACT */
executeContactDensitySummation();
Expand All @@ -617,14 +649,13 @@ void StructuralSimulation::runSimulationStep(int &ite, Real &dt, Real &integrati
executeConstrainSolidBodyRegion();
executePositionSolidBody(dt);
executePositionScaleSolidBody(dt);
executeTranslateSolidBody(dt);
executeTranslateSolidBody(dt); // only one time

executeDamping(dt);

executeConstrainSolidBodyRegion();
executePositionSolidBody(dt);
executePositionScaleSolidBody(dt);
executeTranslateSolidBody(dt);

executeStressRelaxationSecondHalf(dt);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ using SpringDamperTuple = tuple<int, Vec3d, Real>;
using PositionSolidBodyTuple = tuple<int, Real, Real, Vec3d>;
using PositionScaleSolidBodyTuple = tuple<int, Real, Real, Real>;
using TranslateSolidBodyTuple = tuple<int, Real, Real, Vec3d>;
using TranslateSolidBodyPartTuple = tuple<int, Real, Real, Vec3d, BoundingBox>;

class BodyPartByParticleTriMesh : public BodyPartByParticle
{
Expand Down Expand Up @@ -89,6 +90,7 @@ class StructuralSimulationInput
Real scale_system_boundaries_;
// particle relaxation
vector<bool> particle_relaxation_list_;
bool write_particle_relaxation_data_;
// boundary conditions
vector<GravityPair> non_zero_gravity_;
vector<AccelTuple> acceleration_bounding_box_tuple_;
Expand All @@ -97,6 +99,7 @@ class StructuralSimulationInput
vector<PositionSolidBodyTuple> position_solid_body_tuple_;
vector<PositionScaleSolidBodyTuple> position_scale_solid_body_tuple_;
vector<TranslateSolidBodyTuple> translation_solid_body_tuple_;
vector<TranslateSolidBodyPartTuple> translation_solid_body_part_tuple_;

StructuralSimulationInput(
string relative_input_path,
Expand Down Expand Up @@ -124,6 +127,7 @@ class StructuralSimulation
vector<array<int, 2>> contacting_body_pairs_list_;
vector<pair<array<int, 2>, array<Real, 2>>> time_dep_contacting_body_pairs_list_; //optional: time dependent contact
vector<bool> particle_relaxation_list_; // optional: particle relaxation
bool write_particle_relaxation_data_;

// internal members
Real system_resolution_;
Expand Down Expand Up @@ -160,6 +164,9 @@ class StructuralSimulation
// for TranslateSolidBody
vector<shared_ptr<solid_dynamics::TranslateSolidBody>> translation_solid_body_;
vector<TranslateSolidBodyTuple> translation_solid_body_tuple_;
// for TranslateSolidBodyPart
vector<shared_ptr<solid_dynamics::TranslateSolidBodyPart>> translation_solid_body_part_;
vector<TranslateSolidBodyPartTuple> translation_solid_body_part_tuple_;

// for constructor, the order is important
void scaleTranslationAndResolution();
Expand All @@ -179,6 +186,7 @@ class StructuralSimulation
void initializePositionSolidBody();
void initializePositionScaleSolidBody();
void initializeTranslateSolidBody();
void initializeTranslateSolidBodyPart();

// for runSimulation, the order is important
void executeCorrectConfiguration();
Expand All @@ -192,6 +200,7 @@ class StructuralSimulation
void executePositionSolidBody(Real dt);
void executePositionScaleSolidBody(Real dt);
void executeTranslateSolidBody(Real dt);
void executeTranslateSolidBodyPart(Real dt);
void executeDamping(Real dt);
void executeStressRelaxationSecondHalf(Real dt);
void executeUpdateCellLinkedList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,45 @@ class TestStructuralSimulation : StructuralSimulation
TestStructuralSimulation(StructuralSimulationInput& input) : StructuralSimulation(input){};
void TestRunSimulation(Real end_time){ runSimulation(end_time); };
// input members
string Get_relative_input_path_(){ return relative_input_path_; };
vector<string> Get_imported_stl_list_(){ return imported_stl_list_; };
Real Get_scale_stl_(){ return scale_stl_; };
vector<Vec3d> Get_translation_list_(){ return translation_list_; };
Real Get_system_resolution_(){ return system_resolution_; };
vector<Real> Get_resolution_list_(){ return resolution_list_; };
vector<LinearElasticSolid> Get_material_model_list_(){ return material_model_list_; };
Real Get_physical_viscosity_(){ return physical_viscosity_; };
string get_relative_input_path_(){ return relative_input_path_; };
vector<string> get_imported_stl_list_(){ return imported_stl_list_; };
Real get_scale_stl_(){ return scale_stl_; };
vector<Vec3d> get_translation_list_(){ return translation_list_; };
Real get_system_resolution_(){ return system_resolution_; };
vector<Real> get_resolution_list_(){ return resolution_list_; };
vector<LinearElasticSolid> get_material_model_list_(){ return material_model_list_; };
Real get_physical_viscosity_(){ return physical_viscosity_; };
// internal members
SPHSystem Get_system_(){ return system_; };
Real Get_scale_system_boundaries_(){ return scale_system_boundaries_; };
In_Output Get_in_output_(){ return in_output_; };
SPHSystem get_system_(){ return system_; };
Real get_scale_system_boundaries_(){ return scale_system_boundaries_; };
In_Output get_in_output_(){ return in_output_; };
// other
vector<TriangleMeshShape> Get_body_mesh_list_(){ return body_mesh_list_; };
vector<shared_ptr<SolidBodyForSimulation>> Get_solid_body_list_(){ return solid_body_list_; };
vector<array<int, 2>> Get_contacting_body_pairs_list_(){ return contacting_body_pairs_list_; };
vector<pair<array<int, 2>, array<Real, 2>>> Get_time_dep_contacting_body_pairs_list_(){ return time_dep_contacting_body_pairs_list_; };
vector<shared_ptr<SolidBodyRelationContact>> Get_contact_list_(){ return contact_list_; };
vector<shared_ptr<solid_dynamics::ContactDensitySummation>> Get_contact_density_list_(){ return contact_density_list_; };
vector<shared_ptr<solid_dynamics::ContactForce>> Get_contact_force_list_(){ return contact_force_list_; };
vector<TriangleMeshShape> get_body_mesh_list_(){ return body_mesh_list_; };
vector<shared_ptr<SolidBodyForSimulation>> get_solid_body_list_(){ return solid_body_list_; };
vector<array<int, 2>> get_contacting_body_pairs_list_(){ return contacting_body_pairs_list_; };
vector<pair<array<int, 2>, array<Real, 2>>> get_time_dep_contacting_body_pairs_list_(){ return time_dep_contacting_body_pairs_list_; };
vector<shared_ptr<SolidBodyRelationContact>> get_contact_list_(){ return contact_list_; };
vector<shared_ptr<solid_dynamics::ContactDensitySummation>> get_contact_density_list_(){ return contact_density_list_; };
vector<shared_ptr<solid_dynamics::ContactForce>> get_contact_force_list_(){ return contact_force_list_; };
// for initializeATimeStep
vector<shared_ptr<TimeStepInitialization>> Get_initialize_gravity_(){ return initialize_gravity_; };
vector<GravityPair> Get_non_zero_gravity_(){ return non_zero_gravity_; };
vector<shared_ptr<TimeStepInitialization>> get_initialize_gravity_(){ return initialize_gravity_; };
vector<GravityPair> get_non_zero_gravity_(){ return non_zero_gravity_; };
// for AccelerationForBodyPartInBoundingBox
vector<shared_ptr<solid_dynamics::AccelerationForBodyPartInBoundingBox>> Get_acceleration_bounding_box_(){ return acceleration_bounding_box_; };
vector<AccelTuple> Get_acceleration_bounding_box_tuple_(){ return acceleration_bounding_box_tuple_; };
vector<shared_ptr<solid_dynamics::AccelerationForBodyPartInBoundingBox>> get_acceleration_bounding_box_(){ return acceleration_bounding_box_; };
vector<AccelTuple> get_acceleration_bounding_box_tuple_(){ return acceleration_bounding_box_tuple_; };
// for SpringDamperConstraintParticleWise
vector<shared_ptr<solid_dynamics::SpringDamperConstraintParticleWise>> Get_spring_damper_constraint_(){ return spring_damper_constraint_; };
vector<SpringDamperTuple> Get_spring_damper_tuple_(){ return spring_damper_tuple_; };
vector<shared_ptr<solid_dynamics::SpringDamperConstraintParticleWise>> get_spring_damper_constraint_(){ return spring_damper_constraint_; };
vector<SpringDamperTuple> get_spring_damper_tuple_(){ return spring_damper_tuple_; };
// for ConstrainSolidBodyRegion
vector<shared_ptr<solid_dynamics::ConstrainSolidBodyRegion>> Get_fixed_constraint_(){ return fixed_constraint_; };
vector<int> Get_body_indeces_fixed_constraint_(){ return body_indeces_fixed_constraint_; };
vector<shared_ptr<solid_dynamics::ConstrainSolidBodyRegion>> get_fixed_constraint_(){ return fixed_constraint_; };
vector<int> get_body_indeces_fixed_constraint_(){ return body_indeces_fixed_constraint_; };
// for PositionSolidBody
vector<shared_ptr<solid_dynamics::PositionSolidBody>> Get_position_solid_body_(){ return position_solid_body_; };
vector<PositionSolidBodyTuple> Get_position_solid_body_tuple_(){ return position_solid_body_tuple_; };
vector<shared_ptr<solid_dynamics::PositionSolidBody>> get_position_solid_body_(){ return position_solid_body_; };
vector<PositionSolidBodyTuple> get_position_solid_body_tuple_(){ return position_solid_body_tuple_; };
// for PositionScaleSolidBody
vector<shared_ptr<solid_dynamics::PositionScaleSolidBody>> Get_position_scale_solid_body_(){ return position_scale_solid_body_; };
vector<PositionScaleSolidBodyTuple> Get_position_scale_solid_body_tuple_(){ return position_scale_solid_body_tuple_; };
vector<shared_ptr<solid_dynamics::PositionScaleSolidBody>> get_position_scale_solid_body_(){ return position_scale_solid_body_; };
vector<PositionScaleSolidBodyTuple> get_position_scale_solid_body_tuple_(){ return position_scale_solid_body_tuple_; };
// for TranslateSolidBody
vector<shared_ptr<solid_dynamics::TranslateSolidBody>> Get_translation_solid_body_(){ return translation_solid_body_; };
vector<TranslateSolidBodyTuple> Get_translation_solid_body_tuple_(){ return translation_solid_body_tuple_; };
vector<shared_ptr<solid_dynamics::TranslateSolidBody>> get_translation_solid_body_(){ return translation_solid_body_; };
vector<TranslateSolidBodyTuple> get_translation_solid_body_tuple_(){ return translation_solid_body_tuple_; };
};
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#define PARTICLE_GENERATOR_NETWORK_H


#include "sph_data_conainers.h"
#include "sph_data_containers.h"
#include "base_particle_generator.h"
#include "generative_structures.h"

Expand Down
2 changes: 1 addition & 1 deletion SPHINXsys/src/shared/bodies/base_body.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#define BASE_BODY_H

#include "base_data_package.h"
#include "sph_data_conainers.h"
#include "sph_data_containers.h"
#include "particle_adaptation.h"
#include "all_particle_generators.h"
#include "particle_sorting.h"
Expand Down
24 changes: 24 additions & 0 deletions SPHINXsys/src/shared/common/sph_data_containers.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* @file sph_data_containers.cpp
* @brief Global functions related to sph_data_containers.h
* @author Bence Rochlitz, Luhui Han, Chi ZHang and Xiangyu Hu
*/

#include "sph_data_containers.h"

namespace SPH {
//=================================================================================================//
bool checkIfPointInBoundingBox(Vec3d point, BoundingBox& bbox)
{
return point[0] >= bbox.first[0] && point[0] <= bbox.second[0] &&
point[1] >= bbox.first[1] && point[1] <= bbox.second[1] &&
point[2] >= bbox.first[2] && point[2] <= bbox.second[2];
}
//=================================================================================================//
bool checkIfPointInBoundingBox(Vec2d point, BoundingBox& bbox)
{
return point[0] >= bbox.first[0] && point[0] <= bbox.second[0] &&
point[1] >= bbox.first[1] && point[1] <= bbox.second[1];
}
//=================================================================================================//
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define SPH_DATA_CONTAINERS_H

#include "base_data_package.h"
#include "base_data_type.h"

namespace SPH {
/**
Expand All @@ -24,6 +25,10 @@ namespace SPH {

/** Bounding box for system, body, body part and shape, first: lower bound, second: upper bound. */
typedef std::pair<Vecd, Vecd> BoundingBox;
/** Check if a point is inside the bounding box */
bool checkIfPointInBoundingBox(Vec3d point, BoundingBox& bbox);
bool checkIfPointInBoundingBox(Vec2d point, BoundingBox& bbox);

/** Generalized particle data type */
typedef std::tuple<StdVec<StdLargeVec<Real>*>, StdVec<StdLargeVec<Vecd>*>, StdVec<StdLargeVec<Matd>*>,
StdVec<StdLargeVec<int>*>> ParticleData;
Expand Down
2 changes: 1 addition & 1 deletion SPHINXsys/src/shared/geometries/base_geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

#include "base_particles.h"
#include "base_data_package.h"
#include "sph_data_conainers.h"
#include "sph_data_containers.h"

#include <string>

Expand Down
Loading

0 comments on commit 66343ad

Please sign in to comment.