当前位置: 首页>>代码示例>>C++>>正文


C++ PatchData::num_nodes方法代码示例

本文整理汇总了C++中PatchData::num_nodes方法的典型用法代码示例。如果您正苦于以下问题:C++ PatchData::num_nodes方法的具体用法?C++ PatchData::num_nodes怎么用?C++ PatchData::num_nodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PatchData的用法示例。


在下文中一共展示了PatchData::num_nodes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: printPatch

void NonGradient::printPatch(const PatchData &pd, MsqError &err)
{
  if( mNonGradDebug==0 )
  {
    return;
  }
  const size_t numNode = pd.num_nodes();   //27,  27 what?
  MSQ_PRINT(3)("Number of Vertices: %d\n",(int)pd.num_nodes());
  const size_t numVert = pd.num_free_vertices(); // 1
  MSQ_PRINT(3)("Num Free = %d\n",(int)pd.num_free_vertices());
  const size_t numSlaveVert = pd.num_slave_vertices(); //0
  const size_t numCoin = pd.num_corners(); // 64
  const MsqVertex* coord = pd.get_vertex_array(err);
  MSQ_PRINT(3)("Number of Vertices: %d\n",(int)pd.num_nodes());

  std::cout << "Patch " << numNode << "  " << numVert << "  " << numSlaveVert << "  " << numCoin << std::endl;
  MSQ_PRINT(3)("");
  std::cout << "Coordinate ";
  std::cout << "         " << std::endl;
  for( size_t index = 0; index < numVert; index++ )
  {
    std::cout << coord[index][0] << "  " << coord[index][1] << "  " << coord[index][2] << std::endl;
  }
  //const size_t numElt = pd.num_elements();
  if( mNonGradDebug >= 3 ) 
  {      
         std::cout << "Number of Elements: " << pd.num_elements() << std::endl;
  }      
  MSQ_PRINT(3)("Number of Elements: %d\n",(int)pd.num_elements());
}
开发者ID:bartlettroscoe,项目名称:trilinos_old_public,代码行数:30,代码来源:Mesquite_NonGradient.cpp

示例2: check_global_patch_slaved

int check_global_patch_slaved( Mesh& mesh, MsqError& err )
{
  Settings s;
  s.set_slaved_ho_node_mode( Settings::SLAVE_FLAG );
  MeshDomainAssoc mesh_and_domain = MeshDomainAssoc(&mesh, 0);
  Instruction::initialize_vertex_byte( &mesh_and_domain, &s, err ); MSQ_ERRZERO(err);
  
  PatchData pd;
  pd.attach_settings( &s );
  pd.set_mesh( &mesh );
  pd.fill_global_patch( err ); MSQ_ERRZERO(err);

  std::vector<bool> fixed, slaved;
  mesh.vertices_get_fixed_flag( pd.get_vertex_handles_array(), 
                                fixed, pd.num_nodes(), err );
  MSQ_ERRZERO(err);
  mesh.vertices_get_slaved_flag( pd.get_vertex_handles_array(), 
                                 slaved, pd.num_nodes(), err );
  MSQ_ERRZERO(err);
  
  const size_t first_free = 0;
  const size_t first_slaved = pd.num_free_vertices();
  const size_t first_fixed = pd.num_free_vertices() + pd.num_slave_vertices();
  int error_count = 0;
  for (size_t i = first_free; i < first_slaved; ++i) {
    if (fixed[i]) {
      std::cerr << "Vertex " << (size_t)pd.get_vertex_handles_array()[i]
                << " is fixed in mesh but free in PatchData" << std::endl;
      ++error_count;
    }
    if (slaved[i]) {
      std::cerr << "Vertex " << (size_t)pd.get_vertex_handles_array()[i]
                << " is slaved in mesh but free in PatchData" << std::endl;
      ++error_count;
    }
  }
  for (size_t i = first_slaved; i < first_fixed; ++i) {
    if (fixed[i]) {
      std::cerr << "Vertex " << (size_t)pd.get_vertex_handles_array()[i]
                << " is fixed in mesh but slaved in PatchData" << std::endl;
      ++error_count;
    }
    else if (!slaved[i]) {
      std::cerr << "Vertex " << (size_t)pd.get_vertex_handles_array()[i]
                << " is free in Mesh but slaved in PatchData" << std::endl;
      ++error_count;
    }
  }
  for (size_t i = first_fixed; i < pd.num_nodes(); ++i) {
    if (!fixed[i]) {
      std::cerr << "Vertex " << (size_t)pd.get_vertex_handles_array()[i]
                << " is not fixed in mesh but is in PatchData" << std::endl;
      ++error_count;
    }
  }
  return 0 == error_count;
}
开发者ID:gitter-badger,项目名称:quinoa,代码行数:57,代码来源:main.cpp

