コード例 #1
0
    def setUp(self):
        """
        Set up of tests
        """
        self.my_cells = OneDimensionHansboEnrichedCell(1)
        self.my_cells._classical = np.array([False])
        self.my_cells._external_library = None

        self.my_cells.energy.current_value = np.array([1.e+06])
        self.my_cells.pressure.current_value = np.array([1.5e+09])
        self.my_cells.density.current_value = np.array([8000.])
        self.my_cells.pseudo.current_value = np.array([1.e+08])
        self.my_cells.sound_velocity.current_value = np.array([300.])
        self.my_cells._deviatoric_stress_current = np.array([[5., 8., 3.]])

        self.my_cells.energy.new_value = np.array([0.8e+06])
        self.my_cells.pressure.new_value = np.array([1.3e+09])
        self.my_cells.density.new_value = np.array([8020.])
        self.my_cells.pseudo.new_value = np.array([1.e+08])
        self.my_cells.sound_velocity.new_value = np.array([302.])
        self.my_cells._deviatoric_stress_new = np.array([[4., 5., 6.]])
        self.my_cells._deviatoric_strain_rate = np.array([[1., 1., 1.]])

        self.my_cells.enr_density.current_value = np.array([4000.])
        self.my_cells.enr_density.new_value = np.array([4020.])
        self.my_cells.enr_pressure.current_value = np.array([1.1e+09])
        self.my_cells.enr_pressure.new_value = np.array([1.3e+09])
        self.my_cells.enr_energy.current_value = np.array([1.e+06])
        self.my_cells.enr_energy.new_value = np.array([0.8e+06])
        self.my_cells.enr_artificial_viscosity.current_value = np.array([1.e+08])
        self.my_cells.enr_artificial_viscosity.new_value = np.array([1.e+08])
        self.my_cells.enr_sound_velocity.current_value = np.array([300.])
        self.my_cells.enr_sound_velocity.new_value = np.array([302.])
        self.my_cells._enr_deviatoric_stress_current = np.array([[3., 2., 1.], ])
        self.my_cells._enr_deviatoric_stress_new = np.array([[5., 12., 7.], ])
        self.my_cells._enr_deviatoric_stress_new = np.array([[5., 12., 7.], ])
        self.my_cells._enr_deviatoric_strain_rate = np.array([[4., 3., 8.], ])
        self.my_cells.enr_yield_stress.current_value = np.array([10.])
        self.my_cells._enr_equivalent_plastic_strain_rate = np.array([0.])
        self.my_cells._enr_stress = np.array([[0., 0., 0.]])
        self.my_cells.left_part_size.current_value = np.array([0.2])
        self.my_cells.right_part_size.current_value = np.array([0.3])
        self.my_cells.left_part_size.new_value = np.array([0.4])
        self.my_cells.right_part_size.new_value = np.array([0.6])

        # configuration d'un mock 'discontinuity'
        config = {'mask_in_nodes': np.array([True, False]),
                  'mask_out_nodes': np.array([False, True]),
                  'position_in_ruptured_element':
                      DataContainer().material_target.failure_model.failure_treatment_value,
                  'mask_ruptured_cell': np.array([True]),
                  'ruptured_cell_id': np.array([0]),
                  'plastic_cells': np.array([False]),
                  }
        self.__patcher = mock.patch('xfv.src.discontinuity.discontinuity.Discontinuity',
                             spec=Discontinuity, **config)
        self.mock_disc = self.__patcher.start()

        self.test_data = DataContainer()  # pylint: disable=no-value-for-parameter
