diff --git a/Applications/ApplicationsLib/ProjectData.cpp b/Applications/ApplicationsLib/ProjectData.cpp index e931ac9a298f75798a41d8b190bfd769f539f1d5..58c6ff0169443a8a9eceece6b25d7dee7db5017d 100644 --- a/Applications/ApplicationsLib/ProjectData.cpp +++ b/Applications/ApplicationsLib/ProjectData.cpp @@ -34,7 +34,7 @@ #include "UncoupledProcessesTimeLoop.h" -#include "ProcessLib/GroundwaterFlow/GroundwaterFlowProcess-fwd.h" +#include "ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.h" #include "ProcessLib/TES/TESProcess.h" @@ -179,14 +179,14 @@ void ProjectData::buildProcesses() // here. _processes.emplace_back( ProcessLib::GroundwaterFlow:: - createGroundwaterFlowProcess<GlobalSetupType>( + createGroundwaterFlowProcess( *_mesh_vec[0], *nl_slv, std::move(time_disc), _process_variables, _parameters, pc)); } else if (type == "TES") { _processes.emplace_back( - ProcessLib::TES::createTESProcess<GlobalSetupType>( + ProcessLib::TES::createTESProcess( *_mesh_vec[0], *nl_slv, std::move(time_disc), _process_variables, _parameters, pc)); } @@ -323,7 +323,7 @@ void ProjectData::parseOutput(BaseLib::ConfigTree const& output_config, output_config.checkConfigParameter("type", "VTK"); DBUG("Parse output configuration:"); - _output = ProcessLib::Output<GlobalSetupType>::newInstance(output_config, output_directory); + _output = ProcessLib::Output::newInstance(output_config, output_directory); } void ProjectData::parseTimeStepping(BaseLib::ConfigTree const& timestepping_config) @@ -351,7 +351,7 @@ void ProjectData::parseLinearSolvers(BaseLib::ConfigTree const& config) BaseLib::insertIfKeyUniqueElseError(_linear_solvers, name, MathLib::createLinearSolver<GlobalMatrix, GlobalVector, - GlobalSetupType::LinearSolver>(&conf), + GlobalLinearSolver>(&conf), "The linear solver name is not unique"); } } diff --git a/Applications/ApplicationsLib/ProjectData.h b/Applications/ApplicationsLib/ProjectData.h index 54a098e5eac0fca1500884ad8da06b22e97d083d..9d5abda1704d66154d445d199698f6fbe3ab79b9 100644 --- a/Applications/ApplicationsLib/ProjectData.h +++ b/Applications/ApplicationsLib/ProjectData.h @@ -55,8 +55,6 @@ class UncoupledProcessesTimeLoop; */ class ProjectData final { - using GlobalMatrix = GlobalSetupType::MatrixType; - using GlobalVector = GlobalSetupType::VectorType; public: /// The time loop type used to solve this project's processes. using TimeLoop = ApplicationsLib::UncoupledProcessesTimeLoop< @@ -117,12 +115,12 @@ public: /// Iterator access for processes. /// Provides read access to the process container. std::vector< - std::unique_ptr<ProcessLib::Process<GlobalSetupType>>>::const_iterator + std::unique_ptr<ProcessLib::Process>>::const_iterator processesBegin() const { return _processes.begin(); } - std::vector<std::unique_ptr<ProcessLib::Process<GlobalSetupType>>>::iterator + std::vector<std::unique_ptr<ProcessLib::Process>>::iterator processesBegin() { return _processes.begin(); @@ -130,24 +128,24 @@ public: /// Iterator access for processes as in processesBegin(). std::vector< - std::unique_ptr<ProcessLib::Process<GlobalSetupType>>>::const_iterator + std::unique_ptr<ProcessLib::Process>>::const_iterator processesEnd() const { return _processes.end(); } - std::vector<std::unique_ptr<ProcessLib::Process<GlobalSetupType>>>::iterator + std::vector<std::unique_ptr<ProcessLib::Process>>::iterator processesEnd() { return _processes.end(); } - ProcessLib::Output<GlobalSetupType> const& + ProcessLib::Output const& getOutputControl() const { return *_output; } - ProcessLib::Output<GlobalSetupType>& + ProcessLib::Output& getOutputControl() { return *_output; @@ -204,7 +202,7 @@ private: private: GeoLib::GEOObjects *_geoObjects = new GeoLib::GEOObjects(); std::vector<MeshLib::Mesh*> _mesh_vec; - std::vector<std::unique_ptr<ProcessLib::Process<GlobalSetupType>>> + std::vector<std::unique_ptr<ProcessLib::Process>> _processes; std::vector<ProcessLib::ProcessVariable> _process_variables; @@ -214,7 +212,7 @@ private: /// Buffer for each parameter config passed to the process. std::vector<std::unique_ptr<ProcessLib::ParameterBase>> _parameters; - std::unique_ptr<ProcessLib::Output<GlobalSetupType>> _output; + std::unique_ptr<ProcessLib::Output> _output; /// The time loop used to solve this project's processes. std::unique_ptr<TimeLoop> _time_loop; diff --git a/Applications/ApplicationsLib/UncoupledProcessesTimeLoop.h b/Applications/ApplicationsLib/UncoupledProcessesTimeLoop.h index 275aeea03e4bbc4bb9b17de749901d9a541fd118..2ce2b8a2c37dbc30ad6293408b8bf1ddd0fa5db3 100644 --- a/Applications/ApplicationsLib/UncoupledProcessesTimeLoop.h +++ b/Applications/ApplicationsLib/UncoupledProcessesTimeLoop.h @@ -45,7 +45,7 @@ private: //! An abstract equations system using EquationSystem = NumLib::EquationSystem<Vector>; //! An abstract process - using Process = ProcessLib::Process<GlobalSetupType>; + using Process = ProcessLib::Process; //! An abstract time discretization using TimeDisc = NumLib::TimeDiscretization<Vector>; diff --git a/MathLib/LinAlg/GlobalMatrixVectorTypes.h b/MathLib/LinAlg/GlobalMatrixVectorTypes.h index 4dafd718ddf9692cbf35c182129243c12561e43b..a3ddae379717880c8ecbe86806d647dff92fcff1 100644 --- a/MathLib/LinAlg/GlobalMatrixVectorTypes.h +++ b/MathLib/LinAlg/GlobalMatrixVectorTypes.h @@ -21,66 +21,45 @@ #include "MathLib/LinAlg/Eigen/EigenVector.h" #include "MathLib/LinAlg/EigenLis/EigenLisLinearSolver.h" - namespace detail - { - using GlobalVectorType = MathLib::EigenVector; - using GlobalMatrixType = MathLib::EigenMatrix; + using GlobalVector = MathLib::EigenVector; + using GlobalMatrix = MathLib::EigenMatrix; - using LinearSolverType = MathLib::EigenLisLinearSolver; - } + using GlobalLinearSolver = MathLib::EigenLisLinearSolver; #elif defined(USE_PETSC) #include "MathLib/LinAlg/PETSc/PETScVector.h" #include "MathLib/LinAlg/PETSc/PETScMatrix.h" #include "MathLib/LinAlg/PETSc/PETScLinearSolver.h" -namespace detail -{ - using GlobalVectorType = MathLib::PETScVector; - using GlobalMatrixType = MathLib::PETScMatrix; - using LinearSolverType = MathLib::PETScLinearSolver; -} + using GlobalVector = MathLib::PETScVector; + using GlobalMatrix = MathLib::PETScMatrix; -#else -#ifdef OGS_USE_EIGEN + using GlobalLinearSolver = MathLib::PETScLinearSolver; + +#elif defined(OGS_USE_EIGEN) #include "MathLib/LinAlg/Eigen/EigenVector.h" #include "MathLib/LinAlg/Eigen/EigenMatrix.h" #include "MathLib/LinAlg/Eigen/EigenLinearSolver.h" -namespace detail -{ - using GlobalVectorType = MathLib::EigenVector; - using GlobalMatrixType = MathLib::EigenMatrix; - - using LinearSolverType = MathLib::EigenLinearSolver; -} -#else // OGS_USE_EIGEN - #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 + + using GlobalVector = MathLib::EigenVector; + using GlobalMatrix = MathLib::EigenMatrix; + + using GlobalLinearSolver = MathLib::EigenLinearSolver; + #endif // OGS_USE_EIGEN /// A type used for indexing of global vectors and matrices. It is equal to the -/// GlobalMatrixType::IndexType and the GlobalVectorType::IndexType. -static_assert(std::is_integral<detail::GlobalMatrixType::IndexType>::value, +/// GlobalMatrix::IndexType and the GlobalVector::IndexType. +static_assert(std::is_integral<GlobalMatrix::IndexType>::value, "The index type for global matrices is not an integral type."); -static_assert(std::is_integral<detail::GlobalVectorType::IndexType>::value, +static_assert(std::is_integral<GlobalVector::IndexType>::value, "The index type for global vectors is not an integral type."); -static_assert(std::is_same<detail::GlobalMatrixType::IndexType, - detail::GlobalVectorType::IndexType>::value, +static_assert(std::is_same<GlobalMatrix::IndexType, + GlobalVector::IndexType>::value, "The global matrix and vector index types do not match."); // Both types are integral types and equal, define a single GlobalIndexType. -using GlobalIndexType = detail::GlobalMatrixType::IndexType; +using GlobalIndexType = GlobalMatrix::IndexType; using GlobalSparsityPattern = MathLib::SparsityPattern<GlobalIndexType>; diff --git a/NumLib/Assembler/VectorMatrixBuilder.h b/NumLib/Assembler/VectorMatrixBuilder.h deleted file mode 100644 index fbba5d69459e353b7db87e12d93097d92a1c7f55..0000000000000000000000000000000000000000 --- a/NumLib/Assembler/VectorMatrixBuilder.h +++ /dev/null @@ -1,49 +0,0 @@ -/** - * \author Norihiro Watanabe - * \date 2013-04-16 - * - * \copyright - * Copyright (c) 2012-2016, 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 NUMLIB_VECTORMATRIXBUILDER_H_ -#define NUMLIB_VECTORMATRIXBUILDER_H_ - -namespace NumLib -{ - -template <typename MatrixType_, typename VectorType_> -class VectorMatrixBuilder -{ -public: - typedef VectorType_ VectorType; - typedef MatrixType_ MatrixType; - -public: - /// Create matrix of given size. Any additional arguments are directly - /// passed to the vector constructor. - template <typename ...Args_> - static - VectorType* createVector(std::size_t const size, Args_&&... args) - { - return new VectorType(size, std::forward<Args_>(args)...); - } - - /// Create a matrix of given size. Any additional arguments are directly - /// passed to the matrix constructor. - template <typename ...Args_> - static - MatrixType* createMatrix(std::size_t const size, Args_&&... args) - { - return new MatrixType(size, std::forward<Args_>(args)...); - } - -}; - -} // namespace NumLib - -#endif // NUMLIB_VECTORMATRIXBUILDER_H_ diff --git a/NumLib/DOF/GlobalMatrixProviders.cpp b/NumLib/DOF/GlobalMatrixProviders.cpp index 0d420288509d653626e72da155e90d158a9150d1..4d42f1b5d5d69cea607e1461e2a5b7f95301ec79 100644 --- a/NumLib/DOF/GlobalMatrixProviders.cpp +++ b/NumLib/DOF/GlobalMatrixProviders.cpp @@ -38,9 +38,6 @@ INITIALIZE_GLOBAL_MATRIX_VECTOR_PROVIDER(Eigen::MatrixXd, Eigen::VectorXd, #endif -using GlobalMatrix = GlobalSetupType::MatrixType; -using GlobalVector = GlobalSetupType::VectorType; - INITIALIZE_GLOBAL_MATRIX_VECTOR_PROVIDER(GlobalMatrix, GlobalVector, globalSetupGlobalMatrixVectorProvider) diff --git a/NumLib/GlobalSetup.h b/NumLib/GlobalSetup.h deleted file mode 100644 index 27bed2596c65753701e9d77d91d4938bc8c0af2b..0000000000000000000000000000000000000000 --- a/NumLib/GlobalSetup.h +++ /dev/null @@ -1,69 +0,0 @@ -/** - * \copyright - * Copyright (c) 2012-2016, 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 NUMLIB_GLOBAL_SETUP_H_ -#define NUMLIB_GLOBAL_SETUP_H_ - -#include <functional> - -namespace NumLib -{ - -/// The GlobalSetup collects vector and matrix builder and corresponding global -/// loop executor. -template <typename VectorMatrixBuilder, typename Executor, typename LinearSolver_> -struct GlobalSetup -{ - typedef typename VectorMatrixBuilder::VectorType VectorType; - typedef typename VectorMatrixBuilder::MatrixType MatrixType; - - using LinearSolver = LinearSolver_; - - template <typename... Args> - static - VectorType* createVector(Args&& ... args) - { - return VectorMatrixBuilder::createVector(std::forward<Args>(args)...); - } - - template <typename... Args> - static - MatrixType* createMatrix(Args&& ... args) - { - return VectorMatrixBuilder::createMatrix(std::forward<Args>(args)...); - } - - template <typename... Args> - static - void executeDereferenced(Args&& ... args) - { - return Executor::executeDereferenced(std::forward<Args>(args)...); - } - - template <typename... Args> - static - void executeMemberDereferenced(Args&& ... args) - { - return Executor::executeMemberDereferenced(std::forward<Args>(args)...); - } - - template <typename... Args> - static - void transformDereferenced(Args&& ... args) - { - return Executor::transformDereferenced(std::forward<Args>(args)...); - } - - //! Do not create any instances; this struct only has static members. - GlobalSetup() = delete; -}; - -} // namespace NumLib - -#endif // NUMLIB_GLOBAL_SETUP_H_ diff --git a/NumLib/NumericsConfig.h b/NumLib/NumericsConfig.h index 607704beddb6f7644cfc37f443bd017302a5b8a7..20c643038309c3c01d4e4bf877463eef7951f31d 100644 --- a/NumLib/NumericsConfig.h +++ b/NumLib/NumericsConfig.h @@ -7,57 +7,22 @@ * */ -#ifndef APPLICATIONS_NUMERICSCONFIG_H_ -#define APPLICATIONS_NUMERICSCONFIG_H_ - -#include <type_traits> -#include "MathLib/LinAlg/GlobalMatrixVectorTypes.h" +#ifndef NUMLIB_NUMERICSCONFIG_H_ +#define NUMLIB_NUMERICSCONFIG_H_ /** * 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 ProcessLib::GlobalSetup template. - * The existence of the GlobalSetupType is checked at the end of the file. */ -// -// Global vector/matrix builder. -// - -#include "NumLib/Assembler/VectorMatrixBuilder.h" -namespace detail -{ -using GlobalVectorMatrixBuilderType = - NumLib::VectorMatrixBuilder< - GlobalMatrixType, - GlobalVectorType>; -} +#include "MathLib/LinAlg/GlobalMatrixVectorTypes.h" // // Global executor // #include "NumLib/Assembler/SerialExecutor.h" -namespace detail -{ -using GlobalExecutorType = NumLib::SerialExecutor; -} - -/// -/// Global setup collects the previous configuration in single place. -/// -#include "GlobalSetup.h" -using GlobalSetupType = - NumLib::GlobalSetup< - detail::GlobalVectorMatrixBuilderType, - detail::GlobalExecutorType, - detail::LinearSolverType>; +using GlobalExecutor = NumLib::SerialExecutor; -// -// Check the configuration -// -static_assert(std::is_class<GlobalSetupType>::value, - "GlobalSetupType was not defined."); -#endif // APPLICATIONS_NUMERICSCONFIG_H_ +#endif // NUMLIB_NUMERICSCONFIG_H_ diff --git a/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess-fwd.h b/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess-fwd.h deleted file mode 100644 index d5e33c7c6a8367f00c0a4bd0e124dbada30cb63f..0000000000000000000000000000000000000000 --- a/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess-fwd.h +++ /dev/null @@ -1,18 +0,0 @@ -/** - * \copyright - * Copyright (c) 2012-2016, 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 PROCESS_LIB_GROUNDWATERFLOWPROCESS_FWD_H_ -#define PROCESS_LIB_GROUNDWATERFLOWPROCESS_FWD_H_ - -#include "GroundwaterFlowProcess.h" -#include "NumLib/NumericsConfig.h" - -extern template class ProcessLib::GroundwaterFlow::GroundwaterFlowProcess<GlobalSetupType>; - -#endif // PROCESS_LIB_GROUNDWATERFLOWPROCESS_FWD_H_ diff --git a/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.cpp b/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.cpp deleted file mode 100644 index 2646e636596c94d0be64bf7e96d8ae3c6e70920f..0000000000000000000000000000000000000000 --- a/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/** - * \copyright - * Copyright (c) 2012-2016, 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 "GroundwaterFlowProcess-fwd.h" -#include "GroundwaterFlowProcess.h" - -namespace ProcessLib { -namespace GroundwaterFlow { - -template class GroundwaterFlowProcess<GlobalSetupType>; - -} -} diff --git a/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.h b/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.h index 3bf2c24c8b4b68c04ead6243047c14e11680a408..d5d2610ba9c27fee1d990ba4478231ea5aa9c9a3 100644 --- a/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.h +++ b/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.h @@ -26,25 +26,22 @@ namespace ProcessLib namespace GroundwaterFlow { -template<typename GlobalSetup> class GroundwaterFlowProcess final - : public Process<GlobalSetup> + : public Process { - using Base = Process<GlobalSetup>; - using GlobalMatrix = typename GlobalSetup::MatrixType; - using GlobalVector = typename GlobalSetup::VectorType; + using Base = Process; public: GroundwaterFlowProcess( MeshLib::Mesh& mesh, - typename Base::NonlinearSolver& nonlinear_solver, - std::unique_ptr<typename Base::TimeDiscretization>&& time_discretization, + Base::NonlinearSolver& nonlinear_solver, + std::unique_ptr<Base::TimeDiscretization>&& time_discretization, std::vector<std::reference_wrapper<ProcessVariable>>&& process_variables, GroundwaterFlowProcessData&& process_data, SecondaryVariableCollection<GlobalVector>&& secondary_variables, ProcessOutput<GlobalVector>&& process_output ) - : Process<GlobalSetup>(mesh, nonlinear_solver, std::move(time_discretization), + : Process(mesh, nonlinear_solver, std::move(time_discretization), std::move(process_variables), std::move(secondary_variables), std::move(process_output)) @@ -94,7 +91,7 @@ private: DBUG("Create global assembler."); _global_assembler.reset(new GlobalAssembler(dof_table)); - ProcessLib::createLocalAssemblers<GlobalSetup, LocalAssemblerData>( + ProcessLib::createLocalAssemblers<LocalAssemblerData>( mesh.getDimension(), mesh.getElements(), dof_table, integration_order, _local_assemblers, _process_data); @@ -129,7 +126,7 @@ private: DBUG("Assemble GroundwaterFlowProcess."); // Call global assembler for each local assembly item. - GlobalSetup::executeMemberDereferenced( + GlobalExecutor::executeMemberDereferenced( *_global_assembler, &GlobalAssembler::assemble, _local_assemblers, t, x, M, K, b); } @@ -143,12 +140,11 @@ private: std::unique_ptr<ExtrapolatorInterface> _extrapolator; }; -template <typename GlobalSetup> -std::unique_ptr<GroundwaterFlowProcess<GlobalSetup>> +std::unique_ptr<GroundwaterFlowProcess> createGroundwaterFlowProcess( MeshLib::Mesh& mesh, - typename Process<GlobalSetup>::NonlinearSolver& nonlinear_solver, - std::unique_ptr<typename Process<GlobalSetup>::TimeDiscretization>&& time_discretization, + Process::NonlinearSolver& nonlinear_solver, + std::unique_ptr<Process::TimeDiscretization>&& time_discretization, std::vector<ProcessVariable> const& variables, std::vector<std::unique_ptr<ParameterBase>> const& parameters, BaseLib::ConfigTree const& config) @@ -179,7 +175,7 @@ createGroundwaterFlowProcess( hydraulic_conductivity }; - SecondaryVariableCollection<typename GlobalSetup::VectorType> secondary_variables { + SecondaryVariableCollection<GlobalVector> secondary_variables { //! \ogs_file_param{process__secondary_variables} config.getConfigSubtreeOptional("secondary_variables"), { @@ -192,13 +188,13 @@ createGroundwaterFlowProcess( } }; - ProcessOutput<typename GlobalSetup::VectorType> + ProcessOutput<GlobalVector> //! \ogs_file_param{process__output} process_output{config.getConfigSubtree("output"), process_variables, secondary_variables}; - return std::unique_ptr<GroundwaterFlowProcess<GlobalSetup>>{ - new GroundwaterFlowProcess<GlobalSetup>{ + return std::unique_ptr<GroundwaterFlowProcess>{ + new GroundwaterFlowProcess{ mesh, nonlinear_solver,std::move(time_discretization), std::move(process_variables), std::move(process_data), diff --git a/ProcessLib/NeumannBc.h b/ProcessLib/NeumannBc.h index f87deae5305780cb235a539acd0e686a4987b71d..c666ec4787b65e53d09b3a21da5afcf56290ff5f 100644 --- a/ProcessLib/NeumannBc.h +++ b/ProcessLib/NeumannBc.h @@ -41,13 +41,9 @@ namespace ProcessLib /// right-hand-sides happen in the initialize() function. /// The integration() function provides calls then the actual integration of the /// Neumann boundary condition. -template <typename GlobalSetup> class NeumannBc { public: - using GlobalVector = typename GlobalSetup::VectorType; - using GlobalMatrix = typename GlobalSetup::MatrixType; - /// Create a Neumann boundary condition process from given config, /// DOF-table, and a mesh subset for a given variable and its component. /// A local DOF-table, a subset of the given one, is constructed. @@ -99,7 +95,7 @@ public: /// matrix and the right-hand-side. void integrate(const double t, GlobalVector& b) { - GlobalSetup::executeMemberDereferenced( + GlobalExecutor::executeMemberDereferenced( *_global_assembler, &GlobalAssembler::assemble, _local_assemblers, t, b); } @@ -115,7 +111,7 @@ public: return _function(); }; - createLocalAssemblers<GlobalSetup, LocalNeumannBcAsmData>( + createLocalAssemblers<LocalNeumannBcAsmData>( global_dim, _elements, *_local_to_global_index_map, _integration_order, _local_assemblers, diff --git a/ProcessLib/Output.cpp b/ProcessLib/Output.cpp index 76024cb4bdffedc54cd50e2e6f5978a26b5feefb..65d1a30a2c81f1e81223233f2d97af48f439c995 100644 --- a/ProcessLib/Output.cpp +++ b/ProcessLib/Output.cpp @@ -44,8 +44,7 @@ bool shallDoOutput(unsigned timestep, CountsSteps const& repeats_each_steps) namespace ProcessLib { -template<typename GlobalSetup> -std::unique_ptr<Output<GlobalSetup>> Output<GlobalSetup>:: +std::unique_ptr<Output> Output:: newInstance(const BaseLib::ConfigTree &config, std::string const& output_directory) { std::unique_ptr<Output> out{ new Output{ @@ -81,10 +80,8 @@ newInstance(const BaseLib::ConfigTree &config, std::string const& output_directo return out; } -template<typename GlobalSetup> -void Output<GlobalSetup>:: -initialize(typename Output<GlobalSetup>::ProcessIter first, - typename Output<GlobalSetup>::ProcessIter last) +void Output:: +initialize(Output::ProcessIter first, Output::ProcessIter last) { for (unsigned pcs_idx = 0; first != last; ++first, ++pcs_idx) { @@ -97,12 +94,11 @@ initialize(typename Output<GlobalSetup>::ProcessIter first, } } -template<typename GlobalSetup> -void Output<GlobalSetup>:: -doOutputAlways(Process<GlobalSetup> const& process, +void Output:: +doOutputAlways(Process const& process, unsigned timestep, const double t, - typename GlobalSetup::VectorType const& x) + GlobalVector const& x) { auto spd_it = _single_process_data.find(&process); if (spd_it == _single_process_data.end()) { @@ -121,30 +117,24 @@ doOutputAlways(Process<GlobalSetup> const& process, spd.pvd_file.addVTUFile(output_file_name, t); } -template<typename GlobalSetup> -void Output<GlobalSetup>:: -doOutput(Process<GlobalSetup> const& process, +void Output:: +doOutput(Process const& process, unsigned timestep, const double t, - typename GlobalSetup::VectorType const& x) + GlobalVector const& x) { if (shallDoOutput(timestep, _repeats_each_steps)) doOutputAlways(process, timestep, t, x); } -template<typename GlobalSetup> -void Output<GlobalSetup>:: -doOutputLastTimestep(Process<GlobalSetup> const& process, +void Output:: +doOutputLastTimestep(Process const& process, unsigned timestep, const double t, - typename GlobalSetup::VectorType const& x) + GlobalVector const& x) { if (!shallDoOutput(timestep, _repeats_each_steps)) doOutputAlways(process, timestep, t, x); } - -// explicit instantiation -template class Output<GlobalSetupType>; - } diff --git a/ProcessLib/Output.h b/ProcessLib/Output.h index fcfa16edae99c958cb461caa3dc97ead8dbdda50..cda6c91c133a3027565ebabf9c36da9ea7692093 100644 --- a/ProcessLib/Output.h +++ b/ProcessLib/Output.h @@ -22,7 +22,6 @@ namespace ProcessLib * This class decides at which timesteps output is written * and initiates the writing process. */ -template<typename GlobalSetup> class Output { public: @@ -30,7 +29,7 @@ public: newInstance(const BaseLib::ConfigTree& config, const std::string& output_directory); - using ProcessIter = std::vector<std::unique_ptr<ProcessLib::Process<GlobalSetupType>>> + using ProcessIter = std::vector<std::unique_ptr<ProcessLib::Process>> ::const_iterator; //! Opens a PVD file for each process. @@ -39,25 +38,25 @@ public: //! Writes output for the given \c process if it should be written in the //! given \c timestep. void doOutput( - Process<GlobalSetup> const& process, unsigned timestep, + Process const& process, unsigned timestep, const double t, - typename GlobalSetup::VectorType const& x); + GlobalVector const& x); //! Writes output for the given \c process if it has not been written yet. //! This method is intended for doing output after the last timestep in order //! to make sure that its results are written. void doOutputLastTimestep( - Process<GlobalSetup> const& process, unsigned timestep, + Process const& process, unsigned timestep, const double t, - typename GlobalSetup::VectorType const& x); + GlobalVector const& x); //! Writes output for the given \c process. //! This method will always write. //! It is intended to write output in error handling routines. void doOutputAlways( - Process<GlobalSetup> const& process, unsigned timestep, + Process const& process, unsigned timestep, const double t, - typename GlobalSetup::VectorType const& x); + GlobalVector const& x); struct PairRepeatEachSteps { @@ -90,7 +89,7 @@ private: //! Describes after which timesteps to write output. std::vector<PairRepeatEachSteps> _repeats_each_steps; - std::map<Process<GlobalSetup> const*, SingleProcessData> _single_process_data; + std::map<Process const*, SingleProcessData> _single_process_data; }; } diff --git a/ProcessLib/Process.h b/ProcessLib/Process.h index d9967fd4af196c72277c60c712f9b7c13eaf2568..4859acc03267b1a331f2a7f64c1af384002c871e 100644 --- a/ProcessLib/Process.h +++ b/ProcessLib/Process.h @@ -32,18 +32,15 @@ class Mesh; namespace ProcessLib { -template <typename GlobalSetup> class Process - : public NumLib::ODESystem<typename GlobalSetup::MatrixType, - typename GlobalSetup::VectorType, + : public NumLib::ODESystem<GlobalMatrix, + GlobalVector, // TODO: later on use a simpler ODE system NumLib::ODESystemTag::FirstOrderImplicitQuasilinear, NumLib::NonlinearSolverTag::Newton> { public: - using GlobalVector = typename GlobalSetup::VectorType; - using GlobalMatrix = typename GlobalSetup::MatrixType; - using Index = typename GlobalMatrix::IndexType; + using Index = GlobalMatrix::IndexType; using NonlinearSolver = NumLib::NonlinearSolverBase<GlobalMatrix, GlobalVector>; using TimeDiscretization = NumLib::TimeDiscretization<GlobalVector>; @@ -296,7 +293,7 @@ private: // Create a neumann BC for the process variable storing them in the // _neumann_bcs vector. - variable.createNeumannBcs<GlobalSetup>( + variable.createNeumannBcs( std::back_inserter(_neumann_bcs), mesh_element_searcher, _integration_order, @@ -328,7 +325,7 @@ private: GlobalSparsityPattern _sparsity_pattern; std::vector<DirichletBc<GlobalIndexType>> _dirichlet_bcs; - std::vector<std::unique_ptr<NeumannBc<GlobalSetup>>> _neumann_bcs; + std::vector<std::unique_ptr<NeumannBc>> _neumann_bcs; NonlinearSolver& _nonlinear_solver; std::unique_ptr<TimeDiscretization> _time_discretization; diff --git a/ProcessLib/ProcessVariable.h b/ProcessLib/ProcessVariable.h index 3b2e05b06ee211bc31ffa5c82ea82c4b278bad1e..3741a14a641345212d2a151e7ae0fd1a9efab8c9 100644 --- a/ProcessLib/ProcessVariable.h +++ b/ProcessLib/ProcessVariable.h @@ -82,7 +82,7 @@ public: } } - template <typename GlobalSetup, typename OutputIterator> + template <typename OutputIterator> void createNeumannBcs(OutputIterator bcs, MeshGeoToolsLib::BoundaryElementsSearcher& searcher, unsigned const integration_order, @@ -100,8 +100,8 @@ public: // Create/initialize the boundary condition with matching component // id and output it through the OutputIterator. bc_config.first->initialize(searcher); - bcs++ = std::unique_ptr<NeumannBc<GlobalSetup>>{ - new NeumannBc<GlobalSetup>(*bc_config.first, + bcs++ = std::unique_ptr<NeumannBc>{ + new NeumannBc(*bc_config.first, integration_order, dof_table, variable_id, diff --git a/ProcessLib/TES/TESProcess.cpp b/ProcessLib/TES/TESProcess.cpp index 732f0ed637f119deb5a02d18e69aca7426ce9272..0d91e6a7c4db4dc2737080825e250fc59ac8b100 100644 --- a/ProcessLib/TES/TESProcess.cpp +++ b/ProcessLib/TES/TESProcess.cpp @@ -67,17 +67,16 @@ namespace ProcessLib { namespace TES { -template <typename GlobalSetup> -TESProcess<GlobalSetup>::TESProcess( +TESProcess::TESProcess( MeshLib::Mesh& mesh, - typename Process<GlobalSetup>::NonlinearSolver& nonlinear_solver, - std::unique_ptr<typename Process<GlobalSetup>::TimeDiscretization>&& + Process::NonlinearSolver& nonlinear_solver, + std::unique_ptr<Process::TimeDiscretization>&& time_discretization, std::vector<std::reference_wrapper<ProcessVariable>>&& process_variables, SecondaryVariableCollection<GlobalVector>&& secondary_variables, ProcessOutput<GlobalVector>&& process_output, const BaseLib::ConfigTree& config) - : Process<GlobalSetup>( + : Process( mesh, nonlinear_solver, std::move(time_discretization), std::move(process_variables), std::move(secondary_variables), std::move(process_output)) @@ -168,15 +167,14 @@ TESProcess<GlobalSetup>::TESProcess( */ } -template <typename GlobalSetup> -void TESProcess<GlobalSetup>::initializeConcreteProcess( +void TESProcess::initializeConcreteProcess( NumLib::LocalToGlobalIndexMap const& dof_table, MeshLib::Mesh const& mesh, unsigned const integration_order) { DBUG("Create global assembler."); _global_assembler.reset(new GlobalAssembler(dof_table)); - ProcessLib::createLocalAssemblers<GlobalSetup, TESLocalAssembler>( + ProcessLib::createLocalAssemblers<TESLocalAssembler>( mesh.getDimension(), mesh.getElements(), dof_table, integration_order, _local_assemblers, _assembly_params); @@ -227,7 +225,7 @@ void TESProcess<GlobalSetup>::initializeConcreteProcess( makeEx(TESIntPtVariables::REACTION_DAMPING_FACTOR)); namespace PH = std::placeholders; - using Self = TESProcess<GlobalSetup>; + using Self = TESProcess; add2nd("vapour_partial_pressure", 1, {std::bind(&Self::computeVapourPartialPressure, this, PH::_1, PH::_2, @@ -242,8 +240,7 @@ void TESProcess<GlobalSetup>::initializeConcreteProcess( nullptr}); } -template <typename GlobalSetup> -void TESProcess<GlobalSetup>::assembleConcreteProcess(const double t, +void TESProcess::assembleConcreteProcess(const double t, GlobalVector const& x, GlobalMatrix& M, GlobalMatrix& K, @@ -252,13 +249,12 @@ void TESProcess<GlobalSetup>::assembleConcreteProcess(const double t, DBUG("Assemble TESProcess."); // Call global assembler for each local assembly item. - GlobalSetup::executeMemberDereferenced(*_global_assembler, + GlobalExecutor::executeMemberDereferenced(*_global_assembler, &GlobalAssembler::assemble, _local_assemblers, t, x, M, K, b); } -template <typename GlobalSetup> -void TESProcess<GlobalSetup>::preTimestep(GlobalVector const& x, const double t, +void TESProcess::preTimestep(GlobalVector const& x, const double t, const double delta_t) { DBUG("new timestep"); @@ -271,8 +267,7 @@ void TESProcess<GlobalSetup>::preTimestep(GlobalVector const& x, const double t, MathLib::MatrixVectorTraits<GlobalVector>::newInstance(x); } -template <typename GlobalSetup> -void TESProcess<GlobalSetup>::preIteration(const unsigned iter, +void TESProcess::preIteration(const unsigned iter, GlobalVector const& /*x*/) { _assembly_params.iteration_in_current_timestep = iter; @@ -280,8 +275,7 @@ void TESProcess<GlobalSetup>::preIteration(const unsigned iter, ++_assembly_params.number_of_try_of_iteration; } -template <typename GlobalSetup> -NumLib::IterationResult TESProcess<GlobalSetup>::postIteration( +NumLib::IterationResult TESProcess::postIteration( GlobalVector const& x) { if (this->_process_output.output_iteration_results) @@ -321,7 +315,7 @@ NumLib::IterationResult TESProcess<GlobalSetup>::postIteration( check_passed = false; }; - GlobalSetup::executeDereferenced(check_variable_bounds, + GlobalExecutor::executeDereferenced(check_variable_bounds, _local_assemblers); } @@ -339,10 +333,9 @@ NumLib::IterationResult TESProcess<GlobalSetup>::postIteration( return NumLib::IterationResult::SUCCESS; } -template <typename GlobalSetup> -typename TESProcess<GlobalSetup>::GlobalVector const& -TESProcess<GlobalSetup>::computeVapourPartialPressure( - typename TESProcess::GlobalVector const& x, +GlobalVector const& +TESProcess::computeVapourPartialPressure( + GlobalVector const& x, NumLib::LocalToGlobalIndexMap const& dof_table, std::unique_ptr<GlobalVector>& result_cache) { @@ -373,10 +366,9 @@ TESProcess<GlobalSetup>::computeVapourPartialPressure( return *result_cache; } -template <typename GlobalSetup> -typename TESProcess<GlobalSetup>::GlobalVector const& -TESProcess<GlobalSetup>::computeRelativeHumidity( - typename TESProcess::GlobalVector const& x, +GlobalVector const& +TESProcess::computeRelativeHumidity( + GlobalVector const& x, NumLib::LocalToGlobalIndexMap const& dof_table, std::unique_ptr<GlobalVector>& result_cache) { @@ -412,10 +404,9 @@ TESProcess<GlobalSetup>::computeRelativeHumidity( return *result_cache; } -template <typename GlobalSetup> -typename TESProcess<GlobalSetup>::GlobalVector const& -TESProcess<GlobalSetup>::computeEquilibriumLoading( - typename TESProcess::GlobalVector const& x, +GlobalVector const& +TESProcess::computeEquilibriumLoading( + GlobalVector const& x, NumLib::LocalToGlobalIndexMap const& dof_table, std::unique_ptr<GlobalVector>& result_cache) { @@ -454,9 +445,6 @@ TESProcess<GlobalSetup>::computeEquilibriumLoading( return *result_cache; } -// Explicitly instantiate TESProcess for GlobalSetupType. -template class TESProcess<GlobalSetupType>; - } // namespace TES } // namespace ProcessLib diff --git a/ProcessLib/TES/TESProcess.h b/ProcessLib/TES/TESProcess.h index 03b2fe89aa557e49947d2c1660e8d59d130c3382..0570def18bf786b6f773f019fca58419284d845c 100644 --- a/ProcessLib/TES/TESProcess.h +++ b/ProcessLib/TES/TESProcess.h @@ -29,19 +29,15 @@ namespace ProcessLib { namespace TES { -template <typename GlobalSetup> -class TESProcess final : public Process<GlobalSetup> +class TESProcess final : public Process { - using BP = Process<GlobalSetup>; //!< "Base Process" + using BP = Process; //!< "Base Process" public: - using GlobalVector = typename GlobalSetup::VectorType; - using GlobalMatrix = typename GlobalSetup::MatrixType; - TESProcess( MeshLib::Mesh& mesh, - typename Process<GlobalSetup>::NonlinearSolver& nonlinear_solver, - std::unique_ptr<typename Process<GlobalSetup>::TimeDiscretization>&& + Process::NonlinearSolver& nonlinear_solver, + std::unique_ptr<Process::TimeDiscretization>&& time_discretization, std::vector<std::reference_wrapper<ProcessVariable>>&& process_variables, @@ -106,11 +102,10 @@ private: std::unique_ptr<GlobalVector> _x_previous_timestep; }; -template <typename GlobalSetup> -std::unique_ptr<TESProcess<GlobalSetup>> createTESProcess( +inline std::unique_ptr<TESProcess> createTESProcess( MeshLib::Mesh& mesh, - typename Process<GlobalSetup>::NonlinearSolver& nonlinear_solver, - std::unique_ptr<typename Process<GlobalSetup>::TimeDiscretization>&& + Process::NonlinearSolver& nonlinear_solver, + std::unique_ptr<Process::TimeDiscretization>&& time_discretization, std::vector<ProcessVariable> const& variables, std::vector<std::unique_ptr<ParameterBase>> const& /*parameters*/, @@ -124,7 +119,7 @@ std::unique_ptr<TESProcess<GlobalSetup>> createTESProcess( variables, config, {"fluid_pressure", "temperature", "vapour_mass_fraction"}); - SecondaryVariableCollection<typename GlobalSetup::VectorType> + SecondaryVariableCollection<GlobalVector> secondary_variables{ config.getConfigSubtreeOptional("secondary_variables"), {"solid_density", "reaction_rate", "velocity_x", "velocity_y", @@ -132,11 +127,11 @@ std::unique_ptr<TESProcess<GlobalSetup>> createTESProcess( "vapour_partial_pressure", "relative_humidity", "equilibrium_loading"}}; - ProcessOutput<typename GlobalSetup::VectorType> process_output{ + ProcessOutput<GlobalVector> process_output{ config.getConfigSubtree("output"), process_variables, secondary_variables}; - return std::unique_ptr<TESProcess<GlobalSetup>>{new TESProcess<GlobalSetup>{ + return std::unique_ptr<TESProcess>{new TESProcess{ mesh, nonlinear_solver, std::move(time_discretization), std::move(process_variables), std::move(secondary_variables), std::move(process_output), config}}; diff --git a/ProcessLib/Utils/CreateLocalAssemblers.h b/ProcessLib/Utils/CreateLocalAssemblers.h index c5eaae8a7ff981741270e9c931017d7fef0d8066..f4fae98b4582ab010a9b8c62674b6bf626c96fa3 100644 --- a/ProcessLib/Utils/CreateLocalAssemblers.h +++ b/ProcessLib/Utils/CreateLocalAssemblers.h @@ -23,7 +23,7 @@ namespace ProcessLib namespace detail { -template<unsigned GlobalDim, typename GlobalSetup, +template<unsigned GlobalDim, template <typename, typename, typename, typename, unsigned> class LocalAssemblerImplementation, typename LocalAssemblerInterface, @@ -40,8 +40,8 @@ void createLocalAssemblers( using LocalDataInitializer = LocalDataInitializer< LocalAssemblerInterface, LocalAssemblerImplementation, - typename GlobalSetup::MatrixType, - typename GlobalSetup::VectorType, + GlobalMatrix, + GlobalVector, GlobalDim, ExtraCtorArgs...>; @@ -52,7 +52,7 @@ void createLocalAssemblers( LocalDataInitializer initializer(dof_table); DBUG("Calling local assembler builder for all mesh elements."); - GlobalSetup::transformDereferenced( + GlobalExecutor::transformDereferenced( initializer, mesh_elements, local_assemblers, @@ -65,7 +65,6 @@ void createLocalAssemblers( /*! Creates local assemblers for each element of the given \c mesh. * - * \tparam GlobalSetup the global setup of the process * \tparam LocalAssemblerImplementation the individual local assembler type * \tparam LocalAssemblerInterface the general local assembler interface * \tparam ExtraCtorArgs types of additional constructor arguments. @@ -75,8 +74,7 @@ void createLocalAssemblers( * The first two template parameters cannot be deduced from the arguments. * Therefore they always have to be provided manually. */ -template<typename GlobalSetup, - template <typename, typename, typename, typename, unsigned> class +template<template <typename, typename, typename, typename, unsigned> class LocalAssemblerImplementation, typename LocalAssemblerInterface, typename... ExtraCtorArgs> @@ -95,21 +93,21 @@ void createLocalAssemblers( { case 1: detail::createLocalAssemblers< - 1, GlobalSetup, LocalAssemblerImplementation>( + 1, LocalAssemblerImplementation>( dof_table, mesh_elements, integration_order, local_assemblers, std::forward<ExtraCtorArgs>(extra_ctor_args)...); break; case 2: detail::createLocalAssemblers< - 2, GlobalSetup, LocalAssemblerImplementation>( + 2, LocalAssemblerImplementation>( dof_table, mesh_elements, integration_order, local_assemblers, std::forward<ExtraCtorArgs>(extra_ctor_args)...); break; case 3: detail::createLocalAssemblers< - 3, GlobalSetup, LocalAssemblerImplementation>( + 3, LocalAssemblerImplementation>( dof_table, mesh_elements, integration_order, local_assemblers, std::forward<ExtraCtorArgs>(extra_ctor_args)...); diff --git a/Tests/NumLib/TestExtrapolation.cpp b/Tests/NumLib/TestExtrapolation.cpp index baa5e97a413cbfddcd4e6b940c19296c3772f00a..341debb750b564c6dfe9842a0270158b7aa3ea2d 100644 --- a/Tests/NumLib/TestExtrapolation.cpp +++ b/Tests/NumLib/TestExtrapolation.cpp @@ -148,13 +148,9 @@ private: std::vector<double> _int_pt_values; }; -template<typename GlobalSetup> class TestProcess { public: - using GlobalMatrix = typename GlobalSetup::MatrixType; - using GlobalVector = typename GlobalSetup::VectorType; - using LocalAssembler = LocalAssemblerDataInterface<GlobalMatrix, GlobalVector>; using GlobalAssembler = NumLib::VectorMatrixAssembler< GlobalMatrix, GlobalVector, LocalAssembler, @@ -208,7 +204,7 @@ public: _global_assembler->passLocalVector(inner_cb, id, x); }; - GlobalSetup::executeDereferenced( + GlobalExecutor::executeDereferenced( cb, _local_assemblers, global_nodal_values); } @@ -247,7 +243,7 @@ private: LocalDataInitializer initializer(*_dof_table); DBUG("Calling local assembler builder for all mesh elements."); - GlobalSetup::transformDereferenced( + GlobalExecutor::transformDereferenced( initializer, mesh.getElements(), _local_assemblers, @@ -266,15 +262,13 @@ private: }; -template<typename GlobalSetup> -void extrapolate(TestProcess<GlobalSetup> const& pcs, +void extrapolate(TestProcess const& pcs, IntegrationPointValue property, - typename GlobalSetup::VectorType const& + GlobalVector const& expected_extrapolated_global_nodal_values, std::size_t const nnodes, std::size_t const nelements) { namespace BLAS = MathLib::BLAS; - using GlobalVector = typename GlobalSetup::VectorType; auto const tolerance_dx = 20.0 * std::numeric_limits<double>::epsilon(); auto const tolerance_res = 4.0 * std::numeric_limits<double>::epsilon(); @@ -319,8 +313,6 @@ TEST(NumLib, DISABLED_Extrapolation) { namespace BLAS = MathLib::BLAS; - using GlobalSetup = GlobalSetupType; - using GlobalVector = GlobalSetup::VectorType; const double mesh_length = 1.0; const double mesh_elements_in_each_direction = 5.0; @@ -334,7 +326,7 @@ TEST(NumLib, DISABLED_Extrapolation) auto const nelements = mesh->getNumberOfElements(); DBUG("number of nodes: %lu, number of elements: %lu", nnodes, nelements); - TestProcess<GlobalSetup> pcs(*mesh, integration_order); + TestProcess pcs(*mesh, integration_order); // generate random nodal values MathLib::MatrixSpecifications spec{nnodes, nnodes, nullptr, nullptr}; diff --git a/Tests/NumLib/TestODEInt.cpp b/Tests/NumLib/TestODEInt.cpp index eedde108ee7b8d2188b366cb77471e2b2d5da868..19137e73b21aa06b7b87fb58f6d64f62392158c1 100644 --- a/Tests/NumLib/TestODEInt.cpp +++ b/Tests/NumLib/TestODEInt.cpp @@ -14,8 +14,8 @@ using EDMatrix = Eigen::MatrixXd; using EVector = Eigen::VectorXd; -using GMatrix = GlobalSetupType::MatrixType; -using GVector = GlobalSetupType::VectorType; +using GMatrix = GlobalMatrix; +using GVector = GlobalVector; template<typename Matrix, typename Vector, NumLib::NonlinearSolverTag NLTag> diff --git a/Tests/NumLib/TestSerialLinearSolver.cpp b/Tests/NumLib/TestSerialLinearSolver.cpp index 76e7487865ffd710da3edeb656f08b7cd0cd1fbc..cc495b12b777ed9d9bf9140e6ae805529e3db696 100644 --- a/Tests/NumLib/TestSerialLinearSolver.cpp +++ b/Tests/NumLib/TestSerialLinearSolver.cpp @@ -19,6 +19,9 @@ #include "NumLib/Assembler/VectorMatrixAssembler.h" #include "MathLib/LinAlg/ApplyKnownSolution.h" +#include "MathLib/LinAlg/GlobalMatrixVectorTypes.h" +#include "MathLib/LinAlg/MatrixSpecifications.h" +#include "MathLib/LinAlg/MatrixVectorTraits.h" #include "MathLib/LinAlg/Solvers/GaussAlgorithm.h" #include "MathLib/LinAlg/FinalizeMatrixAssembly.h" #include "MathLib/MathTools.h" @@ -41,11 +44,6 @@ TEST(NumLibSerialLinearSolver, Steady2DdiffusionQuadElem) using Example = SteadyDiffusion2DExample1<GlobalIndexType>; Example ex1; - //-------------------------------------------------------------------------- - // Choose implementation type - //-------------------------------------------------------------------------- - using GlobalSetup = GlobalSetupType; // defined in numerics config - //-------------------------------------------------------------------------- // Prepare mesh items where data are assigned //-------------------------------------------------------------------------- @@ -65,15 +63,14 @@ TEST(NumLibSerialLinearSolver, Steady2DdiffusionQuadElem) // Construct a linear system //-------------------------------------------------------------------------- // allocate a vector and matrix - typedef GlobalSetup::VectorType GlobalVector; - typedef GlobalSetup::MatrixType GlobalMatrix; - auto A = std::unique_ptr<GlobalMatrix>{ - GlobalSetup::createMatrix(local_to_global_index_map.dofSizeWithGhosts())}; + MathLib::MatrixSpecifications ms{local_to_global_index_map.dofSizeWithoutGhosts(), + local_to_global_index_map.dofSizeWithoutGhosts(), + &local_to_global_index_map.getGhostIndices(), + nullptr}; + auto A = MathLib::MatrixVectorTraits<GlobalMatrix>::newInstance(ms); A->setZero(); - auto rhs = std::unique_ptr<GlobalVector>{ - GlobalSetup::createVector(local_to_global_index_map.dofSizeWithGhosts())}; - auto x = std::unique_ptr<GlobalVector>{ - GlobalSetup::createVector(local_to_global_index_map.dofSizeWithGhosts())}; + auto rhs = MathLib::MatrixVectorTraits<GlobalVector>::newInstance(ms); + auto x = MathLib::MatrixVectorTraits<GlobalVector>::newInstance(ms); // TODO no setZero() for rhs, x? using LocalAssembler = Example::LocalAssemblerData<GlobalMatrix, GlobalVector>; @@ -95,7 +92,7 @@ TEST(NumLibSerialLinearSolver, Steady2DdiffusionQuadElem) }; // Call global initializer for each mesh element. - GlobalSetup::transformDereferenced( + GlobalExecutor::transformDereferenced( local_asm_builder, ex1.msh->getElements(), local_assembler_data); @@ -109,11 +106,10 @@ TEST(NumLibSerialLinearSolver, Steady2DdiffusionQuadElem) GlobalAssembler assembler(local_to_global_index_map); // Call global assembler for each mesh element. - auto M_dummy = std::unique_ptr<GlobalMatrix>{ - GlobalSetup::createMatrix(local_to_global_index_map.dofSizeWithGhosts())}; + auto M_dummy = MathLib::MatrixVectorTraits<GlobalMatrix>::newInstance(ms); A->setZero(); auto const t = 0.0; - GlobalSetup::executeMemberDereferenced( + GlobalExecutor::executeMemberDereferenced( assembler, &GlobalAssembler::assemble, local_assembler_data, t, *x, *M_dummy, *A, *rhs); @@ -148,7 +144,7 @@ TEST(NumLibSerialLinearSolver, Steady2DdiffusionQuadElem) BaseLib::ConfigTree::onerror, BaseLib::ConfigTree::onwarning); - GlobalSetup::LinearSolver ls("solver_name", &conf); + GlobalLinearSolver ls("solver_name", &conf); ls.solve(*A, *rhs, *x); // copy solution to double vector diff --git a/Tests/NumLib/TestVectorMatrixBuilder.cpp b/Tests/NumLib/TestVectorMatrixBuilder.cpp deleted file mode 100644 index caf09df16220a8f5f8d27c4fe2a685d7e883a3aa..0000000000000000000000000000000000000000 --- a/Tests/NumLib/TestVectorMatrixBuilder.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/** - * \copyright - * Copyright (c) 2012-2016, 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 <memory> -#include <gtest/gtest.h> - -#include "NumLib/DOF/MeshComponentMap.h" - -#include "MeshLib/MeshGenerators/MeshGenerator.h" -#include "MeshLib/MeshSubsets.h" - -#include "NumLib/Assembler/VectorMatrixBuilder.h" - -template <typename Builder> -class NumLibVectorMatrixBuilder : public ::testing::Test -{ - public: - typedef MeshLib::MeshItemType MeshItemType; - typedef MeshLib::Location Location; - typedef NumLib::MeshComponentMap MeshComponentMap; - - typedef typename Builder::VectorType VectorType; - typedef typename Builder::MatrixType MatrixType; - - public: - NumLibVectorMatrixBuilder() - : mesh(nullptr), nodesSubset(nullptr), cmap(nullptr) - { - mesh = MeshLib::MeshGenerator::generateLineMesh(1.0, mesh_size); - nodesSubset = new MeshLib::MeshSubset(*mesh, &mesh->getNodes()); - - // Add two components both based on the same nodesSubset. - components.emplace_back(new MeshLib::MeshSubsets{nodesSubset}); - components.emplace_back(new MeshLib::MeshSubsets{nodesSubset}); - - cmap = new MeshComponentMap(components, - NumLib::ComponentOrder::BY_COMPONENT); - } - - ~NumLibVectorMatrixBuilder() - { - delete cmap; - delete nodesSubset; - delete mesh; - } - - static std::size_t const mesh_size = 9; - MeshLib::Mesh const* mesh; - MeshLib::MeshSubset const* nodesSubset; - - std::vector<std::unique_ptr<MeshLib::MeshSubsets>> components; - MeshComponentMap const* cmap; -}; - -TYPED_TEST_CASE_P(NumLibVectorMatrixBuilder); - -#ifndef USE_PETSC -TYPED_TEST_P(NumLibVectorMatrixBuilder, createVector) -#else -TYPED_TEST_P(NumLibVectorMatrixBuilder, DISABLED_createVector) -#endif -{ - typedef typename TestFixture::VectorType V; - typedef TypeParam Builder; - V* v = Builder::createVector(this->cmap->dofSizeWithGhosts()); - - ASSERT_TRUE(v != nullptr); - ASSERT_EQ(this->cmap->dofSizeWithGhosts(), v->size()); - - delete v; -} - -#ifndef USE_PETSC -TYPED_TEST_P(NumLibVectorMatrixBuilder, createMatrix) -#else -TYPED_TEST_P(NumLibVectorMatrixBuilder, DISABLED_createMatrix) -#endif -{ - typedef typename TestFixture::MatrixType M; - typedef TypeParam Builder; - M* m = Builder::createMatrix(this->cmap->dofSizeWithGhosts()); - - ASSERT_TRUE(m != nullptr); - ASSERT_EQ(this->cmap->dofSizeWithGhosts(), m->getNumberOfRows()); - ASSERT_EQ(this->cmap->dofSizeWithGhosts(), m->getNumberOfColumns()); - - delete m; -} - -#ifndef USE_PETSC -REGISTER_TYPED_TEST_CASE_P(NumLibVectorMatrixBuilder, - createVector, createMatrix); -#else -REGISTER_TYPED_TEST_CASE_P(NumLibVectorMatrixBuilder, - DISABLED_createVector, DISABLED_createMatrix); -#endif - -#ifdef USE_LIS -#include "MathLib/LinAlg/Lis/LisVector.h" -#include "MathLib/LinAlg/Lis/LisMatrix.h" -#endif // USE_LIS - -#ifdef USE_PETSC -#include "MathLib/LinAlg/PETSc/PETScVector.h" -#include "MathLib/LinAlg/PETSc/PETScMatrix.h" -#endif // USE_PETSC - -#ifdef OGS_USE_EIGEN -#include "MathLib/LinAlg/Eigen/EigenVector.h" -#include "MathLib/LinAlg/Eigen/EigenMatrix.h" -#endif // OGS_USE_EIGEN - -typedef ::testing::Types - < - NumLib::VectorMatrixBuilder< - MathLib::EigenMatrix, MathLib::EigenVector> -#ifdef USE_LIS - , NumLib::VectorMatrixBuilder< - MathLib::LisMatrix, MathLib::LisVector> -#endif // USE_LIS -#ifdef USE_PETSC - , NumLib::VectorMatrixBuilder< - MathLib::PETScMatrix, MathLib::PETScVector> -#endif // USE_PETSC - > TestTypes; - -INSTANTIATE_TYPED_TEST_CASE_P(templated, NumLibVectorMatrixBuilder, - TestTypes);