247 std::cout <<
"WARNING: mesh is assumed to be properly numbered" << std::endl;
249 vtkSmartPointer<vtkDataSet> dataSet =
cubature->getDataSet();
250 std::vector<int> arrayIDs =
cubature->getArrayIDs();
251 int numPoints = dataSet->GetNumberOfPoints();
255 vtkQuadratureSchemeDefinition **dict =
cubature->getDict();
256 std::vector<int> numComponents =
cubature->getNumComponents();
258 int totalComponents =
cubature->getTotalComponents();
260 std::vector<vtkSmartPointer<vtkDoubleArray>> newPntData(numComponents.size());
262 std::vector<vtkSmartPointer<vtkDoubleArray>> errorPntData(
263 numComponents.size());
265 vtkSmartPointer<vtkPointData> pd = dataSet->GetPointData();
267 std::vector<std::string> errorNames(numComponents.size());
270 for (
int i = 0; i < numComponents.size(); ++i)
272 std::string name = pd->GetArrayName(arrayIDs[i]);
273 std::string newName = name +
"New";
275 newPntData[i]->SetName(newName.c_str());
276 newPntData[i]->SetNumberOfComponents(numComponents[i]);
277 newPntData[i]->SetNumberOfTuples(numPoints);
279 std::string errName = name +
"Error";
281 errorPntData[i]->SetName(errName.c_str());
282 errorPntData[i]->SetNumberOfComponents(numComponents[i]);
283 errorPntData[i]->SetNumberOfTuples(numPoints);
284 errorNames[i] = errName;
289 nodeSizes->SetName(
"nodeSizes");
290 nodeSizes->SetNumberOfComponents(1);
291 nodeSizes->SetNumberOfTuples(numPoints);
297 for (
int i = 0; i < numPoints; ++i)
300 dataSet->GetPointCells(i, patchCellIDs);
303 int numPatchPoints = 0;
306 for (
int k = 0; k < patchCellIDs->GetNumberOfIds(); ++k)
309 dataSet->GetCell(patchCellIDs->GetId(k), genCell);
311 patchCellIDs->GetId(k))->GetCellType();
312 numPatchPoints += dict[
cellType]->GetNumberOfQuadraturePoints();
315 nodeSize += std::sqrt(genCell->GetLength2());
318 nodeSize /= patchCellIDs->GetNumberOfIds();
319 nodeSizes->InsertTuple(i, &nodeSize);
321 std::vector<std::vector<double>> coords(numPatchPoints);
323 std::vector<VectorXd>
data(totalComponents);
324 for (
int k = 0; k < totalComponents; ++k)
326 data[k].resize(numPatchPoints);
330 for (
int j = 0; j < patchCellIDs->GetNumberOfIds(); ++j)
333 patchCellIDs->GetId(j));
338 std::vector<double> genNodeCoord(3);
339 dataSet->GetPoint(i, genNodeCoord.data());
343 std::unique_ptr<polyApprox> patchPolyApprox
347 for (
int k = 0; k < numComponents.size(); ++k)
349 auto *comps =
new double[numComponents[k]];
350 auto *refComps =
new double[numComponents[k]];
351 auto *errorComps =
new double[numComponents[k]];
352 pd->GetArray(arrayIDs[k])->GetTuple(i, refComps);
353 for (
int l = 0; l < numComponents[k]; ++l)
356 comps[l] = patchPolyApprox->
eval(genNodeCoord);
357 errorComps[l] = std::pow(comps[l] - refComps[l], 2);
361 newPntData[k]->InsertTuple(i, comps);
362 errorPntData[k]->InsertTuple(i, errorComps);
368 for (
int k = 0; k < numComponents.size(); ++k)
371 pd->AddArray(errorPntData[k]);
374 pd->AddArray(nodeSizes);
375 return cubature->integrateOverAllCells(errorNames,
true);
static std::unique_ptr< polyApprox > CreateUnique(int order, const std::vector< std::vector< double >> &coords)
data_type data
Edge/face with sorted point ids (a, b, c, ...) is located at some index i in data[b], with data[b][i].first == [a, c] (for edges, third point id treated as -1).
double eval(const std::vector< double > &coord) const
void computeCoeff(const Eigen::VectorXd &data)
geoMeshBase * New(MeshType meshType)
Create a new mesh object.
std::vector< pntDataPair > pntDataPairVec
void regularizeCoords(std::vector< std::vector< double >> &coords, std::vector< double > &genNodeCoord) const
void extractAxesAndData(const pntDataPairVec &pntsAndData, std::vector< std::vector< double >> &coords, std::vector< Eigen::VectorXd > &data, const std::vector< int > &numComponents, int &pntNum) const
std::unique_ptr< GaussCubature > cubature