diff --git a/MathLib/LinAlg/Eigen/LinearSolverOptionsParser.cpp b/MathLib/LinAlg/Eigen/LinearSolverOptionsParser.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..56d37a10e69a5fe7fcf26960b340c1d6b9d704ca
--- /dev/null
+++ b/MathLib/LinAlg/Eigen/LinearSolverOptionsParser.cpp
@@ -0,0 +1,146 @@
+/**
+ * \file
+ * \copyright
+ * Copyright (c) 2012-2022, OpenGeoSys Community (http://www.opengeosys.org)
+ *            Distributed under a Modified BSD License.
+ *              See accompanying file LICENSE.txt or
+ *              http://www.opengeosys.org/project/license
+ *
+ */
+
+#include "LinearSolverOptionsParser.h"
+
+#include "BaseLib/ConfigTree.h"
+#include "BaseLib/Error.h"
+#include "MathLib/LinAlg/LinearSolverOptions.h"
+
+namespace MathLib
+{
+std::tuple<std::string, EigenOption>
+LinearSolverOptionsParser<EigenLinearSolver>::parseNameAndOptions(
+    std::string const& prefix,
+    BaseLib::ConfigTree const* const solver_config) const
+{
+    if (!solver_config)
+    {
+        return {prefix, EigenOption{}};
+    }
+
+    ignoreOtherLinearSolvers(*solver_config, "eigen");
+    //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen}
+    auto const config = solver_config->getConfigSubtreeOptional("eigen");
+    if (!config)
+    {
+        OGS_FATAL(
+            "OGS was compiled with Eigen but the config section in the "
+            "project file seems to be invalid");
+    }
+
+    EigenOption options;
+
+    if (auto solver_type =
+            //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__solver_type}
+        config->getConfigParameterOptional<std::string>("solver_type"))
+    {
+        options.solver_type = MathLib::EigenOption::getSolverType(*solver_type);
+    }
+    if (auto precon_type =
+            //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__precon_type}
+        config->getConfigParameterOptional<std::string>("precon_type"))
+    {
+        options.precon_type = MathLib::EigenOption::getPreconType(*precon_type);
+    }
+    if (auto error_tolerance =
+            //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__error_tolerance}
+        config->getConfigParameterOptional<double>("error_tolerance"))
+    {
+        options.error_tolerance = *error_tolerance;
+    }
+    if (auto max_iteration_step =
+            //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__max_iteration_step}
+        config->getConfigParameterOptional<int>("max_iteration_step"))
+    {
+        options.max_iterations = *max_iteration_step;
+    }
+    if (auto scaling =
+            //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__scaling}
+        config->getConfigParameterOptional<bool>("scaling"))
+    {
+#ifdef USE_EIGEN_UNSUPPORTED
+        options.scaling = *scaling;
+#else
+        OGS_FATAL(
+            "The code is not compiled with the Eigen unsupported modules. "
+            "scaling is not available.");
+#endif
+    }
+    if (auto restart =
+            //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__restart}
+        config->getConfigParameterOptional<int>("restart"))
+    {
+#ifdef USE_EIGEN_UNSUPPORTED
+        options.restart = *restart;
+#else
+        OGS_FATAL(
+            "The code is not compiled with the Eigen unsupported modules. "
+            "GMRES/GMRES option restart is not available.");
+#endif
+    }
+    if (auto l =
+            //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__l}
+        config->getConfigParameterOptional<int>("l"))
+    {
+#ifdef USE_EIGEN_UNSUPPORTED
+        options.l = *l;
+#else
+        OGS_FATAL(
+            "The code is not compiled with the Eigen unsupported modules.");
+#endif
+    }
+    if (auto s =
+            //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__s}
+        config->getConfigParameterOptional<int>("s"))
+    {
+#ifdef USE_EIGEN_UNSUPPORTED
+        options.s = *s;
+#else
+        OGS_FATAL(
+            "The code is not compiled with the Eigen unsupported modules.");
+#endif
+    }
+    if (auto smoothing =
+            //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__smoothing}
+        config->getConfigParameterOptional<int>("smoothing"))
+    {
+#ifdef USE_EIGEN_UNSUPPORTED
+        options.smoothing = *smoothing;
+#else
+        OGS_FATAL(
+            "The code is not compiled with the Eigen unsupported modules.");
+#endif
+    }
+    if (auto angle =
+            //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__angle}
+        config->getConfigParameterOptional<int>("angle"))
+    {
+#ifdef USE_EIGEN_UNSUPPORTED
+        options.angle = *angle;
+#else
+        OGS_FATAL(
+            "The code is not compiled with the Eigen unsupported modules.");
+#endif
+    }
+    if (auto residualupdate =
+            //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__residual_update}
+        config->getConfigParameterOptional<int>("residual_update"))
+    {
+#ifdef USE_EIGEN_UNSUPPORTED
+        options.residualupdate = *residualupdate;
+#else
+        OGS_FATAL(
+            "The code is not compiled with the Eigen unsupported modules.");
+#endif
+    }
+    return {prefix, options};
+}
+}  // namespace MathLib
diff --git a/MathLib/LinAlg/Eigen/LinearSolverOptionsParser.h b/MathLib/LinAlg/Eigen/LinearSolverOptionsParser.h
index 87c2ed0df17ffc136bcc4be159ae0d4118b687e2..ef24f33e967afbda3e23f1ed32b28b6a6fe4046a 100644
--- a/MathLib/LinAlg/Eigen/LinearSolverOptionsParser.h
+++ b/MathLib/LinAlg/Eigen/LinearSolverOptionsParser.h
@@ -10,16 +10,15 @@
 
 #pragma once
 
-#include <memory>
-#include <vector>
-
-#include "BaseLib/ConfigTree.h"
-#include "BaseLib/Error.h"
 #include "EigenLinearSolver.h"
 #include "EigenOption.h"
-#include "MathLib/LinAlg/LinearSolverOptions.h"
 #include "MathLib/LinAlg/LinearSolverOptionsParser.h"
 
+namespace BaseLib
+{
+class ConfigTree;
+}
+
 namespace MathLib
 {
 template <>
@@ -34,132 +33,7 @@ struct LinearSolverOptionsParser<EigenLinearSolver> final
     /// string, the second item are all the options as an EigenOption object
     std::tuple<std::string, EigenOption> parseNameAndOptions(
         std::string const& prefix,
-        BaseLib::ConfigTree const* const solver_config) const
-    {
-        if (!solver_config)
-        {
-            return {prefix, EigenOption{}};
-        }
-
-        ignoreOtherLinearSolvers(*solver_config, "eigen");
-        //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen}
-        auto const config = solver_config->getConfigSubtreeOptional("eigen");
-        if (!config)
-        {
-            OGS_FATAL(
-                "OGS was compiled with Eigen but the config section in the "
-                "project file seems to be invalid");
-        }
-
-        EigenOption options;
-
-        if (auto solver_type =
-                //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__solver_type}
-            config->getConfigParameterOptional<std::string>("solver_type"))
-        {
-            options.solver_type =
-                MathLib::EigenOption::getSolverType(*solver_type);
-        }
-        if (auto precon_type =
-                //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__precon_type}
-            config->getConfigParameterOptional<std::string>("precon_type"))
-        {
-            options.precon_type =
-                MathLib::EigenOption::getPreconType(*precon_type);
-        }
-        if (auto error_tolerance =
-                //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__error_tolerance}
-            config->getConfigParameterOptional<double>("error_tolerance"))
-        {
-            options.error_tolerance = *error_tolerance;
-        }
-        if (auto max_iteration_step =
-                //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__max_iteration_step}
-            config->getConfigParameterOptional<int>("max_iteration_step"))
-        {
-            options.max_iterations = *max_iteration_step;
-        }
-        if (auto scaling =
-                //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__scaling}
-            config->getConfigParameterOptional<bool>("scaling"))
-        {
-#ifdef USE_EIGEN_UNSUPPORTED
-            options.scaling = *scaling;
-#else
-            OGS_FATAL(
-                "The code is not compiled with the Eigen unsupported modules. "
-                "scaling is not available.");
-#endif
-        }
-        if (auto restart =
-                //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__restart}
-            config->getConfigParameterOptional<int>("restart"))
-        {
-#ifdef USE_EIGEN_UNSUPPORTED
-            options.restart = *restart;
-#else
-            OGS_FATAL(
-                "The code is not compiled with the Eigen unsupported modules. "
-                "GMRES/GMRES option restart is not available.");
-#endif
-        }
-        if (auto l =
-            //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__l}
-            config->getConfigParameterOptional<int>("l"))
-        {
-#ifdef USE_EIGEN_UNSUPPORTED
-            options.l = *l;
-#else
-            OGS_FATAL(
-                "The code is not compiled with the Eigen unsupported modules.");
-#endif
-        }
-        if (auto s =
-            //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__s}
-            config->getConfigParameterOptional<int>("s"))
-        {
-#ifdef USE_EIGEN_UNSUPPORTED
-            options.s = *s;
-#else
-            OGS_FATAL(
-                "The code is not compiled with the Eigen unsupported modules.");
-#endif
-        }
-        if (auto smoothing =
-            //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__smoothing}
-            config->getConfigParameterOptional<int>("smoothing"))
-        {
-#ifdef USE_EIGEN_UNSUPPORTED
-            options.smoothing = *smoothing;
-#else
-            OGS_FATAL(
-                "The code is not compiled with the Eigen unsupported modules.");
-#endif
-        }
-        if (auto angle =
-            //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__angle}
-            config->getConfigParameterOptional<int>("angle"))
-        {
-#ifdef USE_EIGEN_UNSUPPORTED
-            options.angle = *angle;
-#else
-            OGS_FATAL(
-                "The code is not compiled with the Eigen unsupported modules.");
-#endif
-        }
-        if (auto residualupdate =
-            //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__residual_update}
-            config->getConfigParameterOptional<int>("residual_update"))
-        {
-#ifdef USE_EIGEN_UNSUPPORTED
-            options.residualupdate = *residualupdate;
-#else
-            OGS_FATAL(
-                "The code is not compiled with the Eigen unsupported modules.");
-#endif
-        }
-        return {prefix, options};
-    }
+        BaseLib::ConfigTree const* const solver_config) const;
 };
 
 }  // namespace MathLib
diff --git a/MathLib/LinAlg/EigenLis/LinearSolverOptionsParser.cpp b/MathLib/LinAlg/EigenLis/LinearSolverOptionsParser.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4066ef5c957d8c15c46a8ba8f928c2f9957a656a
--- /dev/null
+++ b/MathLib/LinAlg/EigenLis/LinearSolverOptionsParser.cpp
@@ -0,0 +1,42 @@
+/**
+ * \file
+ * \copyright
+ * Copyright (c) 2012-2022, OpenGeoSys Community (http://www.opengeosys.org)
+ *            Distributed under a Modified BSD License.
+ *              See accompanying file LICENSE.txt or
+ *              http://www.opengeosys.org/project/license
+ *
+ */
+
+#pragma once
+
+#include "LinearSolverOptionsParser.h"
+
+#include "BaseLib/ConfigTree.h"
+#include "BaseLib/Logging.h"
+#include "MathLib/LinAlg/LinearSolverOptions.h"
+
+namespace MathLib
+{
+std::tuple<std::string, std::string>
+LinearSolverOptionsParser<EigenLisLinearSolver>::parseNameAndOptions(
+    std::string const& prefix, BaseLib::ConfigTree const* const config) const
+{
+    std::string lis_options = "-initx_zeros 0";
+
+    if (config)
+    {
+        ignoreOtherLinearSolvers(*config, "lis");
+        //! \ogs_file_param{prj__linear_solvers__linear_solver__lis}
+        if (auto s = config->getConfigParameterOptional<std::string>("lis"))
+        {
+            if (!s->empty())
+            {
+                lis_options += " " + *s;
+                INFO("Lis options: '{:s}'", lis_options);
+            }
+        }
+    }
+    return {prefix, lis_options};
+}
+}  // namespace MathLib
diff --git a/MathLib/LinAlg/EigenLis/LinearSolverOptionsParser.h b/MathLib/LinAlg/EigenLis/LinearSolverOptionsParser.h
index 7e9a99b72b46136b79fcd3067047705f1029f3a5..c5b49a4b7e59ad82b975de94280f57c8a0ef13ec 100644
--- a/MathLib/LinAlg/EigenLis/LinearSolverOptionsParser.h
+++ b/MathLib/LinAlg/EigenLis/LinearSolverOptionsParser.h
@@ -10,10 +10,11 @@
 
 #pragma once
 
-#include "BaseLib/ConfigTree.h"
-#include "BaseLib/Logging.h"
+namespace BaseLib
+{
+class ConfigTree;
+}
 #include "MathLib/LinAlg/EigenLis/EigenLisLinearSolver.h"
-#include "MathLib/LinAlg/LinearSolverOptions.h"
 #include "MathLib/LinAlg/LinearSolverOptionsParser.h"
 
 namespace MathLib
@@ -31,25 +32,7 @@ struct LinearSolverOptionsParser<EigenLisLinearSolver> final
     /// passed to LIS via lis_solver_set_options()
     std::tuple<std::string, std::string> parseNameAndOptions(
         std::string const& prefix,
-        BaseLib::ConfigTree const* const config) const
-    {
-        std::string lis_options = "-initx_zeros 0";
-
-        if (config)
-        {
-            ignoreOtherLinearSolvers(*config, "lis");
-            //! \ogs_file_param{prj__linear_solvers__linear_solver__lis}
-            if (auto s = config->getConfigParameterOptional<std::string>("lis"))
-            {
-                if (!s->empty())
-                {
-                    lis_options += " " + *s;
-                    INFO("Lis options: '{:s}'", lis_options);
-                }
-            }
-        }
-        return {prefix, lis_options};
-    }
+        BaseLib::ConfigTree const* const config) const;
 };
 
 }  // namespace MathLib
