Line data Source code
1 : // The libMesh Finite Element Library. 2 : // Copyright (C) 2002-2025 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner 3 : 4 : // This library is free software; you can redistribute it and/or 5 : // modify it under the terms of the GNU Lesser General Public 6 : // License as published by the Free Software Foundation; either 7 : // version 2.1 of the License, or (at your option) any later version. 8 : 9 : // This library is distributed in the hope that it will be useful, 10 : // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 : // Lesser General Public License for more details. 13 : 14 : // You should have received a copy of the GNU Lesser General Public 15 : // License along with this library; if not, write to the Free Software 16 : // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 : 18 : 19 : 20 : #ifndef LIBMESH_SURFACE_H 21 : #define LIBMESH_SURFACE_H 22 : 23 : // Local includes 24 : #include "libmesh/point.h" 25 : 26 : namespace libMesh 27 : { 28 : 29 : /** 30 : * The base class for all "surface" related geometric objects. A 31 : * Surface is a two-dimensional object living in three-dimensional 32 : * space. Examples of Surfaces are planes, hollow spheres, hollow 33 : * cylinders, etc... This is a generic base class that describes the 34 : * useful functionality a surface will provide. Specific derived 35 : * classes actually implement the functionality, so this class has 36 : * pure virtual members. 37 : * 38 : * \author Benjamin S. Kirk 39 : * \date 2002 40 : * \brief Base class for Plane and Sphere classes. 41 : */ 42 : class Surface 43 : { 44 : public: 45 : 46 : /** 47 : * Constructor. Does nothing at the moment. 48 : */ 49 34 : Surface () = default; 50 : 51 : /** 52 : * Copy-constructor. 53 : */ 54 : Surface (const Surface &) = default; 55 : 56 : /** 57 : * Destructor. 58 : */ 59 34 : virtual ~Surface () = default; 60 : 61 : /** 62 : * \returns \p true if the point p is above the surface, 63 : * false otherwise. 64 : */ 65 : virtual bool above_surface (const Point & p) const = 0; 66 : 67 : /** 68 : * \returns \p true if the point p is below the surface, 69 : * false otherwise. 70 : */ 71 : virtual bool below_surface (const Point & p) const = 0; 72 : 73 : /** 74 : * \returns \p true if the point p is on the surface, 75 : * false otherwise. 76 : * 77 : * \note The definition of "on the surface" really means "very 78 : * close" to account for roundoff error. 79 : */ 80 : virtual bool on_surface (const Point & p) const = 0; 81 : 82 : /** 83 : * \returns The closest point on the surface to point p. 84 : */ 85 : virtual Point closest_point (const Point & p) const = 0; 86 : 87 : /** 88 : * \returns A unit vector normal to the surface at 89 : * point p. 90 : */ 91 : virtual Point unit_normal (const Point & p) const = 0; 92 : 93 : /** 94 : * \returns The \p Point \p world_coords in the 95 : * surface's coordinate system. \p world_coords 96 : * is in the world coordinate system. This method 97 : * is not purely virtual, because there may be surfaces 98 : * that do not have their own coordinate system. These 99 : * simply do not have to override this method. 100 : */ 101 0 : virtual Point surface_coords (const Point & world_coords) const { return world_coords; } 102 : 103 : /** 104 : * \returns The world (cartesian) coordinates for the 105 : * surface coordinates \p surf_coords. This method 106 : * is not purely virtual, because there may be surfaces 107 : * that do not have an own coordinate system. These 108 : * simply do not have to override this method. 109 : */ 110 0 : virtual Point world_coords (const Point & surf_coords) const { return surf_coords; } 111 : }; 112 : 113 : } // namespace libMesh 114 : 115 : #endif // LIBMESH_SURFACE_H