Esempio n. 1
0
    def _init_mesh(self):
        mesh = Ofpp.FoamMesh(self.path_dir)
        mesh.read_cell_centres(self.path_dir + self.path_centres)
        mesh.read_cell_volumes(self.path_dir + self.path_vols)

        self.nodes = mesh.points
        self.face_nodes = mesh.faces
        self.cell_faces = mesh.cell_faces

        self.n_node = len(self.nodes)
        # self.n_face = mesh.num_inner_face
        self.n_face = mesh.num_face
        self.n_bdface = mesh.num_face - mesh.num_inner_face
        self.n_cell = len(self.cell_faces)

        self.owner = mesh.owner
        self.neighbour = mesh.neighbour

        self.centers = mesh.cell_centres
        self.volumes = mesh.cell_volumes

        self._set_boundary(mesh)
        self._calc_face_centers()
        self._calc_face_vec()
        self._calc_vec_lr()
Esempio n. 2
0
 def open_file(self, filename):
     self.mesh = Ofpp.FoamMesh(self.filename)
Esempio n. 3
0
from unittest import TestCase
import unittest
import numpy as np
import Ofpp
from smithers.io.openfoamhandler import OpenFoamHandler

openfoam_mesh_path = 'tests/test_datasets/openfoam_mesh'
notime_openfoam_mesh_path = 'tests/test_datasets/notime_openfoam_mesh'

handler = OpenFoamHandler()
mesh = handler.read(openfoam_mesh_path)
truth_mesh = Ofpp.FoamMesh(openfoam_mesh_path)

class TestOpenFoamHandler(TestCase):
    def test_read(self):
        assert type(mesh) == dict

        assert 'points' in mesh['0']
        assert 'faces' in mesh['0']
        assert 'boundary' in mesh['0']
        assert 'cells' in mesh['0']

    def test_read_boundary_names(self):
        assert set(mesh['0']['boundary'].keys()) == set([b'inlet', b'outlet', b'bottom', b'top', b'obstacle', b'frontAndBack'])

    def test_read_points(self):
        np.testing.assert_almost_equal(mesh['0']['points'], truth_mesh.points)

    def test_read_faces(self):
        np.testing.assert_almost_equal(mesh['0']['faces'], truth_mesh.faces)