MFEM  v4.4.0
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
prestriction.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2022, Lawrence Livermore National Security, LLC. Produced
2 // at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3 // LICENSE and NOTICE for details. LLNL-CODE-806117.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability visit https://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the BSD-3 license. We welcome feedback and contributions, see file
10 // CONTRIBUTING.md for details.
11 
12 #ifndef MFEM_PRESTRICTION
13 #define MFEM_PRESTRICTION
14 
15 #include "../config/config.hpp"
16 
17 #ifdef MFEM_USE_MPI
18 
19 #include "restriction.hpp"
20 
21 namespace mfem
22 {
23 
24 class ParFiniteElementSpace;
25 
26 /// Operator that extracts Face degrees of freedom for NCMesh in parallel.
27 /** Objects of this type are typically created and owned by
28  ParFiniteElementSpace objects, see
29  ParFiniteElementSpace::GetFaceRestriction(). */
31 {
32 protected:
33  const FaceType type;
35  mutable Vector x_interp;
36 
37 public:
38  /** @brief Constructs an ParNCH1FaceRestriction.
39 
40  @param[in] fes The ParFiniteElementSpace on which this operates
41  @param[in] ordering Request a specific ordering
42  @param[in] type Request internal or boundary faces dofs */
44  ElementDofOrdering ordering,
45  FaceType type);
46 
47  /** @brief Scatter the degrees of freedom, i.e. goes from L-Vector to
48  face E-Vector.
49 
50  @param[in] x The L-vector degrees of freedom.
51  @param[out] y The face E-Vector degrees of freedom with the given format:
52  face_dofs x vdim x nf
53  where nf is the number of interior or boundary faces
54  requested by @a type in the constructor.
55  The face_dofs are ordered according to the given
56  ElementDofOrdering. */
57  void Mult(const Vector &x, Vector &y) const override;
58 
59  /** @brief Gather the degrees of freedom, i.e. goes from face E-Vector to
60  L-Vector.
61 
62  @param[in] x The face E-Vector degrees of freedom with the given format:
63  face_dofs x vdim x nf
64  where nf is the number of interior or boundary faces
65  requested by @a type in the constructor.
66  The face_dofs should be ordered according to the given
67  ElementDofOrdering.
68  @param[in,out] y The L-vector degrees of freedom. */
69  void AddMultTranspose(const Vector &x, Vector &y) const override;
70 
71 private:
72  /** @brief Compute the scatter indices: L-vector to E-vector, the offsets
73  for the gathering: E-vector to L-vector, and the interpolators from
74  coarse to fine face for master non-comforming faces.
75 
76  @param[in] ordering Request a specific element ordering.
77  @param[in] type Request internal or boundary faces dofs.
78  */
79  void ComputeScatterIndicesAndOffsets(const ElementDofOrdering ordering,
80  const FaceType type);
81 
82  /** @brief Compute the gather indices: E-vector to L-vector.
83 
84  Note: Requires the gather offsets to be computed.
85 
86  @param[in] ordering Request a specific element ordering.
87  @param[in] type Request internal or boundary faces dofs.
88  */
89  void ComputeGatherIndices(const ElementDofOrdering ordering,
90  const FaceType type);
91 };
92 
93 /// Operator that extracts Face degrees of freedom in parallel.
94 /** Objects of this type are typically created and owned by
95  ParFiniteElementSpace objects, see
96  ParFiniteElementSpace::GetFaceRestriction(). */
98 {
99 protected:
100  /** @brief Constructs an ParL2FaceRestriction.
101 
102  @param[in] fes The ParFiniteElementSpace on which this operates
103  @param[in] ordering Request a specific ordering
104  @param[in] type Request internal or boundary faces dofs
105  @param[in] m Request the face dofs for elem1, or both elem1 and
106  elem2
107  @param[in] build Request the ParL2FaceRestriction to compute the
108  scatter/gather indices. False should only be used
109  when inheriting from ParL2FaceRestriction. */
111  ElementDofOrdering ordering,
112  FaceType type,
113  L2FaceValues m,
114  bool build);
115 
116 public:
117  /** @brief Constructs an ParL2FaceRestriction.
118 
119  @param[in] fes The ParFiniteElementSpace on which this operates
120  @param[in] ordering Request a specific ordering
121  @param[in] type Request internal or boundary faces dofs
122  @param[in] m Request the face dofs for elem1, or both elem1 and
123  elem2 */
125  ElementDofOrdering ordering,
126  FaceType type,
128 
129  /** @brief Scatter the degrees of freedom, i.e. goes from L-Vector to
130  face E-Vector.
131 
132  @param[in] x The L-vector degrees of freedom.
133  @param[out] y The face E-Vector degrees of freedom with the given format:
134  if L2FacesValues::DoubleValued (face_dofs x vdim x 2 x nf),
135  if L2FacesValues::SingleValued (face_dofs x vdim x nf),
136  where nf is the number of interior or boundary faces
137  requested by @a type in the constructor.
138  The face_dofs are ordered according to the given
139  ElementDofOrdering. */
140  void Mult(const Vector &x, Vector &y) const override;
141 
142  /** Fill the I array of SparseMatrix corresponding to the sparsity pattern
143  given by this ParL2FaceRestriction.
144 
145  @param[in,out] mat The sparse matrix for which we want to initialize the
146  row offsets.
147  @param[in] keep_nbr_block When set to true the SparseMatrix will
148  include the rows (in addition to the columns)
149  corresponding to face-neighbor dofs. The
150  default behavior is to disregard those rows. */
151  void FillI(SparseMatrix &mat,
152  const bool keep_nbr_block = false) const override;
153 
154  /** Fill the I array of SparseMatrix corresponding to the sparsity pattern
155  given by this ParL2FaceRestriction. @a mat contains the interior dofs
156  contribution, the @a face_mat contains the shared dofs contribution.*/
157  void FillI(SparseMatrix &mat,
158  SparseMatrix &face_mat) const;
159 
160  /** Fill the J and Data arrays of SparseMatrix corresponding to the sparsity
161  pattern given by this ParL2FaceRestriction, and the values of ea_data.
162  @a mat contains the interior dofs contribution, the @a face_mat contains
163  the shared dofs contribution.*/
164  void FillJAndData(const Vector &ea_data,
165  SparseMatrix &mat,
166  SparseMatrix &face_mat) const;
167 
168  /** @brief Fill the J and Data arrays of the SparseMatrix corresponding to
169  the sparsity pattern given by this ParL2FaceRestriction, and the values of
170  fea_data.
171 
172  @param[in] fea_data The dense matrices representing the local operators
173  on each face. The format is:
174  face_dofs x face_dofs x 2 x nf.
175  On each face the first local matrix corresponds to
176  the contribution of elem1 on elem2, and the second to
177  the contribution of elem2 on elem1.
178  @param[in,out] mat The sparse matrix that is getting filled.
179  @param[in] keep_nbr_block When set to true the SparseMatrix will
180  include the rows (in addition to the columns)
181  corresponding to face-neighbor dofs. The
182  default behavior is to disregard those rows. */
183  void FillJAndData(const Vector &fea_data,
184  SparseMatrix &mat,
185  const bool keep_nbr_block = false) const override;
186 
187 private:
188  /** @brief Compute the scatter indices: L-vector to E-vector, and the offsets
189  for the gathering: E-vector to L-vector.
190 
191  @param[in] ordering Request a specific element ordering.
192  @param[in] type Request internal or boundary faces dofs.
193  */
194  void ComputeScatterIndicesAndOffsets(const ElementDofOrdering ordering,
195  const FaceType type);
196 
197  /** @brief Compute the gather indices: E-vector to L-vector.
198 
199  Note: Requires the gather offsets to be computed.
200 
201  @param[in] ordering Request a specific element ordering.
202  @param[in] type Request internal or boundary faces dofs.
203  */
204  void ComputeGatherIndices(const ElementDofOrdering ordering,
205  const FaceType type);
206 
207 public:
208  /** @brief Scatter the degrees of freedom, i.e. goes from L-Vector to
209  face E-Vector. Should only be used with conforming faces and when:
210  m == L2FacesValues::DoubleValued
211 
212  @param[in] x The L-vector degrees of freedom.
213  @param[out] y The face E-Vector degrees of freedom with the given format:
214  face_dofs x vdim x 2 x nf
215  where nf is the number of interior or boundary faces
216  requested by @a type in the constructor.
217  The face_dofs are ordered according to the given
218  ElementDofOrdering. */
219  void DoubleValuedConformingMult(const Vector& x, Vector& y) const override;
220 };
221 
222 /// Operator that extracts Face degrees of freedom for NCMesh in parallel.
223 /** Objects of this type are typically created and owned by
224  ParFiniteElementSpace objects, see
225  ParFiniteElementSpace::GetFaceRestriction(). */
228 {
229 public:
230  /** @brief Constructs an ParNCL2FaceRestriction.
231 
232  @param[in] fes The ParFiniteElementSpace on which this operates
233  @param[in] ordering Request a specific ordering
234  @param[in] type Request internal or boundary faces dofs
235  @param[in] m Request the face dofs for elem1, or both elem1 and
236  elem2 */
238  ElementDofOrdering ordering,
239  FaceType type,
241 
242  /** @brief Scatter the degrees of freedom, i.e. goes from L-Vector to
243  face E-Vector.
244 
245  @param[in] x The L-vector degrees of freedom.
246  @param[out] y The face E-Vector degrees of freedom with the given format:
247  if L2FacesValues::DoubleValued (face_dofs x vdim x 2 x nf),
248  if L2FacesValues::SingleValued (face_dofs x vdim x nf),
249  where nf is the number of interior or boundary faces
250  requested by @a type in the constructor.
251  The face_dofs are ordered according to the given
252  ElementDofOrdering. */
253  void Mult(const Vector &x, Vector &y) const override;
254 
255  /** @brief Gather the degrees of freedom, i.e. goes from face E-Vector to
256  L-Vector.
257 
258  @param[in] x The face E-Vector degrees of freedom with the given format:
259  if L2FacesValues::DoubleValued (face_dofs x vdim x 2 x nf),
260  if L2FacesValues::SingleValued (face_dofs x vdim x nf),
261  where nf is the number of interior or boundary faces
262  requested by @a type in the constructor.
263  The face_dofs should be ordered according to the given
264  ElementDofOrdering
265  @param[in,out] y The L-vector degrees of freedom. */
266  void AddMultTranspose(const Vector &x, Vector &y) const override;
267 
268  /** @brief Fill the I array of SparseMatrix corresponding to the sparsity
269  pattern given by this ParNCL2FaceRestriction.
270 
271  @param[in,out] mat The sparse matrix for which we want to initialize the
272  row offsets.
273  @param[in] keep_nbr_block When set to true the SparseMatrix will
274  include the rows (in addition to the columns)
275  corresponding to face-neighbor dofs. The
276  default behavior is to disregard those rows.
277 
278  @warning This method is not implemented yet. */
279  void FillI(SparseMatrix &mat,
280  const bool keep_nbr_block = false) const override;
281 
282  /** Fill the I array of SparseMatrix corresponding to the sparsity pattern
283  given by this ParNCL2FaceRestriction. @a mat contains the interior dofs
284  contribution, the @a face_mat contains the shared dofs contribution.
285 
286  @warning This method is not implemented yet. */
287  void FillI(SparseMatrix &mat,
288  SparseMatrix &face_mat) const;
289 
290  /** Fill the J and Data arrays of SparseMatrix corresponding to the sparsity
291  pattern given by this ParNCL2FaceRestriction, and the values of ea_data.
292  @a mat contains the interior dofs contribution, the @a face_mat contains
293  the shared dofs contribution.
294 
295  @warning This method is not implemented yet. */
296  void FillJAndData(const Vector &fea_data,
297  SparseMatrix &mat,
298  SparseMatrix &face_mat) const;
299 
300  /** @brief Fill the J and Data arrays of the SparseMatrix corresponding to
301  the sparsity pattern given by this ParNCL2FaceRestriction, and the values
302  of ea_data.
303 
304  @param[in] fea_data The dense matrices representing the local operators
305  on each face. The format is:
306  face_dofs x face_dofs x 2 x nf.
307  On each face the first local matrix corresponds to
308  the contribution of elem1 on elem2, and the second to
309  the contribution of elem2 on elem1.
310  @param[in,out] mat The sparse matrix that is getting filled.
311  @param[in] keep_nbr_block When set to true the SparseMatrix will
312  include the rows (in addition to the columns)
313  corresponding to face-neighbor dofs. The
314  default behavior is to disregard those rows.
315 
316  @warning This method is not implemented yet. */
317  void FillJAndData(const Vector &fea_data,
318  SparseMatrix &mat,
319  const bool keep_nbr_block = false) const override;
320 
321 private:
322  /** @brief Compute the scatter indices: L-vector to E-vector, the offsets
323  for the gathering: E-vector to L-vector, and the interpolators from
324  coarse to fine face for master non-comforming faces.
325 
326  @param[in] ordering Request a specific element ordering.
327  @param[in] type Request internal or boundary faces dofs.
328  */
329  void ComputeScatterIndicesAndOffsets(const ElementDofOrdering ordering,
330  const FaceType type);
331 
332  /** @brief Compute the gather indices: E-vector to L-vector.
333 
334  Note: Requires the gather offsets to be computed.
335 
336  @param[in] ordering Request a specific element ordering.
337  @param[in] type Request internal or boundary faces dofs.
338  */
339  void ComputeGatherIndices(const ElementDofOrdering ordering,
340  const FaceType type);
341 
342 public:
343  /** @brief Scatter the degrees of freedom, i.e. goes from L-Vector to
344  face E-Vector. Should only be used with nonconforming faces and when:
345  L2FaceValues m == L2FaceValues::SingleValued
346 
347  @param[in] x The L-vector degrees of freedom.
348  @param[out] y The face E-Vector degrees of freedom with the given format:
349  (face_dofs x vdim x nf),
350  where nf is the number of interior or boundary faces
351  requested by @a type in the constructor.
352  The face_dofs are ordered according to the given
353  ElementDofOrdering. */
354  void SingleValuedNonconformingMult(const Vector& x, Vector& y) const;
355 
356  /** @brief Scatter the degrees of freedom, i.e. goes from L-Vector to
357  face E-Vector. Should only be used with nonconforming faces and when:
358  L2FaceValues m == L2FaceValues::DoubleValued
359 
360  @param[in] x The L-vector degrees of freedom.
361  @param[out] y The face E-Vector degrees of freedom with the given format:
362  (face_dofs x vdim x 2 x nf),
363  where nf is the number of interior or boundary faces
364  requested by @a type in the constructor.
365  The face_dofs are ordered according to the given
366  ElementDofOrdering. */
367  void DoubleValuedNonconformingMult(const Vector& x, Vector& y) const override;
368 };
369 
370 }
371 
372 #endif // MFEM_USE_MPI
373 
374 #endif // MFEM_PRESTRICTION
void Mult(const Vector &x, Vector &y) const override
Scatter the degrees of freedom, i.e. goes from L-Vector to face E-Vector.
Operator that extracts Face degrees of freedom in parallel.
void DoubleValuedNonconformingMult(const Vector &x, Vector &y) const override
Scatter the degrees of freedom, i.e. goes from L-Vector to face E-Vector. Should only be used with no...
void AddMultTranspose(const Vector &x, Vector &y) const override
Gather the degrees of freedom, i.e. goes from face E-Vector to L-Vector.
Operator that extracts Face degrees of freedom for H1 FiniteElementSpaces.
void Mult(const Vector &x, Vector &y) const override
Scatter the degrees of freedom, i.e. goes from L-Vector to face E-Vector.
ParL2FaceRestriction(const ParFiniteElementSpace &fes, ElementDofOrdering ordering, FaceType type, L2FaceValues m, bool build)
Constructs an ParL2FaceRestriction.
ParNCH1FaceRestriction(const ParFiniteElementSpace &fes, ElementDofOrdering ordering, FaceType type)
Constructs an ParNCH1FaceRestriction.
InterpolationManager interpolations
Operator that extracts face degrees of freedom for L2 nonconforming spaces.
Abstract parallel finite element space.
Definition: pfespace.hpp:28
const L2FaceValues m
void Mult(const Vector &x, Vector &y) const override
Scatter the degrees of freedom, i.e. goes from L-Vector to face E-Vector.
ParNCL2FaceRestriction(const ParFiniteElementSpace &fes, ElementDofOrdering ordering, FaceType type, L2FaceValues m=L2FaceValues::DoubleValued)
Constructs an ParNCL2FaceRestriction.
FaceType
Definition: mesh.hpp:45
const FiniteElementSpace & fes
Data type sparse matrix.
Definition: sparsemat.hpp:46
Operator that extracts Face degrees of freedom for L2 spaces.
Operator that extracts Face degrees of freedom for NCMesh in parallel.
const FiniteElementSpace & fes
void FillJAndData(const Vector &fea_data, SparseMatrix &mat, SparseMatrix &face_mat) const
This class manages the storage and computation of the interpolations from master (coarse) face to sla...
void DoubleValuedConformingMult(const Vector &x, Vector &y) const override
Scatter the degrees of freedom, i.e. goes from L-Vector to face E-Vector. Should only be used with co...
void SingleValuedNonconformingMult(const Vector &x, Vector &y) const
Scatter the degrees of freedom, i.e. goes from L-Vector to face E-Vector. Should only be used with no...
ElementDofOrdering
Constants describing the possible orderings of the DOFs in one element.
Definition: fespace.hpp:66
Operator that extracts Face degrees of freedom for NCMesh in parallel.
Vector data type.
Definition: vector.hpp:60
void FillJAndData(const Vector &ea_data, SparseMatrix &mat, SparseMatrix &face_mat) const
void AddMultTranspose(const Vector &x, Vector &y) const override
Gather the degrees of freedom, i.e. goes from face E-Vector to L-Vector.
void FillI(SparseMatrix &mat, const bool keep_nbr_block=false) const override
void FillI(SparseMatrix &mat, const bool keep_nbr_block=false) const override
Fill the I array of SparseMatrix corresponding to the sparsity pattern given by this ParNCL2FaceRestr...