Beispiel #1
0
    def test_read_parameters_filename_default(self):
        params = RBFParameters()
        params.read_parameters()
        outfilename = 'parameters_rbf.prm'
        outfilename_expected = 'tests/test_datasets/parameters_rbf_default.prm'

        self.assertTrue(filecmp.cmp(outfilename, outfilename_expected))
        os.remove(outfilename)
Beispiel #2
0
 def test_save_points_deformed(self):
     params = RBFParameters()
     params.read_parameters(
         filename='tests/test_datasets/parameters_rbf_cube.prm')
     outfilename = 'tests/test_datasets/box_test_cube_deformed_out.vtk'
     outfilename_expected = 'tests/test_datasets/box_test_cube_deformed.vtk'
     params.save_points(outfilename, True)
     self.assertTrue(filecmp.cmp(outfilename, outfilename_expected))
     os.remove(outfilename)
Beispiel #3
0
    def test_write_parameters(self):
        params = RBFParameters()
        params.read_parameters('tests/test_datasets/parameters_rbf_cube.prm')

        outfilename = 'tests/test_datasets/parameters_rbf_cube_out.prm'
        outfilename_expected = 'tests/test_datasets/parameters_rbf_cube_out_true.prm'
        params.write_parameters(outfilename)

        self.assertTrue(filecmp.cmp(outfilename, outfilename_expected))
        os.remove(outfilename)
Beispiel #4
0
 def test_save_points_deformed(self):
     params = RBFParameters()
     params.read_parameters(
         filename='tests/test_datasets/parameters_rbf_cube.prm')
     outfilename = 'tests/test_datasets/box_test_cube_deformed_out.vtk'
     outfilename_expected = 'tests/test_datasets/box_test_cube_deformed.vtk'
     params.save_points(outfilename, True)
     with open(outfilename, 'r') as out, open(outfilename_expected,
                                              'r') as exp:
         self.assertTrue(out.readlines()[1:] == exp.readlines()[1:])
     os.remove(outfilename)
Beispiel #5
0
output_morphed_vtk_path = args.output

print("GENERATING MORPHED VTK");



cwd = os.getcwd()
full_path = os.path.realpath(__file__)
path, filename = os.path.split(full_path)


# In[2]:


params = RBFParameters()
params.read_parameters(parameter_file_path)


# In[2]:


vtk_handler = VtkHandler()
mesh = vtk_handler.parse(mesh_file_path)


# In[4]:


rbf = RBF(params, mesh)
rbf.perform()
new_mesh_points = rbf.modified_mesh_points
Beispiel #6
0
    mesh[i] = [float(x), float(y), float(z)]
    i += 1
#
fig = plt.figure(1)
ax = fig.add_subplot(111, projection='3d')
ax.scatter(mesh[:, 0], mesh[:, 1], mesh[:, 2], c='blue', marker='o')
ax.set_xlabel('X axis')
ax.set_ylabel('Y axis')
ax.set_zlabel('Z axis')
plt.show()

# modified 2-D mesh

# read the RBF parameters
params = RBFParameters()
params.read_parameters(filename='turn_airfoil.prm')

params.plot_points()

params.save_points(filename='point.vtk')
#
rbf = RBF(params, mesh)
rbf.perform()
new_mesh_points = rbf.modified_mesh_points
#

