16#ifndef dealii_mesh_worker_assembler_h
17#define dealii_mesh_worker_assembler_h
109 template <
typename VectorType>
133 template <
class DOFINFO>
141 template <
class DOFINFO>
148 template <
class DOFINFO>
150 assemble(
const DOFINFO &info1,
const DOFINFO &info2);
159 const std::vector<types::global_dof_index> &dof);
208 template <
typename MatrixType,
typename number =
double>
240 template <
class DOFINFO>
248 template <
class DOFINFO>
255 template <
class DOFINFO>
257 assemble(
const DOFINFO &info1,
const DOFINFO &info2);
266 const unsigned int block_row,
267 const unsigned int block_col,
268 const std::vector<types::global_dof_index> &dof1,
269 const std::vector<types::global_dof_index> &dof2);
323 template <
typename MatrixType,
typename number =
double>
374 template <
class DOFINFO>
382 template <
class DOFINFO>
389 template <
class DOFINFO>
391 assemble(
const DOFINFO &info1,
const DOFINFO &info2);
400 const unsigned int block_row,
401 const unsigned int block_col,
402 const std::vector<types::global_dof_index> &dof1,
403 const std::vector<types::global_dof_index> &dof2,
404 const unsigned int level1,
405 const unsigned int level2,
414 const unsigned int block_row,
415 const unsigned int block_col,
416 const std::vector<types::global_dof_index> &dof1,
417 const std::vector<types::global_dof_index> &dof2,
418 const unsigned int level1,
419 const unsigned int level2);
427 const unsigned int block_row,
428 const unsigned int block_col,
429 const std::vector<types::global_dof_index> &dof1,
430 const std::vector<types::global_dof_index> &dof2,
431 const unsigned int level1,
432 const unsigned int level2);
440 const unsigned int block_row,
441 const unsigned int block_col,
442 const std::vector<types::global_dof_index> &dof1,
443 const std::vector<types::global_dof_index> &dof2,
444 const unsigned int level1,
445 const unsigned int level2);
453 const unsigned int block_row,
454 const unsigned int block_col,
455 const std::vector<types::global_dof_index> &dof1,
456 const std::vector<types::global_dof_index> &dof2,
457 const unsigned int level1,
458 const unsigned int level2);
466 const unsigned int block_row,
467 const unsigned int block_col,
468 const std::vector<types::global_dof_index> &dof1,
469 const std::vector<types::global_dof_index> &dof2,
470 const unsigned int level1,
471 const unsigned int level2);
527 template <
typename VectorType>
537 template <
typename VectorType>
546 template <
typename VectorType>
547 template <
class DOFINFO>
553 info.initialize_vectors(
residuals.size());
556 template <
typename VectorType>
561 const std::vector<types::global_dof_index> &dof)
565 for (
unsigned int b = 0; b < local.
n_blocks(); ++b)
566 for (
unsigned int j = 0; j < local.
block(b).size(); ++j)
576 const unsigned int jcell =
577 this->
block_info->local().local_to_global(b, j);
578 global(dof[jcell]) += local.
block(b)(j);
582 constraints->distribute_local_to_global(local, dof, global);
586 template <
typename VectorType>
587 template <
class DOFINFO>
591 for (
unsigned int i = 0; i <
residuals.size(); ++i)
598 template <
typename VectorType>
599 template <
class DOFINFO>
602 const DOFINFO &info1,
603 const DOFINFO &info2)
605 for (
unsigned int i = 0; i <
residuals.size(); ++i)
619 template <
typename MatrixType,
typename number>
626 template <
typename MatrixType,
typename number>
638 template <
typename MatrixType,
typename number>
648 template <
typename MatrixType,
typename number>
649 template <
class DOFINFO>
655 info.initialize_matrices(*
matrices, face);
660 template <
typename MatrixType,
typename number>
665 const unsigned int block_row,
666 const unsigned int block_col,
667 const std::vector<types::global_dof_index> &dof1,
668 const std::vector<types::global_dof_index> &dof2)
672 for (
unsigned int j = 0; j < local.n_rows(); ++j)
673 for (
unsigned int k = 0; k < local.n_cols(); ++k)
684 const unsigned int jcell =
685 this->
block_info->local().local_to_global(block_row, j);
686 const unsigned int kcell =
687 this->
block_info->local().local_to_global(block_col, k);
689 global.
add(dof1[jcell], dof2[kcell], local(j, k));
695 std::vector<types::global_dof_index> sliced_row_indices(
697 for (
unsigned int i = 0; i < sliced_row_indices.size(); ++i)
698 sliced_row_indices[i] = dof1[bi.
block_start(block_row) + i];
700 std::vector<types::global_dof_index> sliced_col_indices(
702 for (
unsigned int i = 0; i < sliced_col_indices.size(); ++i)
703 sliced_col_indices[i] = dof2[bi.
block_start(block_col) + i];
713 template <
typename MatrixType,
typename number>
714 template <
class DOFINFO>
719 for (
unsigned int i = 0; i <
matrices->size(); ++i)
727 info.matrix(i,
false).matrix,
736 template <
typename MatrixType,
typename number>
737 template <
class DOFINFO>
740 const DOFINFO &info1,
741 const DOFINFO &info2)
743 for (
unsigned int i = 0; i <
matrices->size(); ++i)
751 info1.matrix(i,
false).matrix,
757 info1.matrix(i,
true).matrix,
763 info2.matrix(i,
false).matrix,
769 info2.matrix(i,
true).matrix,
780 template <
typename MatrixType,
typename number>
787 template <
typename MatrixType,
typename number>
799 template <
typename MatrixType,
typename number>
808 template <
typename MatrixType,
typename number>
809 template <
class DOFINFO>
815 info.initialize_matrices(*
matrices, face);
820 template <
typename MatrixType,
typename number>
831 template <
typename MatrixType,
typename number>
841 template <
typename MatrixType,
typename number>
846 const unsigned int block_row,
847 const unsigned int block_col,
848 const std::vector<types::global_dof_index> &dof1,
849 const std::vector<types::global_dof_index> &dof2,
850 const unsigned int level1,
851 const unsigned int level2,
854 for (
unsigned int j = 0; j < local.n_rows(); ++j)
855 for (
unsigned int k = 0; k < local.n_cols(); ++k)
866 const unsigned int jcell =
867 this->
block_info->local().local_to_global(block_row, j);
868 const unsigned int kcell =
869 this->
block_info->local().local_to_global(block_col, k);
879 const unsigned int jglobal = this->
block_info->level(level1)
880 .global_to_local(dof1[jcell])
882 const unsigned int kglobal = this->
block_info->level(level2)
883 .global_to_local(dof2[kcell])
889 global.add(kglobal, jglobal, local(j, k));
891 global.add(jglobal, kglobal, local(j, k));
912 global.add(kglobal, jglobal, local(j, k));
914 global.add(jglobal, kglobal, local(j, k));
920 global.add(kglobal, jglobal, local(j, k));
922 global.add(jglobal, kglobal, local(j, k));
930 template <
typename MatrixType,
typename number>
935 const unsigned int block_row,
936 const unsigned int block_col,
937 const std::vector<types::global_dof_index> &dof1,
938 const std::vector<types::global_dof_index> &dof2,
939 const unsigned int level1,
940 const unsigned int level2)
942 for (
unsigned int j = 0; j < local.n_rows(); ++j)
943 for (
unsigned int k = 0; k < local.n_cols(); ++k)
954 const unsigned int jcell =
955 this->
block_info->local().local_to_global(block_row, j);
956 const unsigned int kcell =
957 this->
block_info->local().local_to_global(block_col, k);
967 const unsigned int jglobal = this->
block_info->level(level1)
968 .global_to_local(dof1[jcell])
970 const unsigned int kglobal = this->
block_info->level(level2)
971 .global_to_local(dof2[kcell])
975 global.add(jglobal, kglobal, local(j, k));
987 global.add(jglobal, kglobal, local(j, k));
993 template <
typename MatrixType,
typename number>
998 const unsigned int block_row,
999 const unsigned int block_col,
1000 const std::vector<types::global_dof_index> &dof1,
1001 const std::vector<types::global_dof_index> &dof2,
1002 const unsigned int level1,
1003 const unsigned int level2)
1005 for (
unsigned int j = 0; j < local.n_rows(); ++j)
1006 for (
unsigned int k = 0; k < local.n_cols(); ++k)
1007 if (std::fabs(local(j, k)) >=
threshold)
1017 const unsigned int jcell =
1018 this->
block_info->local().local_to_global(block_row, j);
1019 const unsigned int kcell =
1020 this->
block_info->local().local_to_global(block_col, k);
1030 const unsigned int jglobal = this->
block_info->level(level1)
1031 .global_to_local(dof1[jcell])
1033 const unsigned int kglobal = this->
block_info->level(level2)
1034 .global_to_local(dof2[kcell])
1038 global.add(jglobal, kglobal, local(j, k));
1050 global.add(jglobal, kglobal, local(j, k));
1056 template <
typename MatrixType,
typename number>
1061 const unsigned int block_row,
1062 const unsigned int block_col,
1063 const std::vector<types::global_dof_index> &dof1,
1064 const std::vector<types::global_dof_index> &dof2,
1065 const unsigned int level1,
1066 const unsigned int level2)
1068 for (
unsigned int j = 0; j < local.n_rows(); ++j)
1069 for (
unsigned int k = 0; k < local.n_cols(); ++k)
1070 if (std::fabs(local(k, j)) >=
threshold)
1080 const unsigned int jcell =
1081 this->
block_info->local().local_to_global(block_row, j);
1082 const unsigned int kcell =
1083 this->
block_info->local().local_to_global(block_col, k);
1093 const unsigned int jglobal = this->
block_info->level(level1)
1094 .global_to_local(dof1[jcell])
1096 const unsigned int kglobal = this->
block_info->level(level2)
1097 .global_to_local(dof2[kcell])
1101 global.add(jglobal, kglobal, local(k, j));
1113 global.add(jglobal, kglobal, local(k, j));
1119 template <
typename MatrixType,
typename number>
1124 const unsigned int block_row,
1125 const unsigned int block_col,
1126 const std::vector<types::global_dof_index> &dof1,
1127 const std::vector<types::global_dof_index> &dof2,
1128 const unsigned int level1,
1129 const unsigned int level2)
1134 for (
unsigned int j = 0; j < local.n_rows(); ++j)
1135 for (
unsigned int k = 0; k < local.n_cols(); ++k)
1136 if (std::fabs(local(j, k)) >=
threshold)
1146 const unsigned int jcell =
1147 this->
block_info->local().local_to_global(block_row, j);
1148 const unsigned int kcell =
1149 this->
block_info->local().local_to_global(block_col, k);
1159 const unsigned int jglobal = this->
block_info->level(level1)
1160 .global_to_local(dof1[jcell])
1162 const unsigned int kglobal = this->
block_info->level(level2)
1163 .global_to_local(dof2[kcell])
1167 global.add(jglobal, kglobal, local(j, k));
1179 level2, kglobal)) ||
1184 jglobal == kglobal))
1185 global.add(jglobal, kglobal, local(j, k));
1188 global.add(jglobal, kglobal, local(j, k));
1194 template <
typename MatrixType,
typename number>
1199 const unsigned int block_row,
1200 const unsigned int block_col,
1201 const std::vector<types::global_dof_index> &dof1,
1202 const std::vector<types::global_dof_index> &dof2,
1203 const unsigned int level1,
1204 const unsigned int level2)
1209 for (
unsigned int j = 0; j < local.n_rows(); ++j)
1210 for (
unsigned int k = 0; k < local.n_cols(); ++k)
1211 if (std::fabs(local(k, j)) >=
threshold)
1221 const unsigned int jcell =
1222 this->
block_info->local().local_to_global(block_row, j);
1223 const unsigned int kcell =
1224 this->
block_info->local().local_to_global(block_col, k);
1234 const unsigned int jglobal = this->
block_info->level(level1)
1235 .global_to_local(dof1[jcell])
1237 const unsigned int kglobal = this->
block_info->level(level2)
1238 .global_to_local(dof2[kcell])
1242 global.add(jglobal, kglobal, local(k, j));
1254 level2, kglobal)) ||
1259 jglobal == kglobal))
1260 global.add(jglobal, kglobal, local(k, j));
1263 global.add(jglobal, kglobal, local(k, j));
1270 template <
typename MatrixType,
typename number>
1271 template <
class DOFINFO>
1274 const DOFINFO &info)
1276 const unsigned int level = info.cell->level();
1278 for (
unsigned int i = 0; i <
matrices->size(); ++i)
1282 const unsigned int row =
matrices->block(i)[level].row;
1283 const unsigned int col =
matrices->block(i)[level].column;
1286 info.matrix(i,
false).matrix,
1297 info.matrix(i,
false).matrix,
1306 info.matrix(i,
false).matrix,
1315 info.matrix(i,
false).matrix,
1323 info.matrix(i,
false).matrix,
1335 template <
typename MatrixType,
typename number>
1336 template <
class DOFINFO>
1339 const DOFINFO &info1,
1340 const DOFINFO &info2)
1342 const unsigned int level1 = info1.cell->level();
1343 const unsigned int level2 = info2.cell->level();
1345 for (
unsigned int i = 0; i <
matrices->size(); ++i)
1351 const unsigned int row = o[level1].row;
1352 const unsigned int col = o[level1].column;
1354 if (level1 == level2)
1359 info1.matrix(i,
false).matrix,
1367 info1.matrix(i,
true).matrix,
1375 info2.matrix(i,
false).matrix,
1383 info2.matrix(i,
true).matrix,
1394 info1.matrix(i,
false).matrix,
1402 info1.matrix(i,
true).matrix,
1410 info2.matrix(i,
false).matrix,
1418 info2.matrix(i,
true).matrix,
1436 info1.matrix(i,
false).matrix,
1444 info1.matrix(i,
true).matrix,
1452 info2.matrix(i,
true).matrix,
size_type block_size(const unsigned int i) const
size_type block_start(const unsigned int i) const
A small class collecting the different BlockIndices involved in global, multilevel and local computat...
unsigned int n_blocks() const
BlockType & block(const unsigned int i)
void add(const size_type i, const size_type j, const typename MatrixType::value_type value)
void assemble_down(MatrixType &global, const FullMatrix< number > &local, const unsigned int block_row, const unsigned int block_col, const std::vector< types::global_dof_index > &dof1, const std::vector< types::global_dof_index > &dof2, const unsigned int level1, const unsigned int level2)
void initialize_info(DOFINFO &info, bool face) const
MatrixPtrVectorPtr matrices
void assemble_in(MatrixType &global, const FullMatrix< number > &local, const unsigned int block_row, const unsigned int block_col, const std::vector< types::global_dof_index > &dof1, const std::vector< types::global_dof_index > &dof2, const unsigned int level1, const unsigned int level2)
MGMatrixBlockVector< MatrixType > MatrixPtrVector
SmartPointer< MatrixPtrVector, MGMatrixLocalBlocksToGlobalBlocks< MatrixType, number > > MatrixPtrVectorPtr
SmartPointer< const MGConstrainedDoFs, MGMatrixLocalBlocksToGlobalBlocks< MatrixType, number > > mg_constrained_dofs
void assemble(const DOFINFO &info)
MatrixPtrVectorPtr interface_out
void initialize(const BlockInfo *block_info, MatrixPtrVector &matrices)
void assemble_up(MatrixType &global, const FullMatrix< number > &local, const unsigned int block_row, const unsigned int block_col, const std::vector< types::global_dof_index > &dof1, const std::vector< types::global_dof_index > &dof2, const unsigned int level1, const unsigned int level2)
void assemble_out(MatrixType &global, const FullMatrix< number > &local, const unsigned int block_row, const unsigned int block_col, const std::vector< types::global_dof_index > &dof1, const std::vector< types::global_dof_index > &dof2, const unsigned int level1, const unsigned int level2)
MatrixPtrVectorPtr interface_in
void initialize_interfaces(MatrixPtrVector &interface_in, MatrixPtrVector &interface_out)
void assemble_fluxes(MatrixType &global, const FullMatrix< number > &local, const unsigned int block_row, const unsigned int block_col, const std::vector< types::global_dof_index > &dof1, const std::vector< types::global_dof_index > &dof2, const unsigned int level1, const unsigned int level2)
MatrixPtrVectorPtr flux_down
SmartPointer< const BlockInfo, MGMatrixLocalBlocksToGlobalBlocks< MatrixType, number > > block_info
void initialize_edge_flux(MatrixPtrVector &up, MatrixPtrVector &down)
MatrixPtrVectorPtr flux_up
MGMatrixLocalBlocksToGlobalBlocks(double threshold=1.e-12)
SmartPointer< MatrixBlockVector< MatrixType >, MatrixLocalBlocksToGlobalBlocks< MatrixType, number > > matrices
SmartPointer< const BlockInfo, MatrixLocalBlocksToGlobalBlocks< MatrixType, number > > block_info
SmartPointer< const AffineConstraints< typename MatrixType::value_type >, MatrixLocalBlocksToGlobalBlocks< MatrixType, number > > constraints
void initialize_info(DOFINFO &info, bool face) const
void initialize(const BlockInfo *block_info, MatrixBlockVector< MatrixType > &matrices)
MatrixLocalBlocksToGlobalBlocks(double threshold=1.e-12)
void assemble(const DOFINFO &info)
void initialize_info(DOFINFO &info, bool face) const
void initialize(const BlockInfo *block_info, AnyData &residuals)
void assemble(const DOFINFO &info)
SmartPointer< const BlockInfo, ResidualLocalBlocksToGlobalBlocks< VectorType > > block_info
SmartPointer< const AffineConstraints< typename VectorType::value_type >, ResidualLocalBlocksToGlobalBlocks< VectorType > > constraints
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
unsigned int global_dof_index