//---------------------------------------------------------------------------// TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ForwardHistory, pack_unpack, Ordinal ) { std::size_t byte_size = 2*sizeof(Ordinal) + 2*sizeof(double) + 3*sizeof(int); MCLS::ForwardHistory<Ordinal>::setByteSize(); std::size_t packed_bytes = MCLS::ForwardHistory<Ordinal>::getPackedBytes(); TEST_EQUALITY( packed_bytes, byte_size ); MCLS::ForwardHistory<Ordinal> h_1( 5, 2, 6 ); h_1.live(); h_1.setEvent( MCLS::Event::BOUNDARY ); h_1.addToHistoryTally( 2.44 ); h_1.addStep(); Teuchos::Array<char> packed_history = h_1.pack(); TEST_EQUALITY( Teuchos::as<std::size_t>( packed_history.size() ), byte_size ); MCLS::ForwardHistory<Ordinal> h_2( packed_history ); TEST_EQUALITY( h_2.weight(), 6 ); TEST_EQUALITY( h_2.globalState(), 5 ); TEST_EQUALITY( h_2.localState(), Teuchos::OrdinalTraits<Ordinal>::invalid() ); TEST_EQUALITY( h_2.startingState(), 5 ); TEST_ASSERT( h_2.alive() ); TEST_EQUALITY( h_2.event(), MCLS::Event::BOUNDARY ); TEST_EQUALITY( h_2.historyTally(), 2.44 ); TEST_EQUALITY( h_2.numSteps(), 1 ); }
//---------------------------------------------------------------------------// TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ForwardHistory, broadcast, Ordinal ) { Teuchos::RCP<const Teuchos::Comm<int> > comm = Teuchos::DefaultComm<int>::getComm(); int comm_rank = comm->getRank(); MCLS::ForwardHistory<Ordinal>::setByteSize(); std::size_t packed_bytes = MCLS::ForwardHistory<Ordinal>::getPackedBytes(); Teuchos::Array<char> packed_history( packed_bytes ); if ( comm_rank == 0 ) { MCLS::ForwardHistory<Ordinal> h_1( 5, 2, 6 ); h_1.live(); h_1.setEvent( MCLS::Event::BOUNDARY ); h_1.addToHistoryTally( 1.98 ); h_1.addStep(); packed_history = h_1.pack(); } Teuchos::broadcast( *comm, 0, packed_history() ); MCLS::ForwardHistory<Ordinal> h_2( packed_history ); TEST_EQUALITY( h_2.weight(), 6 ); TEST_EQUALITY( h_2.globalState(), 5 ); TEST_EQUALITY( h_2.localState(), Teuchos::OrdinalTraits<Ordinal>::invalid() ); TEST_EQUALITY( h_2.startingState(), 5 ); TEST_ASSERT( h_2.alive() ); TEST_EQUALITY( h_2.event(), MCLS::Event::BOUNDARY ); TEST_EQUALITY( h_2.historyTally(), 1.98 ); TEST_EQUALITY( h_2.numSteps(), 1 ); }
void highOrderTools::computeStraightSidedPositions() { _clean(); // compute straigh sided positions that are actually X,Y,Z positions // that are NOT always on curves and surfaces // points classified on model vertices shall not move ! for(GModel::viter it = _gm->firstVertex(); it != _gm->lastVertex(); ++it){ if ((*it)->points.size()){ MPoint *p = (*it)->points[0]; MVertex *v = p->getVertex(0); _straightSidedLocation [v] = SVector3((*it)->x(),(*it)->y(),(*it)->z()); _targetLocation [v] = SVector3((*it)->x(),(*it)->y(),(*it)->z()); } } // printf("coucou2\n"); // compute stright sided positions of vertices that are classified on model edges for(GModel::eiter it = _gm->firstEdge(); it != _gm->lastEdge(); ++it){ for (unsigned int i=0;i<(*it)->lines.size();i++){ MLine *l = (*it)->lines[i]; int N = l->getNumVertices()-2; SVector3 p0((*it)->lines[i]->getVertex(0)->x(), (*it)->lines[i]->getVertex(0)->y(), (*it)->lines[i]->getVertex(0)->z()); SVector3 p1((*it)->lines[i]->getVertex(1)->x(), (*it)->lines[i]->getVertex(1)->y(), (*it)->lines[i]->getVertex(1)->z()); for (int j=1;j<=N;j++){ const double xi = (double)(j)/(N+1); // printf("xi = %g\n",xi); const SVector3 straightSidedPoint = p0 *(1.-xi) + p1*xi; MVertex *v = (*it)->lines[i]->getVertex(j+1); if (_straightSidedLocation.find(v) == _straightSidedLocation.end()){ _straightSidedLocation [v] = straightSidedPoint; _targetLocation[v] = SVector3(v->x(),v->y(),v->z()); } } } } // printf("coucou3\n"); // compute stright sided positions of vertices that are classified on model faces for(GModel::fiter it = _gm->firstFace(); it != _gm->lastFace(); ++it){ for (unsigned int i=0;i<(*it)->mesh_vertices.size();i++){ MVertex *v = (*it)->mesh_vertices[i]; _targetLocation[v] = SVector3(v->x(),v->y(),v->z()); } for (unsigned int i=0;i<(*it)->triangles.size();i++){ MTriangle *t = (*it)->triangles[i]; MFace face = t->getFace(0); const nodalBasis* fs = t->getFunctionSpace(); for (int j=0;j<t->getNumVertices();j++){ if (t->getVertex(j)->onWhat() == *it){ const double t1 = fs->points(j, 0); const double t2 = fs->points(j, 1); SPoint3 pc = face.interpolate(t1, t2); _straightSidedLocation [t->getVertex(j)] = SVector3(pc.x(),pc.y(),pc.z()); } } } for (unsigned int i=0;i<(*it)->quadrangles.size();i++){ // printf("coucou quad %d\n",i); MQuadrangle *q = (*it)->quadrangles[i]; MFace face = q->getFace(0); const nodalBasis* fs = q->getFunctionSpace(); for (int j=0;j<q->getNumVertices();j++){ if (q->getVertex(j)->onWhat() == *it){ const double t1 = fs->points(j, 0); const double t2 = fs->points(j, 1); SPoint3 pc = face.interpolate(t1, t2); _straightSidedLocation [q->getVertex(j)] = SVector3(pc.x(),pc.y(),pc.z()); } } } } for(GModel::riter it = _gm->firstRegion(); it != _gm->lastRegion(); ++it){ for (unsigned int i=0;i<(*it)->mesh_vertices.size();i++){ MVertex *v = (*it)->mesh_vertices[i]; _targetLocation[v] = SVector3(v->x(),v->y(),v->z()); } for (unsigned int i=0;i<(*it)->tetrahedra.size();i++){ _dim = 3; MTetrahedron *t = (*it)->tetrahedra[i]; MTetrahedron t_1 ((*it)->tetrahedra[i]->getVertex(0), (*it)->tetrahedra[i]->getVertex(1), (*it)->tetrahedra[i]->getVertex(2), (*it)->tetrahedra[i]->getVertex(3)); const nodalBasis* fs = t->getFunctionSpace(); for (int j=0;j<t->getNumVertices();j++){ if (t->getVertex(j)->onWhat() == *it){ double t1 = fs->points(j, 0); double t2 = fs->points(j, 1); double t3 = fs->points(j, 2); SPoint3 pc; t_1.pnt(t1, t2, t3,pc); _straightSidedLocation [t->getVertex(j)] = SVector3(pc.x(),pc.y(),pc.z()); } } } for (unsigned int i=0;i<(*it)->hexahedra.size();i++){ _dim = 3; MHexahedron *h = (*it)->hexahedra[i]; MHexahedron h_1 ((*it)->hexahedra[i]->getVertex(0), (*it)->hexahedra[i]->getVertex(1), (*it)->hexahedra[i]->getVertex(2), (*it)->hexahedra[i]->getVertex(3), (*it)->hexahedra[i]->getVertex(4), (*it)->hexahedra[i]->getVertex(5), (*it)->hexahedra[i]->getVertex(6), (*it)->hexahedra[i]->getVertex(7)); const nodalBasis* fs = h->getFunctionSpace(); for (int j=0;j<h->getNumVertices();j++){ if (h->getVertex(j)->onWhat() == *it){ double t1 = fs->points(j, 0); double t2 = fs->points(j, 1); double t3 = fs->points(j, 2); SPoint3 pc; h_1.pnt(t1, t2, t3,pc); _straightSidedLocation [h->getVertex(j)] = SVector3(pc.x(),pc.y(),pc.z()); } } } } Msg::Info("highOrderTools has been set up : %d nodes are considered", _straightSidedLocation.size()); }