aboutsummaryrefslogtreecommitdiff
path: root/Source/WarpX.cpp
diff options
context:
space:
mode:
authorGravatar Luca Fedeli <luca.fedeli@cea.fr> 2023-08-01 12:00:50 +0200
committerGravatar GitHub <noreply@github.com> 2023-08-01 12:00:50 +0200
commit63dc76ff15c1c8660f30e1ff1cfcb9c2f04db814 (patch)
treeb9ab0e372c0bb50fc80b379f9d287dab1ef1fb3b /Source/WarpX.cpp
parent862df560823cedaf08b67cbee527ed9bedc79683 (diff)
downloadWarpX-63dc76ff15c1c8660f30e1ff1cfcb9c2f04db814.tar.gz
WarpX-63dc76ff15c1c8660f30e1ff1cfcb9c2f04db814.tar.zst
WarpX-63dc76ff15c1c8660f30e1ff1cfcb9c2f04db814.zip
Refactoring: instantiate WarpX class via MakeWarpX function (#4104)
* move functions from main to WarpX class and make WarpX constructible only using factory method * instantiate WarpX via MakeWarpX static member function * test adding MakeWarpX to warpx_init in python wrapper * revert to the use of a simple pointer for the WarpX instance * fix issue * use finalize in python wrapper * change finalize order * move finalize * fix bug
Diffstat (limited to 'Source/WarpX.cpp')
-rw-r--r--Source/WarpX.cpp36
1 files changed, 25 insertions, 11 deletions
diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp
index a6e4f06a1..f5826fd93 100644
--- a/Source/WarpX.cpp
+++ b/Source/WarpX.cpp
@@ -232,11 +232,25 @@ bool WarpX::do_device_synchronize = false;
WarpX* WarpX::m_instance = nullptr;
+void WarpX::MakeWarpX ()
+{
+ ParseGeometryInput();
+
+ ConvertLabParamsToBoost();
+ ReadBCParams();
+
+#ifdef WARPX_DIM_RZ
+ CheckGriddingForRZSpectral();
+#endif
+
+ m_instance = new WarpX();
+}
+
WarpX&
WarpX::GetInstance ()
{
if (!m_instance) {
- m_instance = new WarpX();
+ MakeWarpX();
}
return *m_instance;
}
@@ -244,14 +258,20 @@ WarpX::GetInstance ()
void
WarpX::ResetInstance ()
{
- delete m_instance;
- m_instance = nullptr;
+ if (m_instance){
+ delete m_instance;
+ m_instance = nullptr;
+ }
}
-WarpX::WarpX ()
+void
+WarpX::Finalize()
{
- m_instance = this;
+ WarpX::ResetInstance();
+}
+WarpX::WarpX ()
+{
ReadParameters();
BackwardCompatibility();
@@ -304,12 +324,6 @@ WarpX::WarpX ()
// Particle Boundary Buffer (i.e., scraped particles on boundary)
m_particle_boundary_buffer = std::make_unique<ParticleBoundaryBuffer>();
- // Diagnostics
- multi_diags = std::make_unique<MultiDiagnostics>();
-
- /** create object for reduced diagnostics */
- reduced_diags = std::make_unique<MultiReducedDiags>();
-
Efield_aux.resize(nlevs_max);
Bfield_aux.resize(nlevs_max);