diff --git a/.devcontainer/Dockerfile.codespace b/.devcontainer/Dockerfile.codespace new file mode 100644 index 000000000..215600811 --- /dev/null +++ b/.devcontainer/Dockerfile.codespace @@ -0,0 +1,12 @@ +FROM fedora:37 + +RUN dnf -y update \ + && dnf -y install \ + cmake \ + gcc-c++ \ + gdb \ + git \ + make \ + zlib-devel \ + llvm-devel \ + && dnf clean all \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..eccf8125f --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,10 @@ +{ + "name": "MICM Development Environment", + "dockerFile": "Dockerfile.codespace", + "extensions": [ + "ms-vscode.cpptools" + ], + "settings": { + }, + "postCreateCommand": "cd /workspaces/micm && mkdir build && cd build && cmake -D CMAKE_BUILD_TYPE=debug -D ENABLE_CLANG_TIDY:BOOL=FALSE -D ENABLE_LLVM:BOOL=TRUE -D ENABLE_MEMCHECK:BOOL=TRUE .. && make install -j 2" +} diff --git a/CMakeLists.txt b/CMakeLists.txt index f105b8a20..5ea8bc748 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,10 +27,6 @@ set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${PROJECT_SOURCE_DIR}/cmake") # Set up include and lib directories set(MICM_LIB_DIR "${PROJECT_BINARY_DIR}/lib") -include(GNUInstallDirs) -set(INSTALL_PREFIX "micm-${PROJECT_VERSION}" ) -set(INSTALL_MOD_DIR "${INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}") - option(ENABLE_CLANG_TIDY "Enable clang-tiday to format source code" OFF) option(ENABLE_MPI "Enable MPI parallel support" OFF) option(ENABLE_OPENMP "Enable OpenMP support" OFF) diff --git a/docker/Dockerfile b/docker/Dockerfile index 1241bd0bf..1954e7222 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -7,6 +7,7 @@ RUN dnf -y update \ gdb \ git \ make \ + json-devel \ && dnf clean all # copy the MICM code @@ -21,4 +22,18 @@ RUN mkdir /build \ ../micm \ && make install -j 8 +# now test if we can use the installed files +RUN cd /micm/test/integration/cmake/find_package \ + && mkdir build && cd build \ + && cmake .. \ + && make \ + && make test + +# now test that fetch content can be used +RUN cd /micm/test/integration/cmake/fetch_content \ + && mkdir build && cd build \ + && cmake .. \ + && make \ + && make test + WORKDIR /build \ No newline at end of file diff --git a/docs/source/contributing/index.rst b/docs/source/contributing/index.rst index 3e5950e5b..a684149bb 100644 --- a/docs/source/contributing/index.rst +++ b/docs/source/contributing/index.rst @@ -1,3 +1,4 @@ +.. _Contributing: Contributing ============ @@ -40,14 +41,8 @@ of ``clang-format`` enforces some consistency which means moving from file to fi Setting up developer environments --------------------------------- -macOS -^^^^^ - -Linux -^^^^^ - -Windows -^^^^^^^ +Most developers work on micm in VS Code. For instructions on how to setup micm with Xcode or Visual Studio, +please see the :ref:`Debugging` section of the :ref:`Installation and usage` guide. Building the documentation -------------------------- diff --git a/docs/source/getting_started.rst b/docs/source/getting_started.rst index 1483c0697..cf1ce1d07 100644 --- a/docs/source/getting_started.rst +++ b/docs/source/getting_started.rst @@ -5,6 +5,9 @@ Getting Started Build and Test ============== +Configuring for different platforms and environments is shown here. There is an additional tutorial which covers +some other specifics: :ref:`Installation and usage`. + CPU --- To build and install MICM locally, you must have the following libraries installed: @@ -48,6 +51,9 @@ others require that you have libraries installed on your system. - OpenMP - On macOS, you either need to configure cmake to use gcc which ships with OpenMP (either ``CXX=g++ cmake -DENABLE_OPENMP=ON ..`` or ``cmake -DCMAKE_CXX_COMPILER=g++ -DENABLE_OPENMP=ON ..``) +For more ways to build and install micm, see :ref:`Installation and usage`. If you would like instructions for building +the docs, see :ref:`Contributing`. + Docker Container ---------------- diff --git a/docs/source/user_guide/but_how_fast_is_it.rst b/docs/source/user_guide/but_how_fast_is_it.rst index de67d03c0..2d4e2ad4e 100644 --- a/docs/source/user_guide/but_how_fast_is_it.rst +++ b/docs/source/user_guide/but_how_fast_is_it.rst @@ -56,9 +56,9 @@ in the stats object. .. literalinclude:: ../../../test/tutorial/test_but_how_fast_is_it.cpp :language: cpp - :lines: 75-86 + :lines: 69-80 -.. code-block:: console +.. code-block:: bash Solver state: Converged accepted: 20 @@ -78,9 +78,9 @@ wasted, for the ``false`` version. .. literalinclude:: ../../../test/tutorial/test_but_how_fast_is_it.cpp :language: cpp - :lines: 88-96 + :lines: 82-90 -.. code-block:: console +.. code-block:: bash Total solve time: 24416 nanoseconds total_forcing_time: 3167 nanoseconds diff --git a/docs/source/user_guide/images/codespaces.png b/docs/source/user_guide/images/codespaces.png new file mode 100644 index 000000000..149765743 Binary files /dev/null and b/docs/source/user_guide/images/codespaces.png differ diff --git a/docs/source/user_guide/index.rst b/docs/source/user_guide/index.rst index 4a2d3b497..7896b135a 100644 --- a/docs/source/user_guide/index.rst +++ b/docs/source/user_guide/index.rst @@ -40,6 +40,7 @@ If you would like to include the json examples, you must configure micm to build :maxdepth: 1 :caption: Contents: + installation_and_usage rate_constant_tutorial user_defined_rate_constant_tutorial multiple_grid_cells diff --git a/docs/source/user_guide/installation_and_usage.rst b/docs/source/user_guide/installation_and_usage.rst new file mode 100644 index 000000000..e0287a4db --- /dev/null +++ b/docs/source/user_guide/installation_and_usage.rst @@ -0,0 +1,215 @@ +.. _Installation and usage: + +Installation and usage +====================== + +This tutorial is going to focus **only** and how to install micm and/or include it +into your project in multiple different ways. Any API specific details will be elided and will be covered +in another tutorial. + + +Github codespace +---------------- + +If you want to play around with micm without figuring out how to include it in your local setup, this is the **easiest** +option. Github codespaces offers a cloud-hosted version of Visual Studio Code configured to work with specific projects. +We've set one up for micm. It'll allow you to instantly run the tests and make changes. Please note that there is a cap on +the number of hours your personal github account has each month. Follow these instructions to see your +`github codespace usage `_. +At the time of this writing, there was a maximum of 120 core-houres allowed for github codespaces for free accounts. + +To set this up, on the github page for `micm `_, poke on the green code button and choose the +codespaces tab and select "create codespace on main". This will open up a new tab and start building a cloud environment +running an instance of VSCode with the micm repository displayed and all of the tests prebuilt. + +.. image:: images/codespaces.png + +The first time that you open up a codespace, it will spend some time building the image and then compiling the test files. +Onces that's done, you can move into the build direcotry and run the tests. + + +.. code-block:: bash + + cd build + make test + +Installing +---------- + +From an archive +^^^^^^^^^^^^^^^ + +All versions of micm are associated with a github `release `_. +Each release includes a tarall and zip that you can use to grab the code. + +Find a release of micm that you want to build and download that archive. You can either do this with the browser by +poking on the desired file or with the commands below. + +If you intend to use cmake to install micm, you can choose the install location when you configure +cmake: ``cmake -D CMAKE_INSTALL_PREFIX=/Users/me/Documents ..``. + +Zip +~~~ +.. code-block:: bash + + wget https://github.com/NCAR/micm/archive/refs/tags/v3.2.0.zip + unzip v3.2.0.zip + cd micm-3.2.0 + mkdir build && cd build + cmake .. + make -j 8 + make test + sudo make install + +Tarball +~~~~~~~ +.. code-block:: bash + + wget https://github.com/NCAR/micm/archive/refs/tags/v3.2.0.tar.gz + tar -xf v3.2.0.tar.gz + cd micm-3.2.0 + mkdir build && cd build + cmake .. + make -j 8 + make test + sudo make install + +Cloning from github +^^^^^^^^^^^^^^^^^^^ + +.. code-block:: bash + + git clone https://github.com/NCAR/micm.git + cd micm + mkdir build && cd build + cmake .. + make -j 8 + make test + sudo make install + +Usage after installation +^^^^^^^^^^^^^^^^^^^^^^^^ + +micm installs itself in a location typical on your system, like ``/usr/local``. It does so under it's own +directory with the version appended, e.g. ``/usr/local/micm-3.2.0``. It installs header files and files suitable +for use with cmake's `find_package `_. + +:: + + $ tree /usr/local/micm-3.2.0 -L 2 + /usr/local/micm-3.2.0 + ├── cmake + │ ├── micmConfig.cmake + │ ├── micmConfigVersion.cmake + │ └── micm_Exports.cmake + └── include + └── micm + +micm only installs its header and cmake files. If you intend to use any of the additional features of micm +like JIT compiling or json parsing, you'll need to have it's dependencies installed. + +Specify include path +~~~~~~~~~~~~~~~~~~~~ + +To compile micm code, it's as simple as adding the include path to your compile command ``-I/usr/local/micm-3.2.0/include`` +or ``export CPPFLAGS="-I/usr/local/micm-3.2.0/include"``. If you changed the install location when configuring cmake, you'll +need to set that path instead. + +Cmake +----- + +micm is developed with cmake support. This makes the inclusion of micm into projects that use cmake especially easy. + +find_package +^^^^^^^^^^^^ + +This assumes you have micm installed using one of the methods above. + +The cmake files installed with micm allow you to ask cmake to take care of finding and setting the include paths for you +in a cmake project. Using micm with `find_package `_ +is as simple as adding this line to your cmake project and linking +your target to micm. You will need to change the version accordingly. + +.. code-block:: cmake + + find_package(micm 3.2.0 REQUIRED) + + add_executable(my_target my_target.cpp) + + target_link_libraries(my_target + PUBLIC + musica::micm + ) + +Fetch content +^^^^^^^^^^^^^ + +If you can use cmake 3.11+, the easiest way to include micm is with the +`FetchContent module `_. +If you must use a lower version, you'll either need to install the files on your system, or properly set +the include flags of your cmake project to point to the micm header files if you don't need GPU support. +You may also want to look into `ExternalProject `_. + +To use micm with fetch content, you'll need to include the module and point it to the micm repository and a commit +or tag that you want to use. Then you make the content available and link your cmake target to micm. + +.. code-block:: cmake + + include(FetchContent) + + FetchContent_Declare(micm + GIT_REPOSITORY https://github.com/NCAR/micm.git + GIT_TAG 0996e5848b097e77ccbb2819f22c49844154f3e3 + ) + + FetchContent_MakeAvailable(micm) + + add_executable(my_target my_target.cpp) + + target_link_libraries(my_target + PUBLIC + musica::micm + ) + + +.. _Debugging: + +Debugging +--------- + +If you find yourself needing to debug the internals of micm, you don't have to stick to print statements. + +Luckily, cmake will generate projects for the major IDEs. + +VS Code +^^^^^^^ + +At this time, the easiest way to work in VS Code is to build micm yourself with cmake on the command line and use print +statements. Feel free to submit a PR with instructions for setting up visual studio code for debugging micm. + +Xcode +^^^^^ + +On macOS, you'll want to use xcode. You can ask cmake to generate an xcode project file for you. + +.. code-block:: + + mkdir xcode && cd xcode + cmake -G Xcode .. + +After this completes, there will be a file called micm.xcodeproj that you can open with Xcode. Select a target you want to build +and start debugging. Further use of xcode is beyond the scope of this documentation. + +Visual Studio +^^^^^^^^^^^^^ + +On windows, you'll want to use Visual Studio. You can ask cmake to generate an xcode project file for you. + +.. code-block:: + + mkdir xcode && cd xcode + cmake -G "Visual Studio 17 2022" .. + +After this completes, there will be a file called micm.sln that you can open with Visual Studio. +Select a target you want to build and start debugging. +Further use of Visual Studio is beyond the scope of this documentation. \ No newline at end of file diff --git a/docs/source/user_guide/multiple_grid_cells.rst b/docs/source/user_guide/multiple_grid_cells.rst index 245911f4c..f91b9ed02 100644 --- a/docs/source/user_guide/multiple_grid_cells.rst +++ b/docs/source/user_guide/multiple_grid_cells.rst @@ -34,14 +34,13 @@ This mechanism only needs the user defined rate constant and the rosenbrock solv .. literalinclude:: ../../../test/tutorial/test_multiple_grid_cells.cpp :language: cpp - :lines: 1-5 + :lines: 1-4 -After that, we'll use the ``micm`` namespace and setup a template alias so that we can instantiate the -rosenbrock solver. +After that, we'll use the ``micm`` namespace. .. literalinclude:: ../../../test/tutorial/test_multiple_grid_cells.cpp :language: cpp - :lines: 7-14 + :lines: 6-7 To create a :cpp:class:`micm::RosenbrockSolver`, we have to define a chemical system (:cpp:class:`micm::System`) and our reactions, which will be a vector of :cpp:class:`micm::Process` We will use the species to define these as @@ -49,14 +48,14 @@ well as a :cpp:class:`micm::Phase`. .. literalinclude:: ../../../test/tutorial/test_multiple_grid_cells.cpp :language: cpp - :lines: 56-60 + :lines: 49-53 With the species and gas phase, we can define all of our reactions .. literalinclude:: ../../../test/tutorial/test_multiple_grid_cells.cpp :language: cpp - :lines: 62-78 + :lines: 55-71 Now we can define our RosenbrockSolver. This time we'll form the reactions and chemical system in place. @@ -67,7 +66,7 @@ the order the species are added to the gas phase. .. literalinclude:: ../../../test/tutorial/test_multiple_grid_cells.cpp :language: cpp - :lines: 80-84 + :lines: 73-77 Now we need to get a state and set the concentations of each of the species. In the @@ -77,25 +76,25 @@ to set the concentrations. Here we will set the concentations by providing the : .. literalinclude:: ../../../test/tutorial/test_multiple_grid_cells.cpp :language: cpp - :lines: 86-91 + :lines: 79-84 Then we set the reaction rates by creating a vector that is 3 elements long, one for each grid cell. .. literalinclude:: ../../../test/tutorial/test_multiple_grid_cells.cpp :language: cpp - :lines: 93-98 + :lines: 86-91 And lastly set the temperature, pressure, and air density for each grid cell. .. literalinclude:: ../../../test/tutorial/test_multiple_grid_cells.cpp :language: cpp - :lines: 100-108 + :lines: 93-102 Now we are ready to run the simulation. .. literalinclude:: ../../../test/tutorial/test_multiple_grid_cells.cpp :language: cpp - :lines: 110-133 + :lines: 104-127 And these are the results. diff --git a/docs/source/user_guide/solver_configurations.rst b/docs/source/user_guide/solver_configurations.rst index 37b68039b..ecde3e0b3 100644 --- a/docs/source/user_guide/solver_configurations.rst +++ b/docs/source/user_guide/solver_configurations.rst @@ -45,14 +45,14 @@ Configuring the rosenbrock solver is as easy as providing the solver with a set .. literalinclude:: ../../../test/tutorial/test_solver_configuration.cpp :language: cpp - :lines: 154-172 + :lines: 147-165 After that, the usage is the same as a regular solver. A templated method was used here to run the same solving code for each of the different solver configurations. .. literalinclude:: ../../../test/tutorial/test_solver_configuration.cpp :language: cpp - :lines: 40-123 + :lines: 34-116 Running this program should give an output similar to this: diff --git a/docs/source/user_guide/user_defined_rate_constant_tutorial.rst b/docs/source/user_guide/user_defined_rate_constant_tutorial.rst index 089f6aa12..a36d7246d 100644 --- a/docs/source/user_guide/user_defined_rate_constant_tutorial.rst +++ b/docs/source/user_guide/user_defined_rate_constant_tutorial.rst @@ -56,14 +56,14 @@ Adding the custom rate constant is quite simple. Include the header file: .. code-block:: diff - #include - #include - #include - #include - #include - #include - +#include - #include + #include + #include + #include + #include + #include + #include + + #include + #include Then setup the reaction which will use this rate constant: diff --git a/packaging/CMakeLists.txt b/packaging/CMakeLists.txt index d9b7208ae..122ffdc1f 100644 --- a/packaging/CMakeLists.txt +++ b/packaging/CMakeLists.txt @@ -1,4 +1,6 @@ include(CMakePackageConfigHelpers) +include(GNUInstallDirs) +set(INSTALL_PREFIX "micm-${PROJECT_VERSION}" ) install( TARGETS diff --git a/test/integration/cmake/README.md b/test/integration/cmake/README.md new file mode 100644 index 000000000..c6a47a3a2 --- /dev/null +++ b/test/integration/cmake/README.md @@ -0,0 +1,3 @@ +This folder tests usage with cmake. These are not tests that can be run with `make test`. +Both of these are tested in the Dockerfile so they are tested as part of the automated build. Please +look at that dockerfile to see how to test these. \ No newline at end of file diff --git a/test/integration/cmake/configs/robertson/reactions.json b/test/integration/cmake/configs/robertson/reactions.json new file mode 100644 index 000000000..cbffae848 --- /dev/null +++ b/test/integration/cmake/configs/robertson/reactions.json @@ -0,0 +1,43 @@ +{ + "camp-data": [ + { + "name": "reaction rates no user defined", + "type": "MECHANISM", + "reactions": [ + { + "type": "PHOTOLYSIS", + "reactants": { + "A": {} + }, + "products": { + "B": {} + }, + "MUSICA name": "r1" + }, + { + "type": "PHOTOLYSIS", + "reactants": { + "B": { "qty": 2} + }, + "products": { + "B": {}, + "C": {} + }, + "MUSICA name": "r2" + }, + { + "type": "PHOTOLYSIS", + "reactants": { + "B": {}, + "C": {} + }, + "products": { + "A": {}, + "C": {} + }, + "MUSICA name": "r3" + } + ] + } + ] +} \ No newline at end of file diff --git a/test/integration/cmake/configs/robertson/species.json b/test/integration/cmake/configs/robertson/species.json new file mode 100644 index 000000000..5a1a8db68 --- /dev/null +++ b/test/integration/cmake/configs/robertson/species.json @@ -0,0 +1,16 @@ +{ + "camp-data": [ + { + "name": "A", + "type": "CHEM_SPEC" + }, + { + "name": "B", + "type": "CHEM_SPEC" + }, + { + "name": "C", + "type": "CHEM_SPEC" + } + ] +} \ No newline at end of file diff --git a/test/integration/cmake/fetch_content/CMakeLists.txt b/test/integration/cmake/fetch_content/CMakeLists.txt new file mode 100644 index 000000000..0003ff08b --- /dev/null +++ b/test/integration/cmake/fetch_content/CMakeLists.txt @@ -0,0 +1,37 @@ +cmake_minimum_required(VERSION 3.11) + +project( + test_micm_fetch_content + VERSION 0.0.0 + LANGUAGES CXX +) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) + +include(FetchContent) + +FetchContent_Declare(micm + GIT_REPOSITORY https://github.com/NCAR/micm.git + GIT_TAG 0996e5848b097e77ccbb2819f22c49844154f3e3 +) + +FetchContent_MakeAvailable(micm) + +################################################################################ +# Tests +add_executable(test_micm ../test_micm.cpp) + +target_link_libraries(test_micm + PUBLIC + musica::micm +) + +enable_testing() + +add_test( + NAME test_micm + COMMAND test_micm +) + +add_custom_target(copy_configs ALL ${CMAKE_COMMAND} -E copy_directory + ${CMAKE_CURRENT_SOURCE_DIR}/../configs ${CMAKE_BINARY_DIR}/configs) \ No newline at end of file diff --git a/test/integration/cmake/find_package/CMakeLists.txt b/test/integration/cmake/find_package/CMakeLists.txt new file mode 100644 index 000000000..c27ec0d37 --- /dev/null +++ b/test/integration/cmake/find_package/CMakeLists.txt @@ -0,0 +1,30 @@ +cmake_minimum_required(VERSION 3.11) + +project( + test_micm_fetch_content + VERSION 0.0.0 + LANGUAGES CXX +) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) + +find_package(micm 3.2.0 REQUIRED) + +################################################################################ +# Tests +add_executable(test_micm ../test_micm.cpp) + +target_link_libraries(test_micm + PUBLIC + musica::micm +) + +enable_testing() + +add_test( + NAME test_micm + COMMAND test_micm +) + +add_custom_target(copy_configs ALL ${CMAKE_COMMAND} -E copy_directory + ${CMAKE_CURRENT_SOURCE_DIR}/../configs ${CMAKE_BINARY_DIR}/configs) \ No newline at end of file diff --git a/test/integration/cmake/test_micm.cpp b/test/integration/cmake/test_micm.cpp new file mode 100644 index 000000000..03974f612 --- /dev/null +++ b/test/integration/cmake/test_micm.cpp @@ -0,0 +1,87 @@ +#include +#include + +using namespace micm; + +void print_header() +{ + std::cout << std::setw(5) << "time" + << "," << std::setw(10) << "A" + << "," << std::setw(10) << "B" + << "," << std::setw(10) << "C" << std::endl; +} + +template class T> +void print_state(double time, State& state) +{ + std::ios oldState(nullptr); + oldState.copyfmt(std::cout); + + std::cout << std::setw(5) << time << ","; + std::cout << std::scientific << std::setprecision(2) + << std::setw(10) << state.variables_[0][state.variable_map_["A"]] << "," + << std::setw(10) << state.variables_[0][state.variable_map_["B"]] << "," + << std::setw(10) << state.variables_[0][state.variable_map_["C"]] + << std::endl; + + std::cout.copyfmt(oldState); +} + +int main() +{ + constexpr size_t n_threads = 3; + + SolverConfig solverConfig; + + std::string config_path = "./configs/robertson"; + ConfigParseStatus status = solverConfig.ReadAndParse(config_path); + if (status != micm::ConfigParseStatus::Success) + { + throw "Parsing failed"; + } + + micm::SolverParameters solver_params = solverConfig.GetSolverParams(); + + auto chemical_system = solver_params.system_; + auto reactions = solver_params.processes_; + + RosenbrockSolver<> solver{ chemical_system, + reactions, + RosenbrockSolverParameters::three_stage_rosenbrock_parameters(1, false) }; + State state = solver.GetState(); + + // mol m-3 + state.variables_[0] = { 1, 0, 0 }; + + double k1 = 0.04; + double k2 = 3e7; + double k3 = 1e4; + state.SetCustomRateParameter("PHOTO.r1", k1); + state.SetCustomRateParameter("PHOTO.r2", k2); + state.SetCustomRateParameter("PHOTO.r3", k3); + + double temperature = 272.5; // [K] + double pressure = 101253.3; // [Pa] + double air_density = 1e6; // [mol m-3] + + state.conditions_[0].temperature_ = temperature; + state.conditions_[0].pressure_ = pressure; + state.conditions_[0].air_density_ = air_density; + + double time_step = 200; // s + + print_header(); + print_state(0, state); + for (int i = 0; i < 10; ++i) + { + double elapsed_solve_time = 0; + + while (elapsed_solve_time < time_step) + { + auto result = solver.Solve(time_step - elapsed_solve_time, state); + elapsed_solve_time = result.final_time_; + state.variables_ = result.result_; + } + print_state(time_step * (i + 1), state); + } +} \ No newline at end of file diff --git a/test/tutorial/test_but_how_fast_is_it.cpp b/test/tutorial/test_but_how_fast_is_it.cpp index 0cb133a83..cdc114fd3 100644 --- a/test/tutorial/test_but_how_fast_is_it.cpp +++ b/test/tutorial/test_but_how_fast_is_it.cpp @@ -7,12 +7,6 @@ // Use our namespace so that this example is easier to read using namespace micm; -// The Rosenbrock solver can use many matrix ordering types -// Here, we use the default ordering, but we still need to provide a templated -// Arguent to the solver so it can use the proper ordering with any data type -template -using SparseMatrixPolicy = SparseMatrix; - int main() { auto a = Species("A"); @@ -39,7 +33,7 @@ int main() .rate_constant(UserDefinedRateConstant({ .label_ = "r3" })) .phase(gas_phase); - RosenbrockSolver solver{ System(SystemParameters{ .gas_phase_ = gas_phase }), + RosenbrockSolver<> solver{ System(SystemParameters{ .gas_phase_ = gas_phase }), std::vector{ r1, r2, r3 }, RosenbrockSolverParameters::three_stage_rosenbrock_parameters( 3, false) }; diff --git a/test/tutorial/test_multiple_grid_cells.cpp b/test/tutorial/test_multiple_grid_cells.cpp index 57b17c691..bf0216108 100644 --- a/test/tutorial/test_multiple_grid_cells.cpp +++ b/test/tutorial/test_multiple_grid_cells.cpp @@ -6,12 +6,6 @@ // Use our namespace so that this example is easier to read using namespace micm; -// The Rosenbrock solver can use many matrix ordering types -// Here, we use the default ordering, but we still need to provide a templated -// Arguent to the solver so it can use the proper ordering with any data type -template -using SparseMatrixPolicy = SparseMatrix; - void print_header() { std::cout << std::setw(5) << "time" @@ -76,7 +70,7 @@ int main() .rate_constant(micm::UserDefinedRateConstant({ .label_ = "r3" })) .phase(gas_phase); - micm::RosenbrockSolver solver{ + micm::RosenbrockSolver<> solver{ micm::System(micm::SystemParameters{ .gas_phase_ = gas_phase }), std::vector{ r1, r2, r3 }, micm::RosenbrockSolverParameters::three_stage_rosenbrock_parameters(3, false) diff --git a/test/tutorial/test_rate_constants_user_defined_by_hand.cpp b/test/tutorial/test_rate_constants_user_defined_by_hand.cpp index 6938c20ee..df997e096 100644 --- a/test/tutorial/test_rate_constants_user_defined_by_hand.cpp +++ b/test/tutorial/test_rate_constants_user_defined_by_hand.cpp @@ -15,12 +15,6 @@ // Use our namespace so that this example is easier to read using namespace micm; -// The Rosenbrock solver can use many matrix ordering types -// Here, we use the default ordering, but we still need to provide a templated -// Arguent to the solver so it can use the proper ordering with any data type -template -using SparseMatrixPolicy = SparseMatrix; - void print_header() { std::cout << std::setw(5) << "time" @@ -152,7 +146,7 @@ int main(const int argc, const char* argv[]) auto chemical_system = System(micm::SystemParameters{ .gas_phase_ = gas_phase }); auto reactions = std::vector{ r1, r2, r3, r4, r5, r6, r7, r8, r9, r10 }; - RosenbrockSolver solver{ chemical_system, + RosenbrockSolver<> solver{ chemical_system, reactions, RosenbrockSolverParameters::three_stage_rosenbrock_parameters() }; State state = solver.GetState(); diff --git a/test/tutorial/test_rate_constants_user_defined_with_config.cpp b/test/tutorial/test_rate_constants_user_defined_with_config.cpp index 2d0218ecf..60ba430e4 100644 --- a/test/tutorial/test_rate_constants_user_defined_with_config.cpp +++ b/test/tutorial/test_rate_constants_user_defined_with_config.cpp @@ -15,12 +15,6 @@ // Use our namespace so that this example is easier to read using namespace micm; -// The Rosenbrock solver can use many matrix ordering types -// Here, we use the default ordering, but we still need to provide a templated -// Arguent to the solver so it can use the proper ordering with any data type -template -using SparseMatrixPolicy = SparseMatrix; - void print_header() { std::cout << std::setw(5) << "time" @@ -68,7 +62,7 @@ int main(const int argc, const char* argv[]) auto chemical_system = solver_params.system_; auto reactions = solver_params.processes_; - RosenbrockSolver solver{ chemical_system, + RosenbrockSolver<> solver{ chemical_system, reactions, RosenbrockSolverParameters::three_stage_rosenbrock_parameters() }; diff --git a/test/tutorial/test_solver_configuration.cpp b/test/tutorial/test_solver_configuration.cpp index 7f208005b..611fadecc 100644 --- a/test/tutorial/test_solver_configuration.cpp +++ b/test/tutorial/test_solver_configuration.cpp @@ -7,12 +7,6 @@ // Use our namespace so that this example is easier to read using namespace micm; -// The Rosenbrock solver can use many matrix ordering types -// Here, we use the default ordering, but we still need to provide a templated -// Arguent to the solver so it can use the proper ordering with any data type -template -using SparseMatrixPolicy = SparseMatrix; - void print_header() { std::cout << std::setw(5) << "time" @@ -150,23 +144,23 @@ int main() auto system = System(SystemParameters{ .gas_phase_ = gas_phase }); auto reactions = std::vector{ r1, r2, r3 }; - RosenbrockSolver two_stage{ + RosenbrockSolver<> two_stage{ system, reactions, RosenbrockSolverParameters::two_stage_rosenbrock_parameters() }; - RosenbrockSolver three_stage{ + RosenbrockSolver<> three_stage{ system, reactions, RosenbrockSolverParameters::three_stage_rosenbrock_parameters() }; - RosenbrockSolver four_stage{ + RosenbrockSolver<> four_stage{ system, reactions, RosenbrockSolverParameters::four_stage_rosenbrock_parameters() }; - RosenbrockSolver four_stage_da{ + RosenbrockSolver<> four_stage_da{ system, reactions, RosenbrockSolverParameters::four_stage_differential_algebraic_rosenbrock_parameters() }; - RosenbrockSolver six_stage_da{ + RosenbrockSolver<> six_stage_da{ system, reactions, RosenbrockSolverParameters::six_stage_differential_algebraic_rosenbrock_parameters() };