MOAB: Mesh Oriented datABase  (version 5.2.1)
PatchDataInstances.hpp
Go to the documentation of this file.
00001 /* *****************************************************************
00002     MESQUITE -- The Mesh Quality Improvement Toolkit
00003 
00004     Copyright 2004 Sandia Corporation and Argonne National
00005     Laboratory.  Under the terms of Contract DE-AC04-94AL85000
00006     with Sandia Corporation, the U.S. Government retains certain
00007     rights in 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     diachin2@llnl.gov, djmelan@sandia.gov, mbrewer@sandia.gov,
00024     pknupp@sandia.gov, tleurent@mcs.anl.gov, tmunson@mcs.anl.gov
00025 
00026   ***************************************************************** */
00027 //
00028 //    AUTHOR: Thomas Leurent <tleurent@mcs.anl.gov>
00029 //       ORG: Argonne National Laboratory
00030 //    E-MAIL: tleurent@mcs.anl.gov
00031 //
00032 // ORIG-DATE: 12-Nov-02 at 18:05:56
00033 //  LAST-MOD:  9-Jun-04 at 14:43:39 by Thomas Leurent
00034 //
00035 // DESCRIPTION:
00036 // ============
00037 /*! \file PatchDataInstances.hpp
00038 
00039 This header file contains some functions to instantiates particular PatchData Objects.
00040 Those objects can be used in unit tests.
00041 Patches must be allocated and dealocated by the caller.
00042 
00043 \author Thomas Leurent
00044 \author Michael Brewer
00045 
00046 */
00047 // DESCRIP-END.
00048 //
00049 
00050 #ifndef PatchDataInstances_hpp
00051 #define PatchDataInstances_hpp
00052 
00053 #include "MsqVertex.hpp"
00054 #include "PatchData.hpp"
00055 #include "PlanarDomain.hpp"
00056 #include "IdealElements.hpp"
00057 #include "TopologyInfo.hpp"
00058 
00059 #include <math.h>
00060 #include <iostream>
00061 
00062 #include "cppunit/extensions/HelperMacros.h"
00063 
00064 namespace MBMesquite
00065 {
00066 //! must be called in sync with create_...._patch_with_domain
00067 inline void destroy_patch_with_domain( PatchData& pd )
00068 {
00069     MeshDomain* domain = pd.get_domain();
00070     pd.set_domain( 0 );
00071     delete domain;
00072 
00073     // Mesh* mesh = pd.get_mesh();
00074     // pd.set_mesh( 0 );
00075     // delete mesh;
00076 }
00077 
00078 inline void move_vertex( PatchData& pd, const Vector3D& position, const Vector3D& delta, MsqError& err )
00079 {
00080     const MsqVertex* array = pd.get_vertex_array( err );
00081     if( err ) return;
00082 
00083     int idx = 0, cnt = 0;
00084     for( size_t i = 0; i < pd.num_nodes(); ++i )
00085         if( ( array[i] - position ).length_squared() < DBL_EPSILON )
00086         {
00087             idx = i;
00088             ++cnt;
00089         }
00090 
00091     CPPUNIT_ASSERT_EQUAL( cnt, 1 );
00092 
00093     pd.move_vertex( delta, idx, err );
00094 }
00095 
00096 /*! creates a patch containing one ideal hexahedra
00097  */
00098 inline void create_one_hex_patch( PatchData& one_hex_patch, MsqError& err )
00099 {
00100     double coords[] = { 1.0, 1.0, 1.0, 2.0, 1.0, 1.0, 2.0, 2.0, 1.0, 1.0, 2.0, 1.0,
00101                         1.0, 1.0, 2.0, 2.0, 1.0, 2.0, 2.0, 2.0, 2.0, 1.0, 2.0, 2.0 };
00102 
00103     size_t indices[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };
00104 
00105     one_hex_patch.fill( 8, coords, 1, HEXAHEDRON, indices, 0, err );
00106 }
00107 
00108 //! creates a Patch containing an ideal tetrahedra
00109 inline void create_one_tet_patch( PatchData& one_tet_patch, MsqError& err )
00110 {
00111     double coords[] = { 1.0,
00112                         1.0,
00113                         1.0,
00114                         2.0,
00115                         1.0,
00116                         1.0,
00117                         1.5,
00118                         1 + sqrt( 3.0 ) / 2.0,
00119                         1.0,
00120                         1.5,
00121                         1 + sqrt( 3.0 ) / 6.0,
00122                         1 + sqrt( 2.0 ) / sqrt( 3.0 ) };
00123 
00124     size_t indices[4] = { 0, 1, 2, 3 };
00125 
00126     one_tet_patch.fill( 4, coords, 1, TETRAHEDRON, indices, 0, err );
00127 }
00128 
00129 //! create patch containing one ideal pyramid
00130 inline void create_one_pyr_patch( PatchData& one_pyr_patch, MsqError& err )
00131 {
00132     /* Equilateral triangles
00133     double coords[] = { 1, -1, 0,
00134                         1,  1, 0,
00135                        -1,  1, 0,
00136                        -1, -1, 0,
00137                         0,  0, sqrt(2) };
00138     */
00139     /* Unit height */
00140     double coords[] = { 1, -1, 0, 1, 1, 0, -1, 1, 0, -1, -1, 0, 0, 0, 2 };
00141 
00142     size_t indices[5] = { 0, 1, 2, 3, 4 };
00143 
00144     one_pyr_patch.fill( 5, coords, 1, PYRAMID, indices, 0, err );
00145 }
00146 
00147 //! create patch containing one ideal wedge
00148 inline void create_one_wdg_patch( PatchData& one_wdg_patch, MsqError& err )
00149 {
00150     double hgt      = 0.5 * MSQ_SQRT_THREE;
00151     double coords[] = { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.5, hgt, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.5, hgt, 1.0 };
00152 
00153     size_t indices[6] = { 0, 1, 2, 3, 4, 5 };
00154 
00155     one_wdg_patch.fill( 6, coords, 1, PRISM, indices, 0, err );
00156 }
00157 
00158 //! creates a Patch containing an ideal tetrahedra, inverted
00159 inline void create_one_inverted_tet_patch( PatchData& one_tet_patch, MsqError& err )
00160 {
00161     double coords[] = {
00162         1, 1, 1, 2, 1, 1, 1.5, 1 + sqrt( 3.0 ) / 2.0, 1, 1.5, 1 + sqrt( 3.0 ) / 6.0, 1 - sqrt( 2.0 ) / sqrt( 3.0 ),
00163     };
00164 
00165     size_t indices[4] = { 0, 1, 2, 3 };
00166 
00167     one_tet_patch.fill( 4, coords, 1, TETRAHEDRON, indices, 0, err );
00168 }
00169 
00170 //! creates a Patch containing an ideal quadrilateral
00171 inline void create_one_quad_patch( PatchData& one_qua_patch, MsqError& err )
00172 {
00173     double coords[] = { 1, 1, 1, 2, 1, 1, 2, 2, 1, 1, 2, 1 };
00174 
00175     size_t indices[4] = { 0, 1, 2, 3 };
00176 
00177     one_qua_patch.fill( 4, coords, 1, QUADRILATERAL, indices, 0, err );
00178 }
00179 
00180 /*! \fn create_one_tri_patch(PatchData &one_tri_patch, MsqError &err)
00181        2
00182       / \      creates a Patch containing an ideal triangle
00183      /   \
00184     0-----1
00185     This Patch also has the normal information.
00186 */
00187 inline void create_one_tri_patch( PatchData& one_tri_patch, MsqError& err )
00188 {
00189     /* ************** Creates normal info ******************* */
00190     Vector3D pnt( 0, 0, 0 );
00191     Vector3D s_norm( 0, 0, 3 );
00192     one_tri_patch.set_domain( new PlanarDomain( s_norm, pnt ) );
00193 
00194     /* *********************FILL tri************************* */
00195     double coords[] = { 1, 1, 1, 2, 1, 1, 1.5, 1 + sqrt( 3.0 ) / 2.0, 1 };
00196 
00197     size_t indices[3] = { 0, 1, 2 };
00198     one_tri_patch.fill( 3, coords, 1, TRIANGLE, indices, 0, err );
00199 }
00200 
00201 /*! \fn create_two_tri_patch(PatchData &one_tri_patch, MsqError &err)
00202          2
00203         / \      creates a Patch containing two ideal triangles
00204        / 0 \
00205       0-----1
00206        \ 1 /
00207         \ /
00208          3
00209       This Patch also has the normal information.
00210 */
00211 inline void create_two_tri_patch( PatchData& pd, MsqError& err )
00212 {
00213     /* ************** Creates normal info ******************* */
00214     Vector3D pnt( 0, 0, 1 );
00215     Vector3D s_norm( 0, 0, 3 );
00216     pd.set_domain( new PlanarDomain( s_norm, pnt ) );
00217 
00218     // **********************FILL tri*************************
00219 
00220     double coords[] = { 1, 1, 1, 2, 1, 1, 1.5, 1 + sqrt( 3.0 ) / 2.0, 1, 1.5, 1 - sqrt( 3.0 ) / 2.0, 1 };
00221 
00222     size_t indices[] = { 0, 1, 2, 0, 3, 1 };
00223 
00224     pd.fill( 4, coords, 2, TRIANGLE, indices, 0, err );
00225 }
00226 
00227 /*! \fn create_four_quads_patch(PatchData &four_quads, MsqError &err)
00228   our 2D set up: 4 quads, center vertex outcentered by (0,-0.5)
00229    7____6____5
00230    |    |    |
00231    | 2  |  3 |
00232    8-_  |  _-4       vertex 1 is at (0,0)
00233    |  -_0_-  |       vertex 5 is at (2,2)
00234    | 0  |  1 |
00235    1----2----3
00236 */
00237 inline void create_four_quads_patch( PatchData& four_quads, MsqError& err )
00238 {
00239     double coords[] = { 1, .5, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 2, 1, 0, 2, 2, 0, 1, 2, 0, 0, 2, 0, 0, 1, 0 };
00240 
00241     size_t indices[] = { 1, 2, 0, 8, 2, 3, 4, 0, 8, 0, 6, 7, 0, 4, 5, 6 };
00242 
00243     four_quads.fill( 9, coords, 4, QUADRILATERAL, indices, 0, err );
00244 }
00245 
00246 /*! \fn create_six_quads_patch(PatchData &four_quads, MsqError &err)
00247   our 2D set up: 6 quads, 1 center vertex outcentered by (0,-0.5), the other centered
00248    7____6____5___11
00249    |    |    |    |
00250    | 2  |  3 | 5  |
00251    8-_  |  _-4---10       vertex 1 is at (0,0)
00252    |  -_0_-  |    |       vertex 11 is at (3,2)
00253    | 0  |  1 | 4  |
00254    1----2----3----9
00255 
00256    use destroy_patch_with_domain() in sync.
00257 */
00258 inline void create_six_quads_patch_with_domain( PatchData& pd, MsqError& err )
00259 {
00260     // associates domain
00261     Vector3D pnt( 0, 0, 0 );
00262     Vector3D s_norm( 0, 0, 3 );
00263     pd.set_domain( new PlanarDomain( s_norm, pnt ) );
00264 
00265     double coords[] = { 1, .5, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 2, 1, 0, 2, 2, 0,
00266                         1, 2,  0, 0, 2, 0, 0, 1, 0, 3, 0, 0, 3, 1, 0, 3, 2, 0 };
00267 
00268     size_t indices[] = { 1, 2, 0, 8, 2, 3, 4, 0, 8, 0, 6, 7, 0, 4, 5, 6, 3, 9, 10, 4, 4, 10, 11, 5 };
00269 
00270     bool fixed[] = { false, true, true, true, false, true, true, true, true, true, true, true };
00271 
00272     pd.fill( 12, coords, 6, QUADRILATERAL, indices, fixed, err );
00273 }
00274 
00275 /*! \fn create_six_quads_patch_inverted_with_domain(PatchData &four_quads, MsqError &err)
00276   our 2D set up: 6 quads, 1 center vertex outcentered by (0,-0.5), the other centered
00277    7____6____5___11
00278    |    |    |    |
00279    | 2  |  3 | 5  |
00280    8    |    4---10       vertex 1 is at (0,0)
00281    |\       /|    |       vertex 11 is at (3,2)
00282    |    |    | 4  |
00283    1----2----3----9
00284       \  /
00285        0
00286    use destroy_patch_with_domain() in sync.
00287 */
00288 inline void create_six_quads_patch_inverted_with_domain( PatchData& pd, MsqError& err )
00289 {
00290     create_six_quads_patch_with_domain( pd, err );MSQ_CHKERR( err );
00291 
00292     Vector3D displacement( 0, -1.5, 0 );
00293 
00294     pd.move_vertex( displacement, 0, err );
00295 }
00296 
00297 /*! \fn create_twelve_hex_patch(PatchData &pd, MsqError &err)
00298   3D set up: 12 quads, one center vertex outcentered by (0,-0.5),
00299   the other centered. Vertex 1 is at (0,0,-1). Vertex 35 is at (3,2,1).
00300 
00301    7____6____5___11     19___18____17__23     31___30___29___35
00302    |    |    |    |      |    |    |    |      |    |    |    |
00303    | 2  |  3 | 5  |      |    |    |    |      | 8  |  9 | 11 |
00304    8----0----4---10     20-_  |  _16---22     32---24---28---34
00305    |    |    |    |      |  -12_-  |    |      |    |    |    |
00306    | 0  |  1 | 4  |      |    |    |    |      | 6  |  7 | 10 |
00307    1----2----3----9     13---14---15---21     25---26---27---33
00308 */
00309 inline void create_twelve_hex_patch( PatchData& pd, MsqError& err )
00310 {
00311     double coords[] = { 1, 1,  -1, 0, 0, -1, 1, 0, -1, 2, 0, -1, 2, 1, -1, 2, 2, -1,
00312                         1, 2,  -1, 0, 2, -1, 0, 1, -1, 3, 0, -1, 3, 1, -1, 3, 2, -1,
00313 
00314                         1, .5, 0,  0, 0, 0,  1, 0, 0,  2, 0, 0,  2, 1, 0,  2, 2, 0,
00315                         1, 2,  0,  0, 2, 0,  0, 1, 0,  3, 0, 0,  3, 1, 0,  3, 2, 0,
00316 
00317                         1, 1,  1,  0, 0, 1,  1, 0, 1,  2, 0, 1,  2, 1, 1,  2, 2, 1,
00318                         1, 2,  1,  0, 2, 1,  0, 1, 1,  3, 0, 1,  3, 1, 1,  3, 2, 1 };
00319 
00320     size_t connectivity[] = { 1,  2,  0,  8,  13, 14, 12, 20,    // 0
00321                               2,  3,  4,  0,  14, 15, 16, 12,    // 1
00322                               8,  0,  6,  7,  20, 12, 18, 19,    // 2
00323                               0,  4,  5,  6,  12, 16, 17, 18,    // 3
00324                               3,  9,  10, 4,  15, 21, 22, 16,    // 4
00325                               4,  10, 11, 5,  16, 22, 23, 17,    // 5
00326                               13, 14, 12, 20, 25, 26, 24, 32,    // 6
00327                               14, 15, 16, 12, 26, 27, 28, 24,    // 7
00328                               20, 12, 18, 19, 32, 24, 30, 31,    // 8
00329                               12, 16, 17, 18, 24, 28, 29, 30,    // 9
00330                               15, 21, 22, 16, 27, 33, 34, 28,    // 10
00331                               16, 22, 23, 17, 28, 34, 35, 29 };  // 11
00332 
00333     bool fixed[] = { true,  true, true, true, true,  true, true, true, true, true, true, true,
00334                      false, true, true, true, false, true, true, true, true, true, true, true,
00335                      true,  true, true, true, true,  true, true, true, true, true, true, true };
00336 
00337     pd.fill( 36, coords, 12, HEXAHEDRON, connectivity, fixed, err );
00338 }
00339 
00340 inline void create_twelve_hex_patch_inverted( PatchData& pd, MsqError& err )
00341 {
00342     create_twelve_hex_patch( pd, err );MSQ_CHKERR( err );
00343     move_vertex( pd, Vector3D( 2, 1, 0 ), Vector3D( 0, 0, 1.5 ), err );MSQ_CHKERR( err );
00344 }
00345 
00346 /* Patch used in several quality metric tests.
00347    Our triangular patch is made of two tris.  tri_1 is a perfect
00348    equilateral (the ideal for most metrics).  tri_2 is an arbitrary
00349    triangle.
00350    Memory allocated in this function must be deallocated with
00351    destroy_patch_with_domain().
00352 */
00353 inline void create_qm_two_tri_patch_with_domain( PatchData& triPatch, MsqError& err )
00354 {
00355     Vector3D pnt( 0, 0, 0 );
00356     Vector3D s_norm( 0, 0, 3 );
00357     triPatch.set_domain( new PlanarDomain( s_norm, pnt ) );
00358 
00359     double coords[] = { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.5, sqrt( 3.0 ) / 2.0, 0.0, 2.0, -4.0, 2.0 };
00360 
00361     const size_t conn[] = { 0, 1, 2, 0, 3, 1 };
00362 
00363     triPatch.fill( 4, coords, 2, TRIANGLE, conn, 0, err );
00364 }
00365 
00366 /* Patch used in several quality metric tests.
00367   Our quad patch is made of two quads.  quad_1 is a perfect
00368   square (the ideal for most metrics).  quad_2 is an arbitrary
00369   quad.
00370   Memory allocated in this function must be deallocated with
00371   destroy_patch_with_domain().
00372 */
00373 inline void create_qm_two_quad_patch_with_domain( PatchData& quadPatch, MsqError& err )
00374 {
00375     Vector3D pnt( 0, 0, 0 );
00376     Vector3D s_norm( 0, 0, 3 );
00377     quadPatch.set_domain( new PlanarDomain( s_norm, pnt ) );
00378 
00379     double coords[] = { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 2.0, -1.0, .5, 1.5, 1.0, 1.0 };
00380 
00381     const size_t conn[] = { 0, 1, 2, 3, 1, 4, 5, 2 };
00382 
00383     quadPatch.fill( 6, coords, 2, QUADRILATERAL, conn, 0, err );
00384 }
00385 
00386 /* Patch used in several quality metric tests.
00387    Our tet patch is made of two tets.  tet_1 is a perfect
00388    equilateral (the ideal for most metrics).  tet_2 is an arbitrary
00389    tet.
00390 */
00391 inline void create_qm_two_tet_patch( PatchData& tetPatch, MsqError& err )
00392 {
00393     double coords[] = {
00394         0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.5, sqrt( 3.0 ) / 2.0, 0.0, 0.5, sqrt( 3.0 ) / 6.0, sqrt( 2.0 ) / sqrt( 3.0 ),
00395         2.0, 3.0, -.5
00396     };
00397 
00398     const size_t conn[] = { 0, 1, 2, 3, 1, 4, 2, 3 };
00399 
00400     tetPatch.fill( 5, coords, 2, TETRAHEDRON, conn, 0, err );
00401 }
00402 
00403 /* Patch used in several quality metric tests.
00404    Our pyr patch is made of two pyramids.  The first is a perfect
00405    pyramid (the ideal for most metrics).  The second is an arbitrary
00406    pyramid.
00407 */
00408 inline void create_qm_two_pyr_patch( PatchData& pyrPatch, MsqError& err )
00409 {
00410     /* Equilateral triangles
00411     double coords[] = { 1, -1, 0,
00412                         1,  1, 0,
00413                        -1,  1, 0,
00414                        -1, -1, 0,
00415                         0,  0, sqrt(2) };
00416     */
00417     /* Unit height */
00418     double coords[] = { /* Equilateral triangles */
00419                         /*   1, -1, 0,
00420                              1,  1, 0,
00421                             -1,  1, 0,
00422                             -1, -1, 0,
00423                              0,  0, sqrt(2)  */
00424                         /* Unit height */
00425                         1, -1, 0, 1, 1, 0, -1, 1, 0, -1, -1, 0, 0, 0, 2,
00426                         /* Apex for a squashed pyramid */
00427                         0, 0, -1
00428     };
00429 
00430     const size_t conn[] = { 0, 1, 2, 3, 4, 3, 2, 1, 0, 5 };
00431 
00432     pyrPatch.fill( 6, coords, 2, PYRAMID, conn, 0, err );
00433 }
00434 
00435 /* Patch used in several quality metric tests.
00436    Our prism patch is made of two prisms.  The first is a perfect
00437    prism (the ideal for most metrics).  The second is an arbitrary
00438    wedge.
00439 */
00440 inline void create_qm_two_wdg_patch( PatchData& wdgPatch, MsqError& err )
00441 {
00442     double hgt      = 0.5 * MSQ_SQRT_THREE;
00443     double coords[] = { // ideal prism vertices
00444                         0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.5, hgt, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.5, hgt, 1.0,
00445                         // top vertices for stretched wedge
00446                         0.5, -3.0, 0.0, 0.5, -4.0, 1.0
00447     };
00448 
00449     const size_t conn[] = { 0, 1, 2, 3, 4, 5, 1, 0, 6, 4, 3, 7 };
00450 
00451     wdgPatch.fill( 8, coords, 2, PRISM, conn, 0, err );
00452 }
00453 
00454 /* Patch used in seveal quality metric tests.
00455    Our hex patch is made of two hexes.  hex_1 is a perfect
00456    unit cube (the ideal for most metrics).  hex_2 is an arbitrary
00457    hex.
00458 */
00459 inline void create_qm_two_hex_patch( PatchData& hexPatch, MsqError& err )
00460 {
00461     double coords[] = { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0,  1.0, 1.0, 0.0, 1.0,
00462                         1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 2.0, 0.0, 0.0, 2.0, 1.0, 0.0, 2.0, -1.0, 1.0, 3.0, 2.0, 1.0 };
00463 
00464     const size_t conn[] = { 0, 1, 2, 3, 4, 5, 6, 7, 1, 8, 9, 2, 5, 10, 11, 6 };
00465 
00466     hexPatch.fill( 12, coords, 2, HEXAHEDRON, conn, 0, err );
00467 }
00468 
00469 // Create patch containing one ideal element, optionally higher-order.
00470 // For 2D elements, will attach appropriate planar domain.
00471 inline void create_ideal_element_patch( PatchData& pd, EntityTopology type, size_t num_nodes, MsqError& err )
00472 {
00473     static PlanarDomain zplane( PlanarDomain::XY );
00474     static Settings settings;
00475     settings.set_slaved_ho_node_mode( Settings::SLAVE_NONE );
00476     pd.attach_settings( &settings );
00477 
00478     // build list of vertex coordinates
00479     const Vector3D* corners = unit_edge_element( type );
00480     std::vector< Vector3D > coords( corners, corners + TopologyInfo::corners( type ) );
00481     bool mids[4] = { false };
00482     TopologyInfo::higher_order( type, num_nodes, mids[1], mids[2], mids[3], err );MSQ_ERRRTN( err );
00483     std::vector< size_t > conn( coords.size() );
00484     for( unsigned i = 0; i < coords.size(); ++i )
00485         conn[i] = i;
00486 
00487     for( unsigned dim = 1; dim <= TopologyInfo::dimension( type ); ++dim )
00488     {
00489         if( !mids[dim] ) continue;
00490 
00491         int num_side;
00492         if( dim == TopologyInfo::dimension( type ) )
00493             num_side = 1;
00494         else
00495             num_side = TopologyInfo::adjacent( type, dim );
00496 
00497         for( int s = 0; s < num_side; ++s )
00498         {
00499             unsigned idx = TopologyInfo::higher_order_from_side( type, num_nodes, dim, s, err );MSQ_ERRRTN( err );
00500             conn.push_back( idx );
00501 
00502             unsigned n;
00503             const unsigned* side = TopologyInfo::side_vertices( type, dim, s, n, err );MSQ_ERRRTN( err );
00504             Vector3D avg = coords[side[0]];
00505             for( unsigned v = 1; v < n; ++v )
00506                 avg += coords[side[v]];
00507             avg *= 1.0 / n;
00508             coords.push_back( avg );
00509         }
00510     }
00511 
00512     bool* fixed = new bool[coords.size()];
00513     std::fill( fixed, fixed + coords.size(), false );
00514     pd.fill( coords.size(), coords[0].to_array(), 1, &type, &num_nodes, &conn[0], fixed, err );
00515     delete[] fixed;MSQ_ERRRTN( err );
00516 
00517     if( TopologyInfo::dimension( type ) == 2 ) pd.set_domain( &zplane );
00518 }
00519 
00520 }  // namespace MBMesquite
00521 
00522 #endif  // PatchDataInstances_hpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines