Skip to content

Commit b13b302

Browse files
authored
Merge pull request #941 from Xiangyu-Hu/xiangyu/bonuding_box_generalization
Xiangyu/bonuding box generalization
2 parents 9802180 + 6a09385 commit b13b302

File tree

210 files changed

+442
-431
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

210 files changed

+442
-431
lines changed

modules/opencascade/opencascade/surface_shape.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Vecd SurfaceShape::findClosestPoint(const Vecd &input_pnt)
2626

2727
////=================================================================================================//
2828
bool SurfaceShape::checkContain(const Vecd &pnt, bool BOUNDARY_INCLUDED) { return 0; }
29-
BoundingBox SurfaceShape::findBounds() { return BoundingBox(); }
29+
BoundingBoxd SurfaceShape::findBounds() { return BoundingBoxd(); }
3030
//=================================================================================================//
3131

3232
Vecd SurfaceShape::getCartesianPoint(Standard_Real u, Standard_Real v)

modules/opencascade/opencascade/surface_shape.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class SurfaceShape : public Shape
4949
Handle_Geom_Surface surface_;
5050

5151
protected:
52-
virtual BoundingBox findBounds() override;
52+
virtual BoundingBoxd findBounds() override;
5353
};
5454

5555
class SurfaceShapeSTEP : public SurfaceShape

modules/opencascade/tests/test_3d_aortic_valve/aortic_valve.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Vec3d domain_upper_bound(15.0, 15.0, 26.0);
2828
//----------------------------------------------------------------------
2929
// Domain bounds of the system.
3030
//----------------------------------------------------------------------
31-
BoundingBox system_domain_bounds(domain_lower_bound, domain_upper_bound);
31+
BoundingBoxd system_domain_bounds(domain_lower_bound, domain_upper_bound);
3232

