Skip to content
Snippets Groups Projects
Commit 701c53a4 authored by wenqing's avatar wenqing
Browse files

[PETSc] Changed two related processes

parent eb1bfb47
No related branches found
No related tags found
No related merge requests found
...@@ -83,14 +83,7 @@ PETScVector::PETScVector(PETScVector &&other) ...@@ -83,14 +83,7 @@ PETScVector::PETScVector(PETScVector &&other)
, _size_loc{other._size_loc} , _size_loc{other._size_loc}
, _size_ghosts{other._size_ghosts} , _size_ghosts{other._size_ghosts}
, _has_ghost_id{other._has_ghost_id} , _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() void PETScVector::config()
{ {
...@@ -264,7 +257,6 @@ void PETScVector::shallowCopy(const PETScVector &v) ...@@ -264,7 +257,6 @@ void PETScVector::shallowCopy(const PETScVector &v)
void finalizeVectorAssembly(PETScVector &vec) void finalizeVectorAssembly(PETScVector &vec)
{ {
vec.finalizeAssembly(); vec.finalizeAssembly();
vec.setGlobalVector();
} }
} //end of namespace } //end of namespace
...@@ -299,16 +299,6 @@ class PETScVector ...@@ -299,16 +299,6 @@ class PETScVector
/// A funtion called by constructors to configure members /// A funtion called by constructors to configure members
void config(); 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); friend void finalizeVectorAssembly(PETScVector &vec);
}; };
......
...@@ -47,6 +47,9 @@ void HeatConductionProcess::preTimestepConcreteProcess(GlobalVector const& x, ...@@ -47,6 +47,9 @@ void HeatConductionProcess::preTimestepConcreteProcess(GlobalVector const& x,
auto& x0 = *_x_previous_timestep; auto& x0 = *_x_previous_timestep;
MathLib::LinAlg::copy(x, x0); MathLib::LinAlg::copy(x, x0);
} }
auto& x0 = *_x_previous_timestep;
MathLib::LinAlg::setLocalAccessibleVector(x0);
} }
void HeatConductionProcess::initializeConcreteProcess( void HeatConductionProcess::initializeConcreteProcess(
......
...@@ -285,6 +285,10 @@ NumLib::IterationResult TESProcess::postIterationConcreteProcess( ...@@ -285,6 +285,10 @@ NumLib::IterationResult TESProcess::postIterationConcreteProcess(
std::vector<double> local_x_cache; std::vector<double> local_x_cache;
std::vector<double> local_x_prev_ts_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, auto check_variable_bounds = [&](std::size_t id,
TESLocalAssemblerInterface& loc_asm) { TESLocalAssemblerInterface& loc_asm) {
auto const r_c_indices = NumLib::getRowColumnIndices( auto const r_c_indices = NumLib::getRowColumnIndices(
......
...@@ -520,6 +520,7 @@ bool UncoupledProcessesTimeLoop::setCoupledSolutions() ...@@ -520,6 +520,7 @@ bool UncoupledProcessesTimeLoop::setCoupledSolutions()
const std::size_t c_id = const std::size_t c_id =
std::distance(_per_process_data.begin(), found_item); std::distance(_per_process_data.begin(), found_item);
MathLib::LinAlg::setLocalAccessibleVector(*_process_solutions[c_id]);
BaseLib::insertIfTypeIndexKeyUniqueElseError( BaseLib::insertIfTypeIndexKeyUniqueElseError(
coupled_xs, coupled_process_pair.first, coupled_xs, coupled_process_pair.first,
*_process_solutions[c_id], "global_coupled_x"); *_process_solutions[c_id], "global_coupled_x");
...@@ -532,6 +533,7 @@ bool UncoupledProcessesTimeLoop::setCoupledSolutions() ...@@ -532,6 +533,7 @@ bool UncoupledProcessesTimeLoop::setCoupledSolutions()
// Create a vector to store the solution of the last coupling iteration // Create a vector to store the solution of the last coupling iteration
auto& x_coupling0 = NumLib::GlobalVectorProvider::provider.getVector(x); auto& x_coupling0 = NumLib::GlobalVectorProvider::provider.getVector(x);
MathLib::LinAlg::copy(x, x_coupling0); MathLib::LinAlg::copy(x, x_coupling0);
MathLib::LinAlg::setLocalAccessibleVector(x_coupling0);
// append a solution vector of suitable size // append a solution vector of suitable size
_solutions_of_last_cpl_iteration.emplace_back(&x_coupling0); _solutions_of_last_cpl_iteration.emplace_back(&x_coupling0);
......
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