SPHinXsys  alpha version
complex_shape.h
Go to the documentation of this file.
1 /* -------------------------------------------------------------------------*
2  * SPHinXsys *
3  * --------------------------------------------------------------------------*
4  * SPHinXsys (pronunciation: s'finksis) is an acronym from Smoothed Particle *
5  * Hydrodynamics for industrial compleX systems. It provides C++ APIs for *
6  * physical accurate simulation and aims to model coupled industrial dynamic *
7  * systems including fluid, solid, multi-body dynamics and beyond with SPH *
8  * (smoothed particle hydrodynamics), a meshless computational method using *
9  * particle discretization. *
10  * *
11  * SPHinXsys is partially funded by German Research Foundation *
12  * (Deutsche Forschungsgemeinschaft) DFG HU1527/6-1, HU1527/10-1 *
13  * and HU1527/12-1. *
14  * *
15  * Portions copyright (c) 2017-2020 Technical University of Munich and *
16  * the authors' affiliations. *
17  * *
18  * Licensed under the Apache License, Version 2.0 (the "License"); you may *
19  * not use this file except in compliance with the License. You may obtain a *
20  * copy of the License at http://www.apache.org/licenses/LICENSE-2.0. *
21  * *
22  * --------------------------------------------------------------------------*/
31 #ifndef COMPLEX_SHAPE_H
32 #define COMPLEX_SHAPE_H
33 
34 #include "base_geometry.h"
35 
36 #include "geometric_shape.h"
37 #include "transform_shape.h"
38 #include <string>
39 
40 namespace SPH
41 {
42  class LevelSetShape;
43 
44  class ComplexShape : public BinaryShapes
45  {
46  public:
47  explicit ComplexShape(const std::string &shape_name) : BinaryShapes(shape_name){};
48  virtual ~ComplexShape(){};
49 
50  template <typename... ConstructorArgs>
51  LevelSetShape *defineLevelSetShape(SPHBody *sph_body, const std::string &shape_name, ConstructorArgs &&...args)
52  {
53  size_t index = getShapeIndexByName(shape_name);
54  LevelSetShape *level_set_shape = shapes_ptr_keeper_[index].createPtr<LevelSetShape>(
55  sph_body, *shapes_and_ops_[index].first, std::forward<ConstructorArgs>(args)...);
56  shapes_and_ops_[index].first = level_set_shape;
57  return level_set_shape;
58  };
59  };
60 
61  using DefaultShape = ComplexShape;
62 
68  class AlignedBoxShape : public TransformShape<GeometricShapeBox>
69  {
70  public:
72  template <typename... Args>
73  explicit AlignedBoxShape(const Transformd &transformd, Args &&...args)
74  : TransformShape<GeometricShapeBox>(transformd, std::forward<Args>(args)...){};
76  template <typename... Args>
77  explicit AlignedBoxShape(const Shape &shape, Args &&...args)
79  Transformd(0.5 * (shape.bounding_box_.second + shape.bounding_box_.first)),
80  0.5 * (shape.bounding_box_.second - shape.bounding_box_.first), std::forward<Args>(args)...){};
81 
82  Vecd HalfSize() { return halfsize_; }
83  bool checkInBounds(int axis, const Vecd &point);
84  bool checkUpperBound(int axis, const Vecd &point);
85  bool checkLowerBound(int axis, const Vecd &point);
86  bool checkNearUpperBound(int axis, const Vecd &point, Real threshold);
87  bool checkNearLowerBound(int axis, const Vecd &point, Real threshold);
88  Vecd getUpperPeriodic(int axis, const Vecd &point);
89  Vecd getLowerPeriodic(int axis, const Vecd &point);
90  };
91 }
92 
93 #endif // COMPLEX_SHAPE_H
AlignedBoxShape(const Shape &shape, Args &&...args)
Definition: complex_shape.h:77
Definition: geometric_shape.h:38
Base class for all volumetric geometries Note that checkContain and findClosest point are basic funct...
Definition: base_geometry.h:64
Definition: complex_shape.h:44
tranformation related class for geometries.
Used to describe a bounding box in which the plane vertical to axis direction is aligned to a planar ...
Definition: complex_shape.h:68
A shape using level set to define geometry.
Definition: level_set_shape.h:46
Coordinate transform in 2D Note that the rotation is around the frame (or local) origin.
Definition: base_data_type.h:453
Shape is the base class for all geometries.
A template shape in which coordinate transformation is applied before or/and after access the interfa...
Definition: transform_shape.h:21
a collections of shapes with binary operations This class so that it has ownership of all shapes by u...
Definition: base_geometry.h:101
SPHBody is a base body with basic data and functions. Its derived class can be a real fluid body...
Definition: base_body.h:61
AlignedBoxShape(const Transformd &transformd, Args &&...args)
Definition: complex_shape.h:73
Definition: solid_body_supplementary.cpp:9