Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F76025357
timestepper.hpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Aug 5, 19:28
Size
2 KB
Mime Type
text/x-c++
Expires
Wed, Aug 7, 19:28 (1 d, 22 h)
Engine
blob
Format
Raw Data
Handle
19648278
Attached To
rSPECMICP SpecMiCP / ReactMiCP
timestepper.hpp
View Options
#ifndef SPECMICP_REACTMICP_SOLVER_TIMESTEPPER_HPP
#define SPECMICP_REACTMICP_SOLVER_TIMESTEPPER_HPP
#include "utils/moving_average.hpp"
#include "utils/options_handler.hpp"
namespace
specmicp
{
namespace
reactmicp
{
namespace
solver
{
// forward declaration
enum
class
ReactiveTransportReturnCode
;
//! \brief Options for the timestepper
struct
TimestepperOptions
{
scalar_t
lower_bound
;
//!< Lower bound for the timestep
scalar_t
upper_bound
;
//!< Upper bound for the timestep
scalar_t
restart_timestep
;
//!< Value used when restarting the problem
scalar_t
iteration_lower_target
{
1.01
};
//!< Lower target for the number of iterations
scalar_t
iteration_upper_target
{
15.0
};
//!< Upper target for the number of iterations
scalar_t
alpha_average
{
0.5
};
//!< Parameter for the exponential moving average
scalar_t
decrease_failure
{
0.5
};
//!< Reduction factor in case of failure
scalar_t
increase_error_minimization
{
1.3
};
//!< Increase factor in case of error minimization
scalar_t
decrease_factor
{
0.75
};
//!< Reduction factor to get the number of iterations inside the target
scalar_t
increase_factor
{
1.25
};
//!< Increase factor to get the number of iterations inside the target
TimestepperOptions
(
scalar_t
dt_lower_bound
,
scalar_t
dt_upper_bound
)
:
lower_bound
(
dt_lower_bound
),
upper_bound
(
dt_upper_bound
),
restart_timestep
(
dt_lower_bound
)
{}
};
//! \brief Adaptative timestepper for the reactive transport solver
class
Timestepper
:
public
OptionsHandler
<
TimestepperOptions
>
{
public
:
//! \brief Constructor
//!
//! \param dt_lower_bound lower_bound for the timestep
//! \param dt_upper_bound upper_bound for the timestep
//! \param total_target total target time
//! \param init_iterations initial iterations
Timestepper
(
scalar_t
dt_lower_bound
,
scalar_t
dt_upper_bound
,
scalar_t
total_target
,
scalar_t
init_iterations
)
:
OptionsHandler
(
dt_lower_bound
,
dt_upper_bound
),
m_total
(
0
),
m_total_target
(
total_target
),
m_average
(
0.5
,
init_iterations
)
{
m_average
.
set_alpha
(
get_options
().
alpha_average
);
}
//! \brief Return the total time
scalar_t
get_total
()
const
{
return
m_total
;}
//! \brief Return the total target time
scalar_t
get_total_target
()
const
{
return
m_total_target
;}
//! \brief Set the total target time
void
set_total_target
(
scalar_t
total_target
)
{
m_total_target
=
total_target
;}
void
set_average_parameter
(
scalar_t
alpha
)
{
get_options
().
alpha_average
=
alpha
;
m_average
.
set_alpha
(
alpha
);
}
//! obtain the next timestep
scalar_t
next_timestep
(
scalar_t
dt_done
,
ReactiveTransportReturnCode
return_code
,
index_t
nb_iterations
);
private
:
scalar_t
m_total
;
scalar_t
m_total_target
;
utils
::
ExponentialMovingAverage
m_average
;
};
}
// end namespace solver
}
// end namespace reactmicp
}
// end namespace specmicp
#endif
// SPECMICP_REACTMICP_SOLVER_TIMESTEPPER_HPP
Event Timeline
Log In to Comment