9#include <kernel/lafem/dense_vector.hpp> 
   10#include <kernel/lafem/dense_vector_blocked.hpp> 
   11#include <kernel/lafem/filter_chain.hpp> 
   12#include <kernel/lafem/sparse_matrix_csr.hpp> 
   13#include <kernel/lafem/sparse_matrix_bcsr.hpp> 
   14#include <kernel/lafem/sparse_matrix_bwrappedcsr.hpp> 
   15#include <kernel/lafem/saddle_point_matrix.hpp> 
   17#include <kernel/lafem/filter_sequence.hpp> 
   18#include <kernel/lafem/none_filter.hpp> 
   19#include <kernel/lafem/slip_filter.hpp> 
   20#include <kernel/lafem/tuple_filter.hpp> 
   21#include <kernel/lafem/tuple_mirror.hpp> 
   22#include <kernel/lafem/tuple_diag_matrix.hpp> 
   23#include <kernel/lafem/transfer.hpp> 
   24#include <kernel/assembly/mirror_assembler.hpp> 
   25#include <kernel/assembly/symbolic_assembler.hpp> 
   26#include <kernel/assembly/domain_assembler_basic_jobs.hpp> 
   27#include <kernel/assembly/bilinear_operator_assembler.hpp> 
   28#include <kernel/assembly/common_operators.hpp> 
   29#include <kernel/assembly/gpdv_assembler.hpp> 
   30#include <kernel/assembly/grid_transfer.hpp> 
   31#include <kernel/assembly/mean_filter_assembler.hpp> 
   32#include <kernel/assembly/unit_filter_assembler.hpp> 
   33#include <kernel/global/gate.hpp> 
   34#include <kernel/global/muxer.hpp> 
   35#include <kernel/global/vector.hpp> 
   36#include <kernel/global/matrix.hpp> 
   37#include <kernel/global/filter.hpp> 
   38#include <kernel/global/mean_filter.hpp> 
   39#include <kernel/global/symmetric_lumped_schur_matrix.hpp> 
   40#include <kernel/global/transfer.hpp> 
   42#include <control/domain/domain_control.hpp> 
   43#include <control/asm/gate_asm.hpp> 
   44#include <control/asm/muxer_asm.hpp> 
   45#include <control/asm/splitter_asm.hpp> 
   46#include <control/asm/transfer_asm.hpp> 
   55      typename DataType_ = 
Real,
 
   56      typename IndexType_ = 
Index,
 
   57      typename MatrixBlockA_ = LAFEM::SparseMatrixBCSR<DataType_, IndexType_, dim_, dim_>,
 
   58      typename MatrixBlockB_ = LAFEM::SparseMatrixBCSR<DataType_, IndexType_, dim_, 1>,
 
   59      typename MatrixBlockD_ = LAFEM::SparseMatrixBCSR<DataType_, IndexType_, 1, dim_>,
 
   60      typename ScalarMatrix_ = LAFEM::SparseMatrixCSR<DataType_, IndexType_>,
 
   61      typename TransferMatrixV_ = LAFEM::SparseMatrixBWrappedCSR<DataType_, IndexType_, dim_>,
 
   62      typename TransferMatrixP_ = LAFEM::SparseMatrixCSR<DataType_, IndexType_>
 
   68      typedef DataType_ DataType;
 
   69      typedef IndexType_ IndexType;
 
   70      static constexpr int dim = dim_;
 
   73      typedef ScalarMatrix_ LocalScalarMatrix;
 
   74      typedef typename LocalScalarMatrix::VectorTypeL LocalScalarVector;
 
   77      typedef MatrixBlockA_ LocalMatrixBlockA;
 
   78      typedef MatrixBlockB_ LocalMatrixBlockB;
 
   79      typedef MatrixBlockD_ LocalMatrixBlockD;
 
   83      typedef typename LocalMatrixBlockB::VectorTypeL LocalVeloVector;
 
   84      typedef typename LocalMatrixBlockD::VectorTypeL LocalPresVector;
 
   94      typedef TransferMatrixV_ LocalVeloTransferMatrix;
 
   95      typedef TransferMatrixP_ LocalPresTransferMatrix;
 
  187        matrix_sys(&gate_sys, &gate_sys),
 
  189        transfer_pres(&coarse_muxer_pres),
 
  190        transfer_sys(&coarse_muxer_sys)
 
  206        matrix_sys(&gate_sys, &gate_sys),
 
  208        transfer_pres(&coarse_muxer_pres),
 
  209        transfer_sys(&coarse_muxer_sys),
 
  210        filter_velo(neumann_list)
 
  229      void compile_system_matrix()
 
  231        if(lumped_matrix_a.
local().size() == 
Index(0))
 
  243      void compile_system_transfer()
 
  245        transfer_sys.get_mat_prol().template at<0,0>()
 
  247        transfer_sys.get_mat_rest().template at<0,0>()
 
  249        transfer_sys.get_mat_prol().template at<1,1>()
 
  251        transfer_sys.get_mat_rest().template at<1,1>()
 
  255      template<
