3#ifndef vtkDGOperationEvaluator_h
4#define vtkDGOperationEvaluator_h
54template <
typename InputIterator,
typename OutputIterator,
vtkDGSharingType DOFSharing,
71 op, connectivity, values, sideConn, offset, shapeGradient, shapeConnectivity, shapeValues)
75 throw std::logic_error(
"Must have non-null operator.");
77 if (Modifier !=
None && !shapeGradient)
79 throw std::logic_error(
"Must have non-null shape gradient operator.");
90 throw std::logic_error(
"DOF sharing requires a cell-connectivity array.");
92 int nvc = this->
CellValues->GetNumberOfComponents();
106 if (Modifier !=
None)
109 this->
ShapeBasisTuple.resize(shapeGradient.NumberOfFunctions * shapeGradient.OperatorSize);
118 throw std::logic_error(
"Shape DOF-sharing requires a shape-connectivity array.");
120 int nvs = this->
ShapeValues->GetNumberOfComponents();
136 if (
auto* typedEntry =
151 auto xx(outIter[tt]);
152 int nc =
static_cast<int>(xx.size());
154 for (
int ii = 0; ii < nc; ++ii)
161 for (
int jj = 0; jj < this->
OpEntry.OperatorSize; ++jj)
163 for (
int kk = 0; kk < this->
OpEntry.NumberOfFunctions; ++kk)
165 xx[ii * this->
OpEntry.OperatorSize + jj] +=
167 this->
ValueTuple[kk * this->NumberOfValuesPerFunction + ii];
177 constexpr int nc = 9;
178 assert(nc == this->
ShapeGradientEntry.OperatorSize * this->NumberOfShapeValuesPerFunction);
180 for (
int ii = 0; ii < nc; ++ii)
190 this->
Jacobian[jj + this->NumberOfShapeValuesPerFunction * ii] +=
207 int nv = this->
ShapeValues->GetNumberOfComponents();
208 for (std::size_t jj = 0; jj < nc; ++jj)
226 throw std::logic_error(
"Invalid shape DOF-sharing enumerant.");
239 std::array<double, 9> inverseJacobian;
244 auto rr(outIter[ii]);
245 const int nc =
static_cast<int>(rr.size());
248 throw std::logic_error(
"Jacobian must apply to vector or matrix values.");
250 for (
int vv = 0; vv < nc / 3; ++vv)
252 vtkTypeUInt64 mm = 3 * vv;
253 double* vec = rr.data() + mm;
267 std::array<double, 3> vec;
268 auto rr(outIter[ii]);
269 const int nc =
static_cast<int>(rr.size());
272 throw std::logic_error(
"Jacobian must apply to vector or matrix values.");
274 for (
int vv = 0; vv < nc / 3; ++vv)
276 vtkTypeUInt64 mm = 3 * vv;
277 vec = { { rr[mm], rr[mm + 1], rr[mm + 2] } };
288 InputIterator& inIter, OutputIterator& outIter, vtkTypeUInt64 begin, vtkTypeUInt64 end)
const
290 vtkTypeUInt64 currId;
293 for (vtkTypeUInt64 ii = begin; ii != end; ++ii)
295 currId = inIter.GetCellId(ii);
302 int nv = this->
CellValues->GetNumberOfComponents();
303 for (std::size_t jj = 0; jj < nc; ++jj)
309 auto param = inIter.GetParameter(ii);
310 for (
int jj = 0; jj < 3; ++jj)
312 this->
RST[jj] = param[jj];
328 for (vtkTypeUInt64 ii = begin; ii != end; ++ii)
330 currId = inIter.GetCellId(ii);
337 int nv = this->
CellValues->GetNumberOfComponents();
338 for (std::size_t jj = 0; jj < nc; ++jj)
344 auto param = inIter.GetParameter(ii);
345 for (
int jj = 0; jj < 3; ++jj)
347 this->
RST[jj] = param[jj];
363 for (vtkTypeUInt64 ii = begin; ii != end; ++ii)
365 currId = inIter.GetCellId(ii);
373 auto param = inIter.GetParameter(ii);
374 for (
int jj = 0; jj < 3; ++jj)
376 this->
RST[jj] = param[jj];
392 for (vtkTypeUInt64 ii = begin; ii != end; ++ii)
394 currId = inIter.GetCellId(ii);
402 auto param = inIter.GetParameter(ii);
403 for (
int jj = 0; jj < 3; ++jj)
405 this->
RST[jj] = param[jj];
433 OutputIterator, DOFSharing, SourceType, Modifier, ShapeSharing>(
434 op, conn, values, sides, offset, shapeGradient, shapeConnectivity, shapeValues));
435 entry.
Function = [&entry](InputIterator& inIter, OutputIterator& outIter, vtkTypeUInt64 begin,
439 DOFSharing, SourceType, Modifier, ShapeSharing
>*>(entry.
State.get());
440 return (*eval)(inIter, outIter, begin, end);
static void prepEntry(vtkDGOperationStateEntry< InputIterator, OutputIterator > &entry, vtkDGOperatorEntry op, vtkDataArray *conn, vtkDataArray *values, vtkDataArray *sides, vtkTypeUInt64 offset, vtkDGOperatorEntry shapeGradient=vtkDGOperatorEntry(), vtkDataArray *shapeConnectivity=nullptr, vtkDataArray *shapeValues=nullptr)
Prepare an entry for evaluating op with the given data arrays and class template parameters.
void ApplyScaledJacobian(vtkTypeUInt64 ii, OutputIterator &outIter) const
InputIterator InputIteratorType
vtkDGOperationEvaluator(vtkDGOperatorEntry &op, vtkDataArray *connectivity, vtkDataArray *values, vtkDataArray *sideConn, vtkTypeUInt64 offset, vtkDGOperatorEntry shapeGradient=vtkDGOperatorEntry(), vtkDataArray *shapeConnectivity=nullptr, vtkDataArray *shapeValues=nullptr)
OutputIterator OutputIteratorType
void CloneInto(vtkDGOperationStateEntryBase &entry) const override
void InnerProduct(vtkTypeUInt64 tt, OutputIterator &outIter) const
Compute the inner product of this->BasisTuple and this->ValueTuple, storing the result in the tt-th t...
void operator()(InputIterator &inIter, OutputIterator &outIter, vtkTypeUInt64 begin, vtkTypeUInt64 end) const
void ComputeJacobian() const
Compute the shape-attribute Jacobian matrix, storing it in this->Jacobian.
void ShapeInnerProduct() const
Compute the inner product of this->ShapeBasisTuple and this->ShapeValueTuple, storing the result in t...
void ApplyInverseJacobian(vtkTypeUInt64 ii, OutputIterator &outIter) const
This is a base class that exists so that vtkDGOperationState can provide a virtual CloneInto method t...
Encapsulate the state required to evaluate DG cell-attributes.
std::unique_ptr< vtkDGOperationState > State
vtkDGCellRangeEvaluator< InputIterator, OutputIterator > Function
std::vector< double > ShapeBasisTuple
std::vector< double > ShapeValueTuple
vtkDGOperatorEntry ShapeGradientEntry
vtkDataArray * ShapeValues
std::vector< vtkTypeUInt64 > ShapeConnTuple
vtkDGOperatorEntry OpEntry
std::vector< double > ValueTuple
std::vector< double > Jacobian
vtkDataArray * SideConnectivity
std::vector< double > BasisTuple
std::array< vtkTypeUInt64, 2 > SideTuple
int NumberOfShapeValuesPerFunction
int NumberOfValuesPerFunction
vtkDataArray * CellValues
vtkDGOperationState(vtkDGOperatorEntry &op, vtkDataArray *connectivity, vtkDataArray *values, vtkDataArray *sideConn, vtkTypeUInt64 offset, vtkDGOperatorEntry shapeGradient=vtkDGOperatorEntry(), vtkDataArray *shapeConnectivity=nullptr, vtkDataArray *shapeValues=nullptr)
vtkTypeUInt64 LastShapeCellId
std::vector< vtkTypeUInt64 > ConnTuple
vtkDataArray * CellConnectivity
std::array< double, 3 > RST
vtkDataArray * ShapeConnectivity
A record for a basis in a function space that is specific to one cell shape.
int OperatorSize
The number of coordinates each operator-function evaluates to.
int NumberOfFunctions
The number of functions in the basis.
double Determinant()
Compute the determinant of the matrix and return it.
void MultiplyPoint(const float in[3], float out[3])
Multiply a homogeneous coordinate by this matrix, i.e.
#define VTK_ALWAYS_EXPORT
vtkDGShapeModifier
Which type of shape-function post-processing is required.
@ ScaledJacobian
!< For HGRAD
vtkDGSharingType
Whether degrees of freedom (DOF) are shared between cells.
@ Discontinuous
Degrees of freedom are not shared.
@ SharedDOF
Degrees of freedom (DOF) are shared.
vtkDGSideType
Whether cells are stand-alone or sides of other cells.
@ Cells
A cell specified by degrees of freedom held in arrays.
@ Sides
A side specified by a cell ID and an integer index into sides.