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

Add a test of the halo finder's halo center finding

One mode of it and the code that involkes it anyway.

Change-Id: I4754b2d3be4d59666640a9af21da26b6cdc8efb5
parent 3e66df0b
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,8 @@ genericio/m000.499.allparticles
paraview_add_test_cxx(${vtk-module}CxxTests tests
NO_OUTPUT
TestHaloFinder.cxx
TestHaloFinder.cxx # test of particles output
TestHaloFinderSummaryInfo.cxx # test of summary information output
)
vtk_test_mpi_executable(${vtk-module}CxxTests tests
......
......@@ -51,7 +51,7 @@ struct HaloFinderTestVTKObjects {
vtkSmartPointer< vtkCompositePolyDataMapper2 > mapper;
};
std::set< std::string > getFirstOutputArrays()
inline std::set< std::string > getFirstOutputArrays()
{
std::set< std::string > arrayNames;
arrayNames.insert("vx");
......@@ -62,7 +62,7 @@ std::set< std::string > getFirstOutputArrays()
return arrayNames;
}
std::set< std::string > getHaloSummaryArrays()
inline std::set< std::string > getHaloSummaryArrays()
{
std::set< std::string > arrayNames;
arrayNames.insert("fof_halo_tag");
......@@ -74,14 +74,14 @@ std::set< std::string > getHaloSummaryArrays()
return arrayNames;
}
std::set< std::string > getHaloSummaryWithCenterInfoArrays()
inline std::set< std::string > getHaloSummaryWithCenterInfoArrays()
{
std::set< std::string > arrayNames = getHaloSummaryArrays();
arrayNames.insert("fof_halo_center");
arrayNames.insert("fof_center");
return arrayNames;
}
bool pointDataHasTheseArrays(vtkPointData* pd, const std::set< std::string >& arrays)
inline bool pointDataHasTheseArrays(vtkPointData* pd, const std::set< std::string >& arrays)
{
if (pd->GetNumberOfArrays() != arrays.size())
{
......@@ -99,7 +99,8 @@ bool pointDataHasTheseArrays(vtkPointData* pd, const std::set< std::string >& ar
return true;
}
HaloFinderTestVTKObjects SetupHaloFinderTest(int argc, char* argv[])
inline HaloFinderTestVTKObjects SetupHaloFinderTest(
int argc, char* argv[], vtkPANLHaloFinder::CenterFindingType centerFinding = vtkPANLHaloFinder::NONE)
{
HaloFinderTestVTKObjects testObjects;
char* fname =
......@@ -122,6 +123,10 @@ HaloFinderTestVTKObjects SetupHaloFinderTest(int argc, char* argv[])
testObjects.haloFinder->SetRL(128);
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);
testObjects.haloFinder->Update();
testObjects.onlyPointsInHalos->SetInputConnection(
......
......@@ -31,14 +31,14 @@ int runHaloFinderTest1(int argc, char*argv[])
HaloFinderTestHelpers::getFirstOutputArrays()))
{
std::cerr << "Error at line: " << __LINE__ << std::endl;
return 1;
return 0;
}
vtkUnstructuredGrid* haloSummaries = to.haloFinder->GetOutput(1);
if (!HaloFinderTestHelpers::pointDataHasTheseArrays(haloSummaries->GetPointData(),
HaloFinderTestHelpers::getHaloSummaryArrays()))
{
std::cerr << "Error at line: " << __LINE__ << std::endl;
return 1;
return 0;
}
......@@ -48,16 +48,7 @@ int runHaloFinderTest1(int argc, char*argv[])
to.iren->Start();
}
// maskPoints->SetInputConnection(haloFinder->GetOutputPort(1));
// maskPoints->Update();
// int retVal2 = vtkRegressionTestImage(renWin.GetPointer());
// if (retVal2 = vtkRegressionTester::DO_INTERACTOR)
// {
// iRen->Start();
// }
return retVal; // && retVal2;
return retVal;
}
}
......
/*=========================================================================
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 "vtkArrayCalculator.h"
#include "vtkColorTransferFunction.h"
#include "vtkMPIController.h"
#include "vtkRegressionTestImage.h"
namespace {
int runHaloFinderTest(int argc, char*argv[])
{
HaloFinderTestHelpers::HaloFinderTestVTKObjects to =
HaloFinderTestHelpers::SetupHaloFinderTest(
argc, argv, vtkPANLHaloFinder::MOST_BOUND_PARTICLE);
vtkUnstructuredGrid* allParticles = to.haloFinder->GetOutput(0);
if (!HaloFinderTestHelpers::pointDataHasTheseArrays(allParticles->GetPointData(),
HaloFinderTestHelpers::getFirstOutputArrays()))
{
std::cerr << "Error at line: " << __LINE__ << std::endl;
return 0;
}
vtkUnstructuredGrid* haloSummaries = to.haloFinder->GetOutput(1);
if (!HaloFinderTestHelpers::pointDataHasTheseArrays(haloSummaries->GetPointData(),
HaloFinderTestHelpers::getHaloSummaryWithCenterInfoArrays()))
{
std::cerr << "Error at line: " << __LINE__ << std::endl;
return 0;
}
vtkNew< vtkArrayCalculator > calc;
calc->SetInputConnection(to.haloFinder->GetOutputPort(1));
calc->SetResultArrayName("Result");
calc->AddCoordinateVectorVariable("coords");
calc->AddVectorArrayName("fof_center");
calc->SetFunction("mag(fof_center - coords)");
calc->Update();
double range[2];
calc->GetOutput()->GetPointData()->GetArray("Result")->GetRange(range);
to.maskPoints->SetInputConnection(calc->GetOutputPort());
to.maskPoints->Update();
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();
lut->SetVectorModeToMagnitude();
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();
int retVal = vtkRegressionTestImage(to.renWin.GetPointer());
if ( retVal == vtkRegressionTester::DO_INTERACTOR)
{
to.iren->Start();
}
return retVal;
}
}
int TestHaloFinderSummaryInfo(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;
}
222274cc0c3690557f66bdf9df43d651
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