Commit a4bc54ee authored by David E. DeMarle's avatar David E. DeMarle

use a better and smaller data file fix bugs this exposed

parent 7fc4b92b
......@@ -6,5 +6,4 @@ vtk_add_test_cxx(${vtk-module}CxxTests tests
TestTRUCHASReader.cxx,NO_VALID
)
vtk_test_cxx_executable(${vtk-module}CxxTests tests
RENDERING_FACTORY
)
)
......@@ -18,6 +18,7 @@
#include "vtkDoubleArray.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkNew.h"
#include "vtkPointData.h"
#include "vtkTesting.h"
#include "vtkTestUtilities.h"
#include "vtkTRUCHASReader.h"
......@@ -44,22 +45,45 @@ int TestTRUCHASReader(int argc, char *argv[])
testing->AddArguments(argc, argv);
char *fileName =
vtkTestUtilities::ExpandDataFileName(argc,argv,
"Data/TRUCHAS/moving_rod.h5");
"Data/TRUCHAS/viscoplastic-ring.h5");
vtkNew<vtkTRUCHASReader> reader;
reader->SetFileName(fileName);
reader->UpdateInformation();
reader->SetCellArrayStatus("dTdt", 0);
int nb = reader->GetNumberOfBlockArrays();
cerr << nb << " BLOCKS" << endl;
for (int b = 0; b < nb; b++)
{
cerr << "BLOCK ID " << b
<< " named " << reader->GetBlockArrayName(b) << endl;
}
reader->SetBlockArrayStatus("2", 0); //block nums start at 1
reader->SetBlockArrayStatus("1", 0); //block nums start at 1
reader->SetBlockArrayStatus("2", 1); //block nums start at 1
reader->SetBlockArrayStatus("3", 0); //block nums start at 1
int nca = reader->GetNumberOfCellArrays();
cerr << nca << " CELL ARRAYS" << endl;
for (int a = 0; a < nca; a++)
{
cerr << "ARRAY " << a
<< " named " << reader->GetCellArrayName(a) << endl;
}
cerr << "IGNORE VOF" << endl;
reader->SetCellArrayStatus("VOF", 0);
int npa = reader->GetNumberOfPointArrays();
cerr << npa << " POINT ARRAYS" << endl;
for (int a = 0; a < npa; a++)
{
cerr << "ARRAY " << a
<< " named " << reader->GetPointArrayName(a) << endl;
}
cerr << "IGNORE Displacement" << endl;
reader->SetPointArrayStatus("Displacement", 0);
reader->Update();
vtkUnstructuredGrid *grid = vtkUnstructuredGrid::SafeDownCast
(reader->GetOutput()->GetBlock(0));
(reader->GetOutput()->GetBlock(1));
if (!grid)
{
cerr << "Could not open first block of known good file" << endl;
......@@ -74,27 +98,53 @@ int TestTRUCHASReader(int argc, char *argv[])
}
}
if ( (rnb != 1) ||
(reader->GetOutput()->GetNumberOfBlocks() != 2) )
(reader->GetOutput()->GetNumberOfBlocks() != 3) )
{
cerr << "Got unexpected number of blocks, found "
<< rnb << "/" << reader->GetOutput()->GetNumberOfBlocks()
<< " instead of "
<< 1 << "/" << 2
<< 1 << "/" << 3
<< endl;
}
const int expectedNumArrays = 6;
if (grid->GetCellData()->GetNumberOfArrays() != 6)
cerr << "---- CELL ARRAYS ----" << endl;
const int expectedNumCArrays = nca-1;
if (nca > 0 &&
grid->GetCellData()->GetNumberOfArrays() != expectedNumCArrays)
{
cerr << "Got unexpected number of arrays, found "
cerr << "Got unexpected number of cell arrays, found "
<< grid->GetCellData()->GetNumberOfArrays()
<< " instead of "
<< expectedNumArrays
<< expectedNumCArrays
<< endl;
return EXIT_FAILURE;
}
for (int a = 0; a < grid->GetCellData()->GetNumberOfArrays(); a++)
{
vtkDataArray *da = grid->GetCellData()->GetArray(a);
cerr << da->GetName() << endl;
}
cerr << "---- POINT ARRAYS ----" << endl;
const int expectedNumPArrays = npa-1;
if (npa > 0 &&
grid->GetPointData()->GetNumberOfArrays() != expectedNumPArrays)
{
cerr << "Got unexpected number of point arrays, found "
<< grid->GetPointData()->GetNumberOfArrays()
<< " instead of "
<< expectedNumPArrays
<< endl;
return EXIT_FAILURE;
}
for (int a = 0; a < grid->GetPointData()->GetNumberOfArrays(); a++)
{
vtkDataArray *da = grid->GetPointData()->GetArray(a);
cerr << da->GetName() << endl;
}
const int expectedNumPoints = 2872;
const int expectedNumPoints = 496;
if (grid->GetNumberOfPoints()!=expectedNumPoints)
{
cerr << "Got unexpected number of points from file "
......@@ -104,7 +154,7 @@ int TestTRUCHASReader(int argc, char *argv[])
<< endl;
return EXIT_FAILURE;
}
const int expectedNumCells = 1716;
const int expectedNumCells = 180;
if (grid->GetNumberOfCells()!=expectedNumCells)
{
cerr << "Got unexpected number of cells from file "
......@@ -114,59 +164,75 @@ int TestTRUCHASReader(int argc, char *argv[])
<< endl;
return EXIT_FAILURE;
}
vtkDoubleArray *da = vtkDoubleArray::SafeDownCast(grid->GetCellData()->GetArray("Grad_T"));
vtkDoubleArray *da = vtkDoubleArray::SafeDownCast
(grid->GetCellData()->GetArray("Grad_T"));
if (!da)
{
cerr << "Couldn't get " << "Grad_T" << " array" << endl;
return EXIT_FAILURE;
}
double *ptr = da->GetTuple(42);
if (!AE(*ptr,-135.675) || !AE(*(ptr+1),-62.7603) || !AE(*(ptr+2),2.01974))
const double eVals[3] = {
-10.4436, -4.32586, -10.4913
};
if (!AE(*ptr,eVals[0]) || !AE(*(ptr+1),eVals[1]) || !AE(*(ptr+2),eVals[2]))
{
cerr << "Got unexpected values from Grad_T array for cell 42 "
<< *ptr << "," << *(ptr+1) << "," << *(ptr+2)
<< " instead of "
<< -135.675 << "," << -62.7603 << "," << *(ptr+2)
<< eVals[0] << "," << eVals[1] << "," << eVals[2]
<< endl;
return EXIT_FAILURE;
}
reader->SetCellArrayStatus("dTdt", 1);
reader->SetCellArrayStatus("VOF", 1);
reader->Update();
if (grid->GetCellData()->GetNumberOfArrays() != expectedNumArrays+1)
if (grid->GetCellData()->GetNumberOfArrays() != expectedNumCArrays+1)
{
cerr << "Got unexpected number of arrays, found "
cerr << "Got unexpected number of cell arrays, found "
<< grid->GetCellData()->GetNumberOfArrays()
<< " instead of "
<< expectedNumArrays+1
<< expectedNumCArrays+1
<< endl;
return EXIT_FAILURE;
}
vtkInformation *inf = reader->GetExecutive()->GetOutputInformation(0);
int numTimes = inf->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
cerr << "FOUND " << numTimes << " timesteps " << endl;
double tAlpha = inf->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS(), 0);
double tOmega = inf->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS(), numTimes-1);
if (numTimes != 61 || !AE(tAlpha, 0.0) || !AE(tOmega, 301.932))
const int expectedNumTimes = 2;
const double expectedMinT = 0.0;
const double expectedMaxT = 0.5;
if (numTimes != 2 || !AE(tAlpha, expectedMinT) || !AE(tOmega, expectedMaxT))
{
cerr << "Got unexpected times." << endl;
cerr << numTimes << " not " << 61 << " times ";
cerr << tAlpha << " not " << 0.0 << " first time";
cerr << tOmega << " not " << 301.932 << " last time";
cerr << numTimes << " not " << expectedNumTimes << " times ";
cerr << tAlpha << " not " << expectedMinT << " first time";
cerr << tOmega << " not " << expectedMaxT << " last time";
return EXIT_FAILURE;
}
const double expectedRanges[5][2] =
const int divs = 3;
const double expectedRanges[divs][2] =
{
{0,0},
{-0.0360963,0.123483},
{-0.0231966,0.108961},
{-0.0222647,0.111447},
{-0.0204965,0.111295},
{0,0}, //before
{0,0}, //after first
{-1.99025,-0.85729}, //after second
};
for (int i = 0; i < 5; i++)
for (int i = 0; i < divs; i++)
{
double tNext = tAlpha + i*(tOmega-tAlpha)/5;
double tNext = tAlpha-0.1 + i*(tOmega-tAlpha)*2.5/divs;
reader->UpdateTimeStep(tNext);
grid = vtkUnstructuredGrid::SafeDownCast
(reader->GetOutput()->GetBlock(0));
(reader->GetOutput()->GetBlock(1));
da = vtkDoubleArray::SafeDownCast(grid->GetCellData()->GetArray("dTdt"));
double *mM = da->GetRange();
cerr << "ts " << i << ":" << tNext
<< " got " << mM[0] << "," << mM[1] << endl;
if (!AE(mM[0], expectedRanges[i][0]) ||
!AE(mM[1], expectedRanges[i][1]))
{
......
......@@ -760,26 +760,18 @@ int vtkTRUCHASReader::RequestData(
(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP());
reqTime = reqTS;
}
std::map<double, std::string>::iterator tit;
std::map<double, std::string>::iterator tit2;
bool done = false;
for (tit = this->Internals->tmap.begin();
tit != this->Internals->tmap.end() && !done;
)
std::map<double, std::string>::iterator tit
= this->Internals->tmap.begin();
for (std::map<double, std::string>::iterator ttit =
this->Internals->tmap.begin();
ttit != this->Internals->tmap.end();)
{
if (tit->first < reqTime)
{
tit2=tit;
tit2++;
if (tit2 != this->Internals->tmap.end())
{
tit++;
}
}
else
if (ttit->first < reqTime)
{
done = true;
tit = ttit;
}
ttit++;
}
//open the corresponding section in the hdf5 file to get arrays from
std::string time_group_name ="/Simulations/MAIN/Series Data/" + tit->second;
......
bc90eca1e8e2e48ec3501a1b8d868b51
14a7f5379eaca1199f377cd769c538ca
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment