Skip to content
Snippets Groups Projects
Commit ada900c4 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Improve output period management

parent af4ba50f
No related branches found
No related tags found
1 merge request!79Utils/gitlab
......@@ -102,8 +102,8 @@ GnuplotWriter::_writeCellValue(const CellValue<DataType>& cell_value, CellId cel
template <typename DataType, ItemType item_type>
void
GnuplotWriter::_writeValue(const ItemValue<DataType, item_type>& item_value,
CellId cell_id,
NodeId node_id,
[[maybe_unused]] CellId cell_id,
[[maybe_unused]] NodeId node_id,
std::ostream& fout) const
{
if constexpr (item_type == ItemType::cell) {
......
......@@ -172,7 +172,7 @@ WriterBase::getLastTime() const
}
WriterBase::WriterBase(const std::string& base_filename, const double& time_period)
: m_base_filename{base_filename}, m_time_period{time_period}
: m_base_filename{base_filename}, m_time_period{time_period}, m_next_time{0}
{}
void
......@@ -183,7 +183,8 @@ WriterBase::writeIfNeeded(const std::vector<std::shared_ptr<const NamedDiscreteF
if (time == last_time)
return; // output already performed
if (time >= last_time + m_time_period) {
if (time >= m_next_time) {
m_next_time += m_time_period;
this->write(named_discrete_function_list, time);
m_saved_times.push_back(time);
}
......
......@@ -13,6 +13,7 @@ class WriterBase : public IWriter
protected:
const std::string m_base_filename;
const double m_time_period;
mutable double m_next_time;
mutable std::vector<double> m_saved_times;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment