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)
563 if (constraints == 0)
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)
592 assemble(*(residuals.entry<VectorType>(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)
607 assemble(*(residuals.entry<VectorType>(i)),
610 assemble(*(residuals.entry<VectorType>(i)),
619 template <
typename MatrixType,
typename number>
622 : threshold(threshold)
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)
670 if (constraints ==
nullptr)
672 for (
unsigned int j = 0; j < local.n_rows(); ++j)
673 for (
unsigned int k = 0; k < local.n_cols(); ++k)
674 if (std::fabs(local(j, k)) >= threshold)
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];
705 constraints->distribute_local_to_global(local,
713 template <
typename MatrixType,
typename number>
714 template <
class DOFINFO>
719 for (
unsigned int i = 0; i < matrices->size(); ++i)
726 assemble(matrices->block(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)
750 assemble(matrices->block(i),
751 info1.matrix(i,
false).matrix,
756 assemble(matrices->block(i),
757 info1.matrix(i,
true).matrix,
762 assemble(matrices->block(i),
763 info2.matrix(i,
false).matrix,
768 assemble(matrices->block(i),
769 info2.matrix(i,
true).matrix,
780 template <
typename MatrixType,
typename number>
783 : threshold(threshold)
787 template <
typename MatrixType,
typename number>
794 AssertDimension(block_info->local().size(), block_info->global().size());
799 template <
typename MatrixType,
typename number>
804 mg_constrained_dofs = &mg_c;
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)
856 if (std::fabs(local(j, k)) >= threshold)
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])
886 if (mg_constrained_dofs == 0)
889 global.add(kglobal, jglobal, local(j, k));
891 global.add(jglobal, kglobal, local(j, k));
895 if (!mg_constrained_dofs->at_refinement_edge(level1,
897 !mg_constrained_dofs->at_refinement_edge(level2, kglobal))
899 if (mg_constrained_dofs->set_boundary_values())
901 if ((!mg_constrained_dofs->is_boundary_index(
903 !mg_constrained_dofs->is_boundary_index(
905 (mg_constrained_dofs->is_boundary_index(
907 mg_constrained_dofs->is_boundary_index(
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)
944 if (std::fabs(local(j, k)) >= threshold)
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])
974 if (mg_constrained_dofs == 0)
975 global.add(jglobal, kglobal, local(j, k));
978 if (!mg_constrained_dofs->non_refinement_edge_index(
980 !mg_constrained_dofs->non_refinement_edge_index(level2,
983 if (!mg_constrained_dofs->at_refinement_edge(level1,
985 !mg_constrained_dofs->at_refinement_edge(level2,
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])
1037 if (mg_constrained_dofs == 0)
1038 global.add(jglobal, kglobal, local(j, k));
1041 if (!mg_constrained_dofs->non_refinement_edge_index(
1043 !mg_constrained_dofs->non_refinement_edge_index(level2,
1046 if (!mg_constrained_dofs->at_refinement_edge(level1,
1048 !mg_constrained_dofs->at_refinement_edge(level2,
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])
1100 if (mg_constrained_dofs == 0)
1101 global.add(jglobal, kglobal, local(k, j));
1104 if (!mg_constrained_dofs->non_refinement_edge_index(
1106 !mg_constrained_dofs->non_refinement_edge_index(level2,
1109 if (!mg_constrained_dofs->at_refinement_edge(level1,
1111 !mg_constrained_dofs->at_refinement_edge(level2,
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])
1166 if (mg_constrained_dofs == 0)
1167 global.add(jglobal, kglobal, local(j, k));
1170 if (mg_constrained_dofs->at_refinement_edge(level1,
1172 !mg_constrained_dofs->at_refinement_edge(level2, kglobal))
1174 if (mg_constrained_dofs->set_boundary_values())
1176 if ((!mg_constrained_dofs->is_boundary_index(
1178 !mg_constrained_dofs->is_boundary_index(
1179 level2, kglobal)) ||
1180 (mg_constrained_dofs->is_boundary_index(
1182 mg_constrained_dofs->is_boundary_index(
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])
1241 if (mg_constrained_dofs == 0)
1242 global.add(jglobal, kglobal, local(k, j));
1245 if (mg_constrained_dofs->at_refinement_edge(level1,
1247 !mg_constrained_dofs->at_refinement_edge(level2, kglobal))
1249 if (mg_constrained_dofs->set_boundary_values())
1251 if ((!mg_constrained_dofs->is_boundary_index(
1253 !mg_constrained_dofs->is_boundary_index(
1254 level2, kglobal)) ||
1255 (mg_constrained_dofs->is_boundary_index(
1257 mg_constrained_dofs->is_boundary_index(
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;
1285 assemble(matrices->block(i)[
level].matrix,
1286 info.matrix(i,
false).matrix,
1293 if (mg_constrained_dofs != 0)
1295 if (interface_in != 0)
1296 assemble_in(interface_in->block(i)[
level],
1297 info.matrix(i,
false).matrix,
1304 if (interface_out != 0)
1305 assemble_in(interface_out->block(i)[
level],
1306 info.matrix(i,
false).matrix,
1314 assemble_in(matrices->block_in(i)[
level],
1315 info.matrix(i,
false).matrix,
1322 assemble_out(matrices->block_out(i)[
level],
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)
1356 if (mg_constrained_dofs == 0)
1358 assemble(o[level1].matrix,
1359 info1.matrix(i,
false).matrix,
1366 assemble(o[level1].matrix,
1367 info1.matrix(i,
true).matrix,
1374 assemble(o[level1].matrix,
1375 info2.matrix(i,
false).matrix,
1382 assemble(o[level1].matrix,
1383 info2.matrix(i,
true).matrix,
1393 assemble_fluxes(o[level1].matrix,
1394 info1.matrix(i,
false).matrix,
1401 assemble_fluxes(o[level1].matrix,
1402 info1.matrix(i,
true).matrix,
1409 assemble_fluxes(o[level1].matrix,
1410 info2.matrix(i,
false).matrix,
1417 assemble_fluxes(o[level1].matrix,
1418 info2.matrix(i,
true).matrix,
1430 if (flux_up->size() != 0)
1435 assemble_fluxes(o[level1].matrix,
1436 info1.matrix(i,
false).matrix,
1443 assemble_up(flux_up->block(i)[level1].matrix,
1444 info1.matrix(i,
true).matrix,
1451 assemble_down(flux_down->block(i)[level1].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< 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)