17 #ifndef dealii_mesh_worker_simple_h
18 #define dealii_mesh_worker_simple_h
59 template <
typename VectorType>
102 template <
class DOFINFO>
112 template <
class DOFINFO>
119 template <
class DOFINFO>
121 assemble(
const DOFINFO &info1,
const DOFINFO &info2);
169 template <
typename MatrixType>
209 template <
class DOFINFO>
217 template <
class DOFINFO>
225 template <
class DOFINFO>
227 assemble(
const DOFINFO &info1,
const DOFINFO &info2);
233 std::vector<SmartPointer<MatrixType, MatrixSimple<MatrixType>>>
matrix;
249 const unsigned int index,
250 const std::vector<types::global_dof_index> &i1,
251 const std::vector<types::global_dof_index> &i2);
272 template <
typename MatrixType>
316 template <
class DOFINFO>
323 template <
class DOFINFO>
331 template <
class DOFINFO>
333 assemble(
const DOFINFO &info1,
const DOFINFO &info2);
342 const std::vector<types::global_dof_index> &i1,
343 const std::vector<types::global_dof_index> &i2);
351 const std::vector<types::global_dof_index> &i1,
352 const std::vector<types::global_dof_index> &i2,
353 const unsigned int level);
362 const std::vector<types::global_dof_index> &i1,
363 const std::vector<types::global_dof_index> &i2,
372 const std::vector<types::global_dof_index> &i1,
373 const std::vector<types::global_dof_index> &i2,
383 const std::vector<types::global_dof_index> &i1,
384 const std::vector<types::global_dof_index> &i2,
394 const std::vector<types::global_dof_index> &i1,
395 const std::vector<types::global_dof_index> &i2,
456 template <
typename MatrixType,
typename VectorType>
490 template <
class DOFINFO>
497 template <
class DOFINFO>
505 template <
class DOFINFO>
507 assemble(
const DOFINFO &info1,
const DOFINFO &info2);
517 const unsigned int index,
518 const std::vector<types::global_dof_index> &indices);
523 const unsigned int index,
524 const std::vector<types::global_dof_index> &i1,
525 const std::vector<types::global_dof_index> &i2);
531 template <
typename VectorType>
538 template <
typename VectorType>
547 template <
typename MatrixType>
553 template <
typename VectorType>
554 template <
class DOFINFO>
558 info.initialize_vectors(residuals.size());
562 template <
typename VectorType>
563 template <
class DOFINFO>
567 for (
unsigned int k = 0; k < residuals.size(); ++k)
570 for (
unsigned int i = 0; i != info.vector(k).n_blocks(); ++i)
572 const std::vector<types::global_dof_index> &ldi =
573 info.vector(k).n_blocks() == 1 ? info.indices :
574 info.indices_by_block[i];
576 if (constraints !=
nullptr)
577 constraints->distribute_local_to_global(info.vector(k).block(i),
581 v->add(ldi, info.vector(k).block(i));
586 template <
typename VectorType>
587 template <
class DOFINFO>
590 const DOFINFO &info2)
599 template <
typename MatrixType>
601 : threshold(threshold)
605 template <
typename MatrixType>
614 template <
typename MatrixType>
619 for (
unsigned int i = 0; i < m.size(); ++i)
624 template <
typename MatrixType>
633 template <
typename MatrixType>
634 template <
class DOFINFO>
640 const unsigned int n = info.indices_by_block.size();
643 info.initialize_matrices(
matrix.size(), face);
646 info.initialize_matrices(
matrix.size() * n * n, face);
648 for (
unsigned int m = 0; m <
matrix.size(); ++m)
649 for (
unsigned int i = 0; i < n; ++i)
650 for (
unsigned int j = 0; j < n; ++j, ++k)
652 info.matrix(k,
false).row = i;
653 info.matrix(k,
false).column = j;
656 info.matrix(k,
true).row = i;
657 info.matrix(k,
true).column = j;
665 template <
typename MatrixType>
669 const unsigned int index,
670 const std::vector<types::global_dof_index> &i1,
671 const std::vector<types::global_dof_index> &i2)
676 if (constraints ==
nullptr)
678 for (
unsigned int j = 0; j < i1.size(); ++j)
679 for (
unsigned int k = 0; k < i2.size(); ++k)
681 matrix[index]->add(i1[j], i2[k], M(j, k));
684 constraints->distribute_local_to_global(M, i1, i2, *
matrix[index]);
688 template <
typename MatrixType>
689 template <
class DOFINFO>
694 const unsigned int n = info.indices_by_block.size();
697 for (
unsigned int m = 0; m <
matrix.size(); ++m)
698 assemble(info.matrix(m,
false).matrix, m, info.indices, info.indices);
701 for (
unsigned int m = 0; m <
matrix.size(); ++m)
702 for (
unsigned int k = 0; k < n * n; ++k)
705 info.matrix(k + m * n * n,
false).matrix,
707 info.indices_by_block[info.matrix(k + m * n * n,
false).row],
708 info.indices_by_block[info.matrix(k + m * n * n,
false)
715 template <
typename MatrixType>
716 template <
class DOFINFO>
719 const DOFINFO &info2)
724 info2.indices_by_block.size());
726 const unsigned int n = info1.indices_by_block.size();
730 for (
unsigned int m = 0; m <
matrix.size(); ++m)
732 assemble(info1.matrix(m,
false).matrix,
736 assemble(info1.matrix(m,
true).matrix,
740 assemble(info2.matrix(m,
false).matrix,
744 assemble(info2.matrix(m,
true).matrix,
752 for (
unsigned int m = 0; m <
matrix.size(); ++m)
753 for (
unsigned int k = 0; k < n * n; ++k)
755 const unsigned int row = info1.matrix(k + m * n * n,
false).row;
756 const unsigned int column =
757 info1.matrix(k + m * n * n,
false).column;
759 assemble(info1.matrix(k + m * n * n,
false).matrix,
761 info1.indices_by_block[row],
762 info1.indices_by_block[column]);
763 assemble(info1.matrix(k + m * n * n,
true).matrix,
765 info1.indices_by_block[row],
766 info2.indices_by_block[column]);
767 assemble(info2.matrix(k + m * n * n,
false).matrix,
769 info2.indices_by_block[row],
770 info2.indices_by_block[column]);
771 assemble(info2.matrix(k + m * n * n,
true).matrix,
773 info2.indices_by_block[row],
774 info1.indices_by_block[column]);
782 template <
typename MatrixType>
784 : threshold(threshold)
788 template <
typename MatrixType>
795 template <
typename MatrixType>
799 mg_constrained_dofs = &c;
803 template <
typename MatrixType>
814 template <
typename MatrixType>
821 interface_out = &out;
825 template <
typename MatrixType>
826 template <
class DOFINFO>
830 const unsigned int n = info.indices_by_block.size();
833 info.initialize_matrices(1, face);
836 info.initialize_matrices(n * n, face);
838 for (
unsigned int i = 0; i < n; ++i)
839 for (
unsigned int j = 0; j < n; ++j, ++k)
841 info.matrix(k,
false).row = i;
842 info.matrix(k,
false).column = j;
845 info.matrix(k,
true).row = i;
846 info.matrix(k,
true).column = j;
853 template <
typename MatrixType>
858 const std::vector<types::global_dof_index> &i1,
859 const std::vector<types::global_dof_index> &i2)
866 for (
unsigned int j = 0; j < i1.size(); ++j)
867 for (
unsigned int k = 0; k < i2.size(); ++k)
869 G.add(i1[j], i2[k], M(j, k));
873 template <
typename MatrixType>
878 const std::vector<types::global_dof_index> &i1,
879 const std::vector<types::global_dof_index> &i2,
880 const unsigned int level)
885 if (mg_constrained_dofs ==
nullptr)
887 for (
unsigned int j = 0; j < i1.size(); ++j)
888 for (
unsigned int k = 0; k < i2.size(); ++k)
890 G.add(i1[j], i2[k], M(j, k));
894 for (
unsigned int j = 0; j < i1.size(); ++j)
895 for (
unsigned int k = 0; k < i2.size(); ++k)
909 if (mg_constrained_dofs->at_refinement_edge(
level, i1[j]) ||
910 mg_constrained_dofs->at_refinement_edge(
level, i2[k]))
915 if ((mg_constrained_dofs->is_boundary_index(
level, i1[j]) ||
916 mg_constrained_dofs->is_boundary_index(
level, i2[k])) &&
920 G.add(i1[j], i2[k], M(j, k));
926 template <
typename MatrixType>
931 const std::vector<types::global_dof_index> &i1,
932 const std::vector<types::global_dof_index> &i2,
933 const unsigned int level)
938 if (mg_constrained_dofs ==
nullptr)
940 for (
unsigned int j = 0; j < i1.size(); ++j)
941 for (
unsigned int k = 0; k < i2.size(); ++k)
943 G.add(i1[j], i2[k], M(k, j));
947 for (
unsigned int j = 0; j < i1.size(); ++j)
948 for (
unsigned int k = 0; k < i2.size(); ++k)
950 if (!mg_constrained_dofs->at_refinement_edge(
level, i2[k]))
951 G.add(i1[j], i2[k], M(k, j));
955 template <
typename MatrixType>
960 const std::vector<types::global_dof_index> &i1,
961 const std::vector<types::global_dof_index> &i2,
962 const unsigned int level)
967 if (mg_constrained_dofs ==
nullptr)
969 for (
unsigned int j = 0; j < i1.size(); ++j)
970 for (
unsigned int k = 0; k < i2.size(); ++k)
972 G.add(i1[j], i2[k], M(j, k));
976 for (
unsigned int j = 0; j < i1.size(); ++j)
977 for (
unsigned int k = 0; k < i2.size(); ++k)
979 if (!mg_constrained_dofs->at_refinement_edge(
level, i2[k]))
980 G.add(i1[j], i2[k], M(j, k));
984 template <
typename MatrixType>
989 const std::vector<types::global_dof_index> &i1,
990 const std::vector<types::global_dof_index> &i2,
991 const unsigned int level)
997 for (
unsigned int j = 0; j < i1.size(); ++j)
998 for (
unsigned int k = 0; k < i2.size(); ++k)
1011 if (mg_constrained_dofs->at_refinement_edge(
level, i1[j]) &&
1012 !mg_constrained_dofs->at_refinement_edge(
level, i2[k]))
1014 if ((!mg_constrained_dofs->is_boundary_index(
level, i1[j]) &&
1015 !mg_constrained_dofs->is_boundary_index(
level, i2[k])) ||
1016 (mg_constrained_dofs->is_boundary_index(
level, i1[j]) &&
1017 mg_constrained_dofs->is_boundary_index(
level, i2[k]) &&
1019 G.add(i1[j], i2[k], M(j, k));
1024 template <
typename MatrixType>
1029 const std::vector<types::global_dof_index> &i1,
1030 const std::vector<types::global_dof_index> &i2,
1031 const unsigned int level)
1037 for (
unsigned int j = 0; j < i1.size(); ++j)
1038 for (
unsigned int k = 0; k < i2.size(); ++k)
1040 if (mg_constrained_dofs->at_refinement_edge(
level, i1[j]) &&
1041 !mg_constrained_dofs->at_refinement_edge(
level, i2[k]))
1043 if ((!mg_constrained_dofs->is_boundary_index(
level, i1[j]) &&
1044 !mg_constrained_dofs->is_boundary_index(
level, i2[k])) ||
1045 (mg_constrained_dofs->is_boundary_index(
level, i1[j]) &&
1046 mg_constrained_dofs->is_boundary_index(
level, i2[k]) &&
1048 G.add(i1[j], i2[k], M(k, j));
1053 template <
typename MatrixType>
1054 template <
class DOFINFO>
1059 const unsigned int level = info.cell->level();
1061 if (info.indices_by_block.size() == 0)
1064 info.matrix(0,
false).matrix,
1068 if (mg_constrained_dofs !=
nullptr)
1070 assemble_in((*interface_in)[
level],
1071 info.matrix(0,
false).matrix,
1075 assemble_out((*interface_out)[
level],
1076 info.matrix(0,
false).matrix,
1083 for (
unsigned int k = 0; k < info.n_matrices(); ++k)
1085 const unsigned int row = info.matrix(k,
false).row;
1086 const unsigned int column = info.matrix(k,
false).column;
1089 info.matrix(k,
false).matrix,
1090 info.indices_by_block[row],
1091 info.indices_by_block[column],
1094 if (mg_constrained_dofs !=
nullptr)
1096 assemble_in((*interface_in)[
level],
1097 info.matrix(k,
false).matrix,
1098 info.indices_by_block[row],
1099 info.indices_by_block[column],
1101 assemble_out((*interface_out)[
level],
1102 info.matrix(k,
false).matrix,
1103 info.indices_by_block[column],
1104 info.indices_by_block[row],
1111 template <
typename MatrixType>
1112 template <
class DOFINFO>
1115 const DOFINFO &info2)
1119 const unsigned int level1 = info1.cell->level();
1120 const unsigned int level2 = info2.cell->level();
1122 if (info1.indices_by_block.size() == 0)
1124 if (level1 == level2)
1127 info1.matrix(0,
false).matrix,
1132 info1.matrix(0,
true).matrix,
1137 info2.matrix(0,
false).matrix,
1142 info2.matrix(0,
true).matrix,
1154 info1.matrix(0,
false).matrix,
1160 assemble_up((*flux_up)[level1],
1161 info1.matrix(0,
true).matrix,
1165 assemble_down((*flux_down)[level1],
1166 info2.matrix(0,
true).matrix,
1174 for (
unsigned int k = 0; k < info1.n_matrices(); ++k)
1176 const unsigned int row = info1.matrix(k,
false).row;
1177 const unsigned int column = info1.matrix(k,
false).column;
1179 if (level1 == level2)
1182 info1.matrix(k,
false).matrix,
1183 info1.indices_by_block[row],
1184 info1.indices_by_block[column],
1187 info1.matrix(k,
true).matrix,
1188 info1.indices_by_block[row],
1189 info2.indices_by_block[column],
1192 info2.matrix(k,
false).matrix,
1193 info2.indices_by_block[row],
1194 info2.indices_by_block[column],
1197 info2.matrix(k,
true).matrix,
1198 info2.indices_by_block[row],
1199 info1.indices_by_block[column],
1209 info1.matrix(k,
false).matrix,
1210 info1.indices_by_block[row],
1211 info1.indices_by_block[column],
1215 assemble_up((*flux_up)[level1],
1216 info1.matrix(k,
true).matrix,
1217 info2.indices_by_block[column],
1218 info1.indices_by_block[row],
1220 assemble_down((*flux_down)[level1],
1221 info2.matrix(k,
true).matrix,
1222 info2.indices_by_block[row],
1223 info1.indices_by_block[column],
1232 template <
typename MatrixType,
typename VectorType>
1238 template <
typename MatrixType,
typename VectorType>
1245 data.
add(p,
"right hand side");
1251 template <
typename MatrixType,
typename VectorType>
1260 template <
typename MatrixType,
typename VectorType>
1261 template <
class DOFINFO>
1270 template <
typename MatrixType,
typename VectorType>
1275 const unsigned int index,
1276 const std::vector<types::global_dof_index> &indices)
1286 for (
unsigned int i = 0; i < indices.size(); ++i)
1287 (*v)(indices[i]) += vector(i);
1289 for (
unsigned int j = 0; j < indices.size(); ++j)
1290 for (
unsigned int k = 0; k < indices.size(); ++k)
1308 template <
typename MatrixType,
typename VectorType>
1313 const unsigned int index,
1314 const std::vector<types::global_dof_index> &i1,
1315 const std::vector<types::global_dof_index> &i2)
1325 for (
unsigned int j = 0; j < i1.size(); ++j)
1326 for (
unsigned int k = 0; k < i2.size(); ++k)
1335 vector, i1, i2, *v, M,
false);
1342 template <
typename MatrixType,
typename VectorType>
1343 template <
class DOFINFO>
1350 const unsigned int n = info.indices_by_block.size();
1356 assemble(info.matrix(m,
false).matrix,
1357 info.vector(m).block(0),
1365 for (
unsigned int k = 0; k < n * n; ++k)
1367 const unsigned int row = info.matrix(k + m * n * n,
false).row;
1368 const unsigned int column =
1369 info.matrix(k + m * n * n,
false).column;
1372 assemble(info.matrix(k + m * n * n,
false).matrix,
1373 info.vector(m).block(row),
1375 info.indices_by_block[row]);
1377 assemble(info.matrix(k + m * n * n,
false).matrix,
1378 info.vector(m).block(row),
1380 info.indices_by_block[row],
1381 info.indices_by_block[column]);
1387 template <
typename MatrixType,
typename VectorType>
1388 template <
class DOFINFO>
1391 const DOFINFO &info2)
1396 info2.indices_by_block.size());
1398 const unsigned int n = info1.indices_by_block.size();
1405 assemble(info1.matrix(m,
false).matrix,
1406 info1.vector(m).block(0),
1409 assemble(info1.matrix(m,
true).matrix,
1410 info1.vector(m).block(0),
1414 assemble(info2.matrix(m,
false).matrix,
1415 info2.vector(m).block(0),
1418 assemble(info2.matrix(m,
true).matrix,
1419 info2.vector(m).block(0),
1429 for (
unsigned int k = 0; k < n * n; ++k)
1431 const unsigned int row = info1.matrix(k + m * n * n,
false).row;
1432 const unsigned int column =
1433 info1.matrix(k + m * n * n,
false).column;
1437 assemble(info1.matrix(k + m * n * n,
false).matrix,
1438 info1.vector(m).block(row),
1440 info1.indices_by_block[row]);
1441 assemble(info2.matrix(k + m * n * n,
false).matrix,
1442 info2.vector(m).block(row),
1444 info2.indices_by_block[row]);
1448 assemble(info1.matrix(k + m * n * n,
false).matrix,
1449 info1.vector(m).block(row),
1451 info1.indices_by_block[row],
1452 info1.indices_by_block[column]);
1453 assemble(info2.matrix(k + m * n * n,
false).matrix,
1454 info2.vector(m).block(row),
1456 info2.indices_by_block[row],
1457 info2.indices_by_block[column]);
1459 assemble(info1.matrix(k + m * n * n,
true).matrix,
1460 info1.vector(m).block(row),
1462 info1.indices_by_block[row],
1463 info2.indices_by_block[column]);
1464 assemble(info2.matrix(k + m * n * n,
true).matrix,
1465 info2.vector(m).block(row),
1467 info2.indices_by_block[row],
1468 info1.indices_by_block[column]);