1#ifndef DUNE_COPASI_MODEL_MAKE_DIFFUSION_REACTION_STEP_OPERATOR_HH
2#define DUNE_COPASI_MODEL_MAKE_DIFFUSION_REACTION_STEP_OPERATOR_HH
7#if HAVE_METIS && DUNE_COPASI_CONCURRENT_ASSEMBLY
8#include <dune/pdelab/common/partition/metis.hh>
11#include <dune/pdelab/common/partition/simple.hh>
12#include <dune/pdelab/common/execution.hh>
13#include <dune/pdelab/operator/operator.hh>
15#include <spdlog/spdlog.h>
24 class ResidualQuantity,
26 PDELab::Concept::Basis
Basis,
29[[
nodiscard]]
inline static std::unique_ptr<PDELab::Operator<Coefficients, Coefficients>>
37 std::unique_ptr<PDELab::Operator<Coefficients, Coefficients>>
one_step;
41 ExecutionPolicy execution_policy, const OperatorBasis& operator_basis) {
42 spdlog::info(
"Creating mass/stiffness local operator");
43 const auto& time_step_cfg = config.sub(
"time_step_operator");
44 const auto& scalar_field_cfg = config.sub(
"scalar_field");
45 bool is_linear = config.get(
"is_linear",
false);
47 LocalOperator<OperatorBasis, LocalBasisTraits, CellDataGridView, CellDataType, ExecutionPolicy>;
48 LocalOperator
const stiff_lop(operator_basis,
49 LocalOperator::Form::Stiffness,
55 LocalOperator
const mass_lop(operator_basis,
56 LocalOperator::Form::Mass,
63 time_step_cfg, operator_basis, mass_lop, stiff_lop);
70#if DUNE_COPASI_CONCURRENT_ASSEMBLY
73 auto entity_set = basis.entitySet();
74 auto default_part_type =
80 auto part_type = assembly_cfg.get(
"partition.type", default_part_type);
81 auto part_coloring = assembly_cfg.get(
"partition.coloring",
"None");
82 spdlog::info(
" Concurrent Partitioning:");
83 spdlog::info(
" Type: {}", part_type);
84 spdlog::info(
" Patches: {}", part_patches);
85 spdlog::info(
" Halo: {}", halo);
86 spdlog::info(
" Coloring: {}", part_coloring);
87 if (part_type ==
"METIS") {
89 if (part_coloring ==
"None") {
90 return make_one_step_op(
93 PDELab::EntitySetPartitioner::Metis{ entity_set, part_patches, halo },
94 TypeTree::treePath()));
95 }
else if (part_coloring ==
"DSatur") {
96 return make_one_step_op(
98 basis.subSpace(PDELab::EntitySetPartitioner::MetisColored{ entity_set, part_patches, halo },
99 TypeTree::treePath()));
101 throw format_exception(IOError{},
"Not known coloring algorithm '{}' known", part_coloring);
104 throw format_exception(IOError{},
"'METIS' partitioner is not available on this executable");
106 }
else if (part_type ==
"Simple") {
107 if (part_coloring ==
"None") {
108 return make_one_step_op(
111 PDELab::EntitySetPartitioner::Simple{ entity_set, part_patches, halo },
112 TypeTree::treePath()));
113 }
else if (part_coloring ==
"DSatur") {
114 return make_one_step_op(
116 basis.subSpace(PDELab::EntitySetPartitioner::SimpleColored{ entity_set, part_patches, halo },
117 TypeTree::treePath()));
119 throw format_exception(IOError{},
"Not known coloring algorithm '{}' known", part_coloring);
122 throw format_exception(IOError{},
"Not known partition algorithm '{}' known", part_type);
131 spdlog::info(
"Creating time-step operator with '{}' execution policy",
exec_policy);
134 spdlog::warn(
"Too few patches '{}', execution policy of assembler is switched to 'sequential'",
part_patches);
139#if DUNE_COPASI_CONCURRENT_ASSEMBLY
auto format_exception(Exception &&e, fmt::format_string< Args... > format, Args &&... args)
Definition exceptions.hh:23
constexpr bool is_bitflags_v
Alias for Bitflag indicator.
Definition bit_flags.hh:24