MOAB: Mesh Oriented datABase  (version 5.3.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, MBMesquite::Vector3D coordinates[],
00096                            unsigned count, MBMesquite::MsqError& err ) const;
00097 
00098     MESQUITE_EXPORT
00099     void closest_point( MBMesquite::Mesh::VertexHandle handle, const MBMesquite::Vector3D& position,
00100                         MBMesquite::Vector3D& closest, MBMesquite::Vector3D& normal, MBMesquite::MsqError& err ) const;
00101 
00102     MESQUITE_EXPORT
00103     void domain_DoF( const MBMesquite::Mesh::VertexHandle* handle_array, unsigned short* dof_array, size_t num_handles,
00104                      MBMesquite::MsqError& err ) const;
00105 
00106   private:
00107     double minCoords[3], maxCoords[3];  //!< corner coords
00108     const int normalDir, widthDir, heightDir;
00109 
00110     //! Single constraint on a vertex (reduces degrees of freedom by 1)
00111     struct VertexConstraint
00112     {
00113         enum Constraint
00114         {
00115             XC = 0,
00116             YC = 1,
00117             ZC = 2
00118         };
00119         VertexConstraint( int a, double c ) : axis( (Constraint)a ), coord( c ) {}
00120         Constraint axis;
00121         double coord;
00122     };
00123 
00124     //! Map vertex handles to constraints
00125     typedef std::multimap< Mesh::VertexHandle, VertexConstraint > constraint_t;
00126     constraint_t mConstraints;
00127 };
00128 
00129 }  // namespace MBMesquite
00130 
00131 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines