![]() |
KASKADE 7 development version
|
A class for assembling Galerkin representation matrices and right hand sides for variational functionals depending on multiple variables. More...
#include <assemblerCore.hh>
Classes | |
| struct | BlockToSequence |
| struct | BlockToTriplet |
| struct | CountNonzeros |
Public Types | |
| typedef VariationalFunctionalAssembler< F, SparseIndex, BoundaryDetector, QuadRule > | Self |
| typedef F | Functional |
| functional | |
| typedef Functional::AnsatzVars | AnsatzVariableSetDescription |
| ansatz variables | |
| typedef Functional::TestVars | TestVariableSetDescription |
| test variables | |
| typedef AnsatzVariableSetDescription::Grid | Grid |
| grid | |
| typedef AnsatzVariableSetDescription::GridView | GridView |
| The grid view on which the variables live. | |
| typedef AnsatzVariableSetDescription::Spaces | Spaces |
| spaces | |
| typedef AnsatzVariableSetDescription::IndexSet | IndexSet |
| index set | |
| typedef Functional::Scalar | field_type |
| Underlying field type. | |
| using | Scalar = field_type |
| using | MatrixBlockArray = typename AssemblyDetail::BlockArray<Policy,AnsatzVariables,TestVariables,SparseIndex>::type |
| A boost::fusion sequence of AssemblyDetail::MatrixBlock elements for present matrix blocks. | |
| typedef AssemblyDetail::RhsBlockArray< Policy, TestVariables >::type | RhsBlockArray |
| A boost::fusion sequence of AssemblyDetail::RhsBock elements for present rhs blocks. | |
| typedef TestVariableSetDescription::template CoefficientVector | RhsArray |
| A LinearProductSpace type of right hand side coefficient vectors. | |
Public Member Functions | |
| VariationalFunctionalAssembler (Spaces const &spaces) | |
| Construct an empty assembler, gridManager is implicitly obtained from the first space. | |
| void | assemble (F const &f, unsigned int flags=Assembler::EVERYTHING, int nThreads=0, bool verbose=false) |
| Assembly without block filter or cell filter. | |
| template<class BlockFilter, class CellFilter> | |
| void | assemble (F const &f, CellFilter const &cellFilter, unsigned int flags=Assembler::EVERYTHING, int nTasks=0, bool verbose=false) |
| Create data in assembler. | |
| int | valid () |
| Returns a bitfield specifyign which of the parts have been assembled since construction or flush() according to the format (VALUE|RHS|MATRX). | |
| void | flush (int flags=(VALUE|RHS|MATRIX)) |
| Destructs parts of the assembled quatities according to the format (VALUE|RHS|MATRX) | |
| std::pair< size_t, size_t > | size (int row, int col) const |
| the size of a matrix block (in terms of scalar rows/columns) | |
| template<class DataOutIter> | |
| void | toSequence (int rbegin, int rend, DataOutIter xi) const |
| Writes the subvector defined by the half-open block range [rbegin,rend) to the output iterator xi. | |
| MatrixBlockArray & | getMatrix () const |
| Returns a mutable reference to the sequence of matrix blocks. | |
| template<int first = 0, int last = TestVariableSetDescription::noOfVariables> | |
| TestVariableSetDescription::template CoefficientVector< first, last > | rhs () const |
| Returns a contiguous subrange of the rhs coefficient vectors. | |
Tuning parameters | |
| Self & | setNSimultaneousBlocks (int n) |
| Defines how many cells are assembled locally before scattering them together into the global data structures. | |
| Self & | setRowBlockFactor (double a) |
| Defines how many more row blocks in each matrix are used compared to the number of threads. | |
| Self & | setLocalStorageSize (size_t s) |
| Defines how many memory the locally assembled matrices may occupy before they are scattered. | |
| Self & | setGatherTimings (bool gt) |
| Whether to gather timing statistics using Kaskade::Timings. | |
Submatrix access | |
| template<class Matrix> | |
| Matrix | get (bool extractOnlyLowerTriangle=false, int rbegin=0, int rend=TestVariableSetDescription::noOfVariables, int cbegin=0, int cend=AnsatzVariableSetDescription::noOfVariables) const |
| Extracts the submatrix defined by the half-open block ranges [rbegin,rend), [cbegin,cend). | |
| template<int row, int col> | |
| auto const & | get () const |
| Extracts a raw single submatrix block indexed by row and column. | |
| template<class MatrixType, class BlockInformation> | |
| MatrixType | get (bool extractOnlyLowerTriangle) const |
| Extracts the submatrix defined by the half-open block ranges given as template parameter. | |
General information | |
| size_t | nnz (size_t rbegin=0, size_t rend=TestVariableSetDescription::noOfVariables, size_t cbegin=0, size_t cend=AnsatzVariableSetDescription::noOfVariables, bool extractOnlyLowerTriangle=false) const |
| Returns the number of structurally nonzero entries in the submatrix defined by the half-open block ranges [rbegin,rend), [cbegin,cend). | |
| size_t | nrows (int firstBlock=0, int lastBlock=TestVariableSetDescription::noOfVariables) const |
| Returns the number of scalar rows in the row block range [firstBlock,lastBlock[. | |
| size_t | ncols (int firstBlock=0, int lastBlock=AnsatzVariableSetDescription::noOfVariables) const |
| Returns the number of scalar cols in the column block range [firstBlock,lastBlock[. | |
| Spaces const & | spaces () const |
| Returns the list of spaces used. | |
| GridView const & | gridView () const |
| The grid view used. | |
Static Public Attributes | |
| static unsigned int const | VALUE = Assembler::VALUE |
| DEPRECATED, enums in the Assembler namespace. | |
| static unsigned int const | RHS = Assembler::RHS |
| static unsigned int const | MATRIX = Assembler::MATRIX |
| static unsigned int const | EVERYTHING = Assembler::EVERYTHING |
Protected Types | |
| typedef AssemblyDetail::FormulationPolicy< F > | Policy |
| typedef AnsatzVariableSetDescription::Variables | AnsatzVariables |
| typedef TestVariableSetDescription::Variables | TestVariables |
| typedef GridView::template Codim< 0 >::Iterator | CellIterator |
| typedef CellIterator::Entity | Entity |
Protected Member Functions | |
| std::pair< RhsArray &, RhsBlockArray & > | getRhs () const |
| void | reactToRefinement (GridSignals::Status const status) |
Protected Attributes | |
| boost::signals2::scoped_connection | refConnection |
| Spaces const & | spaces_ |
| GridManagerBase< Grid > const & | gridManager |
| GridView const & | gv |
| IndexSet const & | indexSet |
| std::shared_ptr< MatrixBlockArray > | matrixBlocks |
| std::shared_ptr< RhsArray > | rhss |
| std::shared_ptr< RhsBlockArray > | rhsBlocks |
| BoundaryDetector | boundaryDetector |
| int | validparts |
| int | nSimultaneousBlocks |
| double | rowBlockFactor |
| size_t | localStorageSize |
| bool | gatherTimings = false |
Static Protected Attributes | |
| static constexpr bool | innerBoundaries = hasInnerBoundaryCache<Functional> |
A class for assembling Galerkin representation matrices and right hand sides for variational functionals depending on multiple variables.
Template parameters:
| F | The variational functional. This has to be a model of the VariationalFunctional concept. |
| BoundaryDetector | A policy class type for detecting cells incident to the boundary. Currently CachingBoundaryDetector, ForwardingBoundaryDetector, and TrivialBoundaryDetector may be used. |
| QuadRule | allows choice of quadrature formula. Default: provided by DUNE, some special formulas: special_quadrature.hh |
After a grid refinement an assembler is not valid anymore and has to be constructed again. This is, because the assembler copies the index set at construction, which changes, if the grid changes
Definition at line 1431 of file assemblerCore.hh.
|
protected |
Definition at line 1469 of file assemblerCore.hh.
| typedef Functional::AnsatzVars Kaskade::VariationalFunctionalAssembler< F, SparseIndex, BoundaryDetector, QuadRule >::AnsatzVariableSetDescription |
ansatz variables
Definition at line 1443 of file assemblerCore.hh.
|
protected |
Definition at line 1609 of file assemblerCore.hh.
|
protected |
Definition at line 1610 of file assemblerCore.hh.
| typedef Functional::Scalar Kaskade::VariationalFunctionalAssembler< F, SparseIndex, BoundaryDetector, QuadRule >::field_type |
Underlying field type.
Definition at line 1464 of file assemblerCore.hh.
| typedef F Kaskade::VariationalFunctionalAssembler< F, SparseIndex, BoundaryDetector, QuadRule >::Functional |
functional
Definition at line 1441 of file assemblerCore.hh.
| typedef AnsatzVariableSetDescription::Grid Kaskade::VariationalFunctionalAssembler< F, SparseIndex, BoundaryDetector, QuadRule >::Grid |
grid
Definition at line 1449 of file assemblerCore.hh.
| typedef AnsatzVariableSetDescription::GridView Kaskade::VariationalFunctionalAssembler< F, SparseIndex, BoundaryDetector, QuadRule >::GridView |
The grid view on which the variables live.
Definition at line 1454 of file assemblerCore.hh.
| typedef AnsatzVariableSetDescription::IndexSet Kaskade::VariationalFunctionalAssembler< F, SparseIndex, BoundaryDetector, QuadRule >::IndexSet |
index set
Definition at line 1459 of file assemblerCore.hh.
| using Kaskade::VariationalFunctionalAssembler< F, SparseIndex, BoundaryDetector, QuadRule >::MatrixBlockArray = typename AssemblyDetail::BlockArray<Policy,AnsatzVariables,TestVariables,SparseIndex>::type |
A boost::fusion sequence of AssemblyDetail::MatrixBlock elements for present matrix blocks.
The elements of this sequence type include both block info and the global matrices.
Definition at line 1488 of file assemblerCore.hh.
|
protected |
Definition at line 1435 of file assemblerCore.hh.
| typedef TestVariableSetDescription::template CoefficientVector Kaskade::VariationalFunctionalAssembler< F, SparseIndex, BoundaryDetector, QuadRule >::RhsArray |
A LinearProductSpace type of right hand side coefficient vectors.
Definition at line 1500 of file assemblerCore.hh.
| typedef AssemblyDetail::RhsBlockArray<Policy,TestVariables>::type Kaskade::VariationalFunctionalAssembler< F, SparseIndex, BoundaryDetector, QuadRule >::RhsBlockArray |
A boost::fusion sequence of AssemblyDetail::RhsBock elements for present rhs blocks.
The elements of this sequence type include the rhs block infos.
Definition at line 1495 of file assemblerCore.hh.
| using Kaskade::VariationalFunctionalAssembler< F, SparseIndex, BoundaryDetector, QuadRule >::Scalar = field_type |
Definition at line 1466 of file assemblerCore.hh.
| typedef VariationalFunctionalAssembler<F,SparseIndex,BoundaryDetector,QuadRule> Kaskade::VariationalFunctionalAssembler< F, SparseIndex, BoundaryDetector, QuadRule >::Self |
Definition at line 1438 of file assemblerCore.hh.
| typedef AnsatzVariableSetDescription::Spaces Kaskade::VariationalFunctionalAssembler< F, SparseIndex, BoundaryDetector, QuadRule >::Spaces |
spaces
Definition at line 1457 of file assemblerCore.hh.
|
protected |
Definition at line 1470 of file assemblerCore.hh.
| typedef Functional::TestVars Kaskade::VariationalFunctionalAssembler< F, SparseIndex, BoundaryDetector, QuadRule >::TestVariableSetDescription |
test variables
Definition at line 1446 of file assemblerCore.hh.
|
inlineexplicit |
Construct an empty assembler, gridManager is implicitly obtained from the first space.
Definition at line 1523 of file assemblerCore.hh.
|
inline |
Create data in assembler.
Assembles the value and/or derivative and/or Hessian (according to the given flags, default is to assemble all three) of the FE-discretized variational functional given by f. The block filter can be used for partial assembly of specified blocks in the matrix and rhs.
The data that is not concerned by the given flags and block filter is left unmodified. Be careful: This allows to drive the Galerkin operator representation into a semantically inconsistent state. This need not be a problem (instead it can be useful and more efficient in certain situations), but one has to be aware of that fact. The data that is not concerned by the cell filter is cleared before assembly (must be, because new values are partially added up to existing data).
| BlockFilter | a traits class implementing the BlockFilter concept |
| CellFilter | a callable type for deciding on which cells to assemble |
The assembled data can afterwards be accessed via the functional, rhs, and matrix methods.
| f | the variational functional or weak formulation to be assembled |
| cellFilter | a callable mapping a grid cell to a boolean. Assembly is performed only on those cells for which the cell filter returns true. This can be used, e.g., for subassembly in non-overlapping domain decomposition such as BDDC, or for partial update of stiffness matrices/rhs in case of spatially local changes in Newton's method. |
| flags | a bitset determining what to assemble |
| nTasks | number of tasks to submit to the thread pool for parallel execution. 0 (default) means to use the default hardware concurrency reported by the system. Sequential computation is performed if the grid is reported not to be thread-safe. You can call GridManagerBase::enforceConcurrentReads to lie about thread-safety in case you know (or believe) the implementation to be thread safe. |
| verbose | whether to output status messages to standard output |
Definition at line 1654 of file assemblerCore.hh.
|
inline |
Assembly without block filter or cell filter.
Definition at line 1600 of file assemblerCore.hh.
Referenced by assemble(), Kaskade::HigherOrderRecovery< Grid, Space >::getErrorFunction(), and Kaskade::Limex< Eq >::step().
|
inline |
Destructs parts of the assembled quatities according to the format (VALUE|RHS|MATRX)
The default flag leads to destruction of all three values.
Definition at line 2113 of file assemblerCore.hh.
Referenced by reactToRefinement().
|
inline |
Extracts a raw single submatrix block indexed by row and column.
Note that for symmetric matrices, only the lower triangular part is stored.
Compilation will fail if the referenced matrix block is not present.
Definition at line 2192 of file assemblerCore.hh.
Referenced by get().
|
inline |
Extracts the submatrix defined by the half-open block ranges given as template parameter.
Provide the block information via IstlInterface_Detail::BlockInfo.
Definition at line 2203 of file assemblerCore.hh.
|
inline |
Extracts the submatrix defined by the half-open block ranges [rbegin,rend), [cbegin,cend).
If extractOnlyLowerTriangle is true, the Galerkin operator is treated as if its upper triangle was structurally zero.
In order to be able to read the assembled matrix into the smart pointer a specialization of AssemblyDetail::Fill, i.e. AssemblyDetail::Fill<MatrixType> must be available!!!
Kaskade provides spezializations of AssemblyDetail::Fill for
| extractOnlyLowerTriangle | if true, and the matrix is symmetric, only the lower triangular part is extracted |
| rbegin | number first block row to store |
| rend | number of one past the last block row to store |
| cbegin | number first block column to store |
| cend | number of one past the last block column to store |
Definition at line 2164 of file assemblerCore.hh.
|
inline |
Returns a mutable reference to the sequence of matrix blocks.
The data structure for the matrix is created on the fly if needed.
Definition at line 2289 of file assemblerCore.hh.
Referenced by assemble(), get(), get(), and nnz().
|
inlineprotected |
Definition at line 2338 of file assemblerCore.hh.
Referenced by assemble(), rhs(), and toSequence().
|
inline |
The grid view used.
Definition at line 2273 of file assemblerCore.hh.
|
inline |
Returns the number of scalar cols in the column block range [firstBlock,lastBlock[.
Definition at line 2257 of file assemblerCore.hh.
Referenced by get().
|
inline |
Returns the number of structurally nonzero entries in the submatrix defined by the half-open block ranges [rbegin,rend), [cbegin,cend).
This is the number of elements written by the corresponding call of toTriplet().
Definition at line 2238 of file assemblerCore.hh.
Referenced by get(), Kaskade::HigherOrderRecovery< Grid, Space >::getErrorFunction(), and Kaskade::Limex< Eq >::step().
|
inline |
Returns the number of scalar rows in the row block range [firstBlock,lastBlock[.
Definition at line 2249 of file assemblerCore.hh.
Referenced by get().
|
inlineprotected |
Definition at line 2366 of file assemblerCore.hh.
|
inline |
Returns a contiguous subrange of the rhs coefficient vectors.
Definition at line 2331 of file assemblerCore.hh.
Referenced by Kaskade::Limex< Eq >::step().
|
inline |
Whether to gather timing statistics using Kaskade::Timings.
Gathering timings can be switched on and off. Note that if several assembler calls are done in parallel, it must be switched off, since the timings functionality is not thread-safe. Defaults to off.
Definition at line 1589 of file assemblerCore.hh.
|
inline |
Defines how many memory the locally assembled matrices may occupy before they are scattered.
The amount of memory (in bytes) should scale with CPU cache, roughly a quarter of the second level cache size should be a reasonable value. Note that this is merely a hint, not a hard limit. The actual local matrix storage can be slightly larger.
Definition at line 1576 of file assemblerCore.hh.
|
inline |
Defines how many cells are assembled locally before scattering them together into the global data structures.
Higher numbers reduce the overhead of locking for mutually exclusive write access to global matrix/rhs and improve memory access locality, but increase the amount of thread-local computation and storage. The default value is 42, but the performance appears to be not very sensitive to this parameter in the range [20,60].
Definition at line 1547 of file assemblerCore.hh.
|
inline |
Defines how many more row blocks in each matrix are used compared to the number of threads.
When scattering the local matrices/rhs into the global data structures, blocks of sequential rows are processed in turn. Each block of rows is equipped with a lock in order to guarantee exclusive write access.
A high number of row blocks allows fine granularity and improves cache locality and simultaneous scattering into different parts of the global data structures, but incurs some inefficiency due to more frequent locking and more thread-local processing. The default value is to use two times the number of threads.
Definition at line 1563 of file assemblerCore.hh.
|
inline |
the size of a matrix block (in terms of scalar rows/columns)
Definition at line 2129 of file assemblerCore.hh.
|
inline |
|
inline |
Writes the subvector defined by the half-open block range [rbegin,rend) to the output iterator xi.
Definition at line 2217 of file assemblerCore.hh.
Referenced by Kaskade::HigherOrderRecovery< Grid, Space >::getErrorFunction(), and Kaskade::Limex< Eq >::step().
|
inline |
Returns a bitfield specifyign which of the parts have been assembled since construction or flush() according to the format (VALUE|RHS|MATRX).
Definition at line 2106 of file assemblerCore.hh.
|
protected |
Definition at line 2384 of file assemblerCore.hh.
|
static |
Definition at line 1533 of file assemblerCore.hh.
|
protected |
Definition at line 2391 of file assemblerCore.hh.
|
protected |
Definition at line 2377 of file assemblerCore.hh.
|
protected |
Definition at line 2378 of file assemblerCore.hh.
|
protected |
Definition at line 2379 of file assemblerCore.hh.
|
staticconstexprprotected |
Definition at line 1478 of file assemblerCore.hh.
|
protected |
Definition at line 2390 of file assemblerCore.hh.
|
static |
Definition at line 1532 of file assemblerCore.hh.
|
mutableprotected |
Definition at line 2381 of file assemblerCore.hh.
|
protected |
Definition at line 2388 of file assemblerCore.hh.
|
protected |
Definition at line 2374 of file assemblerCore.hh.
|
static |
Definition at line 1531 of file assemblerCore.hh.
|
mutableprotected |
Definition at line 2383 of file assemblerCore.hh.
|
mutableprotected |
Definition at line 2382 of file assemblerCore.hh.
|
protected |
Definition at line 2389 of file assemblerCore.hh.
|
protected |
Definition at line 2376 of file assemblerCore.hh.
|
protected |
Definition at line 2385 of file assemblerCore.hh.
|
static |
DEPRECATED, enums in the Assembler namespace.
Definition at line 1530 of file assemblerCore.hh.