[Paraview-developers] SOADataArray Templates and Catalyst fail to work

David Lonie david.lonie at kitware.com
Wed Sep 7 09:38:14 EDT 2016


Hi Max,

I'm having some trouble following your example code:

On Wed, Sep 7, 2016 at 4:13 AM, Staufer, Max
<Max.Staufer at rolls-royce.com> wrote:
> However, pushing vector data to the client does not () , the pointer in the SOA -> AOS Structure works fine on the coprocessor side, but the
> Paraview client displays only random garbage.
>
> // Add a vector field to the VTK data container using SOADataArrayTemplate
> extern "C" void addvectorfieldsoa_(float* vector0,float* vector1,float* vector2, char* name) {
>    vtkCPInputDataDescription* idd =
> vtkCPPythonAdaptorAPI::GetCoProcessorData()->GetInputDescriptionByName("input");
>
>      vtkUnstructuredGrid* VTKgrid =
> vtkUnstructuredGrid::SafeDownCast(idd->GetGrid());
>
>      if (!VTKgrid) {
>        vtkGenericWarningMacro("No adaptor grid to attach field data to.");
>        return;
>      }
>
>      if (idd->IsFieldNeeded(name)) {
>        //vtkSOADataArrayTemplate<float>* field = //vtkSOADataArrayTemplate<float>::SafeDownCast(VTKgrid->GetCellData()->GetArray(name));
>        vtkFloatArray* field = vtkFloatArray::SafeDownCast(
>          VTKgrid->GetCellData()->GetArray(name));
>        if (!field) {
>
>          // vector array
>          vtkSOADataArrayTemplate<float>* field = vtkSOADataArrayTemplate<float>::New();
>          field->SetNumberOfComponents(3); //field->SetNumberOfTuples(VTKgrid->GetNumberOfCells());
>          field->SetName(name);
>          field->SetArray(vector0, 3*VTKgrid->GetNumberOfCells(), 1);

There is no method in vtkSOADataArrayTemplate that matches the
signature of the above call (in this scope, 'field' is a
vtkSOADataArrayTemplate<float>).

>          field->SetArray(0, vector0, VTKgrid->GetNumberOfCells(), false, true);
>          field->SetArray(1, vector1, VTKgrid->GetNumberOfCells(), false, true);
>          field->SetArray(2, vector2, VTKgrid->GetNumberOfCells(), false, true);
>          VTKgrid->GetCellData()->AddArray(field);
>          field->Delete();
>        }
>        else {
>          field->SetArray(0, vector0, VTKgrid->GetNumberOfCells(), false, true);
>          field->SetArray(1, vector1, VTKgrid->GetNumberOfCells(), false, true);
>          field->SetArray(2, vector2, VTKgrid->GetNumberOfCells(), false, true);

There is no method in vtkFloatArray that matches the above signature
(in this scope, 'field' is a vtkFloatArray).

>        }
>      }
> }

Is this the actual code? I'd be surprised if it compiles. I suspect
that if the compiler is allowing the above, it's getting confused
about the shadowed 'field' variable and doing Very Bad Things instead
of throwing an error. Does renaming the new array to an unused
identifier help anything?

Otherwise, I'd try iterating through the data in the raw pointers and
the data in the data array and print out the values. That might
provide some clues as to what's going wrong.

Also, I see that you've commented out SetNumberOfTuples, and also pass
'false' as the updateMaxId argument to SetArray. The array will think
that it's empty in this situation, which is probably not what you
want.

HTH,
Dave


More information about the Paraview-developers mailing list