14#ifndef dealii_mesh_worker_assembler_h
15#define dealii_mesh_worker_assembler_h
108 template <
typename VectorType>
132 template <
class DOFINFO>
140 template <
class DOFINFO>
147 template <
class DOFINFO>
149 assemble(
const DOFINFO &info1,
const DOFINFO &info2);
158 const std::vector<types::global_dof_index> &dof);
207 template <
typename MatrixType,
typename number =
double>
239 template <
class DOFINFO>
247 template <
class DOFINFO>
254 template <
class DOFINFO>
256 assemble(
const DOFINFO &info1,
const DOFINFO &info2);
265 const unsigned int block_row,
266 const unsigned int block_col,
267 const std::vector<types::global_dof_index> &dof1,
268 const std::vector<types::global_dof_index> &dof2);
322 template <
typename MatrixType,
typename number =
double>
373 template <
class DOFINFO>
381 template <
class DOFINFO>
388 template <
class DOFINFO>
390 assemble(
const DOFINFO &info1,
const DOFINFO &info2);
399 const unsigned int block_row,
400 const unsigned int block_col,
401 const std::vector<types::global_dof_index> &dof1,
402 const std::vector<types::global_dof_index> &dof2,
403 const unsigned int level1,
404 const unsigned int level2,
413 const unsigned int block_row,
414 const unsigned int block_col,
415 const std::vector<types::global_dof_index> &dof1,
416 const std::vector<types::global_dof_index> &dof2,
417 const unsigned int level1,
418 const unsigned int level2);
426 const unsigned int block_row,
427 const unsigned int block_col,
428 const std::vector<types::global_dof_index> &dof1,
429 const std::vector<types::global_dof_index> &dof2,
430 const unsigned int level1,
431 const unsigned int level2);
439 const unsigned int block_row,
440 const unsigned int block_col,
441 const std::vector<types::global_dof_index> &dof1,
442 const std::vector<types::global_dof_index> &dof2,
443 const unsigned int level1,
444 const unsigned int level2);
452 const unsigned int block_row,
453 const unsigned int block_col,
454 const std::vector<types::global_dof_index> &dof1,
455 const std::vector<types::global_dof_index> &dof2,
456 const unsigned int level1,
457 const unsigned int level2);
465 const unsigned int block_row,
466 const unsigned int block_col,
467 const std::vector<types::global_dof_index> &dof1,
468 const std::vector<types::global_dof_index> &dof2,
469 const unsigned int level1,
470 const unsigned int level2);
526 template <
typename VectorType>
536 template <
typename VectorType>
545 template <
typename VectorType>
546 template <
class DOFINFO>
552 info.initialize_vectors(
residuals.size());
555 template <
typename VectorType>
560 const std::vector<types::global_dof_index> &dof)
564 for (
unsigned int b = 0; b < local.
n_blocks(); ++b)
565 for (
unsigned int j = 0; j < local.
block(b).size(); ++j)
575 const unsigned int jcell =
576 this->
block_info->local().local_to_global(b, j);
577 global(dof[jcell]) += local.
block(b)(j);
581 constraints->distribute_local_to_global(local, dof, global);
585 template <
typename VectorType>
586 template <
class DOFINFO>
590 for (
unsigned int i = 0; i <
residuals.size(); ++i)
597 template <
typename VectorType>
598 template <
class DOFINFO>
601 const DOFINFO &info1,
602 const DOFINFO &info2)
604 for (
unsigned int i = 0; i <
residuals.size(); ++i)
618 template <
typename MatrixType,
typename number>
625 template <
typename MatrixType,
typename number>
637 template <
typename MatrixType,
typename number>
647 template <
typename MatrixType,
typename number>
648 template <
class DOFINFO>
654 info.initialize_matrices(*
matrices, face);
659 template <
typename MatrixType,
typename number>
664 const unsigned int block_row,
665 const unsigned int block_col,
666 const std::vector<types::global_dof_index> &dof1,
667 const std::vector<types::global_dof_index> &dof2)
671 for (
unsigned int j = 0; j < local.n_rows(); ++j)
672 for (
unsigned int k = 0; k < local.n_cols(); ++k)
683 const unsigned int jcell =
684 this->
block_info->local().local_to_global(block_row, j);
685 const unsigned int kcell =
686 this->
block_info->local().local_to_global(block_col, k);
688 global.
add(dof1[jcell], dof2[kcell], local(j, k));
694 std::vector<types::global_dof_index> sliced_row_indices(
696 for (
unsigned int i = 0; i < sliced_row_indices.size(); ++i)
697 sliced_row_indices[i] = dof1[bi.
block_start(block_row) + i];
699 std::vector<types::global_dof_index> sliced_col_indices(
701 for (
unsigned int i = 0; i < sliced_col_indices.size(); ++i)
702 sliced_col_indices[i] = dof2[bi.
block_start(block_col) + i];
712 template <
typename MatrixType,
typename number>
713 template <
class DOFINFO>
718 for (
unsigned int i = 0; i <
matrices->size(); ++i)
726 info.matrix(i,
false).matrix,
735 template <
typename MatrixType,
typename number>
736 template <
class DOFINFO>
739 const DOFINFO &info1,
740 const DOFINFO &info2)
742 for (
unsigned int i = 0; i <
matrices->size(); ++i)
750 info1.matrix(i,
false).matrix,
756 info1.matrix(i,
true).matrix,
762 info2.matrix(i,
false).matrix,
768 info2.matrix(i,
true).matrix,
779 template <
typename MatrixType,
typename number>
786 template <
typename MatrixType,
typename number>
798 template <
typename MatrixType,
typename number>
807 template <
typename MatrixType,
typename number>
808 template <
class DOFINFO>
814 info.initialize_matrices(*
matrices, face);
819 template <
typename MatrixType,
typename number>
830 template <
typename MatrixType,
typename number>
840 template <
typename MatrixType,
typename number>
845 const unsigned int block_row,
846 const unsigned int block_col,
847 const std::vector<types::global_dof_index> &dof1,
848 const std::vector<types::global_dof_index> &dof2,
849 const unsigned int level1,
850 const unsigned int level2,
853 for (
unsigned int j = 0; j < local.n_rows(); ++j)
854 for (
unsigned int k = 0; k < local.n_cols(); ++k)
865 const unsigned int jcell =
866 this->
block_info->local().local_to_global(block_row, j);
867 const unsigned int kcell =
868 this->
block_info->local().local_to_global(block_col, k);
878 const unsigned int jglobal = this->
block_info->level(level1)
879 .global_to_local(dof1[jcell])
881 const unsigned int kglobal = this->
block_info->level(level2)
882 .global_to_local(dof2[kcell])
888 global.add(kglobal, jglobal, local(j, k));
890 global.add(jglobal, kglobal, local(j, k));
911 global.add(kglobal, jglobal, local(j, k));
913 global.add(jglobal, kglobal, local(j, k));
919 global.add(kglobal, jglobal, local(j, k));
921 global.add(jglobal, kglobal, local(j, k));
929 template <
typename MatrixType,
typename number>
934 const unsigned int block_row,
935 const unsigned int block_col,
936 const std::vector<types::global_dof_index> &dof1,
937 const std::vector<types::global_dof_index> &dof2,
938 const unsigned int level1,
939 const unsigned int level2)
941 for (
unsigned int j = 0; j < local.n_rows(); ++j)
942 for (
unsigned int k = 0; k < local.n_cols(); ++k)
953 const unsigned int jcell =
954 this->
block_info->local().local_to_global(block_row, j);
955 const unsigned int kcell =
956 this->
block_info->local().local_to_global(block_col, k);
966 const unsigned int jglobal = this->
block_info->level(level1)
967 .global_to_local(dof1[jcell])
969 const unsigned int kglobal = this->
block_info->level(level2)
970 .global_to_local(dof2[kcell])
974 global.add(jglobal, kglobal, local(j, k));
986 global.add(jglobal, kglobal, local(j, k));
992 template <
typename MatrixType,
typename number>
997 const unsigned int block_row,
998 const unsigned int block_col,
999 const std::vector<types::global_dof_index> &dof1,
1000 const std::vector<types::global_dof_index> &dof2,
1001 const unsigned int level1,
1002 const unsigned int level2)
1004 for (
unsigned int j = 0; j < local.n_rows(); ++j)
1005 for (
unsigned int k = 0; k < local.n_cols(); ++k)
1006 if (std::fabs(local(j, k)) >=
threshold)
1016 const unsigned int jcell =
1017 this->
block_info->local().local_to_global(block_row, j);
1018 const unsigned int kcell =
1019 this->
block_info->local().local_to_global(block_col, k);
1029 const unsigned int jglobal = this->
block_info->level(level1)
1030 .global_to_local(dof1[jcell])
1032 const unsigned int kglobal = this->
block_info->level(level2)
1033 .global_to_local(dof2[kcell])
1037 global.add(jglobal, kglobal, local(j, k));
1049 global.add(jglobal, kglobal, local(j, k));
1055 template <
typename MatrixType,
typename number>
1060 const unsigned int block_row,
1061 const unsigned int block_col,
1062 const std::vector<types::global_dof_index> &dof1,
1063 const std::vector<types::global_dof_index> &dof2,
1064 const unsigned int level1,
1065 const unsigned int level2)
1067 for (
unsigned int j = 0; j < local.n_rows(); ++j)
1068 for (
unsigned int k = 0; k < local.n_cols(); ++k)
1069 if (std::fabs(local(k, j)) >=
threshold)
1079 const unsigned int jcell =
1080 this->
block_info->local().local_to_global(block_row, j);
1081 const unsigned int kcell =
1082 this->
block_info->local().local_to_global(block_col, k);
1092 const unsigned int jglobal = this->
block_info->level(level1)
1093 .global_to_local(dof1[jcell])
1095 const unsigned int kglobal = this->
block_info->level(level2)
1096 .global_to_local(dof2[kcell])
1100 global.add(jglobal, kglobal, local(k, j));
1112 global.add(jglobal, kglobal, local(k, j));
1118 template <
typename MatrixType,
typename number>
1123 const unsigned int block_row,
1124 const unsigned int block_col,
1125 const std::vector<types::global_dof_index> &dof1,
1126 const std::vector<types::global_dof_index> &dof2,
1127 const unsigned int level1,
1128 const unsigned int level2)
1133 for (
unsigned int j = 0; j < local.n_rows(); ++j)
1134 for (
unsigned int k = 0; k < local.n_cols(); ++k)
1135 if (std::fabs(local(j, k)) >=
threshold)
1145 const unsigned int jcell =
1146 this->
block_info->local().local_to_global(block_row, j);
1147 const unsigned int kcell =
1148 this->
block_info->local().local_to_global(block_col, k);
1158 const unsigned int jglobal = this->
block_info->level(level1)
1159 .global_to_local(dof1[jcell])
1161 const unsigned int kglobal = this->
block_info->level(level2)
1162 .global_to_local(dof2[kcell])
1166 global.add(jglobal, kglobal, local(j, k));
1178 level2, kglobal)) ||
1183 jglobal == kglobal))
1184 global.add(jglobal, kglobal, local(j, k));
1187 global.add(jglobal, kglobal, local(j, k));
1193 template <
typename MatrixType,
typename number>
1198 const unsigned int block_row,
1199 const unsigned int block_col,
1200 const std::vector<types::global_dof_index> &dof1,
1201 const std::vector<types::global_dof_index> &dof2,
1202 const unsigned int level1,
1203 const unsigned int level2)
1208 for (
unsigned int j = 0; j < local.n_rows(); ++j)
1209 for (
unsigned int k = 0; k < local.n_cols(); ++k)
1210 if (std::fabs(local(k, j)) >=
threshold)
1220 const unsigned int jcell =
1221 this->
block_info->local().local_to_global(block_row, j);
1222 const unsigned int kcell =
1223 this->
block_info->local().local_to_global(block_col, k);
1233 const unsigned int jglobal = this->
block_info->level(level1)
1234 .global_to_local(dof1[jcell])
1236 const unsigned int kglobal = this->
block_info->level(level2)
1237 .global_to_local(dof2[kcell])
1241 global.add(jglobal, kglobal, local(k, j));
1253 level2, kglobal)) ||
1258 jglobal == kglobal))
1259 global.add(jglobal, kglobal, local(k, j));
1262 global.add(jglobal, kglobal, local(k, j));
1269 template <
typename MatrixType,
typename number>
1270 template <
class DOFINFO>
1273 const DOFINFO &info)
1275 const unsigned int level = info.cell->level();
1277 for (
unsigned int i = 0; i <
matrices->size(); ++i)
1281 const unsigned int row =
matrices->block(i)[level].row;
1282 const unsigned int col =
matrices->block(i)[level].column;
1285 info.matrix(i,
false).matrix,
1296 info.matrix(i,
false).matrix,
1305 info.matrix(i,
false).matrix,
1314 info.matrix(i,
false).matrix,
1322 info.matrix(i,
false).matrix,
1334 template <
typename MatrixType,
typename number>
1335 template <
class DOFINFO>
1338 const DOFINFO &info1,
1339 const DOFINFO &info2)
1341 const unsigned int level1 = info1.cell->level();
1342 const unsigned int level2 = info2.cell->level();
1344 for (
unsigned int i = 0; i <
matrices->size(); ++i)
1350 const unsigned int row = o[level1].row;
1351 const unsigned int col = o[level1].column;
1353 if (level1 == level2)
1358 info1.matrix(i,
false).matrix,
1366 info1.matrix(i,
true).matrix,
1374 info2.matrix(i,
false).matrix,
1382 info2.matrix(i,
true).matrix,
1393 info1.matrix(i,
false).matrix,
1401 info1.matrix(i,
true).matrix,
1409 info2.matrix(i,
false).matrix,
1417 info2.matrix(i,
true).matrix,
1428 Assert(level1 > level2, ExcNotImplemented());
1435 info1.matrix(i,
false).matrix,
1443 info1.matrix(i,
true).matrix,
1451 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
void assemble(const DOFINFO &info)
ObserverPointer< const BlockInfo, MGMatrixLocalBlocksToGlobalBlocks< MatrixType, number > > block_info
MatrixPtrVectorPtr interface_out
void initialize(const BlockInfo *block_info, MatrixPtrVector &matrices)
ObserverPointer< MatrixPtrVector, MGMatrixLocalBlocksToGlobalBlocks< MatrixType, number > > MatrixPtrVectorPtr
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)
ObserverPointer< const MGConstrainedDoFs, MGMatrixLocalBlocksToGlobalBlocks< MatrixType, number > > mg_constrained_dofs
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
void initialize_edge_flux(MatrixPtrVector &up, MatrixPtrVector &down)
MatrixPtrVectorPtr flux_up
MGMatrixLocalBlocksToGlobalBlocks(double threshold=1.e-12)
void initialize_info(DOFINFO &info, bool face) const
ObserverPointer< const BlockInfo, MatrixLocalBlocksToGlobalBlocks< MatrixType, number > > block_info
ObserverPointer< const AffineConstraints< typename MatrixType::value_type >, MatrixLocalBlocksToGlobalBlocks< MatrixType, number > > constraints
void initialize(const BlockInfo *block_info, MatrixBlockVector< MatrixType > &matrices)
ObserverPointer< MatrixBlockVector< MatrixType >, MatrixLocalBlocksToGlobalBlocks< MatrixType, number > > 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)
ObserverPointer< const BlockInfo, ResidualLocalBlocksToGlobalBlocks< VectorType > > block_info
ObserverPointer< const AffineConstraints< typename VectorType::value_type >, ResidualLocalBlocksToGlobalBlocks< VectorType > > constraints
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
unsigned int global_dof_index