Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91322797
runner.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
Sun, Nov 10, 00:09
Size
4 KB
Mime Type
text/x-c
Expires
Tue, Nov 12, 00:09 (2 d)
Engine
blob
Format
Raw Data
Handle
22242285
Attached To
rSPECMICP SpecMiCP / ReactMiCP
runner.cpp
View Options
/* =============================================================================
Copyright (c) 2014 - 2016
F. Georget <fabieng@princeton.edu> Princeton University
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
============================================================================= */
#include "runner.hpp"
#include "reactmicp/io/reactive_transport.hpp"
#include "staggers_base/variables_base.hpp"
#include "specmicp_common/timer.hpp"
#include "specmicp_common/io/csv_formatter.hpp"
#include <fstream>
namespace specmicp {
namespace reactmicp {
namespace solver {
void ReactiveTransportRunner::run_until(scalar_t target, VariablesBasePtr variables)
{
Timer total_time;
VariablesBase* vars = variables.get();
total_time.start();
m_timestepper.set_total_target(target);
m_output_target = m_timestepper.get_total()+m_simulinfo.output_step;
io::OutFile out_iter(
m_simulinfo.complete_filepath(
std::string("iter"), std::string("dat")));
io::print_reactmicp_header(out_iter);
if (m_simulinfo.print_iter_info)
{
io::print_reactmicp_performance_long_header(out_iter);
}
scalar_t dt = m_timestepper.get_options().restart_timestep;
auto retcode = ReactiveTransportReturnCode::NotConvergedYet;
while(retcode >= ReactiveTransportReturnCode::NotConvergedYet
and m_timestepper.get_total() < m_timestepper.get_total_target())
{
Timer step_timer;
step_timer.start();
retcode = m_solver.solve_timestep(dt, vars);
step_timer.stop();
if (m_simulinfo.print_iter_info)
io::print_reactmicp_performance_long(
out_iter, m_cnt,
m_timestepper.get_total()+dt,
m_solver.get_perfs()
);
dt = m_timestepper.next_timestep(
dt,
retcode,
m_solver.get_perfs().nb_iterations
);
if (retcode <= reactmicp::solver::ReactiveTransportReturnCode::NotConvergedYet)
{
dt = m_timestepper.get_options().restart_timestep;
vars->reset_main_variables();
retcode = m_solver.solve_timestep(dt, vars);
if (m_simulinfo.print_iter_info)
io::print_reactmicp_performance_long(
out_iter, m_cnt,
m_timestepper.get_total()+dt,
m_solver.get_perfs()
);
dt = m_timestepper.next_timestep(
dt,
retcode,
m_solver.get_perfs().nb_iterations
);
}
++m_cnt;
// output
if (m_timestepper.get_total() > m_output_target)
{
m_output_function(m_timestepper.get_total(), variables);
m_output_target += m_simulinfo.output_step;
}
if (retcode == reactmicp::solver::ReactiveTransportReturnCode::UserTermination)
break;
}
total_time.stop();
io::print_reactmicp_end(out_iter, total_time, get_timer());
}
} // end namespace solver
} // end namespace reactmicp
} // end namespace specmicp
Event Timeline
Log In to Comment