diff --git a/Applications/ApplicationsLib/ProjectData.cpp b/Applications/ApplicationsLib/ProjectData.cpp index 5ba3c4933e6860e449c07c870e23741d5fae4b91..03b4cf6ed16047d757ef17d4ad8b96091c927ab2 100644 --- a/Applications/ApplicationsLib/ProjectData.cpp +++ b/Applications/ApplicationsLib/ProjectData.cpp @@ -192,15 +192,13 @@ void ProjectData::parseProcesses(ConfigTree const& processes_config) DBUG("Reading processes:\n"); for (auto pc_it : processes_config) { ConfigTree const& process_config = pc_it.second; - if (process_config.get<std::string>("type") == "GROUNDWATER_FLOW") { - // The existence check of the in the configuration referenced - // process variables is checked in the physical process. - // TODO at the moment we have only one mesh, later there can be - // several meshes. Then we have to assign the referenced mesh - // here. - _processes.push_back(new ProcessLib::GroundwaterFlowProcess( - *_mesh_vec[0], _process_variables, process_config) - ); + + // Check if the process type is specified. + if (!process_config.get_optional<std::string>("type")) { + ERR("The process config does not provide a type tag."); + ERR(" Ignoring this process config."); + continue; } + _process_configs.push_back(process_config); } } diff --git a/Applications/ApplicationsLib/ProjectData.h b/Applications/ApplicationsLib/ProjectData.h index 6797f1415ff32259021aacab30acb26e891b9760..da654247bc712d5668d76c0dfddf5a3427c16e90 100644 --- a/Applications/ApplicationsLib/ProjectData.h +++ b/Applications/ApplicationsLib/ProjectData.h @@ -22,6 +22,7 @@ #endif #include "ProcessLib/ProcessVariable.h" +#include "ProcessLib/Process.h" namespace MeshLib { class Mesh; } @@ -78,6 +79,35 @@ public: /// false otherwise. bool removeMesh(const std::string &name); + // + // Process interface + // + + /// Builder for processes. The supplied template defines the types of global + /// vectors and matrices, and the global executor. These types are passed to + /// every of the constructed processes. + template <typename GlobalSetupType> + void buildProcesses() + { + for (auto pc : _process_configs) + { + /* Adding of a specific proccess will look like in the following + * if-clause. Commented, because there is no GroundwaterFlow process + * for now. + if (pc.get<std::string>("type") == "GROUNDWATER_FLOW") { + // The existence check of the in the configuration referenced + // process variables is checked in the physical process. + // TODO at the moment we have only one mesh, later there can be + // several meshes. Then we have to assign the referenced mesh + // here. + _processes.push_back( + new ProcessLib::GroundwaterFlowProcess<GlobalSetupType>( + *_mesh_vec[0], _process_variables, pc)); + } + */ + } + } + private: /// Checks if a mesh with the same name exists and provides a unique name in /// case of already existing mesh. Returns true if the mesh name is unique. @@ -113,6 +143,11 @@ private: std::vector<MeshLib::Mesh*> _mesh_vec; std::vector<ProcessLib::Process*> _processes; std::vector<ProcessLib::ProcessVariable> _process_variables; + + /// Buffer for each process' config used in the process building function. + std::vector<ConfigTree> _process_configs; + + }; #endif //PROJECTDATA_H_ diff --git a/Applications/CLI/NumericsConfig.h b/Applications/CLI/NumericsConfig.h new file mode 100644 index 0000000000000000000000000000000000000000..aeffba2c3fe9e87063c3423143db7c3a65d4ce5b --- /dev/null +++ b/Applications/CLI/NumericsConfig.h @@ -0,0 +1,89 @@ +/** + * \copyright + * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#ifndef APPLICATIONS_NUMERICSCONFIG_H_ +#define APPLICATIONS_NUMERICSCONFIG_H_ + +#include <type_traits> + +/** + * This file provides a configuration of the global matrix/vector and + * corresponding linear solver, and the global executer types. + * The configuration is collected in the GlobalSetupType being a particular + * instantiation of the AssemblerLib::GlobalSetup template. + * The existence of the GlobalSetupType is checked at the end of the file. + */ + +// +// Global vector/matrix types and linear solver. +// +#ifdef USE_LIS + + #include "MathLib/LinAlg/Lis/LisMatrix.h" + #include "MathLib/LinAlg/Lis/LisVector.h" + #include "MathLib/LinAlg/Lis/LisLinearSolver.h" + +namespace detail +{ + using GlobalVectorType = MathLib::LisVector; + using GlobalMatrixType = MathLib::LisMatrix; + + using LinearSolverType = MathLib::LisLinearSolver; +} + +#else // USE_LIS + #include "MathLib/LinAlg/Dense/DenseVector.h" + #include "MathLib/LinAlg/Dense/GlobalDenseMatrix.h" + #include "MathLib/LinAlg/Solvers/GaussAlgorithm.h" +namespace detail +{ + using GlobalVectorType = MathLib::DenseVector<double>; + using GlobalMatrixType = MathLib::GlobalDenseMatrix<double>; + + using LinearSolverType = + MathLib::GaussAlgorithm<GlobalMatrixType, GlobalVectorType>; +} + +#endif // USE_LIS + + +// +// Global executor and vector/matrix builder. +// +#include "AssemblerLib/SerialExecutor.h" +#include "AssemblerLib/SerialVectorMatrixBuilder.h" + +namespace detail +{ +using GlobalExecutorType = AssemblerLib::SerialExecutor; + +using GlobalVectorMatrixBuilderType = + AssemblerLib::SerialVectorMatrixBuilder< + GlobalMatrixType, + GlobalVectorType>; +} + + +#include "AssemblerLib/GlobalSetup.h" + +/// +/// Global setup collects the previous configuration in single place. +/// +using GlobalSetupType = + AssemblerLib::GlobalSetup< + detail::GlobalVectorMatrixBuilderType, + detail::GlobalExecutorType>; + + +// +// Check the configuration +// +static_assert(std::is_class<GlobalSetupType>::value, + "GlobalSetupType was not defined."); +#endif // APPLICATIONS_NUMERICSCONFIG_H_ diff --git a/Applications/CLI/ogs.cpp b/Applications/CLI/ogs.cpp index a1eed4a3e9d217f82adada9a1b87ce267454ea3f..d90ea999b16ebd72e404ce364f0c90dffd5dbfb2 100644 --- a/Applications/CLI/ogs.cpp +++ b/Applications/CLI/ogs.cpp @@ -27,6 +27,7 @@ #include "Applications/ApplicationsLib/ProjectData.h" +#include "NumericsConfig.h" int main(int argc, char *argv[]) @@ -73,6 +74,9 @@ int main(int argc, char *argv[]) ProjectData project(project_config, BaseLib::extractPath(project_arg.getValue())); + // Create processes. + project.buildProcesses<GlobalSetupType>(); + delete fmt; delete logog_cout;