Reference documentation for deal.II version Git 193422c69f 2020-07-08 17:07:46 +0200
\(\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\}}\)
copy_data.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2019 - 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 #ifndef dealii_meshworker_copy_data_h
17 #define dealii_meshworker_copy_data_h
18 
19 #include <deal.II/base/config.h>
20 
21 #include <deal.II/base/types.h>
22 
24 #include <deal.II/lac/vector.h>
25 
26 #include <vector>
27 
29 
30 namespace MeshWorker
31 {
47  template <int n_matrices = 1,
48  int n_vectors = n_matrices,
49  int n_dof_indices = n_matrices>
50  struct CopyData
51  {
56  explicit CopyData(const unsigned int size);
57 
61  explicit CopyData(
62  const std::array<std::array<unsigned int, 2>, n_matrices> &matrix_sizes,
63  const std::array<unsigned int, n_vectors> & vector_sizes,
64  const std::array<unsigned int, n_dof_indices> &dof_indices_sizes);
65 
70  default;
71 
75  std::array<FullMatrix<double>, n_matrices> matrices;
76 
80  std::array<Vector<double>, n_vectors> vectors;
81 
85  std::array<std::vector<types::global_dof_index>, n_dof_indices>
87  };
88 
89 
90 #ifndef DOXYGEN
91  //
92  // Template definitions
93  //
94  template <int n_matrices, int n_vectors, int n_dof_indices>
96  const unsigned int size)
97  {
98  for (auto &m : matrices)
99  m.reinit({size, size});
100  for (auto &v : vectors)
101  v.reinit(size);
102  for (auto &d : local_dof_indices)
103  d.resize(size);
104  }
105 
106 
107 
108  template <int n_matrices, int n_vectors, int n_dof_indices>
110  const std::array<std::array<unsigned int, 2>, n_matrices> &matrix_sizes,
111  const std::array<unsigned int, n_vectors> & vector_sizes,
112  const std::array<unsigned int, n_dof_indices> &dof_indices_sizes)
113  {
114  for (unsigned int i = 0; i < n_matrices; ++i)
115  matrices[i].reinit(matrix_sizes[i++]);
116 
117  for (unsigned int i = 0; i < n_vectors; ++i)
118  vectors[i].reinit(vector_sizes[i++]);
119 
120  for (unsigned int i = 0; i < n_dof_indices; ++i)
121  local_dof_indices[i].resize(dof_indices_sizes[i++]);
122  }
123 
124 #endif // DOXYGEN
125 } // namespace MeshWorker
126 
128 
129 #endif
void reinit(MatrixBlock< MatrixType > &v, const BlockSparsityPattern &p)
Definition: matrix_block.h:618
CopyData(const unsigned int size)
std::array< FullMatrix< double >, n_matrices > matrices
Definition: copy_data.h:75
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:363
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
std::array< std::vector< types::global_dof_index >, n_dof_indices > local_dof_indices
Definition: copy_data.h:86
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:362
std::array< Vector< double >, n_vectors > vectors
Definition: copy_data.h:80