コード例 #2
0
    def setUp(self):
        """
        Preparation des tests
        """
        data_file_path = os.path.join(os.path.dirname(__file__),
                                      "../../../tests/0_UNITTEST/XDATA_hydro.json")
        self.test_datacontainer = DataContainer(data_file_path)

        class Element:
            """
            A class to mimic cell
            """
            def __init__(self, poz, pressure, pseudo, masse):
                """
                Creation of the instance
                """
                self.coord = poz
                self.pression_new = pressure
                self.pseudo = pseudo
                self.masse = masse

        self.elem_0 = Element(np.array([-0.5]), 2.5e+09, 1.0e+09, 1. / 4.)
        self.elem_1 = Element(np.array([0.5]), 1.0e+09, 0.5e+09, 1. / 4.)
        self.elem_2 = Element(np.array([1.5]), 2.0e+09, 0.e+09, 1. / 2.)
        self.my_nodes = OneDimensionNode(4, np.array([[-1., ], [0., ], [1., ], [2., ]], ndmin=2),
                                         np.array([[0., ], [0., ], [0., ], [0., ]], ndmin=2),
                                         section=1.0e-06)
コード例 #3
0
 def setUpClass(cls):
     """
     Tests setup for class
     """
     data_file_path = os.path.join(os.path.dirname(__file__),
                                   "../../../tests/0_UNITTEST/XDATA_enrichment_epp.json")
     DataContainer(data_file_path)
コード例 #4
0
    def __init__(self, nbr_of_nodes, poz_init, vit_init, section=1.):

        super().__init__(nbr_of_nodes,
                         position_initiale=poz_init,
                         dim=1,
                         vitesse_initiale=vit_init)
        self._section = section
        self._nbr_of_nodes = nbr_of_nodes
        # By definition, these nodes are not enriched
        self._classical = np.empty([
            self.number_of_nodes,
        ],
                                   dtype=np.bool,
                                   order='C')
        self._classical[:] = True
        self._enrichment_not_concerned = np.copy(self._classical)

        interface_position = DataContainer(
        ).geometric.initial_interface_position
        self.nodes_in_projectile = poz_init[:, 0] <= interface_position
        self.nodes_in_target = poz_init[:, 0] >= interface_position
        # the node in contact belongs both to the target and projectile

        # Velocity field that takes into account the enriched degrees of freedom influence
        self._v_field = np.zeros_like(self.upundemi)
コード例 #5
0
 def setUp(self):
     """
     Test set up
     """
     self.nbr_cells = 4
     self.my_cells = OneDimensionCell(self.nbr_cells)
     self.my_cells.cell_in_target = np.ones(self.nbr_cells, dtype='bool')
     self.test_data = DataContainer()  # pylint: disable=no-value-for-parameter
コード例 #6
0
ファイル: test_topology1d.py プロジェクト: MarieBichette/XVOF
 def setUp(self):
     """
     Preparation des tests
     """
     data_file_path = os.path.join(
         os.path.dirname(__file__),
         "../../../tests/0_UNITTEST/XDATA_hydro.json")
     self.test_datacontainer = DataContainer(data_file_path)
     self.topology = Topology1D(4, 3)
コード例 #7
0
    def setUp(self):
        """
        Initialisation des tests
        """
        data_file_path = os.path.join(os.path.dirname(__file__),
                                      "../../../tests/0_UNITTEST/XDATA_enrichment_epp.json")
        DataContainer(data_file_path)

        self.cells = OneDimensionHansboEnrichedCell(10)
コード例 #8
0
 def __init__(self, path_to_db: str, verbose: bool):
     """
     Creation of the class
     :param path_to_db : complete path to database hdf5 band (should include all_fields.hdf5)
     :param verbose : to allow a detailed print
     """
     self._my_hd = OutputDatabaseExploit(path_to_db)
     self._case = os.path.basename(os.path.dirname(path_to_db))
     self._data_container = DataContainer(
         os.path.join(os.path.dirname(path_to_db), "XDATA.json"))
     self._verbose = verbose
     self.first_enr_time = dict()
