Skip to content
Snippets Groups Projects
Commit 209019e6 authored by Norihiro Watanabe's avatar Norihiro Watanabe Committed by GitHub
Browse files

Merge pull request #1256 from norihiro-w/rm-GlobalSetup

Remove GlobalSetup
parents 9d56a83b a862d524
No related branches found
No related tags found
No related merge requests found
Showing
with 128 additions and 393 deletions
......@@ -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");
}
}
......
......@@ -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;
......
......@@ -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>;
......
......@@ -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>;
......
/**
* \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_
......@@ -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)
......
/**
* \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_
......@@ -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_
/**
* \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_
/**
* \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>;
}
}
......@@ -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),
......
......@@ -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,
......
......@@ -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>;
}
......@@ -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;
};
}
......
......@@ -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;
......
......@@ -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,
......
......@@ -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
......@@ -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}};
......
......@@ -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)...);
......
......@@ -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};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment