MOAB: Mesh Oriented datABase  (version 5.4.0)
XYRectangle.hpp
Go to the documentation of this file.
00001 /* *****************************************************************
00002     MESQUITE -- The Mesh Quality Improvement Toolkit
00003 
00004     Copyright 2007 Sandia National Laboratories.  Developed at the
00005     University of Wisconsin--Madison under SNL contract number
00006     624796.  The U.S. Government and the University of Wisconsin
00007     retain certain rights to this software.
00008 
00009     This library is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU Lesser General Public
00011     License as published by the Free Software Foundation; either
00012     version 2.1 of the License, or (at your option) any later version.
00013 
00014     This library is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017     Lesser General Public License for more details.
00018 
00019     You should have received a copy of the GNU Lesser General Public License
00020     (lgpl.txt) along with this library; if not, write to the Free Software
00021     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 
00023     (2007) kraftche@cae.wisc.edu
00024 
00025   ***************************************************************** */
00026 
00027 /** \file XYRectangle.hpp
00028  *  \brief Define simple domain for 2D test problems
00029  *  \author Jason Kraftcheck
00030  */
00031 
00032 #ifndef MSQ_XY_RECTANGLE_HPP
00033 #define MSQ_XY_RECTANGLE_HPP
00034 
00035 #include "Mesquite.hpp"
00036 #include "MeshInterface.hpp"
00037 
00038 #include <map>
00039 
00040 namespace MBMesquite
00041 {
00042 
00043 /**\brief Simple 2D Domain for free-smooth testing
00044  *
00045  * Define a simple bounded rectangular domain in the XY-plane.
00046  * Mesh vertices are classified as one of the following:
00047  *  - 0 DoF : On a corner of the rectangle
00048  *  - 1 DoF : On an edge of the rectangle
00049  *  - 2 DoF : In the interior of the rectangle
00050  */
00051 class XYRectangle : public MBMesquite::MeshDomain
00052 {
00053   public:
00054     enum Plane
00055     {
00056         XY = 2,
00057         YZ = 0,
00058         ZX = 1
00059     };
00060 
00061     /**\brief Define rectangular domain
00062      *
00063      *\param w Width of rectangle (X-range)
00064      *\param h Height of rectangle (Y-range)
00065      *\param x Minimum X coordinate of rectangle
00066      *\param y Minimum Y coordinate of rectangle
00067      *\param z Minimum Z coordinate of rectangle
00068      *\param plane Which plane (default is XY).
00069      *
00070      * Create w x h rectangle with, if plane is XY: X range of [x, x+w] and
00071      * Y range of [y, y+h].
00072      */
00073     MESQUITE_EXPORT
00074     XYRectangle( double w, double h, double x = 0, double y = 0, double z = 0, Plane plane = XY );
00075 
00076     /**\brief Classify mesh vertices against domain
00077      *
00078      * Figure out which input mesh vertices like on corners
00079      * or edges of the domain.  Will fail if any vertex is outside
00080      * of the rectangle.
00081      */
00082     MESQUITE_EXPORT
00083     void setup( MBMesquite::Mesh* mesh, MBMesquite::MsqError& err );
00084 
00085     MESQUITE_EXPORT
00086     void snap_to( MBMesquite::Mesh::VertexHandle entity_handle, MBMesquite::Vector3D& coordinate ) const;
00087 
00088     MESQUITE_EXPORT
00089     void vertex_normal_at( MBMesquite::Mesh::VertexHandle entity_handle, MBMesquite::Vector3D& coordinate ) const;
00090 
00091     MESQUITE_EXPORT
00092     void element_normal_at( MBMesquite::Mesh::ElementHandle entity_handle, MBMesquite::Vector3D& coordinate ) const;
00093 
00094     MESQUITE_EXPORT
00095     void vertex_normal_at( const MBMesquite::Mesh::VertexHandle* handles,
00096                            MBMesquite::Vector3D coordinates[],
00097                            unsigned count,
00098                            MBMesquite::MsqError& err ) const;
00099 
00100     MESQUITE_EXPORT
00101     void closest_point( MBMesquite::Mesh::VertexHandle handle,
00102                         const MBMesquite::Vector3D& position,
00103                         MBMesquite::Vector3D& closest,
00104                         MBMesquite::Vector3D& normal,
00105                         MBMesquite::MsqError& err ) const;
00106 
00107     MESQUITE_EXPORT
00108     void domain_DoF( const MBMesquite::Mesh::VertexHandle* handle_array,
00109                      unsigned short* dof_array,
00110                      size_t num_handles,
00111                      MBMesquite::MsqError& err ) const;
00112 
00113   private:
00114     double minCoords[3], maxCoords[3];  //!< corner coords
00115     const int normalDir, widthDir, heightDir;
00116 
00117     //! Single constraint on a vertex (reduces degrees of freedom by 1)
00118     struct VertexConstraint
00119     {
00120         enum Constraint
00121         {
00122             XC = 0,
00123             YC = 1,
00124             ZC = 2
00125         };
00126         VertexConstraint( int a, double c ) : axis( (Constraint)a ), coord( c ) {}
00127         Constraint axis;
00128         double coord;
00129     };
00130 
00131     //! Map vertex handles to constraints
00132     typedef std::multimap< Mesh::VertexHandle, VertexConstraint > constraint_t;
00133     constraint_t mConstraints;
00134 };
00135 
00136 }  // namespace MBMesquite
00137 
00138 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines