Skip to content
Snippets Groups Projects
Commit e37480d5 authored by Jean Fechter's avatar Jean Fechter Committed by Kitware Robot
Browse files

Merge topic 'fixAppendFilterMergeGhost'


5243512b Add test append filter parallel
1ca08680 Fix invalid indices in appendfilter merge ghosts

Acked-by: default avatarKitware Robot <kwrobot@kitware.com>
Acked-by: default avatarbuildbot <buildbot@kitware.com>
Reviewed-by: default avatarCharles Gueunet <charles.gueunet@kitware.com>
Reviewed-by: default avatarLucas Givord <lucas.givord@kitware.com>
Reviewed-by: default avatarMathieu Westphal (Kitware) <mathieu.westphal@kitware.com>
Merge-request: !11696
parents 278da190 5243512b
No related branches found
No related tags found
No related merge requests found
......@@ -109,4 +109,13 @@ set(all_tests
${no_vtkm_tests}
)
if (TARGET VTK::ParallelMPI)
set(vtkFiltersCoreCxxTests-MPI_NUMPROCS 2)
vtk_add_test_mpi(vtkFiltersCoreCxxTests-MPI mpi_test
TestAppendFilterDistributed.cxx,NO_VALID
)
vtk_test_cxx_executable(vtkFiltersCoreCxxTests-MPI mpi_test)
endif()
vtk_test_cxx_executable(vtkFiltersCoreCxxTests all_tests)
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
#include "vtkImageData.h"
#include "vtkMPIController.h"
#include "vtkUnstructuredGrid.h"
#include <vtkAppendFilter.h>
#include <vtkGenerateGlobalIds.h>
#include <vtkGeometryFilter.h>
#include <vtkLogger.h>
#include <vtkRedistributeDataSetFilter.h>
#include <vtkSpatioTemporalHarmonicsSource.h>
int TestAppendFilterDistributed(int argc, char* argv[])
{
// Initialize MPI Controller
vtkNew<vtkMPIController> controller;
controller->Initialize(&argc, &argv);
vtkMultiProcessController::SetGlobalController(controller);
vtkNew<vtkSpatioTemporalHarmonicsSource> source;
source->Update();
vtkNew<vtkGenerateGlobalIds> globalIds;
globalIds->SetInputData(source->GetOutput());
globalIds->SetTolerance(0);
globalIds->Update();
vtkNew<vtkRedistributeDataSetFilter> redistribute;
redistribute->SetInputData(globalIds->GetOutput());
redistribute->Update();
// This filter is only here to test cell's faces and points validity, it will crash if invalid.
vtkNew<vtkGeometryFilter> geometry;
geometry->SetInputData(redistribute->GetOutput());
geometry->Update();
vtkSmartPointer<vtkUnstructuredGrid> grid =
vtkUnstructuredGrid::SafeDownCast(redistribute->GetOutput());
if (grid->GetNumberOfCells() != 8000)
{
std::cerr << "Incorrect number of cells. Expected 8000 got " << grid->GetNumberOfCells()
<< std::endl;
controller->Finalize();
return EXIT_FAILURE;
}
if (grid->GetNumberOfPoints() != 4851)
{
std::cerr << "Incorrect number of points. Expected 4851 got " << grid->GetNumberOfPoints()
<< std::endl;
controller->Finalize();
return EXIT_FAILURE;
}
controller->Finalize();
return EXIT_SUCCESS;
}
......@@ -54,3 +54,5 @@ TEST_DEPENDS
VTK::TestingDataModel
TEST_OPTIONAL_DEPENDS
VTK::AcceleratorsVTKmFilters
VTK::mpi
VTK::ParallelMPI
......@@ -302,34 +302,30 @@ int vtkAppendFilter::RequestData(vtkInformation* vtkNotUsed(request),
{
if (reallyMergePoints)
{
if (!dataSet->HasAnyGhostPoints() ||
dataSet->GetGhostArray(vtkDataObject::POINT)->GetValue(ptId) == 0)
if (dataSetGlobalIdsArray)
{
if (dataSetGlobalIdsArray)
vtkIdType globalId = dataSetGlobalIdsArray->GetValue(ptId);
auto it = addedPointsMap.find(globalId);
if (it == addedPointsMap.end())
{
vtkIdType globalId = dataSetGlobalIdsArray->GetValue(ptId);
auto it = addedPointsMap.find(globalId);
if (it == addedPointsMap.end())
{
globalIndices[ptId + ptOffset] = newPts->GetNumberOfPoints();
dataSet->GetPoint(ptId, p);
vtkIdType newPtId = newPts->InsertNextPoint(p);
addedPointsMap.emplace(globalId, newPtId);
}
else
{
globalIndices[ptId + ptOffset] = it->second;
}
globalIndices[ptId + ptOffset] = newPts->GetNumberOfPoints();
dataSet->GetPoint(ptId, p);
vtkIdType newPtId = newPts->InsertNextPoint(p);
addedPointsMap.emplace(globalId, newPtId);
}
else
{
vtkIdType globalPtId = 0;
dataSet->GetPoint(ptId, p);
ptInserter->InsertUniquePoint(p, globalPtId);
globalIndices[ptId + ptOffset] = globalPtId;
// The point inserter puts the point into newPts, so we don't have to do that here.
globalIndices[ptId + ptOffset] = it->second;
}
}
else
{
vtkIdType globalPtId = 0;
dataSet->GetPoint(ptId, p);
ptInserter->InsertUniquePoint(p, globalPtId);
globalIndices[ptId + ptOffset] = globalPtId;
// The point inserter puts the point into newPts, so we don't have to do that here.
}
}
else
{
......@@ -481,7 +477,8 @@ void vtkAppendFilter::AppendArrays(int attributesType, vtkInformationVector** in
const auto numberOfInputTuples = inputData->GetNumberOfTuples();
for (vtkIdType id = 0; id < numberOfInputTuples; ++id)
{
if (!reallyMergePoints || !dataSet->HasAnyGhostPoints() ||
if (attributesType != vtkDataObject::POINT || !reallyMergePoints ||
!dataSet->HasAnyGhostPoints() ||
dataSet->GetGhostArray(vtkDataObject::POINT)->GetValue(id) == 0)
{
if (globalIds != nullptr)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment