MFEM v4.8.0
Finite element discretization library
Loading...
Searching...
No Matches
restriction.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2025, 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_RESTRICTION
13#define MFEM_RESTRICTION
14
16#include "../mesh/mesh.hpp"
18
19namespace mfem
20{
21
22class FiniteElementSpace;
23enum class ElementDofOrdering;
24
25class FaceQuadratureSpace;
26
27/// Abstract base class that defines an interface for element restrictions.
29{
30public:
31 /// @brief Add the E-vector degrees of freedom @a x to the L-vector degrees
32 /// of freedom @a y.
33 void AddMultTranspose(const Vector &x, Vector &y,
34 const real_t a = 1.0) const override = 0;
35};
36
37/// Operator that converts FiniteElementSpace L-vectors to E-vectors.
38/** Objects of this type are typically created and owned by FiniteElementSpace
39 objects, see FiniteElementSpace::GetElementRestriction(). */
41{
42protected:
44 const int ne;
45 const int vdim;
46 const bool byvdim;
47 const int ndofs;
48 const int dof;
49 const int nedofs;
53
54public:
56 void Mult(const Vector &x, Vector &y) const override;
57 void MultTranspose(const Vector &x, Vector &y) const override;
58 void AddMultTranspose(const Vector &x, Vector &y,
59 const real_t a = 1.0) const override;
60
61 /// Compute Mult without applying signs based on DOF orientations.
62 void MultUnsigned(const Vector &x, Vector &y) const;
63 /// Compute MultTranspose without applying signs based on DOF orientations.
64 void MultTransposeUnsigned(const Vector &x, Vector &y) const;
65
66 /// Compute MultTranspose by setting (rather than adding) element
67 /// contributions; this is a left inverse of the Mult() operation
68 void MultLeftInverse(const Vector &x, Vector &y) const;
69
70 /// @brief Fills the E-vector y with `boolean` values 0.0 and 1.0 such that each
71 /// each entry of the L-vector is uniquely represented in `y`.
72 /** This means, the sum of the E-vector `y` is equal to the sum of the
73 corresponding L-vector filled with ones. The boolean mask is required to
74 emulate SetSubVector and its transpose on GPUs. This method is running on
75 the host, since the `processed` array requires a large shared memory. */
76 void BooleanMask(Vector& y) const;
77
78 /// Fill a Sparse Matrix with Element Matrices.
79 void FillSparseMatrix(const Vector &mat_ea, SparseMatrix &mat) const;
80
81 /** Fill the I array of SparseMatrix corresponding to the sparsity pattern
82 given by this ElementRestriction. */
83 int FillI(SparseMatrix &mat) const;
84 /** Fill the J and Data arrays of SparseMatrix corresponding to the sparsity
85 pattern given by this ElementRestriction, and the values of ea_data. */
86 void FillJAndData(const Vector &ea_data, SparseMatrix &mat) const;
87 /// @private Not part of the public interface (device kernel limitation).
88 ///
89 /// Performs either MultTranspose or AddMultTranspose depending on the
90 /// boolean template parameter @a ADD.
91 template <bool ADD> void TAddMultTranspose(const Vector &x, Vector &y) const;
92
93 /// @name Low-level access to the underlying element-dof mappings
94 ///@{
95 const Array<int> &GatherMap() const { return gather_map; }
96 const Array<int> &Indices() const { return indices; }
97 const Array<int> &Offsets() const { return offsets; }
98 ///@}
99};
100
101/// Operator that converts L2 FiniteElementSpace L-vectors to E-vectors.
102/** Objects of this type are typically created and owned by FiniteElementSpace
103 objects, see FiniteElementSpace::GetElementRestriction(). L-vectors
104 corresponding to grid functions in L2 finite element spaces differ from
105 E-vectors only in the ordering of the degrees of freedom. */
107{
108 const int ne;
109 const int vdim;
110 const bool byvdim;
111 const int ndof;
112 const int ndofs;
113public:
115 void Mult(const Vector &x, Vector &y) const override;
116 void MultTranspose(const Vector &x, Vector &y) const override;
117 void AddMultTranspose(const Vector &x, Vector &y,
118 const real_t a = 1.0) const override;
119 /** Fill the I array of SparseMatrix corresponding to the sparsity pattern
120 given by this ElementRestriction. */
121 void FillI(SparseMatrix &mat) const;
122 /** Fill the J and Data arrays of SparseMatrix corresponding to the sparsity
123 pattern given by this L2FaceRestriction, and the values of ea_data. */
124 void FillJAndData(const Vector &ea_data, SparseMatrix &mat) const;
125 /// @private Not part of the public interface (device kernel limitation).
126 ///
127 /// Performs either MultTranspose or AddMultTranspose depending on the
128 /// boolean template parameter @a ADD.
129 template <bool ADD> void TAddMultTranspose(const Vector &x, Vector &y) const;
130};
131
132/** An enum type to specify if only e1 value is requested (SingleValued) or both
133 e1 and e2 (DoubleValued). */
135
136/** @brief Base class for operators that extracts Face degrees of freedom.
137
138 In order to compute quantities on the faces of a mesh, it is often useful to
139 extract the degrees of freedom on the faces of the elements. This class
140 provides an interface for such operations.
141
142 If the FiniteElementSpace is ordered by Ordering::byVDIM, then the expected
143 format for the L-vector is (vdim x ndofs), otherwise if Ordering::byNODES
144 the expected format is (ndofs x vdim), where ndofs is the total number of
145 degrees of freedom.
146 Since FiniteElementSpace can either be continuous or discontinuous, the
147 degrees of freedom on a face can either be single valued or double valued,
148 this is what we refer to as the multiplicity and is represented by the
149 L2FaceValues enum type.
150 The format of the output face E-vector of degrees of freedom is
151 (face_dofs x vdim x multiplicity x nfaces), where face_dofs is the number of
152 degrees of freedom on each face, and nfaces the number of faces of the
153 requested FaceType (see FiniteElementSpace::GetNFbyType).
154
155 @note Objects of this type are typically created and owned by
156 FiniteElementSpace objects, see FiniteElementSpace::GetFaceRestriction(). */
158{
159public:
161
162 FaceRestriction(int h, int w): Operator(h, w) { }
163
164 virtual ~FaceRestriction() { }
165
166 /** @brief Extract the face degrees of freedom from @a x into @a y.
167
168 @param[in] x The L-vector of degrees of freedom.
169 @param[out] y The degrees of freedom on the face, corresponding to a face
170 E-vector.
171 */
172 void Mult(const Vector &x, Vector &y) const override = 0;
173
174 /** @brief Add the face degrees of freedom @a x to the element degrees of
175 freedom @a y.
176
177 @param[in] x The face degrees of freedom on the face.
178 @param[in,out] y The L-vector of degrees of freedom to which we add the
179 face degrees of freedom.
180 @param[in] a Scalar coefficient for addition.
181 */
182 void AddMultTranspose(const Vector &x, Vector &y,
183 const real_t a = 1.0) const override = 0;
184
185 /** @brief Add the face degrees of freedom @a x to the element degrees of
186 freedom @a y ignoring the signs from DOF orientation. */
187 virtual void AddMultTransposeUnsigned(const Vector &x, Vector &y,
188 const real_t a = 1.0) const
189 {
190 AddMultTranspose(x, y, a);
191 }
192
193 /** @brief Add the face degrees of freedom @a x to the element degrees of
194 freedom @a y. Perform the same computation as AddMultTranspose, but
195 @a x is invalid after calling this method.
196
197 @param[in,out] x The face degrees of freedom on the face.
198 @param[in,out] y The L-vector of degrees of freedom to which we add the
199 face degrees of freedom.
200
201 @note This method is an optimization of AddMultTranspose where the @a x
202 Vector is used and modified to avoid memory allocation and memcpy.
203 */
204 virtual void AddMultTransposeInPlace(Vector &x, Vector &y) const
205 {
206 AddMultTranspose(x, y);
207 }
208
209 /** @brief Set the face degrees of freedom in the element degrees of freedom
210 @a y to the values given in @a x.
211
212 @param[in] x The face degrees of freedom on the face.
213 @param[in,out] y The L-vector of degrees of freedom to which we add the
214 face degrees of freedom.
215 */
216 void MultTranspose(const Vector &x, Vector &y) const override
217 {
218 y = 0.0;
219 AddMultTranspose(x, y);
220 }
221
222 /** @brief For each face, sets @a y to the partial derivative of @a x with
223 respect to the reference coordinate whose direction is
224 perpendicular to the face on the reference element.
225
226 @details This is not the normal derivative in physical coordinates, but can
227 be mapped to the physical normal derivative using the element
228 Jacobian and the tangential derivatives (in reference coordinates)
229 which can be computed from the face values (provided by Mult).
230
231 Note that due to the polynomial degree of the element mapping, the
232 physical normal derivative may be a higher degree polynomial than
233 the restriction of the values to the face. However, the normal
234 derivative in reference coordinates has degree-1, and therefore can
235 be exactly represented with the degrees of freedom of a face
236 E-vector.
237
238 @param[in] x The L-vector degrees of freedom.
239 @param[in,out] y The reference normal derivative degrees of freedom. Is
240 E-vector like.
241 */
242 virtual void NormalDerivativeMult(const Vector &x, Vector &y) const
243 {
244 MFEM_ABORT("Not implemented for this restriction operator.");
245 }
246
247 /** @brief Add the face reference-normal derivative degrees of freedom in @a
248 x to the element degrees of freedom in @a y.
249
250 @details see NormalDerivativeMult.
251
252 @param[in] x The degrees of freedom of the face reference-normal
253 derivative. Is E-vector like.
254 @param[in,out] y The L-vector degrees of freedom.
255 */
256 virtual void NormalDerivativeAddMultTranspose(const Vector &x, Vector &y) const
257 {
258 MFEM_ABORT("Not implemented for this restriction operator.");
259 }
260
261 /// @brief Low-level access to the underlying gather map.
262 virtual const Array<int> &GatherMap() const
263 {
264 MFEM_ABORT("Not implemented for this restriction operator.");
265 }
266};
267
268/// @brief Operator that extracts face degrees of freedom for H1, ND, or RT
269/// FiniteElementSpaces.
270///
271/// Objects of this type are typically created and owned by FiniteElementSpace
272/// objects, see FiniteElementSpace::GetFaceRestriction().
274{
275protected:
277 const int nf; // Number of faces of the requested type
278 const int vdim;
279 const bool byvdim;
280 const int face_dofs; // Number of dofs on each face
281 const int elem_dofs; // Number of dofs in each element
282 const int nfdofs; // Total number of face E-vector dofs
283 const int ndofs; // Total number of dofs
284 Array<int> scatter_indices; // Scattering indices for element 1 on each face
285 Array<int> gather_offsets; // offsets for the gathering indices of each dof
286 Array<int> gather_indices; // gathering indices for each dof
287 Array<int> vol_dof_map; // mapping from lexicographic to native ordering
288
289 /** @brief Construct a ConformingFaceRestriction.
290
291 @param[in] fes The FiniteElementSpace on which this operates
292 @param[in] f_ordering Request a specific face dof ordering
293 @param[in] type Request internal or boundary faces dofs
294 @param[in] build Request the NCL2FaceRestriction to compute the
295 scatter/gather indices. False should only be used
296 when inheriting from ConformingFaceRestriction.
297 */
299 const ElementDofOrdering f_ordering,
300 const FaceType type,
301 bool build);
302public:
303 /** @brief Construct a ConformingFaceRestriction.
304
305 @param[in] fes The FiniteElementSpace on which this operates
306 @param[in] f_ordering Request a specific face dof ordering
307 @param[in] type Request internal or boundary faces dofs */
309 const ElementDofOrdering f_ordering,
310 const FaceType type);
311
312 /** @brief Scatter the degrees of freedom, i.e. goes from L-Vector to
313 face E-Vector.
314
315 @param[in] x The L-vector degrees of freedom.
316 @param[out] y The face E-Vector degrees of freedom with the given format:
317 face_dofs x vdim x nf
318 where nf is the number of interior or boundary faces
319 requested by @a type in the constructor.
320 The face_dofs are ordered according to the given
321 ElementDofOrdering. */
322 void Mult(const Vector &x, Vector &y) const override;
323
325
326 /** @brief Gather the degrees of freedom, i.e. goes from face E-Vector to
327 L-Vector.
328
329 @param[in] x The face E-Vector degrees of freedom with the given format:
330 face_dofs x vdim x nf
331 where nf is the number of interior or boundary faces
332 requested by @a type in the constructor.
333 The face_dofs should be ordered according to the given
334 ElementDofOrdering
335 @param[in,out] y The L-vector degrees of freedom.
336 @param[in] a Scalar coefficient for addition. */
337 void AddMultTranspose(const Vector &x, Vector &y,
338 const real_t a = 1.0) const override;
339
340 /** @brief Gather the degrees of freedom, i.e. goes from face E-Vector to
341 L-Vector @b not taking into account signs from DOF orientations.
342
343 @sa AddMultTranspose(). */
344 void AddMultTransposeUnsigned(const Vector &x, Vector &y,
345 const real_t a = 1.0) const override;
346
347private:
348 /** @brief Compute the scatter indices: L-vector to E-vector, and the offsets
349 for the gathering: E-vector to L-vector.
350
351 @param[in] f_ordering Request a specific face dof ordering.
352 @param[in] type Request internal or boundary faces dofs.
353 */
354 void ComputeScatterIndicesAndOffsets(const ElementDofOrdering f_ordering,
355 const FaceType type);
356
357 /** @brief Compute the gather indices: E-vector to L-vector.
358
359 Note: Requires the gather offsets to be computed.
360
361 @param[in] f_ordering Request a specific face dof ordering.
362 @param[in] type Request internal or boundary faces dofs.
363 */
364 void ComputeGatherIndices(const ElementDofOrdering f_ordering,
365 const FaceType type);
366
367protected:
368 mutable Array<int> face_map; // Used in the computation of GetFaceDofs
369
370 /** @brief Verify that ConformingFaceRestriction is built from a supported
371 finite element space.
372
373 @param[in] f_ordering The requested face dof ordering.
374 */
375 void CheckFESpace(const ElementDofOrdering f_ordering);
376
377 /** @brief Set the scattering indices of elem1, and increment the offsets for
378 the face described by the @a face.
379
380 @param[in] face The face information of the current face.
381 @param[in] face_index The interior/boundary face index.
382 @param[in] f_ordering Request a specific face dof ordering.
383 */
385 const int face_index,
386 const ElementDofOrdering f_ordering);
387
388 /** @brief Set the gathering indices of elem1 for the interior face described
389 by the @a face.
390
391 @param[in] face The face information of the current face.
392 @param[in] face_index The interior/boundary face index.
393 @param[in] f_ordering Request a specific face dof ordering.
394 */
396 const int face_index,
397 const ElementDofOrdering f_ordering);
398};
399
400/// @brief Alias for ConformingFaceRestriction, for backwards compatibility and
401/// as base class for ParNCH1FaceRestriction.
403
404/// Operator that extracts Face degrees of freedom for L2 spaces.
405/** Objects of this type are typically created and owned by FiniteElementSpace
406 objects, see FiniteElementSpace::GetFaceRestriction(). */
408{
409protected:
412 const int nf; // Number of faces of the requested type
413 const int ne; // Number of elements
414 const int vdim; // vdim
415 const bool byvdim;
416 const int face_dofs; // Number of dofs on each face
417 const int elem_dofs; // Number of dofs in each element
418 const int nfdofs; // Total number of dofs on the faces
419 const int ndofs; // Total number of dofs
422 Array<int> scatter_indices1; // Scattering indices for element 1 on each face
423 Array<int> scatter_indices2; // Scattering indices for element 2 on each face
424 Array<int> gather_offsets; // offsets for the gathering indices of each dof
425 Array<int> gather_indices; // gathering indices for each dof
426 mutable std::unique_ptr<L2NormalDerivativeFaceRestriction> normal_deriv_restr;
427
428 /** @brief Constructs an L2FaceRestriction.
429
430 @param[in] fes The FiniteElementSpace on which this operates
431 @param[in] f_ordering Request a specific face dof ordering
432 @param[in] type Request internal or boundary faces dofs
433 @param[in] m Request the face dofs for elem1, or both elem1 and
434 elem2
435 @param[in] build Request the NCL2FaceRestriction to compute the
436 scatter/gather indices. False should only be used
437 when inheriting from L2FaceRestriction.
438 */
440 const ElementDofOrdering f_ordering,
441 const FaceType type,
442 const L2FaceValues m,
443 bool build);
444
445public:
446 /** @brief Constructs an L2FaceRestriction.
447
448 @param[in] fes The FiniteElementSpace on which this operates
449 @param[in] f_ordering Request a specific face dof ordering
450 @param[in] type Request internal or boundary faces dofs
451 @param[in] m Request the face dofs for elem1, or both elem1 and
452 elem2 */
454 const ElementDofOrdering f_ordering,
455 const FaceType type,
457
458 /** @brief Scatter the degrees of freedom, i.e. goes from L-Vector to
459 face E-Vector.
460
461 @param[in] x The L-vector degrees of freedom.
462 @param[out] y The face E-Vector degrees of freedom with the given format:
463 if L2FacesValues::DoubleValued (face_dofs x vdim x 2 x nf)
464 if L2FacesValues::SingleValued (face_dofs x vdim x nf)
465 where nf is the number of interior or boundary faces
466 requested by @a type in the constructor.
467 The face_dofs are ordered according to the given
468 ElementDofOrdering. */
469 void Mult(const Vector &x, Vector &y) const override;
470
472
473 /** @brief Gather the degrees of freedom, i.e. goes from face E-Vector to
474 L-Vector.
475
476 @param[in] x The face E-Vector degrees of freedom with the given format:
477 if L2FacesValues::DoubleValued (face_dofs x vdim x 2 x nf)
478 if L2FacesValues::SingleValued (face_dofs x vdim x nf)
479 where nf is the number of interior or boundary faces
480 requested by @a type in the constructor.
481 The face_dofs should be ordered according to the given
482 ElementDofOrdering
483 @param[in,out] y The L-vector degrees of freedom.
484 @param[in] a Scalar coefficient for addition. */
485 void AddMultTranspose(const Vector &x, Vector &y,
486 const real_t a = 1.0) const override;
487
488 /** @brief Fill the I array of SparseMatrix corresponding to the sparsity
489 pattern given by this L2FaceRestriction.
490
491 @param[in,out] mat The sparse matrix for which we want to initialize the
492 row offsets.
493 @param[in] keep_nbr_block When set to true the SparseMatrix will
494 include the rows (in addition to the columns)
495 corresponding to face-neighbor dofs. The
496 default behavior is to disregard those rows. */
497 virtual void FillI(SparseMatrix &mat, const bool keep_nbr_block = false) const;
498
499 /** @brief Fill the J and Data arrays of the SparseMatrix corresponding to
500 the sparsity pattern given by this L2FaceRestriction, and the values of
501 fea_data.
502
503 @param[in] fea_data The dense matrices representing the local operators
504 on each face. The format is:
505 face_dofs x face_dofs x 2 x nf
506 On each face the first local matrix corresponds to
507 the contribution of elem1 on elem2, and the second to
508 the contribution of elem2 on elem1.
509 @param[in,out] mat The sparse matrix that is getting filled.
510 @param[in] keep_nbr_block When set to true the SparseMatrix will
511 include the rows (in addition to the columns)
512 corresponding to face-neighbor dofs. The
513 default behavior is to disregard those rows. */
514 virtual void FillJAndData(const Vector &fea_data,
515 SparseMatrix &mat,
516 const bool keep_nbr_block = false) const;
517
518 /** @brief This methods adds the DG face matrices to the element matrices.
519
520 @param[in] fea_data The dense matrices representing the local operators
521 on each face. The format is:
522 face_dofs x face_dofs x 2 x nf
523 On each face the first and second local matrices
524 correspond to the contributions of elem1 and elem2 on
525 themselves respectively.
526 @param[in,out] ea_data The dense matrices representing the element local
527 contributions for each element to which will be
528 added the face contributions.
529 The format is: dofs x dofs x ne, where dofs is the
530 number of dofs per element and ne the number of
531 elements. */
532 virtual void AddFaceMatricesToElementMatrices(const Vector &fea_data,
533 Vector &ea_data) const;
534
535 /** @brief Scatter the degrees of freedom, i.e. goes from L-Vector to
536 face E-Vector.
537
538 @param[in] x The L-vector degrees of freedom.
539 @param[out] y The face E-Vector degrees of freedom with the given format:
540 (face_dofs x vdim x 2 x nf) where nf is the number of
541 interior or boundary faces requested by @a type in the
542 constructor. The face_dofs are ordered according to the
543 given ElementDofOrdering. */
544 void NormalDerivativeMult(const Vector &x, Vector &y) const override;
545
546 /** @brief Add the face reference-normal derivative degrees of freedom in @a
547 x to the element degrees of freedom in @a y.
548
549 @details see NormalDerivativeMult.
550
551 @param[in] x The degrees of freedom of the face reference-normal
552 derivative. Is E-vector like.
553 @param[in,out] y The L-vector degrees of freedom.
554 */
556 Vector &y) const override;
557private:
558 /** @brief Compute the scatter indices: L-vector to E-vector, and the offsets
559 for the gathering: E-vector to L-vector.
560 */
561 void ComputeScatterIndicesAndOffsets();
562
563 /** @brief Compute the gather indices: E-vector to L-vector.
564
565 Note: Requires the gather offsets to be computed.
566 */
567 void ComputeGatherIndices();
568
569 /// Create the internal normal derivative restriction operator if needed.
570 void EnsureNormalDerivativeRestriction() const;
571
572protected:
573 mutable Array<int> face_map; // Used in the computation of GetFaceDofs
574
575 /** @brief Verify that L2FaceRestriction is built from an L2 FESpace.
576 */
577 void CheckFESpace();
578
579 /** @brief Set the scattering indices of elem1, and increment the offsets for
580 the face described by the @a face. The ordering of the face dofs of elem1
581 is lexicographic relative to elem1.
582
583 @param[in] face The face information of the current face.
584 @param[in] face_index The interior/boundary face index.
585 */
587 const int face_index);
588
589 /** @brief Permute and set the scattering indices of elem2, and increment the
590 offsets for the face described by the @a face. The permutation orders the
591 dofs of elem2 lexicographically as the ones of elem1.
592
593 @param[in] face The face information of the current face.
594 @param[in] face_index The interior/boundary face index.
595 */
597 const int face_index);
598
599 /** @brief Permute and set the scattering indices of elem2 for the shared
600 face described by the @a face. The permutation orders the dofs of elem2 as
601 the ones of elem1.
602
603 @param[in] face The face information of the current face.
604 @param[in] face_index The interior/boundary face index.
605 */
607 const Mesh::FaceInformation &face,
608 const int face_index);
609
610 /** @brief Set the scattering indices of elem2 for the boundary face
611 described by the @a face.
612
613 @param[in] face The face information of the current face.
614 @param[in] face_index The interior/boundary face index.
615 */
617 const int face_index);
618
619 /** @brief Set the gathering indices of elem1 for the interior face described
620 by the @a face.
621
622 Note: This function modifies the offsets.
623
624 @param[in] face The face information of the current face.
625 @param[in] face_index The interior/boundary face index.
626 */
628 const int face_index);
629
630 /** @brief Permute and set the gathering indices of elem2 for the interior
631 face described by the @a face. The permutation orders the dofs of elem2 as
632 the ones of elem1.
633
634 Note: This function modifies the offsets.
635
636 @param[in] face The face information of the current face.
637 @param[in] face_index The interior/boundary face index.
638 */
640 const int face_index);
641
642public:
643 /** @brief Scatter the degrees of freedom, i.e. goes from L-Vector to
644 face E-Vector. Should only be used with conforming faces and when:
645 m == L2FacesValues::SingleValued
646
647 @param[in] x The L-vector degrees of freedom.
648 @param[out] y The face E-Vector degrees of freedom with the given format:
649 face_dofs x vdim x nf
650 where nf is the number of interior or boundary faces
651 requested by @a type in the constructor.
652 The face_dofs are ordered according to the given
653 ElementDofOrdering. */
654 void SingleValuedConformingMult(const Vector& x, Vector& y) const;
655
656 /** @brief Scatter the degrees of freedom, i.e. goes from L-Vector to
657 face E-Vector. Should only be used with conforming faces and when:
658 m == L2FacesValues::DoubleValued
659
660 @param[in] x The L-vector degrees of freedom.
661 @param[out] y The face E-Vector degrees of freedom with the given format:
662 face_dofs x vdim x 2 x nf
663 where nf is the number of interior or boundary faces
664 requested by @a type in the constructor.
665 The face_dofs are ordered according to the given
666 ElementDofOrdering. */
667 virtual void DoubleValuedConformingMult(const Vector& x, Vector& y) const;
668
669 /** @brief Gather the degrees of freedom, i.e. goes from face E-Vector to
670 L-Vector. Should only be used with conforming faces and when:
671 m == L2FacesValues::SingleValued
672
673 @param[in] x The face E-Vector degrees of freedom with the given format:
674 face_dofs x vdim x nf
675 where nf is the number of interior or boundary faces
676 requested by @a type in the constructor.
677 The face_dofs should be ordered according to the given
678 ElementDofOrdering
679 @param[in,out] y The L-vector degrees of freedom. */
681
682 /** @brief Gather the degrees of freedom, i.e. goes from face E-Vector to
683 L-Vector. Should only be used with conforming faces and when:
684 m == L2FacesValues::DoubleValued
685
686 @param[in] x The face E-Vector degrees of freedom with the given format:
687 face_dofs x vdim x 2 x nf
688 where nf is the number of interior or boundary faces
689 requested by @a type in the constructor.
690 The face_dofs should be ordered according to the given
691 ElementDofOrdering
692 @param[in,out] y The L-vector degrees of freedom. */
694};
695
696/** This struct stores which side is the master nonconforming side and the
697 index of the interpolator, see InterpolationManager class below. */
699{
700 uint32_t is_non_conforming : 1;
701 uint32_t master_side : 1;
702 uint32_t index : 30;
703
704 // default constructor, create a conforming face with index 0.
705 InterpConfig() = default;
706
707 // Non-conforming face
708 InterpConfig(int master_side, int nc_index)
710 { }
711
712 InterpConfig(const InterpConfig&) = default;
713
714 InterpConfig &operator=(const InterpConfig &rhs) = default;
715};
716
717/** This struct stores which side is the master nonconforming side and the
718 index of the interpolator, see InterpolationManager class below. */
720{
722 uint32_t is_non_conforming : 1;
723 uint32_t master_side : 1;
724 uint32_t index : 30;
725
726 // default constructor.
727 NCInterpConfig() = default;
728
729 // Non-conforming face
730 NCInterpConfig(int face_index, int master_side, int nc_index)
734 index(nc_index)
735 { }
736
737 // Non-conforming face
744
746
748};
749
750/** @brief This class manages the storage and computation of the interpolations
751 from master (coarse) face to slave (fine) face.
752*/
754{
755protected:
758 Array<InterpConfig> interp_config; // interpolator index for each face
759 Array<NCInterpConfig> nc_interp_config; // interpolator index for each ncface
760 Vector interpolators; // face_dofs x face_dofs x num_interpolators
761 int nc_cpt; // Counter for interpolators, and used as index.
762
763 /** The interpolators are associated to a key of containing the address of
764 PointMatrix and a local face identifier. */
765 using Key = std::pair<const DenseMatrix*,int>;
766 /// The temporary map used to store the different interpolators.
767 using Map = std::map<Key, std::pair<int,const DenseMatrix*>>;
768 Map interp_map; // The temporary map that stores the interpolators.
769
770public:
772
773 /** @brief main constructor.
774
775 @param[in] fes The FiniteElementSpace on which this operates
776 @param[in] ordering Request a specific element ordering.
777 @param[in] type Request internal or boundary faces dofs
778 */
781 FaceType type);
782
783 /** @brief Register the face with @a face and index @a face_index as a
784 conforming face for the interpolation of the degrees of freedom.
785
786 @param[in] face The face information of the current face.
787 @param[in] face_index The interior/boundary face index.
788 */
790 int face_index);
791
792 /** @brief Register the face with @a face and index @a face_index as a
793 conforming face for the interpolation of the degrees of freedom.
794
795 @param[in] face The face information of the current face.
796 @param[in] face_index The interior/boundary face index.
797 */
799 int face_index);
800
801 /** @brief Transform the interpolation matrix map into a contiguous memory
802 structure. */
804
806
807 /// @brief Return the total number of interpolators.
809 {
810 return nc_cpt;
811 }
812
813 /** @brief Return an mfem::Vector containing the interpolators in the
814 following format: face_dofs x face_dofs x num_interpolators. */
816 {
817 return interpolators;
818 }
819
820 /** @brief Return an array containing the interpolation configuration for
821 each face registered with RegisterFaceConformingInterpolation and
822 RegisterFaceCoarseToFineInterpolation. */
824 {
825 return interp_config;
826 }
827
828 /** @brief Return an array containing the interpolation configuration for
829 each face registered with RegisterFaceConformingInterpolation and
830 RegisterFaceCoarseToFineInterpolation. */
832 {
833 return nc_interp_config;
834 }
835
836private:
837 /** @brief Returns the interpolation operator from a master (coarse) face to
838 a slave (fine) face.
839
840 @param[in] face The face information of the current face.
841 @param[in] ptMat The PointMatrix describing the position and orientation
842 of the fine face in the coarse face. This PointMatrix is
843 usually obtained from the mesh through the method
844 GetNCFacesPtMat.
845 @param[in] ordering Request a specific element ordering.
846 @return The dense matrix corresponding to the interpolation of the face
847 degrees of freedom of the master (coarse) face to the slave
848 (fine) face. */
849 const DenseMatrix* GetCoarseToFineInterpolation(
850 const Mesh::FaceInformation &face,
851 const DenseMatrix* ptMat);
852};
853
854/** @brief Operator that extracts face degrees of freedom for L2 nonconforming
855 spaces.
856
857 In order to support face restrictions on nonconforming meshes, this
858 operator interpolates master (coarse) face degrees of freedom onto the
859 slave (fine) face. This allows face integrators to treat nonconforming
860 faces just as regular conforming faces. */
862{
863protected:
866
867 /** @brief Constructs an NCL2FaceRestriction, this is a specialization of a
868 L2FaceRestriction for nonconforming meshes.
869
870 @param[in] fes The FiniteElementSpace on which this operates
871 @param[in] f_ordering Request a specific face dof ordering
872 @param[in] type Request internal or boundary faces dofs
873 @param[in] m Request the face dofs for elem1, or both elem1 and
874 elem2
875 @param[in] build Request the NCL2FaceRestriction to compute the
876 scatter/gather indices. False should only be used
877 when inheriting from NCL2FaceRestriction.
878 */
880 const ElementDofOrdering f_ordering,
881 const FaceType type,
882 const L2FaceValues m,
883 bool build);
884public:
885 /** @brief Constructs an NCL2FaceRestriction, this is a specialization of a
886 L2FaceRestriction for nonconforming meshes.
887
888 @param[in] fes The FiniteElementSpace on which this operates
889 @param[in] f_ordering Request a specific face dof ordering
890 @param[in] type Request internal or boundary faces dofs
891 @param[in] m Request the face dofs for elem1, or both elem1 and
892 elem2
893 */
895 const ElementDofOrdering f_ordering,
896 const FaceType type,
898
899 /** @brief Scatter the degrees of freedom, i.e. goes from L-Vector to
900 face E-Vector.
901
902 @param[in] x The L-vector degrees of freedom.
903 @param[out] y The face E-Vector degrees of freedom with the given format:
904 if L2FacesValues::DoubleValued (face_dofs x vdim x 2 x nf),
905 if L2FacesValues::SingleValued (face_dofs x vdim x nf),
906 where nf is the number of interior or boundary faces
907 requested by @a type in the constructor.
908 The face_dofs are ordered according to the given
909 ElementDofOrdering. */
910 void Mult(const Vector &x, Vector &y) const override;
911
912 /** @brief Gather the degrees of freedom, i.e. goes from face E-Vector to
913 L-Vector.
914
915 @param[in] x The face E-Vector degrees of freedom with the given format:
916 if L2FacesValues::DoubleValued (face_dofs x vdim x 2 x nf),
917 if L2FacesValues::SingleValued (face_dofs x vdim x nf),
918 where nf is the number of interior or boundary faces
919 requested by @a type in the constructor.
920 The face_dofs should be ordered according to the given
921 ElementDofOrdering
922 @param[in,out] y The L-vector degrees of freedom.
923 @param[in] a Scalar coefficient for addition. */
924 void AddMultTranspose(const Vector &x, Vector &y,
925 const real_t a = 1.0) const override;
926
927 /** @brief Gather the degrees of freedom, i.e. goes from face E-Vector to
928 L-Vector.
929
930 @param[in,out] x The face E-Vector degrees of freedom with the given format:
931 if L2FacesValues::DoubleValued (face_dofs x vdim x 2 x nf),
932 if L2FacesValues::SingleValued (face_dofs x vdim x nf),
933 where nf is the number of interior or boundary faces
934 requested by @a type in the constructor.
935 The face_dofs should be ordered according to the given
936 ElementDofOrdering
937 @param[in,out] y The L-vector degrees of freedom.
938
939 @note This method is an optimization of AddMultTranspose where the @a x
940 Vector is used and modified to avoid memory allocation and memcpy. */
941 void AddMultTransposeInPlace(Vector &x, Vector &y) const override;
942
943 /** @brief Fill the I array of SparseMatrix corresponding to the sparsity
944 pattern given by this NCL2FaceRestriction.
945
946 @param[in,out] mat The sparse matrix for which we want to initialize the
947 row offsets.
948 @param[in] keep_nbr_block When set to true the SparseMatrix will
949 include the rows (in addition to the columns)
950 corresponding to face-neighbor dofs. The
951 default behavior is to disregard those rows.
952
953 @warning This method is not implemented yet. */
954 void FillI(SparseMatrix &mat,
955 const bool keep_nbr_block = false) const override;
956
957 /** @brief Fill the J and Data arrays of the SparseMatrix corresponding to
958 the sparsity pattern given by this NCL2FaceRestriction, and the values of
959 ea_data.
960
961 @param[in] fea_data The dense matrices representing the local operators
962 on each face. The format is:
963 face_dofs x face_dofs x 2 x nf.
964 On each face the first local matrix corresponds to
965 the contribution of elem1 on elem2, and the second to
966 the contribution of elem2 on elem1.
967 @param[in,out] mat The sparse matrix that is getting filled.
968 @param[in] keep_nbr_block When set to true the SparseMatrix will
969 include the rows (in addition to the columns)
970 corresponding to face-neighbor dofs. The
971 default behavior is to disregard those rows.
972
973 @warning This method is not implemented yet. */
974 void FillJAndData(const Vector &fea_data,
975 SparseMatrix &mat,
976 const bool keep_nbr_block = false) const override;
977
978 /** @brief This methods adds the DG face matrices to the element matrices.
979
980 @param[in] fea_data The dense matrices representing the local operators
981 on each face. The format is:
982 face_dofs x face_dofs x 2 x nf.
983 On each face the first and second local matrices
984 correspond to the contributions of elem1 and elem2 on
985 themselves respectively.
986 @param[in,out] ea_data The dense matrices representing the element local
987 contributions for each element to which will be
988 added the face contributions.
989 The format is: dofs x dofs x ne, where dofs is the
990 number of dofs per element and ne the number of
991 elements.
992
993 @warning This method is not implemented yet. */
994 void AddFaceMatricesToElementMatrices(const Vector &fea_data,
995 Vector &ea_data) const override;
996
997private:
998 /** @brief Compute the scatter indices: L-vector to E-vector, the offsets
999 for the gathering: E-vector to L-vector, and the interpolators from
1000 coarse to fine face for master non-comforming faces.
1001 */
1002 void ComputeScatterIndicesAndOffsets();
1003
1004 /** @brief Compute the gather indices: E-vector to L-vector.
1005
1006 Note: Requires the gather offsets to be computed.
1007 */
1008 void ComputeGatherIndices();
1009
1010public:
1011 /** @brief Scatter the degrees of freedom, i.e. goes from L-Vector to
1012 face E-Vector. Should only be used with nonconforming faces and when:
1013 L2FaceValues m == L2FaceValues::DoubleValued
1014
1015 @param[in] x The L-vector degrees of freedom.
1016 @param[out] y The face E-Vector degrees of freedom with the given format:
1017 (face_dofs x vdim x 2 x nf),
1018 where nf is the number of interior or boundary faces
1019 requested by @a type in the constructor.
1020 The face_dofs are ordered according to the given
1021 ElementDofOrdering. */
1022 virtual void DoubleValuedNonconformingMult(const Vector& x, Vector& y) const;
1023
1024 /** @brief Apply a change of basis from coarse element basis to fine element
1025 basis for the coarse face dofs.
1026
1027 @param[in,out] x The dofs vector that needs coarse dofs to be express in
1028 term of the fine basis.
1029 */
1031
1032 /** @brief Apply a change of basis from fine element basis to coarse element
1033 basis for the coarse face dofs. Should only be used when:
1034 L2FaceValues m == L2FaceValues::SingleValued
1035
1036 @param[in] x The dofs vector that needs coarse dofs to be express in term
1037 of the coarse basis, the result is stored in x_interp.
1038 */
1040
1041 /** @brief Apply a change of basis from fine element basis to coarse element
1042 basis for the coarse face dofs. Should only be used when:
1043 L2FaceValues m == L2FaceValues::SingleValued
1044
1045 @param[in,out] x The dofs vector that needs coarse dofs to be express in
1046 term of the coarse basis, the result is stored in x.
1047 */
1049
1050 /** @brief Apply a change of basis from fine element basis to coarse element
1051 basis for the coarse face dofs. Should only be used when:
1052 L2FaceValues m == L2FaceValues::DoubleValued
1053
1054 @param[in] x The dofs vector that needs coarse dofs to be express in term
1055 of the coarse basis, the result is stored in x_interp.
1056 */
1058
1059 /** @brief Apply a change of basis from fine element basis to coarse element
1060 basis for the coarse face dofs. Should only be used when:
1061 L2FaceValues m == L2FaceValues::DoubleValued
1062
1063 @param[in,out] x The dofs vector that needs coarse dofs to be express in
1064 term of the coarse basis, the result is stored in
1065 x.
1066 */
1068};
1069
1070/// Operator that extracts face degrees of freedom for L2 interface spaces.
1071/** Objects of this type are typically created and owned by FiniteElementSpace
1072 objects, see FiniteElementSpace::GetFaceRestriction(). */
1074{
1075protected:
1076 const FiniteElementSpace &fes; ///< The finite element space
1077 const ElementDofOrdering ordering; ///< Requested ordering
1078 const FaceType type; ///< Face type (interior or boundary)
1079 const int nfaces; ///< Number of faces of the requested type
1080 const int vdim; ///< vdim of the space
1081 const bool byvdim; ///< DOF ordering (by nodes or by vdim)
1082 const int face_dofs; ///< Number of dofs on each face
1083 const int nfdofs; ///< Total number of dofs on the faces (E-vector size)
1084 const int ndofs; ///< Number of dofs in the space (L-vector size)
1085 Array<int> gather_map; ///< Gather map
1086
1087public:
1088 /** @brief Constructs an L2InterfaceFaceRestriction.
1089
1090 @param[in] fes_ The FiniteElementSpace on which this operates
1091 @param[in] ordering_ Request a specific face dof ordering
1092 @param[in] type_ Request internal or boundary faces dofs */
1094 const ElementDofOrdering ordering_,
1095 const FaceType type_);
1096
1097 /** @brief Scatter the degrees of freedom, i.e. goes from L-Vector to
1098 face E-Vector.
1099
1100 @param[in] x The L-vector degrees of freedom.
1101 @param[out] y The face E-Vector degrees of freedom with size (face_dofs,
1102 vdim, nf), where nf is the number of interior or boundary
1103 faces requested by @a type in the constructor. The
1104 face_dofs are ordered according to the given
1105 ElementDofOrdering. */
1106 void Mult(const Vector &x, Vector &y) const override;
1107
1109
1110 /** @brief Gather the degrees of freedom, i.e. goes from face E-Vector to
1111 L-Vector.
1112
1113 @param[in] x The face E-Vector degrees of freedom with size
1114 (face_dofs, vdim, nf), where nf is the number of
1115 interior or boundary faces requested by @a type in the
1116 constructor. The face_dofs should be ordered according
1117 to the given ElementDofOrdering
1118 @param[in,out] y The L-vector degrees of freedom.
1119 @param[in] a Scalar coefficient for addition. */
1120 void AddMultTranspose(const Vector &x, Vector &y,
1121 const real_t a = 1.0) const override;
1122
1123 const Array<int> &GatherMap() const override;
1124};
1125
1126/** @brief Convert a dof face index from Native ordering to lexicographic
1127 ordering for quads and hexes.
1128
1129 @param[in] dim The dimension of the element, 2 for quad, 3 for hex
1130 @param[in] face_id The local face identifier
1131 @param[in] size1d The 1D number of degrees of freedom for each dimension
1132 @param[in] index The native index on the face
1133 @return The lexicographic index on the face
1134*/
1135int ToLexOrdering(const int dim, const int face_id, const int size1d,
1136 const int index);
1137
1138/** @brief Compute the dof face index of elem2 corresponding to the given dof
1139 face index.
1140
1141 @param[in] dim The dimension of the element, 2 for quad, 3 for hex
1142 @param[in] face_id1 The local face identifier of elem1
1143 @param[in] face_id2 The local face identifier of elem2
1144 @param[in] orientation The orientation of elem2 relative to elem1 on the
1145 face
1146 @param[in] size1d The 1D number of degrees of freedom for each dimension
1147 @param[in] index The dof index on elem1
1148 @return The dof index on elem2 facing the dof on elem1
1149*/
1150int PermuteFaceL2(const int dim, const int face_id1,
1151 const int face_id2, const int orientation,
1152 const int size1d, const int index);
1153
1154/// @brief Return the face-neighbor data given the L-vector @a x.
1155///
1156/// If the input vector @a x is a ParGridFunction with non-empty face-neighbor
1157/// data, return an alias to ParGridFunction::FaceNbrData() (avoiding an
1158/// unneeded call to ParGridFunction::ExchangeFaceNbrData).
1159///
1160/// Otherwise, create a temporary ParGridFunction, exchange the face-neighbor
1161/// data, and return the resulting vector.
1162///
1163/// If @a fes is not a parallel space, or if @a ftype is not FaceType::Interior,
1164/// return an empty vector.
1166 const FiniteElementSpace &fes, const Vector &x, FaceType ftype);
1167
1168}
1169
1170#endif // MFEM_RESTRICTION
Operator that extracts face degrees of freedom for H1, ND, or RT FiniteElementSpaces.
ConformingFaceRestriction(const FiniteElementSpace &fes, const ElementDofOrdering f_ordering, const FaceType type, bool build)
Construct a ConformingFaceRestriction.
void CheckFESpace(const ElementDofOrdering f_ordering)
Verify that ConformingFaceRestriction is built from a supported finite element space.
void SetFaceDofsGatherIndices(const Mesh::FaceInformation &face, const int face_index, const ElementDofOrdering f_ordering)
Set the gathering indices of elem1 for the interior face described by the face.
void AddMultTransposeUnsigned(const Vector &x, Vector &y, const real_t a=1.0) const override
Gather the degrees of freedom, i.e. goes from face E-Vector to L-Vector not taking into account signs...
const FiniteElementSpace & fes
void AddMultTranspose(const Vector &x, Vector &y, const real_t a=1.0) const override
Gather the degrees of freedom, i.e. goes from face E-Vector to L-Vector.
void SetFaceDofsScatterIndices(const Mesh::FaceInformation &face, const int face_index, const ElementDofOrdering f_ordering)
Set the scattering indices of elem1, and increment the offsets for the face described by the face.
void Mult(const Vector &x, Vector &y) const override
Scatter the degrees of freedom, i.e. goes from L-Vector to face E-Vector.
Data type dense matrix using column-major storage.
Definition densemat.hpp:24
Abstract base class that defines an interface for element restrictions.
void AddMultTranspose(const Vector &x, Vector &y, const real_t a=1.0) const override=0
Add the E-vector degrees of freedom x to the L-vector degrees of freedom y.
Operator that converts FiniteElementSpace L-vectors to E-vectors.
ElementRestriction(const FiniteElementSpace &, ElementDofOrdering)
const FiniteElementSpace & fes
void Mult(const Vector &x, Vector &y) const override
Operator application: y=A(x).
const Array< int > & GatherMap() const
void FillSparseMatrix(const Vector &mat_ea, SparseMatrix &mat) const
Fill a Sparse Matrix with Element Matrices.
void AddMultTranspose(const Vector &x, Vector &y, const real_t a=1.0) const override
Add the E-vector degrees of freedom x to the L-vector degrees of freedom y.
void FillJAndData(const Vector &ea_data, SparseMatrix &mat) const
void MultTranspose(const Vector &x, Vector &y) const override
Action of the transpose operator: y=A^t(x). The default behavior in class Operator is to generate an ...
void MultTransposeUnsigned(const Vector &x, Vector &y) const
Compute MultTranspose without applying signs based on DOF orientations.
const Array< int > & Offsets() const
void MultLeftInverse(const Vector &x, Vector &y) const
const Array< int > & Indices() const
void BooleanMask(Vector &y) const
Fills the E-vector y with boolean values 0.0 and 1.0 such that each each entry of the L-vector is uni...
void MultUnsigned(const Vector &x, Vector &y) const
Compute Mult without applying signs based on DOF orientations.
int FillI(SparseMatrix &mat) const
Base class for operators that extracts Face degrees of freedom.
virtual void AddMultTransposeInPlace(Vector &x, Vector &y) const
Add the face degrees of freedom x to the element degrees of freedom y. Perform the same computation a...
void AddMultTranspose(const Vector &x, Vector &y, const real_t a=1.0) const override=0
Add the face degrees of freedom x to the element degrees of freedom y.
virtual void NormalDerivativeAddMultTranspose(const Vector &x, Vector &y) const
Add the face reference-normal derivative degrees of freedom in x to the element degrees of freedom in...
virtual void AddMultTransposeUnsigned(const Vector &x, Vector &y, const real_t a=1.0) const
Add the face degrees of freedom x to the element degrees of freedom y ignoring the signs from DOF ori...
FaceRestriction(int h, int w)
virtual void NormalDerivativeMult(const Vector &x, Vector &y) const
For each face, sets y to the partial derivative of x with respect to the reference coordinate whose d...
void MultTranspose(const Vector &x, Vector &y) const override
Set the face degrees of freedom in the element degrees of freedom y to the values given in x.
virtual const Array< int > & GatherMap() const
Low-level access to the underlying gather map.
void Mult(const Vector &x, Vector &y) const override=0
Extract the face degrees of freedom from x into y.
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition fespace.hpp:244
This class manages the storage and computation of the interpolations from master (coarse) face to sla...
std::map< Key, std::pair< int, const DenseMatrix * > > Map
The temporary map used to store the different interpolators.
std::pair< const DenseMatrix *, int > Key
const Array< NCInterpConfig > & GetNCFaceInterpConfig() const
Return an array containing the interpolation configuration for each face registered with RegisterFace...
void RegisterFaceCoarseToFineInterpolation(const Mesh::FaceInformation &face, int face_index)
Register the face with face and index face_index as a conforming face for the interpolation of the de...
int GetNumInterpolators() const
Return the total number of interpolators.
Array< NCInterpConfig > nc_interp_config
const Vector & GetInterpolators() const
Return an mfem::Vector containing the interpolators in the following format: face_dofs x face_dofs x ...
void LinearizeInterpolatorMapIntoVector()
Transform the interpolation matrix map into a contiguous memory structure.
const FiniteElementSpace & fes
const ElementDofOrdering ordering
Array< InterpConfig > interp_config
void RegisterFaceConformingInterpolation(const Mesh::FaceInformation &face, int face_index)
Register the face with face and index face_index as a conforming face for the interpolation of the de...
const Array< InterpConfig > & GetFaceInterpConfig() const
Return an array containing the interpolation configuration for each face registered with RegisterFace...
Operator that converts L2 FiniteElementSpace L-vectors to E-vectors.
L2ElementRestriction(const FiniteElementSpace &)
void AddMultTranspose(const Vector &x, Vector &y, const real_t a=1.0) const override
Add the E-vector degrees of freedom x to the L-vector degrees of freedom y.
void FillJAndData(const Vector &ea_data, SparseMatrix &mat) const
void MultTranspose(const Vector &x, Vector &y) const override
Action of the transpose operator: y=A^t(x). The default behavior in class Operator is to generate an ...
void FillI(SparseMatrix &mat) const
void Mult(const Vector &x, Vector &y) const override
Operator application: y=A(x).
Operator that extracts Face degrees of freedom for L2 spaces.
void PermuteAndSetFaceDofsGatherIndices2(const Mesh::FaceInformation &face, const int face_index)
Permute and set the gathering indices of elem2 for the interior face described by the face....
virtual void FillI(SparseMatrix &mat, const bool keep_nbr_block=false) const
Fill the I array of SparseMatrix corresponding to the sparsity pattern given by this L2FaceRestrictio...
Array< int > scatter_indices2
void SingleValuedConformingMult(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 co...
L2FaceRestriction(const FiniteElementSpace &fes, const ElementDofOrdering f_ordering, const FaceType type, const L2FaceValues m, bool build)
Constructs an L2FaceRestriction.
void NormalDerivativeMult(const Vector &x, Vector &y) const override
Scatter the degrees of freedom, i.e. goes from L-Vector to face E-Vector.
void AddMultTranspose(const Vector &x, Vector &y, const real_t a=1.0) const override
Gather the degrees of freedom, i.e. goes from face E-Vector to L-Vector.
void NormalDerivativeAddMultTranspose(const Vector &x, Vector &y) const override
Add the face reference-normal derivative degrees of freedom in x to the element degrees of freedom in...
void Mult(const Vector &x, Vector &y) const override
Scatter the degrees of freedom, i.e. goes from L-Vector to face E-Vector.
void SingleValuedConformingAddMultTranspose(const Vector &x, Vector &y) const
Gather the degrees of freedom, i.e. goes from face E-Vector to L-Vector. Should only be used with con...
std::unique_ptr< L2NormalDerivativeFaceRestriction > normal_deriv_restr
void PermuteAndSetSharedFaceDofsScatterIndices2(const Mesh::FaceInformation &face, const int face_index)
Permute and set the scattering indices of elem2 for the shared face described by the face....
void CheckFESpace()
Verify that L2FaceRestriction is built from an L2 FESpace.
virtual void DoubleValuedConformingMult(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 co...
void PermuteAndSetFaceDofsScatterIndices2(const Mesh::FaceInformation &face, const int face_index)
Permute and set the scattering indices of elem2, and increment the offsets for the face described by ...
Array< int > scatter_indices1
const L2FaceValues m
const FiniteElementSpace & fes
void SetBoundaryDofsScatterIndices2(const Mesh::FaceInformation &face, const int face_index)
Set the scattering indices of elem2 for the boundary face described by the face.
void SetFaceDofsScatterIndices1(const Mesh::FaceInformation &face, const int face_index)
Set the scattering indices of elem1, and increment the offsets for the face described by the face....
void SetFaceDofsGatherIndices1(const Mesh::FaceInformation &face, const int face_index)
Set the gathering indices of elem1 for the interior face described by the face.
const ElementDofOrdering ordering
void DoubleValuedConformingAddMultTranspose(const Vector &x, Vector &y) const
Gather the degrees of freedom, i.e. goes from face E-Vector to L-Vector. Should only be used with con...
virtual void FillJAndData(const Vector &fea_data, SparseMatrix &mat, const bool keep_nbr_block=false) const
Fill the J and Data arrays of the SparseMatrix corresponding to the sparsity pattern given by this L2...
virtual void AddFaceMatricesToElementMatrices(const Vector &fea_data, Vector &ea_data) const
This methods adds the DG face matrices to the element matrices.
Operator that extracts face degrees of freedom for L2 interface spaces.
const int face_dofs
Number of dofs on each face.
const int ndofs
Number of dofs in the space (L-vector size)
const int nfdofs
Total number of dofs on the faces (E-vector size)
const FiniteElementSpace & fes
The finite element space.
L2InterfaceFaceRestriction(const FiniteElementSpace &fes_, const ElementDofOrdering ordering_, const FaceType type_)
Constructs an L2InterfaceFaceRestriction.
Array< int > gather_map
Gather map.
const int vdim
vdim of the space
const int nfaces
Number of faces of the requested type.
void Mult(const Vector &x, Vector &y) const override
Scatter the degrees of freedom, i.e. goes from L-Vector to face E-Vector.
const Array< int > & GatherMap() const override
Low-level access to the underlying gather map.
void AddMultTranspose(const Vector &x, Vector &y, const real_t a=1.0) const override
Gather the degrees of freedom, i.e. goes from face E-Vector to L-Vector.
const ElementDofOrdering ordering
Requested ordering.
const FaceType type
Face type (interior or boundary)
const bool byvdim
DOF ordering (by nodes or by vdim)
Operator that extracts face degrees of freedom for L2 nonconforming spaces.
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 NCL2FaceRestrict...
void AddFaceMatricesToElementMatrices(const Vector &fea_data, Vector &ea_data) const override
This methods adds the DG face matrices to the element matrices.
void FillJAndData(const Vector &fea_data, SparseMatrix &mat, const bool keep_nbr_block=false) const override
Fill the J and Data arrays of the SparseMatrix corresponding to the sparsity pattern given by this NC...
void AddMultTransposeInPlace(Vector &x, Vector &y) const override
Gather the degrees of freedom, i.e. goes from face E-Vector to L-Vector.
void SingleValuedNonconformingTransposeInterpolation(const Vector &x) const
Apply a change of basis from fine element basis to coarse element basis for the coarse face dofs....
void SingleValuedNonconformingTransposeInterpolationInPlace(Vector &x) const
Apply a change of basis from fine element basis to coarse element basis for the coarse face dofs....
InterpolationManager interpolations
virtual void DoubleValuedNonconformingMult(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...
void DoubleValuedNonconformingTransposeInterpolation(const Vector &x) const
Apply a change of basis from fine element basis to coarse element basis for the coarse face dofs....
void DoubleValuedNonconformingInterpolation(Vector &x) const
Apply a change of basis from coarse element basis to fine element basis for the coarse face dofs.
void Mult(const Vector &x, Vector &y) const override
Scatter the degrees of freedom, i.e. goes from L-Vector to face E-Vector.
void AddMultTranspose(const Vector &x, Vector &y, const real_t a=1.0) const override
Gather the degrees of freedom, i.e. goes from face E-Vector to L-Vector.
void DoubleValuedNonconformingTransposeInterpolationInPlace(Vector &x) const
Apply a change of basis from fine element basis to coarse element basis for the coarse face dofs....
NCL2FaceRestriction(const FiniteElementSpace &fes, const ElementDofOrdering f_ordering, const FaceType type, const L2FaceValues m, bool build)
Constructs an NCL2FaceRestriction, this is a specialization of a L2FaceRestriction for nonconforming ...
Abstract operator.
Definition operator.hpp:25
Data type sparse matrix.
Definition sparsemat.hpp:51
Vector data type.
Definition vector.hpp:82
int dim
Definition ex24.cpp:53
int index(int i, int j, int nx, int ny)
Definition life.cpp:236
real_t a
Definition lissajous.cpp:41
Vector GetLVectorFaceNbrData(const FiniteElementSpace &fes, const Vector &x, FaceType ftype)
Return the face-neighbor data given the L-vector x.
int ToLexOrdering(const int dim, const int face_id, const int size1d, const int index)
Convert a dof face index from Native ordering to lexicographic ordering for quads and hexes.
float real_t
Definition config.hpp:43
int PermuteFaceL2(const int dim, const int face_id1, const int face_id2, const int orientation, const int size1d, const int index)
Compute the dof face index of elem2 corresponding to the given dof face index.
ElementDofOrdering
Constants describing the possible orderings of the DOFs in one element.
Definition fespace.hpp:83
FaceType
Definition mesh.hpp:48
InterpConfig & operator=(const InterpConfig &rhs)=default
InterpConfig(int master_side, int nc_index)
InterpConfig(const InterpConfig &)=default
InterpConfig()=default
This structure is used as a human readable output format that deciphers the information contained in ...
Definition mesh.hpp:1980
NCInterpConfig & operator=(const NCInterpConfig &rhs)=default
NCInterpConfig(const NCInterpConfig &)=default
NCInterpConfig(int face_index, InterpConfig &config)
NCInterpConfig()=default
NCInterpConfig(int face_index, int master_side, int nc_index)