VTK  9.7.20261003
vtkDGOperatorEntry.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
3#ifndef vtkDGOperatorEntry_h
4#define vtkDGOperatorEntry_h
5
6#include "vtkFiltersCellGridModule.h" // For export macro.
7#include "vtkStringToken.h" // For ivar.
8
9#include <array>
10#include <functional>
11#include <vector>
12
13VTK_ABI_NAMESPACE_BEGIN
14
55class VTKFILTERSCELLGRID_EXPORT vtkDGOperatorEntry
56{
57public:
66 using OperatorFunction = std::function<void(
67 const std::array<double, 3>&, std::vector<double>&, const std::vector<int>&)>;
68
71 using FunctionCounter = std::function<int(const std::vector<int>&)>;
72
73 vtkDGOperatorEntry() = default;
76
78 vtkDGOperatorEntry(int numFunc, int opSize, OperatorFunction op, const std::string& shader)
79 : NumberOfFunctions(numFunc)
80 , OperatorSize(opSize)
81 , Op(op)
82 , ShaderOp(shader)
83 {
84 }
85
90 FunctionCounter counter, int opSize, OperatorFunction op, const std::string& shader)
91 : OperatorSize(opSize)
92 , Op(op)
93 , ShaderOp(shader)
94 , FunctionCount(counter)
95 {
96 }
97
103 operator bool() const { return !!this->Op && this->NumberOfFunctions > 0; }
104
106 bool IsOrderDependent() const { return !!this->FunctionCount; }
107
115 bool SetOrder(const std::vector<int>& order);
116
122 void Evaluate(const std::array<double, 3>& rst, std::vector<double>& values) const
123 {
124 this->Op(rst, values, this->Order);
125 }
126
133
136 static int TensorProductFunctionCount(const std::vector<int>& order);
137
140 static int SimplexFunctionCount(const std::vector<int>& order);
141
144 static int WedgeFunctionCount(const std::vector<int>& order);
146
148 std::string GetShaderString(
149 const std::string& functionName, const std::string& parameterName, int order) const;
150
158
163 int OperatorSize{ 1 };
164
169
171 std::string ShaderOp;
172
177 std::vector<int> Order;
178
183};
184
185VTK_ABI_NAMESPACE_END
186#endif // vtkDGOperatorEntry_h
RealT rst
Definition TetF2Basis.h:17
std::function< int(const std::vector< int > &)> FunctionCounter
The signature of functions reporting how many basis functions an arbitrary-order operator provides at...
int OperatorSize
The number of coordinates each operator-function evaluates to.
OperatorFunction Op
A function you may call to evaluate the operator.
std::string ShaderOp
A string holding the source code to evaluate all the basis functions.
bool IsOrderDependent() const
Return whether this operator implements an arbitrary polynomial order.
static int WedgeFunctionCount(const std::vector< int > &order)
A wedge: a triangle (the r- and s-axes) crossed with an edge (the t-axis), so the two counts multiply...
int NumberOfFunctions
The number of functions in the basis.
static int TensorProductFunctionCount(const std::vector< int > &order)
A tensor product with an independent order along each parametric axis: (n0 + 1)(n1 + 1)… functions,...
vtkDGOperatorEntry & operator=(const vtkDGOperatorEntry &)=default
std::vector< int > Order
The polynomial order along each parametric axis of the cell.
bool SetOrder(const std::vector< int > &order)
Bind an order-dependent operator to a concrete polynomial order.
void Evaluate(const std::array< double, 3 > &rst, std::vector< double > &values) const
Evaluate this operator at the parametric coordinates rst.
vtkDGOperatorEntry(FunctionCounter counter, int opSize, OperatorFunction op, const std::string &shader)
Construct an entry for an operator implementing an arbitrary polynomial order.
vtkDGOperatorEntry()=default
FunctionCounter FunctionCount
For order-dependent operators, computes NumberOfFunctions from an Order.
std::string GetShaderString(const std::string &functionName, const std::string &parameterName, int order) const
Return a glsl string that defines this operator.
vtkDGOperatorEntry(const vtkDGOperatorEntry &)=default
std::function< void( const std::array< double, 3 > &, std::vector< double > &, const std::vector< int > &)> OperatorFunction
The signature of the functions that evaluate an operator.
static int SimplexFunctionCount(const std::vector< int > &order)
A simplex, whose axes share a single total degree: (n+1)(n+2)…(n+d)/d!
vtkDGOperatorEntry(int numFunc, int opSize, OperatorFunction op, const std::string &shader)
Construct an entry for an operator implementing a single polynomial order.