|
| | HierarchyAveragedDataManager (std::string object_name, SAMRAI::tbox::Pointer< SAMRAI::hier::Variable< NDIM >> var, SAMRAI::tbox::Pointer< SAMRAI::tbox::Database > input_db, SAMRAI::tbox::Pointer< SAMRAI::hier::GridGeometry< NDIM >> grid_geom, bool register_for_restart=true) |
| |
| | HierarchyAveragedDataManager (std::string object_name, SAMRAI::tbox::Pointer< SAMRAI::hier::Variable< NDIM >> var, SAMRAI::tbox::Pointer< SAMRAI::tbox::Database > input_db, std::set< double > snapshot_time_points, double period_start_time, double period_end_time, double threshold, SAMRAI::tbox::Pointer< SAMRAI::hier::GridGeometry< NDIM >> grid_geom, bool register_for_restart=true) |
| |
| | ~HierarchyAveragedDataManager ()=default |
| | The destructor for class HierarchyAveragedDataManager deallocates patch data as needed. More...
|
| |
| void | clearSnapshots () |
| |
| bool | updateTimeAveragedSnapshot (int u_idx, double time, SAMRAI::tbox::Pointer< SAMRAI::hier::PatchHierarchy< NDIM >> hierarchy, const int wgt_idx=IBTK::invalid_index, double tol=1.0e-8) |
| |
| bool | updateTimeAveragedSnapshot (int u_idx, double time, SAMRAI::tbox::Pointer< SAMRAI::hier::PatchHierarchy< NDIM >> hierarchy, const std::string &mean_refine_type, const int wgt_idx=IBTK::invalid_index, double tol=1.0e-8) |
| |
| bool | isAtPeriodicSteadyState () |
| |
| bool | isAtPeriodicSteadyState (double time, const double tol) |
| |
| const std::set< double > & | getSnapshotTimePoints () |
| |
| double | getTimePoint (double time, double tol) |
| |
| SnapshotCache & | getSnapshotCache () |
| |
| void | putToDatabase (SAMRAI::tbox::Pointer< SAMRAI::tbox::Database > db) override |
| |
The average field is defined as \( \bar{u} = \lim_{N\rightarrow\infty}\frac{1}{N} \sum_{i = 0}^{N-1} u(x,t + i*P) \) in which \( P \) is the period. This class computes the average \( \bar{u}_N = \frac{1}{N} \sum_{i = 0}^{N-1} u(x,t + i*P) \) via the relation \( \bar{u}_N = \frac{N - 1}{N} \bar{u}_{N-1} + \frac{1}{N} u(x, t + (N-1)*P) \). The average is considered converged when the L2 norm of \( \frac{1}{N} (\bar{u}_N - u(x, t + (N-1)*P)) \) is less than some specified threshold.
Note when the period is equal to 0.0, the average field reduces to \( \bar{u} = \lim_{T\rightarrow\infty} \frac{1}{T} \int_0^T u(x, t_0 + \tau)d\tau \). In this case, it is important that snapshots be taken at consistent time intervals to ensure the above recurrence relation still holds.
If requested, this class can output visualization files corresponding to the tracked average and convergence criteria (called 'deviation'). Visualization files are written after every call to updateTimeAveragedSnapshot. Side and face centered variables are assumed to represent d-dimensional vector fields, while all other fields output a depth consistent with the provided variable in the constructor.
A common use of this class is to determine an average flow field over the course of a simulation. For example, the below code will take snapshots of a flow field at specified intervals.
while (t < T_final)
{
ins_integrator->advanceHierarchy(dt);
t += dt;
if (t >= next_snap_time)
{
auto var_db = VariableDatabase<NDIM>::getDatabase();
const int u_idx = var_db->mapVariableAndContextToIndex(ins_hierarchy->getVelocityVariable(),
ins_hierarchy->getCurrentContext());
HierarchyMathOps hier_math_ops("HierarchyMathOps", patch_hierarchy);
hier_math_ops.resetLevels(0, patch_hierarchy->getFinestLevelNumber());
const int wgt_sc_idx = hier_math_ops.getSideWeightPatchDescriptorIndex();
bool at_steady_state = hier_avg_data_manager.updateTimeAveragedSnapshot(
u_idx, t, patch_hierarchy, "CONSERVATIVE_LINEAR_REFINE", wgt_sc_idx, 1.0e-8);
if (at_steady_state)
pout <<
"Determined steady state!\n";
}
}