示例3: err

template <class QMType> inline
void TMPQualityMetricTest<QMType>::test_evaluate_surface()
{
  MsqPrintError err(cout);
  PatchData pd;
  bool rval;
  double value;
  
  QMType m( &surf_target, &faux_pi );
  
    // test with aligned elements
  faux_pi.count = 0;
  tester.get_ideal_element( QUADRILATERAL, true, pd );
  rval = m.evaluate( pd, 0, value, err );
  CPPUNIT_ASSERT(!MSQ_CHKERR(err));
  CPPUNIT_ASSERT(rval);
  CPPUNIT_ASSERT_DOUBLES_EQUAL( faux_pi.value, value, DBL_EPSILON );
  CPPUNIT_ASSERT_EQUAL( 1, faux_pi.count );
  
    // test that columns are orthogonal for ideal quad element
  CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, col_dot_prod(faux_pi.last_A_2D), 1e-6 );
  
    // test with an element rotated about X-axis
  faux_pi.count = 0;
  tester.get_ideal_element( QUADRILATERAL, true, pd );
  // rotate by 90 degrees about X axis
  for (size_t i = 0; i < pd.num_nodes(); ++i) {
    Vector3D orig = pd.vertex_by_index(i);
    Vector3D newp( orig[0], -orig[2], orig[1] );
    pd.set_vertex_coordinates( newp, i, err );
  }
  rval = m.evaluate( pd, 0, value, err );
  CPPUNIT_ASSERT(!MSQ_CHKERR(err));
  CPPUNIT_ASSERT(rval);
  CPPUNIT_ASSERT_DOUBLES_EQUAL( faux_pi.value, value, DBL_EPSILON );
  CPPUNIT_ASSERT_EQUAL( 1, faux_pi.count );
  
    // test with an element rotated about Y-axis
  faux_pi.count = 0;
  tester.get_ideal_element( TRIANGLE, true, pd );
  // rotate by -90 degrees about Y axis
  for (size_t i = 0; i < pd.num_nodes(); ++i) {
    Vector3D orig = pd.vertex_by_index(i);
    Vector3D newp( orig[2], orig[1], -orig[0] );
    pd.set_vertex_coordinates( newp, i, err );
  }
  rval = m.evaluate( pd, 0, value, err );
  CPPUNIT_ASSERT(!MSQ_CHKERR(err));
  CPPUNIT_ASSERT(rval);
  CPPUNIT_ASSERT_DOUBLES_EQUAL( faux_pi.value, value, DBL_EPSILON );
  CPPUNIT_ASSERT_EQUAL( 1, faux_pi.count );
}  
开发者ID:,项目名称:,代码行数:52,代码来源:

示例4: test_vertex_bound

//VERTEX BOUND
void TerminationCriterionTest::test_vertex_bound()
{
  MsqPrintError err(std::cout);
  PatchData pd;
  create_twelve_hex_patch( pd, err );
  ASSERT_NO_ERROR(err);
  
    // get bounding dimension for patch
  double maxcoord = 0.0;
  for (size_t i = 0; i < pd.num_nodes(); ++i) 
    for (int d = 0; d < 3; ++d)
      if (fabs(pd.vertex_by_index(i)[d]) > maxcoord)
        maxcoord = fabs(pd.vertex_by_index(i)[d]);
    // add a little bit for rounding error
  maxcoord += 1e-5;
  
  TerminationCriterion tc;
  tc.add_bounded_vertex_movement( maxcoord );
  tc.reset_inner( pd, ofEval, err );
  ASSERT_NO_ERROR(err);
  tc.reset_patch( pd, err );
  ASSERT_NO_ERROR(err);
  CPPUNIT_ASSERT(!tc.terminate());
  
  int idx = pd.num_free_vertices() - 1;
  Vector3D pos = pd.vertex_by_index(idx);
  pos[0] = 2*maxcoord;
  pd.set_vertex_coordinates( pos, idx, err );
  ASSERT_NO_ERROR(err);
  tc.accumulate_inner( pd, 0.0, 0, err );
  ASSERT_NO_ERROR(err);
  tc.accumulate_patch( pd, err );
  ASSERT_NO_ERROR(err);
  CPPUNIT_ASSERT(tc.terminate());
}
开发者ID:gitter-badger,项目名称:quinoa,代码行数:36,代码来源:TerminationCriterionTest.cpp

示例5: test_get_vertex_evaluations

