diff --git a/ProcessLib/GroundwaterFlowProcess.h b/ProcessLib/GroundwaterFlowProcess.h index 7099163fce126cc480e454b736bd1ab889a8dfeb..e049c284accdaa4bbb68374cab5e1a86ce66065d 100644 --- a/ProcessLib/GroundwaterFlowProcess.h +++ b/ProcessLib/GroundwaterFlowProcess.h @@ -215,24 +215,10 @@ public: return "gw_"; } - void initialize() override + void init() override { DBUG("Initialize GroundwaterFlowProcess."); - DBUG("Construct dof mappings."); - initializeMeshSubsets(this->_mesh); - - this->_local_to_global_index_map.reset( - new AssemblerLib::LocalToGlobalIndexMap(this->_all_mesh_subsets, AssemblerLib::ComponentOrder::BY_COMPONENT)); - - DBUG("Compute sparsity pattern"); - Process<GlobalSetup>::computeSparsityPattern( - *this->_local_to_global_index_map); - - // create global vectors and linear solver - Process<GlobalSetup>::createLinearSolver(*this->_local_to_global_index_map, - getLinearSolverName()); - setInitialConditions(*_hydraulic_head); if (this->_mesh.getDimension()==1) diff --git a/ProcessLib/Process.h b/ProcessLib/Process.h index ec9d408f66f77d5ba317f578f8922f6100e1d5b5..5731d2125055feb64e6dca52e7bcfe79e6d6f7c2 100644 --- a/ProcessLib/Process.h +++ b/ProcessLib/Process.h @@ -41,7 +41,8 @@ public: delete p; } - virtual void initialize() = 0; + /// Process specific initialization called by initialize(). + virtual void init() = 0; virtual bool assemble(const double delta_t) = 0; virtual std::string getLinearSolverName() const = 0; @@ -55,6 +56,28 @@ public: /// Creates mesh subsets, i.e. components, for given mesh. virtual void initializeMeshSubsets(MeshLib::Mesh const& mesh) = 0; + void initialize() + { + DBUG("Initialize process."); + + DBUG("Construct dof mappings."); + initializeMeshSubsets(_mesh); + + _local_to_global_index_map.reset( + new AssemblerLib::LocalToGlobalIndexMap( + _all_mesh_subsets, AssemblerLib::ComponentOrder::BY_COMPONENT)); + +#ifndef USE_PETSC + DBUG("Compute sparsity pattern"); + computeSparsityPattern(); +#endif + + // create global vectors and linear solver + createLinearSolver(getLinearSolverName()); + + init(); // Execute proces specific initialization. + } + bool solve(const double delta_t) { _A->setZero(); @@ -75,9 +98,7 @@ protected: } /// Creates global matrix, rhs and solution vectors, and the linear solver. - void createLinearSolver( - AssemblerLib::LocalToGlobalIndexMap const& local_to_global_index_map, - std::string const solver_name) + void createLinearSolver(std::string const& solver_name) { DBUG("Allocate global matrix, vectors, and linear solver."); #ifdef USE_PETSC @@ -87,10 +108,10 @@ protected: mat_opt.d_nz = pmesh.getMaximumNConnectedNodesToNode(); mat_opt.o_nz = mat_opt.d_nz; const std::size_t num_unknowns = - local_to_global_index_map.dofSizeGlobal(); + _local_to_global_index_map->dofSizeGlobal(); _A.reset(_global_setup.createMatrix(num_unknowns, mat_opt)); #else - const std::size_t num_unknowns = local_to_global_index_map.dofSize(); + const std::size_t num_unknowns = _local_to_global_index_map->dofSize(); _A.reset(_global_setup.createMatrix(num_unknowns)); #endif _x.reset(_global_setup.createVector(num_unknowns)); @@ -101,11 +122,10 @@ protected: /// Computes and stores global matrix' sparsity pattern from given /// DOF-table. - void computeSparsityPattern( - AssemblerLib::LocalToGlobalIndexMap const& local_to_global_index_map) + void computeSparsityPattern() { _sparsity_pattern = std::move(AssemblerLib::computeSparsityPattern( - local_to_global_index_map, _mesh)); + *_local_to_global_index_map, _mesh)); } protected: