MFEM v4.9.0
Finite element discretization library
Loading...
Searching...
No Matches
fieldoperator.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#pragma once
12
13#include <type_traits>
14
15namespace mfem::future
16{
17
18/// @brief Base class for FieldOperators.
19///
20/// This class serves as a base for different FieldOperator types which can be
21/// applied to fields that are used with inputs to a quadrature point function.
22/// See DifferentialOperator.
23template <int FIELD_ID = -1>
25{
26public:
27 /// @brief Constructor for the FieldOperator.
28 ///
29 /// This constructor initializes the FieldOperator with it's size on
30 /// quadrature points. The size on quadrature points has to be determined by
31 /// the FieldOperator type, the dimension and the vector dimension (number
32 /// of components). See the following examples
33 ///
34 /// Scalar FiniteElementSpace with Value FieldOperator:
35 /// size = vdim x dim x 1 = 1 x dim x 1 = dim
36 ///
37 /// Vector FiniteElementSpace with Gradient FieldOperator:
38 /// size = vdim x dim x dim = vdim x dim x dim = vdim * dim^2
39 ///
40 /// ParameterSpace with Identity FieldOperator:
41 /// size = vdim = vdim
42 constexpr FieldOperator(int size_on_qp = 0) :
44
45 /// @brief Get the field id this FieldOperator is attached to.
46 static constexpr int GetFieldId() { return FIELD_ID; }
47
48 /// @brief Get the size on quadrature point for this FieldOperator.
49 int size_on_qp = -1;
50
51 /// @brief Get the dimension of the FieldOperator.
52 int dim = -1;
53
54 /// @brief Get the vector dimension (number of components)
55 /// of the FieldOperator.
56 int vdim = -1;
57};
58
59/// @brief Identity FieldOperator.
60///
61/// This FieldOperator does nothing to the field. The field (usually a
62/// ParametricFunction) transfers the values to the quadrature point data and
63/// Identity can be viewed as an identity operation.
64template <int FIELD_ID = -1>
65class Identity : public FieldOperator<FIELD_ID>
66{
67public:
68 constexpr Identity() : FieldOperator<FIELD_ID>() {}
69};
70
71template< typename T >
72struct is_identity_fop : std::false_type {};
73
74template <int FIELD_ID>
75struct is_identity_fop<Identity<FIELD_ID>> : std::true_type {};
76
77/// @brief Weight FieldOperator.
78///
79/// This FieldOperator is used to signal that this field contains the quadrature
80/// point weights.
81class Weight : public FieldOperator<-1>
82{
83public:
84 constexpr Weight() : FieldOperator<-1>() {};
85};
86
87template< typename T >
88struct is_weight_fop : std::false_type {};
89
90template <>
91struct is_weight_fop<Weight> : std::true_type {};
92
93/// @brief Value FieldOperator.
94///
95/// This FieldOperator is used to signal that the field contains the
96/// interpolated values of the degrees of freedom at the quadrature points.
97template <int FIELD_ID = -1>
98class Value : public FieldOperator<FIELD_ID>
99{
100public:
101 constexpr Value() : FieldOperator<FIELD_ID>() {};
102};
103
104template< typename T >
105struct is_value_fop : std::false_type {};
106
107template <int FIELD_ID>
108struct is_value_fop<Value<FIELD_ID>> : std::true_type {};
109
110/// @brief Gradient FieldOperator.
111///
112/// This FieldOperator is used to signal that the field contains the
113/// interpolated gradients of the degrees of freedom at the quadrature points.
114template <int FIELD_ID = -1>
115class Gradient : public FieldOperator<FIELD_ID>
116{
117public:
118 constexpr Gradient() : FieldOperator<FIELD_ID>() {};
119};
120
121template< typename T >
122struct is_gradient_fop : std::false_type {};
123
124template <int FIELD_ID>
125struct is_gradient_fop<Gradient<FIELD_ID>> : std::true_type {};
126
127/// @brief Sum FieldOperator.
128///
129/// This FieldOperator is commonly used to signal that an output of a quadrature
130/// function should be summed.
131template <int FIELD_ID = -1>
132class Sum : public FieldOperator<FIELD_ID>
133{
134public:
135 constexpr Sum() : FieldOperator<FIELD_ID>() {};
136};
137
138template< typename T >
139struct is_sum_fop : std::false_type {};
140
141template <int FIELD_ID>
142struct is_sum_fop<Sum<FIELD_ID>> : std::true_type {};
143
144} // namespace mfem::future
Base class for FieldOperators.
int vdim
Get the vector dimension (number of components) of the FieldOperator.
int size_on_qp
Get the size on quadrature point for this FieldOperator.
constexpr FieldOperator(int size_on_qp=0)
Constructor for the FieldOperator.
int dim
Get the dimension of the FieldOperator.
static constexpr int GetFieldId()
Get the field id this FieldOperator is attached to.
Gradient FieldOperator.
Identity FieldOperator.
Sum FieldOperator.
Value FieldOperator.
Weight FieldOperator.