Skip to content

Commit 8793fe8

Browse files
pre-commit-ci[bot]ax3l
authored andcommitted
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 1847002 commit 8793fe8

176 files changed

Lines changed: 22639 additions & 22033 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/13_write_dynamic_configuration.cpp

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

11-
1211
int main()
1312
{
14-
if( !getVariants()["adios2"] )
13+
if (!getVariants()["adios2"])
1514
{
1615
// Example configuration below selects the ADIOS2 backend
1716
return 0;
@@ -67,28 +66,27 @@ chunks = "auto"
6766

6867
// open file for writing
6968
Series series =
70-
Series( "../samples/dynamicConfig.bp", Access::CREATE, defaults );
69+
Series("../samples/dynamicConfig.bp", Access::CREATE, defaults);
7170

72-
Datatype datatype = determineDatatype< position_t >();
71+
Datatype datatype = determineDatatype<position_t>();
7372
constexpr unsigned long length = 10ul;
74-
Extent global_extent = { length };
75-
Dataset dataset = Dataset( datatype, global_extent );
76-
std::shared_ptr< position_t > local_data(
77-
new position_t[ length ],
78-
[]( position_t const * ptr ) { delete[] ptr; } );
73+
Extent global_extent = {length};
74+
Dataset dataset = Dataset(datatype, global_extent);
75+
std::shared_ptr<position_t> local_data(
76+
new position_t[length], [](position_t const *ptr) { delete[] ptr; });
7977

8078
WriteIterations iterations = series.writeIterations();
81-
for( size_t i = 0; i < 100; ++i )
79+
for (size_t i = 0; i < 100; ++i)
8280
{
83-
Iteration iteration = iterations[ i ];
84-
Record electronPositions = iteration.particles[ "e" ][ "position" ];
81+
Iteration iteration = iterations[i];
82+
Record electronPositions = iteration.particles["e"]["position"];
8583

86-
std::iota( local_data.get(), local_data.get() + length, i * length );
87-
for( auto const & dim : { "x", "y", "z" } )
84+
std::iota(local_data.get(), local_data.get() + length, i * length);
85+
for (auto const &dim : {"x", "y", "z"})
8886
{
89-
RecordComponent pos = electronPositions[ dim ];
90-
pos.resetDataset( dataset );
91-
pos.storeChunk( local_data, Offset{ 0 }, global_extent );
87+
RecordComponent pos = electronPositions[dim];
88+
pos.resetDataset(dataset);
89+
pos.storeChunk(local_data, Offset{0}, global_extent);
9290
}
9391

9492
/*
@@ -118,14 +116,14 @@ chunks = "auto"
118116
}
119117
}
120118
})END";
121-
Dataset differentlyCompressedDataset{ Datatype::INT, { 10 } };
119+
Dataset differentlyCompressedDataset{Datatype::INT, {10}};
122120
differentlyCompressedDataset.options = differentCompressionSettings;
123121

124-
auto someMesh = iteration.meshes[ "differentCompressionSettings" ]
125-
[ RecordComponent::SCALAR ];
126-
someMesh.resetDataset( differentlyCompressedDataset );
127-
std::vector< int > dataVec( 10, i );
128-
someMesh.storeChunk( dataVec, { 0 }, { 10 } );
122+
auto someMesh = iteration.meshes["differentCompressionSettings"]
123+
[RecordComponent::SCALAR];
124+
someMesh.resetDataset(differentlyCompressedDataset);
125+
std::vector<int> dataVec(10, i);
126+
someMesh.storeChunk(dataVec, {0}, {10});
129127

130128
iteration.close();
131129
}

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});

0 commit comments

Comments
 (0)