Hi,

I just came across Dave DeMarle's ParaView course slides presented
at the 6th OpenFOAM Workshop.
http://www.openfoamworkshop.org/6th_OpenFOAM_Workshop_2011/Program/Training/deMarle_slides.pdf

In the 11th slide (Temporal Processing) I see that the "Interpolation
between time steps" is grayed out, which I suspect was done so because
the temporal interpolator did not interpolate the OpenFOAM dataset
(which made path lines unpractical as well).  This is a known
problem that has fixes involving both the OpenFOAM reader and the
temporal interpolator. The fix to the former (which I backported from
my own development version) is attached in this mail and the latter
has already been filed as a bug with a patch:
http://vtk.org/Bug/view.php?id=12151

Thanks,
Takuya

Takuya OSHIMA, Ph.D.
Faculty of Engineering, Niigata University
8050 Ikarashi-Ninocho, Nishi-ku, Niigata, 950-2181, JAPAN
diff --git a/IO/vtkOpenFOAMReader.cxx b/IO/vtkOpenFOAMReader.cxx
index 7445c6f..423124f 100644
--- a/IO/vtkOpenFOAMReader.cxx
+++ b/IO/vtkOpenFOAMReader.cxx
@@ -337,6 +337,8 @@ private:
       vtkPoints *);
   bool GetCellZoneMesh(vtkMultiBlockDataSet *, const vtkFoamIntVectorVector *,
       const vtkFoamIntVectorVector *, vtkPoints *);
+  void SetShallowCopies(vtkMultiBlockDataSet *, vtkMultiBlockDataSet *,
+      const char *);
 };
 
 vtkStandardNewMacro(vtkOpenFOAMReaderPrivate);
@@ -7682,6 +7684,30 @@ void vtkOpenFOAMReaderPrivate::AddArrayToFieldData(
 }
 
 //-----------------------------------------------------------------------------
+// Set shallow copies of the input datasets to output
+void vtkOpenFOAMReaderPrivate::SetShallowCopies(vtkMultiBlockDataSet *output,
+    vtkMultiBlockDataSet *input, const char *blockName)
+{
+  // Set shallow copies of the member datasets as the final output so
+  // as not to get overridden in the input temporal dataset during the
+  // execution of temporal pipeline executive.
+  vtkMultiBlockDataSet *mbds = vtkMultiBlockDataSet::New();
+  for (unsigned int blockI = 0; blockI < input->GetNumberOfBlocks(); blockI++)
+    {
+    vtkDataObject *ds = input->GetBlock(blockI)->NewInstance();
+    ds->ShallowCopy(input->GetBlock(blockI));
+    mbds->SetBlock(blockI, ds);
+    ds->FastDelete();
+    mbds->GetMetaData(blockI)->CopyEntry(input->GetMetaData(blockI),
+        vtkCompositeDataSet::NAME());
+    }
+  const unsigned int groupTypeI = output->GetNumberOfBlocks();
+  output->SetBlock(groupTypeI, mbds);
+  mbds->FastDelete();
+  this->SetBlockName(output, groupTypeI, blockName);
+}
+
+//-----------------------------------------------------------------------------
 // return 0 if there's any error, 1 if success
 int vtkOpenFOAMReaderPrivate::RequestData(vtkMultiBlockDataSet *output,
     bool recreateInternalMesh, bool recreateBoundaryMesh, bool updateVariables)
@@ -8004,16 +8030,21 @@ int vtkOpenFOAMReaderPrivate::RequestData(vtkMultiBlockDataSet *output,
   // Add Internal Mesh to final output only if selected for display
   if (this->InternalMesh != NULL)
     {
-    output->SetBlock(0, this->InternalMesh);
+    // Set shallow copy of the unstructured grid as the final output
+    // so as not to get overridden when it is used as the input of
+    // temporal filters during the execution of the temporal pipeline
+    // executive.
+    vtkUnstructuredGrid *ug = vtkUnstructuredGrid::New();
+    ug->ShallowCopy(this->InternalMesh);
+    output->SetBlock(0, ug);
+    ug->FastDelete();
     this->SetBlockName(output, 0, "internalMesh");
     }
 
   // set boundary meshes/data as output
   if (this->BoundaryMesh != NULL && this->BoundaryMesh->GetNumberOfBlocks() > 0)
     {
-    const unsigned int groupTypeI = output->GetNumberOfBlocks();
-    output->SetBlock(groupTypeI, this->BoundaryMesh);
-    this->SetBlockName(output, groupTypeI, "Patches");
+    this->SetShallowCopies(output, this->BoundaryMesh, "Patches");
     }
 
   // set lagrangian mesh as output
@@ -8021,50 +8052,37 @@ int vtkOpenFOAMReaderPrivate::RequestData(vtkMultiBlockDataSet *output,
     {
     if (lagrangianMesh->GetNumberOfBlocks() > 0)
       {
-      const unsigned int groupTypeI = output->GetNumberOfBlocks();
-      output->SetBlock(groupTypeI, lagrangianMesh);
-      this->SetBlockName(output, groupTypeI, "Lagrangian Particles");
+      this->SetShallowCopies(output, lagrangianMesh, "Lagrangian Particles");
       }
     lagrangianMesh->Delete();
     }
 
   if (this->Parent->GetReadZones())
     {
-    vtkMultiBlockDataSet *zones = NULL;
+    vtkMultiBlockDataSet *zones
+        = (this->PointZoneMesh || this->FaceZoneMesh || this->CellZoneMesh
+        ? vtkMultiBlockDataSet::New() : 0);
+
     // set Zone Meshes as output
     if (this->PointZoneMesh != NULL)
       {
-      zones = vtkMultiBlockDataSet::New();
-      const unsigned int zoneTypeI = zones->GetNumberOfBlocks();
-      zones->SetBlock(zoneTypeI, this->PointZoneMesh);
-      this->SetBlockName(zones, zoneTypeI, "pointZones");
+      this->SetShallowCopies(zones, this->PointZoneMesh, "pointZones");
       }
 
     if (this->FaceZoneMesh != NULL)
       {
-      if (zones == NULL)
-        {
-        zones = vtkMultiBlockDataSet::New();
-        }
-      const unsigned int zoneTypeI = zones->GetNumberOfBlocks();
-      zones->SetBlock(zoneTypeI, this->FaceZoneMesh);
-      this->SetBlockName(zones, zoneTypeI, "faceZones");
+      this->SetShallowCopies(zones, this->FaceZoneMesh, "faceZones");
       }
 
     if (this->CellZoneMesh != NULL)
       {
-      if (zones == NULL)
-        {
-        zones = vtkMultiBlockDataSet::New();
-        }
-      const unsigned int zoneTypeI = zones->GetNumberOfBlocks();
-      zones->SetBlock(zoneTypeI, this->CellZoneMesh);
-      this->SetBlockName(zones, zoneTypeI, "cellZones");
+      this->SetShallowCopies(zones, this->CellZoneMesh, "cellZones");
       }
     if (zones != NULL)
       {
       const unsigned int groupTypeI = output->GetNumberOfBlocks();
       output->SetBlock(groupTypeI, zones);
+      zones->FastDelete();
       this->SetBlockName(output, groupTypeI, "Zones");
       }
     }
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Follow this link to subscribe/unsubscribe:
http://www.paraview.org/mailman/listinfo/paraview

Reply via email to