typename D_, 
typename I_, 
typename SMA_, 
typename SMB_, 
typename SMD_, 
typename SM_, 
typename TV_, 
typename TP_>
 
  256      void convert(
const ScalarMixedSystemLevel<dim_, D_, I_, SMA_, SMB_, SMD_, SM_, TV_, TP_> & other)
 
  268        Asm::build_splitter_tuple(this->base_splitter_sys, this->gate_sys.
get_freqs(), this->base_splitter_velo, this->base_splitter_pres);
 
  275        transfer_pres.
convert(&coarse_muxer_pres, 
other.transfer_pres);
 
  277        this->compile_system_matrix();
 
  278        this->compile_system_transfer();
 
  280        filter_velo.convert(
other.filter_velo);
 
  281        filter_pres.convert(
other.filter_pres);
 
  283        this->compile_system_filter();
 
  286      template<
typename DomainLevel_>
 
  287      void assemble_gates(
const Domain::VirtualLevel<DomainLevel_>& virt_dom_lvl)
 
  289        Asm::asm_gate(virt_dom_lvl, virt_dom_lvl->space_velo, this->gate_velo, 
true);
 
  290        Asm::asm_gate(virt_dom_lvl, virt_dom_lvl->space_pres, this->gate_pres, 
true);
 
  291        Asm::build_gate_tuple(this->gate_sys, this->gate_velo, this->gate_pres);
 
  295      template<
typename DomainLevel_>
 
  296      void assemble_coarse_muxers(
const Domain::VirtualLevel<DomainLevel_>& virt_lvl_coarse)
 
  298        Asm::asm_muxer(virt_lvl_coarse, [](
const DomainLevel_& dl){
return &dl.space_velo;}, this->
coarse_muxer_velo);
 
  299        Asm::asm_muxer(virt_lvl_coarse, [](
const DomainLevel_& dl){
return &dl.space_pres;}, this->coarse_muxer_pres);
 
  300        Asm::build_muxer_tuple(this->coarse_muxer_sys, this->gate_sys.
get_freqs(), this->coarse_muxer_velo, this->coarse_muxer_pres);
 
  304      template<
typename DomainLevel_>
 
  305      void assemble_base_splitters(
const Domain::VirtualLevel<DomainLevel_>& virt_lvl)
 
  307        Asm::asm_splitter(virt_lvl, [](
const DomainLevel_& dl){
return &dl.space_velo;}, this->
base_splitter_velo);
 
  308        Asm::asm_splitter(virt_lvl, [](
const DomainLevel_& dl){
return &dl.space_pres;}, this->base_splitter_pres);
 
  309        Asm::build_splitter_tuple(this->base_splitter_sys, this->gate_sys.
get_freqs(), this->base_splitter_velo, this->base_splitter_pres);
 
  313      template<
