[Paraview] CoProcessing with Fortran and ParaView 3.98

Vanmoer, Mark W mvanmoer at illinois.edu
Tue Mar 19 19:05:25 EDT 2013


> Message: 5
> Date: Tue, 19 Mar 2013 18:31:28 +0000
> From: "Pettey . Lucas" <LPettey at drc.com>
> Subject: [Paraview] CoProcessing with Fortran and ParaView 3.98
> To: paraview ?[paraview at paraview.org]? 	<paraview at paraview.org>
> Message-ID:
> <C7ACF6F2C9304A4C81EAC2E2C96B5E165F1E0373 at EXMB01.drc.com>
> Content-Type: text/plain; charset="windows-1256"
> 
> Hello everyone,
> 
> I am trying to run a simple Fortran coprocessing example with a complex data
> type. I am following the example here:
> 
> http://en.wikibooks.org/wiki/Parallel_Spectral_Numerical_Methods/Visualiz
> ation_with_ParaView_CoProcessing#ParaView_CoProcessing_Resources
> 
> I have written a basic Fortran code that outputs the data in binary, opened
> that in ParaView, output the coprocessing script and then written the
> adaptor following the example in the above link. My adaptor looks like:
> 
> extern "C" void createcpimagedata_(int* nx, int* ny, int* nz) {
>   if (!ParaViewCoProcessing::GetCoProcessorData()) {
>     vtkGenericWarningMacro("Unable to access CoProcessorData.");
>     return;
>   }
> 
>   // The simulation grid is a 2-dimensional topologically and geometrically
>   // regular grid. In VTK/ParaView, this is considered an image data set.
>   vtkImageData* Grid = vtkImageData::New();
> 
>   // assuming dimZ == 1 for now
>   Grid->SetDimensions(*nx, *ny, *nz);
>   Grid->SetNumberOfScalarComponents(2);
> 
>   // Setting the Origin and Spacing are also options.
> 
>   // Name should be consistent between here, Fortran and Python client
> script.
>   ParaViewCoProcessing::GetCoProcessorData()-
> >GetInputDescriptionByName("input")->SetGrid(Grid);
> }
> 
> // Add field(s) to the data container.
> // Separate from above because this will be dynamic, grid is static.
> // Might be an issue, VTK probably assumes row major, but // omeg probably
> passed column major...
> // by hand name mangling for fortran
> extern "C" void addfield_(double* scalars, char* name) {
>   vtkCPInputDataDescription *idd =
> ParaViewCoProcessing::GetCoProcessorData()-
> >GetInputDescriptionByName("input");
> 
>   vtkImageData* Image = vtkImageData::SafeDownCast(idd->GetGrid());
> 
>   if (!Image) {
>     vtkGenericWarningMacro("No adaptor grid to attach field data to.");
>     return;
>   }
> 
> 
>   // field name must match that in the fortran code.
>   if (idd->IsFieldNeeded(name)) {
>     vtkSmartPointer<vtkDoubleArray> field =
> vtkSmartPointer<vtkDoubleArray>::New();
>     field->SetNumberOfComponents(2);
>     field->SetName(name);
>     field->SetArray(scalars, 2* Image->GetNumberOfPoints(), 1);
>     Image->GetPointData()->AddArray(field);
> 
>   }
> }
> 
> I am getting some errors from the Makefile generated by Cmake:
> 
> /Users/lucaspettey/codes/BEC/coprocVTK.cxx:40:38: error: too few
> arguments to function call, expected 2, have 1
>   Grid->SetNumberOfScalarComponents(2);
>   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ^
> /Users/lucaspettey/ParaView-
> git/ParaView/VTK/Common/DataModel/vtkImageData.h:298:3: note:
> 'SetNumberOfScalarComponents' declared here
>   static void SetNumberOfScalarComponents( int n, vtkInformation*
> meta_data);
>   ^
> /Users/lucaspettey/codes/BEC/coprocVTK.cxx:67:5: error: unknown type
> name 'vtkSmartPointer'; did you mean 'vtkSmartPointerBase'?
>     vtkSmartPointer<vtkDoubleArray> field =
> vtkSmartPointer<vtkDoubleArray>::New();
>     ^~~~~~~~~~~~~~~
>     vtkSmartPointerBase
> /Users/lucaspettey/ParaView-
> git/ParaView/VTK/Common/Core/vtkOStreamWrapper.h:36:7: note:
> 'vtkSmartPointerBase' declared here class vtkSmartPointerBase;
>       ^
> /Users/lucaspettey/codes/BEC/coprocVTK.cxx:67:20: error: expected
> unqualified-id
>     vtkSmartPointer<vtkDoubleArray> field =
> vtkSmartPointer<vtkDoubleArray>::New();
>                    ^
> /Users/lucaspettey/codes/BEC/coprocVTK.cxx:68:5: error: use of undeclared
> identifier 'field'
>     field->SetNumberOfComponents(2);
>     ^
> /Users/lucaspettey/codes/BEC/coprocVTK.cxx:69:5: error: use of undeclared
> identifier 'field'
>     field->SetName(name);
>     ^
> /Users/lucaspettey/codes/BEC/coprocVTK.cxx:70:5: error: use of undeclared
> identifier 'field'
>     field->SetArray(scalars, 2* Image->GetNumberOfPoints(), 1);
>     ^
> /Users/lucaspettey/codes/BEC/coprocVTK.cxx:71:37: error: use of
> undeclared identifier 'field'
>     Image->GetPointData()->AddArray(field);
>                                     ^
> 
> Any help is appreciated.
> 
> Thanks,
> Lucas
> 
Hello Lucas, 

I helped write those notes for a project through XSEDE last year. They were based on Nautilus down at NICS. The ParaView on Nautilus used VTK 5.x, it looks like the API has changed for VTK 6, so some of those calls will have to be changed. For example, the SetNumberOfScalarComponents method is now handled completely differently. 

I haven't studied VTK 6 yet, hopefully someone with VTK 6 knowledge can add more.


Mark


More information about the ParaView mailing list