コード例 #9
0
ファイル: cell.py プロジェクト: MarieBichette/XVOF
    def __init__(self, nbr_of_cells: int):
        """
        Constructor of the array of cells

        :param nbr_of_cells: number of cells
        """
        self.data = DataContainer()  # pylint: disable=no-value-for-parameter
        self._nbr_of_cells = nbr_of_cells
        self._dt = np.zeros(self._nbr_of_cells, dtype=np.float64, order='C')
        self._size_t = np.zeros(self._nbr_of_cells,
                                dtype=np.float64,
                                order='C')
        self._size_t_plus_dt = np.zeros(self._nbr_of_cells,
                                        dtype=np.float64,
                                        order='C')
        self._mass = np.zeros(self._nbr_of_cells, dtype=np.float64, order='C')
        self._fields_manager = FieldManager()

        self.cell_in_target = np.zeros(self.number_of_cells, dtype='bool')
        self.cell_in_projectile = np.zeros(self.number_of_cells, dtype='bool')

        # Default initialization for target material ---------------------
        # hydro :
        material_data = self.data.material_target.initial_values
        self._fields_manager["Density"] = Field(self._nbr_of_cells,
                                                material_data.rho_init,
                                                material_data.rho_init)
        self._fields_manager["Pressure"] = Field(self._nbr_of_cells,
                                                 material_data.pression_init,
                                                 material_data.pression_init)
        self._fields_manager["Energy"] = Field(self._nbr_of_cells,
                                               material_data.energie_init,
                                               material_data.energie_init)
        self._fields_manager["Pseudo"] = Field(self._nbr_of_cells)
        self._fields_manager["SoundVelocity"] = Field(self._nbr_of_cells)
        # Elasticity
        self._stress = np.zeros([self.number_of_cells, 3],
                                dtype=np.float64,
                                order='C')
        self._fields_manager["ShearModulus"] = Field(
            self._nbr_of_cells, material_data.shear_modulus_init,
            material_data.shear_modulus_init)
        self._fields_manager["YieldStress"] = Field(
            self._nbr_of_cells, material_data.yield_stress_init,
            material_data.yield_stress_init)
        # Porosity
        self._fields_manager["Porosity"] = Field(self._nbr_of_cells,
                                                 material_data.porosity_init,
                                                 material_data.porosity_init)

        # Coordonnées des mailles selon l'axe x
        self._coordinates_x = np.zeros(self.number_of_cells, dtype=float)
コード例 #10
0
 def setUp(self):
     """
     Test initialisation
     """
     # DataContainer creation (just to be able to build the discontinuity)
     data_file_path = os.path.join(os.path.dirname(__file__),
                                   "../../../tests/0_UNITTEST/XDATA_hydro.json")
     self.test_datacontainer = DataContainer(data_file_path)
     # Discontinuity creation
     self.disc = Discontinuity(0, np.array([True, False]), np.array([False, True]), 0.5,
                               LumpMenouillardMassMatrixProps())
     # Creation of the tested service
     self.test_unloading_model = LossOfStiffnessUnloading()
コード例 #11
0
    def setUp(self):
        """
        Prepare unittests
        """
        data_file_path = os.path.join(
            os.path.dirname(__file__),
            "../../../tests/0_UNITTEST/XDATA_hydro.json")
        self.test_datacontainer = DataContainer(data_file_path)

        self.mask_in = np.array([True, False, False, False])
        self.mask_out = np.array([False, True, False, False])
        self.my_disc = Discontinuity(0, self.mask_in, self.mask_out, 0.2,
                                     LumpMenouillardMassMatrixProps())
コード例 #12
0
ファイル: test_node.py プロジェクト: MarieBichette/XVOF
    def setUp(self):
        """
        Initialisation des tests
        """
        data_file_path = os.path.join(os.path.dirname(__file__),
                                      "../../../tests/0_UNITTEST/XDATA_hydro.json")
        self.test_datacontainer = DataContainer(data_file_path)

        self.vit_init = np.array([-1.5e+03, 1.2e+03, 0.3e+03], ndmin=2)
        self.poz_init = np.array([0.5, 0.025, -0.1], ndmin=2)
        # Création d'un noeud en 3D :
        self.my_node = nd.Node(1, position_initiale=self.poz_init,
                               vitesse_initiale=self.vit_init, dim=3)
