FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
slip_filter_asm.hpp
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#pragma once
7
9#include <kernel/lafem/slip_filter.hpp>
10#include <kernel/assembly/slip_filter_assembler.hpp>
11#include <kernel/global/gate.hpp>
12
13namespace FEAT
14{
15 namespace Control
16 {
17 namespace Asm
18 {
38 template<typename DataType_, typename IndexType_, int block_size_, typename DomainLevel_, typename Space_>
39 void asm_slip_filter(LAFEM::SlipFilter<DataType_, IndexType_, block_size_>& filter,
40 const DomainLevel_& dom_level, const Space_& space, const String& mesh_part_names)
41 {
42 // create slip-filter assembler
43 Assembly::SlipFilterAssembler<typename DomainLevel_::TrafoType> slip_filter_asm(dom_level.trafo);
44
45 std::deque<String> mp_names;
46 if(mesh_part_names == "*")
47 mp_names = dom_level.get_mesh_node()->get_mesh_part_names(true);
48 else
49 mp_names = mesh_part_names.split_by_whitespaces();
50
51 // loop over all mesh parts
52 for(const auto& mp_name : mp_names)
53 {
54 auto* mesh_part_node = dom_level.get_mesh_node()->find_mesh_part_node(mp_name);
55 XASSERT(mesh_part_node != nullptr);
56
57 // let's see if we have that mesh part
58 // if it is nullptr, then our patch is not adjacent to that boundary part
59 auto* mesh_part = mesh_part_node->get_mesh();
60 if (mesh_part != nullptr)
61 {
62 // add to boundary assembler
63 slip_filter_asm.add_mesh_part(*mesh_part);
64 }
65 }
66
67 // finally, assemble the filter
68 slip_filter_asm.assemble(filter, space);
69 }
70
80 template<typename Gate_, typename SlipFilter_>
81 void sync_slip_filter(Gate_& gate, SlipFilter_& slip_filter)
82 {
83 auto& slip_filter_vector = slip_filter.get_filter_vector();
84 auto tmp = gate.get_freqs().clone(LAFEM::CloneMode::Layout);
85 tmp.format();
86
87 if(slip_filter_vector.used_elements() > 0)
88 {
89 auto* tmp_elements = tmp.template elements<LAFEM::Perspective::native>();
90 auto* sfv_elements = slip_filter_vector.template elements<LAFEM::Perspective::native>();
91
92 // Copy sparse filter vector contents to DenseVector
93 for(Index isparse(0); isparse < slip_filter_vector.used_elements(); ++isparse)
94 {
95 Index idense(slip_filter_vector.indices()[isparse]);
96 tmp_elements[idense] = sfv_elements[isparse];
97 }
98
99 gate.sync_0(tmp);
100
101 // Copy sparse filter vector contents to DenseVector
102 for(Index isparse(0); isparse < slip_filter_vector.used_elements(); ++isparse)
103 {
104 Index idense(slip_filter_vector.indices()[isparse]);
105 tmp_elements[idense].normalize();
106 sfv_elements[isparse] = tmp_elements[idense];
107 }
108 }
109 else
110 {
111 gate.sync_0(tmp);
112 }
113 }
114 } // namespace Asm
115 } // namespace Control
116} // namespace FEAT
#define XASSERT(expr)
Assertion macro definition.
Definition: assertion.hpp:262
FEAT Kernel base header.
FEAT namespace.
Definition: adjactor.hpp:12
std::uint64_t Index
Index data type.