31 #include <vtkCellData.h> 32 #include <vtkCellIterator.h> 40 :
SizeFieldBase(_ds, arrayID, 0.0, false,
"Z2ErrorSF"), order(_order) {
41 std::cout <<
"Z2ErrorSizeField constructed" << std::endl;
45 std::vector<int> arrayIDs(1);
46 arrayIDs[0] = arrayID;
47 std::unique_ptr<PatchRecovery> recoverObj =
54 ds->GetPointData()->GetArray(da->GetName(), arrayID);
57 std::string errorName = da->GetName();
58 errorName +=
"ErrorIntegral";
60 vtkSmartPointer<vtkDataArray> errorIntegrals =
61 ds->GetCellData()->GetArray(errorName.c_str());
62 vtkSmartPointer<vtkDataArray> nodeSizes =
63 ds->GetPointData()->GetArray(
"nodeSizes");
65 std::vector<double> sizeField;
66 sizeField.reserve(
ds->GetNumberOfCells());
68 vtkCellIterator *it =
ds->NewCellIterator();
70 for (it->InitTraversal(); !it->IsDoneWithTraversal(); it->GoToNextCell()) {
71 double interpSize = 0.0;
75 auto *weights =
new double[cell->GetNumberOfPoints()];
78 cell->GetParametricCenter(center);
79 cell->EvaluateLocation(subId, center, x, weights);
81 for (
int j = 0; j < cell->GetNumberOfPoints(); ++j) {
82 int pntID = cell->GetPointId(j);
84 nodeSizes->GetTuple(pntID, size);
85 interpSize += size[0] * weights[j];
90 errorIntegrals->GetTuple(it->GetCellId(), error);
91 sizeField.emplace_back(
92 interpSize / (std::pow(error[0] / aveError, 1.0 /
order)) *
sizeFactor);
97 da2->SetName(
sfname.c_str());
98 da2->SetNumberOfComponents(1);
99 for (vtkIdType i = 0; i <
ds->GetNumberOfCells(); ++i)
100 da2->InsertNextTypedTuple(&sizeField[i]);
101 ds->GetCellData()->AddArray(da2);
std::vector< std::vector< double > > computeNodalError()
vtkSmartPointer< vtkDataSet > ds
geoMeshBase * New(MeshType meshType)
Create a new mesh object.
double computeNodalError(int arrayID) const
vtkSmartPointer< vtkDataArray > da
Z2ErrorSizeField(vtkDataSet *_ds, int arrayID, int _order)
void computeSizeField(vtkDataArray *da) override