diff --git a/src/reactmicp/CMakeLists.txt b/src/reactmicp/CMakeLists.txt index 35801dd..6ab3553 100644 --- a/src/reactmicp/CMakeLists.txt +++ b/src/reactmicp/CMakeLists.txt @@ -1,139 +1,146 @@ # ReactMiCP # ============= set(REACTMICP_SOLVER_DIR solver) set(REACTMICP_SYSTEMS_DIR systems) set(REACTMICP_EQUILIBRIUMCURVE equilibrium_curve) add_custom_target(reactmicp_incl SOURCES ${REACTMICP_SOLVER_DIR}/reactive_transport_solver_structs.hpp ${REACTMICP_SOLVER_DIR}/staggers_base/variables_base.hpp ${REACTMICP_SOLVER_DIR}/staggers_base/transport_stagger_base.hpp ${REACTMICP_SOLVER_DIR}/staggers_base/chemistry_stagger_base.hpp ${REACTMICP_SOLVER_DIR}/staggers_base/upscaling_stagger_base.hpp ${REACTMICP_SOLVER_DIR}/staggers_base/stagger_structs.hpp ${REACTMICP_SOLVER_DIR}/staggers_base/decl.inl ${REACTMICP_SOLVER_DIR}/staggers_base/staggers_base.hpp ${REACTMICP_SYSTEMS_DIR}/saturated_react/variablesfwd.hpp ) set(REACTMICP_LIBFILES ${REACTMICP_EQUILIBRIUMCURVE}/chemistry.cpp ${REACTMICP_EQUILIBRIUMCURVE}/eqcurve_extractor.cpp ${REACTMICP_EQUILIBRIUMCURVE}/eqcurve_coupler.cpp ${REACTMICP_EQUILIBRIUMCURVE}/eqcurve_solid_transport.cpp # Flexible reactive transport solver # ---------------------------------- ${REACTMICP_SOLVER_DIR}/reactive_transport_solver.cpp ${REACTMICP_SOLVER_DIR}/timestepper.cpp ${REACTMICP_SOLVER_DIR}/runner.cpp # ${REACTMICP_SYSTEMS_DIR}/saturated_react/variables.cpp ${REACTMICP_SYSTEMS_DIR}/saturated_react/transport_program.cpp ${REACTMICP_SYSTEMS_DIR}/saturated_react/transport_stagger.cpp ${REACTMICP_SYSTEMS_DIR}/saturated_react/equilibrium_stagger.cpp ${REACTMICP_SYSTEMS_DIR}/saturated_react/kinetic_stagger.cpp ${REACTMICP_SYSTEMS_DIR}/saturated_react/react_solver.cpp ${REACTMICP_SYSTEMS_DIR}/saturated_react/init_variables.cpp ${REACTMICP_SYSTEMS_DIR}/saturated_react/diffusive_upscaling_stagger.cpp io/reactive_transport.cpp io/saturated_react.cpp + io/configuration.cpp ) if(OPENMP_FOUND) if(SPECMICP_USE_OPENMP) set_source_files_properties(${REACTMICP_SYSTEMS_DIR}/saturated_react/equilibrium_stagger.cpp PROPERTIES COMPILE_DEFINITIONS "SPECMICP_USE_OPENMP" ) set_source_files_properties(${REACTMICP_SYSTEMS_DIR}/saturated_react/kinetic_stagger.cpp PROPERTIES COMPILE_DEFINITIONS "SPECMICP_USE_OPENMP" ) endif() endif() add_library(reactmicp SHARED ${REACTMICP_LIBFILES}) target_link_libraries(reactmicp dfpm) install(TARGETS reactmicp LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR} ) # include files # ------------- set(REACTMICP_STAGGERBASE_INCLUDE_LIST ${REACTMICP_SOLVER_DIR}/staggers_base/variables_base.hpp ${REACTMICP_SOLVER_DIR}/staggers_base/transport_stagger_base.hpp ${REACTMICP_SOLVER_DIR}/staggers_base/chemistry_stagger_base.hpp ${REACTMICP_SOLVER_DIR}/staggers_base/upscaling_stagger_base.hpp ${REACTMICP_SOLVER_DIR}/staggers_base/stagger_structs.hpp ${REACTMICP_SOLVER_DIR}/staggers_base/decl.inl ${REACTMICP_SOLVER_DIR}/staggers_base/staggers_base.hpp ) set(REACTMICP_SOLVER_INCLUDE_LIST ${REACTMICP_SOLVER_DIR}/reactive_transport_solver_structs.hpp ${REACTMICP_SOLVER_DIR}/reactive_transport_solver.hpp ${REACTMICP_SOLVER_DIR}/timestepper.hpp ${REACTMICP_SOLVER_DIR}/runner.hpp ) set(REACTMICP_SATURATEDREACT_INCLUDE_LIST ${REACTMICP_SYSTEMS_DIR}/saturated_react/variablesfwd.hpp ${REACTMICP_SYSTEMS_DIR}/saturated_react/variables.hpp ${REACTMICP_SYSTEMS_DIR}/saturated_react/transport_program.hpp ${REACTMICP_SYSTEMS_DIR}/saturated_react/transport_stagger.hpp ${REACTMICP_SYSTEMS_DIR}/saturated_react/equilibrium_stagger.hpp ${REACTMICP_SYSTEMS_DIR}/saturated_react/kinetic_stagger.hpp ${REACTMICP_SYSTEMS_DIR}/saturated_react/react_solver.hpp ${REACTMICP_SYSTEMS_DIR}/saturated_react/init_variables.hpp ${REACTMICP_SYSTEMS_DIR}/saturated_react/diffusive_upscaling_stagger.hpp ) set(REACTMICP_EQUILIBRIUMCURVE_INCLUDE_LIST ${REACTMICP_EQUILIBRIUMCURVE}/chemistry.cpp ${REACTMICP_EQUILIBRIUMCURVE}/eqcurve_extractor.cpp ${REACTMICP_EQUILIBRIUMCURVE}/eqcurve_coupler.cpp ${REACTMICP_EQUILIBRIUMCURVE}/eqcurve_solid_transport.cpp ) +set(REACTMICP_IO_INCLUDE_LIST + io/reactive_transport.hpp + io/saturated_react.hpp + io/configuration.hpp +) + install(FILES ${REACTMICP_STAGGERBASE_INCLUDE_LIST} DESTINATION ${INCLUDE_INSTALL_DIR}/reactmicp/solver/staggers_base ) install(FILES ${REACTMICP_SOLVER_INCLUDE_LIST} DESTINATION ${INCLUDE_INSTALL_DIR}/reactmicp/solver ) install(FILES ${REACTMICP_SATURATEDREACT_INCLUDE_LIST} DESTINATION ${INCLUDE_INSTALL_DIR}/reactmicp/systems/saturated_react ) install(FILES ${REACTMICP_EQUILIBRIUMCURVE_INCLUDE_LIST} DESTINATION ${INCLUDE_INSTALL_DIR}/reactmicp/equilibrium_curve ) -install(FILES io/reactive_transport.hpp io/saturated_react.hpp +install(FILES ${REACTMICP_IO_INCLUDE_LIST} DESTINATION ${INCLUDE_INSTALL_DIR}/reactmicp/io ) # static libraries # ---------------- if(SPECMICP_BUILD_STATIC) add_library(reactmicp_static STATIC ${REACTMICP_LIBFILES}) install(TARGETS reactmicp_static ARCHIVE DESTINATION ${STATIC_LIBRARY_INSTALL_DIR} ) else() add_library(reactmicp_static EXCLUDE_FROM_ALL STATIC ${REACTMICP_LIBFILES}) endif() set_target_properties(reactmicp_static PROPERTIES OUTPUT_NAME reactmicp) target_link_libraries(reactmicp_static dfpm_static) diff --git a/src/reactmicp/io/configuration.cpp b/src/reactmicp/io/configuration.cpp new file mode 100644 index 0000000..a54a550 --- /dev/null +++ b/src/reactmicp/io/configuration.cpp @@ -0,0 +1,90 @@ +/*------------------------------------------------------------------------------- + +Copyright (c) 2015 F. Georget , 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 "configuration.hpp" + +#include + +#include "../../specmicp/adimensional/adimensional_system_solver_structs.hpp" + +#define S_SPECMICP "specmicp" +#define S_SPECMICP_A_MAX_ITER "maximum_iteration" +#define S_SPECMICP_A_RES_TOL "residual_tolerance" +#define S_SPECMICP_A_STEP_TOL "step_tolerance" +#define S_SPECMICP_A_MAX_STEP_LENGTH "maximum_step_length" +#define S_SPECMICP_A_MAX_STEP_MAX_ITER "maximum_step_iteration" +#define S_SPECMICP_A_SCALING "enable_scaling" +#define S_SPECMICP_A_NONMONOTONE "enable_nonmonotone_linesearch" +#define S_SPECMICP_A_DESCENT_DIRECTION "factor_descent_direction" +#define S_SPECMICP_A_COND_CHECK "threshold_condition_check" +#define S_SPECMICP_A_TRSHOLD_CYCLING_LSEARCH "threshold_cycling_linesearch" +#define S_SPECMICP_A_NONIDEAL_TOL "non_ideality_tolerance" +#define S_SPECMICP_A_CUTOFF_TOT_CONC "cutoff_total_concentration" + +namespace specmicp { +namespace io { + +void configure_specmicp_options(AdimensionalSystemSolverOptions& options, const ptree& configuration) +{ + const boost::property_tree::ptree& conf = configuration.get_child(S_SPECMICP); + + //options.units_set = the_units_set; + + options.solver_options.set_maximum_iterations( + conf.get(S_SPECMICP_A_MAX_ITER, SPECMICP_DEFAULT_MAX_ITER)); + options.solver_options.set_tolerance( + conf.get(S_SPECMICP_A_RES_TOL, SPECMICP_DEFAULT_RES_TOL), + conf.get(S_SPECMICP_A_STEP_TOL, SPECMICP_DEFAULT_STEP_TOL)); + options.solver_options.set_maximum_step_length( + conf.get(S_SPECMICP_A_MAX_STEP_LENGTH, SPECMICP_DEFAULT_MAX_STEP), + conf.get(S_SPECMICP_A_MAX_STEP_MAX_ITER, + std::min(SPECMICP_DEFAULT_MAX_ITER_MAXSTEP, options.solver_options.max_iter))); + options.solver_options.use_scaling = conf.get(S_SPECMICP_A_SCALING, SPECMICP_DEFAULT_USE_SCALING); + options.solver_options.non_monotone_linesearch = conf.get( + S_SPECMICP_A_NONMONOTONE, SPECMICP_DEFAULT_USE_NONMONOTONE_LSEARCH); + options.solver_options.factor_descent_condition = conf.get( + S_SPECMICP_A_DESCENT_DIRECTION, SPECMICP_DEFAULT_FACTOR_DESC_COND + ); + options.solver_options.condition_limit = conf.get( + S_SPECMICP_A_COND_CHECK, SPECMICP_DEFAULT_COND_THRESHOLD); + options.solver_options.threshold_cycling_linesearch = conf.get( + S_SPECMICP_A_TRSHOLD_CYCLING_LSEARCH, SPECMICP_DEFAULT_COND_THRESHOLD + ); + + options.system_options.non_ideality_tolerance = conf.get( + S_SPECMICP_A_NONIDEAL_TOL, SPECMICP_DEFAULT_NONIDEAL_TOL); + options.system_options.cutoff_total_concentration = conf.get( + S_SPECMICP_A_CUTOFF_TOT_CONC, SPECMICP_DEFAULT_CUTOFF_TOT_CONC); +} + +} //end namespace io +} //end namespace specmicp diff --git a/src/reactmicp/io/configuration.hpp b/src/reactmicp/io/configuration.hpp new file mode 100644 index 0000000..dd03e7d --- /dev/null +++ b/src/reactmicp/io/configuration.hpp @@ -0,0 +1,57 @@ +/*------------------------------------------------------------------------------- + +Copyright (c) 2015 F. Georget , 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. + +-----------------------------------------------------------------------------*/ + +#ifndef SPECMICP_REACTMICP_IO_CONFIGURATION_HPP +#define SPECMICP_REACTMICP_IO_CONFIGURATION_HPP + +#include "types.hpp" +#include + +namespace specmicp { + +struct AdimensionalSystemSolverOptions; + +namespace io { + +using namespace boost::property_tree; + +void SPECMICP_DLL_PUBLIC configure_specmicp_options( + specmicp::AdimensionalSystemSolverOptions& options, + const ptree& configuration + ); + + + +} //end namespace io +} //end namespace specmicp + +#endif // SPECMICP_REACTMICP_IO_CONFIGURATION_HPP diff --git a/src/reactmicp/io/saturated_react.hpp b/src/reactmicp/io/saturated_react.hpp index 9abb4bd..c87a222 100644 --- a/src/reactmicp/io/saturated_react.hpp +++ b/src/reactmicp/io/saturated_react.hpp @@ -1,129 +1,129 @@ /*------------------------------------------------------------------------------- Copyright (c) 2014,2015 F. Georget , 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. -----------------------------------------------------------------------------*/ #ifndef SPECMICP_IO_SATURATEDREACT_HPP #define SPECMICP_IO_SATURATEDREACT_HPP //! \file saturated_react.hpp //! \brief Print information about the saturated reactive transport module #include "../../types.hpp" #include #include namespace specmicp { // forward declarations namespace database { - class DataContainer; + struct DataContainer; } //end namespace database using RawDatabasePtr = std::shared_ptr; namespace units { struct UnitsSet; } //end namespace units namespace mesh { class Mesh1D; using Mesh1DPtr = std::shared_ptr; } //end namespace mesh namespace reactmicp { namespace systems { namespace satdiff { class SaturatedVariables; using SaturatedVariablesPtr = std::shared_ptr; } //end namespace satdiff } //end namespace systems } //end namespace reactmicp namespace io { using namespace specmicp::reactmicp::systems::satdiff; //! \brief Print the time as a comment void SPECMICP_DLL_PUBLIC print_csv_header(std::ostream* ofile); //! \brief Print the total aqueous concentrations in the CSV format in 'ofile' void SPECMICP_DLL_PUBLIC print_components_total_aqueous_concentration( RawDatabasePtr the_database, SaturatedVariablesPtr variables, mesh::Mesh1DPtr the_mesh, const units::UnitsSet& units_set, std::ostream* ofile ); //! \brief Print the total aqueous concentrations in the CSV format in the file 'filepath' void SPECMICP_DLL_PUBLIC print_components_total_aqueous_concentration( RawDatabasePtr the_database, SaturatedVariablesPtr variables, mesh::Mesh1DPtr the_mesh, const units::UnitsSet& units_set, const std::string& filepath ); //! \brief Print the total solid concentrations in the CSV format in the file 'filepath' void SPECMICP_DLL_PUBLIC print_components_total_solid_concentration( RawDatabasePtr the_database, SaturatedVariablesPtr variables, mesh::Mesh1DPtr the_mesh, const units::UnitsSet& units_set, const std::string& filepath ); //! \brief Print the solid phases profiles in 'ofile' void SPECMICP_DLL_PUBLIC print_minerals_profile( RawDatabasePtr the_database, SaturatedVariablesPtr variables, mesh::Mesh1DPtr the_mesh, std::ostream* ofile ); //! \brief Print the solid phases profiles in 'filepath' void SPECMICP_DLL_PUBLIC print_minerals_profile( RawDatabasePtr the_database, SaturatedVariablesPtr variables, mesh::Mesh1DPtr the_mesh, const std::string& filepath ); } // end namespace io } // end namespace specmicp #endif // SPECMICP_IO_SATURATEDREACT_HPP