void PMeanPMetricTest::test_get_vertex_evaluations()
{
  MsqError err;
  FauxMetric m;
  VertexPMeanP e( 1.0, &m );
  std::vector<size_t> handles;
    // test that handles array contains all vertices
  e.get_evaluations( pd, handles, false, err );
  std::sort( handles.begin(), handles.end() );
  CPPUNIT_ASSERT_EQUAL( pd.num_nodes(), handles.size() );
  for (unsigned i = 1; i < handles.size(); ++i)
    CPPUNIT_ASSERT_EQUAL( handles[i-1]+1, handles[i] );
    // test that handles array contains all vertices
  e.get_evaluations( pd, handles, true, err );
  std::sort( handles.begin(), handles.end() );
  CPPUNIT_ASSERT_EQUAL( pd.num_nodes(), handles.size() );
  for (unsigned i = 1; i < handles.size(); ++i)
    CPPUNIT_ASSERT_EQUAL( handles[i-1]+1, handles[i] );
}
开发者ID:haripandey,项目名称:trilinos,代码行数:19,代码来源:PMeanPMetricTest.cpp

示例6: get_nonideal_element

 void get_nonideal_element( EntityTopology type, PatchData& pd )
   {
     tester.get_nonideal_element( type, pd, true );
       // Callers assume surface elements are in XY plane.
       // Verify this assumption.
     if (TopologyInfo::dimension(type) == 2) {
       for (size_t i = 0; i < pd.num_nodes(); ++i) {
         CPPUNIT_ASSERT_DOUBLES_EQUAL( pd.vertex_by_index(i)[2], 0.0, 1e-6 );
       }
     }
   }
开发者ID:,项目名称:,代码行数:11,代码来源:

示例7: step

void EdgeIterator::step( MsqError& err )
{
  if (adjIter != adjList.end())
  {
    ++adjIter;
  }
  
  while (adjIter == adjList.end() && ++vertIdx < patchPtr->num_nodes())
  {
    get_adjacent_vertices( err );  MSQ_ERRRTN(err);
  }
}
开发者ID:bartlettroscoe,项目名称:trilinos_old_public,代码行数:12,代码来源:Mesquite_EdgeIterator.hpp

示例8: optimize_vertex_positions

void NonSmoothDescent::optimize_vertex_positions(PatchData &pd, 
                                                MsqError &err)
{
  MSQ_FUNCTION_TIMER( "NonSmoothDescent" );

  //  cout << "- Executing NonSmoothDescent::optimize_node_positions()\n";
  /* perform the min max smoothing algorithm */
  MSQ_PRINT(2)("\nInitializing the patch iteration\n");

  MSQ_PRINT(3)("Number of Vertices: %d\n",(int)pd.num_nodes());
  MSQ_PRINT(3)("Number of Elements: %d\n",(int)pd.num_elements());
    //Michael: Note: is this a reliable way to get the dimension?
  mDimension = pd.get_mesh()->get_geometric_dimension(err); MSQ_ERRRTN(err);
  MSQ_PRINT(3)("Spatial Dimension: %d\n",mDimension);

  MSQ_PRINT(3)("Num Free = %d\n",(int)pd.num_free_vertices());

  MsqFreeVertexIndexIterator free_iter(pd, err); MSQ_ERRRTN(err);
  free_iter.reset();
  free_iter.next(); 
  freeVertexIndex = free_iter.value();
  MSQ_PRINT(3)("Free Vertex Index = %d\n",freeVertexIndex);

  // TODO - need to switch to validity via metric evaluations should
  // be associated with the compute_function somehow
  /* check for an invalid mesh; if it's invalid return and ask the user 
     to use untangle */
  if (this->validity_check(pd,err)!=1) {
      MSQ_PRINT(1)("ERROR: Invalid mesh\n");
      MSQ_SETERR(err)("Invalid Mesh: Use untangle to create a valid "
                      "triangulation", MsqError::INVALID_MESH);
      return;
  }

  /* assumes one function value per element */
  // TODO - need to include vertex metrics 
  numFunctionValues = pd.num_elements();

  /* initialize the optimization data up to numFunctionValues */
  this->init_opt(err); MSQ_ERRRTN(err);
  this->init_max_step_length(pd,err);  MSQ_ERRRTN(err);
  MSQ_PRINT(3)("Done initializing optimization\n");

  /* compute the initial function values */
  //TODO this should return a bool with the validity
  this->compute_function(&pd, originalFunction, err);  MSQ_ERRRTN(err);
 
  // find the initial active set
  this->find_active_set(originalFunction, mActive, err);   MSQ_ERRRTN(err);

  this->minmax_opt(pd,err);  MSQ_ERRRTN(err);
}
开发者ID:haripandey,项目名称:trilinos,代码行数:52,代码来源:NonSmoothDescent.cpp