typename DomainLevel_>
 
  314      void assemble_transfers(
 
  316        const Domain::VirtualLevel<DomainLevel_>& virt_lvl_fine,
 
  317        const Domain::VirtualLevel<DomainLevel_>& virt_lvl_coarse,
 
  318        const String& cubature, 
bool trunc_v = 
false, 
bool trunc_p = 
false, 
bool shrink = 
true)
 
  320        Asm::asm_transfer_blocked(virt_lvl_fine, virt_lvl_coarse, cubature, trunc_v, shrink,
 
  321          [](
const DomainLevel_& dl) {
return &dl.space_velo;},
 
  322          this->transfer_velo.
local(), this->coarse_muxer_velo, this->gate_velo, sys_lvl_coarse.gate_velo);
 
  323        Asm::asm_transfer_scalar(virt_lvl_fine, virt_lvl_coarse, cubature, trunc_p, shrink,
 
  324          [](
const DomainLevel_& dl) {
return &dl.space_pres;},
 
  325          this->transfer_pres.
local(), this->coarse_muxer_pres, this->gate_pres, sys_lvl_coarse.gate_pres);
 
  327        this->transfer_velo.compile();
 
  328        this->transfer_pres.compile();
 
  329        this->compile_system_transfer();
 
  332      template<
typename DomainLevel_>
 
  333      void assemble_transfers(
 
  334        const Domain::VirtualLevel<DomainLevel_>& virt_lvl_fine,
 
  335        const Domain::VirtualLevel<DomainLevel_>& virt_lvl_coarse,
 
  336        const String& cubature, 
bool trunc_v = 
false, 
bool trunc_p = 
false, 
bool shrink = 
true)
 
  339        XASSERT(!virt_lvl_coarse.is_parent());
 
  341        Asm::asm_transfer_blocked(virt_lvl_fine, virt_lvl_coarse, cubature, trunc_v, shrink,
 
  342          [](
const DomainLevel_& dl) {
return &dl.space_velo;},
 
  343          this->transfer_velo.
local(), this->coarse_muxer_velo, this->gate_velo, this->gate_velo);
 
  344        Asm::asm_transfer_scalar(virt_lvl_fine, virt_lvl_coarse, cubature, trunc_p, shrink,
 
  345          [](
const DomainLevel_& dl) {
return &dl.space_pres;},
 
  346          this->transfer_pres.
local(), this->coarse_muxer_pres, this->gate_pres, this->gate_pres);
 
  348        this->transfer_velo.compile();
 
  349        this->transfer_pres.compile();
 
  350        this->compile_system_transfer();
 
  353      template<
typename SpaceVelo_, 
typename SpacePres_, 
typename Cubature_>
 
  354      void assemble_grad_div_matrices(
const SpaceVelo_& space_velo, 
const SpacePres_& space_pres, 
const Cubature_& cubature)
 
  357        space_velo, space_pres, cubature, DataType(1), DataType(1));
 
  360      template<
typename SpaceVelo_>
 
  361      void assemble_velo_struct(
const SpaceVelo_& space_velo)
 
  367      void compile_system_filter()
 
  373      void assemble_global_filters()
 
  376        const VeloGate& my_col_gate(this->gate_velo);
 
  379        for(
auto& it : filter_sys.local().template at<0>())
 
  383          auto& slip_filter_vector = it.second.get_filter_vector();
 
  386          if(slip_filter_vector.used_elements() > 0)
 
  389            LocalVeloVector tmp(slip_filter_vector.size(), DataType_(0));
 
  391            auto* tmp_elements = tmp.template elements<LAFEM::Perspective::native>();
 
  392            auto* sfv_elements = slip_filter_vector.template elements<LAFEM::Perspective::native>();
 
  395            for(
Index isparse(0); isparse < slip_filter_vector.used_elements(); ++isparse)
 
  397              Index idense(slip_filter_vector.indices()[isparse]);
 
  398              tmp_elements[idense] = sfv_elements[isparse];
 
  402            my_col_gate.sync_0(tmp);
 
  405            for(
Index isparse(0); isparse < slip_filter_vector.used_elements(); ++isparse)
 
  407              Index idense(slip_filter_vector.indices()[isparse]);
 
  408              tmp_elements[idense].normalize();
 
  409              sfv_elements[isparse] = tmp_elements[idense];
 
  417            LocalVeloVector tmp(slip_filter_vector.size(), DataType_(0));
 
  418            my_col_gate.sync_0(tmp);
 
