-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSON/TOML backend: introduce abbreviated IO modes #1493
JSON/TOML backend: introduce abbreviated IO modes #1493
Conversation
737da87
to
be7d165
Compare
// std::string config = R"( | ||
// { | ||
// "iteration_encoding": "variable_based", | ||
// "toml": { | ||
// "dataset": {"mode": "template"}, | ||
// "attribute": {"mode": "short"} | ||
// } | ||
// } | ||
// )"; |
Check notice
Code scanning / CodeQL
Commented-out code Note
4a969c5
to
7969864
Compare
7969864
to
ef8236f
Compare
ef8236f
to
92cf227
Compare
92cf227
to
c63d56f
Compare
8ee5ae8
to
09a70bc
Compare
With this, the JSON backend is now sensibly usable from codes such as PIConGPU: {
"__openPMD_internal": {
"attribute_mode": "short",
"dataset_mode": "template"
},
"attributes": {
"basePath": "/data/%T/",
"date": "2023-10-11 09:57:53 +0200",
"iterationEncoding": "fileBased",
"iterationFormat": "simData_%06T",
"meshesPath": "fields/",
"openPMD": "1.1.0",
"openPMDextension": 0,
"particlesPath": "particles/",
"picongpuIOVersionMajor": 2,
"picongpuIOVersionMinor": 0,
"software": "PIConGPU",
"softwareVersion": "0.7.0-dev"
},
"data": {
"100": {
"attributes": {
"cell_depth": 4.252342224121094,
"cell_height": 1.0630855560302734,
"cell_width": 4.252342224121094,
"dt": 1,
"eps0": 169.19711303710938,
"iteration": 100,
"mue0": 0.005910266190767288,
"particleBoundary": [
"absorbing",
"absorbing",
"absorbing",
"absorbing",
"absorbing",
"absorbing"
],
"particleBoundaryParameters": [
"without field correction",
"without field correction",
"without field correction",
"without field correction",
"without field correction",
"without field correction"
],
"sim_slides": 0,
"time": 100,
"timeUnitSI": 1.39e-16,
"unit_bfield": 40903.82224060171,
"unit_charge": 1.1143237516482563e-15,
"unit_efield": 12262657411105.05,
"unit_energy": 5.694183860145225e-10,
"unit_length": 4.1671151662e-08,
"unit_mass": 6.335633991170193e-27,
"unit_speed": 299792458,
"unit_time": 1.39e-16
},
"fields": {
"B": {
"attributes": {
"axisLabels": [
"z",
"y",
"x"
],
"dataOrder": "C",
"fieldSmoothing": "none",
"geometry": "cartesian",
"gridGlobalOffset": [
0,
0,
0
],
"gridSpacing": [
4.252342224121094,
1.0630855560302734,
4.252342224121094
],
"gridUnitSI": 4.1671151662e-08,
"timeOffset": 0,
"unitDimension": [
0,
1,
-2,
-1,
0,
0,
0
]
},
"x": {
"attributes": {
"position": [
0,
0.5,
0.5
],
"unitSI": 40903.82224060171
},
"datatype": "FLOAT",
"extent": [
32,
32,
32
]
},
"y": {
"attributes": {
"position": [
0.5,
0,
0.5
],
"unitSI": 40903.82224060171
},
"datatype": "FLOAT",
"extent": [
32,
32,
32
]
},
"z": {
"attributes": {
"position": [
0.5,
0.5,
0
],
"unitSI": 40903.82224060171
},
"datatype": "FLOAT",
"extent": [
32,
32,
32
]
}
},
"E": {
"attributes": {
"axisLabels": [
"z",
"y",
"x"
],
"dataOrder": "C",
"fieldSmoothing": "none",
"geometry": "cartesian",
"gridGlobalOffset": [
0,
0,
0
],
"gridSpacing": [
4.252342224121094,
1.0630855560302734,
4.252342224121094
],
"gridUnitSI": 4.1671151662e-08,
"timeOffset": 0,
"unitDimension": [
1,
1,
-3,
-1,
0,
0,
0
]
},
"x": {
"attributes": {
"position": [
0.5,
0,
0
],
"unitSI": 12262657411105.05
},
"datatype": "FLOAT",
"extent": [
32,
32,
32
]
},
"y": {
"attributes": {
"position": [
0,
0.5,
0
],
"unitSI": 12262657411105.05
},
"datatype": "FLOAT",
"extent": [
32,
32,
32
]
},
"z": {
"attributes": {
"position": [
0,
0,
0.5
],
"unitSI": 12262657411105.05
},
"datatype": "FLOAT",
"extent": [
32,
32,
32
]
}
},
"attributes": {
"chargeCorrection": "none",
"currentSmoothing": "none",
"fieldBoundary": [
"open",
"open",
"open",
"open",
"open",
"open"
],
"fieldBoundaryParameters": [
"convolutional PML over 12 cells",
"convolutional PML over 12 cells",
"convolutional PML over 12 cells",
"convolutional PML over 12 cells",
"convolutional PML over 12 cells",
"convolutional PML over 12 cells"
],
"fieldSolver": "Yee"
},
"e_all_chargeDensity": {
"attributes": {
"axisLabels": [
"z",
"y",
"x"
],
"dataOrder": "C",
"fieldSmoothing": "none",
"geometry": "cartesian",
"gridGlobalOffset": [
0,
0,
0
],
"gridSpacing": [
4.252342224121094,
1.0630855560302734,
4.252342224121094
],
"gridUnitSI": 4.1671151662e-08,
"position": [
0,
0,
0
],
"timeOffset": 0,
"unitDimension": [
-3,
0,
1,
1,
0,
0,
0
],
"unitSI": 15399438.226078901
},
"datatype": "FLOAT",
"extent": [
32,
32,
32
]
},
"e_all_energyDensity": {
"attributes": {
"axisLabels": [
"z",
"y",
"x"
],
"dataOrder": "C",
"fieldSmoothing": "none",
"geometry": "cartesian",
"gridGlobalOffset": [
0,
0,
0
],
"gridSpacing": [
4.252342224121094,
1.0630855560302734,
4.252342224121094
],
"gridUnitSI": 4.1671151662e-08,
"position": [
0,
0,
0
],
"timeOffset": 0,
"unitDimension": [
-1,
1,
-2,
0,
0,
0,
0
],
"unitSI": 7869098408118.734
},
"datatype": "FLOAT",
"extent": [
32,
32,
32
]
},
"picongpu_idProvider": {
"attributes": {
"axisLabels": [
"x"
],
"dataOrder": "C",
"geometry": "cartesian",
"gridGlobalOffset": [
0
],
"gridSpacing": [
1
],
"gridUnitSI": 1,
"timeOffset": 0,
"unitDimension": [
0,
0,
0,
0,
0,
0,
0
]
},
"nextId": {
"attributes": {
"position": [
0
],
"unitSI": 1
},
"datatype": "ULONG",
"extent": [
1,
1,
1
]
},
"startId": {
"attributes": {
"maxNumProc": 1,
"position": [
0
],
"unitSI": 1
},
"datatype": "ULONG",
"extent": [
1,
1,
1
]
}
}
},
"particles": {
"e": {
"attributes": {
"currentDeposition": "Esirkepov",
"particleInterpolation": "uniform",
"particlePush": "Boris",
"particleShape": 2,
"particleSmoothing": "none"
},
"charge": {
"attributes": {
"macroWeighted": 0,
"shape": [
0
],
"timeOffset": 0,
"unitDimension": [
0,
0,
1,
1,
0,
0,
0
],
"unitSI": 1.1143237516482563e-15,
"value": -0.0001437801111023873,
"weightingPower": 1
}
},
"mass": {
"attributes": {
"macroWeighted": 0,
"shape": [
0
],
"timeOffset": 0,
"unitDimension": [
0,
1,
0,
0,
0,
0,
0
],
"unitSI": 6.335633991170193e-27,
"value": 0.0001437801111023873,
"weightingPower": 1
}
},
"momentum": {
"attributes": {
"macroWeighted": 1,
"timeOffset": 0,
"unitDimension": [
1,
1,
-1,
0,
0,
0,
0
],
"weightingPower": 1
},
"x": {
"attributes": {
"shape": [
0
],
"unitSI": 1.8993752872012626e-18,
"value": 0
}
},
"y": {
"attributes": {
"shape": [
0
],
"unitSI": 1.8993752872012626e-18,
"value": 0
}
},
"z": {
"attributes": {
"shape": [
0
],
"unitSI": 1.8993752872012626e-18,
"value": 0
}
}
},
"particlePatches": {
"extent": {
"attributes": {
"unitDimension": [
0,
0,
0,
0,
0,
0,
0
]
},
"x": {
"attributes": {
"unitSI": 1
},
"datatype": "ULONG",
"extent": [
1
]
},
"y": {
"attributes": {
"unitSI": 1
},
"datatype": "ULONG",
"extent": [
1
]
},
"z": {
"attributes": {
"unitSI": 1
},
"datatype": "ULONG",
"extent": [
1
]
}
},
"numParticles": {
"attributes": {
"unitSI": 1
},
"datatype": "ULONG",
"extent": [
1
]
},
"numParticlesOffset": {
"attributes": {
"unitSI": 1
},
"datatype": "ULONG",
"extent": [
1
]
},
"offset": {
"attributes": {
"unitDimension": [
0,
0,
0,
0,
0,
0,
0
]
},
"x": {
"attributes": {
"unitSI": 1
},
"datatype": "ULONG",
"extent": [
1
]
},
"y": {
"attributes": {
"unitSI": 1
},
"datatype": "ULONG",
"extent": [
1
]
},
"z": {
"attributes": {
"unitSI": 1
},
"datatype": "ULONG",
"extent": [
1
]
}
}
},
"position": {
"attributes": {
"macroWeighted": 0,
"timeOffset": 0,
"unitDimension": [
1,
0,
0,
0,
0,
0,
0
],
"weightingPower": 0
},
"x": {
"attributes": {
"shape": [
0
],
"unitSI": 1.7719999774007647e-07,
"value": 0
}
},
"y": {
"attributes": {
"shape": [
0
],
"unitSI": 4.429999943501912e-08,
"value": 0
}
},
"z": {
"attributes": {
"shape": [
0
],
"unitSI": 1.7719999774007647e-07,
"value": 0
}
}
},
"positionOffset": {
"attributes": {
"macroWeighted": 0,
"timeOffset": 0,
"unitDimension": [
1,
0,
0,
0,
0,
0,
0
],
"weightingPower": 0
},
"x": {
"attributes": {
"shape": [
0
],
"unitSI": 1.7719999774007647e-07,
"value": 0
}
},
"y": {
"attributes": {
"shape": [
0
],
"unitSI": 4.429999943501912e-08,
"value": 0
}
},
"z": {
"attributes": {
"shape": [
0
],
"unitSI": 1.7719999774007647e-07,
"value": 0
}
}
},
"weighting": {
"attributes": {
"macroWeighted": 1,
"shape": [
0
],
"timeOffset": 0,
"unitDimension": [
0,
0,
0,
0,
0,
0,
0
],
"unitSI": 1,
"value": 0,
"weightingPower": 1
}
}
}
}
}
}
} |
c511364
to
544923b
Compare
8ca52da
to
6464af8
Compare
src/IO/JSON/JSONIOHandlerImpl.cpp
Outdated
@@ -1269,40 +2009,165 @@ | |||
return (*obtainJsonContents(file))[filePosition->id]; | |||
} | |||
|
|||
void JSONIOHandlerImpl::putJsonContents( | |||
auto JSONIOHandlerImpl::putJsonContents( |
Check warning
Code scanning / CodeQL
Poorly documented large function Warning
baf807e
to
914aaaa
Compare
9269933
to
047e571
Compare
047e571
to
7cc629e
Compare
7cc629e
to
a2cf97a
Compare
a2cf97a
to
4d68f6d
Compare
for more information, see https://pre-commit.ci
Reading the chunk table requires NOT using template mode, otherwise the string just consists of '\0' bytes.
for more information, see https://pre-commit.ci
f72ef68
to
7f81e62
Compare
switch (m_fileFormat) | ||
{ | ||
case FileFormat::Json: | ||
m_attributeMode.m_mode = | ||
m_handler->m_standard >= OpenpmdStandard::v_2_0_0 | ||
? AttributeMode::Short | ||
: AttributeMode::Long; | ||
break; | ||
default: | ||
break; | ||
} |
Check notice
Code scanning / CodeQL
No trivial switch statements Note
helper::listSeries(read); | ||
} | ||
|
||
TEST_CASE("json_short_modes") |
Check notice
Code scanning / CodeQL
Unused static function Note test
autoRegistrar7
d52c6fa
to
985a59f
Compare
Factored out of #1277, based on #1436
Introduces two options:
json.dataset.mode = "template"
(default:= "dataset"
), write just the dataset extent and not the actual contentjson.attribute.mode = "short"
(default:= "long"
), write an attribute as{"software": "openPMD-api"}
instead of{"software": {"value": "openPMD-api", "type": "STRING"}}
TODO:
Diff: https://github.com/franzpoeschel/openPMD-api/compare/parallel-json..topic-json-short-modes