コード例 #13
0
    def setUp(self):
        """
        Preparation of the unit tests
        """
        data_file_path = os.path.join(
            os.path.dirname(__file__),
            "../../../tests/0_UNITTEST/XDATA_hydro.json")
        self.test_datacontainer = DataContainer(data_file_path)

        self.vit_init = np.zeros([2, 1], dtype='float')
        self.vit_init[:, 0] = [1.2e+03, 0.0]
        self.poz_init = np.zeros([2, 1], dtype='float')
        self.poz_init[:, 0] = [1., 2.]
        self.my_nodes = OneDimensionHansboEnrichedNode(2,
                                                       self.poz_init,
                                                       self.vit_init,
                                                       section=1.0e-06)
        self.my_nodes._classical = np.array([False, False])

        # configuration d'un mock 'discontinuity'
        config = {
            'mask_in_nodes':
            np.array([True, False]),
            'mask_out_nodes':
            np.array([False, True]),
            'label':
            1,
            'position_in_ruptured_element':
            self.test_datacontainer.material_target.failure_model.
            failure_treatment_value,
            'mask_ruptured_cell':
            np.array([True]),
            'ruptured_cell_id':
            np.array([0]),
            'plastic_cells':
            np.array([False]),
            'enr_force':
            np.array([[
                1.,
            ], [
                2.,
            ]]),
            'enr_velocity_new':
            np.zeros([2, 1])
        }
        patcher = mock.patch(
            'xfv.src.discontinuity.discontinuity.Discontinuity',
            spec=Discontinuity,
            **config)
        self.mock_discontinuity = patcher.start()
コード例 #14
0
    def setUp(self) -> None:
        """
        Preparation of the test
        """
        # Creation of a fake DataContainer :
        data_file_path = os.path.join(
            os.path.dirname(__file__),
            "../../../tests/0_UNITTEST/XDATA_hydro.json")
        self.test_datacontainer = DataContainer(data_file_path)

        # Preparation of the test
        self._pressure = 0.
        self.my_imposed_pressure = ImposedPressure(self._pressure)
        self.cells = OneDimensionCell(1000)
        self.cells.pressure_field[:] = 1.
        self.ruptured_cells = np.ndarray([1000], dtype=np.bool, order='C')
        self.ruptured_cells[:] = False
        self.ruptured_cells[500] = True
コード例 #15
0
 def tearDown(self) -> None:
     """
     End of the tests
     """
     DataContainer.clear()
コード例 #16
0
 def tearDownClass(cls):
     """
     Tear down after class tests
     """
     DataContainer.clear()
     print("\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \n")
コード例 #17
0
ファイル: outputmanager.py プロジェクト: MarieBichette/XVOF
    def register_all_fields(self, enrichment_registration, cells, nodes,
                            database_id):
        """
        Add all fields to the manager.

        :param enrichment_registration: bool to control if the enriched fields should be registered
        :param cells: cells from which fields must be printed
        :param nodes: nodes from which fields must be printed
        :param database_id: identifier of the database
        """
        node_indexes = slice(0, nodes.number_of_nodes)
        cell_indexes = slice(0, cells.number_of_cells)
        enriched_cells = np.where(cells.enriched)[0]

        # Node and cell status should always been registered
        self.register_field(
            "NodeStatus",
            nodes,
            ("enriched", ),  # should always be registered
            database_names=[database_id],
            indexes=node_indexes)
        self.register_field(
            "CellStatus",
            cells,
            ("enriched", ),  # should always be registered
            database_names=[database_id],
            indexes=cell_indexes)

        # Classical field registration
        for key in field_list:
            if key in DataContainer(
            ).output.variables:  # registration if field is in the dataset
                field_infos = field_list[key]
                # Node field
                if field_infos.support == "nodes":
                    self.register_field(field_infos.name,
                                        nodes,
                                        field_infos.attr_name,
                                        database_names=[database_id],
                                        indexes=node_indexes)
                # Cell field
                if field_infos.support == "cells":
                    self.register_field(field_infos.name,
                                        cells,
                                        field_infos.attr_name,
                                        database_names=[database_id],
                                        indexes=cell_indexes)

        if enrichment_registration:
            # => Register the enriched field also
            # Left and right size should always been registered
            self.register_field("AdditionalLeftSize",
                                cells, ("left_part_size", "current_value"),
                                database_names=[database_id],
                                indexes=enriched_cells)
            self.register_field("AdditionalRightSize",
                                cells, ("right_part_size", "current_value"),
                                database_names=[database_id],
                                indexes=enriched_cells)

            for key in enr_field_list:  # registration if field is in the dataset
                if key in DataContainer().output.variables:
                    field_infos = enr_field_list[key]
                    # Enr Node field
                    if field_infos.support is None:
                        self.register_field(field_infos.name,
                                            None,
                                            field_infos.attr_name,
                                            database_names=[database_id])
                    # Enr Cell field
                    if field_infos.support == "cells":
                        self.register_field(field_infos.name,
                                            cells,
                                            field_infos.attr_name,
                                            database_names=[database_id],
                                            indexes=cell_indexes)