3333
namespace SPH
3434
{

modules/structural_simulation/structural_simulation_class.cpp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ BodyPartFromMesh::BodyPartFromMesh(SPHBody &body, SharedPtr<TriangleMeshShape> t
1616
: BodyRegionByParticle(body, triangle_mesh_shape_ptr)
1717
{
1818
// set the body domain bounds because it is not set by default
19-
BoundingBox bounds = triangle_mesh_shape_ptr->getBounds();
19+
BoundingBoxd bounds = triangle_mesh_shape_ptr->getBounds();
2020
setBodyPartBounds(bounds);
2121
}
2222

@@ -46,18 +46,18 @@ SolidBodyForSimulation::SolidBodyForSimulation(
4646
std::cout << " normal initialization done" << std::endl;
4747
}
4848

49-
BoundingBox expandBoundingBox(const BoundingBox &original, const BoundingBox &additional)
49+
BoundingBoxd expandBoundingBox(const BoundingBoxd &original, const BoundingBoxd &additional)
5050
{
51-
BoundingBox expanded = original;
52-
for (int i = 0; i < expanded.first_.size(); i++)
51+
BoundingBoxd expanded = original;
52+
for (int i = 0; i < expanded.lower_.size(); i++)
5353
{
54-
if (additional.first_[i] < expanded.first_[i])
54+
if (additional.lower_[i] < expanded.lower_[i])
5555
{
56-
expanded.first_[i] = additional.first_[i];
56+
expanded.lower_[i] = additional.lower_[i];
5757
}
58-
if (additional.second_[i] > expanded.second_[i])
58+
if (additional.upper_[i] > expanded.upper_[i])
5959
{
60-
expanded.second_[i] = additional.second_[i];
60+
expanded.upper_[i] = additional.upper_[i];
6161
}
6262
}
6363
return expanded;
@@ -108,7 +108,7 @@ void relaxParticlesSingleResolution(bool write_particle_relaxation_data,
108108
std::tuple<Vecd *, Real *> generateAndRelaxParticlesFromMesh(
109109
SharedPtr<TriangleMeshShape> triangle_mesh_shape, Real resolution, bool particle_relaxation, bool write_particle_relaxation_data)
110110
{
111-
BoundingBox bb = triangle_mesh_shape->getBounds();
111+
BoundingBoxd bb = triangle_mesh_shape->getBounds();
112112
SPHSystem system(bb, resolution);
113113
SolidBody model(system, triangle_mesh_shape);
114114
model.defineBodyLevelSetShape()->cleanLevelSet();
@@ -197,7 +197,7 @@ StructuralSimulation::StructuralSimulation(const StructuralSimulationInput &inpu
197197
particle_relaxation_list_(input.particle_relaxation_list_),
198198
write_particle_relaxation_data_(input.write_particle_relaxation_data_),
199199
system_resolution_(0.0),
200-
system_(SPHSystem(BoundingBox(Vec3d::Zero(), Vec3d::Zero()), system_resolution_)),
200+
system_(SPHSystem(BoundingBoxd(Vec3d::Zero(), Vec3d::Zero()), system_resolution_)),
201201
scale_system_boundaries_(input.scale_system_boundaries_),
202202
physical_time_(*system_.getSystemVariableDataByName<Real>("PhysicalTime")),
203203

@@ -284,17 +284,17 @@ void StructuralSimulation::calculateSystemBoundaries()
284284
// calculate system bounds from all bodies
285285
for (size_t i = 0; i < body_mesh_list_.size(); i++)
286286
{
287-
BoundingBox additional = body_mesh_list_[i]->getBounds();
287+
BoundingBoxd additional = body_mesh_list_[i]->getBounds();
288288
system_.setSystemDomainBounds(expandBoundingBox(system_.getSystemDomainBounds(), additional));
289289
}
290290
// scale the system bounds around the center point
291-
Vecd center_point = (system_.getSystemDomainBounds().first_ + system_.getSystemDomainBounds().second_) * 0.5;
291+
Vecd center_point = (system_.getSystemDomainBounds().lower_ + system_.getSystemDomainBounds().upper_) * 0.5;
292292

293-
Vecd distance_first = system_.getSystemDomainBounds().first_ - center_point;
294-
Vecd distance_second = system_.getSystemDomainBounds().second_ - center_point;
293+
Vecd distance_first = system_.getSystemDomainBounds().lower_ - center_point;
294+
Vecd distance_second = system_.getSystemDomainBounds().upper_ - center_point;
295295

296-
system_.getSystemDomainBounds().first_ = center_point + distance_first * scale_system_boundaries_;
297-
system_.getSystemDomainBounds().second_ = center_point + distance_second * scale_system_boundaries_;
296+
system_.getSystemDomainBounds().lower_ = center_point + distance_first * scale_system_boundaries_;
297+
system_.getSystemDomainBounds().upper_ = center_point + distance_second * scale_system_boundaries_;
298298
}
299299

300300
void StructuralSimulation::createBodyMeshList()
@@ -430,17 +430,17 @@ void StructuralSimulation::initializeForceInBodyRegion()
430430
for (size_t i = 0; i < force_in_body_region_tuple_.size(); i++)
431431
{
432432
int body_index = std::get<0>(force_in_body_region_tuple_[i]);
433-
BoundingBox bbox = std::get<1>(force_in_body_region_tuple_[i]);
433+
BoundingBoxd bbox = std::get<1>(force_in_body_region_tuple_[i]);
434434
Vec3d force = std::get<2>(force_in_body_region_tuple_[i]);
435435
Real end_time = std::get<3>(force_in_body_region_tuple_[i]);
436436

437437
// get the length of each side to create the box
438-
Real x_side = bbox.second_[0] - bbox.first_[0];
439-
Real y_side = bbox.second_[1] - bbox.first_[1];
440-
Real z_side = bbox.second_[2] - bbox.first_[2];
438+
Real x_side = bbox.upper_[0] - bbox.lower_[0];
439+
Real y_side = bbox.upper_[1] - bbox.lower_[1];
440+
Real z_side = bbox.upper_[2] - bbox.lower_[2];
441441
Vec3d halfsize_bbox(0.5 * x_side, 0.5 * y_side, 0.5 * z_side);
442442
// get the center point for translation from the origin
443-
Vec3d center = (bbox.second_ + bbox.first_) * 0.5;
443+
Vec3d center = (bbox.upper_ + bbox.lower_) * 0.5;
444444
// SimTK geometric modeling resolution
445445
int resolution(20);
446446
// create the triangle mesh of the box
@@ -510,15 +510,15 @@ void StructuralSimulation::initializeConstrainSolidBodyRegion()
510510
for (size_t i = 0; i < body_indices_fixed_constraint_region_.size(); i++)
511511
{
512512
int body_index = body_indices_fixed_constraint_region_[i].first;
513-
BoundingBox bbox = body_indices_fixed_constraint_region_[i].second;
513+
BoundingBoxd bbox = body_indices_fixed_constraint_region_[i].second;
514514

515515
// get the length of each side to create the box
516-
Real x_side = bbox.second_[0] - bbox.first_[0];
517-
Real y_side = bbox.second_[1] - bbox.first_[1];
518-
Real z_side = bbox.second_[2] - bbox.first_[2];
516+
Real x_side = bbox.upper_[0] - bbox.lower_[0];
517+
Real y_side = bbox.upper_[1] - bbox.lower_[1];
518+
Real z_side = bbox.upper_[2] - bbox.lower_[2];
519519
Vec3d halfsize_bbox(0.5 * x_side, 0.5 * y_side, 0.5 * z_side);
520520
// get the center point for translation from the origin
521-
Vec3d center = (bbox.second_ + bbox.first_) * 0.5;
521+
Vec3d center = (bbox.upper_ + bbox.lower_) * 0.5;
522522
// SimTK geometric modeling resolution
523523
int resolution(20);
524524
// create the triangle mesh of the box

modules/structural_simulation/structural_simulation_class.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
using namespace SPH;
3838

3939
using GravityPair = std::pair<int, Vec3d>;
40-
using AccelTuple = std::tuple<int, BoundingBox, Vec3d>;
41-
using ForceTuple = std::tuple<int, BoundingBox, Vec3d, Real>;
40+
using AccelTuple = std::tuple<int, BoundingBoxd, Vec3d>;
41+
using ForceTuple = std::tuple<int, BoundingBoxd, Vec3d, Real>;
4242
using PressureTuple = std::tuple<int, SharedPtr<TriangleMeshShape>, Vec3d, StdVec<std::array<Real, 2>>>;
4343
using SpringDamperTuple = std::tuple<int, Vec3d, Real>;
4444
/**
@@ -51,11 +51,11 @@ using SpringDamperTuple = std::tuple<int, Vec3d, Real>;
5151
* Real: damping coefficient
5252
*/
5353
using SurfaceSpringTuple = std::tuple<int, SharedPtr<TriangleMeshShape>, bool, Vec3d, Real, Real>;
54-
using ConstrainedRegionPair = std::pair<int, BoundingBox>;
54+
using ConstrainedRegionPair = std::pair<int, BoundingBoxd>;
5555
using PositionSolidBodyTuple = std::tuple<int, Real, Real, Vec3d>;
5656
using PositionScaleSolidBodyTuple = std::tuple<int, Real, Real, Real>;
5757
using TranslateSolidBodyTuple = std::tuple<int, Real, Real, Vec3d>;
58-
using TranslateSolidBodyPartTuple = std::tuple<int, Real, Real, Vec3d, BoundingBox>;
58+
using TranslateSolidBodyPartTuple = std::tuple<int, Real, Real, Vec3d, BoundingBoxd>;
5959

6060
#ifdef __EMSCRIPTEN__
6161
struct StlData
@@ -114,7 +114,7 @@ class SolidBodyForSimulation
114114
DampingWithRandomChoice<InteractionSplit<DampingPairwiseInner<Vec3d, FixedDampingRate>>> *getDampingWithRandomChoice() { return &damping_random_; };
115115
};
116116

117-
BoundingBox expandBoundingBox(const BoundingBox &original, const BoundingBox &additional);
117+
BoundingBoxd expandBoundingBox(const BoundingBoxd &original, const BoundingBoxd &additional);
118118

119119
void relaxParticlesSingleResolution(bool write_particles_to_file,
120120
SolidBodyFromMesh &solid_body_from_mesh,

src/for_2D_build/common/data_type.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ using MatTend = Mat3d; // matricized symmetric 2x2x2x2 tensor
4343
using VecMatGrad = VecMatGrad2d; // gradient of vectorized symmetric 2x2 matrix
4444
using AngularVecd = Real;
4545
using Rotation = Rotation2d;
46-
using BoundingBox = BaseBoundingBox<Vec2d>;
46+
using BoundingBoxd = BoundingBox<Real, 2>;
4747
using Transform = BaseTransform<Rotation2d, Vec2d>;
4848

4949
/** only works for smoothing length ratio less or equal than 1.3*/

src/for_2D_build/geometries/multi_polygon_shape.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ Vecd MultiPolygon::findClosestPoint(const Vecd &probe_point)
250250
return p_find;
251251
}
252252
//=================================================================================================//
253-
BoundingBox MultiPolygon::findBounds()
253+
BoundingBoxd MultiPolygon::findBounds()
254254
{
255255
Vecd lower_bound = Vecd::Zero();
256256
Vecd upper_bound = Vecd::Zero();
@@ -259,7 +259,7 @@ BoundingBox MultiPolygon::findBounds()
259259
lower_bound[1] = bg::return_envelope<box>(multi_poly_).min_corner().get<1>();
260260
upper_bound[0] = bg::return_envelope<box>(multi_poly_).max_corner().get<0>();
261261
upper_bound[1] = bg::return_envelope<box>(multi_poly_).max_corner().get<1>();
262-
return BoundingBox(lower_bound, upper_bound);
262+
return BoundingBoxd(lower_bound, upper_bound);
263263
}
264264
//=================================================================================================//
265265
bool MultiPolygonShape::isValid()
@@ -277,7 +277,7 @@ Vecd MultiPolygonShape::findClosestPoint(const Vecd &probe_point)
277277
return multi_polygon_.findClosestPoint(probe_point);
278278
}
279279
//=================================================================================================//
280-
BoundingBox MultiPolygonShape::findBounds()
280+
BoundingBoxd MultiPolygonShape::findBounds()
281281
{
282282
return multi_polygon_.findBounds();
283283
}

src/for_2D_build/geometries/multi_polygon_shape.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class MultiPolygon
8585
explicit MultiPolygon(const Vecd &center, Real radius, int resolution);
8686
boost_multi_poly &getBoostMultiPoly() { return multi_poly_; };
8787

88-
BoundingBox findBounds();
88+
BoundingBoxd findBounds();
8989
bool checkContain(const Vecd &pnt, bool BOUNDARY_INCLUDED = true);
9090
Vecd findClosestPoint(const Vecd &probe_point);
9191

@@ -120,7 +120,7 @@ class MultiPolygonShape : public Shape
120120
virtual bool isValid() override;
121121
virtual bool checkContain(const Vecd &probe_point, bool BOUNDARY_INCLUDED = true) override;
122122
virtual Vecd findClosestPoint(const Vecd &probe_point) override;
123-
virtual BoundingBox findBounds() override;
123+
virtual BoundingBoxd findBounds() override;
124124

125125
protected:
126126
MultiPolygon multi_polygon_;

src/for_2D_build/meshes/cell_linked_list_2d.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ namespace SPH
66
{
77
//=================================================================================================//
88
void BaseCellLinkedList::tagBoundingCellsByMesh(Mesh &mesh, StdVec<CellLists> &cell_data_lists,
9-
const BoundingBox &bounding_bounds, int axis)
9+
const BoundingBoxd &bounding_bounds, int axis)
1010
{
1111
int second_axis = NextAxis(axis);
12-
Array2i body_lower_bound_cell_ = mesh.CellIndexFromPosition(bounding_bounds.first_);
13-
Array2i body_upper_bound_cell_ = mesh.CellIndexFromPosition(bounding_bounds.second_);
12+
Array2i body_lower_bound_cell_ = mesh.CellIndexFromPosition(bounding_bounds.lower_);
13+
Array2i body_upper_bound_cell_ = mesh.CellIndexFromPosition(bounding_bounds.upper_);
1414
Array2i all_cells = mesh.AllCells();
1515
// lower bound cells
1616
for (int j = SMAX(body_lower_bound_cell_[second_axis] - 1, 0);

src/for_3D_build/common/data_type.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ using MatTend = Mat6d; // matricized symmetric 3x3x3x3 tensor
4242
using VecMatGrad = VecMatGrad3d; // gradient of vectorized symmetric 3x3 matrix
4343
using AngularVecd = Vec3d;
4444
using Rotation = Rotation3d;
45-
using BoundingBox = BaseBoundingBox<Vec3d>;
45+
using BoundingBoxd = BoundingBox<Real, 3>;
4646
using Transform = BaseTransform<Rotation3d, Vec3d>;
4747

4848
/** only works for smoothing length ratio less or equal than 1.3*/

0 commit comments

Comments
 (0)