Ejemplo n.º 1
0
void Domain::build( Params &params, SmileiMPI *smpi, VectorPatch &vecPatches, OpenPMDparams &openPMD )
{
    decomposition_ = DomainDecompositionFactory::createGlobal( params );
    patch_ = PatchesFactory::create( params, smpi, decomposition_, vecPatches.refHindex_ / vecPatches.size() );
    patch_->set( params, decomposition_, vecPatches );
    vecPatch_.patches_.push_back( patch_ );
    
    vecPatch_.refHindex_ = vecPatches.refHindex_ / vecPatches.size();
    vecPatch_.update_field_list( smpi );
    
    //vecPatch_.update_field_list(0, smpi);
    vecPatch_.patches_[0]->finalizeMPIenvironment( params );
    vecPatch_.nrequests = vecPatches( 0 )->requests_.size();
    vecPatch_.nAntennas = vecPatch_( 0 )->EMfields->antennas.size();
    vecPatch_.initExternals( params );
    
    /*    if ( params.nDim_field == 1 )
            diag_ = new DiagnosticFields1D( params, smpi, vecPatch_, 0, openPMD );
        else if ( params.nDim_field == 2 )
            diag_ = new DiagnosticCartFields2D( params, smpi, vecPatch_, 0, openPMD );
        else if ( params.nDim_field == 3 )
            diag_ = new DiagnosticCartFields3D( params, smpi, vecPatch_, 0, openPMD );
    
        for (unsigned int ifield=0 ; ifield<vecPatch_(0)->EMfields->Jx_s.size(); ifield++) {
            if( vecPatch_(0)->EMfields->Jx_s[ifield]->data_ == NULL ){
                delete vecPatch_(0)->EMfields->Jx_s[ifield];
                vecPatch_(0)->EMfields->Jx_s[ifield]=NULL;
            }
        }
        for (unsigned int ifield=0 ; ifield<vecPatch_(0)->EMfields->Jy_s.size(); ifield++) {
            if( vecPatch_(0)->EMfields->Jy_s[ifield]->data_ == NULL ){
                delete vecPatch_(0)->EMfields->Jy_s[ifield];
                vecPatch_(0)->EMfields->Jy_s[ifield]=NULL;
            }
        }
        for (unsigned int ifield=0 ; ifield<vecPatch_(0)->EMfields->Jz_s.size(); ifield++) {
            if( vecPatch_(0)->EMfields->Jz_s[ifield]->data_ == NULL ){
                delete vecPatch_(0)->EMfields->Jz_s[ifield];
                vecPatch_(0)->EMfields->Jz_s[ifield]=NULL;
            }
        }
        for (unsigned int ifield=0 ; ifield<vecPatch_(0)->EMfields->rho_s.size(); ifield++) {
            if( vecPatch_(0)->EMfields->rho_s[ifield]->data_ == NULL ){
                delete vecPatch_(0)->EMfields->rho_s[ifield];
                vecPatch_(0)->EMfields->rho_s[ifield]=NULL;
            }
        }
    
        diag_->init( params, smpi, vecPatch_ );
        diag_->theTimeIsNow = diag_->prepare( 0 );
        //if ( diag_->theTimeIsNow )
        //    diag_->run( smpi, vecPatch_, 0, simWindow );
    
    */
    
    if( params.is_pxr ) {
        vecPatch_( 0 )->EMfields->MaxwellAmpereSolver_->coupling( params, vecPatch_( 0 )->EMfields );
    }
}
Ejemplo n.º 2
0
void Checkpoint::dumpAll( VectorPatch &vecPatches, unsigned int itime,  SmileiMPI* smpi, SimWindow* simWin,  Params &params )
{

    hid_t sid, aid, tid;
		
    /*ostringstream nameDump("");
    nameDump << "dump-" << setfill('0') << setw(4) << dump_times%dump_file_sequence << "-" << setfill('0') << setw(4) << smpi->getRank() << ".h5" ;
    fid = H5Fcreate( nameDump.str().c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);*/
    unsigned int num_dump=dump_times%dump_file_sequence;
    
    hid_t fid = H5Fcreate( dumpName(num_dump,smpi).c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
    dump_times++;

    MESSAGEALL("Step " << itime << " : DUMP fields and particles " << dumpName(num_dump,smpi));    

    H5::attr(fid, "Version", string(__VERSION));
    //H5::attr(fid, "CommitDate", string(__COMMITDATE));
    
    H5::attr(fid, "dump_step", itime);
    
    H5::attr(fid, "Energy_time_zero",  static_cast<DiagnosticScalar*>(vecPatches.globalDiags[0])->Energy_time_zero );
    H5::attr(fid, "EnergyUsedForNorm", static_cast<DiagnosticScalar*>(vecPatches.globalDiags[0])->EnergyUsedForNorm);

    for (unsigned int ipatch=0 ; ipatch<vecPatches.size(); ipatch++) {

	// Open a group
	ostringstream patch_name("");
	patch_name << setfill('0') << setw(6) << vecPatches(ipatch)->Hindex();
	string patchName="patch-"+patch_name.str();
	hid_t patch_gid = H5Gcreate(fid, patchName.c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);

	dumpPatch( vecPatches(ipatch)->EMfields, vecPatches(ipatch)->vecSpecies, patch_gid );

	// Close a group
	H5Gclose(patch_gid);

    }

    // Dump moving window status
    if (simWin!=NULL)
	dumpMovingWindow(fid, simWin);

    H5Fclose( fid );
	
}
Ejemplo n.º 3
0
void Checkpoint::restartAll( VectorPatch &vecPatches, unsigned int &itime,  SmileiMPI* smpi, SimWindow* simWin, Params &params )
{ 
	
     string nameDump("");
	
     // This will open both dumps and pick the last one
     for (unsigned int num_dump=0;num_dump<dump_file_sequence; num_dump++) {
	 //ostringstream nameDumpTmp("");
	 //nameDumpTmp << "dump-" << setfill('0') << setw(4) << i << "-" << setfill('0') << setw(4) << smpi->getRank() << ".h5" ;
	 //ifstream f(nameDumpTmp.str().c_str());
         string dump_name=restart_dir+dumpName(num_dump,smpi);
         ifstream f(dump_name.c_str());
	 if (f.good()) {
	     hid_t fid = H5Fopen( dump_name.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);			
	     hid_t aid = H5Aopen(fid, "dump_step", H5T_NATIVE_UINT);
	     unsigned int itimeTmp=0;
	     H5Aread(aid, H5T_NATIVE_UINT, &itimeTmp);	
	     H5Aclose(aid);
	     H5Fclose(fid);
	     if (itimeTmp>itime) {
                 this_run_start_step=itimeTmp;
		 itime=itimeTmp;
		 nameDump=dump_name.c_str();
		 dump_times=num_dump;
	     }
	 }
	 f.close();
     }
	
     if (nameDump.empty()) ERROR("Cannot find a valid restart file");
	
     MESSAGEALL(2, " : Restarting fields and particles " << nameDump << " step=" << this_run_start_step);

     hid_t fid = H5Fopen( nameDump.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
     if (fid < 0) ERROR(nameDump << " is not a valid HDF5 file");
    
     string dump_version;
     H5::getAttr(fid, "Version", dump_version);
    
     string dump_date;
     H5::getAttr(fid, "CommitDate", dump_date);

     if ((dump_version != string(__VERSION)) || (dump_date != string(__COMMITDATE))) {
         WARNING ("The code version that dumped the file is " << dump_version << " of " << dump_date);
         WARNING ("                while running version is " << string(__VERSION) << " of " << string(__COMMITDATE));
     }

     H5::getAttr(fid, "Energy_time_zero",  static_cast<DiagnosticScalar*>(vecPatches.globalDiags[0])->Energy_time_zero );
     H5::getAttr(fid, "EnergyUsedForNorm", static_cast<DiagnosticScalar*>(vecPatches.globalDiags[0])->EnergyUsedForNorm);
	
     hid_t aid, gid, did, sid;
	
     aid = H5Aopen(fid, "dump_step", H5T_NATIVE_UINT);
     H5Aread(aid, H5T_NATIVE_UINT, &itime);	
     H5Aclose(aid);



     for (unsigned int ipatch=0 ; ipatch<vecPatches.size(); ipatch++) {

	ostringstream patch_name("");
	patch_name << setfill('0') << setw(6) << vecPatches(ipatch)->Hindex();
	string patchName="patch-"+patch_name.str();
	hid_t patch_gid = H5Gopen(fid, patchName.c_str(),H5P_DEFAULT);

	restartPatch( vecPatches(ipatch)->EMfields, vecPatches(ipatch)->vecSpecies, params, patch_gid );

	H5Gclose(patch_gid);

     }
	
     // load window status
     if (simWin!=NULL)
	 restartMovingWindow(fid, simWin);

     H5Fclose( fid );
 };