Hi Jacques,<br><br>I don&#39;t see any shortcut for setting the points other than creating a vtkPoints object and directly filling it with values.  For adding cells to an unstructured grid, I think you first want to do an Allocate and then SetCells() for each cell since you should already know how many cells you have ahead of time.  For the arrays in pointdata, celldata, and fielddata you should be able to create the array (e.g. vtkFloatArray) and if the memory layout for your contiguous array (assuming your field values are in contiguous arrays) is the same as VTK (i.e. tuple 0 component 0 then tuple 0 component 1, ..., tuple 1 component 0, tuple 1 component 1,...) then you can use the SetArray() method to reuse your existing memory for field information.<br>
<br>Andy<br><br><div class="gmail_quote">On Thu, Aug 12, 2010 at 6:19 AM, Jacques Papper <span dir="ltr">&lt;<a href="mailto:jacques.papper@gmail.com">jacques.papper@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi Andy, Pat,<br><br>I have the skeleton of the coprocessing working (for the moment I just tried by populating the point field - no cells, no data).<br>I am trying to figure out the most efficient way of transferring my data structure to VTK with minimal copying and looping... <br>

I would like to use the vtkUnstructuredGrid::SetCells() method, which means I probably need to use the vtkCellArray::SetCells() method, and therefore the vtkIdType::SetArray() method... <br>The problem is I am not sure what the format of the array should be ?<br>

I am dealing with unstructured polyhedra cells (most of which are known types like hex prism etc..). <br><br>Of course, I could also use the InsertNextCell() methods, but I was wondering if there wasn&#39;t a more efficient way... <br>

<br>Best,<br>Jacques<br><br><br><div class="gmail_quote">2010/8/9 Andy Bauer <span dir="ltr">&lt;<a href="mailto:andy.bauer@kitware.com" target="_blank">andy.bauer@kitware.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

Hi Jacques,<br><br>I put an example on the wiki based on Pat&#39;s example for running a coprocessing.  It&#39;s at:<br><a href="http://paraview.org/Wiki/Coprocessing_example#Python_Scripts" target="_blank">http://paraview.org/Wiki/Coprocessing_example#Python_Scripts</a><br>



Let me know if you have any problems with it so that I can fix any errors that I have.<br><br>Also, I just made changes so that the coprocessing library gets installed properly.<br><br>Thanks,<br><font color="#888888">Andy</font><div>

<div></div><div><br><br><div class="gmail_quote">
On Wed, Aug 4, 2010 at 7:21 PM, Jacques Papper <span dir="ltr">&lt;<a href="mailto:jacques.papper@gmail.com" target="_blank">jacques.papper@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Thanks Pat, <br><br>I am trying to compile my first attempt.<br>Although I do find the headers I need, I am having some trouble identifying which libraries I need to link to. <br>



For example, I assume that I should be linking to libvtkCoProcessor.so ... Although I find this library in the compilation folder (under bin), I do not find it in the make installed version under lib... <br>
Is this normal ? <br><br>Best, <br>Jacques<br><br><div class="gmail_quote">2010/8/4 pat marion <span dir="ltr">&lt;<a href="mailto:pat.marion@kitware.com" target="_blank">pat.marion@kitware.com</a>&gt;</span><div><div></div>



<div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Below is a simple cxx program I have used for testing.  It creates one sphere per process, positions the sphere as a function of the process id, and the spheres grow/shrink over time.<br><br>Pat<br><br>#include &quot;vtkCPProcessor.h&quot;<br>





#include &quot;vtkCPPythonScriptPipeline.h&quot;<br>#include &quot;vtkMultiProcessController.h&quot;<br>#include &quot;vtkXMLUnstructuredGridReader.h&quot;<br>#include &quot;vtkUnstructuredGrid.h&quot;<br>#include &quot;vtkCPDataDescription.h&quot;<br>





