55#include < numeric> // std::iota
66#include < vector>
77
8- void span_write ( std::string const & filename )
8+ void span_write (std::string const &filename)
99{
1010 using namespace openPMD ;
1111 using position_t = double ;
1212 // open file for writing
13- Series series = Series ( filename, Access::CREATE );
13+ Series series = Series (filename, Access::CREATE );
1414
15- Datatype datatype = determineDatatype< position_t >();
15+ Datatype datatype = determineDatatype<position_t >();
1616 constexpr unsigned long length = 10ul ;
17- Extent extent = { length };
18- Dataset dataset = Dataset ( datatype, extent );
17+ Extent extent = {length};
18+ Dataset dataset = Dataset (datatype, extent);
1919
20- std::vector< position_t > fallbackBuffer;
20+ std::vector<position_t > fallbackBuffer;
2121
2222 WriteIterations iterations = series.writeIterations ();
23- for ( size_t i = 0 ; i < 10 ; ++i )
23+ for ( size_t i = 0 ; i < 10 ; ++i)
2424 {
25- Iteration iteration = iterations[ i ];
26- Record electronPositions = iteration.particles [ " e" ][ " position" ];
25+ Iteration iteration = iterations[i ];
26+ Record electronPositions = iteration.particles [" e" ][ " position" ];
2727
2828 size_t j = 0 ;
29- for ( auto const & dim : { " x" , " y" , " z" } )
29+ for ( auto const &dim : {" x" , " y" , " z" } )
3030 {
31- RecordComponent pos = electronPositions[ dim ];
32- pos.resetDataset ( dataset );
31+ RecordComponent pos = electronPositions[dim];
32+ pos.resetDataset (dataset);
3333 /*
3434 * This demonstrates the storeChunk() strategy (to be) used in
3535 * PIConGPU:
@@ -45,16 +45,15 @@ void span_write( std::string const & filename )
4545 * flushed in each iteration to make the buffer reusable.
4646 */
4747 bool fallbackBufferIsUsed = false ;
48- auto dynamicMemoryView = pos.storeChunk < position_t >(
49- Offset{ 0 },
48+ auto dynamicMemoryView = pos.storeChunk <position_t >(
49+ Offset{0 },
5050 extent,
51- [ &fallbackBuffer, &fallbackBufferIsUsed ]( size_t size )
52- {
51+ [&fallbackBuffer, &fallbackBufferIsUsed](size_t size) {
5352 fallbackBufferIsUsed = true ;
54- fallbackBuffer.resize ( size );
55- return std::shared_ptr< position_t >(
56- fallbackBuffer.data (), []( auto const * ) {} );
57- } );
53+ fallbackBuffer.resize (size);
54+ return std::shared_ptr<position_t >(
55+ fallbackBuffer.data (), [](auto const *) {});
56+ });
5857
5958 /*
6059 * ADIOS2 might reallocate its internal buffers when writing
@@ -63,21 +62,21 @@ void span_write( std::string const & filename )
6362 * directly before writing.
6463 */
6564 auto span = dynamicMemoryView.currentBuffer ();
66- if ( ( i + j ) % 2 == 0 )
65+ if (( i + j) % 2 == 0 )
6766 {
6867 std::iota (
6968 span.begin (),
7069 span.end (),
71- position_t ( 3 * i * length + j * length ) );
70+ position_t (3 * i * length + j * length) );
7271 }
7372 else
7473 {
7574 std::iota (
7675 span.rbegin (),
7776 span.rend (),
78- position_t ( 3 * i * length + j * length ) );
77+ position_t (3 * i * length + j * length) );
7978 }
80- if ( fallbackBufferIsUsed )
79+ if ( fallbackBufferIsUsed)
8180 {
8281 iteration.seriesFlush ();
8382 }
@@ -89,12 +88,12 @@ void span_write( std::string const & filename )
8988
9089int main ()
9190{
92- for ( auto const & ext : openPMD::getFileExtensions () )
91+ for ( auto const &ext : openPMD::getFileExtensions ())
9392 {
94- if ( ext == " sst" || ext == " ssc" )
93+ if ( ext == " sst" || ext == " ssc" )
9594 {
9695 continue ;
9796 }
98- span_write ( " ../samples/span_write." + ext );
97+ span_write (" ../samples/span_write." + ext);
9998 }
10099}
0 commit comments