FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
blocked_basic.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/dense_vector_blocked.hpp>
10#include <kernel/lafem/sparse_matrix_bcsr.hpp>
11#include <kernel/lafem/sparse_matrix_bwrappedcsr.hpp>
12#include <kernel/lafem/unit_filter_blocked.hpp>
13#include <kernel/lafem/slip_filter.hpp>
14#include <kernel/lafem/filter_chain.hpp>
15#include <kernel/lafem/filter_sequence.hpp>
16#include <kernel/lafem/vector_mirror.hpp>
17#include <kernel/lafem/transfer.hpp>
18#include <kernel/global/gate.hpp>
19#include <kernel/global/vector.hpp>
20#include <kernel/global/matrix.hpp>
21#include <kernel/global/filter.hpp>
22#include <kernel/global/transfer.hpp>
23#include <kernel/global/muxer.hpp>
24#include <kernel/assembly/common_operators.hpp>
25#include <kernel/assembly/domain_assembler_basic_jobs.hpp>
26
27#include <control/domain/domain_control.hpp>
28#include <control/asm/gate_asm.hpp>
29#include <control/asm/muxer_asm.hpp>
30#include <control/asm/splitter_asm.hpp>
31#include <control/asm/transfer_asm.hpp>
32#include <control/asm/mean_filter_asm.hpp>
33#include <control/asm/unit_filter_asm.hpp>
34#include <control/asm/slip_filter_asm.hpp>
35
36namespace FEAT
37{
38 namespace Control
39 {
40 template<
41 int dim_,
42 typename DataType_ = Real,
43 typename IndexType_ = Index,
44 typename BlockedMatrix_ = LAFEM::SparseMatrixBCSR<DataType_, IndexType_, dim_, dim_>,
45 typename TransferMatrix_ = LAFEM::SparseMatrixBWrappedCSR<DataType_, IndexType_, dim_>
46 >
48 {
49 public:
50 static_assert(std::is_same<DataType_, typename BlockedMatrix_::DataType>::value, "DataType mismatch!");
51 static_assert(std::is_same<IndexType_, typename BlockedMatrix_::IndexType>::value, "IndexType mismatch!");
52
53 // basic types
54 typedef DataType_ DataType;
55 typedef IndexType_ IndexType;
56 static constexpr int dim = dim_;
57
59 typedef BlockedMatrix_ LocalBlockedMatrix;
60
62 typedef BlockedMatrix_ LocalSystemMatrix;
63
65 typedef TransferMatrix_ LocalSystemTransferMatrix;
66
68 typedef typename LocalSystemMatrix::VectorTypeR LocalSystemVector;
69
72
75
78
79 // define system muxer
81
84
87
90
91 /* ***************************************************************************************** */
92
95
98
101
104
109 {
110 }
111
112 // no copies, no problems
114 BlockedBasicSystemLevel& operator=(const BlockedBasicSystemLevel&) = delete;
115
117 {
118 }
119
121 std::size_t bytes() const
122 {
123 return this->gate_sys.bytes() + this->coarse_muxer_sys.bytes()
124 + this->transfer_sys.bytes() + this->matrix_sys.local().bytes();
125 }
126
127 template<typename M_, typename D_, typename I_, typename SM_>
128 void convert(const BlockedBasicSystemLevel<dim_, M_, D_, I_, SM_> & other)
129 {
130 gate_sys.convert(other.gate_sys);
131 coarse_muxer_sys.convert(other.coarse_muxer_sys);
132 matrix_sys.convert(&gate_sys, &gate_sys, other.matrix_sys);
133 transfer_sys.convert(&coarse_muxer_sys, other.transfer_sys);
134 }
135
136 template<typename DomainLevel_>
137 void assemble_gate(const Domain::VirtualLevel<DomainLevel_>& virt_dom_lvl)
138 {
139 Asm::asm_gate(virt_dom_lvl, virt_dom_lvl->space, this->gate_sys, true);
140 }
141
142 template<typename DomainLevel_>
143 void assemble_coarse_muxer(const Domain::VirtualLevel<DomainLevel_>& virt_lvl_coarse)
144 {
145 Asm::asm_muxer(virt_lvl_coarse, [](const DomainLevel_& dl){return &dl.space;}, this->coarse_muxer_sys);
146 }
147
148 template<typename DomainLevel_>
149 void assemble_transfer(
150 const BlockedBasicSystemLevel& sys_lvl_coarse,
151 const Domain::VirtualLevel<DomainLevel_>& virt_lvl_fine,
152 const Domain::VirtualLevel<DomainLevel_>& virt_lvl_coarse,
153 const String& cubature, bool trunc = false, bool shrink = true)
154 {
155 Asm::asm_transfer_blocked(virt_lvl_fine, virt_lvl_coarse, cubature, trunc, shrink,
156 [](const DomainLevel_& dl) {return &dl.space;},
157 this->transfer_sys.local(), this->coarse_muxer_sys, this->gate_sys, sys_lvl_coarse.gate_sys);
158
159 this->transfer_sys.compile();
160 }
161
162 template<typename DomainLevel_>
163 void assemble_transfer(
164 const Domain::VirtualLevel<DomainLevel_>& virt_lvl_fine,
165 const Domain::VirtualLevel<DomainLevel_>& virt_lvl_coarse,
166 const String& cubature, bool trunc = false, bool shrink = true)
167 {
168 // if the coarse level is a parent, then we need the coarse system level
169 XASSERT(!virt_lvl_coarse.is_parent());
170
171 Asm::asm_transfer_blocked(virt_lvl_fine, virt_lvl_coarse, cubature, trunc, shrink,
172 [](const DomainLevel_& dl) {return &dl.space;},
173 this->transfer_sys.local(), this->coarse_muxer_sys, this->gate_sys, this->gate_sys);
174
175 this->transfer_sys.compile();
176 }
177
178 template<typename Trafo_, typename Space_>
179 void assemble_laplace_matrix(Assembly::DomainAssembler<Trafo_>& dom_asm, const Space_& space, const String& cubature, const DataType nu = DataType(1))
180 {
181 // get local matrix
182 auto& loc_matrix = this->matrix_sys.local();
183
184 // assemble structure?
185 if(loc_matrix.empty())
186 {
188 }
189
190 // format and assemble Laplace
191 loc_matrix.format();
192 Assembly::Common::LaplaceOperatorBlocked<dim_> laplace_op;
193 Assembly::assemble_bilinear_operator_matrix_1(dom_asm, loc_matrix, laplace_op, space, cubature, nu);
194 }
195 }; // class BlockedBasicSystemLevel<...>
196
197
198 template<
199 int dim_,
200 typename DataType_ = Real,
201 typename IndexType_ = Index,
202 typename BlockedMatrix_ = LAFEM::SparseMatrixBCSR<DataType_, IndexType_, dim_, dim_>,
203 typename TransferMatrix_ = LAFEM::SparseMatrixBWrappedCSR<DataType_, IndexType_, dim_>>
205 public BlockedBasicSystemLevel<dim_, DataType_, IndexType_, BlockedMatrix_, TransferMatrix_>
206 {
207 public:
209
210 // basic types
211 typedef DataType_ DataType;
212 typedef IndexType_ IndexType;
213
216
219
222
224 template <typename DT2_, typename IT2_, typename BlockedMatrix2_>
226
229
232 BaseClass()
233 {
234 }
235
237 std::size_t bytes() const
238 {
239 return BaseClass::bytes () + filter_sys.bytes();
240 }
241
242 template<typename M_, typename D_, typename I_, typename SM_>
244 {
245 BaseClass::convert(other);
246 filter_sys.convert(other.filter_sys);
247 }
248
249 template<typename DomainLevel_, typename Space_>
250 void assemble_homogeneous_unit_filter(const DomainLevel_& dom_level, const Space_& space)
251 {
252 Asm::asm_unit_filter_blocked_homogeneous(this->filter_sys.local(), dom_level, space, "*");
253 }
254 }; // class BlockedUnitFilterSystemLevel<...>
255
256 template<
257 int dim_,
258 typename DataType_ = Real,
259 typename IndexType_ = Index,
260 typename BlockedMatrix_ = LAFEM::SparseMatrixBCSR<DataType_, IndexType_, dim_, dim_>,
261 typename TransferMatrix_ = LAFEM::SparseMatrixBWrappedCSR<DataType_, IndexType_, dim_>>
263 public BlockedBasicSystemLevel<dim_, DataType_, IndexType_, BlockedMatrix_, TransferMatrix_>
264 {
265 public:
267
268 // basic types
269 typedef DataType_ DataType;
270 typedef IndexType_ IndexType;
271
274
278 //typedef LAFEM::MeanFilterBlocked<DataType_, IndexType_, dim_> LocalMeanFilter;
282
285
287 template <typename DT2_, typename IT2_, typename BlockedMatrix2_>
289
292
295 BaseClass()
296 {
297 }
298
300 std::size_t bytes() const
301 {
302 return BaseClass::bytes () + filter_sys.bytes();
303 }
304
305 template<typename M_, typename D_, typename I_, typename SM_>
306 void convert(const BlockedCombinedSystemLevel<dim_, M_, D_, I_, SM_> & other)
307 {
308 BaseClass::convert(other);
309 filter_sys.convert(other.filter_sys);
310 }
311
312 LocalUnitFilterSeq& get_local_unit_filter_seq()
313 {
314 return this->filter_sys.local().template at<0>();
315 }
316
317 LocalUnitFilter& get_local_unit_filter(const String& name)
318 {
319 return get_local_unit_filter_seq().find_or_add(name);
320 }
321
322 LocalSlipFilterSeq& get_local_slip_filter_seq()
323 {
324 return this->filter_sys.local().template at<1>();
325 }
326
327 LocalSlipFilter& get_local_slip_filter(const String& name)
328 {
329 return get_local_slip_filter_seq().find_or_add(name);
330 }
331
332 //LocalMeanFilter& get_local_mean_filter()
333 //{
334 //return this->filter_sys.local().template at<1>();
335 //}
336
337 template<typename DomainLevel_, typename Space_>
338 void assemble_homogeneous_unit_filter(const DomainLevel_& dom_level, const Space_& space, const String& name, const String& mesh_parts)
339 {
340 auto& loc_filter = get_local_unit_filter(name);
341 loc_filter.clear();
342 Asm::asm_unit_filter_blocked_homogeneous(loc_filter, dom_level, space, mesh_parts);
343 }
344
345 template<typename DomainLevel_, typename Space_, typename Function_>
346 void assemble_unit_filter(const DomainLevel_& dom_level, const Space_& space, const String& name, const String& mesh_parts, const Function_& function)
347 {
348 auto& loc_filter = get_local_unit_filter(name);
349 loc_filter.clear();
350 Asm::asm_unit_filter_blocked(loc_filter, dom_level, space, mesh_parts, function);
351 }
352
353 template<typename DomainLevel_, typename Space_>
354 void assemble_slip_filter(const DomainLevel_& dom_level, const Space_& space, const String& name, const String& mesh_parts)
355 {
356 auto& loc_filter = get_local_slip_filter(name);
357 loc_filter.clear();
358 Asm::asm_slip_filter(loc_filter, dom_level, space, mesh_parts);
359 Asm::sync_slip_filter(this->gate_sys, loc_filter);
360 }
361
362 //template<typename Space_>
363 //void assemble_mean_filter(const Space_& space, const String& cubature)
364 //{
365 // get_local_mean_filter() = Asm::asm_mean_filter(this->gate_sys, space, cubature);
366 //}
367 }; // class BlockedCombinedSystemLevel<...>
368 } // namespace Control
369} // namespace FEAT
#define XASSERT(expr)
Assertion macro definition.
Definition: assertion.hpp:262
FEAT Kernel base header.
static void assemble_matrix_std1(MatrixType_ &matrix, const Space_ &space)
Assembles a standard matrix structure from a single space.
LocalSystemMatrix::VectorTypeR LocalSystemVector
define local system vector type
BlockedMatrix_ LocalSystemMatrix
define local system matrix type
Global::Transfer< LocalSystemTransfer, SystemMirror > GlobalSystemTransfer
define global system operator type
LAFEM::Transfer< LocalSystemTransferMatrix > LocalSystemTransfer
define local system transfer operator type
TransferMatrix_ LocalSystemTransferMatrix
define local transfer matrix type
GlobalSystemTransfer transfer_sys
our global transfer operator
Global::Matrix< LocalSystemMatrix, SystemMirror, SystemMirror > GlobalSystemMatrix
define global system matrix type
std::size_t bytes() const
Returns the total amount of bytes allocated.
SystemGate gate_sys
our system gate
SystemMuxer coarse_muxer_sys
our coarse-level system muxer
Global::Vector< LocalSystemVector, SystemMirror > GlobalSystemVector
define global system vector type
Global::Gate< LocalSystemVector, SystemMirror > SystemGate
define system gate
GlobalSystemMatrix matrix_sys
our global system matrix
BlockedMatrix_ LocalBlockedMatrix
define local blocked matrix type
LAFEM::VectorMirror< DataType, IndexType > SystemMirror
define system mirror type
Global::Filter< LocalSystemFilter, SystemMirror > GlobalSystemFilter
define global filter type
GlobalSystemFilter filter_sys
our global system filter
LAFEM::UnitFilterBlocked< DataType_, IndexType_, dim_ > LocalUnitFilter
define local filter types
std::size_t bytes() const
Returns the total amount of bytes allocated.
LAFEM::VectorMirror< DataType, IndexType > SystemMirror
define system mirror type
LAFEM::UnitFilterBlocked< DataType_, IndexType_, dim_ > LocalSystemFilter
define local filter type
GlobalSystemFilter filter_sys
our global system filter
LAFEM::VectorMirror< DataType, IndexType > SystemMirror
define system mirror type
std::size_t bytes() const
Returns the total amount of bytes allocated.
Global::Filter< LocalSystemFilter, SystemMirror > GlobalSystemFilter
define global filter type
Global Filter wrapper class template.
Definition: filter.hpp:21
std::size_t bytes() const
Returns the total amount of bytes allocated.
Definition: filter.hpp:77
Global gate implementation.
Definition: gate.hpp:51
void convert(const Gate< LVT2_, MT2_ > &other)
Conversion function for same vector container type but with different MDI-Type.
Definition: gate.hpp:191
std::size_t bytes() const
Returns the total amount of bytes allocated.
Definition: gate.hpp:252
Global Matrix wrapper class template.
Definition: matrix.hpp:40
LocalMatrix_ & local()
Returns a reference to the internal local LAFEM matrix object.
Definition: matrix.hpp:126
Global multiplexer/demultiplexer implementation.
Definition: muxer.hpp:68
std::size_t bytes() const
Returns the internal data size in bytes.
Definition: muxer.hpp:211
void convert(const Muxer< LVT2_, MT2_ > &other)
Conversion function for same vector container type but with different MDI-Type.
Definition: muxer.hpp:155
Global grid-transfer operator class template.
Definition: transfer.hpp:23
void convert(MuxerType *coarse_muxer, const Transfer< LocalTransfer2_, Mirror2_ > &other)
container conversion function
Definition: transfer.hpp:107
std::size_t bytes() const
Definition: transfer.hpp:143
LocalTransfer_ & local()
Definition: transfer.hpp:131
Global vector wrapper class template.
Definition: vector.hpp:68
Filter Chainclass template.
Sequence of filters of the same type.
Slip Filter class template.
Definition: slip_filter.hpp:67
Grid-Transfer operator class template.
Definition: transfer.hpp:27
Unit Filter Blocked class template.
Handles vector prolongation, restriction and serialization.
void assemble_bilinear_operator_matrix_1(DomainAssembler< Trafo_ > &dom_asm, Matrix_ &matrix, const BilOp_ &bilinear_operator, const Space_ &space, const String &cubature, const typename Matrix_::DataType alpha=typename Matrix_::DataType(1))
Assembles a bilinear operator into a matrix with identical test- and trial-spaces.
FEAT namespace.
Definition: adjactor.hpp:12
double Real
Real data type.
std::uint64_t Index
Index data type.