Skip to content

Commit

Permalink
Merge pull request #631 from Xiangyu-Hu/fix/clarified_comment_on_comp…
Browse files Browse the repository at this point in the history
…lex_shape

clarify the limitation of using complex shape
  • Loading branch information
Lisu-lisa authored Jul 28, 2024
2 parents 6aca5d0 + 47932fd commit c1e062a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
13 changes: 6 additions & 7 deletions src/shared/geometries/base_geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
* *
* ------------------------------------------------------------------------- */
/**
* @file base_geometry.h
* @brief Define the base classes Shape, BinaryShape and Edge,
* which are the base classes for all geometries.
* @file base_geometry.h
* @brief Define the base classes Shape, BinaryShape and Edge,
* which are the base classes for all geometries.
* @author Chi Zhang, Yongchuan Yu and Xiangyu Hu
*/

Expand Down Expand Up @@ -92,11 +92,10 @@ class Shape
using SubShapeAndOp = std::pair<Shape *, ShapeBooleanOps>;
/**
* @class BinaryShapes
* @brief a collections of shapes with binary operations
* @brief A collections of shapes with binary operations.
* This class has ownership of all shapes by using a unique pointer vector.
* In this way, add or subtract a shape will call the shape's constructor other than
* passing the shape pointer.
* For now, partially overlapped the shapes are not allowed for binary operations.
*/
class BinaryShapes : public Shape
{
Expand All @@ -106,15 +105,15 @@ class BinaryShapes : public Shape
virtual ~BinaryShapes(){};

template <class SubShapeType, typename... Args>
void add(Args &&...args)
void add(Args &&... args)
{
Shape *sub_shape = sub_shape_ptrs_keeper_.createPtr<SubShapeType>(std::forward<Args>(args)...);
SubShapeAndOp sub_shape_and_op(sub_shape, ShapeBooleanOps::add);
sub_shapes_and_ops_.push_back(sub_shape_and_op);
};

template <class SubShapeType, typename... Args>
void subtract(Args &&...args)
void subtract(Args &&... args)
{
Shape *sub_shape = sub_shape_ptrs_keeper_.createPtr<SubShapeType>(std::forward<Args>(args)...);
SubShapeAndOp sub_shape_and_op(sub_shape, ShapeBooleanOps::sub);
Expand Down
23 changes: 16 additions & 7 deletions src/shared/geometries/complex_shape.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
* *
* ------------------------------------------------------------------------- */
/**
* @file complex_shape.h
* @brief Here, we define the a container of different type of shapes, which allow
* the boolean operation between the different type of shapes. The shapes
* can be defined previously and add to this complex shapes container.
* @file complex_shape.h
* @brief Here, we define the a container of different type of shapes, which allow
* the boolean operation between the different type of shapes. The shapes
* can be defined previously and add to this complex shapes container.
*/

#ifndef COMPLEX_SHAPE_H
Expand All @@ -39,6 +39,15 @@ namespace SPH
{
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.
* However, if only the contain function
* is used, for example generating particles using lattice generator,
* partially overlapped shapes are allowed.
**/
class ComplexShape : public BinaryShapes
{
public:
Expand All @@ -47,7 +56,7 @@ class ComplexShape : public BinaryShapes
virtual ~ComplexShape(){};

template <typename... Args>
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<LevelSetShape>(
Expand All @@ -71,12 +80,12 @@ class AlignedBoxShape : public TransformShape<GeometricShapeBox>
public:
/** construct directly */
template <typename... Args>
explicit AlignedBoxShape(int upper_bound_axis, const Transform &transform, Args &&...args)
explicit AlignedBoxShape(int upper_bound_axis, const Transform &transform, Args &&... args)
: TransformShape<GeometricShapeBox>(transform, std::forward<Args>(args)...),
alignment_axis_(upper_bound_axis){};
/** construct from a shape already has aligned boundaries */
template <typename... Args>
explicit AlignedBoxShape(int upper_bound_axis, const Shape &shape, Args &&...args)
explicit AlignedBoxShape(int upper_bound_axis, const Shape &shape, Args &&... args)
: TransformShape<GeometricShapeBox>(
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>(args)...),
Expand Down

0 comments on commit c1e062a

Please sign in to comment.