Skip to content

Commit 6adac6e

Browse files
committed
prepare rebasing on master for electromag diag writter
1 parent e4e7a51 commit 6adac6e

File tree

7 files changed

+18
-18
lines changed

7 files changed

+18
-18
lines changed

pyphare/pyphare/pharein/diagnostics.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ def _setSubTypeAttributes(self, **kwargs):
196196
MHDDiagnostics.mhd_quantities
197197
)
198198
raise ValueError(error_msg.format(kwargs["quantity"]))
199+
elif kwargs["quantity"] == "B":
200+
self.quantity = "/EM_B"
199201
else:
200202
self.quantity = "/mhd/" + kwargs["quantity"]
201203

pyphare/pyphare/pharein/initialize/hybrid.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ def populateDict(sim):
4949

5050
add_string("simulation/electromag/name", "EM")
5151
add_string("simulation/electromag/electric/name", "E")
52-
5352
add_string("simulation/electromag/magnetic/name", "B")
53+
5454
maginit_path = "simulation/electromag/magnetic/initializer/"
5555
addInitFunction(maginit_path + "x_component", fn_wrapper(modelDict["bx"]))
5656
addInitFunction(maginit_path + "y_component", fn_wrapper(modelDict["by"]))

src/diagnostic/detail/h5writer.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ class H5Writer
7676
else if constexpr (std::is_same_v<Identifier, MHDIdentifier>)
7777
typeWriters_ = {
7878
{"meta", make_writer<MetaDiagnosticWriter<This>>()},
79-
{"mhd", make_writer<MHDDiagnosticWriter<This>>()} //
79+
{"mhd", make_writer<MHDDiagnosticWriter<This>>()},
80+
{"electromag", make_writer<ElectromagDiagnosticWriter<This>>()} //
8081
};
8182
}
8283

