Skip to content
Snippets Groups Projects
Commit f6744bb9 authored by Shawn Waldon's avatar Shawn Waldon
Browse files

Added a test of the halo finder's subhalo finding option

Change-Id: I2cf25fe9cfa85015196608d2e4f14152a58b4915
parent 02ad656f
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ paraview_add_test_cxx(${vtk-module}CxxTests tests
NO_OUTPUT
TestHaloFinder.cxx # test of particles output
TestHaloFinderSummaryInfo.cxx # test of summary information output
TestHaloFinderSubhaloFinding.cxx # test of subhalo finding option
)
vtk_test_mpi_executable(${vtk-module}CxxTests tests
......
......@@ -85,6 +85,8 @@ inline bool pointDataHasTheseArrays(vtkPointData* pd, const std::set< std::strin
{
if (pd->GetNumberOfArrays() != arrays.size())
{
std::cerr << "Wrong number of arrays. There should be " << arrays.size()
<< " and there are " << pd->GetNumberOfArrays() << std::endl;
return false;
}
for (std::set< std::string >::iterator itr = arrays.begin();
......@@ -100,7 +102,9 @@ inline bool pointDataHasTheseArrays(vtkPointData* pd, const std::set< std::strin
}
inline HaloFinderTestVTKObjects SetupHaloFinderTest(
int argc, char* argv[], vtkPANLHaloFinder::CenterFindingType centerFinding = vtkPANLHaloFinder::NONE)
int argc, char* argv[],
vtkPANLHaloFinder::CenterFindingType centerFinding = vtkPANLHaloFinder::NONE,
bool findSubhalos = false)
{
HaloFinderTestVTKObjects testObjects;
char* fname =
......@@ -121,12 +125,22 @@ inline HaloFinderTestVTKObjects SetupHaloFinderTest(
testObjects.haloFinder->SetInputConnection(testObjects.reader->GetOutputPort());
testObjects.haloFinder->SetRL(128);
testObjects.haloFinder->SetParticleMass(13070871810);
testObjects.haloFinder->SetNP(128);
testObjects.haloFinder->SetPMin(100);
testObjects.haloFinder->SetCenterFindingMode(centerFinding);
testObjects.haloFinder->SetOmegaDM(0.2068);
testObjects.haloFinder->SetDeut(0.0224);
testObjects.haloFinder->SetHubble(0.72);
if (findSubhalos)
{
testObjects.haloFinder->SetRunSubHaloFinder(1);
testObjects.haloFinder->SetMinFOFSubhaloSize(7000);
testObjects.haloFinder->SetMinCandidateSize(20);
// Expand the linking length a bit for the subhalo finding test, we need big
// halos to have interesting subhalos
testObjects.haloFinder->SetBB(0.2);
}
testObjects.haloFinder->Update();
testObjects.onlyPointsInHalos->SetInputConnection(
......
/*=========================================================================
Program: Visualization Toolkit
Module: TestHaloFinder.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include <mpi.h>
#include "HaloFinderTestHelpers.h"
#include "vtkCamera.h"
#include "vtkColorTransferFunction.h"
#include "vtkMPIController.h"
#include "vtkRegressionTestImage.h"
#include "vtkRendererCollection.h"
namespace {
std::set< std::string > getSubhaloSummaryArrays()
{
std::set< std::string > result;
result.insert("fof_halo_count");
result.insert("fof_halo_tag");
result.insert("subhalo_com");
result.insert("subhalo_count");
result.insert("subhalo_mass");
result.insert("subhalo_mean_velocity");
result.insert("subhalo_tag");
result.insert("subhalo_velocity_dispersion");
return result;
}
int runHaloFinderTest(int argc, char*argv[])
{
HaloFinderTestHelpers::HaloFinderTestVTKObjects to =
HaloFinderTestHelpers::SetupHaloFinderTest(
argc, argv, vtkPANLHaloFinder::NONE, true);
vtkUnstructuredGrid* allParticles = to.haloFinder->GetOutput(0);
std::set< std::string > firstOutputArrays = HaloFinderTestHelpers::getFirstOutputArrays();
firstOutputArrays.insert("subhalo_tag");
if (!HaloFinderTestHelpers::pointDataHasTheseArrays(allParticles->GetPointData(),
firstOutputArrays))
{
std::cerr << "Error at line: " << __LINE__ << std::endl;
return 0;
}
vtkUnstructuredGrid* haloSummaries = to.haloFinder->GetOutput(1);
if (!HaloFinderTestHelpers::pointDataHasTheseArrays(haloSummaries->GetPointData(),
HaloFinderTestHelpers::getHaloSummaryArrays()))
{
std::cerr << "Error at line: " << __LINE__ << std::endl;
return 0;
}
vtkUnstructuredGrid* subhaloSummaries = to.haloFinder->GetOutput(2);
if (!HaloFinderTestHelpers::pointDataHasTheseArrays(subhaloSummaries->GetPointData(),
getSubhaloSummaryArrays()))
{
std::cerr << "Error at line: " << __LINE__ << std::endl;
return 0;
}
to.onlyPointsInHalos->SetInputArrayToProcess(
0,0,0,vtkDataObject::FIELD_ASSOCIATION_POINTS, "subhalo_tag");
to.onlyPointsInHalos->ThresholdByUpper(0.0);
to.onlyPointsInHalos->Update();
double range[2];
to.onlyPointsInHalos->GetOutput()->GetPointData()->GetArray("subhalo_tag")->GetRange(range);
to.onlyPointsInHalos->GetOutput()->GetPointData()->SetActiveScalars("subhalo_tag");
vtkNew< vtkColorTransferFunction > lut;
lut->AddRGBPoint(range[0], 59/255.0, 76/255.0, 192/255.0);
lut->AddRGBPoint(range[1], 180/255.0, 4/255.0, 38/255.0);
lut->SetColorSpaceToDiverging();
to.mapper->SetLookupTable(lut.GetPointer());
to.mapper->ScalarVisibilityOn();
to.mapper->SetInputArrayToProcess(0,0,0,vtkDataObject::FIELD_ASSOCIATION_POINTS,"subhalo_tag");
to.mapper->SelectColorArray("subhalo_tag");
to.mapper->InterpolateScalarsBeforeMappingOn();
vtkRenderer* ren = to.renWin->GetRenderers()->GetFirstRenderer();
vtkCamera* cam = ren->GetActiveCamera();
cam->SetPosition(39.8465, 33.3915, 99.8347);
cam->SetFocalPoint(25.1646, 47.1462, 107.878);
cam->SetViewUp(-0.526454, -0.77122, 0.357864);
ren->ResetCamera();
int retVal = vtkRegressionTestImage(to.renWin.GetPointer());
if ( retVal == vtkRegressionTester::DO_INTERACTOR)
{
to.iren->Start();
}
return retVal;
}
}
int TestHaloFinderSubhaloFinding(int argc, char* argv[])
{
MPI_Init(&argc,&argv);
vtkNew< vtkMPIController > controller;
controller->Initialize();
vtkMultiProcessController::SetGlobalController(controller.GetPointer());
int retVal = runHaloFinderTest(argc,argv);
controller->Finalize();
return !retVal;
}
......@@ -66,7 +66,6 @@ int runHaloFinderTest(int argc, char*argv[])
to.mapper->SetLookupTable(lut.GetPointer());
to.mapper->ScalarVisibilityOn();
// to.mapper->SelectColorArray("Result");
to.mapper->SetInputArrayToProcess(0,0,0,vtkDataObject::FIELD_ASSOCIATION_POINTS,"Result");
to.mapper->InterpolateScalarsBeforeMappingOn();
......
70c6788a75e98085b4463ef6697f9eb3
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