[Paraview] [EXT] Re: How to test for empty block in multi-block dataset

Dennis Conklin dennis_conklin at goodyear.com
Wed Oct 18 13:05:56 EDT 2017


Andy,

GetCellType works fine when I have cells in the block, but in this recent case I had zero cells in the block after a Threshold filter,   my code is of the form:

    Def process_block(block):
        Print block.GetNumberOfCells()




    ###################################################################
    # main routine starts here
    output.CopyStructure(inputs[0].VTKObject)
    # if you ShallowCopy, then new variables created in input to filter
    output.DeepCopy(inputs[0].VTKObject)

    #
    # Loop over blocks in composite (Exodus) data set
    for block in output:

       # VTK element types:
       #     12 = VTK_HEXAHEDRON (Gdyr Hex)
       #      9 = VTK_QUAD  (Gdyr Membrane)
       #      3 = VTK_LINE  (Gdyr 3D Truss)
       # since EXODUS requires single element type per block, test 1st element only
       if block.GetCellType(0)==12:
          process_block(block)

I think GetCellType is dying as there is no element(0)
I need a way to test the block before calling anything to see if it is empty

Thanks!
Dennis

From: Andy Bauer [mailto:andy.bauer at kitware.com]
Sent: Wednesday, October 18, 2017 11:39 AM
To: Dennis Conklin <dennis_conklin at goodyear.com>
Cc: Paraview (paraview at paraview.org) <paraview at paraview.org>
Subject: Re: [EXT] Re: [Paraview] How to test for empty block in multi-block dataset

Hi Dennis,
Maybe the block isn't a vtkDataSet and thus wouldn't have the GetCellType() method. You could try a print statement after the for loop to see what each block is by doing something like:
print block

Could you share your full python code for the programmable filter? That may make it easier to track down.

Best,
Andy

On Wed, Oct 18, 2017 at 11:01 AM, Dennis Conklin <dennis_conklin at goodyear.com<mailto:dennis_conklin at goodyear.com>> wrote:
Andy,

I’m not sure about the multiblock, my routines generally look like:

For block in output:
     If block.GetCellType(0)=12;
           process_block(block)

would this be

If input.GetBlock(i)
And I might not have loaded all the blocks in the set, then I might have eliminated some loaded blocks with earlier operations – what is the i in GetBlock?  Is it block_number as displayed in Spreadsheet or block index as in:

block_index = block.FieldData.GetArray(‘ElementBlockIds’) - 1

Sorry for such a basic question, but I only know the stuff I have used previously.

Dennis

From: Andy Bauer [mailto:andy.bauer at kitware.com<mailto:andy.bauer at kitware.com>]
Sent: Wednesday, October 18, 2017 10:44 AM
To: Dennis Conklin <dennis_conklin at goodyear.com<mailto:dennis_conklin at goodyear.com>>
Cc: Paraview (paraview at paraview.org<mailto:paraview at paraview.org>) <paraview at paraview.org<mailto:paraview at paraview.org>>
Subject: [EXT] Re: [Paraview] How to test for empty block in multi-block dataset

 WARNING - External email; exercise caution.



Hi Dennis,
I think something like:
if multiblock.GetBlock(i) != None:
  ...
should work. You probably don't even need the "!=None" part.
Cheers,
Andy

On Wed, Oct 18, 2017 at 10:41 AM, Dennis Conklin <dennis_conklin at goodyear.com<mailto:dennis_conklin at goodyear.com>> wrote:
P.S.  I’m writing python inside a Programmable Filter

Thanks again
Dennis

_______________________________________________
Powered by www.kitware.com<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.kitware.com&data=01%7C01%7Cdennis_conklin%40goodyear.com%7C9dc270fb009a4b0639b908d51636b731%7C939e896692854a9a9f040887efe8aae0%7C0&sdata=99HLWFzFakz2A2flWuPb%2BjcOwf%2FEEemG9UURNHalZKc%3D&reserved=0>

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.kitware.com%2Fopensource%2Fopensource.html&data=01%7C01%7Cdennis_conklin%40goodyear.com%7C9dc270fb009a4b0639b908d51636b731%7C939e896692854a9a9f040887efe8aae0%7C0&sdata=3id87QE9dLu8DdNl%2BE7KX3z8TUWFHqotqxtAdGnj8uE%3D&reserved=0>

Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fparaview.org%2FWiki%2FParaView&data=01%7C01%7Cdennis_conklin%40goodyear.com%7C9dc270fb009a4b0639b908d51636b731%7C939e896692854a9a9f040887efe8aae0%7C0&sdata=EMSmEDwRt9GGxILGWdVsG7NuX%2FNZN4a5aPJvzF8X2Rk%3D&reserved=0>

Search the list archives at: http://markmail.org/search/?q=ParaView<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmarkmail.org%2Fsearch%2F%3Fq%3DParaView&data=01%7C01%7Cdennis_conklin%40goodyear.com%7C9dc270fb009a4b0639b908d51636b731%7C939e896692854a9a9f040887efe8aae0%7C0&sdata=mCNLuBUJ1akzSuauw0mK5dbUSoKJGKS9wPhjMkikhyg%3D&reserved=0>

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpublic.kitware.com%2Fmailman%2Flistinfo%2Fparaview&data=01%7C01%7Cdennis_conklin%40goodyear.com%7C9dc270fb009a4b0639b908d51636b731%7C939e896692854a9a9f040887efe8aae0%7C0&sdata=DoIRVm9jB%2BeEPp08AEkgj6RUMnzOU2bLj4SRL2Q%2BKYM%3D&reserved=0>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20171018/abbd6332/attachment.html>


More information about the ParaView mailing list