#include &quot;vtkCPInputDataDescription.h&quot;<br>#include &quot;vtkSmartPointer.h&quot;<br>#include &quot;vtkPolyData.h&quot;<br>#include &quot;vtkSphereSource.h&quot;<br><br>#include &lt;stdio.h&gt;<br>#include &lt;string&gt;<br>





#include &lt;sstream&gt;<br><br>static unsigned int procId;<br><br>void myprint(const std::string&amp; str)<br>{<br>  printf(&quot;driver (%u): %s\n&quot;, procId, str.c_str());<br>}<br><br>class DataGenerator {<br>public:<br>





<br>  DataGenerator()<br>    {<br>    this-&gt;Sphere = vtkSmartPointer&lt;vtkSphereSource&gt;::New();<br>    this-&gt;Sphere-&gt;SetThetaResolution(30);<br>    this-&gt;Sphere-&gt;SetPhiResolution(30);<br>    this-&gt;Sphere-&gt;SetCenter(procId*4.0, 0, 0);<br>





    this-&gt;Index = 0;<br>    }<br><br>  vtkSmartPointer&lt;vtkPolyData&gt; GetNext()<br>    {<br>    double radius = fabs(sin(0.1 * this-&gt;Index));<br>    this-&gt;Index++;<br>    this-&gt;Sphere-&gt;SetRadius(1.0 + radius);<br>





    this-&gt;Sphere-&gt;Update();<br>    vtkSmartPointer&lt;vtkPolyData&gt; ret = vtkSmartPointer&lt;vtkPolyData&gt;::New();<br>    ret-&gt;DeepCopy(this-&gt;Sphere-&gt;GetOutput());<br>    return ret;<br>    }<br><br>protected:<br>





<br>  int Index;<br>  vtkSmartPointer&lt;vtkSphereSource&gt; Sphere;<br>  <br><br>};<br><br>int main(int argc, char* argv[])<br>{<br>  if (argc &lt; 3)<br>    {<br>    printf(&quot;Usage: %s &lt;cp python file&gt; &lt;number of steps&gt;\n&quot;, argv[0]);<br>





    return 1;<br>    }<br><br>  std::string cpPythonFile = argv[1];<br>  int nSteps = atoi(argv[2]);<br><br>  myprint(&quot;starting coprocessor&quot;);<br><br>  vtkCPProcessor* processor = vtkCPProcessor::New();<br>  processor-&gt;Initialize();<br>





  vtkCPPythonScriptPipeline* pipeline = vtkCPPythonScriptPipeline::New();<br><br>  // mpi was initialized when we called vtkCPPythonScriptPipeline::New()<br>  procId = vtkMultiProcessController::GetGlobalController()-&gt;GetLocalProcessId();<br>





<br><br>  // read the coprocessing python file<br>  myprint(&quot;loading pipeline python file: &quot; + cpPythonFile);<br>  int success = pipeline-&gt;Initialize(cpPythonFile.c_str());<br>  if (!success)<br>    {<br>    myprint(&quot;aborting&quot;);<br>





    return 1;<br>    }<br><br>  processor-&gt;AddPipeline(pipeline);<br>  pipeline-&gt;Delete();<br><br>  if (nSteps == 0)<br>    {<br>    return 0;<br>    }<br><br>  // create a data source<br>  DataGenerator generator;<br>





<br>  // do coprocessing<br>  double tStart = 0.0;<br>  double tEnd = 1.0;<br>  double stepSize = (tEnd - tStart)/nSteps;<br><br>  vtkCPDataDescription* dataDesc = vtkCPDataDescription::New();<br>  dataDesc-&gt;AddInput(&quot;input&quot;);<br>





