32 #include <vtkCellData.h> 33 #include <vtkCellIterator.h> 34 #include <vtkDoubleArray.h> 35 #include <vtkGenericCell.h> 36 #include <vtkIdList.h> 46 :
SizeFieldBase(_ds, arrayID, _dev_mult, _maxIsmin,
"GradientSF") {
47 std::cout <<
"GradSizeField constructed" << std::endl;
54 vtkIdList *point_ids = cell->GetPointIds();
55 vtkIdType numPointsInCell = point_ids->GetNumberOfIds();
56 int dim = da->GetNumberOfComponents();
59 std::vector<double> values(dim * numPointsInCell);
60 for (vtkIdType i = 0; i < numPointsInCell; ++i) {
61 std::vector<double> comps(dim);
62 da->GetTuple(point_ids->GetId(i), comps.data());
63 for (
int j = 0; j < dim; ++j) values[i * dim + j] = comps[j];
66 std::vector<double> gradient(dim * 3);
67 std::vector<double> tmp(3, 0.0);
69 cell->Derivatives(0, tmp.data(), values.data(), dim, gradient.data());
82 std::vector<double> result;
83 result.reserve(ds->GetNumberOfCells());
85 vtkCellIterator *it = ds->NewCellIterator();
87 for (it->InitTraversal(); !it->IsDoneWithTraversal(); it->GoToNextCell()) {
101 if (values.empty()) {
102 std::cerr <<
"size array hasn't been populated!" << std::endl;
109 da2->SetName(
sfname.c_str());
110 da2->SetNumberOfComponents(1);
111 for (vtkIdType i = 0; i <
ds->GetNumberOfCells(); ++i)
112 da2->InsertNextTypedTuple(&values[i]);
113 ds->GetCellData()->AddArray(da2);
vtkSmartPointer< vtkDataSet > ds
geoMeshBase * New(MeshType meshType)
Create a new mesh object.
vtkSmartPointer< vtkDataArray > da
static std::vector< double > computeL2GradAtAllCells(vtkDataSet *ds, vtkDataArray *da)
void mutateValues(std::vector< double > &values) const
GradSizeField(vtkDataSet *_ds, int arrayID, double _dev_mult, bool _maxIsmin)
static std::vector< double > computeGradAtCell(vtkCell *cell, vtkDataArray *da)
T l2_Norm(const std::vector< T > &x)
void computeSizeField(vtkDataArray *da) override