コード例 #18
0
 def tearDownClass(cls):
     DataContainer.clear()
     print("\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \n")
コード例 #19
0
ファイル: test_topology1d.py プロジェクト: MarieBichette/XVOF
 def tearDown(self):
     DataContainer.clear()
コード例 #20
0
 def tearDownClass(cls):
     """
     Actions after all the tests of the class
     """
     DataContainer.clear()
     print("\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \n")
コード例 #21
0
 def setUp(self):
     self.nbr_cells = 4
     self.my_cells = OneDimensionCell(self.nbr_cells)
     self.my_cells.cell_in_target = np.ones(self.nbr_cells, dtype='bool')
     self.mask = np.array([True, True, False, False])
     self.test_data = DataContainer()  # pylint: disable=no-value-for-parameter
コード例 #22
0
ファイル: mesh1denriched.py プロジェクト: MarieBichette/XVOF
    def __init__(self, initial_coordinates, initial_velocities):
        """
        Construction of the mesh

        :param initial_coordinates: array for the node coordinates at initial time
        :param initial_velocities: array for the node velocities at initial time
        """
        self.data = DataContainer()  # pylint: disable=no-value-for-parameter
        if np.shape(initial_coordinates) != np.shape(initial_velocities):
            message = "Initial velocity and coordinates vector doesn't have the same shape!"
            raise ValueError(message)
        if np.shape(initial_coordinates)[1] != 1:
            message = (
                """A 1D mesh must have one dimensional vector which is not the case"""
                """ for initial coordinates vector!""")
            raise ValueError(message)

        # ---------------------------------------------
        # Nodes creation
        # ---------------------------------------------
        nbr_nodes = np.shape(initial_coordinates)[0]
        self.nodes = OneDimensionHansboEnrichedNode(
            nbr_nodes,
            initial_coordinates,
            initial_velocities,
            section=self.data.geometric.section)

        # ---------------------------------------------
        # Cells creation
        # ---------------------------------------------
        nbr_cells = nbr_nodes - 1
        self.cells = OneDimensionHansboEnrichedCell(nbr_cells)

        # ----------------------------------------------
        # Mass Matrix creation
        # ----------------------------------------------
        self.mass_matrix = OneDimensionMassMatrix(
            nbr_nodes, self.data.numeric.consistent_mass_matrix_on_last_cells)

        # ---------------------------------------------
        # Topology creation
        # ---------------------------------------------
        self.__topology = Topology1D(nbr_nodes, nbr_cells)
        self.nb_nodes_per_cell = np.zeros([
            self.cells.number_of_cells,
        ],
                                          dtype=np.int,
                                          order='C')
        self.nb_nodes_per_cell[:] = 2

        # ---------------------------------------------
        # Ruptured cells vector
        # ---------------------------------------------
        self.__ruptured_cells = np.zeros(self.cells.number_of_cells,
                                         dtype=np.bool,
                                         order='C')
        self.__plastic_cells = np.zeros(self.cells.number_of_cells,
                                        dtype=np.bool,
                                        order='C')

        # Initialize cell fields
        self.cells.initialize_cell_fields(self.nodes.nodes_in_target,
                                          self.nodes.nodes_in_projectile,
                                          self.__topology)
        self.mask_last_nodes_of_ref = None

        # ---------------------------------------------
        # Cohesive zone model initialisation
        # ---------------------------------------------
        self.cohesive_zone_model = None
        target_dmg_model = self.data.material_target.cohesive_model
        if target_dmg_model is not None:
            self.cohesive_zone_model = target_dmg_model.build_cohesive_model_obj(
            )
        if (self.data.material_target.failure_model.failure_treatment != "Enrichment") and \
                (self.cohesive_zone_model is not None):
            print(
                "No cohesive model is allowed if failure treatment is not Enrichment"
            )
            self.cohesive_zone_model = None

        # ---------------------------------------------
        # Contact model initialisation (contact between discontinuities boundaries)
        # ---------------------------------------------
        if self.data.material_target.contact_model is not None:
            self.contact_model: ContactBase = \
                self.data.material_target.contact_model.contact_model.build_contact_obj()
        else:
            self.contact_model = None
