PRISMS-PF Manual v3.0-pre
All Classes Functions Variables Enumerations Pages
temporal_discretization.h
1// SPDX-FileCopyrightText: © 2025 PRISMS Center at the University of Michigan
2// SPDX-License-Identifier: GNU Lesser General Public Version 2.1
3
4#ifndef temporal_discretization_h
5#define temporal_discretization_h
6
7#include <prismspf/config.h>
8#include <prismspf/core/conditional_ostreams.h>
9#include <prismspf/core/variable_attributes.h>
10
11PRISMS_PF_BEGIN_NAMESPACE
12
17{
18public:
22 void
24 const std::map<unsigned int, variableAttributes> &var_attributes);
25
29 void
31
32 // Final time
33 double final_time = 0.0;
34
35 // Total number of increments
36 unsigned int total_increments = 0;
37
38 // Timestep
39 mutable double dt = 0.0;
40
41 // The current increment
42 mutable unsigned int increment = 0;
43
44 // The current time
45 mutable double time = 0.0;
46};
47
48inline void
50 const std::map<unsigned int, variableAttributes> &var_attributes)
51{
52 // If all of the variables are `TIME_INDEPENDENT`, `AUXILIARY`, or `CONSTANT` then
53 // total_increments should be 1 and final_time should be 0
54 bool only_time_independent_pdes = true;
55 for (const auto &[index, variable] : var_attributes)
56 {
57 if (variable.is_postprocess)
58 {
59 continue;
60 }
61 if (variable.pde_type == PDEType::EXPLICIT_TIME_DEPENDENT ||
62 variable.pde_type == PDEType::IMPLICIT_TIME_DEPENDENT)
63 {
64 only_time_independent_pdes = false;
65 break;
66 }
67 }
68 if (only_time_independent_pdes)
69 {
70 total_increments = 1;
71 return;
72 }
73
74 // Check that the timestep is greater than zero
75 AssertThrow(dt > 0.0,
76 dealii::ExcMessage(
77 "The timestep must be greater than zero for transient problems."));
78
79 // Pick the maximum specified time since the default values are zero
80 final_time = std::max(final_time, dt * total_increments);
81 total_increments = static_cast<unsigned int>(std::ceil(final_time / dt));
82}
83
84inline void
86{
88 << "================================================\n"
89 << " Temporal Discretization\n"
90 << "================================================\n"
91 << "Timestep: " << dt << "\n"
92 << "Total increments: " << total_increments << "\n"
93 << "Final time: " << final_time << "\n\n"
94 << std::flush;
95}
96
97PRISMS_PF_END_NAMESPACE
98
99#endif
static dealii::ConditionalOStream & pout_summary()
Log output stream for writing a summary.log file.
Definition conditional_ostreams.cc:22
Struct that holds temporal discretization parameters.
Definition temporal_discretization.h:17
void postprocess_and_validate(const std::map< unsigned int, variableAttributes > &var_attributes)
Postprocess and validate parameters.
Definition temporal_discretization.h:49
void print_parameter_summary() const
Print parameters to summary.log.
Definition temporal_discretization.h:85