Maintaining surface topology and handling periodic boundary conditions in deformed point clouds

59 Views Asked by At

Body: In my molecular dynamics simulation using periodic boundary conditions, I have defined a closed region enclosed by an irregular surface. Due to the periodic boundary conditions, the closed region may be distributed across the edges and corners of the simulation box. (Figure below.)

Example figure

I have exported the closed region as a VTK unstructured_grid file, which contains a discrete set of points representing the surface. Subsequently, I deform the surface by changing the coordinates of each point using a small-scale affine transformation. However, due to the periodic boundary conditions, some points may pass through the boundaries and appear on the opposite side of the box.

Here is a snippet of Python code:

import vtk

# Function to move the grid points
def affine(point, strain, box_length):
    new_point = [0, 0, 0]
    new_point[0] = point[0] + point[1] * strain
    new_point[1] = point[1]
    new_point[2] = point[2]

    new_point[0] = new_point[0] % box_length
    new_point[1] = new_point[1] % box_length
    new_point[2] = new_point[2] % box_length

    return new_point

# Modify the coordinates of the points on the original surface
def surface_motion(grid):
    transformed_points = vtk.vtkPoints()
    points = grid.GetPoints()
    for i in range(points.GetNumberOfPoints()):
        new_point = affine(points.GetPoint(i), 0.1, 24.238694)
        transformed_points.InsertNextPoint(new_point)
    new_grid = vtk.vtkUnstructuredGrid()
    new_grid.SetPoints(transformed_points)

    # Additional steps should be taken to handle cell data

def main():
    reader = vtk.vtkUnstructuredGridReader()
    reader.SetFileName('./original.vtk')
    reader.Update()

    unstructured_grid = reader.GetOutput()
    surface_motion(unstructured_grid)

if __name__ == '__main__':
    main()

Now, I want to determine whether a user-input point lies within the closed surface formed by the deformed point cloud. My challenge is to reconstruct a closed surface from the deformed set of points while considering the periodic boundary conditions (thus maintaining the original surface’s topology).

I am aware that I need to define cells and form a cell_array to achieve this. However, this approach seems cumbersome.

Could you please recommend any tools, libraries, or algorithms that can help simplify this process and handle periodic boundary conditions effectively?

I have tried to maintain the original connectivity of the deformed points, but due to some points crossing the boundary and appearing on the opposite side after deformation, the original connectivity needs to be adjusted. I lack experience in this area and my search did not yield any results.

Thank you in advance.

0

There are 0 best solutions below