Example #1
0
void load_fields_from_fft(const CH_FFT& fft , Triangulation& T  ) {

  int Nb = fft.Nx();

  c_array vx = fft.field_vel_x();
  c_array vy = fft.field_vel_y();
  c_array al = fft.field_f();

  for(F_v_it vit=T.vertices_begin();
      vit != T.vertices_end();
      vit++) {

    int nx = vit->nx.val();
    int ny = vit->ny.val();

    // "right" ordering 
    int i = ( Nb - 1 ) - ny ;
    int j = nx;

    // "wrong" ordering
    // int i = nx;
    // int j = ny;

    vit->U.set( Vector_2( real(vx(i,j)) , real(vy(i,j)) ) );

    vit->alpha.set( real( al(i,j) ) );

    //  TODO: return more fields (chem pot, pressure, force, etc)
  }

  return;
}
Example #2
0
void load_alpha_on_fft( const Triangulation& T , CH_FFT& fft  ) {

  int Nb = fft.Nx();

  size_t align=fft.alignment();

  c_array al( Nb , Nb , align );

  for(F_v_it vit=T.vertices_begin();
      vit != T.vertices_end();
      vit++) {

    int nx = vit->nx.val();
    int ny = vit->ny.val();

    // "right" ordering 
    int i = ( Nb - 1 ) - ny ;
    int j = nx;

    // "wrong" ordering
    // int i = nx;
    // int j = ny;
    
    FT val =  vit->alpha0.val();
    //FT val =  vit->alpha.val();

    al(i,j) = val;

  }

  fft.set_f( al );
  
  return;
}
void load_fields_on_fft( const Triangulation& T , CH_FFT& fft  ) {

  int Nb = fft.Nx();

  size_t align=fft.alignment();

  c_array u0x( Nb , Nb , align );
  c_array u0y( Nb , Nb , align );

  // fully implicit
  c_array uux( Nb , Nb , align );
  c_array uuy( Nb , Nb , align );

  for(F_v_it vit=T.vertices_begin();
      vit != T.vertices_end();
      vit++) {

    int nx = vit->nx.val();
    int ny = vit->ny.val();

    // "right" ordering 
    int i = ( Nb - 1 ) - ny ;
    int j = nx;

    // "wrong" ordering
    // int i = nx;
    // int j = ny;
    
    Vector_2 v0 =  vit->Uold.val();
    u0x(i,j) = v0.x();
    u0y(i,j) = v0.y();

    // fully implicit
    //Vector_2 vv =  vit->U.val();
    //uux(i,j) = vv.x();
    //uuy(i,j) = vv.y();


    //FT val =  vit->alpha.val();



  }

  fft.set_u( u0x , u0y );

  // fully implicit
  // hack force field to store current velocity
  //  fft.set_force( uux , uuy );
  
  return;
}
Example #4
0
void number(Triangulation& T) {

  int i=0;

  for(F_v_it vit=T.vertices_begin();
      vit != T.vertices_end();
      vit++) {
    //    vit->indx.set(i); //or
    vit->idx=i;
    ++i;
  }

  return;
}
Example #5
0
void number(Triangulation& T) {

  int idx=0;

  int N=simu.no_of_particles();

  int Nb=sqrt(N + 1e-12);
    
  FT spacing=LL/FT(Nb+0);
  FT side=LL-1*spacing;

  
  for(F_v_it vit=T.vertices_begin();
      vit != T.vertices_end();
      vit++) {
    //    vit->indx.set(i); //or
    vit->idx = idx;

    FT x = vit->point().x() + side/2.0;
    FT y = vit->point().y() + side/2.0;

    int i = rint(  FT(Nb) * x / LL );//+ 0.5);
    int j = rint(  FT(Nb) * y / LL );//+ 0.5);

    //    --i; --j;
    
    vit->nx = i;
    vit->ny = j;

    // cout << idx
    // 	 << "  " << i
    //   	 << "  " << j
    //   	 << "  " << x
    //   	 << "  " << y
    // 	 << endl;


    ++idx;

  }

  return;
}
void clone(const Triangulation& Tfrom,Triangulation& Tto) {

  for(F_v_it vit=Tfrom.vertices_begin();
      vit != Tfrom.vertices_end();
      vit++) {

    Periodic_point pp=Tfrom.periodic_point(vit);
    Point p=Tfrom.point(pp);

    Vertex_handle fv=Tto.insert( p );

    fv->rold.set( p );

    fv->U.set( vit->U.val() );
    fv->Uold.set( vit->U.val() );

    fv->idx.set( vit->idx.val() );

  }      

  return;
  
}
Example #7
0
void load_fields_on_fft( const Triangulation& T , CH_FFT& fft  ) {

  int Nb = fft.Nx();

  size_t align=fft.alignment();

  c_array ux( Nb , Nb , align );
  c_array uy( Nb , Nb , align );

  for(F_v_it vit=T.vertices_begin();
      vit != T.vertices_end();
      vit++) {

    int nx = vit->nx.val();
    int ny = vit->ny.val();

    // "right" ordering 
    int i = ( Nb - 1 ) - ny ;
    int j = nx;

    // "wrong" ordering
    // int i = nx;
    // int j = ny;
    
    Vector_2 vv =  vit->Uold.val();
    //FT val =  vit->alpha.val();

    ux(i,j) = vv.x();
    uy(i,j) = vv.y();

  }

  fft.set_u( ux , uy );
  
  return;
}
int main()
{
  Triangulation t;

  Vector midpoint(0.5, 0.5);

  Face_handle fh;
  Triangulation::Locate_type lt;
  int i;
  fh = t.locate(Point(0, 0) + midpoint, lt, i);
  CGAL_assertion(lt == Triangulation::EMPTY);

  Vertex_handle vh_midpoint = t.insert(Point(0, 0) + midpoint);
  fh = t.locate(Point(0, 0) + midpoint, lt, i);
  CGAL_assertion(lt == Triangulation::VERTEX && fh->vertex(i) == vh_midpoint);
  t.remove(vh_midpoint);
  CGAL_assertion(t.empty());

  // High degree vertex
  for (int n = 3; n < 8; ++n)
    {
      vh_midpoint = t.insert(Point(0, 0) + midpoint);
      for (int i = 0; i < n; ++i)
        {
          t.insert(Point(0.3 * sin(i * 1.0 / n * 2 * M_PI), 0.3 * cos(i * 1.0 / n * 2 * M_PI)) + midpoint);
        }
      t.remove(vh_midpoint);
      CGAL_assertion(t.is_valid(true));
      while (!t.empty())
        {
          t.remove(t.vertices_begin());
          CGAL_assertion(t.is_valid(true));
        }
    }

  Random random(1284141159);
  std::cout << "Seed: " << random.get_seed () << std::endl;
  Random_points_in_square g(0.495, random);

  CGAL_assertion(t.is_valid());

  std::cout << "Removing first point" << std::endl;
  Vertex_handle vh0 = t.insert(Point(0.5, 0.5));
  CGAL_assertion(t.is_valid());
  t.remove(vh0);
  CGAL_assertion(t.is_valid());
  CGAL_assertion(t.empty());

  {
    Random random(1284141159);
    std::cout << "Seed: " << random.get_seed () << std::endl;

    Random_points_in_square g(0.495, random);
    Vector midpoint(0.5, 0.5);

    Triangulation t;
    CGAL_assertion(t.is_valid());

    std::cout << "Removing first point" << std::endl;
    Vertex_handle vh0 = t.insert(Point(0.5, 0.5));
    CGAL_assertion(t.is_valid());
    t.remove(vh0);
    CGAL_assertion(t.is_valid());
    CGAL_assertion(t.empty());

    std::cout << "Inserting random points and removing them." << std::endl;

    for (int i = 0; i < N_PTS; ++i)
      {
        t.insert(*(++g) + midpoint);
      }
    CGAL_assertion(t.is_valid());

    for (int i = 0; i < N_PTS; ++i)
      {
        // Find a random vertex
        Vertex_handle vh = t.locate(*(++g) + midpoint)->vertex(0);
        vh = t.get_original_vertex(vh);
        t.remove(vh);
        CGAL_assertion(t.is_valid());
      }
  }
  return 0;
}