diff --git a/MathLib/LinAlg/PETSc/LinearSolverOptionsParser.cpp b/MathLib/LinAlg/PETSc/LinearSolverOptionsParser.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ad9dd51a463e9240425657630f1590bad9841f1a
--- /dev/null
+++ b/MathLib/LinAlg/PETSc/LinearSolverOptionsParser.cpp
@@ -0,0 +1,52 @@
+/**
+ * \file
+ * \copyright
+ * Copyright (c) 2012-2022, OpenGeoSys Community (http://www.opengeosys.org)
+ *            Distributed under a Modified BSD License.
+ *              See accompanying file LICENSE.txt or
+ *              http://www.opengeosys.org/project/license
+ *
+ */
+
+#include "LinearSolverOptionsParser.h"
+
+#include "BaseLib/ConfigTree.h"
+#include "MathLib/LinAlg/LinearSolverOptions.h"
+
+namespace MathLib
+{
+std::tuple<std::string, std::string>
+LinearSolverOptionsParser<PETScLinearSolver>::parseNameAndOptions(
+    std::string solver_prefix, BaseLib::ConfigTree const* const config) const
+{
+    // Insert options into petsc database. Default options are given in the
+    // string below.
+    std::string petsc_options =
+        "-ksp_type cg -pc_type bjacobi -ksp_rtol 1e-16 -ksp_max_it 10000";
+
+    if (config)
+    {
+        ignoreOtherLinearSolvers(*config, "petsc");
+
+        //! \ogs_file_param{prj__linear_solvers__linear_solver__petsc}
+        if (auto const subtree = config->getConfigSubtreeOptional("petsc"))
+        {
+            if (auto const parameters =
+                    //! \ogs_file_param{prj__linear_solvers__linear_solver__petsc__parameters}
+                subtree->getConfigParameterOptional<std::string>("parameters"))
+            {
+                petsc_options = *parameters;
+            }
+
+            if (auto const pre =
+                    //! \ogs_file_param{prj__linear_solvers__linear_solver__petsc__prefix}
+                subtree->getConfigParameterOptional<std::string>("prefix"))
+            {
+                if (!pre->empty())
+                    solver_prefix = *pre + "_";
+            }
+        }
+    }
+    return {solver_prefix, petsc_options};
+}
+}  // namespace MathLib
diff --git a/MathLib/LinAlg/PETSc/LinearSolverOptionsParser.h b/MathLib/LinAlg/PETSc/LinearSolverOptionsParser.h
index 3ab173875a6d3871465b3f11d99bd6ec29074fed..f0e09013180d603d551c3937e1db8043bb83571b 100644
--- a/MathLib/LinAlg/PETSc/LinearSolverOptionsParser.h
+++ b/MathLib/LinAlg/PETSc/LinearSolverOptionsParser.h
@@ -10,11 +10,14 @@
 
 #pragma once
 
-#include "BaseLib/ConfigTree.h"
-#include "MathLib/LinAlg/LinearSolverOptions.h"
 #include "MathLib/LinAlg/LinearSolverOptionsParser.h"
 #include "MathLib/LinAlg/PETSc/PETScLinearSolver.h"
 
+namespace BaseLib
+{
+class ConfigTree;
+}
+
 namespace MathLib
 {
 template <>
@@ -30,39 +33,7 @@ struct LinearSolverOptionsParser<PETScLinearSolver> final
     /// options database
     std::tuple<std::string, std::string> parseNameAndOptions(
         std::string solver_prefix,
-        BaseLib::ConfigTree const* const config) const
-    {
-        // Insert options into petsc database. Default options are given in the
-        // string below.
-        std::string petsc_options =
-            "-ksp_type cg -pc_type bjacobi -ksp_rtol 1e-16 -ksp_max_it 10000";
-
-        if (config)
-        {
-            ignoreOtherLinearSolvers(*config, "petsc");
-
-            //! \ogs_file_param{prj__linear_solvers__linear_solver__petsc}
-            if (auto const subtree = config->getConfigSubtreeOptional("petsc"))
-            {
-                if (auto const parameters =
-                        //! \ogs_file_param{prj__linear_solvers__linear_solver__petsc__parameters}
-                    subtree->getConfigParameterOptional<std::string>(
-                        "parameters"))
-                {
-                    petsc_options = *parameters;
-                }
-
-                if (auto const pre =
-                        //! \ogs_file_param{prj__linear_solvers__linear_solver__petsc__prefix}
-                    subtree->getConfigParameterOptional<std::string>("prefix"))
-                {
-                    if (!pre->empty())
-                        solver_prefix = *pre + "_";
-                }
-            }
-        }
-        return {solver_prefix, petsc_options};
-    }
+        BaseLib::ConfigTree const* const config) const;
 };
 
 }  // namespace MathLib