コード例 #1
0
void to_hex(std::ostream& out, BinarySequence::const_iterator begin, BinarySequence::const_iterator end) {
    boost::io::ios_flags_saver save1(out);
    boost::io::ios_width_saver save2(out);
    boost::io::ios_precision_saver save3(out);
    out << std::hex << std::setw(1) << std::setprecision(1);
    while(end - begin >= 4) {
        int x = 0;
        for(int i=0; i<4; ++i) {
            x |= begin.pop<bool>() << i;
        }
        out << x;
    }
}
コード例 #2
0
void save_and_load3(
    boost::shared_ptr<A>& first, 
    boost::shared_ptr<A>& second,
    boost::weak_ptr<A>& third
){
    const char * testfile = boost::archive::tmpnam(NULL);
    BOOST_REQUIRE(NULL != testfile);

    save3(testfile, first, second, third);

    // Clear the pointers, thereby destroying the objects they contain
    first.reset();
    second.reset();
    third.reset();

    load3(testfile, first, second, third);

    BOOST_CHECK(first == second);
    BOOST_CHECK(first == third.lock());
    std::remove(testfile);
}
コード例 #3
0
int main(int argc, char **argv)
{
 PetscInitialize(&argc, &argv, PETSC_NULL, PETSC_NULL);

 int iter = 1;
 double Re = 1;
 double cfl = 10;
 double mu_l = 1.0;
 double rho_l = 1.0;
 //Solver *solverP = new PetscSolver(KSPPREONLY,PCNONE);
 Solver *solverP = new PetscSolver(KSPCG,PCSOR);
 Solver *solverV = new PetscSolver(KSPCG,PCICC);

 const char *binFolder  = "./bin/";
 const char *datFolder  = "./dat/";
 const char *vtkFolder  = "./vtk/";
 const char *simFolder  = "./sim/";

 string meshFile = "disk6-10-20.vtk";
 string meshDir = (string) getenv("DATA_DIR");
 meshDir += "/mesh/3d/" + meshFile;
 const char *mesh = meshDir.c_str();

 Model3D m1;
 m1.setMeshDisk(6,10,10);
 m1.setAdimenDisk();
 m1.setMapping();
#if NUMGLEU == 5
 m1.setMiniElement();
#else
 m1.setQuadElement();
#endif

 m1.setNeighbour();
 m1.setTriEdge();
 m1.setMapEdgeTri();
 m1.setInitSurfaceArea();
 m1.setSurfaceArea();
 m1.setInitSurfaceVolume();
 m1.setSurfaceVolume();
 m1.tetMeshStats();

 Model3D mOld = m1;
 // F, G and H
 m1.setInfiniteSphereBC(0.0,0.0,0.0);
 //m1.setCDiskBC();

 InOut save2(m1); // cria objeto de gravacao
 save2.saveVTK(vtkFolder,"disk");
  
 m1.transformDiskToSphere();

 InOut save3(m1); // cria objeto de gravacao
 save3.saveVTK(vtkFolder,"sphere");

 Simulator3D s1(m1);

 s1.setRe(Re);
 s1.setCfl(cfl);
 s1.setMu(mu_l);
 s1.setRho(rho_l);
 s1.setSolverVelocity(solverV);
 s1.setSolverPressure(solverP);

 s1.init();
 //s1.initDiskBaseState("../../db/baseState/nuCte/","analiticoNuCte.dat");

 s1.setDtEulerian();
 s1.assembleNuCte();
 //s1.assembleC();
 s1.matMount();
 //s1.matMountC();
 s1.setUnCoupledBC(); 
 //s1.setUnCoupledCBC(); 
 
 if( (*(argv+1)) == NULL )
 {
  cout << endl;
  cout << "--------------> STARTING FROM 0" << endl;
  cout << endl;
 }
 else if( strcmp( *(argv+1),"restart") == 0 )
 {
  cout << endl;
  cout << "--------------> RE-STARTING..." << endl;
  cout << endl;

  iter = s1.loadSolution("./","sim",atoi(*(argv+2)));
 }

 InOut save(m1,s1); // cria objeto de gravacao
 save.saveVTK(vtkFolder,"geometry");
 save.saveInfo("./","info",mesh);
 save.printSimulationReport();

 int nIter = 1000;
 int nR = 10;
 for( int i=0;i<nIter;i++ )
 {
  for( int j=0;j<nR;j++ )
  {
   cout << color(none,magenta,black);
   cout << "____________________________________ Iteration: "
	    << i*nR+j+iter << endl << endl;
   cout << resetColor();

   /* dt variable */
   //s1.setDtEulerian();
   //s1.assembleNuCte();
   ////s1.assembleC();
   //s1.matMount();
   ////s1.matMountC();
   //s1.setUnCoupledBC(); 
   //s1.setUnCoupledCBC(); 

   s1.stepSL();
   s1.setRHS();
   //s1.setCRHS();
   s1.unCoupled();
   //s1.unCoupledC();
   save.saveVonKarman(mOld,simFolder,"vk");
//--------------------------------------------------
//    save.saveDiskRadiusError(simFolder,
// 	                        "vkError",
// 							"../../db/baseState/nuCte/analiticoNuCte.dat");
//    save.saveDiskError(datFolder,
// 	                  "diskError",
// 					  "../../db/baseState/nuCte/analiticoNuCte.dat");
//-------------------------------------------------- 
   save.saveConvergence(datFolder,"convergence");

   s1.saveOldData();

   s1.timeStep();

   cout << color(none,magenta,black);
   cout << "________________________________________ END of "
	    << i*nR+j+iter << endl << endl;;
   cout << resetColor();
  }
  save.saveVTK(vtkFolder,"sim",(i+1)*nR+iter-1);
  //save.saveVTKSurface(vtkFolder,"sim",(nR-1)+i*nR+iter-1);
  save.saveSol(binFolder,"sim",(i+1)*nR+iter-1);
  save.printMeshReport();
  save.saveMeshInfo(datFolder);
 }

 PetscFinalize();
 return 0;
}