$extrastylesheet
elem_cutter.h
Go to the documentation of this file.
00001 // The libMesh Finite Element Library.
00002 // Copyright (C) 2002-2013 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
00003 
00004 // This library is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public
00006 // License as published by the Free Software Foundation; either
00007 // version 2.1 of the License, or (at your option) any later version.
00008 
00009 // This library is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // Lesser General Public License for more details.
00013 
00014 // You should have received a copy of the GNU Lesser General Public
00015 // License along with this library; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 
00018 
00019 
00020 #ifndef LIBMESH_ELEM_CUTTER_H
00021 #define LIBMESH_ELEM_CUTTER_H
00022 
00023 #include "libmesh/libmesh_config.h"
00024 
00025 #if defined(LIBMESH_HAVE_TRIANGLE) && defined(LIBMESH_HAVE_TETGEN)
00026 
00027 // Local includes
00028 #include "libmesh/libmesh_common.h"
00029 #include "libmesh/point.h"
00030 #include "libmesh/auto_ptr.h"
00031 #include "libmesh/parallel.h"
00032 
00033 // C++ includes
00034 #include <vector>
00035 
00036 
00037 
00038 namespace libMesh
00039 {
00040 
00041 // Forward declarations
00042 class Elem;
00043 class SerialMesh;
00044 class TriangleInterface;
00045 class TetGenMeshInterface;
00046 
00056 // ------------------------------------------------------------
00057 // ElemCutter class definition
00058 class ElemCutter
00059 {
00060 public:
00061 
00066   ElemCutter();
00067 
00071   ~ElemCutter();
00072 
00078   bool is_inside (const Elem &elem,
00079                   const std::vector<Real> &vertex_distance_func) const;
00080 
00086   bool is_outside (const Elem &elem,
00087                    const std::vector<Real> &vertex_distance_func) const;
00088 
00094   bool is_cut (const Elem &elem,
00095                const std::vector<Real> &vertex_distance_func) const;
00096 
00106   void operator()(const Elem &elem_in,
00107                   const std::vector<Real> &vertex_distance_func);
00108 
00114   const std::vector<Elem const*> & inside_elements () const
00115   { return _inside_elem; }
00116 
00122   const std::vector<Elem const*> & outside_elements() const
00123   { return _outside_elem; }
00124 
00125 protected:
00126 
00131   void find_intersection_points(const Elem &elem,
00132                                 const std::vector<Real> &vertex_distance_func);
00133 
00137   void cut_1D(const Elem &elem,
00138               const std::vector<Real> &vertex_distance_func);
00139 
00143   void cut_2D(const Elem &elem,
00144               const std::vector<Real> &vertex_distance_func);
00145 
00149   void cut_3D(const Elem &elem,
00150               const std::vector<Real> &vertex_distance_func);
00151 
00152   std::vector<Elem const*> _inside_elem;
00153   std::vector<Elem const*> _outside_elem;
00154 
00155   UniquePtr<SerialMesh> _inside_mesh_2D;
00156   UniquePtr<SerialMesh> _outside_mesh_2D;
00157   UniquePtr<SerialMesh> _inside_mesh_3D;
00158   UniquePtr<SerialMesh> _outside_mesh_3D;
00159 
00160   Parallel::Communicator _comm_self; // defaults to MPI_COMM_SELF
00161 
00162   UniquePtr<TriangleInterface>   _triangle_inside;
00163   UniquePtr<TriangleInterface>   _triangle_outside;
00164   UniquePtr<TetGenMeshInterface> _tetgen_inside;
00165   UniquePtr<TetGenMeshInterface> _tetgen_outside;
00166 
00167   std::vector<Point> _intersection_pts;
00168 };
00169 
00170 
00171 } // namespace libMesh
00172 
00173 #endif // LIBMESH_HAVE_TRIANGLE && LIBMESH_HAVE_TETGEN
00174 #endif // LIBMESH_ELEM_CUTTER_H