v0.16.3
Loading...
Searching...
No Matches
Schur.hpp
Go to the documentation of this file.
1/**
2 * @file Schur.hpp
3 * @brief Assemble Schur complement
4 * @date 2023-02-02
5 *
6 * @copyright Copyright (c) 2023
7 *
8 * To create nested system of Schur complements, you push sequence of operator,
9 * to set up data on entities, and then assemble complements.
10 *
11 * \note Try separate floating points operations from book keeping. Also, align
12 * memory that blocks follow floating point operations.
13 *
14 */
15
16#ifndef __SCHUR_HPP__
17#define __SCHUR_HPP__
18
19namespace MoFEM {
20
21constexpr const char MoFEM_BLOCK_MAT[] = "mofem_block_mat";
22
23/**
24 * @brief Structure to register events for Schur block assembly and solver
25 */
27 static PetscLogEvent MOFEM_EVENT_schurMatSetValues;
28 static PetscLogEvent MOFEM_EVENT_opSchurAssembleEnd;
30 static PetscLogEvent MOFEM_EVENT_BlockStructureMult;
31 static PetscLogEvent MOFEM_EVENT_BlockStructureSolve;
32 static PetscLogEvent MOFEM_EVENT_AssembleSchurMat;
33 static PetscLogEvent MOFEM_EVENT_zeroRowsAndCols;
35};
36
37struct SchurElemMats;
40
48
50
51/**
52 * @brief Construct a new Op Schur Assemble End object
53 *
54 * @param fields_name list of fields (can be empty)
55 * @param field_ents list of entities on which schur complement is applied
56 * @param schur_aos maps dofs indices from main problem to schur complement
57 * @param schur_mat schur matrix
58 * @param sym_schur true if schur (matrix) complement is symmetric
59 * @param symm_op true if block diagonal is symmetric
60 */
62createOpSchurAssembleEnd(std::vector<std::string> fields_name,
63 std::vector<boost::shared_ptr<Range>> field_ents,
66 bool sym_schur = false, bool symm_op = false);
67
68/**
69 * @brief Create a Op Schur Zero Rows And Cols object
70 *
71 * @param marker_ptr
72 * @return OpSchurAssembleBase*
73 */
75 boost::shared_ptr<std::vector<unsigned char>> marker_ptr, double diag_val);
76
77using SchurFieldPair = std::pair<std::string, std::string>;
78
79using SchurFEOpsFEandFields = std::vector<
80
81 std::pair<std::string, std::vector<SchurFieldPair>>
82
83 >;
84
85/**
86 * @brief Create block matrix structure
87 *
88 * For each listed element and each listed pair of fields, one dense block is
89 * allocated per pair of (row entity, column entity). Blocks are stored
90 * row-major, values are shared by block matrix and by nested Schur matrices
91 * created with createSchurNestedMatrixStruture. Block values are allocated on
92 * first use.
93 *
94 * @param dm problem DM
95 * @param schur_fe_op_vec list of elements with pairs of (row, column) fields
96 * @return boost::shared_ptr<BlockStructure>
97 */
98boost::shared_ptr<BlockStructure> createBlockMatStructure(
99
100 DM dm, //< dm
101 SchurFEOpsFEandFields schur_fe_op_vec //< block elements
102
103);
104
105/**
106 * @brief Rebuild a block matrix structure after its problem changed
107 *
108 * Updates the structure created by createBlockMatStructure, in place, for the
109 * problem of dm as it is now (for example after DMMoFEMRebuildProblem or
110 * DMSetUp on a new refinement level), with the same elements and field pairs.
111 *
112 * - Elements are compared with those of the last build. If few changed (at
113 * most the fraction -schur_rebuild_patch_fraction, default 0.25, of the
114 * elements), only pairs of entities of removed and added elements are
115 * listed again, from the elements adjacent to those entities; the other
116 * blocks are kept and renumbered with one lookup per entity. Otherwise the
117 * blocks are listed again by the element loop of createBlockMatStructure.
118 * Either way the blocks are those a new createBlockMatStructure would list.
119 * - Blocks whose entities have no DOFs left are removed.
120 * - Shifts of blocks in storage are assigned again. Values are not kept: an
121 * allocated storage is zeroed and reallocated only if it has to grow; the
122 * matrix has to be assembled again.
123 * - A nested layout (createSchurNestedMatrixStruture) is dropped. Its element
124 * patterns, the element buffers (by element uid) and the data allocation
125 * are kept, so rebuildSchurNestedMatrixStruture reuses them; it has to be
126 * called before the nested matrices are used again.
127 * - Matrices made by createBlockMat have the sizes of the old problem: make
128 * new ones with createBlockMat from the rebuilt structure.
129 *
130 * @param dm problem DM
131 * @param schur_fe_op_vec elements and field pairs, as given at creation
132 * @param data block structure to rebuild
133 * @return MoFEMErrorCode
134 */
136 SchurFEOpsFEandFields schur_fe_op_vec,
137 boost::shared_ptr<BlockStructure> data);
138
140 std::pair<SmartPetscObj<Mat>, boost::shared_ptr<BlockStructure>>;
141
142/**
143 * @brief Create a Schur Mat object
144 *
145 * @param dm
146 * @param data
147 * @return std::pair<SmartPetscObj<Mat>, boost::shared_ptr<BlockStructure>>
148 */
149SchurShellMatData createBlockMat(DM dm, boost::shared_ptr<BlockStructure> data);
150
151using NestSchurData = std::tuple<
152
153 std::array<SmartPetscObj<Mat>, 4>,
154 std::array<boost::shared_ptr<BlockStructure>, 4>,
155 boost::shared_ptr<BlockStructure>,
156 std::pair<SmartPetscObj<IS>, SmartPetscObj<IS>>
157
158 >;
159
160/**
161 * @brief Create structure of nested matrix [A11 A10; A01 A00]
162 *
163 * Storage contract:
164 *
165 * - Blocks of A00 (both entities in block DM) of one finite element are
166 * stored in a buffer of that element. Eliminated fields have to be element
167 * local (L2, broken spaces, interior DOFs); an entity shared by two elements
168 * is an error. Elements with the same block pattern (entities, numbers of
169 * DOFs, listed pairs) share the layout of their buffers.
170 * - Buffers start with listed blocks only. At the first factorisation each
171 * pattern is analysed on a probe element: entities whose diagonal block is
172 * an admissible pivot are eliminated block by block (block LU in place, fill
173 * only where the pattern creates it), the remaining entities form a dense
174 * core factorised with partial pivoting. Buffers are then relaid in place.
175 * The analysis uses values only, it does not depend on the application.
176 * - Block factors of every element are accepted only if the backward error of
177 * a solve with them is small; otherwise the element is factorised dense in
178 * a separate buffer.
179 * - Factors are computed by assembleBlockMatSchur or by first MatSolve on the
180 * A00 matrix, and are reused by MatMult, MatSolve and assembleBlockMatSchur
181 * until MatZeroEntries is called. Assembly or MatZeroRowsColumns on
182 * factorised matrix is an error, i.e. each assembly has to start with
183 * MatZeroEntries.
184 * - If add_preconditioner_block is true, preconditioner buffers are allocated
185 * only for A00 elements, and factors of (A00 + preconditioner) are stored in
186 * place of preconditioner blocks, A00 blocks are kept intact.
187 * Preconditioner can be assembled only to A00 blocks.
188 * - MatSolve is implemented only for the A00 matrix (last matrix in the
189 * array). Processes without A00 elements perform empty solve.
190 * - Element matrices not assembled on this process (copies of elements owned
191 * by other processes) are zero and are skipped.
192 * - Layout of shared storage is fixed by this function, it can be called only
193 * once for given block structure.
194 *
195 * Options:
196 * - -schur_a00_dense: dense element matrices, no block elimination
197 * - -schur_a00_rcond_min (1e-12): smallest reciprocal condition number of
198 * diagonal block admissible as pivot
199 * - -schur_a00_pivot_threshold (0, off): block threshold pivoting, smallest
200 * singular value of pivot block relative to its couplings
201 * - -schur_a00_backward_error (1e-12): accepted backward error of solve with
202 * block factors (or 100 times the dense backward error on probe)
203 *
204 * See doc/development/schur.md.
205 *
206 * @param dms schur dm, and block dm
207 * @param block mat A data
208 * @param fields_name list of fields
209 * @param field_ents list of entities on which schur complement is applied
210 * @param add_preconditioner_block add block for preconditioner
211 * @return boost::shared_ptr<NestSchurData>
212 */
213boost::shared_ptr<NestSchurData> createSchurNestedMatrixStruture(
214 std::pair<SmartPetscObj<DM>, SmartPetscObj<DM>> dms,
215 boost::shared_ptr<BlockStructure> block_mat_data,
216
217 std::vector<std::string> fields_name, //< a00 fields
218 std::vector<boost::shared_ptr<Range>> field_ents, //< a00 ents
219 bool add_preconditioner_block = false
220
221);
222
223/**
224 * @brief Rebuild a nested Schur structure after rebuildBlockMatStructure
225 *
226 * Lays A00 element buffers out again on the rebuilt block structure, for the
227 * Schur and block DMs given (made again after the problem changed). The four
228 * nested block structures of nest_data are reused; element patterns met
229 * before the rebuild keep their layout and analysis, so they are not
230 * analysed again at the next factorisation; elements present before the
231 * rebuild get their buffers back, which are reallocated only if they have to
232 * grow. nest_data is updated in place:
233 * it holds new nested shell matrices and index sets. Make a new nested
234 * matrix with createSchurNestedMatrix(nest_data). The preconditioner
235 * setting is the one given at creation.
236 *
237 * @param dms Schur DM and block DM of the rebuilt problem
238 * @param nest_data data created by createSchurNestedMatrixStruture
239 * @return MoFEMErrorCode
240 */
243 boost::shared_ptr<NestSchurData> nest_data);
244
245/**
246 * @brief Digest of a block structure, for tests
247 *
248 * Hashes of the block index (entities, element, numbering, sizes; not the
249 * storage shifts), of the blocks of this matrix in its numbering, and of the
250 * A00 elements (pattern keys and entity numbering). Equal digests of a
251 * rebuilt and a newly created structure mean the same blocks.
252 */
254 std::size_t nbBlocks = 0;
255 std::size_t nbElems = 0;
256 std::size_t nbPatterns = 0;
257 std::size_t indexHash = 0;
258 std::size_t blocksHash = 0;
259 std::size_t elemsHash = 0;
260};
261
263schurBlockStructureDigest(boost::shared_ptr<BlockStructure> data);
264
265/**
266 * @brief Assemble Schur complement S = A11 - A10 A00^{-1} A01 from block
267 * matrix
268 *
269 * A00 is eliminated element by element. If fields_name and field_ents
270 * coincide with A00 of nested matrix (see createSchurNestedMatrixStruture),
271 * A00 element matrices are factorised in place and factors are reused by
272 * MatSolve. Otherwise element matrices are factorised in scratch memory, and
273 * it is an error if A00 is already factorised in place.
274 *
275 * @param m_field
276 * @param B block matrix
277 * @param S Schur complement matrix (PETSc matrix)
278 * @param fields_name eliminated fields
279 * @param field_ents entities of eliminated fields (can be null)
280 * @param ao mapping from block matrix indices to S indices
281 * @return MoFEMErrorCode
282 */
284assembleBlockMatSchur(MoFEM::Interface &m_field, Mat B, Mat S,
285 std::vector<std::string> fields_name,
286 std::vector<boost::shared_ptr<Range>> field_ents,
288
289/**
290 * @brief Get block values storage
291 *
292 * @note After createSchurNestedMatrixStruture it holds blocks outside A00
293 * only, A00 blocks are stored in element buffers. Direct access bypasses
294 * factorisation guard.
295 *
296 * @return boost::shared_ptr<std::vector<double>>
297 */
298boost::shared_ptr<std::vector<double>> getBlockMatStorageMat(Mat B);
299
300/**
301 * @brief Get preconditioner blocks storage
302 *
303 * @deprecated Preconditioner blocks are stored in buffers of A00 elements,
304 * this function returns an empty vector.
305 *
306 * @return boost::shared_ptr<std::vector<double>>
307 */
308boost::shared_ptr<std::vector<double>>
310
311/**
312 * @brief Switch preconditioner
313 *
314 * @param block_mat_data
315 * @return MoFEMErrorCode
316 */
318schurSwitchPreconditioner(boost::shared_ptr<BlockStructure> block_mat_data);
319
320/**
321 * @brief Save block matrix as a mesh
322 *
323 * @param block_mat_data
324 * @param filename
325 * @return MoFEMErrorCode
326 */
328schurSaveBlockMesh(boost::shared_ptr<BlockStructure> block_mat_data,
329 std::string filename);
330
331/**
332 * @brief Create a Mat Diag Blocks object
333 *
334 * \code {.cpp}
335 *
336 * auto [nested_mat, nested_data_ptr] = createSchurNestedMatrix(
337 *
338 * createSchurNestedMatrixStruture(
339 *
340 * {schur_dm, block_dm}, shell_data,
341 *
342 * {"TENSOR"}, {nullptr}
343 *
344 * )
345 *
346 * );
347 *
348 * \endcode
349 *
350 * @return Mat
351 */
352std::pair<SmartPetscObj<Mat>, boost::shared_ptr<NestSchurData>>
353createSchurNestedMatrix(boost::shared_ptr<NestSchurData> schur_net_data_ptr);
354
355template <>
356MoFEMErrorCode DMMoFEMSetNestSchurData(DM dm, boost::shared_ptr<NestSchurData>);
357
358/**
359 * @brief Set PC for A00 block
360 *
361 * @param pc
362 * @return MoFEMErrorCode
363 */
365
368 using MatSetValuesPtr = boost::function<MoFEMErrorCode(
369 Mat M, const EntitiesFieldData::EntData &row_data,
370 const EntitiesFieldData::EntData &col_data, const MatrixDouble &mat,
371 InsertMode iora)>;
372 static MatSetValuesPtr matSetValuesPtr; ///< backend assembly function
373 static MatSetValuesPtr
374 matSetValuesBlockPtr; ///< backend assembly block mat function
375 static MatSetValuesPtr
376 matSetValuesPreconditionedBlockPtr; ///< backend assembly block
377 ///< preconditioner mat function
378};
379
380template <>
383 const EntitiesFieldData::EntData &col_data,
384 const MatrixDouble &mat, InsertMode iora);
385
386template <>
389 const VectorDouble &nf, InsertMode iora) {
390 return VecSetValues<EssentialBcStorage>(V, data, nf, iora);
391}
392
393template <>
394MoFEMErrorCode MatSetValues<AssemblyTypeSelector<SCHUR>>(
395 Mat M, const EntitiesFieldData::EntData &row_data,
396 const EntitiesFieldData::EntData &col_data, const MatrixDouble &mat,
397 InsertMode iora);
398
399template <>
400inline MoFEMErrorCode VecSetValues<AssemblyTypeSelector<SCHUR>>(
401 Vec V, const EntitiesFieldData::EntData &data, const VectorDouble &nf,
402 InsertMode iora) {
403 return VecSetValues<SchurElemMats>(V, data, nf, iora);
404}
405
406/***
407 * @brief Specialization of MatSetValues for BlockStructure
408 */
409template <>
411MatSetValues<BlockStructure>(Mat M, const EntitiesFieldData::EntData &row_data,
412 const EntitiesFieldData::EntData &col_data,
413 const MatrixDouble &mat, InsertMode iora);
414
415/***
416 * @brief Specialisation of MatSetValues for AssemblyTypeSelector<BLOCK_MAT>
417 */
418template <>
419inline MoFEMErrorCode MatSetValues<AssemblyTypeSelector<BLOCK_MAT>>(
420 Mat M, const EntitiesFieldData::EntData &row_data,
421 const EntitiesFieldData::EntData &col_data, const MatrixDouble &mat,
422 InsertMode iora) {
423 return MatSetValues<BlockStructure>(M, row_data, col_data, mat, iora);
424}
425
426/***
427 * @brief Specialisation of VecSetValues for AssemblyTypeSelector<BLOCK_MAT>
428 */
429template <>
430inline MoFEMErrorCode VecSetValues<AssemblyTypeSelector<BLOCK_MAT>>(
431 Vec V, const EntitiesFieldData::EntData &data, const VectorDouble &nf,
432 InsertMode iora) {
433 return VecSetValues<EssentialBcStorage>(V, data, nf, iora);
434}
435
436/***
437 * @brief Specialization of MatSetValues for SchurElemMatsBlock
438 */
439template <>
442 const EntitiesFieldData::EntData &row_data,
443 const EntitiesFieldData::EntData &col_data,
444 const MatrixDouble &mat, InsertMode iora);
445
446/***
447 * @brief Specialization of VecSetValues for SchurElemMatsBlock
448 */
449template <>
452 const VectorDouble &nf, InsertMode iora) {
453 return VecSetValues<EssentialBcStorage>(V, data, nf, iora);
454}
455
456/***
457 * @brief Specialisation of MatSetValues for AssemblyTypeSelector<BLOCK_SCHUR>
458 */
459template <>
460inline MoFEMErrorCode MatSetValues<AssemblyTypeSelector<BLOCK_SCHUR>>(
461 Mat M, const EntitiesFieldData::EntData &row_data,
462 const EntitiesFieldData::EntData &col_data, const MatrixDouble &mat,
463 InsertMode iora) {
464 return MatSetValues<SchurElemMatsBlock>(M, row_data, col_data, mat, iora);
465}
466
467/***
468 * @brief Specialisation of VecSetValues for AssemblyTypeSelector<BLOCK_SCHUR>
469 */
470template <>
471inline MoFEMErrorCode VecSetValues<AssemblyTypeSelector<BLOCK_SCHUR>>(
472 Vec V, const EntitiesFieldData::EntData &data, const VectorDouble &nf,
473 InsertMode iora) {
474 return VecSetValues<EssentialBcStorage>(V, data, nf, iora);
475}
476
477/***
478 * @brief Specialization of MatSetValues for SchurElemMatsPreconditionedBlock
479 */
480template <>
482 Mat M, const EntitiesFieldData::EntData &row_data,
483 const EntitiesFieldData::EntData &col_data, const MatrixDouble &mat,
484 InsertMode iora);
485
486/***
487 * @brief Specialisation of MatSetValues for
488 * AssemblyTypeSelector<BLOCK_PRECONDITIONER_SCHUR>
489 */
490template <>
492MatSetValues<AssemblyTypeSelector<BLOCK_PRECONDITIONER_SCHUR>>(
493 Mat M, const EntitiesFieldData::EntData &row_data,
494 const EntitiesFieldData::EntData &col_data, const MatrixDouble &mat,
495 InsertMode iora) {
496 return MatSetValues<SchurElemMatsPreconditionedBlock>(M, row_data, col_data,
497 mat, iora);
498}
499
500/***
501 * @brief Specialisation of VecSetValues for AssemblyTypeSelector<BLOCK_SCHUR>
502 */
503template <>
505VecSetValues<AssemblyTypeSelector<BLOCK_PRECONDITIONER_SCHUR>>(
506 Vec V, const EntitiesFieldData::EntData &data, const VectorDouble &nf,
507 InsertMode iora) {
508 return ::VecSetValues(V, data.getIndices().size(),
509 &*data.getIndices().begin(), &*nf.begin(), iora);
510}
511
512/**
513 * @deprecated do not use
514 */
515DEPRECATED OpSchurAssembleBase *createOpSchurAssembleEnd(
516 std::vector<std::string> fields_name,
517 std::vector<boost::shared_ptr<Range>> field_ents,
518 std::vector<SmartPetscObj<AO>> sequence_of_aos,
519 std::vector<SmartPetscObj<Mat>> sequence_of_mats,
520 std::vector<bool> sym_schur, bool symm_op,
521 boost::shared_ptr<BlockStructure> diag_blocks = nullptr);
522
523/**
524 * @deprecated do not use
525 */
526DEPRECATED OpSchurAssembleBase *createOpSchurAssembleEnd(
527 std::vector<std::string> fields_name,
528 std::vector<boost::shared_ptr<Range>> field_ents,
529 std::vector<SmartPetscObj<AO>> sequence_of_aos,
530 std::vector<SmartPetscObj<Mat>> sequence_of_mats,
531 std::vector<bool> sym_schur, std::vector<double> diag_eps, bool symm_op,
532 boost::shared_ptr<BlockStructure> diag_blocks = nullptr);
533
534/** @deprecated do not use, use createSchurNestedMatrixStruture instead */
535DEPRECATED inline boost::shared_ptr<NestSchurData>
537 boost::shared_ptr<BlockStructure> block_mat_data,
538
539 std::vector<std::string> fields_name, //< a00 fields
540 std::vector<boost::shared_ptr<Range>> field_ents, //< a00 ents
541 bool add_preconditioner_block = false
542
543) {
544 return createSchurNestedMatrixStruture(dms, block_mat_data, fields_name,
545 field_ents, add_preconditioner_block);
546}
547
548} // namespace MoFEM
549
550#endif //__SCHUR_HPP__
#define DEPRECATED
Definition definitions.h:17
MoFEMErrorCode VecSetValues< EssentialBcStorage >(Vec V, const EntitiesFieldData::EntData &data, const double *ptr, InsertMode iora)
Set values to vector in operator.
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
UBlasMatrix< double > MatrixDouble
Definition Types.hpp:77
UBlasVector< double > VectorDouble
Definition Types.hpp:68
implementation of Data Operators for Forces and Sources
Definition Common.hpp:10
SchurBlockStructureDigest schurBlockStructureDigest(boost::shared_ptr< BlockStructure > data_ptr)
Definition Schur.cpp:4821
MoFEMErrorCode MatSetValues< SchurElemMats >(Mat M, const EntitiesFieldData::EntData &row_data, const EntitiesFieldData::EntData &col_data, const MatrixDouble &mat, InsertMode iora)
Definition Schur.cpp:4965
OpSchurAssembleBase * createOpSchurAssembleEnd(std::vector< std::string > fields_name, std::vector< boost::shared_ptr< Range > > field_ents, SmartPetscObj< AO > ao, SmartPetscObj< Mat > schur, bool sym_schur, bool symm_op)
Construct a new Op Schur Assemble End object.
Definition Schur.cpp:4892
MoFEMErrorCode MatSetValues< SchurElemMatsBlock >(Mat M, const EntitiesFieldData::EntData &row_data, const EntitiesFieldData::EntData &col_data, const MatrixDouble &mat, InsertMode iora)
Definition Schur.cpp:5041
MoFEMErrorCode schurSwitchPreconditioner(boost::shared_ptr< BlockStructure > block_mat_data)
Switch preconditioner.
Definition Schur.cpp:5081
MoFEMErrorCode setSchurA00MatSolvePC(SmartPetscObj< PC > pc)
Set PC for A00 block.
Definition Schur.cpp:4934
MoFEMErrorCode MatSetValues< SchurElemMatsPreconditionedBlock >(Mat M, const EntitiesFieldData::EntData &row_data, const EntitiesFieldData::EntData &col_data, const MatrixDouble &mat, InsertMode iora)
Definition Schur.cpp:5072
std::pair< SmartPetscObj< Mat >, boost::shared_ptr< BlockStructure > > SchurShellMatData
Definition Schur.hpp:140
std::pair< SmartPetscObj< Mat >, boost::shared_ptr< NestSchurData > > createSchurNestedMatrix(boost::shared_ptr< NestSchurData > schur_net_data_ptr)
Create a Mat Diag Blocks object.
Definition Schur.cpp:4859
MoFEMErrorCode MatSetValues< BlockStructure >(Mat M, const EntitiesFieldData::EntData &row_data, const EntitiesFieldData::EntData &col_data, const MatrixDouble &mat, InsertMode iora)
Definition Schur.cpp:5009
std::tuple< std::array< SmartPetscObj< Mat >, 4 >, std::array< boost::shared_ptr< BlockStructure >, 4 >, boost::shared_ptr< BlockStructure >, std::pair< SmartPetscObj< IS >, SmartPetscObj< IS > > > NestSchurData
Definition Schur.hpp:158
std::pair< std::string, std::string > SchurFieldPair
Definition Schur.hpp:77
boost::shared_ptr< std::vector< double > > getBlockMatPrconditionerStorageMat(Mat B)
Get preconditioner blocks storage.
Definition Schur.cpp:4004
DEPRECATED boost::shared_ptr< NestSchurData > getNestSchurData(std::pair< SmartPetscObj< DM >, SmartPetscObj< DM > > dms, boost::shared_ptr< BlockStructure > block_mat_data, std::vector< std::string > fields_name, std::vector< boost::shared_ptr< Range > > field_ents, bool add_preconditioner_block=false)
Definition Schur.hpp:536
boost::shared_ptr< BlockStructure > createBlockMatStructure(DM dm, SchurFEOpsFEandFields schur_fe_op_vec)
Create block matrix structure.
Definition Schur.cpp:2819
boost::shared_ptr< NestSchurData > createSchurNestedMatrixStruture(std::pair< SmartPetscObj< DM >, SmartPetscObj< DM > > dms, boost::shared_ptr< BlockStructure > block_mat_data_ptr, std::vector< std::string > fields_names, std::vector< boost::shared_ptr< Range > > field_ents, bool add_preconditioner_block)
Create structure of nested matrix [A11 A10; A01 A00].
Definition Schur.cpp:4760
OpSchurAssembleBase * createOpSchurZeroRowsAndCols(boost::shared_ptr< std::vector< unsigned char > > marker_ptr, double diag_val)
Create a Op Schur Zero Rows And Cols object.
Definition Schur.cpp:4904
MoFEMErrorCode schurSaveBlockMesh(boost::shared_ptr< BlockStructure > block_mat_data, std::string filename)
Save block matrix as a mesh.
Definition Schur.cpp:5096
constexpr const char MoFEM_BLOCK_MAT[]
Definition Schur.hpp:21
MoFEMErrorCode rebuildSchurNestedMatrixStruture(std::pair< SmartPetscObj< DM >, SmartPetscObj< DM > > dms, boost::shared_ptr< NestSchurData > nest_data_ptr)
Rebuild a nested Schur structure after rebuildBlockMatStructure.
Definition Schur.cpp:4799
MoFEMErrorCode VecSetValues< SchurElemMatsBlock >(Vec V, const EntitiesFieldData::EntData &data, const VectorDouble &nf, InsertMode iora)
Definition Schur.hpp:451
MoFEMErrorCode rebuildBlockMatStructure(DM dm, SchurFEOpsFEandFields schur_fe_op_vec, boost::shared_ptr< BlockStructure > data_ptr)
Rebuild a block matrix structure after its problem changed.
Definition Schur.cpp:2833
MoFEMErrorCode DMMoFEMSetNestSchurData(DM dm, boost::shared_ptr< NestSchurData >)
Definition DMMoFEM.cpp:1641
std::vector< std::pair< std::string, std::vector< SchurFieldPair > > > SchurFEOpsFEandFields
Definition Schur.hpp:83
MoFEMErrorCode VecSetValues< SchurElemMats >(Vec V, const EntitiesFieldData::EntData &data, const VectorDouble &nf, InsertMode iora)
Definition Schur.hpp:388
SchurShellMatData createBlockMat(DM dm, boost::shared_ptr< BlockStructure > data)
Create a Schur Mat object.
Definition Schur.cpp:3615
MoFEMErrorCode assembleBlockMatSchur(MoFEM::Interface &m_field, Mat B, Mat S, std::vector< std::string > fields_name, std::vector< boost::shared_ptr< Range > > field_ents, SmartPetscObj< AO > ao)
Assemble Schur complement S = A11 - A10 A00^{-1} A01 from block matrix.
Definition Schur.cpp:3650
OpSchurAssembleBase * createOpSchurAssembleBegin()
Definition Schur.cpp:4887
boost::shared_ptr< std::vector< double > > getBlockMatStorageMat(Mat B)
Get block values storage.
Definition Schur.cpp:3995
Deprecated interface functions.
Data on single entity (This is passed as argument to DataOperator::doWork)
UserDataOperator(const FieldSpace space, const char type=OPSPACE, const bool symm=true)
Constructor for operators working on finite element spaces.
static MatSetValuesPtr matSetValuesPreconditionedBlockPtr
Definition Schur.hpp:376
static MatSetValuesPtr matSetValuesPtr
backend assembly function
Definition Schur.hpp:372
static MatSetValuesPtr matSetValuesBlockPtr
backend assembly block mat function
Definition Schur.hpp:374
boost::function< MoFEMErrorCode(Mat M, const EntitiesFieldData::EntData &row_data, const EntitiesFieldData::EntData &col_data, const MatrixDouble &mat, InsertMode iora)> MatSetValuesPtr
Definition Schur.hpp:371
Digest of a block structure, for tests.
Definition Schur.hpp:253
Schur complement data storage.
Definition Schur.cpp:161
Structure to register events for Schur block assembly and solver.
Definition Schur.hpp:26
static PetscLogEvent MOFEM_EVENT_BlockStructureSetValues
Definition Schur.hpp:29
static PetscLogEvent MOFEM_EVENT_BlockStructureMult
Definition Schur.hpp:30
static PetscLogEvent MOFEM_EVENT_zeroRowsAndCols
Definition Schur.hpp:33
static PetscLogEvent MOFEM_EVENT_opSchurAssembleEnd
Definition Schur.hpp:28
static PetscLogEvent MOFEM_EVENT_BlockStructureSolve
Definition Schur.hpp:31
static PetscLogEvent MOFEM_EVENT_schurMatSetValues
Definition Schur.hpp:27
static PetscLogEvent MOFEM_EVENT_AssembleSchurMat
Definition Schur.hpp:32
intrusive_ptr for managing petsc objects