コード例 #1
0
 def ExecuteInitialize(self):
     hdf5_file = self._GetFile()
     prefix = self.settings["prefix"].GetString()
     KratosHDF5.ReadDataValueContainer(hdf5_file, prefix, self._model_part.ProcessInfo)
     nodal_io_settings = KratosMultiphysics.Parameters("""
         {
             "list_of_variables": ["EIGENVECTOR_MATRIX"],
             "prefix" : ""
         }
         """)
     nodal_io_settings["prefix"].SetString(prefix)
     nodal_data_value_io = KratosHDF5.HDF5NodalDataValueIO(nodal_io_settings, hdf5_file)
     nodal_data_value_io.ReadNodalResults(self._model_part.Nodes, self._model_part.GetCommunicator())
コード例 #2
0
 def ExecuteFinalize(self):
     hdf5_file = self._GetFile()
     prefix = self.settings["prefix"].GetString()
     KratosHDF5.WriteDataValueContainer(hdf5_file, prefix,
                                        self._model_part.ProcessInfo)
     nodal_io_settings = KratosMultiphysics.Parameters("""
         {
             "list_of_variables": ["EIGENVECTOR_MATRIX"],
             "prefix" : ""
         }
         """)
     nodal_io_settings["prefix"].SetString(prefix)
     non_historical_nodal_io = KratosHDF5.HDF5NonHistoricalNodalValueIO(
         nodal_io_settings, hdf5_file)
     non_historical_nodal_io.WriteNodalResults(self._model_part.Nodes)
コード例 #3
0
ファイル: model_part.py プロジェクト: dunli/Kratos
 def __call__(self, model_part, hdf5_file):
     KratosHDF5.HDF5ConditionGaussPointOutput(
         self.GetSettings(model_part).Get(),
         hdf5_file).WriteConditionGaussPointValues(
             model_part.Conditions,
             model_part.GetCommunicator().GetDataCommunicator(),
             model_part.ProcessInfo)
コード例 #4
0
 def __call__(self, model_part, hdf5_file):
     if hasattr(self, 'time_format'):
         prefix = Prefix(self.prefix, model_part, self.time_format)
     else:
         prefix = Prefix(self.prefix, model_part)
     KratosHDF5.HDF5PartitionedModelPartIO(
         hdf5_file, prefix).WriteModelPart(model_part)
コード例 #5
0
ファイル: xdmf_utils.py プロジェクト: FelipeFonsecaa14/Kratos
def RenumberConnectivitiesForXdmf(filename_or_list_of_filenames,
                                  h5path_to_mesh):
    """Renumber mesh connectivities for XDMF.

    Keyword arguments:
    filename_or_list_of_filenames -- the HDF5 file(s) to renumber
    h5path_to_mesh -- the internal HDF5 file path to the mesh

    The mesh connectivities must be renumbered for XDMF by the node's array
    index rather than its ID.  The renumbered connectivities are stored in
    HDF5 and referenced by the XDMF Grid.  If a file cannot be opened, it is
    skipped.

    See:
    - XdmfConnectivitiesWriterProcess.
    """
    for path in list(filename_or_list_of_filenames):
        skip = True
        with TryOpenH5File(path, "r") as f:
            if not f:
                continue
            if h5path_to_mesh in f:
                skip = "Xdmf" in f[h5path_to_mesh]
        if not skip:
            KratosHDF5.HDF5XdmfConnectivitiesWriterProcess(
                path, h5path_to_mesh).Execute()
コード例 #6
0
ファイル: file_io.py プロジェクト: wacyyang/Kratos
 def Get(self, model_part=None):
     return KratosHDF5.HDF5FileParallel(
         self._FileSettings(model_part).Get())
コード例 #7
0
 def __call__(self, model_part, hdf5_file):
     primal_io = KratosHDF5.HDF5NodalSolutionStepBossakIO(
         self.GetSettings(model_part).Get(), hdf5_file)
     primal_io.ReadNodalResults(model_part.Nodes,
                                model_part.GetCommunicator())
コード例 #8
0
 def __call__(self, model_part, hdf5_file):
     primal_io = KratosHDF5.HDF5NodalSolutionStepBossakIO(
         self.GetSettings(model_part).Get(), hdf5_file)
     primal_io.SetAlphaBossak(self.alpha_bossak)
     primal_io.WriteNodalResults(model_part.Nodes)
コード例 #9
0
 def __call__(self, model_part, hdf5_file):
     primal_io = KratosHDF5.HDF5NodalFlagValueIO(
         self.GetSettings(model_part).Get(), hdf5_file)
     primal_io.ReadNodalFlags(model_part.Nodes,
                              model_part.GetCommunicator())
コード例 #10
0
def CreateXdmfTemporalGridFromSinglefile(h5_file_name, h5path_pattern_to_mesh,
                                         h5path_pattern_to_results):
    """Return an XDMF Grid object for a list of temporal results in a single HDF5 file.

    Keyword arguments:
    h5_file_name -- the HDF5 file to be parsed
    h5path_pattern_to_mesh -- the internal HDF5 file path pattern to the mesh [ only <step> flag is supported ]
    h5path_pattern_to_results -- the internal HDF5 file path pattern to the results [ only <step> flag is supported ]

    Expects:
    - In prefixes, <step> flag is used maximum of one time only
    - If single mesh description is found, it is considered as single mesh temporal output
    """
    tgrid = TemporalGrid()

    h5path_pattern_to_mesh_wild_cards = h5path_pattern_to_mesh.replace(
        "<step>", "\d*")
    h5path_patterns_to_mesh = h5path_pattern_to_mesh.split("<step>")
    if (len(h5path_patterns_to_mesh) > 2):
        raise RuntimeError("'<step>' flag can only be used once in a prefix")

    h5path_pattern_to_results_wild_cards = h5path_pattern_to_results.replace(
        "<step>", "\d*")
    h5path_patterns_to_results = h5path_pattern_to_results.split("<step>")
    if (len(h5path_patterns_to_results) > 2):
        raise RuntimeError("'<step>' flag can only be used once in a prefix")

    renumbering_mesh_paths = []
    with TryOpenH5File(h5_file_name, "r") as file_:
        if not file_:
            raise RuntimeError(
                "Unsupported h5 file provided [ file_name = {:s} ].".format(
                    h5_file_name))

        output_meshes_dict = {}
        file_.visit(lambda x: GetMatchingGroupNames(
            output_meshes_dict, x, h5path_patterns_to_mesh,
            h5path_pattern_to_mesh_wild_cards))

        for _, v in output_meshes_dict.items():
            if "Xdmf" not in file_[v]:
                renumbering_mesh_paths.append(v)

        if len(output_meshes_dict.keys()) == 0:
            raise RuntimeError(
                "No grid information is found in the given hdf5 file matching the given pattern [ file_name = {:s}, pattern = {:s} ]."
                .format(h5_file_name, h5path_pattern_to_mesh))

    # renumber xdmf connectivities
    for v in renumbering_mesh_paths:
        KratosHDF5.HDF5XdmfConnectivitiesWriterProcess(h5_file_name,
                                                       v).Execute()

    with TryOpenH5File(h5_file_name, "r") as file_:
        output_results_dict = {}
        file_.visit(lambda x: GetMatchingGroupNames(
            output_results_dict, x, h5path_patterns_to_results,
            h5path_pattern_to_results_wild_cards))

        if len(output_results_dict.keys()) == 0:
            raise RuntimeError(
                "No results data is found in the given hdf5 file matching the given pattern [ file_name = {:s}, pattern = {:s} ]."
                .format(h5_file_name, h5path_pattern_to_results))

        for k, v in output_results_dict.items():
            if k in output_meshes_dict:
                sgrid = CreateXdmfSpatialGrid(file_[output_meshes_dict[k]])

            current_sgrid = SpatialGrid()
            for g in sgrid.grids:
                current_sgrid.add_grid(
                    UniformGrid(g.name, g.geometry, g.topology))

            for result in XdmfResults(file_[v]):
                current_sgrid.add_attribute(result)

            tgrid.add_grid(Time(k), current_sgrid)

    return tgrid
コード例 #11
0
ファイル: hdf5_output.py プロジェクト: vchen30/Kratos
 def Execute(self, model_part, hdf5_file):
     KratosHDF5.HDF5ModelPartIO(
         hdf5_file,
         self.settings["prefix"].GetString()).WriteModelPart(model_part)
コード例 #12
0
 def _GetFile(self):
     return KratosHDF5.HDF5FileSerial(self.settings["file_settings"])
コード例 #13
0
ファイル: hdf5_io.py プロジェクト: nasay/Kratos
 def Execute(self, model_part, hdf5_file):
     primal_io = KratosHDF5.HDF5NodalSolutionStepBossakIO(
         self.settings, hdf5_file)
     primal_io.ReadNodalResults(model_part.Nodes,
                                model_part.GetCommunicator())
コード例 #14
0
ファイル: model_part.py プロジェクト: simright/Kratos
 def __call__(self, model_part, hdf5_file):
     KratosHDF5.HDF5NodalDataValueIO(self.GetSettings(model_part),
                                     hdf5_file).WriteNodalResults(
                                         model_part.Nodes)
コード例 #15
0
 def __call__(self, model_part, hdf5_file):
     KratosHDF5.HDF5ElementDataValueIO(
         self.GetSettings(model_part).Get(),
         hdf5_file).WriteElementResults(model_part.Elements)
