void NodeSetTest::test_num_nodes() { NodeSet set; set.clear(); set.set_corner_node(1); CPPUNIT_ASSERT_EQUAL( 1u, set.num_nodes() ); set.set_corner_node(3); CPPUNIT_ASSERT_EQUAL( 2u, set.num_nodes() ); set.set_mid_region_node(0); CPPUNIT_ASSERT_EQUAL( 3u, set.num_nodes() ); set.set_mid_edge_node(1); set.set_mid_edge_node(2); CPPUNIT_ASSERT_EQUAL( 5u, set.num_nodes() ); set.set_all_nodes(HEXAHEDRON); CPPUNIT_ASSERT_EQUAL( 27u, set.num_nodes() ); set.clear(); set.set_all_nodes(TETRAHEDRON); CPPUNIT_ASSERT_EQUAL( 15u, set.num_nodes() ); set.clear(); set.set_all_nodes(TRIANGLE); CPPUNIT_ASSERT_EQUAL( 7u, set.num_nodes() ); set.clear(); set.set_all_nodes(QUADRILATERAL); CPPUNIT_ASSERT_EQUAL( 9u, set.num_nodes() ); set.clear(); set.set_all_nodes(PYRAMID); CPPUNIT_ASSERT_EQUAL( 19u, set.num_nodes() ); set.clear(); set.set_all_nodes(PRISM); CPPUNIT_ASSERT_EQUAL( 21u, set.num_nodes() ); }
void CachingTargetCalculator::notify_sub_patch( PatchData& , CachedTargetData& data, PatchData& subpatch, const size_t* , const size_t* element_map, MsqError& err ) { // If no cached data for this patch, just return if (data.has_data()) return; // Create a new cached data object on the subpatch CachedTargetData& sub_data = get_data( subpatch ); sub_data.clear(); // populate the element offset list, and count the total // number of cached target matrices. sub_data.elementOffsets.resize( subpatch.num_elements() ); size_t count_2D = 0, count_3D = 0; for (size_t i = 0; i < subpatch.num_elements(); ++i) { EntityTopology type = subpatch.element_by_index(i).get_element_type(); size_t& count = (TopologyInfo::dimension( type ) == 2) ? count_2D : count_3D; sub_data.elementOffsets[i] = count; NodeSet samples = subpatch.get_samples( i ); count += samples.num_nodes(); } const bool orient = have_surface_orient(); sub_data.targets3D.resize( count_3D ); if (orient) sub_data.targetsSurface.resize( count_2D ); else sub_data.targets2D.resize( count_2D ); for (size_t i = 0; i < subpatch.num_elements(); ++i) { EntityTopology type = subpatch.element_by_index(i).get_element_type(); size_t off = sub_data.elementOffsets[i]; size_t old_off = data.elementOffsets[element_map[i]]; NodeSet samples = subpatch.get_samples( i ); size_t count = samples.num_nodes(); if (TopologyInfo::dimension( type ) == 3) memcpy( &sub_data.targets3D[off], &data.targets3D[old_off], count*sizeof(MsqMatrix<3,3>) ); else if (orient) memcpy( &sub_data.targetsSurface[off], &data.targetsSurface[old_off], count*sizeof(MsqMatrix<3,2>) ); else memcpy( &sub_data.targets2D[off], &data.targets2D[old_off], count*sizeof(MsqMatrix<2,2>) ); } }
void MsqMeshEntityTest::test_all_nodes( EntityTopology type, unsigned num_nodes ) { const unsigned num_vtx = 27; double coords[3*num_vtx] = {0.0}; size_t conn[num_vtx]; for (size_t i = 0; i < num_vtx; ++i) conn[i] = i; bool fixed[num_vtx] = {false}; CPPUNIT_ASSERT(num_nodes <= num_vtx); MsqError err; PatchData pd; size_t n = num_nodes; pd.fill( num_nodes, coords, 1, &type, &n, conn, fixed, err ); ASSERT_NO_ERROR(err); MsqMeshEntity& elem = pd.element_by_index(0); NodeSet all = elem.all_nodes(err); ASSERT_NO_ERROR(err); CPPUNIT_ASSERT_EQUAL( num_nodes, all.num_nodes() ); CPPUNIT_ASSERT( all.have_any_corner_node() ); bool mid_edge, mid_face, mid_reg; TopologyInfo::higher_order( type, num_nodes, mid_edge, mid_face, mid_reg, err ); ASSERT_NO_ERROR(err); CPPUNIT_ASSERT_EQUAL( mid_edge, !!all.have_any_mid_edge_node() ); CPPUNIT_ASSERT_EQUAL( mid_face, !!all.have_any_mid_face_node() ); CPPUNIT_ASSERT_EQUAL( mid_reg, !!all.have_any_mid_region_node() ); }
void HexLagrangeShape::coefficients( Sample loc, NodeSet nodeset, double* coeff_out, size_t* indices_out, size_t& num_coeff, MsqError& err ) const { if (nodeset.num_nodes() != 27) { MSQ_SETERR(err)("Mapping function supports only 27-node hexahedra with no slaved nodes.", MsqError::UNSUPPORTED_ELEMENT); return; } switch (loc.dimension) { case 0: //Corner sample point - assume that it is there always num_coeff = 1; indices_out[0] = loc.number; coeff_out[0] = 1.0; break; case 1: //Line sample point - check if it is there, num_coeff = 1; indices_out[0] = loc.number+8; coeff_out[0] = 1.0; break; case 2: //Face sample point - check if it is there, num_coeff = 1; indices_out[0] = loc.number+20; coeff_out[0] = 1.0; break; case 3: //Center sample point - check if it is there, num_coeff = 1; indices_out[0] = 26; coeff_out[0] = 1.0; break; default: MSQ_SETERR(err)(MsqError::UNSUPPORTED_ELEMENT, "Request for dimension %d mapping function value" "for a quadratic hexahedral element", loc.dimension); } }
void HexLagrangeShape::derivatives( Sample loc, NodeSet nodeset, size_t* vertices, MsqVector<3>* derivs, size_t& num_vtx, MsqError& err ) const { if (nodeset.num_nodes() != 27) { MSQ_SETERR(err)("Mapping function supports only 27-node hexahedra with no slaved nodes.", MsqError::UNSUPPORTED_ELEMENT); return; } //r coordinate const int HLS1[]= {1, 3, 3, 1, 1, 3, 3, 1, 2, 3, 2, 1, 1, 3, 3, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 2, 2}; //s coordinate const int HLS2[]= {1, 1, 3, 3, 1, 1, 3, 3, 1, 2, 3, 2, 1, 1, 3, 3, 1, 2, 3, 2, 1, 2, 3, 2, 2, 2, 2}; //t coordinate const int HLS3[]= {1, 1, 1, 1, 3, 3, 3, 3, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 2, 2, 2, 2, 1, 3, 2}; const int HLSup1[]= {12, 13, 14, 15, -1, -1, -1, -1, 20, 21, 22, 23, 4, 5, 6, 7, -1, -1, -1, -1, 16, 17, 18, 19, 26, -1, 25}; const int HLSup2[]= {4, 5, 6, 7, -1, -1, -1, -1, 16, 17, 18, 19, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 25, -1, -1}; const int HLSdn1[]= {-1, -1, -1, -1, 12, 13, 14, 15, -1, -1, -1, -1, 0, 1, 2, 3, 20, 21, 22, 23, 8, 9, 10, 11, -1, 26, 24}; const int HLSdn2[]= {-1, -1, -1, -1, 0, 1, 2, 3, -1, -1, -1, -1, -1, -1, -1, -1, 8, 9, 10, 11, -1, -1, -1, -1, -1, 24, -1}; const int HLSlt1[]= {-1, 8, 10, -1, -1, 16, 18, -1, 0, 24, 3, -1, -1, 20, 22, -1, 4, 25, 7, -1, 12, 26, 15, -1, 11, 19, 23}; const int HLSlt2[]= {-1, 0, 3, -1, -1, 4, 7, -1, -1, 11, -1, -1, -1, 12, 15, -1, -1, 19, -1, -1, -1, 23, -1, -1, -1, -1, -1}; const int HLSrt1[]= {8, -1, -1, 10, 16, -1, -1, 18, 1, -1, 2, 24, 20, -1, -1, 22, 5, -1, 6, 25, 13, -1, 14, 26, 9, 17, 21}; const int HLSrt2[]= {1, -1, -1, 2, 5, -1, -1, 6, -1, -1, -1, 9, 13, -1, -1, 14, -1, -1, -1, 17, -1, -1, -1, 21, -1, -1, -1}; const int HLSft1[]= {-1, -1, 9, 11, -1, -1, 17, 19, -1, 1, 24, 0, -1, -1, 21, 23, -1, 5, 25, 4, -1, 13, 26, 12, 8, 16, 20}; const int HLSft2[]= {-1, -1, 1, 0, -1, -1, 5, 4, -1, -1, 8, -1, -1, -1, 13, 12, -1, -1, 16, -1, -1, -1, 20, -1, -1, -1, -1}; const int HLSbk1[]= {11, 9, -1, -1, 19, 17, -1, -1, 24, 2, -1, 3, 23, 21, -1, -1, 25, 6, -1, 7, 26, 14, -1, 15, 10, 18, 22}; const int HLSbk2[]= {3, 2, -1, -1, 7, 6, -1, -1, 10, -1, -1, -1, 15, 14, -1, -1, 18, -1, -1, -1, 22, -1, -1, -1, -1, -1, -1}; double entries[] = {0, -3, 0, 3}; int location=loc.number; switch (loc.dimension) { case 1: location+=8; break; case 2: location+=20; break; case 3: location+=26; break; } num_vtx=0; if (location != 26) { vertices[num_vtx]=location; derivs[num_vtx][0]=entries[HLS1[location]]; derivs[num_vtx][1]=entries[HLS2[location]]; derivs[num_vtx][2]=entries[HLS3[location]]; num_vtx++; } if(HLSup1[location]!=-1){ vertices[num_vtx]=HLSup1[location]; if(HLS3[location]==2) { derivs[num_vtx][0]=0; derivs[num_vtx][1]=0; derivs[num_vtx][2]=1; } else { derivs[num_vtx][0]=0; derivs[num_vtx][1]=0; derivs[num_vtx][2]=4; } num_vtx++; } if(HLSdn1[location]!=-1){ vertices[num_vtx]=HLSdn1[location]; if(HLS3[location]==2) { derivs[num_vtx][0]=0; derivs[num_vtx][1]=0; derivs[num_vtx][2]=-1; } else { derivs[num_vtx][0]=0; derivs[num_vtx][1]=0; derivs[num_vtx][2]=-4; } num_vtx++; } if(HLSup2[location]!=-1){ vertices[num_vtx]=HLSup2[location]; derivs[num_vtx][0]=0; derivs[num_vtx][1]=0; derivs[num_vtx][2]=-1; num_vtx++; } if(HLSdn2[location]!=-1){ vertices[num_vtx]=HLSdn2[location]; derivs[num_vtx][0]=0; derivs[num_vtx][1]=0; derivs[num_vtx][2]=1; num_vtx++; } if(HLSlt1[location]!=-1){ vertices[num_vtx]=HLSlt1[location]; if(HLS1[location]==2) { derivs[num_vtx][0]=-1; derivs[num_vtx][1]=0; derivs[num_vtx][2]=0; } else { derivs[num_vtx][0]=-4; derivs[num_vtx][1]=0; derivs[num_vtx][2]=0; } num_vtx++; } if(HLSrt1[location]!=-1){ vertices[num_vtx]=HLSrt1[location]; if(HLS1[location]==2) { derivs[num_vtx][0]=1; derivs[num_vtx][1]=0; derivs[num_vtx][2]=0; } else { derivs[num_vtx][0]=4; derivs[num_vtx][1]=0; derivs[num_vtx][2]=0; } num_vtx++; } if(HLSlt2[location]!=-1){ vertices[num_vtx]=HLSlt2[location]; derivs[num_vtx][0]=1; derivs[num_vtx][1]=0; derivs[num_vtx][2]=0; num_vtx++; } if(HLSrt2[location]!=-1){ vertices[num_vtx]=HLSrt2[location]; derivs[num_vtx][0]=-1; derivs[num_vtx][1]=0; derivs[num_vtx][2]=0; num_vtx++; } if(HLSft1[location]!=-1){ vertices[num_vtx]=HLSft1[location]; if(HLS2[location]==2) { derivs[num_vtx][0]=0; derivs[num_vtx][1]=-1; derivs[num_vtx][2]=0; } else { derivs[num_vtx][0]=0; derivs[num_vtx][1]=-4; derivs[num_vtx][2]=0; } num_vtx++; } if(HLSbk1[location]!=-1){ vertices[num_vtx]=HLSbk1[location]; if(HLS2[location]==2) { derivs[num_vtx][0]=0; derivs[num_vtx][1]=1; derivs[num_vtx][2]=0; } else { derivs[num_vtx][0]=0; derivs[num_vtx][1]=4; derivs[num_vtx][2]=0; } num_vtx++; } if(HLSft2[location]!=-1){ vertices[num_vtx]=HLSft2[location]; derivs[num_vtx][0]=0; derivs[num_vtx][1]=1; derivs[num_vtx][2]=0; num_vtx++; } if(HLSbk2[location]!=-1){ vertices[num_vtx]=HLSbk2[location]; derivs[num_vtx][0]=0; derivs[num_vtx][1]=-1; derivs[num_vtx][2]=0; num_vtx++; } }