Example #1
0
 def _parse_mold_data(self, geo_data, mesh_data, fill_data):
     mesh_data = self._parse_mesh_data(mesh_data)
     fill_data = self._parse_fill_data(fill_data)
     geo = geo_data.get(oclass=emmo.TwoManifold)
     if geo:
         geo_file = geo_data.get(oclass=emmo.File)
         if geo[0].is_a(emmo.Rectangle) and not geo_file:
             geo_data = self._parse_rectangle_data(geo_data)
             self._geometry = RectangularMesh(
                 **geo_data, **mesh_data, **fill_data
             )
         elif geo[0].is_a(emmo.Cylinder) and not geo_file:
             geo_data = self._parse_cylinder_data(geo_data)
             self._geometry = CylinderMesh(
                 **geo_data, **mesh_data, **fill_data
             )
         elif geo[0].is_a(emmo.Complex) or geo_file:
             geo_data = {
                 'source_path': self._parse_geometry_file(geo_file[0]),
                 'units': self._get_si_unit(geo_data)
             }
             self._geometry = ComplexMesh(
                 **mesh_data, **geo_data, **fill_data
             )
     else:
         raise ValueError(
             'Target geometry not recognized or geometry file not found'
         )
    def create_rectangular_mesh(self, model):
        """Placeholder for a function that builds a rectangular
        mesh for an OpenFOAM simulation"""

        mesh = RectangularMesh(units=model.units,
                               length=model.length,
                               width=model.width,
                               height=model.height,
                               resolution=model.resolution)
        return mesh
Example #3
0
 def setUp(self):
     self.factory = PUFoamFactory(plugin={'id': '0', 'name': 'test'})
     self.data_source = self.factory.create_data_source()
     self.model = self.factory.create_model()
     self.rectangle = RectangularMesh(length=10,
                                      width=2,
                                      height=20,
                                      resolution=5,
                                      units="cm")
     self.cylinder = CylinderMesh(radius=6, resolution=10, units="cm")
     self.complex = ComplexMesh(source_path=get("cone.stl"),
                                inside_location=[0, 0, 2.5],
                                units="cm")
    def setUp(self):
        # Define rectangular mesh and its properties
        self.rectangular = RectangularMesh(length=20,
                                           width=10,
                                           height=150,
                                           resolution=4,
                                           filling_fraction=0.5,
                                           units="mm")
        self.rectangular_block_extent = extent(max_extent=[20, 10, 150])
        self.rectangular_filling_extent = [[0, 0, 0], [0.02, 0.01, 0.075]]
        self.rectangular_ncells = [80, 40, 600]
        self.rectangular_volume = 30000

        # Define cylindrical mesh and its properties
        self.cylinder = CylinderMesh(radius=5,
                                     height=20,
                                     resolution=7,
                                     filling_fraction=0.5,
                                     units="cm")
        self.cylinder_stl_extent = extent([-0.05, -0.05, 0], [0.05, 0.05, 0.2])
        self.cylinder_block_extent = extent([-5, -5, 0], [5, 5, 20])
        self.cylinder_filling_extent = [0.05, 0.1]
        self.cylinder_ncells = [70, 70, 140]
        self.cylinder_location = [0, 0, 0.1]
        self.cylinder_volume = 25 * 20 * np.pi

        # Define complex mesh and its properties
        self.complex_radius = 5
        self.complex_height = 10
        self.complex_resolution = 10
        self.complex = ComplexMesh(source_path=get("cone.stl"),
                                   inside_location=[0, 0, 5],
                                   resolution=10,
                                   filling_fraction=0.5,
                                   units="cm")
        self.complex_stl_extent = extent([-0.05, -0.05, 0], [0.05, 0.05, 0.1])
        self.complex_block_extent = extent([-5, -5, 0], [5, 5, 10])
        self.complex_filling_extent = [[-0.05, -0.05, 0], [0.05, 0.05, 0.05]]
        self.complex_ncells = [100, 100, 100]
        self.complex_location = [0, 0, 0.05]
        self.complex_cutoff = 0.5
        self.complex_volume = 1 / 3 * (np.pi * self.complex_radius**2 *
                                       self.complex_height)
        self.complex_volume_cutoff = 1 / 3 * (
            self.complex_radius *
            (1 - self.complex_cutoff))**2 * np.pi * (self.complex_height *
                                                     self.complex_cutoff)
Example #5
0
    def setUp(self):
        # Define rectangular mesh and its properties
        self.rectangular = RectangularMesh(
            x_length=0.02,
            y_length=0.01,
            z_length=0.15,
            resolution=0.001,
            filling_fraction=0.5,
            units="m"
        )
        self.rectangular_max_extent = extent(
            max_extent=[0.02, 0.01, 0.15]
        )
        self.rectangular_filling_extent = extent(
            max_extent=[0.02, 0.01, 0.075]
        )
        self.rectangular_inside_location = [0.01, 0.005, 0.075]
        self.rectangular_volume = 3e-5
        self.rectangular_stl_ref = os.path.join(
            path, 'rectangle_ref.stl'
        )
        self.rectangular_geo_ref = os.path.join(
            path, 'rectangle_ref.geo'
        )
        # Define cylindrical mesh and its properties
        self.cylinder = CylinderMesh(
            xy_radius=0.05,
            z_length=0.2,
            resolution=0.0014,
            filling_fraction=0.5,
            units="m"
        )
        self.cylinder_max_extent = extent(
            [-0.05, -0.05, 0], [0.05, 0.05, 0.2]
        )
        self.cylinder_filling_extent = extent(
            [-0.05, -0.05, 0], [0.05, 0.05, 0.1]
        )
        self.cylinder_inside_location = [0, 0, 0.1]
        self.cylinder_volume = 0.025**2*0.2*np.pi
        self.cylinder_stl_ref = os.path.join(
            path, 'cylinder_ref.stl'
        )
        self.cylinder_geo_ref = os.path.join(
            path, 'cylinder_ref.geo'
        )

        # Define complex mesh and its properties
        self.complex_xy_radius = 5
        self.complex_z_length = 10
        self.complex_cutoff = 0.5
        self.complex = ComplexMesh(
            source_path=os.path.join(path, "cone.stl"),
            inside_location=[0.0, 0.0, 5.0],
            filling_fraction=0.5,
            units="mm"
        )
        self.complex_max_extent = extent(
            [-5.0, -5.0, 0.0], [5.0, 5.0, 10.0]
        )
        self.complex_filling_extent = extent(
            [-5.0, -5.0, 0.0], [5.0, 5.0, 5.0]
        )
        self.complex_inside_location = [0.0, 0.0, 5.0]
        self.complex_volume = 1/3*(np.pi*5**2*10)
        self.complex_volume_cutoff = \
            1/3*(5/10*10*0.5)**2*np.pi*(10*0.5)