diff --git a/MathLib/LinAlg/PETSc/PETScVector.cpp b/MathLib/LinAlg/PETSc/PETScVector.cpp index 8381982c0b15bc4e6834ef8ac8904f0efb59a1db..d1d40e7ddeb9c7bc7d393a861ba8c607e01b85f6 100644 --- a/MathLib/LinAlg/PETSc/PETScVector.cpp +++ b/MathLib/LinAlg/PETSc/PETScVector.cpp @@ -83,14 +83,7 @@ PETScVector::PETScVector(PETScVector &&other) , _size_loc{other._size_loc} , _size_ghosts{other._size_ghosts} , _has_ghost_id{other._has_ghost_id} -{ - if (!_global_v) - { - _global_v = std::unique_ptr<PetscScalar[]>{ new PetscScalar[_size] }; - } - - getGlobalVector(_global_v.get()); -} +{} void PETScVector::config() { @@ -264,7 +257,6 @@ void PETScVector::shallowCopy(const PETScVector &v) void finalizeVectorAssembly(PETScVector &vec) { vec.finalizeAssembly(); - vec.setGlobalVector(); } } //end of namespace diff --git a/MathLib/LinAlg/PETSc/PETScVector.h b/MathLib/LinAlg/PETSc/PETScVector.h index b9722deb9d52331bd7895aa1de43b6db5a6c531b..67e0d0d526156f598d9666f5e3932573a5e81f47 100644 --- a/MathLib/LinAlg/PETSc/PETScVector.h +++ b/MathLib/LinAlg/PETSc/PETScVector.h @@ -299,16 +299,6 @@ class PETScVector /// A funtion called by constructors to configure members void config(); - /// Set _global_v - void setGlobalVector() - { - if (!_global_v) - { - _global_v = std::unique_ptr<PetscScalar[]>{ new PetscScalar[_size] };; - } - getGlobalVector(_global_v.get()); - } - friend void finalizeVectorAssembly(PETScVector &vec); }; diff --git a/ProcessLib/HeatConduction/HeatConductionProcess.cpp b/ProcessLib/HeatConduction/HeatConductionProcess.cpp index d341c30a4f9ab2476aa4209820f4b591b3e90821..94e61d257172fad85f1586acdc6bb599ea904a68 100644 --- a/ProcessLib/HeatConduction/HeatConductionProcess.cpp +++ b/ProcessLib/HeatConduction/HeatConductionProcess.cpp @@ -47,6 +47,9 @@ void HeatConductionProcess::preTimestepConcreteProcess(GlobalVector const& x, auto& x0 = *_x_previous_timestep; MathLib::LinAlg::copy(x, x0); } + + auto& x0 = *_x_previous_timestep; + MathLib::LinAlg::setLocalAccessibleVector(x0); } void HeatConductionProcess::initializeConcreteProcess( diff --git a/ProcessLib/TES/TESProcess.cpp b/ProcessLib/TES/TESProcess.cpp index 55d9b8566ac035c443a770428c6164ada762ebae..ffdeb5dd6beac2b80ee9bef2cb59ff29b36e0489 100644 --- a/ProcessLib/TES/TESProcess.cpp +++ b/ProcessLib/TES/TESProcess.cpp @@ -285,6 +285,10 @@ NumLib::IterationResult TESProcess::postIterationConcreteProcess( std::vector<double> local_x_cache; std::vector<double> local_x_prev_ts_cache; + // The function only has computation if DDC is appied, + // e.g. Parallel comuting. + MathLib::LinAlg::setLocalAccessibleVector(*_x_previous_timestep); + auto check_variable_bounds = [&](std::size_t id, TESLocalAssemblerInterface& loc_asm) { auto const r_c_indices = NumLib::getRowColumnIndices( diff --git a/ProcessLib/UncoupledProcessesTimeLoop.cpp b/ProcessLib/UncoupledProcessesTimeLoop.cpp index 2ed13eb7e5827946a3eaa1df71522079ef76a1f6..f0465c12d4e64d6096da3a3bc8710fce68f59911 100644 --- a/ProcessLib/UncoupledProcessesTimeLoop.cpp +++ b/ProcessLib/UncoupledProcessesTimeLoop.cpp @@ -520,6 +520,7 @@ bool UncoupledProcessesTimeLoop::setCoupledSolutions() const std::size_t c_id = std::distance(_per_process_data.begin(), found_item); + MathLib::LinAlg::setLocalAccessibleVector(*_process_solutions[c_id]); BaseLib::insertIfTypeIndexKeyUniqueElseError( coupled_xs, coupled_process_pair.first, *_process_solutions[c_id], "global_coupled_x"); @@ -532,6 +533,7 @@ bool UncoupledProcessesTimeLoop::setCoupledSolutions() // Create a vector to store the solution of the last coupling iteration auto& x_coupling0 = NumLib::GlobalVectorProvider::provider.getVector(x); MathLib::LinAlg::copy(x, x_coupling0); + MathLib::LinAlg::setLocalAccessibleVector(x_coupling0); // append a solution vector of suitable size _solutions_of_last_cpl_iteration.emplace_back(&x_coupling0);