14#ifndef dealii_mesh_worker_simple_h
15#define dealii_mesh_worker_simple_h
55 template <
typename VectorType>
82 template <
class DOFINFO>
92 template <
class DOFINFO>
99 template <
class DOFINFO>
101 assemble(
const DOFINFO &info1,
const DOFINFO &info2);
148 template <
typename MatrixType>
188 template <
class DOFINFO>
196 template <
class DOFINFO>
204 template <
class DOFINFO>
206 assemble(
const DOFINFO &info1,
const DOFINFO &info2);
212 std::vector<ObserverPointer<MatrixType, MatrixSimple<MatrixType>>>
matrix;
228 const unsigned int index,
229 const std::vector<types::global_dof_index> &i1,
230 const std::vector<types::global_dof_index> &i2);
250 template <
typename MatrixType>
294 template <
class DOFINFO>
301 template <
class DOFINFO>
309 template <
class DOFINFO>
311 assemble(
const DOFINFO &info1,
const DOFINFO &info2);
320 const std::vector<types::global_dof_index> &i1,
321 const std::vector<types::global_dof_index> &i2);
329 const std::vector<types::global_dof_index> &i1,
330 const std::vector<types::global_dof_index> &i2,
331 const unsigned int level);
340 const std::vector<types::global_dof_index> &i1,
341 const std::vector<types::global_dof_index> &i2,
350 const std::vector<types::global_dof_index> &i1,
351 const std::vector<types::global_dof_index> &i2,
361 const std::vector<types::global_dof_index> &i1,
362 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,
433 template <
typename MatrixType,
typename VectorType>
468 template <
class DOFINFO>
475 template <
class DOFINFO>
483 template <
class DOFINFO>
485 assemble(
const DOFINFO &info1,
const DOFINFO &info2);
495 const unsigned int index,
496 const std::vector<types::global_dof_index> &indices);
501 const unsigned int index,
502 const std::vector<types::global_dof_index> &i1,
503 const std::vector<types::global_dof_index> &i2);
509 template <
typename VectorType>
518 template <
typename VectorType>
528 template <
typename VectorType>
529 template <
class DOFINFO>
533 info.initialize_vectors(
residuals.size());
538 template <
typename VectorType>
539 template <
class DOFINFO>
543 for (
unsigned int k = 0; k <
residuals.size(); ++k)
545 VectorType *v =
residuals.entry<VectorType *>(k);
546 for (
unsigned int i = 0; i != info.vector(k).n_blocks(); ++i)
548 const std::vector<types::global_dof_index> &ldi =
549 info.vector(k).n_blocks() == 1 ? info.indices :
550 info.indices_by_block[i];
553 constraints->distribute_local_to_global(info.vector(k).block(i),
557 v->add(ldi, info.vector(k).block(i));
562 template <
typename VectorType>
563 template <
class DOFINFO>
566 const DOFINFO &info2)
575 template <
typename MatrixType>
581 template <
typename MatrixType>
590 template <
typename MatrixType>
595 for (
unsigned int i = 0; i < m.size(); ++i)
600 template <
typename MatrixType>
609 template <
typename MatrixType>
610 template <
class DOFINFO>
616 const unsigned int n = info.indices_by_block.size();
619 info.initialize_matrices(
matrix.size(), face);
622 info.initialize_matrices(
matrix.size() * n * n, face);
624 for (
unsigned int m = 0; m <
matrix.size(); ++m)
625 for (
unsigned int i = 0; i < n; ++i)
626 for (
unsigned int j = 0; j < n; ++j, ++k)
628 info.matrix(k,
false).row = i;
629 info.matrix(k,
false).column = j;
632 info.matrix(k,
true).row = i;
633 info.matrix(k,
true).column = j;
641 template <
typename MatrixType>
645 const unsigned int index,
646 const std::vector<types::global_dof_index> &i1,
647 const std::vector<types::global_dof_index> &i2)
654 for (
unsigned int j = 0; j < i1.size(); ++j)
655 for (
unsigned int k = 0; k < i2.size(); ++k)
657 matrix[index]->add(i1[j], i2[k], M(j, k));
664 template <
typename MatrixType>
665 template <
class DOFINFO>
670 const unsigned int n = info.indices_by_block.size();
673 for (
unsigned int m = 0; m <
matrix.size(); ++m)
674 assemble(info.matrix(m,
false).matrix, m, info.indices, info.indices);
677 for (
unsigned int m = 0; m <
matrix.size(); ++m)
678 for (
unsigned int k = 0; k < n * n; ++k)
681 info.matrix(k + m * n * n,
false).matrix,
683 info.indices_by_block[info.matrix(k + m * n * n,
false).row],
684 info.indices_by_block[info.matrix(k + m * n * n,
false)
691 template <
typename MatrixType>
692 template <
class DOFINFO>
695 const DOFINFO &info2)
700 info2.indices_by_block.size());
702 const unsigned int n = info1.indices_by_block.size();
706 for (
unsigned int m = 0; m <
matrix.size(); ++m)
708 assemble(info1.matrix(m,
false).matrix,
712 assemble(info1.matrix(m,
true).matrix,
716 assemble(info2.matrix(m,
false).matrix,
720 assemble(info2.matrix(m,
true).matrix,
728 for (
unsigned int m = 0; m <
matrix.size(); ++m)
729 for (
unsigned int k = 0; k < n * n; ++k)
731 const unsigned int row = info1.matrix(k + m * n * n,
false).row;
732 const unsigned int column =
733 info1.matrix(k + m * n * n,
false).column;
735 assemble(info1.matrix(k + m * n * n,
false).matrix,
737 info1.indices_by_block[row],
738 info1.indices_by_block[column]);
739 assemble(info1.matrix(k + m * n * n,
true).matrix,
741 info1.indices_by_block[row],
742 info2.indices_by_block[column]);
743 assemble(info2.matrix(k + m * n * n,
false).matrix,
745 info2.indices_by_block[row],
746 info2.indices_by_block[column]);
747 assemble(info2.matrix(k + m * n * n,
true).matrix,
749 info2.indices_by_block[row],
750 info1.indices_by_block[column]);
758 template <
typename MatrixType>
764 template <
typename MatrixType>
771 template <
typename MatrixType>
779 template <
typename MatrixType>
790 template <
typename MatrixType>
801 template <
typename MatrixType>
802 template <
class DOFINFO>
806 const unsigned int n = info.indices_by_block.size();
809 info.initialize_matrices(1, face);
812 info.initialize_matrices(n * n, face);
814 for (
unsigned int i = 0; i < n; ++i)
815 for (
unsigned int j = 0; j < n; ++j, ++k)
817 info.matrix(k,
false).row = i;
818 info.matrix(k,
false).column = j;
821 info.matrix(k,
true).row = i;
822 info.matrix(k,
true).column = j;
829 template <
typename MatrixType>
834 const std::vector<types::global_dof_index> &i1,
835 const std::vector<types::global_dof_index> &i2)
842 for (
unsigned int j = 0; j < i1.size(); ++j)
843 for (
unsigned int k = 0; k < i2.size(); ++k)
845 G.add(i1[j], i2[k], M(j, k));
849 template <
typename MatrixType>
854 const std::vector<types::global_dof_index> &i1,
855 const std::vector<types::global_dof_index> &i2,
856 const unsigned int level)
863 for (
unsigned int j = 0; j < i1.size(); ++j)
864 for (
unsigned int k = 0; k < i2.size(); ++k)
866 G.add(i1[j], i2[k], M(j, k));
870 for (
unsigned int j = 0; j < i1.size(); ++j)
871 for (
unsigned int k = 0; k < i2.size(); ++k)
896 G.add(i1[j], i2[k], M(j, k));
902 template <
typename MatrixType>
907 const std::vector<types::global_dof_index> &i1,
908 const std::vector<types::global_dof_index> &i2,
909 const unsigned int level)
916 for (
unsigned int j = 0; j < i1.size(); ++j)
917 for (
unsigned int k = 0; k < i2.size(); ++k)
919 G.add(i1[j], i2[k], M(k, j));
923 for (
unsigned int j = 0; j < i1.size(); ++j)
924 for (
unsigned int k = 0; k < i2.size(); ++k)
927 G.add(i1[j], i2[k], M(k, j));
931 template <
typename MatrixType>
936 const std::vector<types::global_dof_index> &i1,
937 const std::vector<types::global_dof_index> &i2,
938 const unsigned int level)
945 for (
unsigned int j = 0; j < i1.size(); ++j)
946 for (
unsigned int k = 0; k < i2.size(); ++k)
948 G.add(i1[j], i2[k], M(j, k));
952 for (
unsigned int j = 0; j < i1.size(); ++j)
953 for (
unsigned int k = 0; k < i2.size(); ++k)
956 G.add(i1[j], i2[k], M(j, k));
960 template <
typename MatrixType>
965 const std::vector<types::global_dof_index> &i1,
966 const std::vector<types::global_dof_index> &i2,
967 const unsigned int level)
973 for (
unsigned int j = 0; j < i1.size(); ++j)
974 for (
unsigned int k = 0; k < i2.size(); ++k)
995 G.add(i1[j], i2[k], M(j, k));
1000 template <
typename MatrixType>
1005 const std::vector<types::global_dof_index> &i1,
1006 const std::vector<types::global_dof_index> &i2,
1007 const unsigned int level)
1013 for (
unsigned int j = 0; j < i1.size(); ++j)
1014 for (
unsigned int k = 0; k < i2.size(); ++k)
1024 G.add(i1[j], i2[k], M(k, j));
1029 template <
typename MatrixType>
1030 template <
class DOFINFO>
1035 const unsigned int level = info.cell->level();
1037 if (info.indices_by_block.empty())
1040 info.matrix(0,
false).matrix,
1047 info.matrix(0,
false).matrix,
1052 info.matrix(0,
false).matrix,
1059 for (
unsigned int k = 0; k < info.n_matrices(); ++k)
1061 const unsigned int row = info.matrix(k,
false).row;
1062 const unsigned int column = info.matrix(k,
false).column;
1065 info.matrix(k,
false).matrix,
1066 info.indices_by_block[row],
1067 info.indices_by_block[column],
1073 info.matrix(k,
false).matrix,
1074 info.indices_by_block[row],
1075 info.indices_by_block[column],
1078 info.matrix(k,
false).matrix,
1079 info.indices_by_block[column],
1080 info.indices_by_block[row],
1087 template <
typename MatrixType>
1088 template <
class DOFINFO>
1091 const DOFINFO &info2)
1095 const unsigned int level1 = info1.cell->level();
1096 const unsigned int level2 = info2.cell->level();
1098 if (info1.indices_by_block.empty())
1100 if (level1 == level2)
1103 info1.matrix(0,
false).matrix,
1108 info1.matrix(0,
true).matrix,
1113 info2.matrix(0,
false).matrix,
1118 info2.matrix(0,
true).matrix,
1130 info1.matrix(0,
false).matrix,
1137 info1.matrix(0,
true).matrix,
1142 info2.matrix(0,
true).matrix,
1150 for (
unsigned int k = 0; k < info1.n_matrices(); ++k)
1152 const unsigned int row = info1.matrix(k,
false).row;
1153 const unsigned int column = info1.matrix(k,
false).column;
1155 if (level1 == level2)
1158 info1.matrix(k,
false).matrix,
1159 info1.indices_by_block[row],
1160 info1.indices_by_block[column],
1163 info1.matrix(k,
true).matrix,
1164 info1.indices_by_block[row],
1165 info2.indices_by_block[column],
1168 info2.matrix(k,
false).matrix,
1169 info2.indices_by_block[row],
1170 info2.indices_by_block[column],
1173 info2.matrix(k,
true).matrix,
1174 info2.indices_by_block[row],
1175 info1.indices_by_block[column],
1185 info1.matrix(k,
false).matrix,
1186 info1.indices_by_block[row],
1187 info1.indices_by_block[column],
1192 info1.matrix(k,
true).matrix,
1193 info2.indices_by_block[column],
1194 info1.indices_by_block[row],
1197 info2.matrix(k,
true).matrix,
1198 info2.indices_by_block[row],
1199 info1.indices_by_block[column],
1208 template <
typename MatrixType,
typename VectorType>
1214 template <
typename MatrixType,
typename VectorType>
1220 VectorType *p = &rhs;
1221 data.
add(p,
"right hand side");
1227 template <
typename MatrixType,
typename VectorType>
1236 template <
typename MatrixType,
typename VectorType>
1237 template <
class DOFINFO>
1246 template <
typename MatrixType,
typename VectorType>
1251 const unsigned int index,
1252 const std::vector<types::global_dof_index> &indices)
1258 VectorType *v =
residuals.entry<VectorType *>(index);
1262 for (
unsigned int i = 0; i < indices.size(); ++i)
1263 (*v)(indices[i]) += vector(i);
1265 for (
unsigned int j = 0; j < indices.size(); ++j)
1266 for (
unsigned int k = 0; k < indices.size(); ++k)
1284 template <
typename MatrixType,
typename VectorType>
1289 const unsigned int index,
1290 const std::vector<types::global_dof_index> &i1,
1291 const std::vector<types::global_dof_index> &i2)
1297 VectorType *v =
residuals.entry<VectorType *>(index);
1301 for (
unsigned int j = 0; j < i1.size(); ++j)
1302 for (
unsigned int k = 0; k < i2.size(); ++k)
1311 vector, i1, i2, *v, M,
false);
1318 template <
typename MatrixType,
typename VectorType>
1319 template <
class DOFINFO>
1326 const unsigned int n = info.indices_by_block.size();
1330 for (
unsigned int m = 0; m < MatrixSimple<MatrixType>::matrix.size();
1332 assemble(info.matrix(m,
false).matrix,
1333 info.vector(m).block(0),
1339 for (
unsigned int m = 0; m < MatrixSimple<MatrixType>::matrix.size();
1341 for (
unsigned int k = 0; k < n * n; ++k)
1343 const unsigned int row = info.matrix(k + m * n * n,
false).row;
1344 const unsigned int column =
1345 info.matrix(k + m * n * n,
false).column;
1348 assemble(info.matrix(k + m * n * n,
false).matrix,
1349 info.vector(m).block(row),
1351 info.indices_by_block[row]);
1353 assemble(info.matrix(k + m * n * n,
false).matrix,
1354 info.vector(m).block(row),
1356 info.indices_by_block[row],
1357 info.indices_by_block[column]);
1363 template <
typename MatrixType,
typename VectorType>
1364 template <
class DOFINFO>
1367 const DOFINFO &info2)
1372 info2.indices_by_block.size());
1374 const unsigned int n = info1.indices_by_block.size();
1378 for (
unsigned int m = 0; m < MatrixSimple<MatrixType>::matrix.size();
1381 assemble(info1.matrix(m,
false).matrix,
1382 info1.vector(m).block(0),
1385 assemble(info1.matrix(m,
true).matrix,
1386 info1.vector(m).block(0),
1390 assemble(info2.matrix(m,
false).matrix,
1391 info2.vector(m).block(0),
1394 assemble(info2.matrix(m,
true).matrix,
1395 info2.vector(m).block(0),
1403 for (
unsigned int m = 0; m < MatrixSimple<MatrixType>::matrix.size();
1405 for (
unsigned int k = 0; k < n * n; ++k)
1407 const unsigned int row = info1.matrix(k + m * n * n,
false).row;
1408 const unsigned int column =
1409 info1.matrix(k + m * n * n,
false).column;
1413 assemble(info1.matrix(k + m * n * n,
false).matrix,
1414 info1.vector(m).block(row),
1416 info1.indices_by_block[row]);
1417 assemble(info2.matrix(k + m * n * n,
false).matrix,
1418 info2.vector(m).block(row),
1420 info2.indices_by_block[row]);
1424 assemble(info1.matrix(k + m * n * n,
false).matrix,
1425 info1.vector(m).block(row),
1427 info1.indices_by_block[row],
1428 info1.indices_by_block[column]);
1429 assemble(info2.matrix(k + m * n * n,
false).matrix,
1430 info2.vector(m).block(row),
1432 info2.indices_by_block[row],
1433 info2.indices_by_block[column]);
1435 assemble(info1.matrix(k + m * n * n,
true).matrix,
1436 info1.vector(m).block(row),
1438 info1.indices_by_block[row],
1439 info2.indices_by_block[column]);
1440 assemble(info2.matrix(k + m * n * n,
true).matrix,
1441 info2.vector(m).block(row),
1443 info2.indices_by_block[row],
1444 info1.indices_by_block[column]);
void add(type entry, const std::string &name)
Add a new data object.
void assemble_out(MatrixType &G, const FullMatrix< double > &M, const std::vector< types::global_dof_index > &i1, const std::vector< types::global_dof_index > &i2, const unsigned int level=numbers::invalid_unsigned_int)
ObserverPointer< MGLevelObject< MatrixType >, MGMatrixSimple< MatrixType > > flux_up
void initialize_fluxes(MGLevelObject< MatrixType > &flux_up, MGLevelObject< MatrixType > &flux_down)
void initialize_interfaces(MGLevelObject< MatrixType > &interface_in, MGLevelObject< MatrixType > &interface_out)
ObserverPointer< MGLevelObject< MatrixType >, MGMatrixSimple< MatrixType > > interface_in
ObserverPointer< MGLevelObject< MatrixType >, MGMatrixSimple< MatrixType > > flux_down
void assemble(const DOFINFO &info)
void initialize_info(DOFINFO &info, bool face) const
ObserverPointer< MGLevelObject< MatrixType >, MGMatrixSimple< MatrixType > > matrix
void assemble_in(MatrixType &G, const FullMatrix< double > &M, const std::vector< types::global_dof_index > &i1, const std::vector< types::global_dof_index > &i2, const unsigned int level=numbers::invalid_unsigned_int)
MGMatrixSimple(double threshold=1.e-12)
ObserverPointer< MGLevelObject< MatrixType >, MGMatrixSimple< MatrixType > > interface_out
void initialize(MGLevelObject< MatrixType > &m)
void assemble_down(MatrixType &G, const FullMatrix< double > &M, const std::vector< types::global_dof_index > &i1, const std::vector< types::global_dof_index > &i2, const unsigned int level=numbers::invalid_unsigned_int)
void assemble_up(MatrixType &G, const FullMatrix< double > &M, const std::vector< types::global_dof_index > &i1, const std::vector< types::global_dof_index > &i2, const unsigned int level=numbers::invalid_unsigned_int)
ObserverPointer< const MGConstrainedDoFs, MGMatrixSimple< MatrixType > > mg_constrained_dofs
std::vector< ObserverPointer< MatrixType, MatrixSimple< MatrixType > > > matrix
void initialize(MatrixType &m)
MatrixSimple(double threshold=1.e-12)
void initialize_info(DOFINFO &info, bool face) const
ObserverPointer< const AffineConstraints< typename MatrixType::value_type >, MatrixSimple< MatrixType > > constraints
void assemble(const DOFINFO &info)
void assemble(const DOFINFO &info)
void initialize_info(DOFINFO &info, bool face) const
ObserverPointer< const AffineConstraints< typename VectorType::value_type >, ResidualSimple< VectorType > > constraints
void initialize(AnyData &results)
SystemSimple(double threshold=1.e-12)
void assemble(const DOFINFO &info)
void initialize(MatrixType &m, VectorType &rhs)
void initialize_info(DOFINFO &info, bool face) const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcNotInitialized()
static ::ExceptionBase & ExcMessage(std::string arg1)
constexpr unsigned int invalid_unsigned_int