Kenichiro,

Thanks for the idea.   This looks very good and I very much appreciate you 
sharing that with me.

Dennis

From: kenichiro yoshimi [mailto:[email protected]]
Sent: Friday, February 16, 2018 1:19 AM
To: Dennis Conklin <[email protected]>
Cc: Andy Bauer <[email protected]>; Paraview ([email protected]) 
<[email protected]>
Subject: Re: [Paraview] [EXT] Re: Good neighbor filter

Hi,

I have experienced a similar situation with a vtkUnstructuredGrid, and written 
a programmable filter something like:
----
import numpy as np

input = self.GetInput()
output = self.GetOutput()

numCells = input.GetNumberOfCells()

volChange = vtk.vtkFloatArray()
volChange.SetName("volumeChange")
volChange.SetNumberOfComponents(1)
volChange.SetNumberOfTuples(numCells)

for cellId in range(numCells):
  cell = input.GetCell(cellId)

  maxVol = -vtk.VTK_DOUBLE_MAX
  minVol = vtk.VTK_DOUBLE_MAX

  nFaces = cell.GetNumberOfFaces()
  for faceId in range(nFaces):
    pntIds = cell.GetFace(faceId).GetPointIds()

    neighbors = vtk.vtkIdList()
    input.GetCellNeighbors(cellId, pntIds, neighbors)

    numNei = neighbors.GetNumberOfIds()
    for num in range(numNei):
      neiId = neighbors.GetId(num)
      nei = input.GetCell(neiId)
      if nei.GetCellType() == vtk.VTK_TETRA:
        p1 = input.GetPoint(nei.GetPointId(0))
        p2 = input.GetPoint(nei.GetPointId(1))
        p3 = input.GetPoint(nei.GetPointId(2))
        p4 = input.GetPoint(nei.GetPointId(3))
        vol = vtk.vtkTetra.ComputeVolume(p1, p2, p3, p4)
        maxVol = np.maximum(maxVol, vol)
        minVol = np.minimum(minVol, vol)

  input.GetCell(cellId)
  #print(str(cellId) + ':' + str(maxVol/minVol))
  volChange.SetValue(cellId, maxVol/minVol)

output.GetCellData().AddArray(volChange)
----

Notice this computes the volumes of all cells that neighbor a cell on its faces.

Thanks,

2018-02-15 23:17 GMT+09:00 Dennis Conklin 
<[email protected]<mailto:[email protected]>>:
Andy,

Thanks for that hint – I think I get the idea.   This is a “as time is 
available” project, so I’ll start exploring it, but I appreciate being pointed 
in the right direction.

Dennis

From: Andy Bauer [mailto:[email protected]<mailto:[email protected]>]
Sent: Wednesday, February 14, 2018 1:51 PM
To: Dennis Conklin 
<[email protected]<mailto:[email protected]>>
Cc: Paraview ([email protected]<mailto:[email protected]>) 
<[email protected]<mailto:[email protected]>>
Subject: [EXT] Re: [Paraview] Good neighbor filter

 WARNING - External email; exercise caution.



Hi Dennis,
I'm assuming you're dealing with a vtkUnstructuredGrid (for the topologically 
regular grids you should just use the extent information). You'll want to look 
at the GetCellNeighbors() method -- 
https://www.vtk.org/doc/nightly/html/classvtkUnstructuredGrid.html#ac532485599a5d92acf4d9ca1e8818bfc<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.vtk.org%2Fdoc%2Fnightly%2Fhtml%2FclassvtkUnstructuredGrid.html%23ac532485599a5d92acf4d9ca1e8818bfc&data=01%7C01%7Cdennis_conklin%40goodyear.com%7Cf1004f8cac4a459ffdb908d573dbed3d%7C939e896692854a9a9f040887efe8aae0%7C0&sdata=L4bbRrKp82mtwWrnYEN6BqxNWNOkPVGp9Oa%2BMj7I7KU%3D&reserved=0>.
 Here, cellId is the cell you want to get the neighbors from, ptIds is the list 
of points that need to be shared by both cells and cellIds is the return list. 
You'll have to iterate over all points of the cell you're interested in (i.e. 
call GetCellNeighbors() 8 times for a hex).
The basic algorithm is:
loop over cells:
  for each cell, loop over all of its points
    for each point call GeCellNeighbors(cellid, point id list with a single 
point)
      loop through cellids to compare cell sizes

Please let me know if this isn't clear enough to get you going...
Cheers,
Andy

On Wed, Feb 14, 2018 at 1:38 PM, Dennis Conklin 
<[email protected]<mailto:[email protected]>> wrote:
All,

I am looking to calculate a mesh quality measure that would be the ratio of the 
max/min of the element volumes of each element and all it’s neighbors (other 
elements with common nodes).  I intend to use this to quantify grid refinement 
transitions and perhaps establish some design standards for them.    I have 
tried Gradient of Element Volume, but I need to eliminate the distance part of 
that to get the number that I want.    So, if I have a hex element in a regular 
grid,  I would expect to have 26 “neighbor” elements plus the original element. 
   The number I want is  (max of 27 element volumes)/(min of 27 element 
volumes).    This quantity will highlight mesh refinement transitions.

My question (at last) is:    how do I find all the neighbor elements (share at 
least 1 node) of each element in my model?   I’d like to do this in a 
Programmable Filter.  I’m afraid I don’t know much about how connectivity is 
implemented in vtk.

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%7Cf1004f8cac4a459ffdb908d573dbed3d%7C939e896692854a9a9f040887efe8aae0%7C0&sdata=1eTG5HFDLMAHdr2ttVYYFysnAKRt41UJMUv%2FGjjbiyc%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%7Cf1004f8cac4a459ffdb908d573dbed3d%7C939e896692854a9a9f040887efe8aae0%7C0&sdata=iXXmPAu3kwVyoiPGrJHLNwfXs4F2ELee3iatafqFl8o%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%7Cf1004f8cac4a459ffdb908d573dbed3d%7C939e896692854a9a9f040887efe8aae0%7C0&sdata=AgCLTZ66JhdDdSQjpheyLuA3rvncYV%2FARBgs9jRtcTg%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%7Cf1004f8cac4a459ffdb908d573dbed3d%7C939e896692854a9a9f040887efe8aae0%7C0&sdata=XPSUQSMnug1qBDAhkYAgiyJI6EmAc8pbGqAORcHOBbk%3D&reserved=0>

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


_______________________________________________
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%7C3174c30567f0400853df08d575052c16%7C939e896692854a9a9f040887efe8aae0%7C0&sdata=0T9q4sPinyzzQW15586ywGFYZUyJmW0XUnfp%2FZH5mrE%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%7C3174c30567f0400853df08d575052c16%7C939e896692854a9a9f040887efe8aae0%7C0&sdata=y7QWoGoa%2FxYzsFmaV5RsQ4e5bPhdJ4hzW1E9tphMi0E%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%7C3174c30567f0400853df08d575052c16%7C939e896692854a9a9f040887efe8aae0%7C0&sdata=1RhRS2662E470PLUk1VxxNdF%2BtCXm6cjAI4qGOyPM%2BM%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%7C3174c30567f0400853df08d575052c16%7C939e896692854a9a9f040887efe8aae0%7C0&sdata=bOE%2ByvZWbGkXFLVReL99VpxiijA20IZjGq1LId3Qx5Q%3D&reserved=0>

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

_______________________________________________
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

Search the list archives at: http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/paraview

Reply via email to