Branch data Line data Source code
1 : : /* *****************************************************************
2 : : MESQUITE -- The Mesh Quality Improvement Toolkit
3 : :
4 : : Copyright 2007 Sandia National Laboratories. Developed at the
5 : : University of Wisconsin--Madison under SNL contract number
6 : : 624796. The U.S. Government and the University of Wisconsin
7 : : retain certain rights to this software.
8 : :
9 : : This library is free software; you can redistribute it and/or
10 : : modify it under the terms of the GNU Lesser General Public
11 : : License as published by the Free Software Foundation; either
12 : : version 2.1 of the License, or (at your option) any later version.
13 : :
14 : : This library is distributed in the hope that it will be useful,
15 : : but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 : : Lesser General Public License for more details.
18 : :
19 : : You should have received a copy of the GNU Lesser General Public License
20 : : (lgpl.txt) along with this library; if not, write to the Free Software
21 : : Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 : :
23 : : (2007) [email protected]
24 : :
25 : : ***************************************************************** */
26 : :
27 : : /** \file XYRectangle.hpp
28 : : * \brief Define simple domain for 2D test problems
29 : : * \author Jason Kraftcheck
30 : : */
31 : :
32 : : #ifndef MSQ_XY_RECTANGLE_HPP
33 : : #define MSQ_XY_RECTANGLE_HPP
34 : :
35 : : #include "Mesquite.hpp"
36 : : #include "MeshInterface.hpp"
37 : :
38 : : #include <map>
39 : :
40 : : namespace MBMesquite
41 : : {
42 : :
43 : : /**\brief Simple 2D Domain for free-smooth testing
44 : : *
45 : : * Define a simple bounded rectangular domain in the XY-plane.
46 : : * Mesh vertices are classified as one of the following:
47 : : * - 0 DoF : On a corner of the rectangle
48 : : * - 1 DoF : On an edge of the rectangle
49 : : * - 2 DoF : In the interior of the rectangle
50 : : */
51 [ - + ]: 4 : class XYRectangle : public MBMesquite::MeshDomain
52 : : {
53 : : public:
54 : : enum Plane
55 : : {
56 : : XY = 2,
57 : : YZ = 0,
58 : : ZX = 1
59 : : };
60 : :
61 : : /**\brief Define rectangular domain
62 : : *
63 : : *\param w Width of rectangle (X-range)
64 : : *\param h Height of rectangle (Y-range)
65 : : *\param x Minimum X coordinate of rectangle
66 : : *\param y Minimum Y coordinate of rectangle
67 : : *\param z Minimum Z coordinate of rectangle
68 : : *\param plane Which plane (default is XY).
69 : : *
70 : : * Create w x h rectangle with, if plane is XY: X range of [x, x+w] and
71 : : * Y range of [y, y+h].
72 : : */
73 : : MESQUITE_EXPORT
74 : : XYRectangle( double w, double h, double x = 0, double y = 0, double z = 0, Plane plane = XY );
75 : :
76 : : /**\brief Classify mesh vertices against domain
77 : : *
78 : : * Figure out which input mesh vertices like on corners
79 : : * or edges of the domain. Will fail if any vertex is outside
80 : : * of the rectangle.
81 : : */
82 : : MESQUITE_EXPORT
83 : : void setup( MBMesquite::Mesh* mesh, MBMesquite::MsqError& err );
84 : :
85 : : MESQUITE_EXPORT
86 : : void snap_to( MBMesquite::Mesh::VertexHandle entity_handle, MBMesquite::Vector3D& coordinate ) const;
87 : :
88 : : MESQUITE_EXPORT
89 : : void vertex_normal_at( MBMesquite::Mesh::VertexHandle entity_handle, MBMesquite::Vector3D& coordinate ) const;
90 : :
91 : : MESQUITE_EXPORT
92 : : void element_normal_at( MBMesquite::Mesh::ElementHandle entity_handle, MBMesquite::Vector3D& coordinate ) const;
93 : :
94 : : MESQUITE_EXPORT
95 : : void vertex_normal_at( const MBMesquite::Mesh::VertexHandle* handles, MBMesquite::Vector3D coordinates[],
96 : : unsigned count, MBMesquite::MsqError& err ) const;
97 : :
98 : : MESQUITE_EXPORT
99 : : void closest_point( MBMesquite::Mesh::VertexHandle handle, const MBMesquite::Vector3D& position,
100 : : MBMesquite::Vector3D& closest, MBMesquite::Vector3D& normal, MBMesquite::MsqError& err ) const;
101 : :
102 : : MESQUITE_EXPORT
103 : : void domain_DoF( const MBMesquite::Mesh::VertexHandle* handle_array, unsigned short* dof_array, size_t num_handles,
104 : : MBMesquite::MsqError& err ) const;
105 : :
106 : : private:
107 : : double minCoords[3], maxCoords[3]; //!< corner coords
108 : : const int normalDir, widthDir, heightDir;
109 : :
110 : : //! Single constraint on a vertex (reduces degrees of freedom by 1)
111 : : struct VertexConstraint
112 : : {
113 : : enum Constraint
114 : : {
115 : : XC = 0,
116 : : YC = 1,
117 : : ZC = 2
118 : : };
119 : 24 : VertexConstraint( int a, double c ) : axis( (Constraint)a ), coord( c ) {}
120 : : Constraint axis;
121 : : double coord;
122 : : };
123 : :
124 : : //! Map vertex handles to constraints
125 : : typedef std::multimap< Mesh::VertexHandle, VertexConstraint > constraint_t;
126 : : constraint_t mConstraints;
127 : : };
128 : :
129 : : } // namespace MBMesquite
130 : :
131 : : #endif
|