コード例 #23
0
 def tearDown(self):
     DataContainer.clear()
     return super().tearDown()
コード例 #24
0
def main(directory: Path) -> None:
    # pylint: disable=too-many-locals, too-many-branches, too-many-statements
    """
    Launch the program
    """
    # ------------------------------------------------------------------
    #             PARAMETERS INITIALIZATION
    # ------------------------------------------------------------------
    # ---- # DATA FILES
    data = DataContainer(directory / "XDATA.json")
    meshfile = directory / "mesh.txt"
    print("Running simulation for {}".format(directory.resolve()))

    # ---- # TIME MANAGEMENT
    final_time = data.time.final_time
    initial_time_step = data.time.initial_time_step

    # ---- # LOADING
    left_bc = data.boundary_condition.left_BC
    left_boundary_condition = _build_boundary_function(left_bc)
    right_bc = data.boundary_condition.right_BC
    right_boundary_condition = _build_boundary_function(right_bc)

    # ---- # RUPTURE
    if data.material_target.failure_model.failure_criterion is not None:
        rupture_criterion = \
            data.material_target.failure_model.failure_criterion.build_rupture_criterion_obj()
    else:
        rupture_criterion = None

    if data.material_target.failure_model.failure_treatment == "ImposedPressure":
        rupture_treatment = ImposedPressure(
            data.material_target.failure_model.failure_treatment_value)
    elif data.material_target.failure_model.failure_treatment == "Enrichment":
        rupture_treatment = EnrichElement(
            data.material_target.failure_model.failure_treatment_value,
            data.material_target.failure_model.lump_mass_matrix)
    else:
        rupture_treatment = None

    # Strong check is made in the FailureModelProps class
    assert rupture_criterion is not None or rupture_treatment is None
    # ---------------------------------------------#
    #         MESH CREATION                        #
    # ---------------------------------------------#
    my_mesh = __create_mesh(meshfile)

    # ---------------------------------------------#
    # TARGET AND PROJECTILE VELOCITIES INITIALIZATION
    # ---------------------------------------------#
    __init_velocity(my_mesh.nodes, data)

    # ---------------------------------------------#
    #  FIGURES MANAGER SETUP                       #
    # ---------------------------------------------#
    the_figure_mng = FigureManager(my_mesh, dump=data.output.dump)
    images_number = data.output.number_of_images
    if images_number != 0:
        the_figure_mng.set_time_controler(final_time / images_number)
        the_figure_mng.populate_figs()

    # ---------------------------------------------#
    #  OUTPUT MANAGER SETUP                        #
    # ---------------------------------------------#
    the_output_mng = __init_output(data, my_mesh)

    # ---------------------------------------------#
    #         NODAL MASS COMPUTATION               #
    # ---------------------------------------------#
    my_mesh.compute_cells_sizes()
    my_mesh.compute_cells_masses()
    my_mesh.compute_nodes_masses()
    print("CALCULUS LAUNCHED!")
    compute_time = 0.

    # ---------------------------------------------#
    #  READ CONSTITUTIVE MODELS SHORTCUTS          #
    # ---------------------------------------------#
    if data.material_projectile is not None:
        projectile_model = data.material_projectile.constitutive_model
        (projectile_elasticity, projectile_plasticity, projectile_shear_modulus,
         projectile_yield_stress, projectile_plasticity_criterion) = \
            _build_material_constitutive_model(projectile_model)
    else:
        projectile_elasticity, projectile_plasticity = False, False
        projectile_shear_modulus = None
        projectile_yield_stress, projectile_plasticity_criterion = None, None

    target_model = data.material_target.constitutive_model
    if target_model is not None:
        (target_elasticity, target_plasticity, target_shear_modulus,
         target_yield_stress, target_plasticity_criterion) = \
            _build_material_constitutive_model(target_model)
    else:
        target_elasticity, target_plasticity = False, False
        target_shear_modulus = None
        target_yield_stress, target_plasticity_criterion = None, None

    # ---------------------------------------------#
    #       READ POROSITY MODEL SHORTCUTS          #
    # ---------------------------------------------#

    target_porosity_model_bool = False
    target_porosity_model = None
    if data.material_target is not None:
        target_model = data.material_target
        target_porosity_model_bool, target_porosity_model = _build_material_porosity_model(
            target_model)

    # ************************************************* #
    #         DEBUT DE LA BOUCLE EN TEMPS               #
    # ************************************************* #
    simulation_time = 0.
    step = 0
    dt = initial_time_step  # pylint: disable=invalid-name
    dt_staggered = dt / 2
    # Le premier increment pour la vitesse a un pas de temps de dt/2 pour
    # tenir compte du fait que les vitesses sont
    # init a t=0 et pas t = -1/2 dt (pour garder l'ordre 2 a l'init).
    # Le dt_staggered est ensuite remis a dt a la fin de la boucle en temps
    dt_crit = 2 * dt
    while simulation_time < final_time:
        loop_begin_time = time.time()
        if step % 1000 == 0:
            msg = ("""Iteration {:<4d} -- Time : {:15.9g} seconds with"""
                   """ a time step of {:15.9g} seconds""".format(
                       step, simulation_time, dt))
            print(msg)

        # ---------------------------------------------#
        #                OUTPUT MANAGEMENT             #
        # ---------------------------------------------#
        the_output_mng.update(
            simulation_time, step,
            data.material_target.failure_model.failure_treatment_value,
            my_mesh.get_discontinuity_list())
        the_figure_mng.update(simulation_time, step)
        # ---------------------------------------------#
        #         NODES VELOCITIES COMPUTATION         #
        # ---------------------------------------------#
        my_mesh.compute_new_nodes_velocities(dt_staggered)
        # ---------------------------------------------#
        #    APPLY VELOCITY BOUNDARY CONDITIONS        #
        # ---------------------------------------------#
        if left_boundary_condition.is_velocity():
            my_mesh.apply_velocity_boundary_condition(
                'left', left_boundary_condition.evaluate(simulation_time))
        if right_boundary_condition.is_velocity():
            my_mesh.apply_velocity_boundary_condition(
                'right', right_boundary_condition.evaluate(simulation_time))
        # ---------------------------------------------#
        #         NODES COORDINATES COMPUTATION        #
        # ---------------------------------------------#
        my_mesh.compute_new_nodes_coordinates(dt)
        # ---------------------------------------------#
        #         CONTACT CORRECTION                   #
        # ---------------------------------------------#
        my_mesh.apply_contact_correction(dt)
        # ---------------------------------------------#
        #         CELLS VOLUMES COMPUTATION            #
        # ---------------------------------------------#
        my_mesh.compute_new_cells_sizes(dt)
        # ---------------------------------------------#
        #         CELLS COORDS COMPUTATION             #
        # ---------------------------------------------#
        my_mesh.compute_new_cell_coordinates()
        # ---------------------------------------------#
        #         CELLS DENSITIES COMPUTATION          #
        # ---------------------------------------------#
        my_mesh.compute_new_cells_densities()
        # ---------------------------------------------#
        #          POROSITY MODEL COMPUTATION          #
        # ---------------------------------------------#
        if target_porosity_model_bool:
            my_mesh.compute_new_cells_porosity(dt, target_porosity_model)
        # ---------------------------------------------#
        #    CELLS DEVIATOR STRESSES COMPUTATION       #
        # ---------------------------------------------#
        if projectile_elasticity:
            my_mesh.apply_elasticity(dt, projectile_shear_modulus,
                                     my_mesh.cells.cell_in_projectile)
        if target_elasticity:
            my_mesh.apply_elasticity(dt, target_shear_modulus,
                                     my_mesh.cells.cell_in_target)
        # ---------------------------------------------#
        #           PLASTICITY COMPUTATION             #
        # ---------------------------------------------#
        if projectile_plasticity:
            my_mesh.apply_plasticity(dt, projectile_yield_stress,
                                     projectile_plasticity_criterion,
                                     my_mesh.cells.cell_in_projectile)
        if target_plasticity:
            my_mesh.apply_plasticity(dt, target_yield_stress,
                                     target_plasticity_criterion,
                                     my_mesh.cells.cell_in_target)
        # ---------------------------------------------#
        #         PSEUDOVISCOSITY COMPUTATION          #
        # ---------------------------------------------#
        my_mesh.compute_new_cells_pseudo_viscosity(dt)
        # ---------------------------------------------#
        #         CELLS PRESSURES COMPUTATION          #
        # ---------------------------------------------#
        my_mesh.compute_new_cells_pressures(dt)
        # ---------------------------------------------#
        #         STRESS TENSOR COMPUTATION            #
        # ---------------------------------------------#
        my_mesh.assemble_complete_stress_tensor()
        # ---------------------------------------------#
        #              RUPTURE                         #
        # ---------------------------------------------#
        if rupture_treatment is not None:
            my_mesh.get_ruptured_cells(rupture_criterion)
            my_mesh.apply_rupture_treatment(rupture_treatment, simulation_time)
        # ---------------------------------------------#
        #         NODES FORCES COMPUTATION             #
        # ---------------------------------------------#
        my_mesh.compute_new_nodes_forces()
        my_mesh.compute_new_cohesive_forces()
        # ---------------------------------------------#
        #         LOADING                              #
        # ---------------------------------------------#
        if left_boundary_condition.is_pressure():
            my_mesh.apply_pressure(
                'left', left_boundary_condition.evaluate(simulation_time))
        if right_boundary_condition.is_pressure():
            my_mesh.apply_pressure(
                'right', right_boundary_condition.evaluate(simulation_time))
        # ---------------------------------------------#
        #         TIME STEP COMPUTATION                #
        # ---------------------------------------------#
        dt_crit = my_mesh.compute_new_time_step()
        if dt > dt_crit:
            dt = min(dt, dt_crit)  # pylint: disable=invalid-name
        # ---------------------------------------------#
        #                INCREMENTATION                #
        # ---------------------------------------------#
        my_mesh.increment()
        simulation_time += dt
        if not data.time.is_time_step_constant:
            dt_staggered = 0.5 * (dt_crit + dt)
            dt = dt_crit  # pylint: disable=invalid-name
        else:
            dt_staggered = dt
        step += 1
        loop_end_time = time.time()
        compute_time += loop_end_time - loop_begin_time

    print("Total time spent in compute operation is : {:15.9g} seconds".format(
        compute_time))
    plt.show(block=False)

    print('Done !')

    the_output_mng.finalize()
コード例 #25
0
 def tearDown(self):
     """
     Operations to be done after completing all the tests in the class
     """
     DataContainer.clear()