13 #ifndef __deal2__mesh_worker_assembler_h
14 #define __deal2__mesh_worker_assembler_h
79 template <
typename number =
double>
106 std::vector<number>
J1;
121 template <
typename number =
double>
148 std::vector<number>
J1;
149 std::vector<number>
J2;
176 template <
typename number =
double>
220 std::vector<BlockVector<number> >
R1;
226 std::vector<BlockVector<number> >
R2;
234 const std::vector<unsigned int>& dof);
255 template <
typename number>
265 unsigned int row,
unsigned int col,
266 unsigned int n_rows,
unsigned int n_cols);
274 template <
class MatrixPtr>
276 std::vector<MatrixPtr>& matrices);
285 std::vector<MatrixBlock<FullMatrix<number> > >
M11;
293 std::vector<MatrixBlock<FullMatrix<number> > >
M22;
304 std::vector<MatrixBlock<FullMatrix<number> > >
M12;
315 std::vector<MatrixBlock<FullMatrix<number> > >
M21;
352 template <
class MATRIX,
typename number =
double>
359 typedef boost::shared_ptr<MatrixBlock<MATRIX> >
MatrixPtr;
404 unsigned int block_row,
405 unsigned int block_col,
406 const std::vector<unsigned int>& dof1,
407 const std::vector<unsigned int>& dof2);
452 template <
class MATRIX,
typename number =
double>
458 typedef boost::shared_ptr<MatrixBlock<MGLevelObject<MATRIX> > >
MatrixPtr;
516 unsigned int block_row,
517 unsigned int block_col,
518 const std::vector<unsigned int>& dof1,
519 const std::vector<unsigned int>& dof2,
522 bool transpose =
false);
560 template <
typename number>
569 template <
typename number>
574 for (
unsigned int i=0;i<results.size();++i)
582 template <
typename number>
588 for (
unsigned int i=0;i<results.size();++i)
596 template <
typename number>
600 AssertIndexRange(i, results.size());
606 template <
typename number>
610 Assert(r.vector_name(0) ==
"cells", FEVectors::ExcNameMismatch(0,
"cells"));
611 Assert(r.vector_name(1) ==
"faces", FEVectors::ExcNameMismatch(1,
"faces"));
612 AssertDimension(r.vector(0).n_blocks(), r.vector(1).n_blocks());
615 separate_faces = sep;
617 J1.resize(results.vector(0).n_blocks());
618 J2.resize(results.vector(0).n_blocks());
622 template <
typename number>
627 for (
unsigned int i=0;i<J1.size();++i)
629 if (separate_faces &&
630 info.
face_number != deal_II_numbers::invalid_unsigned_int)
631 results.vector(1).block(i)(info.
face->user_index()) += J1[i];
634 results.vector(0).block(i)(info.
cell->user_index()) += J1[i];
640 template <
typename number>
646 for (
unsigned int i=0;i<J1.size();++i)
650 results.vector(1).block(i)(info1.
face->user_index()) += J1[i];
652 results.vector(1).block(i)(info2.
face->user_index()) += J1[i];
657 results.vector(0).block(i)(info1.
cell->user_index()) += J1[i];
658 results.vector(0).block(i)(info2.
cell->user_index()) += J2[i];
668 template <
typename number>
677 Assert(block_info.local.size() != 0, ExcNotInitialized());
679 R1.resize(residuals.n_vectors());
680 R2.resize(residuals.n_vectors());
681 for (
unsigned int i=0;i<R1.size();++i)
683 R1[i].reinit(block_info.local);
684 R2[i].reinit(block_info.local);
689 template <
typename number>
694 const std::vector<unsigned int>& dof)
696 for (
unsigned int b=0;b<local.n_blocks();++b)
697 for (
unsigned int j=0;j<local.block(b).size();++j)
707 const unsigned int jcell = this->block_info.local.local_to_global(b, j);
708 global(dof[jcell]) += local.block(b)(j);
713 template <
typename number>
719 for (
unsigned int i=0;i<residuals.n_vectors();++i)
721 assemble(residuals.vector(i), R1[i], info.
indices);
727 template <
typename number>
734 for (
unsigned int i=0;i<residuals.n_vectors();++i)
736 assemble(residuals.vector(i), R1[i], info1.
indices);
737 assemble(residuals.vector(i), R2[i], info2.
indices);
747 template <
typename number>
751 unsigned int row,
unsigned int col,
752 unsigned int n_rows,
unsigned int n_cols)
756 M.matrix.reinit(n_rows, n_cols);
759 template <
typename number>
760 template <
class MatrixPtr>
764 std::vector<MatrixPtr>& matrices)
768 M11.resize(matrices.size());
769 M12.resize(matrices.size());
770 M21.resize(matrices.size());
771 M22.resize(matrices.size());
773 for (
unsigned int i=0;i<matrices.size();++i)
775 const unsigned int row = matrices[i]->row;
776 const unsigned int col = matrices[i]->column;
777 const unsigned int n_rows = block_info.
local.block_size(row);
778 const unsigned int n_cols = block_info.local.block_size(col);
780 initialize_local(M11[i], row, col, n_rows, n_cols);
781 initialize_local(M12[i], row, col, n_rows, n_cols);
782 initialize_local(M21[i], row, col, n_rows, n_cols);
783 initialize_local(M22[i], row, col, n_rows, n_cols);
790 template <
class MATRIX,
typename number>
799 template <
class MATRIX,
typename number>
803 std::vector<MatrixPtr>& m)
811 template <
class MATRIX,
typename number>
816 unsigned int block_row,
817 unsigned int block_col,
818 const std::vector<unsigned int>& dof1,
819 const std::vector<unsigned int>& dof2)
821 for (
unsigned int j=0;j<local.n_rows();++j)
822 for (
unsigned int k=0;k<local.n_cols();++k)
823 if (std::fabs(local(j,k)) >= threshold)
833 const unsigned int jcell = this->block_info.local.local_to_global(block_row, j);
834 const unsigned int kcell = this->block_info.local.local_to_global(block_col, k);
844 const unsigned int jglobal = this->block_info.global.global_to_local(dof1[jcell]).second;
845 const unsigned int kglobal = this->block_info.global.global_to_local(dof2[kcell]).second;
847 global.add(jglobal, kglobal, local(j,k));
852 template <
class MATRIX,
typename number>
858 for (
unsigned int i=0;i<matrices.size();++i)
862 const unsigned int row = matrices[i]->row;
863 const unsigned int col = matrices[i]->column;
865 assemble(matrices[i]->matrix, this->M11[i].matrix, row, col, info.
indices, info.
indices);
866 this->M11[i].matrix = 0.;
871 template <
class MATRIX,
typename number>
878 for (
unsigned int i=0;i<matrices.size();++i)
882 const unsigned int row = matrices[i]->row;
883 const unsigned int col = matrices[i]->column;
885 assemble(matrices[i]->matrix, this->M11[i].matrix, row, col, info1.
indices, info1.
indices);
886 assemble(matrices[i]->matrix, this->M12[i].matrix, row, col, info1.
indices, info2.
indices);
887 assemble(matrices[i]->matrix, this->M21[i].matrix, row, col, info2.
indices, info1.
indices);
888 assemble(matrices[i]->matrix, this->M22[i].matrix, row, col, info2.
indices, info2.
indices);
890 this->M11[i].matrix = 0.;
891 this->M12[i].matrix = 0.;
892 this->M21[i].matrix = 0.;
893 this->M22[i].matrix = 0.;
900 template <
class MATRIX,
typename number>
909 template <
class MATRIX,
typename number>
913 std::vector<MatrixPtr>& m)
920 template <
class MATRIX,
typename number>
923 std::vector<MatrixPtr>& up,
924 std::vector<MatrixPtr>& down)
931 template <
class MATRIX,
typename number>
936 unsigned int block_row,
937 unsigned int block_col,
938 const std::vector<unsigned int>& dof1,
939 const std::vector<unsigned int>& dof2,
944 for (
unsigned int j=0;j<local.n_rows();++j)
945 for (
unsigned int k=0;k<local.n_cols();++k)
946 if (std::fabs(local(j,k)) >= threshold)
956 const unsigned int jcell = this->block_info.local.local_to_global(block_row, j);
957 const unsigned int kcell = this->block_info.local.local_to_global(block_col, k);
967 const unsigned int jglobal = this->block_info.levels[level1].global_to_local(dof1[jcell]).second;
968 const unsigned int kglobal = this->block_info.levels[level2].global_to_local(dof2[kcell]).second;
971 global.add(kglobal, jglobal, local(j,k));
973 global.add(jglobal, kglobal, local(j,k));
978 template <
class MATRIX,
typename number>
984 const unsigned int level = info.
cell->level();
986 for (
unsigned int i=0;i<matrices.size();++i)
990 const unsigned int row = matrices[i]->row;
991 const unsigned int col = matrices[i]->column;
993 assemble(matrices[i]->matrix[level], this->M11[i].matrix, row, col,
996 this->M11[i].matrix = 0.;
1001 template <
class MATRIX,
typename number>
1008 const unsigned int level1 = info1.
cell->level();
1009 const unsigned int level2 = info2.
cell->level();
1011 for (
unsigned int i=0;i<matrices.size();++i)
1015 const unsigned int row = matrices[i]->row;
1016 const unsigned int col = matrices[i]->column;
1018 if (level1 == level2)
1020 assemble(matrices[i]->matrix[level1], this->M11[i].matrix, row, col, info1.
indices, info1.
indices, level1, level1);
1021 assemble(matrices[i]->matrix[level1], this->M12[i].matrix, row, col, info1.
indices, info2.
indices, level1, level2);
1022 assemble(matrices[i]->matrix[level1], this->M21[i].matrix, row, col, info2.
indices, info1.
indices, level2, level1);
1023 assemble(matrices[i]->matrix[level1], this->M22[i].matrix, row, col, info2.
indices, info2.
indices, level2, level2);
1027 Assert(level1 > level2, ExcNotImplemented());
1028 if (flux_up.size() != 0)
1033 assemble(matrices[i]->matrix[level1], this->M11[i].matrix, row, col,
1035 assemble(flux_up[i]->matrix[level1], this->M12[i].matrix, row, col,
1037 assemble(flux_down[i]->matrix[level1], this->M21[i].matrix, row, col,
1042 this->M11[i].matrix = 0.;
1043 this->M12[i].matrix = 0.;
1044 this->M21[i].matrix = 0.;
1045 this->M22[i].matrix = 0.;