コード例 #16
0
ファイル: model_part.py プロジェクト: simright/Kratos
 def __call__(self, model_part, hdf5_file):
     nodal_io = KratosHDF5.HDF5NodalSolutionStepDataIO(
         self.GetSettings(model_part), hdf5_file)
     nodal_io.ReadNodalResults(model_part.Nodes,
                               model_part.GetCommunicator(), 0)
コード例 #17
0
ファイル: hdf5_io.py プロジェクト: Ginux1994/Kratos
 def Execute(self, model_part, hdf5_file):
     KratosHDF5.HDF5ElementDataValueIO(
         self.settings, hdf5_file).WriteElementResults(model_part.Elements)
コード例 #18
0
ファイル: hdf5_io.py プロジェクト: Ginux1994/Kratos
 def Execute(self, model_part, hdf5_file):
     primal_io = KratosHDF5.HDF5NodalDataValueIO(self.settings, hdf5_file)
     primal_io.ReadNodalResults(model_part.Nodes,
                                model_part.GetCommunicator())
コード例 #19
0
ファイル: hdf5_io.py プロジェクト: Ginux1994/Kratos
 def Execute(self, model_part, hdf5_file):
     KratosHDF5.HDF5NodalSolutionStepDataIO(
         self.settings,
         hdf5_file).ReadNodalResults(model_part.Nodes,
                                     model_part.GetCommunicator(), 0)
コード例 #20
0
ファイル: hdf5_io.py プロジェクト: Ginux1994/Kratos
 def Execute(self, model_part, hdf5_file):
     KratosHDF5.HDF5NodalDataValueIO(
         self.settings, hdf5_file).WriteNodalResults(model_part.Nodes)
コード例 #21
0
 def __call__(self, model_part, hdf5_file):
     KratosHDF5.HDF5ElementDataValueIO(
         self.GetSettings(model_part).Get(),
         hdf5_file).ReadElementResults(model_part.Elements,
                                       model_part.GetCommunicator())
コード例 #22
0
ファイル: create_xdmf_file.py プロジェクト: shsong2001/Kratos
def GenerateXdmfConnectivities(file_name):
    with h5py.File(file_name, "r") as h5py_file:
        has_xdmf = ("Xdmf" in h5py_file.get('/ModelData').keys())
    if not has_xdmf:
        KratosHDF5.HDF5XdmfConnectivitiesWriterProcess(file_name, "/ModelData").Execute()
コード例 #23
0
ファイル: hdf5_io.py プロジェクト: nasay/Kratos
 def Execute(self, model_part, hdf5_file):
     primal_io = KratosHDF5.HDF5NodalSolutionStepBossakIO(
         self.settings, hdf5_file)
     primal_io.SetAlphaBossak(self.alpha_bossak)
     primal_io.WriteNodalResults(model_part.Nodes)
コード例 #24
0
 def __call__(self, model_part, hdf5_file):
     KratosHDF5.HDF5ConditionFlagValueIO(
         self.GetSettings(model_part).Get(),
         hdf5_file).WriteConditionFlags(model_part.Conditions)
コード例 #25
0
ファイル: hdf5_io.py プロジェクト: nasay/Kratos
 def Execute(self, model_part, hdf5_file):
     KratosHDF5.HDF5ElementSolutionStepDataIO(
         self.settings, hdf5_file).WriteElementResults(model_part.Elements)
コード例 #26
0
 def __call__(self, model_part, hdf5_file):
     KratosHDF5.HDF5ConditionFlagValueIO(
         self.GetSettings(model_part).Get(),
         hdf5_file).ReadConditionFlags(model_part.Conditions,
                                       model_part.GetCommunicator())
コード例 #27
0
ファイル: hdf5_output.py プロジェクト: vchen30/Kratos
 def Open(self, file_name):
     self.settings["file_name"].SetString(file_name)
     return KratosHDF5.HDF5FileParallel(self.settings)
コード例 #28
0
 def __call__(self, model_part, hdf5_file):
     KratosHDF5.HDF5NodalSolutionStepDataIO(
         self.GetSettings(model_part).Get(),
         hdf5_file).WriteNodalResults(model_part.Nodes, 0)
コード例 #29
0
ファイル: hdf5_output.py プロジェクト: vchen30/Kratos
 def Execute(self, model_part, hdf5_file):
     KratosHDF5.HDF5NodalSolutionStepDataIO(self.settings,
                                            hdf5_file).WriteNodalResults(
                                                model_part.Nodes, 0)
コード例 #30
0
 def __call__(self, model_part, hdf5_file):
     KratosHDF5.HDF5NodalFlagValueIO(
         self.GetSettings(model_part).Get(),
         hdf5_file).WriteNodalFlags(model_part.Nodes)