コード例 #1
0
 def test_generate_default_mesh(self):
     mesh_conf = SimpleBlockMeshConfig(self.width_mm, self.height_mm,
                                       self.length_mm)
     fragmentation_conf = FragmentationConfig()
     mesh = SimpleBlockMeshGenerator(mesh_conf, fragmentation_conf)
     mesh.create(self.file_out)
     self.assertTrue(files.equal(self.file_out, self.reference_file))
コード例 #2
0
    def test_correct_boundary(self):
        config = RailMeshConfig()
        config.width_lines = [100, 100]
        config.height_distance = [200]
        config.length = 300

        fragmentation = FragmentationConfig()
        mesh_generator = RailMeshGenerator(config, fragmentation)
        mesh_generator.create(0)

        expected = r"""frontTractionEnd
    {
        type patch;
        faces
        (
			(0 1 2 3)
        );
    }    rearFixedEnd
    {
        type patch;
        faces
        (
			(4 5 6 7)
        );
    }    topSurface
    {
        type patch;
        faces
        (
			(1 5 6 2)
        );
    }    bottomSurface
    {
        type patch;
        faces
        (
			(0 4 7 3)
        );
    }    rightSurface
    {
        type patch;
        faces
        (
			(0 4 5 1)
        );
    }    leftSurface
    {
        type patch;
        faces
        (
			(3 2 6 7)
        );
    }"""
        self.assertEqual(expected, mesh_generator.boundaries_text.strip())
コード例 #3
0
    def test_correct_fragmentation(self):
        config = RailMeshConfig()
        config.width_lines = [100, 100]
        config.height_distance = [200]
        config.length = 300

        fragmentation = FragmentationConfig()
        mesh_generator = RailMeshGenerator(config, fragmentation)
        mesh_generator.create(0)

        expected = "hex (0 1 2 3 4 5 6 7) (2 2 5) simpleGrading (1.0 1.0 1.0)"
        self.assertEqual(expected, mesh_generator.fragmentation_text.strip())
コード例 #4
0
    def __init__(self):
        self.k_max_deformation = 2.139e-6
        self.k_max_stress = 775900
        self.k_density = 7850
        self.k_mm_to_m = 0.001

        # Create default mesh generator config and fragmentation config
        self.mesh_config = SimpleBlockMeshConfig()
        self.fragmentation_config = FragmentationConfig()
        self.execution_config = ExecutionConfig()

        self.execution_config.execution_folder = "/home/lenferd/OpenFOAM/lenferd-v1906/run/beamEndLoad-20-04-25/"
        self.execution_config.output_dir = self.execution_config.execution_folder + "out/"
        self.execution_config.prepare_env_script = "$HOME/prog/OpenFOAM/OpenFOAM-dev/etc/bashrc_modified"
コード例 #5
0
    def test_create_correct_points(self):
        config = RailMeshConfig()
        config.width_lines = [100, 100]
        config.height_distance = [200]
        config.length = 300

        fragmentation = FragmentationConfig()
        mesh_generator = RailMeshGenerator(config, fragmentation)
        mesh_generator.create(0)

        expected = [
            '(100 0 0)', '(100 200 0)', '(0 200 0)', '(0 0 0)', '(100 0 300)',
            '(100 200 300)', '(0 200 300)', '(0 0 300)'
        ]
        self.assertEqual(expected, mesh_generator.points)
コード例 #6
0
ファイル: rail_solver.py プロジェクト: Lenferd/ANSYS-OpenFOAM
    def __init__(self):
        # Only for wo height case
        self.k_full_height = 30
        self.wo_height = False
        self.k_length = 1000

        self.k_max_deformation = 4.4e-5
        self.k_max_stress = 3.3e+9
        self.k_density = 7850
        self.k_mm_to_m = 0.001
        # FIXME Manual switch required
        self.k_approach = MIDDLE_LINE_ALGO

        # Mesh config
        self.mesh_config = RailMeshConfig()

        # Fragmentation config
        self.fragmentation_config = FragmentationConfig(5, 5, 10)

        # Exec config
        self.execution_config = ExecutionConfig()

        # FIXME Hardcoded
        # FIXME Aware of potential duplication "OpenFOAM/OpenFOAM-dev/OpenFOAM-dev"
        self.execution_config.openfoam_folder = "/home/lenferd/prog/OpenFOAM"
        # self.execution_config.execution_folder = os.path.abspath(os.getcwd())
        script_dir = os.path.dirname(os.path.abspath(__file__))
        # Fixme hardcoded. Expected format: /home/lenferd/OpenFOAM/lenferd-v1906/run/rail-20-05-06-2/OpenFOAM-wrapper
        #  /rail_solver.py
        rail_pos = script_dir.rfind("Beam")
        foam_pos = script_dir.rfind("OpenFOAM-wrapper")
        if rail_pos == -1 or foam_pos == -1:
            # FIXME Hardcoded
            # raise Exception("rail folder (openfoam project folder) or OpenFOAM-wrapper not found in path: {}".format(script_dir))
            print("HARDCORED value is used!")
            self.execution_config.execution_folder = "/home/lenferd/OpenFOAM/lenferd-dev/run/glsymm-cantileverBeam-20200524"
        else:
            self.execution_config.execution_folder = script_dir[:foam_pos]

        print("[D] execution_folder: {}".format(
            self.execution_config.execution_folder))
        self.execution_config.output_dir = os.path.join(
            self.execution_config.execution_folder, "out")
        # FIXME Hardcoded
        self.execution_config.prepare_env_script = "/home/lenferd/prog/OpenFOAM/OpenFOAM-dev/etc/bashrc_modified"
コード例 #7
0
from executor.executor import Executor
from argparse import ArgumentParser
from configs.mesh import SimpleBlockMeshConfig, SimpleBlockMeshArguments
from configs.fragmentation import FragmentationConfig, FragmentationArguments
from configs.execution import ExecutionConfig, ExecutionArguments
from mesh_generator.simple_generator import SimpleBlockMeshGenerator

if __name__ == '__main__':
    parser = ArgumentParser()
    SimpleBlockMeshArguments.add_geometry_argument_iter(parser)
    FragmentationArguments.add_fragmentation_arguments(parser)
    ExecutionArguments.add_execution_arguments(parser)
    args = parser.parse_args()

    fragmentation_conf = FragmentationConfig.create_from_args(args)
    execution_conf = ExecutionConfig.create_from_args(args)

    # FIXME Hardcoded
    script_dir = os.path.dirname(os.path.abspath(__file__))
    rail_pos = script_dir.rfind("Beam")
    foam_pos = script_dir.rfind("OpenFOAM-wrapper")
    if rail_pos == -1 or foam_pos == -1:
        raise Exception("Failed to find Beam folder in path")
    else:
        execution_conf.execution_folder = script_dir[:foam_pos]

    print("[!!!!] WARNING: prepare script and openfoam folder is hardcoded")
    execution_conf.prepare_env_script = "/home/lenferd/prog/OpenFOAM/OpenFOAM-dev/etc/bashrc_modified"
    execution_conf.openfoam_folder = "/home/lenferd/prog/OpenFOAM/"