Skip to content

Commit 92243da

Browse files
committed
Apply pre-commit hooks
1 parent b1235e7 commit 92243da

177 files changed

Lines changed: 22134 additions & 21181 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/10_streaming_read.cpp

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,49 +8,48 @@
88
using std::cout;
99
using namespace openPMD;
1010

11-
int
12-
main()
11+
int main()
1312
{
1413
#if openPMD_HAVE_ADIOS2
1514
using position_t = double;
1615
auto backends = openPMD::getFileExtensions();
17-
if( std::find( backends.begin(), backends.end(), "sst" ) == backends.end() )
16+
if (std::find(backends.begin(), backends.end(), "sst") == backends.end())
1817
{
1918
std::cout << "SST engine not available in ADIOS2." << std::endl;
2019
return 0;
2120
}
2221

23-
Series series = Series( "electrons.sst", Access::READ_ONLY );
22+
Series series = Series("electrons.sst", Access::READ_ONLY);
2423

25-
for( IndexedIteration iteration : series.readIterations() )
24+
for (IndexedIteration iteration : series.readIterations())
2625
{
2726
std::cout << "Current iteration: " << iteration.iterationIndex
2827
<< std::endl;
29-
Record electronPositions = iteration.particles[ "e" ][ "position" ];
30-
std::array< std::shared_ptr< position_t >, 3 > loadedChunks;
31-
std::array< Extent, 3 > extents;
32-
std::array< std::string, 3 > const dimensions{ { "x", "y", "z" } };
28+
Record electronPositions = iteration.particles["e"]["position"];
29+
std::array<std::shared_ptr<position_t>, 3> loadedChunks;
30+
std::array<Extent, 3> extents;
31+
std::array<std::string, 3> const dimensions{{"x", "y", "z"}};
3332

34-
for( size_t i = 0; i < 3; ++i )
33+
for (size_t i = 0; i < 3; ++i)
3534
{
36-
std::string dim = dimensions[ i ];
37-
RecordComponent rc = electronPositions[ dim ];
38-
loadedChunks[ i ] = rc.loadChunk< position_t >(
39-
Offset( rc.getDimensionality(), 0 ), rc.getExtent() );
40-
extents[ i ] = rc.getExtent();
35+
std::string dim = dimensions[i];
36+
RecordComponent rc = electronPositions[dim];
37+
loadedChunks[i] = rc.loadChunk<position_t>(
38+
Offset(rc.getDimensionality(), 0), rc.getExtent());
39+
extents[i] = rc.getExtent();
4140
}
4241

4342
iteration.close();
4443

45-
for( size_t i = 0; i < 3; ++i )
44+
for (size_t i = 0; i < 3; ++i)
4645
{
47-
std::string dim = dimensions[ i ];
48-
Extent const & extent = extents[ i ];
46+
std::string dim = dimensions[i];
47+
Extent const &extent = extents[i];
4948
std::cout << "\ndim: " << dim << "\n" << std::endl;
50-
auto chunk = loadedChunks[ i ];
51-
for( size_t j = 0; j < extent[ 0 ]; ++j )
49+
auto chunk = loadedChunks[i];
50+
for (size_t j = 0; j < extent[0]; ++j)
5251
{
53-
std::cout << chunk.get()[ j ] << ", ";
52+
std::cout << chunk.get()[j] << ", ";
5453
}
5554
std::cout << "\n----------\n" << std::endl;
5655
}

examples/10_streaming_write.cpp

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,39 @@
88
using std::cout;
99
using namespace openPMD;
1010

11-
int
12-
main()
11+
int main()
1312
{
1413
#if openPMD_HAVE_ADIOS2
1514
using position_t = double;
1615
auto backends = openPMD::getFileExtensions();
17-
if( std::find( backends.begin(), backends.end(), "sst" ) == backends.end() )
16+
if (std::find(backends.begin(), backends.end(), "sst") == backends.end())
1817
{
1918
std::cout << "SST engine not available in ADIOS2." << std::endl;
2019
return 0;
2120
}
2221

2322
// open file for writing
24-
Series series = Series( "electrons.sst", Access::CREATE );
23+
Series series = Series("electrons.sst", Access::CREATE);
2524

26-
Datatype datatype = determineDatatype< position_t >();
25+
Datatype datatype = determineDatatype<position_t>();
2726
constexpr unsigned long length = 10ul;
28-
Extent global_extent = { length };
29-
Dataset dataset = Dataset( datatype, global_extent );
30-
std::shared_ptr< position_t > local_data(
31-
new position_t[ length ],
32-
[]( position_t const * ptr ) { delete[] ptr; } );
27+
Extent global_extent = {length};
28+
Dataset dataset = Dataset(datatype, global_extent);
29+
std::shared_ptr<position_t> local_data(
30+
new position_t[length], [](position_t const *ptr) { delete[] ptr; });
3331

3432
WriteIterations iterations = series.writeIterations();
35-
for( size_t i = 0; i < 100; ++i )
33+
for (size_t i = 0; i < 100; ++i)
3634
{
37-
Iteration iteration = iterations[ i ];
38-
Record electronPositions = iteration.particles[ "e" ][ "position" ];
35+
Iteration iteration = iterations[i];
36+
Record electronPositions = iteration.particles["e"]["position"];
3937

40-
std::iota( local_data.get(), local_data.get() + length, i * length );
41-
for( auto const & dim : { "x", "y", "z" } )
38+
std::iota(local_data.get(), local_data.get() + length, i * length);
39+
for (auto const &dim : {"x", "y", "z"})
4240
{
43-
RecordComponent pos = electronPositions[ dim ];
44-
pos.resetDataset( dataset );
45-
pos.storeChunk( local_data, Offset{ 0 }, global_extent );
41+
RecordComponent pos = electronPositions[dim];
42+
pos.resetDataset(dataset);
43+
pos.storeChunk(local_data, Offset{0}, global_extent);
4644
}
4745
iteration.close();
4846
}

examples/12_span_write.cpp

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,31 @@
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

9089
int 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
}

examples/1_structure.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,33 @@
2020
*/
2121
#include <openPMD/openPMD.hpp>
2222

23-
2423
using namespace openPMD;
2524

2625
int main()
2726
{
28-
/* The root of any openPMD output spans across all data for all iterations is a 'Series'.
27+
/* The root of any openPMD output spans across all data for all iterations
28+
* is a 'Series'.
2929
* Data is either in a single file or spread across multiple files. */
3030
Series series = Series("../samples/1_structure.h5", Access::CREATE);
3131

32-
/* Every element that structures your file (groups and datasets for example) can be annotated with attributes. */
33-
series.setComment("This string will show up at the root ('/') of the output with key 'comment'.");
32+
/* Every element that structures your file (groups and datasets for example)
33+
* can be annotated with attributes. */
34+
series.setComment(
35+
"This string will show up at the root ('/') of the output with key "
36+
"'comment'.");
3437

35-
/* Access to individual positions inside happens hierarchically, according to the openPMD standard.
36-
* Creation of new elements happens on access inside the tree-like structure.
37-
* Required attributes are initialized to reasonable defaults for every object. */
38+
/* Access to individual positions inside happens hierarchically, according
39+
* to the openPMD standard. Creation of new elements happens on access
40+
* inside the tree-like structure. Required attributes are initialized to
41+
* reasonable defaults for every object. */
3842
ParticleSpecies electrons = series.iterations[1].particles["electrons"];
3943

40-
/* Data to be moved from memory to persistent storage is structured into Records,
41-
* each holding an unbounded number of RecordComponents.
42-
* If a Record only contains a single (scalar) component, it is treated slightly differently.
44+
/* Data to be moved from memory to persistent storage is structured into
45+
* Records, each holding an unbounded number of RecordComponents. If a
46+
* Record only contains a single (scalar) component, it is treated slightly
47+
* differently.
4348
* https://github.com/openPMD/openPMD-standard/blob/latest/STANDARD.md#scalar-vector-and-tensor-records*/
44-
Record mass = electrons["mass"];
49+
Record mass = electrons["mass"];
4550
RecordComponent mass_scalar = mass[RecordComponent::SCALAR];
4651

4752
Dataset dataset = Dataset(Datatype::DOUBLE, Extent{1});

examples/2_read_serial.cpp

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,52 +20,56 @@
2020
*/
2121
#include <openPMD/openPMD.hpp>
2222

23+
#include <cstddef>
2324
#include <iostream>
2425
#include <memory>
25-
#include <cstddef>
26-
2726

2827
using std::cout;
2928
using namespace openPMD;
3029

3130
int main()
3231
{
33-
Series series = Series(
34-
"../samples/git-sample/data%T.h5",
35-
Access::READ_ONLY
36-
);
37-
cout << "Read a Series with openPMD standard version "
38-
<< series.openPMD() << '\n';
32+
Series series =
33+
Series("../samples/git-sample/data%T.h5", Access::READ_ONLY);
34+
cout << "Read a Series with openPMD standard version " << series.openPMD()
35+
<< '\n';
3936

40-
cout << "The Series contains " << series.iterations.size() << " iterations:";
41-
for( auto const& i : series.iterations )
37+
cout << "The Series contains " << series.iterations.size()
38+
<< " iterations:";
39+
for (auto const &i : series.iterations)
4240
cout << "\n\t" << i.first;
4341
cout << '\n';
4442

4543
Iteration i = series.iterations[100];
4644
cout << "Iteration 100 contains " << i.meshes.size() << " meshes:";
47-
for( auto const& m : i.meshes )
45+
for (auto const &m : i.meshes)
4846
cout << "\n\t" << m.first;
4947
cout << '\n';
50-
cout << "Iteration 100 contains " << i.particles.size() << " particle species:";
51-
for( auto const& ps : i.particles ) {
48+
cout << "Iteration 100 contains " << i.particles.size()
49+
<< " particle species:";
50+
for (auto const &ps : i.particles)
51+
{
5252
cout << "\n\t" << ps.first;
53-
for( auto const& r : ps.second ) {
53+
for (auto const &r : ps.second)
54+
{
5455
cout << "\n\t" << r.first;
5556
cout << '\n';
5657
}
5758
}
5859

5960
openPMD::ParticleSpecies electrons = i.particles["electrons"];
60-
std::shared_ptr<double> charge = electrons["charge"][openPMD::RecordComponent::SCALAR].loadChunk<double>();
61+
std::shared_ptr<double> charge =
62+
electrons["charge"][openPMD::RecordComponent::SCALAR]
63+
.loadChunk<double>();
6164
series.flush();
62-
cout << "And the first electron particle has a charge = " << charge.get()[0];
65+
cout << "And the first electron particle has a charge = "
66+
<< charge.get()[0];
6367
cout << '\n';
6468

6569
MeshRecordComponent E_x = i.meshes["E"]["x"];
6670
Extent extent = E_x.getExtent();
6771
cout << "Field E/x has shape (";
68-
for( auto const& dim : extent )
72+
for (auto const &dim : extent)
6973
cout << dim << ',';
7074
cout << ") and has datatype " << E_x.getDatatype() << '\n';
7175

@@ -77,19 +81,19 @@ int main()
7781
series.flush();
7882
cout << "Chunk has been read from disk\n"
7983
<< "Read chunk contains:\n";
80-
for( size_t row = 0; row < chunk_extent[0]; ++row )
84+
for (size_t row = 0; row < chunk_extent[0]; ++row)
8185
{
82-
for( size_t col = 0; col < chunk_extent[1]; ++col )
83-
cout << "\t"
84-
<< '(' << row + chunk_offset[0] << '|' << col + chunk_offset[1] << '|' << 1 << ")\t"
85-
<< chunk_data.get()[row*chunk_extent[1]+col];
86+
for (size_t col = 0; col < chunk_extent[1]; ++col)
87+
cout << "\t" << '(' << row + chunk_offset[0] << '|'
88+
<< col + chunk_offset[1] << '|' << 1 << ")\t"
89+
<< chunk_data.get()[row * chunk_extent[1] + col];
8690
cout << '\n';
8791
}
8892

8993
auto all_data = E_x.loadChunk<double>();
9094
series.flush();
9195
cout << "Full E/x starts with:\n\t{";
92-
for( size_t col = 0; col < extent[1] && col < 5; ++col )
96+
for (size_t col = 0; col < extent[1] && col < 5; ++col)
9397
cout << all_data.get()[col] << ", ";
9498
cout << "...}\n";
9599

0 commit comments

Comments
 (0)