Reference documentation for deal.II version Git 32ab9f15fd 2020-11-24 23:04:10 -0500
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
operators.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2011 - 2020 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 
17 #ifndef dealii_matrix_free_operators_h
18 #define dealii_matrix_free_operators_h
19 
20 
21 #include <deal.II/base/config.h>
22 
26 
29 
32 
34 
35 
37 
38 
40 {
41  namespace BlockHelper
42  {
43  // workaroud for unifying non-block vector and block vector implementations
44  // a non-block vector has one block and the only subblock is the vector
45  // itself
46  template <typename VectorType>
47  typename std::enable_if<IsBlockVector<VectorType>::value,
48  unsigned int>::type
49  n_blocks(const VectorType &vector)
50  {
51  return vector.n_blocks();
52  }
53 
54  template <typename VectorType>
55  typename std::enable_if<!IsBlockVector<VectorType>::value,
56  unsigned int>::type
58  {
59  return 1;
60  }
61 
62  template <typename VectorType>
63  typename std::enable_if<IsBlockVector<VectorType>::value,
64  typename VectorType::BlockType &>::type
65  subblock(VectorType &vector, unsigned int block_no)
66  {
67  return vector.block(block_no);
68  }
69 
70  template <typename VectorType>
71  typename std::enable_if<IsBlockVector<VectorType>::value,
72  const typename VectorType::BlockType &>::type
73  subblock(const VectorType &vector, unsigned int block_no)
74  {
75  AssertIndexRange(block_no, vector.n_blocks());
76  return vector.block(block_no);
77  }
78 
79  template <typename VectorType>
80  typename std::enable_if<!IsBlockVector<VectorType>::value,
81  VectorType &>::type
82  subblock(VectorType &vector, unsigned int)
83  {
84  return vector;
85  }
86 
87  template <typename VectorType>
88  typename std::enable_if<!IsBlockVector<VectorType>::value,
89  const VectorType &>::type
90  subblock(const VectorType &vector, unsigned int)
91  {
92  return vector;
93  }
94 
95  template <typename VectorType>
96  typename std::enable_if<IsBlockVector<VectorType>::value, void>::type
98  {
99  vector.collect_sizes();
100  }
101 
102  template <typename VectorType>
103  typename std::enable_if<!IsBlockVector<VectorType>::value, void>::type
105  {}
106  } // namespace BlockHelper
107 
185  template <int dim,
187  typename VectorizedArrayType =
189  class Base : public Subscriptor
190  {
191  public:
195  using value_type = typename VectorType::value_type;
196 
201 
205  Base();
206 
210  virtual ~Base() override = default;
211 
216  virtual void
217  clear();
218 
235  void
236  initialize(std::shared_ptr<
238  const std::vector<unsigned int> &selected_row_blocks =
239  std::vector<unsigned int>(),
240  const std::vector<unsigned int> &selected_column_blocks =
241  std::vector<unsigned int>());
242 
256  void
257  initialize(std::shared_ptr<
259  const MGConstrainedDoFs & mg_constrained_dofs,
260  const unsigned int level,
261  const std::vector<unsigned int> &selected_row_blocks =
262  std::vector<unsigned int>());
263 
278  void
279  initialize(std::shared_ptr<
281  const std::vector<MGConstrainedDoFs> &mg_constrained_dofs,
282  const unsigned int level,
283  const std::vector<unsigned int> & selected_row_blocks =
284  std::vector<unsigned int>());
285 
289  size_type
290  m() const;
291 
295  size_type
296  n() const;
297 
301  void
302  vmult_interface_down(VectorType &dst, const VectorType &src) const;
303 
307  void
308  vmult_interface_up(VectorType &dst, const VectorType &src) const;
309 
313  void
314  vmult(VectorType &dst, const VectorType &src) const;
315 
319  void
320  Tvmult(VectorType &dst, const VectorType &src) const;
321 
325  void
326  vmult_add(VectorType &dst, const VectorType &src) const;
327 
331  void
332  Tvmult_add(VectorType &dst, const VectorType &src) const;
333 
338  value_type
339  el(const unsigned int row, const unsigned int col) const;
340 
345  virtual std::size_t
346  memory_consumption() const;
347 
351  void
352  initialize_dof_vector(VectorType &vec) const;
353 
361  virtual void
362  compute_diagonal() = 0;
363 
367  std::shared_ptr<const MatrixFree<dim, value_type, VectorizedArrayType>>
368  get_matrix_free() const;
369 
373  const std::shared_ptr<DiagonalMatrix<VectorType>> &
374  get_matrix_diagonal_inverse() const;
375 
379  const std::shared_ptr<DiagonalMatrix<VectorType>> &
380  get_matrix_diagonal() const;
381 
382 
388  void
389  precondition_Jacobi(VectorType & dst,
390  const VectorType &src,
391  const value_type omega) const;
392 
393  protected:
398  void
399  preprocess_constraints(VectorType &dst, const VectorType &src) const;
400 
405  void
406  postprocess_constraints(VectorType &dst, const VectorType &src) const;
407 
412  void
413  set_constrained_entries_to_one(VectorType &dst) const;
414 
418  virtual void
419  apply_add(VectorType &dst, const VectorType &src) const = 0;
420 
426  virtual void
427  Tapply_add(VectorType &dst, const VectorType &src) const;
428 
432  std::shared_ptr<const MatrixFree<dim, value_type, VectorizedArrayType>>
434 
439  std::shared_ptr<DiagonalMatrix<VectorType>> diagonal_entries;
440 
445  std::shared_ptr<DiagonalMatrix<VectorType>> inverse_diagonal_entries;
446 
451  std::vector<unsigned int> selected_rows;
452 
457  std::vector<unsigned int> selected_columns;
458 
459  private:
463  std::vector<std::vector<unsigned int>> edge_constrained_indices;
464 
468  mutable std::vector<std::vector<std::pair<value_type, value_type>>>
470 
476 
481  void
482  mult_add(VectorType & dst,
483  const VectorType &src,
484  const bool transpose) const;
485 
493  void
494  adjust_ghost_range_if_necessary(const VectorType &vec,
495  const bool is_row) const;
496  };
497 
498 
499 
534  template <typename OperatorType>
536  {
537  public:
541  using value_type = typename OperatorType::value_type;
542 
547 
552 
556  void
557  clear();
558 
562  void
563  initialize(const OperatorType &operator_in);
564 
568  template <typename VectorType>
569  void
570  vmult(VectorType &dst, const VectorType &src) const;
571 
575  template <typename VectorType>
576  void
577  Tvmult(VectorType &dst, const VectorType &src) const;
578 
582  template <typename VectorType>
583  void
584  initialize_dof_vector(VectorType &vec) const;
585 
586 
587  private:
592  };
593 
594 
595 
613  template <int dim,
614  int fe_degree,
615  int n_components = 1,
616  typename Number = double,
617  typename VectorizedArrayType = VectorizedArray<Number>>
619  {
620  static_assert(
621  std::is_same<Number, typename VectorizedArrayType::value_type>::value,
622  "Type of Number and of VectorizedArrayType do not match.");
623 
624  public:
630  const FEEvaluationBase<dim,
631  n_components,
632  Number,
633  false,
634  VectorizedArrayType> &fe_eval);
635 
644  void
645  apply(const AlignedVector<VectorizedArrayType> &inverse_coefficient,
646  const unsigned int n_actual_components,
647  const VectorizedArrayType * in_array,
648  VectorizedArrayType * out_array) const;
649 
661  void
662  apply(const VectorizedArrayType *in_array,
663  VectorizedArrayType * out_array) const;
664 
698  void
699  transform_from_q_points_to_basis(const unsigned int n_actual_components,
700  const VectorizedArrayType *in_array,
701  VectorizedArrayType *out_array) const;
702 
708  void
709  fill_inverse_JxW_values(
710  AlignedVector<VectorizedArrayType> &inverse_jxw) const;
711 
712  private:
716  const FEEvaluationBase<dim,
717  n_components,
718  Number,
719  false,
720  VectorizedArrayType> &fe_eval;
721  };
722 
723 
724 
732  template <int dim,
733  int fe_degree,
734  int n_q_points_1d = fe_degree + 1,
735  int n_components = 1,
736  typename VectorType = LinearAlgebra::distributed::Vector<double>,
737  typename VectorizedArrayType =
739  class MassOperator : public Base<dim, VectorType, VectorizedArrayType>
740  {
741  public:
745  using value_type =
747 
751  using size_type =
753 
757  MassOperator();
758 
763  virtual void
764  compute_diagonal() override;
765 
766  private:
772  virtual void
773  apply_add(VectorType &dst, const VectorType &src) const override;
774 
778  void
779  local_apply_cell(
781  VectorType & dst,
782  const VectorType & src,
783  const std::pair<unsigned int, unsigned int> & cell_range) const;
784  };
785 
786 
787 
798  template <int dim,
799  int fe_degree,
800  int n_q_points_1d = fe_degree + 1,
801  int n_components = 1,
802  typename VectorType = LinearAlgebra::distributed::Vector<double>,
803  typename VectorizedArrayType =
805  class LaplaceOperator : public Base<dim, VectorType, VectorizedArrayType>
806  {
807  public:
811  using value_type =
813 
817  using size_type =
819 
823  LaplaceOperator();
824 
831  virtual void
832  compute_diagonal() override;
833 
884  void
885  set_coefficient(
886  const std::shared_ptr<Table<2, VectorizedArrayType>> &scalar_coefficient);
887 
892  virtual void
893  clear() override;
894 
901  std::shared_ptr<Table<2, VectorizedArrayType>>
902  get_coefficient();
903 
904  private:
910  virtual void
911  apply_add(VectorType &dst, const VectorType &src) const override;
912 
916  void
917  local_apply_cell(
919  VectorType & dst,
920  const VectorType & src,
921  const std::pair<unsigned int, unsigned int> & cell_range) const;
922 
926  void
927  local_diagonal_cell(
929  VectorType & dst,
930  const VectorType &,
931  const std::pair<unsigned int, unsigned int> &cell_range) const;
932 
936  void
937  do_operation_on_cell(
939  & phi,
940  const unsigned int cell) const;
941 
945  std::shared_ptr<Table<2, VectorizedArrayType>> scalar_coefficient;
946  };
947 
948 
949 
950  // ------------------------------------ inline functions ---------------------
951 
952  template <int dim,
953  int fe_degree,
954  int n_components,
955  typename Number,
956  typename VectorizedArrayType>
957  inline CellwiseInverseMassMatrix<dim,
958  fe_degree,
959  n_components,
960  Number,
961  VectorizedArrayType>::
962  CellwiseInverseMassMatrix(
963  const FEEvaluationBase<dim,
964  n_components,
965  Number,
966  false,
967  VectorizedArrayType> &fe_eval)
968  : fe_eval(fe_eval)
969  {}
970 
971 
972 
973  template <int dim,
974  int fe_degree,
975  int n_components,
976  typename Number,
977  typename VectorizedArrayType>
978  inline void
980  fe_degree,
981  n_components,
982  Number,
983  VectorizedArrayType>::
985  AlignedVector<VectorizedArrayType> &inverse_jxw) const
986  {
987  constexpr unsigned int dofs_per_component_on_cell =
988  Utilities::pow(fe_degree + 1, dim);
989  Assert(inverse_jxw.size() > 0 &&
990  inverse_jxw.size() % dofs_per_component_on_cell == 0,
991  ExcMessage(
992  "Expected diagonal to be a multiple of scalar dof per cells"));
993 
994  // compute values for the first component
995  for (unsigned int q = 0; q < dofs_per_component_on_cell; ++q)
996  inverse_jxw[q] = 1. / fe_eval.JxW(q);
997  // copy values to rest of vector
998  for (unsigned int q = dofs_per_component_on_cell; q < inverse_jxw.size();)
999  for (unsigned int i = 0; i < dofs_per_component_on_cell; ++i, ++q)
1000  inverse_jxw[q] = inverse_jxw[i];
1001  }
1002 
1003 
1004 
1005  template <int dim,
1006  int fe_degree,
1007  int n_components,
1008  typename Number,
1009  typename VectorizedArrayType>
1010  inline void
1012  dim,
1013  fe_degree,
1014  n_components,
1015  Number,
1016  VectorizedArrayType>::apply(const VectorizedArrayType *in_array,
1017  VectorizedArrayType * out_array) const
1018  {
1020  template run<fe_degree>(n_components, fe_eval, in_array, out_array);
1021  }
1022 
1023 
1024 
1025  template <int dim,
1026  int fe_degree,
1027  int n_components,
1028  typename Number,
1029  typename VectorizedArrayType>
1030  inline void
1032  fe_degree,
1033  n_components,
1034  Number,
1035  VectorizedArrayType>::
1036  apply(const AlignedVector<VectorizedArrayType> &inverse_coefficients,
1037  const unsigned int n_actual_components,
1038  const VectorizedArrayType * in_array,
1039  VectorizedArrayType * out_array) const
1040  {
1042  template run<fe_degree>(
1043  n_actual_components,
1044  fe_eval.get_shape_info().data.front().inverse_shape_values_eo,
1045  inverse_coefficients,
1046  in_array,
1047  out_array);
1048  }
1049 
1050 
1051 
1052  template <int dim,
1053  int fe_degree,
1054  int n_components,
1055  typename Number,
1056  typename VectorizedArrayType>
1057  inline void
1059  fe_degree,
1060  n_components,
1061  Number,
1062  VectorizedArrayType>::
1063  transform_from_q_points_to_basis(const unsigned int n_actual_components,
1064  const VectorizedArrayType *in_array,
1065  VectorizedArrayType * out_array) const
1066  {
1068  dim,
1069  VectorizedArrayType>::template run<fe_degree>(n_actual_components,
1071  .data.front()
1072  .inverse_shape_values_eo,
1073  in_array,
1074  out_array);
1075  }
1076 
1077 
1078 
1079  //----------------- Base operator -----------------------------
1080  template <int dim, typename VectorType, typename VectorizedArrayType>
1082  : Subscriptor()
1083  , have_interface_matrices(false)
1084  {}
1085 
1086 
1087 
1088  template <int dim, typename VectorType, typename VectorizedArrayType>
1091  {
1092  Assert(data.get() != nullptr, ExcNotInitialized());
1094  0;
1095  for (const unsigned int selected_row : selected_rows)
1096  total_size += data->get_vector_partitioner(selected_row)->size();
1097  return total_size;
1098  }
1099 
1100 
1101 
1102  template <int dim, typename VectorType, typename VectorizedArrayType>
1105  {
1106  Assert(data.get() != nullptr, ExcNotInitialized());
1108  0;
1109  for (const unsigned int selected_column : selected_columns)
1110  total_size += data->get_vector_partitioner(selected_column)->size();
1111  return total_size;
1112  }
1113 
1114 
1115 
1116  template <int dim, typename VectorType, typename VectorizedArrayType>
1117  void
1119  {
1120  data.reset();
1121  inverse_diagonal_entries.reset();
1122  }
1123 
1124 
1125 
1126  template <int dim, typename VectorType, typename VectorizedArrayType>
1129  const unsigned int col) const
1130  {
1131  (void)col;
1132  Assert(row == col, ExcNotImplemented());
1133  Assert(inverse_diagonal_entries.get() != nullptr &&
1134  inverse_diagonal_entries->m() > 0,
1135  ExcNotInitialized());
1136  return 1.0 / (*inverse_diagonal_entries)(row, row);
1137  }
1138 
1139 
1140 
1141  template <int dim, typename VectorType, typename VectorizedArrayType>
1142  void
1144  VectorType &vec) const
1145  {
1146  Assert(data.get() != nullptr, ExcNotInitialized());
1148  for (unsigned int i = 0; i < BlockHelper::n_blocks(vec); ++i)
1149  {
1150  const unsigned int index = selected_rows[i];
1151  if (!BlockHelper::subblock(vec, index)
1152  .partitioners_are_compatible(
1153  *data->get_dof_info(index).vector_partitioner))
1154  data->initialize_dof_vector(BlockHelper::subblock(vec, index), index);
1155 
1156  Assert(BlockHelper::subblock(vec, index)
1157  .partitioners_are_globally_compatible(
1158  *data->get_dof_info(index).vector_partitioner),
1159  ExcInternalError());
1160  }
1162  }
1163 
1164 
1165 
1166  template <int dim, typename VectorType, typename VectorizedArrayType>
1167  void
1170  data_,
1171  const std::vector<unsigned int> &given_row_selection,
1172  const std::vector<unsigned int> &given_column_selection)
1173  {
1174  data = data_;
1175 
1176  selected_rows.clear();
1177  selected_columns.clear();
1178  if (given_row_selection.empty())
1179  for (unsigned int i = 0; i < data_->n_components(); ++i)
1180  selected_rows.push_back(i);
1181  else
1182  {
1183  for (unsigned int i = 0; i < given_row_selection.size(); ++i)
1184  {
1185  AssertIndexRange(given_row_selection[i], data_->n_components());
1186  for (unsigned int j = 0; j < given_row_selection.size(); ++j)
1187  if (j != i)
1188  Assert(given_row_selection[j] != given_row_selection[i],
1189  ExcMessage("Given row indices must be unique"));
1190 
1191  selected_rows.push_back(given_row_selection[i]);
1192  }
1193  }
1194  if (given_column_selection.size() == 0)
1196  else
1197  {
1198  for (unsigned int i = 0; i < given_column_selection.size(); ++i)
1199  {
1200  AssertIndexRange(given_column_selection[i], data_->n_components());
1201  for (unsigned int j = 0; j < given_column_selection.size(); ++j)
1202  if (j != i)
1203  Assert(given_column_selection[j] != given_column_selection[i],
1204  ExcMessage("Given column indices must be unique"));
1205 
1206  selected_columns.push_back(given_column_selection[i]);
1207  }
1208  }
1209 
1210  edge_constrained_indices.clear();
1211  edge_constrained_indices.resize(selected_rows.size());
1212  edge_constrained_values.clear();
1213  edge_constrained_values.resize(selected_rows.size());
1214  have_interface_matrices = false;
1215  }
1216 
1217 
1218 
1219  template <int dim, typename VectorType, typename VectorizedArrayType>
1220  void
1223  data_,
1224  const MGConstrainedDoFs & mg_constrained_dofs,
1225  const unsigned int level,
1226  const std::vector<unsigned int> &given_row_selection)
1227  {
1228  std::vector<MGConstrainedDoFs> mg_constrained_dofs_vector(
1229  1, mg_constrained_dofs);
1230  initialize(data_, mg_constrained_dofs_vector, level, given_row_selection);
1231  }
1232 
1233 
1234 
1235  template <int dim, typename VectorType, typename VectorizedArrayType>
1236  void
1239  data_,
1240  const std::vector<MGConstrainedDoFs> &mg_constrained_dofs,
1241  const unsigned int level,
1242  const std::vector<unsigned int> & given_row_selection)
1243  {
1245  ExcMessage("level is not set"));
1246 
1247  selected_rows.clear();
1248  selected_columns.clear();
1249  if (given_row_selection.empty())
1250  for (unsigned int i = 0; i < data_->n_components(); ++i)
1251  selected_rows.push_back(i);
1252  else
1253  {
1254  for (unsigned int i = 0; i < given_row_selection.size(); ++i)
1255  {
1256  AssertIndexRange(given_row_selection[i], data_->n_components());
1257  for (unsigned int j = 0; j < given_row_selection.size(); ++j)
1258  if (j != i)
1259  Assert(given_row_selection[j] != given_row_selection[i],
1260  ExcMessage("Given row indices must be unique"));
1261 
1262  selected_rows.push_back(given_row_selection[i]);
1263  }
1264  }
1266 
1267  AssertDimension(mg_constrained_dofs.size(), selected_rows.size());
1268  edge_constrained_indices.clear();
1269  edge_constrained_indices.resize(selected_rows.size());
1270  edge_constrained_values.clear();
1271  edge_constrained_values.resize(selected_rows.size());
1272 
1273  data = data_;
1274 
1275  for (unsigned int j = 0; j < selected_rows.size(); ++j)
1276  {
1277  if (data_->n_cell_batches() > 0)
1278  {
1279  AssertDimension(level, data_->get_cell_iterator(0, 0, j)->level());
1280  }
1281 
1282  // setup edge_constrained indices
1283  std::vector<types::global_dof_index> interface_indices;
1284  mg_constrained_dofs[j]
1285  .get_refinement_edge_indices(level)
1286  .fill_index_vector(interface_indices);
1287  edge_constrained_indices[j].clear();
1288  edge_constrained_indices[j].reserve(interface_indices.size());
1289  edge_constrained_values[j].resize(interface_indices.size());
1290  const IndexSet &locally_owned =
1291  data->get_dof_handler(selected_rows[j]).locally_owned_mg_dofs(level);
1292  for (const auto interface_index : interface_indices)
1293  if (locally_owned.is_element(interface_index))
1294  edge_constrained_indices[j].push_back(
1295  locally_owned.index_within_set(interface_index));
1298  static_cast<unsigned int>(edge_constrained_indices[j].size()),
1299  data->get_vector_partitioner()->get_mpi_communicator()) > 0;
1300  }
1301  }
1302 
1303 
1304 
1305  template <int dim, typename VectorType, typename VectorizedArrayType>
1306  void
1308  VectorType &dst) const
1309  {
1310  for (unsigned int j = 0; j < BlockHelper::n_blocks(dst); ++j)
1311  {
1312  const std::vector<unsigned int> &constrained_dofs =
1313  data->get_constrained_dofs(selected_rows[j]);
1314  for (const auto constrained_dof : constrained_dofs)
1315  BlockHelper::subblock(dst, j).local_element(constrained_dof) = 1.;
1316  for (unsigned int i = 0; i < edge_constrained_indices[j].size(); ++i)
1317  BlockHelper::subblock(dst, j).local_element(
1318  edge_constrained_indices[j][i]) = 1.;
1319  }
1320  }
1321 
1322 
1323 
1324  template <int dim, typename VectorType, typename VectorizedArrayType>
1325  void
1327  const VectorType &src) const
1328  {
1329  using Number =
1331  dst = Number(0.);
1332  vmult_add(dst, src);
1333  }
1334 
1335 
1336 
1337  template <int dim, typename VectorType, typename VectorizedArrayType>
1338  void
1340  VectorType & dst,
1341  const VectorType &src) const
1342  {
1343  mult_add(dst, src, false);
1344  }
1345 
1346 
1347 
1348  template <int dim, typename VectorType, typename VectorizedArrayType>
1349  void
1351  VectorType & dst,
1352  const VectorType &src) const
1353  {
1354  mult_add(dst, src, true);
1355  }
1356 
1357 
1358 
1359  template <int dim, typename VectorType, typename VectorizedArrayType>
1360  void
1362  const VectorType &src,
1363  const bool is_row) const
1364  {
1365  using Number =
1367  for (unsigned int i = 0; i < BlockHelper::n_blocks(src); ++i)
1368  {
1369  const unsigned int mf_component =
1370  is_row ? selected_rows[i] : selected_columns[i];
1371  // If both vectors use the same partitioner -> done
1372  if (BlockHelper::subblock(src, i).get_partitioner().get() ==
1373  data->get_dof_info(mf_component).vector_partitioner.get())
1374  continue;
1375 
1376  // If not, assert that the local ranges are the same and reset to the
1377  // current partitioner
1378  Assert(
1379  BlockHelper::subblock(src, i).get_partitioner()->local_size() ==
1380  data->get_dof_info(mf_component).vector_partitioner->local_size(),
1381  ExcMessage("The vector passed to the vmult() function does not have "
1382  "the correct size for compatibility with MatrixFree."));
1383 
1384  // copy the vector content to a temporary vector so that it does not get
1385  // lost
1387  BlockHelper::subblock(src, i));
1388  this->data->initialize_dof_vector(
1389  BlockHelper::subblock(const_cast<VectorType &>(src), i),
1390  mf_component);
1391  BlockHelper::subblock(const_cast<VectorType &>(src), i)
1392  .copy_locally_owned_data_from(copy_vec);
1393  }
1394  }
1395 
1396 
1397 
1398  template <int dim, typename VectorType, typename VectorizedArrayType>
1399  void
1401  VectorType & dst,
1402  const VectorType &src) const
1403  {
1404  using Number =
1406  adjust_ghost_range_if_necessary(src, false);
1408 
1409  // set zero Dirichlet values on the input vector (and remember the src and
1410  // dst values because we need to reset them at the end)
1411  for (unsigned int j = 0; j < BlockHelper::n_blocks(dst); ++j)
1412  {
1413  for (unsigned int i = 0; i < edge_constrained_indices[j].size(); ++i)
1414  {
1415  edge_constrained_values[j][i] = std::pair<Number, Number>(
1416  BlockHelper::subblock(src, j).local_element(
1417  edge_constrained_indices[j][i]),
1418  BlockHelper::subblock(dst, j).local_element(
1419  edge_constrained_indices[j][i]));
1420  BlockHelper::subblock(const_cast<VectorType &>(src), j)
1421  .local_element(edge_constrained_indices[j][i]) = 0.;
1422  }
1423  }
1424  }
1425 
1426 
1427 
1428  template <int dim, typename VectorType, typename VectorizedArrayType>
1429  void
1431  VectorType & dst,
1432  const VectorType &src,
1433  const bool transpose) const
1434  {
1435  AssertDimension(dst.size(), src.size());
1438  preprocess_constraints(dst, src);
1439  if (transpose)
1440  Tapply_add(dst, src);
1441  else
1442  apply_add(dst, src);
1443  postprocess_constraints(dst, src);
1444  }
1445 
1446 
1447 
1448  template <int dim, typename VectorType, typename VectorizedArrayType>
1449  void
1451  VectorType & dst,
1452  const VectorType &src) const
1453  {
1454  for (unsigned int j = 0; j < BlockHelper::n_blocks(dst); ++j)
1455  {
1456  const std::vector<unsigned int> &constrained_dofs =
1457  data->get_constrained_dofs(selected_rows[j]);
1458  for (const auto constrained_dof : constrained_dofs)
1459  BlockHelper::subblock(dst, j).local_element(constrained_dof) +=
1460  BlockHelper::subblock(src, j).local_element(constrained_dof);
1461  }
1462 
1463  // reset edge constrained values, multiply by unit matrix and add into
1464  // destination
1465  for (unsigned int j = 0; j < BlockHelper::n_blocks(dst); ++j)
1466  {
1467  for (unsigned int i = 0; i < edge_constrained_indices[j].size(); ++i)
1468  {
1469  BlockHelper::subblock(const_cast<VectorType &>(src), j)
1470  .local_element(edge_constrained_indices[j][i]) =
1471  edge_constrained_values[j][i].first;
1472  BlockHelper::subblock(dst, j).local_element(
1473  edge_constrained_indices[j][i]) =
1474  edge_constrained_values[j][i].second +
1475  edge_constrained_values[j][i].first;
1476  }
1477  }
1478  }
1479 
1480 
1481 
1482  template <int dim, typename VectorType, typename VectorizedArrayType>
1483  void
1485  VectorType & dst,
1486  const VectorType &src) const
1487  {
1488  using Number =
1490  AssertDimension(dst.size(), src.size());
1491  adjust_ghost_range_if_necessary(src, false);
1493 
1494  dst = Number(0.);
1495 
1497  return;
1498 
1499  // set zero Dirichlet values on the input vector (and remember the src and
1500  // dst values because we need to reset them at the end)
1501  for (unsigned int j = 0; j < BlockHelper::n_blocks(dst); ++j)
1502  for (unsigned int i = 0; i < edge_constrained_indices[j].size(); ++i)
1503  {
1504  edge_constrained_values[j][i] = std::pair<Number, Number>(
1505  BlockHelper::subblock(src, j).local_element(
1506  edge_constrained_indices[j][i]),
1507  BlockHelper::subblock(dst, j).local_element(
1508  edge_constrained_indices[j][i]));
1509  BlockHelper::subblock(const_cast<VectorType &>(src), j)
1510  .local_element(edge_constrained_indices[j][i]) = 0.;
1511  }
1512 
1513  apply_add(dst, src);
1514 
1515  for (unsigned int j = 0; j < BlockHelper::n_blocks(dst); ++j)
1516  {
1517  unsigned int c = 0;
1518  for (unsigned int i = 0; i < edge_constrained_indices[j].size(); ++i)
1519  {
1520  for (; c < edge_constrained_indices[j][i]; ++c)
1521  BlockHelper::subblock(dst, j).local_element(c) = 0.;
1522  ++c;
1523 
1524  // reset the src values
1525  BlockHelper::subblock(const_cast<VectorType &>(src), j)
1526  .local_element(edge_constrained_indices[j][i]) =
1527  edge_constrained_values[j][i].first;
1528  }
1529  for (; c < BlockHelper::subblock(dst, j).local_size(); ++c)
1530  BlockHelper::subblock(dst, j).local_element(c) = 0.;
1531  }
1532  }
1533 
1534 
1535 
1536  template <int dim, typename VectorType, typename VectorizedArrayType>
1537  void
1539  VectorType & dst,
1540  const VectorType &src) const
1541  {
1542  using Number =
1544  AssertDimension(dst.size(), src.size());
1545  adjust_ghost_range_if_necessary(src, false);
1547 
1548  dst = Number(0.);
1549 
1551  return;
1552 
1553  VectorType src_cpy(src);
1554  for (unsigned int j = 0; j < BlockHelper::n_blocks(dst); ++j)
1555  {
1556  unsigned int c = 0;
1557  for (unsigned int i = 0; i < edge_constrained_indices[j].size(); ++i)
1558  {
1559  for (; c < edge_constrained_indices[j][i]; ++c)
1560  BlockHelper::subblock(src_cpy, j).local_element(c) = 0.;
1561  ++c;
1562  }
1563  for (; c < BlockHelper::subblock(src_cpy, j).local_size(); ++c)
1564  BlockHelper::subblock(src_cpy, j).local_element(c) = 0.;
1565  }
1566 
1567  apply_add(dst, src_cpy);
1568 
1569  for (unsigned int j = 0; j < BlockHelper::n_blocks(dst); ++j)
1570  for (unsigned int i = 0; i < edge_constrained_indices[j].size(); ++i)
1571  BlockHelper::subblock(dst, j).local_element(
1572  edge_constrained_indices[j][i]) = 0.;
1573  }
1574 
1575 
1576 
1577  template <int dim, typename VectorType, typename VectorizedArrayType>
1578  void
1580  VectorType & dst,
1581  const VectorType &src) const
1582  {
1583  using Number =
1585  dst = Number(0.);
1586  Tvmult_add(dst, src);
1587  }
1588 
1589 
1590 
1591  template <int dim, typename VectorType, typename VectorizedArrayType>
1592  std::size_t
1594  {
1595  return inverse_diagonal_entries.get() != nullptr ?
1596  inverse_diagonal_entries->memory_consumption() :
1597  sizeof(*this);
1598  }
1599 
1600 
1601 
1602  template <int dim, typename VectorType, typename VectorizedArrayType>
1603  std::shared_ptr<const MatrixFree<
1604  dim,
1606  VectorizedArrayType>>
1608  {
1609  return data;
1610  }
1611 
1612 
1613 
1614  template <int dim, typename VectorType, typename VectorizedArrayType>
1615  const std::shared_ptr<DiagonalMatrix<VectorType>> &
1617  const
1618  {
1619  Assert(inverse_diagonal_entries.get() != nullptr &&
1620  inverse_diagonal_entries->m() > 0,
1621  ExcNotInitialized());
1622  return inverse_diagonal_entries;
1623  }
1624 
1625 
1626 
1627  template <int dim, typename VectorType, typename VectorizedArrayType>
1628  const std::shared_ptr<DiagonalMatrix<VectorType>> &
1630  {
1631  Assert(diagonal_entries.get() != nullptr && diagonal_entries->m() > 0,
1632  ExcNotInitialized());
1633  return diagonal_entries;
1634  }
1635 
1636 
1637 
1638  template <int dim, typename VectorType, typename VectorizedArrayType>
1639  void
1641  VectorType & dst,
1642  const VectorType &src) const
1643  {
1644  apply_add(dst, src);
1645  }
1646 
1647 
1648 
1649  template <int dim, typename VectorType, typename VectorizedArrayType>
1650  void
1652  VectorType & dst,
1653  const VectorType & src,
1654  const typename Base<dim, VectorType, VectorizedArrayType>::value_type omega)
1655  const
1656  {
1658  ExcNotInitialized());
1659  inverse_diagonal_entries->vmult(dst, src);
1660  dst *= omega;
1661  }
1662 
1663 
1664 
1665  //------------------------- MGInterfaceOperator ------------------------------
1666 
1667  template <typename OperatorType>
1669  : Subscriptor()
1670  , mf_base_operator(nullptr)
1671  {}
1672 
1673 
1674 
1675  template <typename OperatorType>
1676  void
1678  {
1679  mf_base_operator = nullptr;
1680  }
1681 
1682 
1683 
1684  template <typename OperatorType>
1685  void
1686  MGInterfaceOperator<OperatorType>::initialize(const OperatorType &operator_in)
1687  {
1688  mf_base_operator = &operator_in;
1689  }
1690 
1691 
1692 
1693  template <typename OperatorType>
1694  template <typename VectorType>
1695  void
1697  const VectorType &src) const
1698  {
1699 #ifndef DEAL_II_MSVC
1700  static_assert(
1701  std::is_same<typename VectorType::value_type, value_type>::value,
1702  "The vector type must be based on the same value type as this "
1703  "operator");
1704 #endif
1705 
1706  Assert(mf_base_operator != nullptr, ExcNotInitialized());
1707 
1708  mf_base_operator->vmult_interface_down(dst, src);
1709  }
1710 
1711 
1712 
1713  template <typename OperatorType>
1714  template <typename VectorType>
1715  void
1717  const VectorType &src) const
1718  {
1719 #ifndef DEAL_II_MSVC
1720  static_assert(
1721  std::is_same<typename VectorType::value_type, value_type>::value,
1722  "The vector type must be based on the same value type as this "
1723  "operator");
1724 #endif
1725 
1726  Assert(mf_base_operator != nullptr, ExcNotInitialized());
1727 
1728  mf_base_operator->vmult_interface_up(dst, src);
1729  }
1730 
1731 
1732 
1733  template <typename OperatorType>
1734  template <typename VectorType>
1735  void
1737  VectorType &vec) const
1738  {
1739  Assert(mf_base_operator != nullptr, ExcNotInitialized());
1740 
1741  mf_base_operator->initialize_dof_vector(vec);
1742  }
1743 
1744 
1745 
1746  //-----------------------------MassOperator----------------------------------
1747 
1748  template <int dim,
1749  int fe_degree,
1750  int n_q_points_1d,
1751  int n_components,
1752  typename VectorType,
1753  typename VectorizedArrayType>
1754  MassOperator<dim,
1755  fe_degree,
1756  n_q_points_1d,
1757  n_components,
1758  VectorType,
1759  VectorizedArrayType>::MassOperator()
1760  : Base<dim, VectorType, VectorizedArrayType>()
1761  {}
1762 
1763 
1764 
1765  template <int dim,
1766  int fe_degree,
1767  int n_q_points_1d,
1768  int n_components,
1769  typename VectorType,
1770  typename VectorizedArrayType>
1771  void
1772  MassOperator<dim,
1773  fe_degree,
1774  n_q_points_1d,
1775  n_components,
1776  VectorType,
1777  VectorizedArrayType>::compute_diagonal()
1778  {
1779  using Number =
1780  typename Base<dim, VectorType, VectorizedArrayType>::value_type;
1782  ExcNotInitialized());
1783 
1784  this->inverse_diagonal_entries =
1785  std::make_shared<DiagonalMatrix<VectorType>>();
1786  this->diagonal_entries = std::make_shared<DiagonalMatrix<VectorType>>();
1787  VectorType &inverse_diagonal_vector =
1788  this->inverse_diagonal_entries->get_vector();
1789  VectorType &diagonal_vector = this->diagonal_entries->get_vector();
1790  this->initialize_dof_vector(inverse_diagonal_vector);
1791  this->initialize_dof_vector(diagonal_vector);
1792  inverse_diagonal_vector = Number(1.);
1793  apply_add(diagonal_vector, inverse_diagonal_vector);
1794 
1795  this->set_constrained_entries_to_one(diagonal_vector);
1796  inverse_diagonal_vector = diagonal_vector;
1797 
1798  const unsigned int local_size = inverse_diagonal_vector.local_size();
1799  for (unsigned int i = 0; i < local_size; ++i)
1800  inverse_diagonal_vector.local_element(i) =
1801  Number(1.) / inverse_diagonal_vector.local_element(i);
1802 
1803  inverse_diagonal_vector.update_ghost_values();
1804  diagonal_vector.update_ghost_values();
1805  }
1806 
1807 
1808 
1809  template <int dim,
1810  int fe_degree,
1811  int n_q_points_1d,
1812  int n_components,
1813  typename VectorType,
1814  typename VectorizedArrayType>
1815  void
1816  MassOperator<dim,
1817  fe_degree,
1818  n_q_points_1d,
1819  n_components,
1820  VectorType,
1821  VectorizedArrayType>::apply_add(VectorType & dst,
1822  const VectorType &src) const
1823  {
1825  &MassOperator::local_apply_cell, this, dst, src);
1826  }
1827 
1828 
1829 
1830  template <int dim,
1831  int fe_degree,
1832  int n_q_points_1d,
1833  int n_components,
1834  typename VectorType,
1835  typename VectorizedArrayType>
1836  void
1837  MassOperator<dim,
1838  fe_degree,
1839  n_q_points_1d,
1840  n_components,
1841  VectorType,
1842  VectorizedArrayType>::
1844  const MatrixFree<
1845  dim,
1846  typename Base<dim, VectorType, VectorizedArrayType>::value_type,
1847  VectorizedArrayType> & data,
1848  VectorType & dst,
1849  const VectorType & src,
1850  const std::pair<unsigned int, unsigned int> &cell_range) const
1851  {
1852  using Number =
1853  typename Base<dim, VectorType, VectorizedArrayType>::value_type;
1854  FEEvaluation<dim,
1855  fe_degree,
1856  n_q_points_1d,
1857  n_components,
1858  Number,
1859  VectorizedArrayType>
1860  phi(data, this->selected_rows[0]);
1861  for (unsigned int cell = cell_range.first; cell < cell_range.second; ++cell)
1862  {
1863  phi.reinit(cell);
1864  phi.read_dof_values(src);
1865  phi.evaluate(EvaluationFlags::values);
1866  for (unsigned int q = 0; q < phi.n_q_points; ++q)
1867  phi.submit_value(phi.get_value(q), q);
1868  phi.integrate(EvaluationFlags::values);
1869  phi.distribute_local_to_global(dst);
1870  }
1871  }
1872 
1873 
1874  //-----------------------------LaplaceOperator----------------------------------
1875 
1876  template <int dim,
1877  int fe_degree,
1878  int n_q_points_1d,
1879  int n_components,
1880  typename VectorType,
1881  typename VectorizedArrayType>
1882  LaplaceOperator<dim,
1883  fe_degree,
1884  n_q_points_1d,
1885  n_components,
1886  VectorType,
1887  VectorizedArrayType>::LaplaceOperator()
1888  : Base<dim, VectorType, VectorizedArrayType>()
1889  {}
1890 
1891 
1892 
1893  template <int dim,
1894  int fe_degree,
1895  int n_q_points_1d,
1896  int n_components,
1897  typename VectorType,
1898  typename VectorizedArrayType>
1899  void
1900  LaplaceOperator<dim,
1901  fe_degree,
1902  n_q_points_1d,
1903  n_components,
1904  VectorType,
1905  VectorizedArrayType>::clear()
1906  {
1908  scalar_coefficient.reset();
1909  }
1910 
1911 
1912 
1913  template <int dim,
1914  int fe_degree,
1915  int n_q_points_1d,
1916  int n_components,
1917  typename VectorType,
1918  typename VectorizedArrayType>
1919  void
1920  LaplaceOperator<dim,
1921  fe_degree,
1922  n_q_points_1d,
1923  n_components,
1924  VectorType,
1925  VectorizedArrayType>::
1927  const std::shared_ptr<Table<2, VectorizedArrayType>> &scalar_coefficient_)
1928  {
1929  scalar_coefficient = scalar_coefficient_;
1930  }
1931 
1932 
1933 
1934  template <int dim,
1935  int fe_degree,
1936  int n_q_points_1d,
1937  int n_components,
1938  typename VectorType,
1939  typename VectorizedArrayType>
1940  std::shared_ptr<Table<2, VectorizedArrayType>>
1941  LaplaceOperator<dim,
1942  fe_degree,
1943  n_q_points_1d,
1944  n_components,
1945  VectorType,
1946  VectorizedArrayType>::get_coefficient()
1947  {
1949  return scalar_coefficient;
1950  }
1951 
1952 
1953 
1954  template <int dim,
1955  int fe_degree,
1956  int n_q_points_1d,
1957  int n_components,
1958  typename VectorType,
1959  typename VectorizedArrayType>
1960  void
1961  LaplaceOperator<dim,
1962  fe_degree,
1963  n_q_points_1d,
1964  n_components,
1965  VectorType,
1966  VectorizedArrayType>::compute_diagonal()
1967  {
1968  using Number =
1969  typename Base<dim, VectorType, VectorizedArrayType>::value_type;
1971  ExcNotInitialized());
1972 
1973  this->inverse_diagonal_entries =
1974  std::make_shared<DiagonalMatrix<VectorType>>();
1975  this->diagonal_entries = std::make_shared<DiagonalMatrix<VectorType>>();
1976  VectorType &inverse_diagonal_vector =
1977  this->inverse_diagonal_entries->get_vector();
1978  VectorType &diagonal_vector = this->diagonal_entries->get_vector();
1979  this->initialize_dof_vector(inverse_diagonal_vector);
1980  this->initialize_dof_vector(diagonal_vector);
1981 
1982  this->data->cell_loop(&LaplaceOperator::local_diagonal_cell,
1983  this,
1984  diagonal_vector,
1985  /*unused*/ diagonal_vector);
1986  this->set_constrained_entries_to_one(diagonal_vector);
1987 
1988  inverse_diagonal_vector = diagonal_vector;
1989 
1990  for (unsigned int i = 0; i < inverse_diagonal_vector.local_size(); ++i)
1991  if (std::abs(inverse_diagonal_vector.local_element(i)) >
1993  inverse_diagonal_vector.local_element(i) =
1994  1. / inverse_diagonal_vector.local_element(i);
1995  else
1996  inverse_diagonal_vector.local_element(i) = 1.;
1997 
1998  inverse_diagonal_vector.update_ghost_values();
1999  diagonal_vector.update_ghost_values();
2000  }
2001 
2002 
2003 
2004  template <int dim,
2005  int fe_degree,
2006  int n_q_points_1d,
2007  int n_components,
2008  typename VectorType,
2009  typename VectorizedArrayType>
2010  void
2011  LaplaceOperator<dim,
2012  fe_degree,
2013  n_q_points_1d,
2014  n_components,
2015  VectorType,
2016  VectorizedArrayType>::apply_add(VectorType & dst,
2017  const VectorType &src) const
2018  {
2020  &LaplaceOperator::local_apply_cell, this, dst, src);
2021  }
2022 
2023  namespace Implementation
2024  {
2025  template <typename VectorizedArrayType>
2026  bool
2027  non_negative(const VectorizedArrayType &n)
2028  {
2029  for (unsigned int v = 0; v < VectorizedArrayType::size(); ++v)
2030  if (n[v] < 0.)
2031  return false;
2032 
2033  return true;
2034  }
2035  } // namespace Implementation
2036 
2037 
2038 
2039  template <int dim,
2040  int fe_degree,
2041  int n_q_points_1d,
2042  int n_components,
2043  typename VectorType,
2044  typename VectorizedArrayType>
2045  void
2046  LaplaceOperator<dim,
2047  fe_degree,
2048  n_q_points_1d,
2049  n_components,
2050  VectorType,
2051  VectorizedArrayType>::
2053  FEEvaluation<
2054  dim,
2055  fe_degree,
2056  n_q_points_1d,
2057  n_components,
2058  typename Base<dim, VectorType, VectorizedArrayType>::value_type> &phi,
2059  const unsigned int cell) const
2060  {
2061  phi.evaluate(EvaluationFlags::gradients);
2062  if (scalar_coefficient.get())
2063  {
2064  Assert(scalar_coefficient->size(1) == 1 ||
2065  scalar_coefficient->size(1) == phi.n_q_points,
2066  ExcMessage("The number of columns in the coefficient table must "
2067  "be either 1 or the number of quadrature points " +
2068  std::to_string(phi.n_q_points) +
2069  ", but the given value was " +
2070  std::to_string(scalar_coefficient->size(1))));
2071  if (scalar_coefficient->size(1) == phi.n_q_points)
2072  for (unsigned int q = 0; q < phi.n_q_points; ++q)
2073  {
2075  (*scalar_coefficient)(cell, q)),
2076  ExcMessage("Coefficient must be non-negative"));
2077  phi.submit_gradient((*scalar_coefficient)(cell, q) *
2078  phi.get_gradient(q),
2079  q);
2080  }
2081  else
2082  {
2084  ExcMessage("Coefficient must be non-negative"));
2085  const VectorizedArrayType coefficient =
2086  (*scalar_coefficient)(cell, 0);
2087  for (unsigned int q = 0; q < phi.n_q_points; ++q)
2088  phi.submit_gradient(coefficient * phi.get_gradient(q), q);
2089  }
2090  }
2091  else
2092  {
2093  for (unsigned int q = 0; q < phi.n_q_points; ++q)
2094  {
2095  phi.submit_gradient(phi.get_gradient(q), q);
2096  }
2097  }
2098  phi.integrate(EvaluationFlags::gradients);
2099  }
2100 
2101 
2102 
2103  template <int dim,
2104  int fe_degree,
2105  int n_q_points_1d,
2106  int n_components,
2107  typename VectorType,
2108  typename VectorizedArrayType>
2109  void
2110  LaplaceOperator<dim,
2111  fe_degree,
2112  n_q_points_1d,
2113  n_components,
2114  VectorType,
2115  VectorizedArrayType>::
2117  const MatrixFree<
2118  dim,
2119  typename Base<dim, VectorType, VectorizedArrayType>::value_type,
2120  VectorizedArrayType> & data,
2121  VectorType & dst,
2122  const VectorType & src,
2123  const std::pair<unsigned int, unsigned int> &cell_range) const
2124  {
2125  using Number =
2126  typename Base<dim, VectorType, VectorizedArrayType>::value_type;
2128  data, this->selected_rows[0]);
2129  for (unsigned int cell = cell_range.first; cell < cell_range.second; ++cell)
2130  {
2131  phi.reinit(cell);
2132  phi.read_dof_values(src);
2133  do_operation_on_cell(phi, cell);
2134  phi.distribute_local_to_global(dst);
2135  }
2136  }
2137 
2138 
2139  template <int dim,
2140  int fe_degree,
2141  int n_q_points_1d,
2142  int n_components,
2143  typename VectorType,
2144  typename VectorizedArrayType>
2145  void
2146  LaplaceOperator<dim,
2147  fe_degree,
2148  n_q_points_1d,
2149  n_components,
2150  VectorType,
2151  VectorizedArrayType>::
2153  const MatrixFree<
2154  dim,
2155  typename Base<dim, VectorType, VectorizedArrayType>::value_type,
2156  VectorizedArrayType> &data,
2157  VectorType & dst,
2158  const VectorType &,
2159  const std::pair<unsigned int, unsigned int> &cell_range) const
2160  {
2161  using Number =
2162  typename Base<dim, VectorType, VectorizedArrayType>::value_type;
2163 
2165  data, this->selected_rows[0]);
2166  for (unsigned int cell = cell_range.first; cell < cell_range.second; ++cell)
2167  {
2168  phi.reinit(cell);
2169  VectorizedArrayType local_diagonal_vector[phi.static_dofs_per_cell];
2170  for (unsigned int i = 0; i < phi.dofs_per_component; ++i)
2171  {
2172  for (unsigned int j = 0; j < phi.dofs_per_component; ++j)
2173  phi.begin_dof_values()[j] = VectorizedArrayType();
2174  phi.begin_dof_values()[i] = 1.;
2175  do_operation_on_cell(phi, cell);
2176  local_diagonal_vector[i] = phi.begin_dof_values()[i];
2177  }
2178  for (unsigned int i = 0; i < phi.dofs_per_component; ++i)
2179  for (unsigned int c = 0; c < phi.n_components; ++c)
2180  phi.begin_dof_values()[i + c * phi.dofs_per_component] =
2181  local_diagonal_vector[i];
2182  phi.distribute_local_to_global(dst);
2183  }
2184  }
2185 
2186 
2187 } // end of namespace MatrixFreeOperators
2188 
2189 
2191 
2192 #endif
typename OperatorType::value_type value_type
Definition: operators.h:541
virtual void apply_add(VectorType &dst, const VectorType &src) const =0
void fill_inverse_JxW_values(AlignedVector< VectorizedArrayType > &inverse_jxw) const
Definition: operators.h:984
static const unsigned int invalid_unsigned_int
Definition: types.h:196
const std::shared_ptr< DiagonalMatrix< VectorType > > & get_matrix_diagonal_inverse() const
Definition: operators.h:1616
#define AssertDimension(dim1, dim2)
Definition: exceptions.h:1623
virtual std::size_t memory_consumption() const
Definition: operators.h:1593
const FEEvaluationBase< dim, n_components, Number, false, VectorizedArrayType > & fe_eval
Definition: operators.h:720
types::global_dof_index size_type
Definition: cuda_kernels.h:45
size_type n() const
Definition: operators.h:1104
void local_diagonal_cell(const MatrixFree< dim, value_type, VectorizedArrayType > &data, VectorType &dst, const VectorType &, const std::pair< unsigned int, unsigned int > &cell_range) const
Definition: operators.h:2152
void precondition_Jacobi(VectorType &dst, const VectorType &src, const value_type omega) const
Definition: operators.h:1651
std::shared_ptr< DiagonalMatrix< VectorType > > diagonal_entries
Definition: operators.h:439
void read_dof_values(const VectorType &src, const unsigned int first_index=0)
#define AssertIndexRange(index, range)
Definition: exceptions.h:1691
std::vector< std::vector< std::pair< value_type, value_type > > > edge_constrained_values
Definition: operators.h:469
static ::ExceptionBase & ExcNotInitialized()
std::shared_ptr< const MatrixFree< dim, value_type, VectorizedArrayType > > data
Definition: operators.h:433
void Tvmult(VectorType &dst, const VectorType &src) const
Definition: operators.h:1579
#define AssertThrow(cond, exc)
Definition: exceptions.h:1576
std::enable_if< IsBlockVector< VectorType >::value, void >::type collect_sizes(VectorType &vector)
Definition: operators.h:97
typename VectorType::value_type value_type
Definition: operators.h:195
typename OperatorType::size_type size_type
Definition: operators.h:546
virtual void compute_diagonal() override
Definition: operators.h:1966
SymmetricTensor< 2, dim, Number > epsilon(const Tensor< 2, dim, Number > &Grad_u)
constexpr T pow(const T base, const int iexp)
Definition: utilities.h:461
std::shared_ptr< const MatrixFree< dim, value_type, VectorizedArrayType > > get_matrix_free() const
Definition: operators.h:1607
void initialize_dof_vector(VectorType &vec) const
Definition: operators.h:1736
void vmult_add(VectorType &dst, const VectorType &src) const
Definition: operators.h:1339
const std::shared_ptr< DiagonalMatrix< VectorType > > & get_matrix_diagonal() const
Definition: operators.h:1629
static ::ExceptionBase & ExcMessage(std::string arg1)
VectorizedArrayType JxW(const unsigned int q_point) const
void vmult_interface_up(VectorType &dst, const VectorType &src) const
Definition: operators.h:1538
std::enable_if< IsBlockVector< VectorType >::value, typename VectorType::BlockType & >::type subblock(VectorType &vector, unsigned int block_no)
Definition: operators.h:65
#define Assert(cond, exc)
Definition: exceptions.h:1466
void local_apply_cell(const MatrixFree< dim, value_type, VectorizedArrayType > &data, VectorType &dst, const VectorType &src, const std::pair< unsigned int, unsigned int > &cell_range) const
Definition: operators.h:2116
auto apply(F &&fn, Tuple &&t) -> decltype(apply_impl(std::forward< F >(fn), std::forward< Tuple >(t), std::make_index_sequence< std::tuple_size< typename std::remove_reference< Tuple >::type >::value >()))
Definition: tuple.h:36
size_type index_within_set(const size_type global_index) const
Definition: index_set.h:1919
void postprocess_constraints(VectorType &dst, const VectorType &src) const
Definition: operators.h:1450
DerivativeForm< 1, spacedim, dim, Number > transpose(const DerivativeForm< 1, dim, spacedim, Number > &DF)
virtual void Tapply_add(VectorType &dst, const VectorType &src) const
Definition: operators.h:1640
std::shared_ptr< Table< 2, VectorizedArrayType > > scalar_coefficient
Definition: operators.h:945
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:372
unsigned int level
Definition: grid_out.cc:4343
const unsigned int dofs_per_component
std::vector< unsigned int > selected_rows
Definition: operators.h:451
std::string to_string(const T &t)
Definition: patterns.h:2342
void reinit(const unsigned int cell_batch_index)
std::enable_if< IsBlockVector< VectorType >::value, unsigned int >::type n_blocks(const VectorType &vector)
Definition: operators.h:49
virtual void clear()
Definition: operators.h:1118
void set_constrained_entries_to_one(VectorType &dst) const
Definition: operators.h:1307
virtual void clear() override
Definition: operators.h:1905
void initialize_dof_vector(VectorType &vec) const
Definition: operators.h:1143
void vmult(VectorType &dst, const VectorType &src) const
Definition: operators.h:1696
virtual void apply_add(VectorType &dst, const VectorType &src) const override
Definition: operators.h:2016
virtual void apply_add(VectorType &dst, const VectorType &src) const override
Definition: operators.h:1821
void Tvmult_add(VectorType &dst, const VectorType &src) const
Definition: operators.h:1350
static constexpr unsigned int n_components
size_type m() const
Definition: operators.h:1090
static constexpr unsigned int static_dofs_per_cell
typename VectorType::size_type size_type
Definition: operators.h:200
void mult_add(VectorType &dst, const VectorType &src, const bool transpose) const
Definition: operators.h:1430
std::shared_ptr< Table< 2, VectorizedArrayType > > get_coefficient()
Definition: operators.h:1946
void do_operation_on_cell(FEEvaluation< dim, fe_degree, n_q_points_1d, n_components, value_type > &phi, const unsigned int cell) const
Definition: operators.h:2052
const VectorizedArrayType * begin_dof_values() const
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:371
std::vector< unsigned int > selected_columns
Definition: operators.h:457
void vmult_interface_down(VectorType &dst, const VectorType &src) const
Definition: operators.h:1484
const internal::MatrixFreeFunctions::ShapeInfo< VectorizedArrayType > & get_shape_info() const
void distribute_local_to_global(VectorType &dst, const unsigned int first_index=0, const std::bitset< VectorizedArrayType::size()> &mask=std::bitset< VectorizedArrayType::size()>().flip()) const
size_type size() const
static ::ExceptionBase & ExcNotImplemented()
value_type el(const unsigned int row, const unsigned int col) const
Definition: operators.h:1128
Definition: table.h:687
std::vector< UnivariateShapeData< Number > > data
Definition: shape_info.h:375
bool is_element(const size_type index) const
Definition: index_set.h:1763
void initialize(const OperatorType &operator_in)
Definition: operators.h:1686
SmartPointer< const OperatorType > mf_base_operator
Definition: operators.h:591
void Tvmult(VectorType &dst, const VectorType &src) const
Definition: operators.h:1716
void apply(const AlignedVector< VectorizedArrayType > &inverse_coefficient, const unsigned int n_actual_components, const VectorizedArrayType *in_array, VectorizedArrayType *out_array) const
Definition: operators.h:1036
std::shared_ptr< DiagonalMatrix< VectorType > > inverse_diagonal_entries
Definition: operators.h:445
void vmult(VectorType &dst, const VectorType &src) const
Definition: operators.h:1326
bool non_negative(const VectorizedArrayType &n)
Definition: operators.h:2027
virtual void compute_diagonal() override
Definition: operators.h:1777
void compute_diagonal(const MatrixFree< dim, Number, VectorizedArrayType > &matrix_free, LinearAlgebra::distributed::Vector< Number > &diagonal_global, const std::function< void(FEEvaluation< dim, fe_degree, n_q_points_1d, n_components, Number, VectorizedArrayType > &)> &local_vmult, const unsigned int dof_no=0, const unsigned int quad_no=0, const unsigned int first_selected_component=0)
Definition: tools.h:176
T max(const T &t, const MPI_Comm &mpi_communicator)
void local_apply_cell(const MatrixFree< dim, value_type, VectorizedArrayType > &data, VectorType &dst, const VectorType &src, const std::pair< unsigned int, unsigned int > &cell_range) const
Definition: operators.h:1843
std::vector< std::vector< unsigned int > > edge_constrained_indices
Definition: operators.h:463
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
void initialize(std::shared_ptr< const MatrixFree< dim, value_type, VectorizedArrayType >> data, const std::vector< unsigned int > &selected_row_blocks=std::vector< unsigned int >(), const std::vector< unsigned int > &selected_column_blocks=std::vector< unsigned int >())
Definition: operators.h:1168
void preprocess_constraints(VectorType &dst, const VectorType &src) const
Definition: operators.h:1400
void transform_from_q_points_to_basis(const unsigned int n_actual_components, const VectorizedArrayType *in_array, VectorizedArrayType *out_array) const
Definition: operators.h:1063
void set_coefficient(const std::shared_ptr< Table< 2, VectorizedArrayType >> &scalar_coefficient)
Definition: operators.h:1926
static ::ExceptionBase & ExcInternalError()
void adjust_ghost_range_if_necessary(const VectorType &vec, const bool is_row) const
Definition: operators.h:1361