示例9: optimize_vertex_positions

void TCTFauxOptimizer::optimize_vertex_positions( PatchData& pd, MsqError& err )
{
  Mesh::VertexHandle free_vtx = pd.get_vertex_handles_array()[0];
  if (visited.insert(free_vtx).second == false) { // already visited this one
    // The inner termination criterion should include an iteration limit of 1.
    // So if we are seeing the same vertex again, this means that we *should*
    // be stating a new pass over the mesh.
  
    // We are presumably starting a new pass over the mesh.
    // Verify that we visisted all of the free, non-culled vertices
    for (size_t i = 0; i < all.size(); ++i) {
      if (culled.find(all[i]) == culled.end()) {
        if (visited.find(all[i]) == visited.end()) {
          std::ostringstream str;
          str << "Did not visit vertex " << i << " (handle " << all[i] << ") in pass " << numPasses << std::endl;
          CPPUNIT_FAIL( str.str() );
        }
      }
    }
    visited.clear();
    visited.insert(free_vtx);
    ++numPasses;
    
    // Check that we terminate when expected
    CPPUNIT_ASSERT(!should_have_terminated());
    
    perturbFrac *= 2; // for each pass, perturb half as many vertices
  }
  
    // check that we are not visiting a culled vertex
  CPPUNIT_ASSERT( culled.find(free_vtx) == culled.end() );
  
    // for each pass, perturb half as many vertices
  size_t idx = std::find( all.begin(), all.end(), free_vtx ) - all.begin();
  CPPUNIT_ASSERT( idx < all.size() ); // not a free vertex????
  if (0 == ((idx+1) % perturbFrac)) {
      // perturb vertex
    double sign = numPasses % 2 == 0 ? 1 : -1;
    Vector3D delta( sign * mDelta, 0, 0 );
    pd.move_vertex( delta, 0, err ); 
    ASSERT_NO_ERROR(err);
      // any adjacent vertices should not be culled
    for (size_t i = 0; i < pd.num_nodes(); ++i)
      culled.erase( pd.get_vertex_handles_array()[i] );
  }
  else {  
      // If we're not moving this vertex, then it should get culled
    culled.insert( free_vtx );
  }
}
开发者ID:gitter-badger,项目名称:quinoa,代码行数:50,代码来源:TerminationCriterionTest.cpp

示例10: move_vertex

 inline void move_vertex( PatchData& pd, 
                          const Vector3D& position,
                          const Vector3D& delta,
                          MsqError& err )
 {
   const MsqVertex* array = pd.get_vertex_array( err ); 
   if (err) return;
   
   int idx = 0, cnt = 0;
   for (size_t i = 0; i < pd.num_nodes(); ++i)
     if ((array[i] - position).length_squared() < DBL_EPSILON) 
       { idx = i; ++cnt; }
   
   CPPUNIT_ASSERT_EQUAL( cnt, 1 );
   
   pd.move_vertex( delta, idx, err );
 }
开发者ID:bddavid,项目名称:mesquite,代码行数:17,代码来源:PatchDataInstances.hpp

示例11: test_hex_vertices

  void test_hex_vertices()
  {
    MsqPrintError err(cout);
    // prints out the vertices.
    const MsqVertex* ideal_vertices = oneHexPatch.get_vertex_array(err); CPPUNIT_ASSERT(!err);
    size_t num_vtx = oneHexPatch.num_nodes();
    CPPUNIT_ASSERT_EQUAL(size_t(8), num_vtx);
    
    MsqVertex vtx;

    vtx.set(1,1,1);
    CPPUNIT_ASSERT_EQUAL(vtx, ideal_vertices[0]);
    
    vtx.set(2,2,2);
    CPPUNIT_ASSERT_EQUAL(vtx, ideal_vertices[6]);
    
    vtx.set(1,2,2);
    CPPUNIT_ASSERT_EQUAL(vtx, ideal_vertices[7]);
  }
开发者ID:gitter-badger,项目名称:quinoa,代码行数:19,代码来源:MsqMeshEntityTest.cpp

示例12: directions

