Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Changed: The dynamic core statistics postprocessor no longer stores or
serializes a separate copy of the dynamic core state. It now reads the current
core data directly from the dynamic core boundary temperature plugin, making the
boundary temperature plugin the single owner of the restart state.
<br>
(Francesco Radica, 2026/06/04)
32 changes: 0 additions & 32 deletions include/aspect/postprocess/core_statistics.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

#include <aspect/postprocess/interface.h>
#include <aspect/simulator_access.h>
#include <aspect/boundary_temperature/dynamic_core.h>


namespace aspect
Expand All @@ -41,7 +40,6 @@ namespace aspect
class CoreStatistics : public Interface<dim>, public ::aspect::SimulatorAccess<dim>
{
public:
CoreStatistics ();
/**
* Declare the parameters this class takes through input files.
*/
Expand All @@ -61,43 +59,13 @@ namespace aspect
std::pair<std::string,std::string>
execute (TableHandler &statistics) override;

/**
* Export core data stored in this object. Doing this only because the boundary
* temperature doesn't allowed to store restart data there. So we store the data needed
* for restart here and exported to boundary temperature object if required.
*/
const BoundaryTemperature::internal::CoreData &
get_core_data() const;

/**
* Serialize the contents of this class as far as they are not read
* from input parameter files.
*/
template <class Archive>
void serialize (Archive &ar, const unsigned int version);

/**
* Save the state of this object.
*/
void save (std::map<std::string, std::string> &status_strings) const override;

/**
* Restore the state of the object.
*/
void load (const std::map<std::string, std::string> &status_strings) override;

private:
/**
* Controls whether output the total excess entropy or the individual entropy terms
* (i.e. entropy for specific heat, radioactive heating, gravitational contribution,
* and adiabatic contribution).
*/
bool excess_entropy_only;

/**
* Stores the core data from boundary temperature.
*/
BoundaryTemperature::internal::CoreData core_data;
};
}
}
Expand Down
30 changes: 4 additions & 26 deletions source/boundary_temperature/dynamic_core.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@


#include <aspect/boundary_temperature/dynamic_core.h>
#include <aspect/postprocess/core_statistics.h>
#include <aspect/geometry_model/spherical_shell.h>
#include <aspect/adiabatic_conditions/interface.h>
#include <aspect/gravity_model/interface.h>
Expand Down Expand Up @@ -86,27 +85,8 @@ namespace aspect
core_data.dt = this->get_timestep();
core_data.H = compute_radioheating_rate();

// It's a bit tricky here.
// Didn't use the initialize() function instead because the postprocess is initialized after boundary temperature.
// It is not available at the time initialize() function of boundary temperature is called.
if (is_first_call==true)
{
AssertThrow(this->get_postprocess_manager().template has_matching_active_plugin<const Postprocess::CoreStatistics<dim>>(),
ExcMessage ("Dynamic core boundary condition has to work with dynamic core statistics postprocessor."));

const Postprocess::CoreStatistics<dim> &core_statistics
= this->get_postprocess_manager().template get_matching_active_plugin<const Postprocess::CoreStatistics<dim>>();
const internal::CoreData &postprocessor_core_data = core_statistics.get_core_data();
const bool restored_core_data = postprocessor_core_data.is_initialized;

// The restart data is stored in 'core statistics' postprocessor.
// If restart from checkpoint, extract data from there.
// In a fresh run, the postprocessor has not seen valid dynamic core
// data yet, so keep the boundary model's CoreData object and
// initialize it from the parameter file below.
if (restored_core_data)
core_data = postprocessor_core_data;

// Read data of other energy source
read_data_OES();

Expand All @@ -127,10 +107,8 @@ namespace aspect
else
dTa = 0.;

// Setup initial core data from prm input.
// If resumed from checkpoint, core_data is read from postprocess instead of set from prm file.
// (The boundary_temperature doesn't seem to support restart/resume, the data has to passed and
// stored in the postprocessor 'core statistics')
// Setup initial core data from prm input. On restart, core_data has
// already been restored by DynamicCore::load().
if (!core_data.is_initialized)
{
core_data.Ti = inner_temperature + dTa;
Expand All @@ -156,7 +134,7 @@ namespace aspect
<<std::setw(15)<<core_data.dX_dt *year_in_seconds<<std::endl;
this->get_pcout() << output.str();
}
else if (restored_core_data)
else
{
core_data.dt = this->get_timestep();
core_data.H = compute_radioheating_rate();
Expand Down Expand Up @@ -1245,7 +1223,7 @@ namespace aspect
ASPECT_REGISTER_BOUNDARY_TEMPERATURE_MODEL(DynamicCore,
"dynamic core",
"This is a boundary temperature model working only with spherical "
"shell geometry and core statistics postprocessor. The temperature "
"shell geometry. The temperature "
"at the top is constant, and the core mantle boundary temperature "
"is dynamically evolving through time by calculating the heat flux "
"into the core and solving the core energy balance. The formulation "
Expand Down
66 changes: 1 addition & 65 deletions source/postprocess/core_statistics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,6 @@ namespace aspect
{
namespace Postprocess
{
template <int dim>
CoreStatistics<dim>::CoreStatistics()
:
// leave the core_data variable in its uninitialized state
core_data()
{}



template <int dim>
std::pair<std::string,std::string>
CoreStatistics<dim>::execute (TableHandler &statistics)
Expand All @@ -52,7 +43,7 @@ namespace aspect
const BoundaryTemperature::DynamicCore<dim> &dynamic_core =
this->get_boundary_temperature_manager().template get_matching_active_plugin<BoundaryTemperature::DynamicCore<dim>>();

core_data = dynamic_core.get_core_data();
const BoundaryTemperature::internal::CoreData &core_data = dynamic_core.get_core_data();

// now add core mantle boundary heat flux to the statistics object
// and create a single string that can be output to the screen
Expand Down Expand Up @@ -185,61 +176,6 @@ namespace aspect



template <int dim>
const BoundaryTemperature::internal::CoreData &
CoreStatistics<dim>::get_core_data() const
{
return core_data;
}



template <int dim>
template <class Archive>
void CoreStatistics<dim>::serialize (Archive &ar, const unsigned int)
{
ar &(core_data.Ti);
ar &(core_data.Ri);
ar &(core_data.Xi);
ar &(core_data.Q);
ar &(core_data.dR_dt);
ar &(core_data.dT_dt);
ar &(core_data.dX_dt);
ar &(core_data.is_initialized);
}



template <int dim>
void CoreStatistics<dim>::save (std::map<std::string, std::string> &status_strings) const
{
// Serialize into a stringstream. Put the following into a code
// block of its own to ensure the destruction of the 'oa'
// archive triggers a flush() on the stringstream so we can
// query the completed string below.
std::ostringstream os;
{
aspect::oarchive oa (os);
oa << (*this);
}

status_strings["CoreStatistics"] = os.str();
}



template <int dim>
void CoreStatistics<dim>::load (const std::map<std::string, std::string> &status_strings)
{
// see if something was saved
if (status_strings.find("CoreStatistics") != status_strings.end())
{
std::istringstream is (status_strings.find("CoreStatistics")->second);
aspect::iarchive ia (is);
ia >> (*this);
}
}

}
}

Expand Down
Loading