Reference documentation for deal.II version 9.3.0
\(\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 - 2021 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/ndarray.h>
22 #include <deal.II/base/types.h>
23 
25 #include <deal.II/lac/vector.h>
26 
27 #include <vector>
28 
30 
31 namespace MeshWorker
32 {
48  template <int n_matrices = 1,
49  int n_vectors = n_matrices,
50  int n_dof_indices = n_matrices>
51  struct CopyData
52  {
57  explicit CopyData(const unsigned int size);
58 
62  explicit CopyData(
63  const ndarray<unsigned int, n_matrices, 2> & matrix_sizes,
64  const std::array<unsigned int, n_vectors> & vector_sizes,
65  const std::array<unsigned int, n_dof_indices> &dof_indices_sizes);
66 
71  default;
72 
76  std::array<FullMatrix<double>, n_matrices> matrices;
77 
81  std::array<Vector<double>, n_vectors> vectors;
82 
86  std::array<std::vector<types::global_dof_index>, n_dof_indices>
88  };
89 
90 
91 #ifndef DOXYGEN
92  //
93  // Template definitions
94  //
95  template <int n_matrices, int n_vectors, int n_dof_indices>
97  const unsigned int size)
98  {
99  for (auto &m : matrices)
100  m.reinit({size, size});
101  for (auto &v : vectors)
102  v.reinit(size);
103  for (auto &d : local_dof_indices)
104  d.resize(size);
105  }
106 
107 
108 
109  template <int n_matrices, int n_vectors, int n_dof_indices>
111  const ndarray<unsigned int, n_matrices, 2> & matrix_sizes,
112  const std::array<unsigned int, n_vectors> & vector_sizes,
113  const std::array<unsigned int, n_dof_indices> &dof_indices_sizes)
114  {
115  for (unsigned int i = 0; i < n_matrices; ++i)
116  matrices[i].reinit(matrix_sizes[i++]);
117 
118  for (unsigned int i = 0; i < n_vectors; ++i)
119  vectors[i].reinit(vector_sizes[i++]);
120 
121  for (unsigned int i = 0; i < n_dof_indices; ++i)
122  local_dof_indices[i].resize(dof_indices_sizes[i++]);
123  }
124 
125 #endif // DOXYGEN
126 } // namespace MeshWorker
127 
129 
130 #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:76
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:395
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:87
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:394
std::array< Vector< double >, n_vectors > vectors
Definition: copy_data.h:81
typename internal::ndarray::HelperArray< T, Ns... >::type ndarray
Definition: ndarray.h:108