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

Staufer, Max Max.Staufer at Rolls-Royce.com
Wed Sep 7 04:13:52 EDT 2016


Dear developers,

   We I, try to access data from a Fortran90 via Catalyst.
Pushing scalars to the Paraview client works fine, see code snipped below

// Add a scalar field to the VTK data container
extern "C" void addfield_(float* scalars, 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)) {

       vtkFloatArray* field = vtkFloatArray::SafeDownCast(
         VTKgrid->GetCellData()->GetArray(name));

       if (!field) {
         vtkFloatArray* field = vtkFloatArray::New();
         field->SetNumberOfComponents(1);
         field->SetName(name);
         field->SetArray(scalars, VTKgrid->GetNumberOfCells(), 1);
         VTKgrid->GetCellData()->AddArray(field);
         field->Delete();
       }
       else {
         field->SetArray(scalars, VTKgrid->GetNumberOfCells(), 1);
       }
     }
}

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);
         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);
       }
     }
}

Interesting enough, sending the data straight as a 3 component float array works fine, only
Paraview will get the ordering wrong because the fortran array has row major ordering and
Paraview assumes a colum major ordering.

// Add a vector field to the VTK data container
extern "C" void addvectorfield_(float* vector0, 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)) {
       vtkFloatArray* field = vtkFloatArray::SafeDownCast(
         VTKgrid->GetCellData()->GetArray(name));
       if (!field) {

         // vector array vector0 is the pointer to the FORTRAN90 2d Array
         vtkFloatArray* field = vtkFloatArray::New();
         field->SetNumberOfComponents(3);
         field->SetName(name);
         field->SetArray(vector0, 3*VTKgrid->GetNumberOfCells(), 1);
         VTKgrid->GetCellData()->AddArray(field);
         field->Delete();
       }
       else {
         field->SetArray(vector0, 3*VTKgrid->GetNumberOfCells(), 1);
       }
     }
}

Any thoughts on this ?

Regards

Max

Rolls-Royce Deutschland Ltd & Co KG Sitz/Registered Office: Blankenfelde-Mahlow, Deutschland, Registergericht/Court of Register: Amtsgericht Potsdam, HRA 2731 P, Persönlich haftende Gesellschafterin/General Partner: Rolls-Royce General Partner Limited, Sitz/Registered Office: Derby, United Kingdom, Register: Registry of Companies Wales and England, 4066556, Directors/Geschäftsführer: Paul O’Neil, Alastair McIntosh, Nicole Fehr, Dr. Holger Cartsburg Confidentiality Notice: This email and any attachments are confidential to the intended recipient and may also be privileged. If you are not the intended recipient please delete it from your system and notify the sender. You should not copy it or use it for any purpose nor disclose or distribute its contents to any other person.
The data contained in, or attached to, this e-mail, may contain confidential information. If you have received it in error you should notify the sender immediately by reply e-mail, delete the message from your system and contact +44 (0) 3301235850 (Security Operations Centre) if you need assistance. Please do not copy it for any purpose, or disclose its contents to any other person.

An e-mail response to this address may be subject to interception or monitoring for operational reasons or for lawful business practices.

(c) 2016 Rolls-Royce plc

Registered office: 62 Buckingham Gate, London SW1E 6AT Company number: 1003142. Registered in England.


More information about the Paraview-developers mailing list