[Paraview] calculate total sum of a variable in CTH data (UNCLASSIFIED)

Su, Simon M CTR USARMY ARL (US) simon.m.su.ctr at mail.mil
Tue Jul 1 09:24:17 EDT 2014


Classification: UNCLASSIFIED
Caveats: NONE

Hi Utkrash,

Thanks
-simon

-----Original Message-----
From: Utkarsh Ayachit [mailto:utkarsh.ayachit at kitware.com]
Sent: Tuesday, July 01, 2014 9:14 AM
To: Su, Simon M CTR USARMY ARL (US)
Cc: paraview at paraview.org
Subject: Re: [Paraview] calculate total sum of a variable in CTH data

Simon,

Use the following for your main body. Also note, for AMR datasets, the scalars 
are available cell data, not point data.


-----------------------------------------------------------------------------------
if input.IsA("vtkUniformGridAMR"):
    # This initializes AMR properly. It will share the dataset instances
    # but we will clone those later.
    output.ShallowCopy(input)

    iter = input.NewIterator()
    iter.UnRegister(None)
    iter.InitTraversal()
    while not iter.IsDoneWithTraversal():
        curInput = iter.GetCurrentDataObject()
        curOutput = curInput.NewInstance()
        calculateSum(curInput, curOutput)
        output.SetDataSet(iter, curOutput)
        curOutput.UnRegister(None)
        iter.GoToNextItem();
else:
    calculateSum(input, output)
-----------------------------------------------------------------------------------

On Tue, Jul 1, 2014 at 8:40 AM, Su, Simon M CTR USARMY ARL (US) 
<simon.m.su.ctr at mail.mil> wrote:
>
> Hello,
>
> I am trying to simply add up all the values of a variable in the CTH
> dataset using programmable filter with the python code at the end of this 
> email..
>
> The code seems to be working for the other dataset that I worked in
> the past. But for CTH dataset, it is giving me an error with
> GetCellData
>
> Traceback (most recent call last):
>
> File "<string>", line 22, in <module>
>
> File "<string>", line 43, in RequestData
>
> File "<string>", line 8, in calculateSum
>
> AttributeError: GetCellData
>
>
> When I printed the output for CTH dataset it is giving me
>
> vtkNonOverlappingAMR (0x7f96ca7675c0)
>
> Debug: Off
>
> Modified Time: 860345754
>
> Reference Count: 2
>
> Registered Events: (none)
>
> Information: 0x7f96ca767040
>
> Data Released: False
>
> Global Release Data: Off
>
> UpdateTime: 856914636
>
> Field Data:
>
> Debug: Off
>
> Modified Time: 855459763
>
> Reference Count: 1
>
> Registered Events: (none)
>
> Number Of Arrays: 4
>
> Array 0 name = GlobalBounds
>
> Array 1 name = GlobalBoxSize
>
> Array 2 name = MinLevel
>
> Array 3 name = MinLevelSpacing
>
> Number Of Components: 4
>
> Number Of Tuples: 6
>
>
> Any help is in adding a variable in a CTH dataset is much appreciated.
>
> thank you
> -simon
>
> p/s: sorry for the other unfinished email sent....
>
>
>
> =========================================
> def calculateSum(input, output):
>     # Copy the cells etc.
>     output.ShallowCopy(input)
>
>     # Get the array to calculate the coefficient
>     toSum = output.GetPointData().GetArray("MOMENT_X")
>
>     # for each of the elements, calculate the three roots and store
> the real and imaginary output in separate arrays
>     numPoints = toSum.GetSize()
>
>     # create the output arrays
>     sum = vtk.vtkDoubleArray()
>     sum.SetNumberOfValues(numPoints)
>     sum.SetName("sum")
>     tsum = 0
>
>     for i in range(0, numPoints):
>         tsum = tsum + toSum.GetValue(i)
>
>     for j in range(0, numPoints):
>         sum.SetValue(j, tsum)
>
>     output.GetPointData().AddArray(sum)
>
> input = self.GetInputDataObject(0, 0)
> output = self.GetOutputDataObject(0)
>
> if input.IsA("vtkMultiBlockDataSet"):
>     output.CopyStructure(input)
>     iter = input.NewIterator()
>     iter.UnRegister(None)
>     iter.InitTraversal()
>     while not iter.IsDoneWithTraversal():
>         curInput = iter.GetCurrentDataObject()
>         curOutput = curInput.NewInstance()
>         curOutput.UnRegister(None)
>         output.SetDataSet(iter, curOutput)
>         calculateSum(curInput, curOutput)
>         iter.GoToNextItem();
> else:
>     calculateSum(input, output)
>
> _______________________________________________
> 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://public.kitware.com/mailman/listinfo/paraview
>

Classification: UNCLASSIFIED
Caveats: NONE


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5633 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/paraview/attachments/20140701/0f99ea4e/attachment.bin>


More information about the ParaView mailing list