Commit 26594e1a authored by Mathieu Westphal's avatar Mathieu Westphal Committed by Kitware Robot
Browse files

Merge topic '10637-EnsightTensorCoordSwitchFix'

338b3136 Adding test for ensight tensor inversion
749c3a22

 Switchin tensor coordinates XZ and YZ with ensight tensor
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !722
parents 117e54c5 338b3136
......@@ -22,5 +22,7 @@ vtk_add_test_python(
EnSightRectGridASCII.py
EnSightRectGridBin.py
EnSightSelectArrays.py
EnSightTensorsInversion.py
EnSightTensorsInversionBin.py
nacaBinary.py
)
#!/usr/bin/env python
import vtk
from vtk.test import Testing
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
# create a rendering window and renderer
ren1 = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren1)
renWin.StereoCapableWindowOn()
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
reader = vtk.vtkGenericEnSightReader()
# Make sure all algorithms use the composite data pipeline
cdp = vtk.vtkCompositeDataPipeline()
reader.SetDefaultExecutivePrototype(cdp)
del cdp
reader.SetCaseFileName("" + str(VTK_DATA_ROOT) + "/Data/EnSight/elements6.case")
geom = vtk.vtkGeometryFilter()
geom.SetInputConnection(reader.GetOutputPort())
calc = vtk.vtkArrayCalculator()
calc.SetInputConnection(geom.GetOutputPort())
calc.SetAttributeModeToUsePointData()
calc.SetFunction("pointTensors_XZ - pointTensors_YZ")
calc.AddScalarVariable("pointTensors_XZ","pointTensors", 5)
calc.AddScalarVariable("pointTensors_YZ","pointTensors", 4)
calc.SetResultArrayName("test")
mapper = vtk.vtkHierarchicalPolyDataMapper()
mapper.SetInputConnection(calc.GetOutputPort())
mapper.SetColorModeToMapScalars()
mapper.SetScalarModeToUsePointFieldData()
mapper.ColorByArrayComponent("test",0)
mapper.SetScalarRange(-0.1,0.1)
actor = vtk.vtkActor()
actor.SetMapper(mapper)
# assign our actor to the renderer
ren1.AddActor(actor)
# enable user interface interactor
iren.Initialize()
renWin.Render()
# prevent the tk window from showing up then start the event loop
reader.SetDefaultExecutivePrototype(None)
# --- end of script --
#!/usr/bin/env python
import vtk
from vtk.test import Testing
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
# create a rendering window and renderer
ren1 = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren1)
renWin.StereoCapableWindowOn()
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
reader = vtk.vtkGenericEnSightReader()
reader.SetCaseFileName("" + str(VTK_DATA_ROOT) + "/Data/EnSight/elements6-bin.case")
reader.UpdateInformation()
reader.GetOutputInformation(0).Set(vtk.vtkStreamingDemandDrivenPipeline.UPDATE_TIME_STEP(), 0.1)
geom = vtk.vtkGeometryFilter()
geom.SetInputConnection(reader.GetOutputPort())
calc = vtk.vtkArrayCalculator()
calc.SetInputConnection(geom.GetOutputPort())
calc.SetAttributeModeToUsePointData()
calc.SetFunction("pointTensors_XZ - pointTensors_YZ")
calc.AddScalarVariable("pointTensors_XZ","pointTensors", 5)
calc.AddScalarVariable("pointTensors_YZ","pointTensors", 4)
calc.SetResultArrayName("test")
mapper = vtk.vtkHierarchicalPolyDataMapper()
mapper.SetInputConnection(calc.GetOutputPort())
mapper.SetColorModeToMapScalars()
mapper.SetScalarModeToUsePointFieldData()
mapper.ColorByArrayComponent("test",0)
mapper.SetScalarRange(-0.1,0.1)
actor = vtk.vtkActor()
actor.SetMapper(mapper)
# assign our actor to the renderer
ren1.AddActor(actor)
# enable user interface interactor
iren.Initialize()
renWin.Render()
# prevent the tk window from showing up then start the event loop
reader.SetDefaultExecutivePrototype(None)
# --- end of script --
......@@ -1457,8 +1457,8 @@ int vtkEnSight6BinaryReader::ReadTensorsPerNode(
tensor[1] = tensorsRead[6*i+1];
tensor[2] = tensorsRead[6*i+2];
tensor[3] = tensorsRead[6*i+3];
tensor[4] = tensorsRead[6*i+4];
tensor[5] = tensorsRead[6*i+5];
tensor[4] = tensorsRead[6*i+5];
tensor[5] = tensorsRead[6*i+4];
tensors->InsertTuple(i, tensor);
}
......@@ -1495,8 +1495,8 @@ int vtkEnSight6BinaryReader::ReadTensorsPerNode(
tensor[1] = tensorsRead[6*i+1];
tensor[2] = tensorsRead[6*i+2];
tensor[3] = tensorsRead[6*i+3];
tensor[4] = tensorsRead[6*i+4];
tensor[5] = tensorsRead[6*i+5];
tensor[4] = tensorsRead[6*i+5];
tensor[5] = tensorsRead[6*i+4];
tensors->InsertTuple(i, tensor);
}
......@@ -2057,8 +2057,8 @@ int vtkEnSight6BinaryReader::ReadTensorsPerElement(
tensor[1] = tensorsRead[6*i+1];
tensor[2] = tensorsRead[6*i+2];
tensor[3] = tensorsRead[6*i+3];
tensor[4] = tensorsRead[6*i+4];
tensor[5] = tensorsRead[6*i+5];
tensor[4] = tensorsRead[6*i+5];
tensor[5] = tensorsRead[6*i+4];
tensors->InsertTuple(this->GetCellIds(idx, elementType)->GetId(i),
tensor);
......@@ -2078,8 +2078,8 @@ int vtkEnSight6BinaryReader::ReadTensorsPerElement(
tensor[1] = tensorsRead[6*i+1];
tensor[2] = tensorsRead[6*i+2];
tensor[3] = tensorsRead[6*i+3];
tensor[4] = tensorsRead[6*i+4];
tensor[5] = tensorsRead[6*i+5];
tensor[4] = tensorsRead[6*i+5];
tensor[5] = tensorsRead[6*i+4];
tensors->InsertTuple(i, tensor);
}
delete [] tensorsRead;
......
......@@ -993,7 +993,7 @@ int vtkEnSight6Reader::ReadTensorsPerNode(
{
vtkEnSight6ReaderRead3(line, " %12e %12e %12e %12e %12e %12e",
&tensor[0], &tensor[1],
&tensor[2], &tensor[3], &tensor[4], &tensor[5]);
&tensor[2], &tensor[3], &tensor[5], &tensor[4]);
tensors->InsertTuple(i, tensor);
lineRead = this->ReadNextDataLine(line);
}
......@@ -1032,7 +1032,7 @@ int vtkEnSight6Reader::ReadTensorsPerNode(
this->ReadNextDataLine(line);
vtkEnSight6ReaderRead3(line, " %12e %12e %12e %12e %12e %12e",
&values[0], &values[1],
&values[2], &values[3], &values[4], &values[5]);
&values[2], &values[3], &values[5], &values[4]);
for (j = 0; j < 6; j++)
{
tensors->InsertComponent(i*6 + j, k, values[j]);
......@@ -1506,7 +1506,7 @@ int vtkEnSight6Reader::ReadTensorsPerElement(
this->ReadNextDataLine(line);
vtkEnSight6ReaderRead3(line, " %12e %12e %12e %12e %12e %12e",
&values[0], &values[1], &values[2],
&values[3], &values[4], &values[5]);
&values[3], &values[5], &values[4]);
for (j = 0; j < 6; j++)
{
tensors->InsertComponent(i*6 + j, k, values[j]);
......@@ -1546,7 +1546,7 @@ int vtkEnSight6Reader::ReadTensorsPerElement(
this->ReadNextDataLine(line);
vtkEnSight6ReaderRead3(line, " %12e %12e %12e %12e %12e %12e",
&tensor[0], &tensor[1], &tensor[2],
&tensor[3], &tensor[4], &tensor[5]);
&tensor[3], &tensor[5], &tensor[4]);
tensors->InsertTuple(this->GetCellIds(idx, elementType)->GetId(i),
tensor);
}
......
......@@ -1798,8 +1798,8 @@ int vtkEnSightGoldBinaryReader::ReadTensorsPerNode(
this->ReadFloatArray(comp2, numPts);
this->ReadFloatArray(comp3, numPts);
this->ReadFloatArray(comp4, numPts);
this->ReadFloatArray(comp5, numPts);
this->ReadFloatArray(comp6, numPts);
this->ReadFloatArray(comp5, numPts);
for (i = 0; i < numPts; i++)
{
tuple[0] = comp1[i];
......@@ -2475,8 +2475,8 @@ int vtkEnSightGoldBinaryReader::ReadTensorsPerElement(
this->ReadFloatArray(comp2, numCells);
this->ReadFloatArray(comp3, numCells);
this->ReadFloatArray(comp4, numCells);
this->ReadFloatArray(comp5, numCells);
this->ReadFloatArray(comp6, numCells);
this->ReadFloatArray(comp5, numCells);
for (i = 0; i < numCells; i++)
{
tuple[0] = comp1[i];
......@@ -2530,8 +2530,8 @@ int vtkEnSightGoldBinaryReader::ReadTensorsPerElement(
this->ReadFloatArray(comp2, numCellsPerElement);
this->ReadFloatArray(comp3, numCellsPerElement);
this->ReadFloatArray(comp4, numCellsPerElement);
this->ReadFloatArray(comp5, numCellsPerElement);
this->ReadFloatArray(comp6, numCellsPerElement);
this->ReadFloatArray(comp5, numCellsPerElement);
for (i = 0; i < numCellsPerElement; i++)
{
tuple[0] = comp1[i];
......
......@@ -815,6 +815,7 @@ int vtkEnSightGoldReader::ReadTensorsPerNode(const char* fileName, const char* d
int timeStep, vtkMultiBlockDataSet *compositeOutput)
{
char line[256];
int symmTensorOrder[6] = {0, 1, 2, 3, 5, 4};
int partId, realId, numPts, i, j;
vtkFloatArray *tensors;
vtkDataSet *output;
......@@ -913,7 +914,7 @@ int vtkEnSightGoldReader::ReadTensorsPerNode(const char* fileName, const char* d
for (j = 0; j < numPts; j++)
{
this->ReadNextDataLine(line);
tensors->InsertComponent(j, i, atof(line));
tensors->InsertComponent(j, symmTensorOrder[i], atof(line));
}
}
tensors->SetName(description);
......@@ -1307,6 +1308,7 @@ int vtkEnSightGoldReader::ReadTensorsPerElement(const char* fileName,
vtkMultiBlockDataSet *compositeOutput)
{
char line[256];
int symmTensorOrder[6] = {0, 1, 2, 3, 5, 4};
int partId, realId, numCells, numCellsPerElement, i, j, idx;
vtkFloatArray *tensors;
int lineRead, elementType;
......@@ -1413,7 +1415,7 @@ int vtkEnSightGoldReader::ReadTensorsPerElement(const char* fileName,
{
this->ReadNextDataLine(line);
value = atof(line);
tensors->InsertComponent(j, i, value);
tensors->InsertComponent(j, symmTensorOrder[i], value);
}
}
lineRead = this->ReadNextDataLine(line);
......@@ -1442,7 +1444,7 @@ int vtkEnSightGoldReader::ReadTensorsPerElement(const char* fileName,
this->ReadNextDataLine(line);
value = atof(line);
tensors->InsertComponent(this->GetCellIds(idx, elementType)->GetId(j),
i, value);
symmTensorOrder[i], value);
}
}
lineRead = this->ReadNextDataLine(line);
......
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