diff --git a/ProcessLib/LiquidFlow/LiquidFlowProcess.cpp b/ProcessLib/LiquidFlow/LiquidFlowProcess.cpp index 7eba951fcbefa57ab5e79a750db085511c025bf6..2d2d07408011da89fe66ebecf77a87ee57ac2d27 100644 --- a/ProcessLib/LiquidFlow/LiquidFlowProcess.cpp +++ b/ProcessLib/LiquidFlow/LiquidFlowProcess.cpp @@ -108,7 +108,8 @@ void LiquidFlowProcess::computeSecondaryVariableConcrete(const double t, DBUG("Compute the velocity for LiquidFlowProcess."); GlobalExecutor::executeMemberOnDereferenced( &LiquidFlowLocalAssemblerInterface::computeSecondaryVariable, - _local_assemblers, *_local_to_global_index_map, t, x, _coupled_solutions); + _local_assemblers, *_local_to_global_index_map, t, x, + _coupled_solutions); } void LiquidFlowProcess::setCoupledSolutionsForStaggeredSchemeToLocalAssemblers() diff --git a/ProcessLib/LocalAssemblerInterface.cpp b/ProcessLib/LocalAssemblerInterface.cpp index c9c6876dab4805b0fdcf7f82c8818a397012a95e..910a73b311a4ef1b007c3797ca31b3b65df283bc 100644 --- a/ProcessLib/LocalAssemblerInterface.cpp +++ b/ProcessLib/LocalAssemblerInterface.cpp @@ -57,7 +57,8 @@ void LocalAssemblerInterface::assembleWithJacobianAndCoupling( void LocalAssemblerInterface::computeSecondaryVariable( std::size_t const mesh_item_id, NumLib::LocalToGlobalIndexMap const& dof_table, double const t, - GlobalVector const& x, CoupledSolutionsForStaggeredScheme const* coupled_term) + GlobalVector const& x, + CoupledSolutionsForStaggeredScheme const* coupled_term) { auto const indices = NumLib::getIndices(mesh_item_id, dof_table); auto const local_x = x.get(indices); diff --git a/ProcessLib/LocalAssemblerInterface.h b/ProcessLib/LocalAssemblerInterface.h index 28bf1188f213a10d4d57b2555bfc879a0f179c6c..bfb983f87d408f22fe43dbf92bc63c6ac1e02be3 100644 --- a/ProcessLib/LocalAssemblerInterface.h +++ b/ProcessLib/LocalAssemblerInterface.h @@ -9,7 +9,6 @@ #pragma once - #include <unordered_map> #include <typeindex> @@ -36,17 +35,18 @@ class LocalAssemblerInterface public: virtual ~LocalAssemblerInterface() = default; - virtual void assemble( - double const t, std::vector<double> const& local_x, - std::vector<double>& local_M_data, std::vector<double>& local_K_data, - std::vector<double>& local_b_data) = 0; - - virtual void assembleWithCoupledTerm(double const t, - std::vector<double> const& local_x, - std::vector<double>& local_M_data, - std::vector<double>& local_K_data, - std::vector<double>& local_b_data, - LocalCoupledSolutions const& coupled_solutions); + virtual void assemble(double const t, std::vector<double> const& local_x, + std::vector<double>& local_M_data, + std::vector<double>& local_K_data, + std::vector<double>& local_b_data) = 0; + + virtual void assembleWithCoupledTerm( + double const t, + std::vector<double> const& local_x, + std::vector<double>& local_M_data, + std::vector<double>& local_K_data, + std::vector<double>& local_b_data, + LocalCoupledSolutions const& coupled_solutions); virtual void assembleWithJacobian(double const t, std::vector<double> const& local_x, @@ -65,10 +65,11 @@ public: std::vector<double>& local_Jac_data, LocalCoupledSolutions const& coupled_solutions); - virtual void computeSecondaryVariable(std::size_t const mesh_item_id, - NumLib::LocalToGlobalIndexMap const& dof_table, - const double t, GlobalVector const& x, - CoupledSolutionsForStaggeredScheme const* coupled_term); + virtual void computeSecondaryVariable( + std::size_t const mesh_item_id, + NumLib::LocalToGlobalIndexMap const& dof_table, const double t, + GlobalVector const& x, + CoupledSolutionsForStaggeredScheme const* coupled_term); virtual void preTimestep(std::size_t const mesh_item_id, NumLib::LocalToGlobalIndexMap const& dof_table, @@ -95,15 +96,17 @@ private: } virtual void postTimestepConcrete(std::vector<double> const& /*local_x*/) {} + virtual void computeSecondaryVariableConcrete( + double const /*t*/, std::vector<double> const& /*local_x*/) + { + } - virtual void computeSecondaryVariableConcrete - (double const /*t*/, std::vector<double> const& /*local_x*/) {} - - virtual void computeSecondaryVariableWithCoupledProcessConcrete - (double const /*t*/, std::vector<double> const& /*local_x*/, - std::unordered_map<std::type_index, - const std::vector<double>> const& - /*coupled_local_solutions*/) {} + virtual void computeSecondaryVariableWithCoupledProcessConcrete( + double const /*t*/, std::vector<double> const& /*local_x*/, + std::unordered_map<std::type_index, const std::vector<double>> const& + /*coupled_local_solutions*/) + { + } }; -} // namespace ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/Process.cpp b/ProcessLib/Process.cpp index 69b15f52b2a53e7a6be893e7fc00058ddd8188ad..5840fccdf3cf64870ea22b72da42e1ec521352f3 100644 --- a/ProcessLib/Process.cpp +++ b/ProcessLib/Process.cpp @@ -65,12 +65,10 @@ void Process::initialize() ++variable_id) { ProcessVariable& pv = _process_variables[variable_id]; - auto sts = - pv.createSourceTerms(*_local_to_global_index_map, variable_id, - _integration_order); + auto sts = pv.createSourceTerms(*_local_to_global_index_map, + variable_id, _integration_order); - std::move(sts.begin(), sts.end(), - std::back_inserter(_source_terms)); + std::move(sts.begin(), sts.end(), std::back_inserter(_source_terms)); } } @@ -109,13 +107,14 @@ void Process::setInitialConditions(double const t, GlobalVector& x) std::abs(_local_to_global_index_map->getGlobalIndex( l, variable_id, component_id)); #ifdef USE_PETSC - // The global indices of the ghost entries of the global matrix - // or the global vectors need to be set as negative values for - // equation assembly, however the global indices start from - // zero. Therefore, any ghost entry with zero index is assigned - // an negative value of the vector size or the matrix dimension. - // To assign the initial value for the ghost entries, the - // negative indices of the ghost entries are restored to zero. + // The global indices of the ghost entries of the global + // matrix or the global vectors need to be set as negative + // values for equation assembly, however the global indices + // start from zero. Therefore, any ghost entry with zero + // index is assigned an negative value of the vector size + // or the matrix dimension. To assign the initial value for + // the ghost entries, the negative indices of the ghost + // entries are restored to zero. if (global_index == x.size()) global_index = 0; #endif @@ -158,7 +157,7 @@ void Process::assembleWithJacobian(const double t, GlobalVector const& x, MathLib::LinAlg::setLocalAccessibleVector(xdot); assembleWithJacobianConcreteProcess(t, x, xdot, dxdot_dx, dx_dx, M, K, b, - Jac); + Jac); // TODO apply BCs to Jacobian. _boundary_conditions.applyNaturalBC(t, x, K, b); @@ -233,7 +232,8 @@ void Process::finishNamedFunctionsInitialization() _named_function_caller.applyPlugs(); for (auto const& named_function : - _named_function_caller.getNamedFunctions()) { + _named_function_caller.getNamedFunctions()) + { auto const& name = named_function.getName(); _secondary_variables.addSecondaryVariable( name, @@ -254,7 +254,7 @@ void Process::computeSparsityPattern() } void Process::preTimestep(GlobalVector const& x, const double t, - const double delta_t) + const double delta_t) { for (auto& cached_var : _cached_secondary_variables) { @@ -278,10 +278,11 @@ void Process::computeSecondaryVariable(const double t, GlobalVector const& x) computeSecondaryVariableConcrete(t, x); } -void Process::preIteration(const unsigned iter, const GlobalVector &x) +void Process::preIteration(const unsigned iter, const GlobalVector& x) { // In every new iteration cached values of secondary variables are expired. - for (auto& cached_var : _cached_secondary_variables) { + for (auto& cached_var : _cached_secondary_variables) + { cached_var->updateCurrentSolution(x, *_local_to_global_index_map); } @@ -289,7 +290,7 @@ void Process::preIteration(const unsigned iter, const GlobalVector &x) preIterationConcreteProcess(iter, x); } -NumLib::IterationResult Process::postIteration(const GlobalVector &x) +NumLib::IterationResult Process::postIteration(const GlobalVector& x) { MathLib::LinAlg::setLocalAccessibleVector(x); return postIterationConcreteProcess(x); diff --git a/ProcessLib/Process.h b/ProcessLib/Process.h index e2ec183a5963390c5bd2bb8822cc4947dc1456f3..dacd9a79f76863fdac0345a5476958dafe3ed713 100644 --- a/ProcessLib/Process.h +++ b/ProcessLib/Process.h @@ -71,7 +71,8 @@ public: MathLib::MatrixSpecifications getMatrixSpecifications() const final; - void setCoupledSolutionsForStaggeredScheme(CoupledSolutionsForStaggeredScheme* const coupled_solutions) + void setCoupledSolutionsForStaggeredScheme( + CoupledSolutionsForStaggeredScheme* const coupled_solutions) { _coupled_solutions = coupled_solutions; } @@ -202,7 +203,8 @@ protected: VectorMatrixAssembler _global_assembler; - /// Pointer to CoupledSolutionsForStaggeredScheme, which contains the references to the + /// Pointer to CoupledSolutionsForStaggeredScheme, which contains the + /// references to the /// coupled processes and the references to the solutions of the coupled /// processes. CoupledSolutionsForStaggeredScheme* _coupled_solutions; diff --git a/ProcessLib/UncoupledProcessesTimeLoop.cpp b/ProcessLib/UncoupledProcessesTimeLoop.cpp index f7fbd419d8a70d5c341334bea129ffb58495310a..e031137c704c6980d1df33bda36ed373fab1d07a 100644 --- a/ProcessLib/UncoupledProcessesTimeLoop.cpp +++ b/ProcessLib/UncoupledProcessesTimeLoop.cpp @@ -920,7 +920,8 @@ bool UncoupledProcessesTimeLoop::solveCoupledEquationSystemsByStaggeredScheme( spd->coupled_processes, _solutions_of_coupled_processes[pcs_idx], dt); - spd->process.setCoupledSolutionsForStaggeredScheme(&coupled_solutions); + spd->process.setCoupledSolutionsForStaggeredScheme( + &coupled_solutions); const auto nonlinear_solver_succeeded = solveOneTimeStepOneProcess( x, timestep_id, t, dt, *spd, *_output); @@ -1038,7 +1039,8 @@ void UncoupledProcessesTimeLoop::outputSolutions( spd->coupled_processes, _solutions_of_coupled_processes[pcs_idx], 0.0); - spd->process.setCoupledSolutionsForStaggeredScheme(&coupled_solutions); + spd->process.setCoupledSolutionsForStaggeredScheme( + &coupled_solutions); spd->process .setCoupledSolutionsForStaggeredSchemeToLocalAssemblers(); (output_object.*output_class_member)(pcs, spd->process_output,