fig = plt.figure(2)
ax = fig.add_subplot(111, projection='3d')
ax.scatter(new_mesh_points[:, 0],
           new_mesh_points[:, 1],
           new_mesh_points[:, 2],
Beispiel #7
0
 def test_read_parameters_failing_number_deformed_control_points(self):
     params = RBFParameters()
     with self.assertRaises(TypeError):
         params.read_parameters(
             'tests/test_datasets/parameters_rbf_bugged_01.prm')
Beispiel #8
0
 def test_read_parameters_failing_filename_type(self):
     params = RBFParameters()
     with self.assertRaises(TypeError):
         params.read_parameters(3)
Beispiel #9
0
 def test_read_parameters_deformed_control_points(self):
     params = RBFParameters()
     params.read_parameters('tests/test_datasets/parameters_rbf_default.prm')
     np.testing.assert_array_almost_equal(params.deformed_control_points,
                                          unit_cube)
Beispiel #10
0
 def test_read_parameters_n_control_points(self):
     params = RBFParameters()
     params.read_parameters('tests/test_datasets/parameters_rbf_default.prm')
     assert params.n_control_points == 8
Beispiel #11
0
 def test_read_parameters_radius(self):
     params = RBFParameters()
     params.read_parameters('tests/test_datasets/parameters_rbf_default.prm')
     assert params.radius == 0.5
Beispiel #12
0
 def test_read_parameters_basis(self):
     params = RBFParameters()
     params.read_parameters('tests/test_datasets/parameters_rbf_default.prm')
     assert params.basis == 'gaussian_spline'
Beispiel #13
0
from pygem import RBFParameters, RBF
import numpy as np
import matplotlib.pyplot as plt

# read the RBF parameters
params = RBFParameters()
params.read_parameters(
    filename='cartesian_test.prm')

nx, ny, nz = (50, 10, 10)
mesh = np.zeros((nx * ny * nz, 3))

xv = np.linspace(0, 5, nx)
yv = np.linspace(0, 1, ny)
zv = np.linspace(0, 1, nz)

# vectors
z, y, x = np.meshgrid(zv, yv, xv)

mesh = np.array([x.ravel(), y.ravel(), z.ravel()])
mesh = mesh.T

fig = plt.figure(1)
ax = fig.add_subplot(111, projection='3d')
ax.scatter(mesh[:, 0], mesh[:, 1], mesh[:, 2], c='blue', marker='o')
ax.set_xlabel('X axis')
ax.set_ylabel('Y axis')
ax.set_zlabel('Z axis')
plt.show()

params.plot_points()
Beispiel #14
0
from pygem import RBFParameters, RBF
import numpy as np
import matplotlib.pyplot as plt
###############
params = RBFParameters()
params.read_parameters(
    filename='PyGem/tests/test_datasets/parameters_rbf_cube.prm')
###############

# the definition of the mesh it has to be
# a 3-D mesh
nx, ny, nz = (10, 10, 10)
mesh = np.zeros((nx * ny * nz, 3))

xv = np.linspace(0, 1, nx)
yv = np.linspace(0, 1, ny)
zv = np.linspace(0, 1, nz)
z, y, x = np.meshgrid(zv, yv, xv)

mesh = np.array([x.ravel(), y.ravel(), z.ravel()])
mesh = mesh.T

fig = plt.figure(1)
ax = fig.add_subplot(111, projection='3d')
ax.scatter(mesh[:, 0], mesh[:, 1], mesh[:, 2], c='blue', marker='o')
ax.set_xlabel('X axis')
ax.set_ylabel('Y axis')
ax.set_zlabel('Z axis')
plt.show()

params.plot_points()
Beispiel #15
0
# coding: utf-8

# In[1]:

#get_ipython().run_line_magic('matplotlib', 'inline')
from pygem import RBFParameters, RBF, StlHandler, VtkHandler
import numpy as np
import matplotlib.pyplot as plt
import os
cwd = os.getcwd()
full_path = os.path.realpath(__file__)
path, filename = os.path.split(full_path)

# In[2]:

params = RBFParameters()
params.read_parameters('../tests/test_datasets/parameters.prm')

# In[2]:

vtk_handler = VtkHandler()
mesh = vtk_handler.parse('../tests/test_datasets/fine_mesh.vtk')

# In[4]:

rbf = RBF(params, mesh)
rbf.perform()
new_mesh_points = rbf.modified_mesh_points
vtk_handler.write(new_mesh_points, "fine_mesh_morphed.vtk")