Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F85089134
timestepper.cpp
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
Thu, Sep 26, 17:13
Size
1 KB
Mime Type
text/x-c
Expires
Sat, Sep 28, 17:13 (2 d)
Engine
blob
Format
Raw Data
Handle
21127514
Attached To
rSPECMICP SpecMiCP / ReactMiCP
timestepper.cpp
View Options
#include "timestepper.hpp"
#include "reactive_transport_solver_structs.hpp"
namespace specmicp {
namespace reactmicp {
namespace solver {
scalar_t Timestepper::next_timestep(
scalar_t dt_done,
ReactiveTransportReturnCode return_code,
index_t nb_iterations
)
{
if (return_code <= ReactiveTransportReturnCode::NotConvergedYet)
{
return get_options().decrease_failure*dt_done;
}
// previous timestep is correct
m_total += dt_done;
m_average.add_point(nb_iterations);
scalar_t proposed_dt = dt_done;
// If the error is minimized we increase the timestep
if (return_code == ReactiveTransportReturnCode::ErrorMinimized)
{
proposed_dt *= get_options().increase_error_minimization;
}
else
// Increase or decrease the timestep to reach the number of iteration target range
{
if (m_average.current_value() <= get_options().iteration_lower_target)
{
proposed_dt *= get_options().increase_factor;
}
else if (m_average.current_value() > get_options().iteration_upper_target)
{
proposed_dt *= get_options().decrease_factor;
}
}
// Check that the total target is not exceeded
if (m_total + proposed_dt > m_total_target)
{
proposed_dt = m_total_target - m_total;
}
// Check that the timestep is inside the bounds
if (proposed_dt < get_options().lower_bound)
{
proposed_dt = get_options().lower_bound;
}
else if (proposed_dt > get_options().upper_bound)
{
proposed_dt = get_options().upper_bound;
}
return proposed_dt;
}
} // end namespace solver
} // end namespace reactmicp
} // end namespace specmicp
Event Timeline
Log In to Comment