Skip to content

Commit

Permalink
Fix for #681 and #682
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederic Perez committed Jan 18, 2024
1 parent adcb03f commit 12dd7db
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 24 deletions.
14 changes: 11 additions & 3 deletions src/Diagnostic/DiagnosticFields.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,11 @@ DiagnosticFields::DiagnosticFields( Params &params, SmileiMPI *smpi, VectorPatch
for( unsigned int ipatch=0 ; ipatch<vecPatches.size() ; ipatch++ ) {
vecPatches( ipatch )->EMfields->allFields_avg.resize( diag_n+1 );
if( time_average > 1 ) {
for( unsigned int ifield=0; ifield<fields_names.size(); ifield++ )
for( unsigned int ifield=0; ifield<fields_names.size(); ifield++ ) {
vecPatches( ipatch )->EMfields->allFields_avg[diag_n].push_back(
vecPatches( ipatch )->EMfields->createField( fields_names[ifield], params )
);
}
}
}
}
Expand Down Expand Up @@ -333,9 +334,16 @@ void DiagnosticFields::run( SmileiMPI *smpi, VectorPatch &vecPatches, int itime,
// Write
H5Write dset = writeField( iteration_group_, fields_names[ifield] );
// Attributes for openPMD
Field *f = vecPatches( 0 )->EMfields->allFields[fields_indexes[ifield]];
vector<double> stagger( f->dims().size() );
for( unsigned int i = 0; i < stagger.size(); i++ ) {
stagger[i] = 0.5 * (double) f->isDual(i);
}
bool ends_with_m = 0 == fields_names[ifield].compare( fields_names[ifield].length()-2, 2, "_m" );
double stagger_t = ends_with_m ? vecPatches( 0 )->EMfields->timestep*0.5 : 0.;
openPMD_->writeFieldAttributes( dset, subgrid_start_, subgrid_step_ );
openPMD_->writeRecordAttributes( dset, field_type[ifield] );
openPMD_->writeFieldRecordAttributes( dset );
openPMD_->writeRecordAttributes( dset, field_type[ifield], stagger_t );
openPMD_->writeFieldRecordAttributes( dset, stagger );
openPMD_->writeComponentAttributes( dset, field_type[ifield] );
}
#pragma omp barrier
Expand Down
4 changes: 0 additions & 4 deletions src/ElectroMagn/ElectroMagn.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ class ElectroMagn
//! Number of elements in arrays without duplicated borders
unsigned int bufsize[3][2];

//!\todo should this be just an integer???
//! Oversize domain to exchange less particles (from params)
std::vector<unsigned int> oversize;

Expand Down Expand Up @@ -380,9 +379,6 @@ class ElectroMagn
cField *p_AM_;
cField *Ap_AM_;

//! \todo check time_dual or time_prim (MG)
// //! method used to solve Maxwell's equation (takes current time and time-step as input parameter)
// virtual void solveMaxwellAmpere() = 0;
//! Maxwell Ampere Solver
Solver *MaxwellAmpereSolver_;
//! Maxwell Faraday Solver
Expand Down
1 change: 0 additions & 1 deletion src/Field/Field.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ class Field
virtual void shift_x( unsigned int delta ) = 0;

//! vector containing the dimensions of the Field
//! \todo private/friend/modify (JD)
std::vector<unsigned int> dims_;

//! keep track ofwich direction of the Field is dual
Expand Down
18 changes: 7 additions & 11 deletions src/Params/OpenPMDparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,12 @@ OpenPMDparams::OpenPMDparams( Params &p ):

// Grid parameters
string xyz = "xyz";
gridGlobalOffset.resize( params->nDim_field );
gridOffset .resize( params->nDim_field );
position .resize( params->nDim_field );
gridGlobalOffset.resize( params->nDim_field, 0. );
gridOffset .resize( params->nDim_field, 0. );
gridSpacing .resize( params->nDim_field );
for( unsigned int idim=0; idim<params->nDim_field; idim++ ) {
axisLabels.addString( xyz.substr( idim, 1 ) );
gridGlobalOffset[idim] = 0.;
gridOffset [idim] = 0.;
position [idim] = 0.;
gridSpacing [idim] = params->cell_length[idim];
gridSpacing[idim] = params->cell_length[idim];
}
fieldSolverParameters = "";
if( params->maxwell_sol == "Yee" ) {
Expand Down Expand Up @@ -192,15 +188,15 @@ void OpenPMDparams::writeSpeciesAttributes( H5Write & )
{
}

void OpenPMDparams::writeRecordAttributes( H5Write &location, unsigned int unit_type )
void OpenPMDparams::writeRecordAttributes( H5Write &location, unsigned int unit_type, double timeOffset )
{
location.attr( "unitDimension", unitDimension[unit_type] );
location.attr( "timeOffset", 0. );
location.attr( "timeOffset", timeOffset );
}

void OpenPMDparams::writeFieldRecordAttributes( H5Write &location )
void OpenPMDparams::writeFieldRecordAttributes( H5Write &location, vector<double> &stagger )
{
location.attr( "position", position );
location.attr( "position", stagger );
}

void OpenPMDparams::writeComponentAttributes( H5Write &location, unsigned int unit_type )
Expand Down
6 changes: 2 additions & 4 deletions src/Params/OpenPMDparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ class OpenPMDparams
DividedString fieldBoundary, fieldBoundaryParameters, particleBoundary, particleBoundaryParameters;
//! current smoothing description
std::string currentSmoothing, currentSmoothingParameters;
//! position of the fields within a cell
std::vector<double> position;

//! Returns a time string in the openPMD format
std::string getLocalTime();
Expand All @@ -74,10 +72,10 @@ class OpenPMDparams
void writeSpeciesAttributes( H5Write& );

//! Write the attributes for a record
void writeRecordAttributes( H5Write&, unsigned int );
void writeRecordAttributes( H5Write&, unsigned int, double timeOffset = 0 );

//! Write the attributes for a field record
void writeFieldRecordAttributes( H5Write& );
void writeFieldRecordAttributes( H5Write&, std::vector<double> &stagger );

//! Write the attributes for a component
void writeComponentAttributes( H5Write&, unsigned int );
Expand Down
2 changes: 1 addition & 1 deletion src/PartCompTime/PartCompTimeFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class PartCompTimeFactory
}
}
else {
ERROR_NAMELIST( "Unknwon parameters setting the particle computing time evaluation operator: "
ERROR_NAMELIST( "Unknown parameters setting the particle computing time evaluation operator: "
<< params.geometry << ", Order : " << params.interpolation_order,
LINK_NAMELIST + std::string("#main-variables"));
}
Expand Down

0 comments on commit 12dd7db

Please sign in to comment.