src/diagnostic/detail/types/mhd.hpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ namespace PHARE::diagnostic::h5
1111
/* Possible outputs
1212
* /t#/pl#/p#/mhd/density
1313
* /t#/pl#/p#/mhd/velocity/(x,y,z)
14-
* /t#/pl#/p#/mhd/B/(x,y,z)
1514
* /t#/pl#/p#/mhd/pressure
1615
* /t#/pl#/p#/mhd/rhoV/(x,y,z)
1716
* /t#/pl#/p#/mhd/Etot
@@ -67,7 +66,7 @@ template<typename H5Writer>
6766
void MHDDiagnosticWriter<H5Writer>::createFiles(DiagnosticProperties& diagnostic)
6867
{
6968
std::string tree{"/mhd/"};
70-
checkCreateFileFor_(diagnostic, fileData_, tree, "rho", "V", "B", "P", "rhoV", "Etot");
69+
checkCreateFileFor_(diagnostic, fileData_, tree, "rho", "V", "P", "rhoV", "Etot");
7170
}
7271

7372
template<typename H5Writer>
@@ -80,7 +79,7 @@ void MHDDiagnosticWriter<H5Writer>::compute(DiagnosticProperties& diagnostic)
8079

8180
auto& rho = modelView.getRho();
8281
auto& V = modelView.getV();
83-
auto& B = modelView.getB();
82+
auto& B = *modelView.getElectromagFields()[0];
8483
auto& P = modelView.getP();
8584
auto& rhoV = modelView.getRhoV();
8685
auto& Etot = modelView.getEtot();
@@ -115,7 +114,6 @@ void MHDDiagnosticWriter<H5Writer>::getDataSetInfo(DiagnosticProperties& diagnos
115114
auto& h5Writer = this->h5Writer_;
116115
auto& rho = h5Writer.modelView().getRho();
117116
auto& V = h5Writer.modelView().getV();
118-
auto& B = h5Writer.modelView().getB();
119117
auto& P = h5Writer.modelView().getP();
120118
auto& rhoV = h5Writer.modelView().getRhoV();
121119
auto& Etot = h5Writer.modelView().getEtot();
@@ -147,8 +145,6 @@ void MHDDiagnosticWriter<H5Writer>::getDataSetInfo(DiagnosticProperties& diagnos
147145
infoDS(rho, "rho", patchAttributes[lvlPatchID]["mhd"]);
148146
if (isActiveDiag(diagnostic, tree, "V"))
149147
infoVF(V, "V", patchAttributes[lvlPatchID]["mhd"]);
150-
if (isActiveDiag(diagnostic, tree, "B"))
151-
infoVF(B, "B", patchAttributes[lvlPatchID]["mhd"]);
152148
if (isActiveDiag(diagnostic, tree, "P"))
153149
infoDS(P, "P", patchAttributes[lvlPatchID]["mhd"]);
154150
if (isActiveDiag(diagnostic, tree, "rhoV"))
@@ -200,8 +196,6 @@ void MHDDiagnosticWriter<H5Writer>::initDataSets(
200196
initDS(path, attr["mhd"], "rho", null);
201197
if (isActiveDiag(diagnostic, tree, "V"))
202198
initVF(path, attr["mhd"], "V", null);
203-
if (isActiveDiag(diagnostic, tree, "B"))
204-
initVF(path, attr["mhd"], "B", null);
205199
if (isActiveDiag(diagnostic, tree, "P"))
206200
initDS(path, attr["mhd"], "P", null);
207201
if (isActiveDiag(diagnostic, tree, "rhoV"))
@@ -219,7 +213,6 @@ void MHDDiagnosticWriter<H5Writer>::write(DiagnosticProperties& diagnostic)
219213
auto& h5Writer = this->h5Writer_;
220214
auto& rho = h5Writer.modelView().getRho();
221215
auto& V = h5Writer.modelView().getV();
222-
auto& B = h5Writer.modelView().getB();
223216
auto& P = h5Writer.modelView().getP();
224217
auto& rhoV = h5Writer.modelView().getRhoV();
225218
auto& Etot = h5Writer.modelView().getEtot();
@@ -237,8 +230,6 @@ void MHDDiagnosticWriter<H5Writer>::write(DiagnosticProperties& diagnostic)
237230
writeDS(path + "rho", rho);
238231
if (isActiveDiag(diagnostic, tree, "V"))
239232
writeTF(path + "V", V);
240-
if (isActiveDiag(diagnostic, tree, "B"))
241-
writeTF(path + "B", B);
242233
if (isActiveDiag(diagnostic, tree, "P"))
243234
writeDS(path + "P", P);
244235
if (isActiveDiag(diagnostic, tree, "rhoV"))

src/diagnostic/diagnostic_manager.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void registerDiagnostics(DiagManager& dMan, initializer::PHAREDict const& diagsP
2929
}
3030
else if constexpr (std::is_same_v<typename DiagManager::Identifier, MHDIdentifier>)
3131
{
32-
return std::vector<std::string>{"mhd", "meta"};
32+
return std::vector<std::string>{"mhd", "meta", "electromag"};
3333
}
3434
}();
3535

src/diagnostic/diagnostic_model_view.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,11 @@ class ModelView<Hierarchy, Model, MHDIdentifier> : public BaseModelView<Hierarch
191191

192192
NO_DISCARD VecField& getV() const { return this->model_.state.V; }
193193

194-
NO_DISCARD VecField& getB() const { return this->model_.state.B; }
194+
// compatibility with the electromag diagnostic writer
195+
NO_DISCARD std::vector<VecField*> getElectromagFields() const
196+
{
197+
return {&this->model_.state.B};
198+
}
195199

196200
NO_DISCARD Field& getP() const { return this->model_.state.P; }
197201

tests/functional/mhd_orszagtang/orszag_tang_merged.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
cpp = cpp_lib()
1313
startMPI()
1414

15-
diag_outputs = "phare_outputs/test/orszag-tang/2d"
15+
diag_outputs = "phare_outputs"
1616
time_step_nbr = 357
1717
time_step = 0.0014
1818
dt = 10 * time_step
@@ -78,8 +78,10 @@ def p(x, y):
7878

7979
ph.MHDModel(density=density, vx=vx, vy=vy, vz=vz, bx=bx, by=by, bz=bz, p=p)
8080

81-
for quantity in ["rho", "V", "B", "P"]:
82-
ph.MHDDiagnostics(quantity=quantity, write_timestamps=timestamps)
81+
ph.ElectromagDiagnostics(quantity="B", write_timestamps=timestamps)
82+
83+
# for quantity in ["rho", "V", "B", "P"]:
84+
# ph.MHDDiagnostics(quantity=quantity, write_timestamps=timestamps)
8385

8486
return sim
8587

0 commit comments

Comments
 (0)