#define XASSERT(expr)
Assertion macro definition.
static void assemble(LAFEM::SparseMatrixBCSR< DataType_, IndexType_, dim_, 1 > &matrix_b, LAFEM::SparseMatrixBCSR< DataType_, IndexType_, 1, dim_ > &matrix_d, const SpaceVelo_ &space_velo, const SpacePres_ &space_pres, const String &cubature_name, const DataType_ scale_b=-DataType_(1), const DataType_ scale_d=-DataType_(1))
Assembles the B and D matrices.
static void assemble_matrix_std1(MatrixType_ &matrix, const Space_ &space)
Assembles a standard matrix structure from a single space.
VeloSplitter base_splitter_velo
our base-mesh multiplexer
VeloGate gate_velo
our system gate
GlobalVeloTransfer transfer_velo
our global transfer operator
ScalarMixedSystemLevel()
Empty standard constructor.
ScalarMixedSystemLevel(const std::deque< String > &neumann_list)
Constructor for using essential boundary conditions.
VeloMuxer coarse_muxer_velo
our coarse-level system muxer
GlobalMatrixBlockA matrix_a
our global system matrix
std::size_t bytes() const
Returns the total amount of bytes allocated.
Global Filter wrapper class template.
std::size_t bytes() const
Returns the total amount of bytes allocated.
Global gate implementation.
void convert(const Gate< LVT2_, MT2_ > &other)
Conversion function for same vector container type but with different MDI-Type.
const LocalVector_ & get_freqs() const
Returns a const reference to the frequencies vector.
Global Matrix wrapper class template.
std::size_t bytes() const
Returns the total amount of bytes allocated.
void lump_rows(VectorTypeL &lump, bool sync=true) const
Computes the lumped rows of the matrix as a vector.
LocalMatrix_ & local()
Returns a reference to the internal local LAFEM matrix object.
Global multiplexer/demultiplexer implementation.
void convert(const Muxer< LVT2_, MT2_ > &other)
Conversion function for same vector container type but with different MDI-Type.
Global base-mesh vector splitter (and joiner) implementation.
void convert(const Splitter< LVT2_, MT2_ > &other)
Conversion function for same vector container type but with different MDI-Type.
Global grid-transfer operator class template.
void convert(MuxerType *coarse_muxer, const Transfer< LocalTransfer2_, Mirror2_ > &other)
container conversion function
Transfer clone(LAFEM::CloneMode clone_mode=LAFEM::CloneMode::Weak) const
Creates a clone of this object.
std::size_t bytes() const
Global vector wrapper class template.
LocalVector_ & local()
Returns a reference to the internal local LAFEM vector object.
Sequence of filters of the same type.
FilterSequence clone(CloneMode clone_mode=CloneMode::Deep) const
Creates a clone of itself.
None Filter class template.
NoneFilter clone(CloneMode=CloneMode::Deep) const
Creates a (empty) clone of itself.
Saddle-Point matrix meta class template.
MatrixTypeA & block_a()
Returns the sub-matrix block A.
MatrixTypeB & block_b()
Returns the sub-matrix block B.
MatrixTypeD & block_d()
Returns the sub-matrix block D.
Slip Filter class template.
Grid-Transfer operator class template.
Tuple-Diag-Matrix meta class template.
TupleVector meta-filter class template.
TupleVector meta-mirror class template.
Variadic TupleVector class template.
Handles vector prolongation, restriction and serialization.
@ other
generic/other permutation strategy
double Real
Real data type.
std::uint64_t Index
Index data type.