/*!Function calculates a scale factor for the patch, then moves
  the incident vertex randomly in each of the three coordinate
  directions (relative to the scale factor multiplied by mPercent).
*/
static inline void randomize_vertex(PatchData &pd,
                                    size_t free_ind,
                                    double percent,
                                    MsqError &err)
{
    size_t i;
    short j;
    const MsqVertex* verts = pd.get_vertex_array(err);
    MSQ_ERRRTN(err);
    const size_t num_vtx = pd.num_nodes();
    //a scale w.r.t. the patch size
    double scale_factor=0.0;
    //a "random" number between -1 and 1
    double rand_double=0.0;
    //a "random" int
    int rand_int=0;
    if (num_vtx<=1) {
        MSQ_PRINT(1)("WARNING: Number of incident vertex is zero.  Returning.\n");
        return;
    }

    for (i=0; i<num_vtx; ++i) {
        if(i != free_ind)
            scale_factor+=(verts[i]-verts[free_ind]).length();
    }
    scale_factor/=( (double) num_vtx - 1.0 );
    Vector3D delta;
    for (j=0; j<3; ++j) {
        rand_int = rand();
        //number between 0 and 1000
        rand_int = rand_int%1000;
        //number between -1 and 1
        rand_double = (((double) rand_int)/500.0)-1.0;
        delta[j] = scale_factor * rand_double * percent;
    }
    pd.move_vertex( delta, free_ind, err );

    return;
}
开发者ID:haripandey,项目名称:trilinos,代码行数:43,代码来源:Randomize.cpp

示例13: get_edge_evaluations

void EdgeQM::get_edge_evaluations( PatchData& pd, 
                                   std::vector<size_t>& handles,
                                   bool free_vertices_only, 
                                   bool single_pass_evaluate,
                                   MsqError& err )
{
  std::vector<EdgeData> vtx_edges;
  size_t n_verts = free_vertices_only ? pd.num_free_vertices() : pd.num_nodes();
  size_t n_cutoff = single_pass_evaluate ? pd.num_nodes() : n_verts;
  handles.clear();

  for (size_t i = 0; i < n_verts; ++i) {
    if (!pd.vertex_by_index(i).is_flag_set( MsqVertex::MSQ_PATCH_VTX ))
      continue;

    vtx_edges.clear();

    size_t n_elems;
    const size_t* elems;
    elems = pd.get_vertex_element_adjacencies( i, n_elems, err );
    MSQ_ERRRTN(err);

    for (size_t j = 0; j < n_elems; ++j) {
      MsqMeshEntity& elem = pd.element_by_index(elems[j]);
      unsigned n_edges = TopologyInfo::edges( elem.get_element_type() );
      for (unsigned k = 0; k < n_edges; ++k) {
        const unsigned* edge = TopologyInfo::edge_vertices( elem.get_element_type(), k, err );
        MSQ_ERRRTN(err);

        size_t vtx1 = elem.get_vertex_index_array()[edge[0]];
        size_t vtx2 = elem.get_vertex_index_array()[edge[1]];
        size_t other;
        if (vtx1 == i)
          other = vtx2;
        else if (vtx2 == i)
          other = vtx1;
        else
          continue;
        
          // If !free_vertices_only, we'll visit every edge twice.  
          // The first check below ensures that we only add each edge
          // once.  The second check is never true unless free_vertices_only
          // is true and single_pass_evaluate is false.  In that case, it 
          // serves as an exception to the first rule for those cases in which 
          // we visit an edge only once.  For single_pass_evaluate (e.g.
          // BCD initialization or QualityAssessor) we want to avoid visiting
          // and edge more than once for every patch rather than just within
          // this patch.
        if (other > i || other > n_cutoff) {
          EdgeData d = { other, elems[j], k };
          vtx_edges.push_back(d);
        }
      } // end for each edge in element
    } // end for each element adjacent to vertex
    
    std::sort( vtx_edges.begin(), vtx_edges.end() );
    std::vector<EdgeData>::iterator it, end;
    end = std::unique( vtx_edges.begin(), vtx_edges.end() );
    for (it = vtx_edges.begin(); it != end; ++it) 
      handles.push_back( handle( it->elemEdge, it->adjElem ) );
  } // end for each (free) vertex
}
开发者ID:haripandey,项目名称:trilinos,代码行数:62,代码来源:EdgeQM.cpp

示例14: is_at_end

bool EdgeIterator::is_at_end() const
{
  return vertIdx >= patchPtr->num_nodes();
}
开发者ID:bartlettroscoe,项目名称:trilinos_old_public,代码行数:4,代码来源:Mesquite_EdgeIterator.hpp

示例15:

const Vector3D* EdgeIterator::mid() const
  { return adjIter->midVertex < patchPtr->num_nodes() ? 
           &patchPtr->vertex_by_index( adjIter->midVertex ) : 0; }
开发者ID:bartlettroscoe,项目名称:trilinos_old_public,代码行数:3,代码来源:Mesquite_EdgeIterator.hpp


注:本文中的PatchData::num_nodes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。