-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move sensei to new diagnostics (#1040)
* move ascent to new diagnostics * move Sensei to the new diagnostics * minor cleaning in new diagnostics * oops, had forgotten some files * fix typo * another typo introduced when merging master into this branch * FlushFormat::WriteToFile takes Vector<MultiFab>& instead of Vector<const MultiFab*> * IO output multifab has 1 guard cell when using sensei * updates to FlushFormatSensei * add some documentation to the class * add refrence to AmrMesh instance needed by the adaptor * add some error output in the case WarpX was not compiled w/ SENSEI * tested with SENSEI 3.2.0 Co-authored-by: Burlen Loring <[email protected]>
- Loading branch information
1 parent
d337f7c
commit bd7d6f6
Showing
18 changed files
with
199 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#ifndef WARPX_FLUSHFORMATSENSEI_H_ | ||
#define WARPX_FLUSHFORMATSENSEI_H_ | ||
|
||
#include "FlushFormat.H" | ||
#include "AMReX_AmrMesh.H" | ||
|
||
#if defined(BL_USE_SENSEI_INSITU) | ||
#include "AMReX_AmrMeshInSituBridge.H" | ||
#else | ||
namespace amrex { | ||
using AmrMeshInSituBridge = void; | ||
} | ||
#endif | ||
|
||
/** | ||
* \brief This class aims at dumping performing in-situ diagnostics with | ||
* SENSEI. In particular, function WriteToFile takes fields and particles as | ||
* input arguments, and calls amrex functions to do the in-situ visualization. | ||
* | ||
* To use the SENSEI flush format one must compile WarpX with the GNUMakefile | ||
* setting: USE_SENSEI_INSITU=TRUE | ||
* | ||
* In addition to the standard controls, the following inputs file fields are | ||
* supported: | ||
* | ||
* sensei_config - the path to a SENSEI XML configuration (required) | ||
* sensei_pin_mesh - integer 0 or 1 forcing the moving mesh to be fixed | ||
* at 0,0,0 (optional) | ||
* | ||
* Fri 29 May 2020 11:19:38 AM PDT : Tested with SENSEI version 3.2.0 | ||
*/ | ||
class FlushFormatSensei : public FlushFormat | ||
{ | ||
public: | ||
FlushFormatSensei(); | ||
~FlushFormatSensei(); | ||
|
||
FlushFormatSensei(const FlushFormatSensei &) = delete; | ||
void operator=(const FlushFormatSensei &) = delete; | ||
|
||
/** \breif Construct. | ||
* \parm[in] amr_mesh an AmrMesh instance | ||
* \parm[in] diag_name ParmParse scope string. | ||
*/ | ||
FlushFormatSensei (amrex::AmrMesh *amr_mesh, std::string diag_name); | ||
|
||
/** Do in-situ visualization for field and particle data */ | ||
virtual void WriteToFile ( | ||
const amrex::Vector<std::string> varnames, | ||
const amrex::Vector<amrex::MultiFab>& mf, | ||
amrex::Vector<amrex::Geometry>& geom, | ||
const amrex::Vector<int> iteration, const double time, | ||
const amrex::Vector<ParticleDiag>& particle_diags, int nlev, const std::string prefix, | ||
bool plot_raw_fields, | ||
bool plot_raw_fields_guards, | ||
bool plot_raw_rho, bool plot_raw_F) const override; | ||
|
||
/** \brief Do in-situ visualization for particle data. | ||
* \param[in] particle_diags Each element of this vector handles output of 1 species. | ||
*/ | ||
void WriteParticles(const amrex::Vector<ParticleDiag>& particle_diags) const; | ||
|
||
private: | ||
amrex::AmrMesh * m_amr_mesh; | ||
amrex::AmrMeshInSituBridge * m_insitu_bridge; | ||
std::string m_insitu_config; | ||
int m_insitu_pin_mesh; | ||
}; | ||
|
||
#endif // WARPX_FLUSHFORMATSENSEI_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#include "FlushFormatSensei.H" | ||
#include "WarpX.H" | ||
|
||
#ifdef BL_USE_SENSEI_INSITU | ||
# include <AMReX_AmrMeshInSituBridge.H> | ||
#endif | ||
|
||
FlushFormatSensei::FlushFormatSensei () : | ||
m_insitu_config(), m_insitu_pin_mesh(0), m_insitu_bridge(nullptr), | ||
m_amr_mesh(nullptr) | ||
{} | ||
|
||
FlushFormatSensei::FlushFormatSensei (amrex::AmrMesh *amr_mesh, | ||
std::string diag_name) : | ||
m_insitu_config(), m_insitu_pin_mesh(0), m_insitu_bridge(nullptr), | ||
m_amr_mesh(amr_mesh) | ||
{ | ||
#ifndef BL_USE_SENSEI_INSITU | ||
(void)amr_mesh; | ||
(void)diag_name; | ||
#else | ||
amrex::ParmParse pp(diag_name); | ||
|
||
pp.query("sensei_config", m_insitu_config); | ||
pp.query("sensei_pin_mesh", m_insitu_pin_mesh); | ||
|
||
m_insitu_bridge = new amrex::AmrMeshInSituBridge; | ||
m_insitu_bridge->setEnabled(true); | ||
m_insitu_bridge->setConfig(m_insitu_config); | ||
m_insitu_bridge->setPinMesh(m_insitu_pin_mesh); | ||
if (!m_amr_mesh || m_insitu_bridge->initialize()) | ||
{ | ||
amrex::ErrorStream() << "FlushFormtSensei::FlushFormatSensei : " | ||
"Failed to initialize the in situ bridge." << std::endl; | ||
|
||
amrex::Abort(); | ||
} | ||
m_insitu_bridge->setFrequency(1); | ||
#endif | ||
} | ||
|
||
FlushFormatSensei::~FlushFormatSensei () | ||
{ | ||
#ifdef BL_USE_SENSEI_INSITU | ||
delete m_insitu_bridge; | ||
#endif | ||
} | ||
|
||
void | ||
FlushFormatSensei::WriteToFile ( | ||
const amrex::Vector<std::string> varnames, | ||
const amrex::Vector<amrex::MultiFab>& mf, | ||
amrex::Vector<amrex::Geometry>& geom, | ||
const amrex::Vector<int> iteration, const double time, | ||
const amrex::Vector<ParticleDiag>& particle_diags, int nlev, | ||
const std::string prefix, bool plot_raw_fields, | ||
bool plot_raw_fields_guards, bool plot_raw_rho, bool plot_raw_F) const | ||
{ | ||
#ifndef BL_USE_SENSEI_INSITU | ||
(void)varnames; | ||
(void)mf; | ||
(void)geom; | ||
(void)iteration; | ||
(void)time; | ||
(void)particle_diags; | ||
(void)nlev; | ||
(void)prefix; | ||
(void)plot_raw_fields; | ||
(void)plot_raw_fields_guards; | ||
(void)plot_raw_rho; | ||
(void)plot_raw_F; | ||
#else | ||
amrex::Vector<amrex::MultiFab> *mf_ptr = | ||
const_cast<amrex::Vector<amrex::MultiFab>*>(&mf); | ||
|
||
if (m_insitu_bridge->update(iteration[0], time, m_amr_mesh, | ||
{mf_ptr}, {varnames})) | ||
{ | ||
amrex::ErrorStream() << "FlushFormatSensei::WriteToFile : " | ||
"Failed to update the in situ bridge." << std::endl; | ||
|
||
amrex::Abort(); | ||
} | ||
#endif | ||
} | ||
|
||
void | ||
FlushFormatSensei::WriteParticles ( | ||
const amrex::Vector<ParticleDiag>& particle_diags) const | ||
{ | ||
#ifndef BL_USE_SENSEI_INSITU | ||
(void)particle_diags; | ||
#else | ||
amrex::ErrorStream() << "FlushFormatSensei::WriteParticles : " | ||
"Not yet implemented." << std::endl; | ||
|
||
amrex::Abort(); | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.