Skip to content

Commit

Permalink
Add python requirements (#102)
Browse files Browse the repository at this point in the history
* Sort imported modules

* Import VTK module once

* Typo fix

* Add python requirements
  • Loading branch information
kursatyurt authored Apr 4, 2022
1 parent b557947 commit 6ab9ac1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
numpy
vtk
8 changes: 4 additions & 4 deletions src/join_mesh.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env python3
import argparse
import json
import logging
import os
import json
from partition_mesh import MeshPartitioner
import vtk
import os.path

import vtk


class MeshJoiner:
"""MeshJoiner class joins meshes partitioned by MeshPartitioner class.
Expand Down Expand Up @@ -76,7 +76,7 @@ def read_meshes(prefix: str, partitions=None, recoveryPath=None):
"""
Reads meshes with given prefix.
"""
logger = MeshPartitioner.get_logger()
logger = MeshJoiner.get_logger()
if not partitions:
partitions = MeshJoiner.count_partitions(prefix)
logger.info("Detected " + str(partitions) + " partitions with prefix " + prefix)
Expand Down
12 changes: 5 additions & 7 deletions src/partition_mesh.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/usr/bin/env python3
import argparse
import json
import logging
import math
import os
from typing import List
import numpy as np
import platform
import shutil
from ctypes import *
import json
import platform

import numpy as np
import vtk


class Mesh:
Expand Down Expand Up @@ -352,7 +353,6 @@ def apply_partition(orig_mesh: Mesh, part, numparts: int):

@staticmethod
def read_mesh(filename: str) -> Mesh:
import vtk
extension = os.path.splitext(filename)[1]
if (extension == ".vtu"):
reader = vtk.vtkXMLUnstructuredGridReader()
Expand Down Expand Up @@ -386,7 +386,6 @@ def write_mesh(filename: str, points: List, data_index: List, cells=None, cell_t
if (cell_types is not None):
assert (len(cell_types) in [0, len(cells)])
assert (len(points) == len(data_index))
import vtk
logger = MeshPartitioner.get_logger()

vtkGrid = vtk.vtkUnstructuredGrid()
Expand Down Expand Up @@ -482,7 +481,6 @@ def write_meshes(meshes, recoveryInfo, meshname: str, orig_mesh, directory=None)

@staticmethod
def vtu2vtk(inmesh, outmesh):
import vtk
reader = vtk.vtkXMLUnstructuredGridReader()
reader.SetFileName(inmesh)
reader.Update()
Expand Down
8 changes: 4 additions & 4 deletions src/vtk_calculator.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env python3
import argparse
import json
import logging
import os.path
import vtk
import json
import sys

import numpy as np
from vtk.util.numpy_support import vtk_to_numpy as v2n
import vtk
from vtk.util.numpy_support import numpy_to_vtk as n2v
from vtk.util.numpy_support import vtk_to_numpy as v2n


class Calculator:
Expand Down

0 comments on commit 6ab9ac1

Please sign in to comment.