<br>  for (int i = 0; i &lt; nSteps; ++i)<br>    {<br><br>    double currentTime = tStart + stepSize*i;<br>    std::stringstream timeStr;<br>    timeStr &lt;&lt; &quot;time(&quot; &lt;&lt; i &lt;&lt; &quot;, &quot; &lt;&lt; currentTime &lt;&lt; &quot;)&quot;;<br>





<br><br>    dataDesc-&gt;SetTimeData(currentTime, i);<br><br>    myprint(&quot;call RequestDataDescription, &quot; + timeStr.str());<br>    int do_coprocessing = processor-&gt;RequestDataDescription(dataDesc);<br><br>    if (do_coprocessing)<br>





      {<br>      myprint(&quot;calling CoProcess, &quot; + timeStr.str());<br><br>      vtkSmartPointer&lt;vtkDataObject&gt; dataObject =<br>        generator.GetNext();<br><br>      dataDesc-&gt;GetInputDescriptionByName(&quot;input&quot;)-&gt;SetGrid(dataObject);<br>





      processor-&gt;CoProcess(dataDesc);<br>      }<br>    }<br><br><br>  myprint(&quot;finalizing&quot;);<br>  dataDesc-&gt;Delete();<br>  processor-&gt;Finalize();<br>  processor-&gt;Delete();<br><br>  return 0;<div><div>




</div><div><br>}<br>
<br><br><br><div class="gmail_quote">On Wed, Aug 4, 2010 at 12:14 PM, Andy Bauer <span dir="ltr">&lt;<a href="mailto:andy.bauer@kitware.com" target="_blank">andy.bauer@kitware.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">





Hi Jacques,<br><br>There is a polyhedra cell type in VTK now -- <a href="http://www.vtk.org/doc/nightly/html/classvtkPolyhedron.html" target="_blank">http://www.vtk.org/doc/nightly/html/classvtkPolyhedron.html</a><br>As far as I know it works with all of the proper filters but since I haven&#39;t tried it yet I won&#39;t promise that.  The good news is that Will Schroeder had a high interest in it and probably worked on some of it so I&#39;d assume that it&#39;s working quite well right now.<br>






<br>As for Phasta, it does run in parallel (as props to their developers it was a finalist for the 2009 Gordon Bell prize).  The grid is already partitioned and each process runs the adaptor and creates an unstructured grid from its portion of the partitioned mesh.  Thus, there isn&#39;t any need for mpi calls in the adaptor code.  If you had ghost cell information in your partitioned mesh and wanted to get fancy you should be able to add that to your partitioned grid to make some of the filters faster but I haven&#39;t tried that.<br>





<font color="#888888">
<br>Andy</font><div><div></div><div><br><br><div class="gmail_quote">On Wed, Aug 4, 2010 at 11:58 AM, Jacques Papper <span dir="ltr">&lt;<a href="mailto:jacques.papper@gmail.com" target="_blank">jacques.papper@gmail.com</a>&gt;</span> wrote:<br>





<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Thanks a lot Andy, Takuya,<br><br>I&#39;m using the PhastaAdaptor, and the FortranAdaptorAPI as a guide for the moment. <br>I know there were talks of getting POLYHEDRAL cell support in VTK. Do you know if this is there yet?<br>







My dataset is multiregion unstructured polyhedral mesh domain decomposed amongst each processor. <br><br>Is the Phasta code parallelized ? If so, I do not see any MPI statements in the adaptor code ?<br><br>Jacques<br><br>







<div class="gmail_quote">2010/8/4 Andy Bauer <span dir="ltr">&lt;<a href="mailto:andy.bauer@kitware.com" target="_blank">andy.bauer@kitware.com</a>&gt;</span><div><div></div><div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">







Hi Jacques,<br><br>What type of data set do you have?  Even though the PHASTA adaptor ( ParaView/CoProcessing/Adaptors/FortranAdaptors/PhastaAdaptor) is for fortran code it may give you an idea.  Also stepping through the example in ParaView/CoProcessing/CoProcessor/Testing/Cxx/PythonScriptCoProcessingExample.cxx may help as well.<br>








<br>I&#39;ll spend some time this week putting up a skeleton of a simulation code on the coprocessing wiki that should hopefully be easier to follow.  I&#39;ll let you know when it&#39;s done.<br><font color="#888888"><br>







Andy<br><br></font><div class="gmail_quote"><div><div></div><div>
On Wed, Aug 4, 2010 at 8:02 AM, Jacques Papper <span dir="ltr">&lt;<a href="mailto:jacques.papper@gmail.com" target="_blank">jacques.papper@gmail.com</a>&gt;</span> wrote:<br></div></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">







<div><div></div><div>
Hi All,<br><br>Sorry for my last post, I figured out that I had wrongly set my PYTHONPATH.. <br>All the tests work ok now. Still interested in CoProcessing adaptors examples though :) <br><br>Thanks <br>Jacques<br><br><div class="gmail_quote">









2010/8/4 Jacques Papper <span dir="ltr">&lt;<a href="mailto:jacques.papper@gmail.com" target="_blank">jacques.papper@gmail.com</a>&gt;</span><div><div></div><div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">









<br><div class="gmail_quote">Hi All, <br><br>I&#39;m starting to look into the ParaView CoProcessing libraries. <br>I just pulled from git today, and compiled it all up following the guidelines in :<br><a href="http://www.paraview.org/Wiki/CoProcessing" target="_blank">http://www.paraview.org/Wiki/CoProcessing</a><br>











I didn&#39;t find :<br><b>BUILD_PYTHON_COPROCESSING_ADAPTOR<br></b>but instead :<br>PARAVIEW_BUILD_PLUGIN_CoProcessingScriptGenerator<br>anyway the compilation went through without any issues.<br>I then tried :<br><br>ctest -R CoProcessing<br>











Test project /users/boreas01/jacques/PARAVIEW/ParaView-bin<br>    Start 491: CoProcessingTestPythonScript<br>1/3 Test #491: CoProcessingTestPythonScript ...........   Passed    0.45 sec<br>    Start 492: CoProcessingPythonScriptGridPlot<br>











2/3 Test #492: CoProcessingPythonScriptGridPlot .......***Failed    0.09 sec<br>    Start 493: CoProcessingPythonScriptPressurePlot<br>3/3 Test #493: CoProcessingPythonScriptPressurePlot ...***Failed    0.09 sec<br><br>33% tests passed, 2 tests failed out of 3<br>











<br>Total Test time (real) =   0.68 sec<br><br>The following tests FAILED:<br>        492 - CoProcessingPythonScriptGridPlot (Failed)<br>        493 - CoProcessingPythonScriptPressurePlot (Failed)<br>Errors while running CTest<br>











<br>Is this a problem in my current installation or on the master branch ? <br><br>Finally, I would like to start writing an adaptor to a C++ parallelised code. Can you tell me what is the closest code I can inspire myself from ? <br>











<br><br>Thank you, <br><font color="#888888"><font color="#888888">Jacques<br>
</font></font></div><br><br>PS sorry mixed up the subjects.. <br>
</blockquote></div></div></div><br>
<br></div></div><div>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the ParaView Wiki at: <a href="http://paraview.org/Wiki/ParaView" target="_blank">http://paraview.org/Wiki/ParaView</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.paraview.org/mailman/listinfo/paraview" target="_blank">http://www.paraview.org/mailman/listinfo/paraview</a><br>
<br></div></blockquote></div><br>
</blockquote></div></div></div><br>
</blockquote></div><br>
</div></div><br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the ParaView Wiki at: <a href="http://paraview.org/Wiki/ParaView" target="_blank">http://paraview.org/Wiki/ParaView</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.paraview.org/mailman/listinfo/paraview" target="_blank">http://www.paraview.org/mailman/listinfo/paraview</a><br>
<br></blockquote></div><br>
</div></div></blockquote></div></div></div><br>
</blockquote></div><br>
</div></div></blockquote></div><br>
</blockquote></div><br>