当前位置: 首页>>代码示例>>Python>>正文


Python MEDLoaderDataForTest.buildAMEDFileDataWithGroupOnOneFamilyForSauv方法代码示例

本文整理汇总了Python中MEDLoaderDataForTest.MEDLoaderDataForTest.buildAMEDFileDataWithGroupOnOneFamilyForSauv方法的典型用法代码示例。如果您正苦于以下问题:Python MEDLoaderDataForTest.buildAMEDFileDataWithGroupOnOneFamilyForSauv方法的具体用法?Python MEDLoaderDataForTest.buildAMEDFileDataWithGroupOnOneFamilyForSauv怎么用?Python MEDLoaderDataForTest.buildAMEDFileDataWithGroupOnOneFamilyForSauv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MEDLoaderDataForTest.MEDLoaderDataForTest的用法示例。


在下文中一共展示了MEDLoaderDataForTest.buildAMEDFileDataWithGroupOnOneFamilyForSauv方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testChangeGroupName

# 需要导入模块: from MEDLoaderDataForTest import MEDLoaderDataForTest [as 别名]
# 或者: from MEDLoaderDataForTest.MEDLoaderDataForTest import buildAMEDFileDataWithGroupOnOneFamilyForSauv [as 别名]
 def testChangeGroupName(self):
     """ This test is a non regression test on MEDFileUMesh.changeGroupName thanks to Alliance.
     """
     mfd=MEDLoaderDataForTest.buildAMEDFileDataWithGroupOnOneFamilyForSauv()
     mesh = mfd.getMeshes().getMeshAtPos(0)
     mesh.changeGroupName("grp0_LM1", "xonall1")
     self.assertTrue("xonall1" in mesh.getGroupsNames())
     pass
开发者ID:mndjinga,项目名称:CDMATH,代码行数:10,代码来源:MEDLoaderTest1.py

示例2: testSauvWriterGroupWithOneFamily

# 需要导入模块: from MEDLoaderDataForTest import MEDLoaderDataForTest [as 别名]
# 或者: from MEDLoaderDataForTest.MEDLoaderDataForTest import buildAMEDFileDataWithGroupOnOneFamilyForSauv [as 别名]
    def testSauvWriterGroupWithOneFamily(self):
        """
        This test checks an option for sauv writing. It is requested here to copy a group from a family if a group is lying on a single family.
        """
        import re
        mfd=MEDLoaderDataForTest.buildAMEDFileDataWithGroupOnOneFamilyForSauv()
        sauvFile = "mesh.sauv"
        sw=SauvWriter.New()
        sw.setMEDFileDS(mfd)
        self.assertTrue(not sw.getCpyGrpIfOnASingleFamilyStatus())
        sw.setCpyGrpIfOnASingleFamilyStatus(True)
        self.assertTrue(sw.getCpyGrpIfOnASingleFamilyStatus())
        sw.write(sauvFile)

        f = open(sauvFile)
        # String pattern for the header of the sub meshes record ("PILE" number, number of named objects, number of objects)
        pattern_pile= re.compile(r'\sPILE\sNUMERO\s+(?P<number>[0-9]+)NBRE\sOBJETS\sNOMMES\s+(?P<nbnamed>[0-9]+)NBRE\sOBJETS\s+(?P<nbobjects>[0-9]+)')
        # String pattern for a sub mesh header (cell type, number of components and three numbers)
        pattern_header=re.compile(r'\s+(?P<type>[0-9]+)\s+(?P<nbsubs>[0-9]+)\s+[0-9]+\s+[0-9]+\s+[0-9]+')

        nbobjects=0
        line = f.readline()
        while(line):
            match_pile = pattern_pile.match(line)
            if match_pile:
                number=int(match_pile.group("number"))
                if number == 1:
                    nbnamed=int(match_pile.group("nbnamed"))
                    nbobjects=int(match_pile.group("nbobjects"))
                    break
                pass
            line=f.readline()
            pass

        # Skipping the objects names
        f.readline()
        # Skipping the objects ids
        f.readline()

        # Looking for each sub-mesh header
        line = f.readline()
        cur_object=0
        while(line and cur_object < nbobjects):
            match_header=pattern_header.match(line)
            if match_header:
                cell_type=int(match_header.group("type"))
                nb_subs=int(match_header.group("nbsubs"))
                # Looking for a compound object
                if cell_type == 0:
                    # Testing if there is only one component
                    self.assertTrue(nb_subs > 1)
                else:
                    f.readline()
                    f.readline()
                    cur_object = cur_object + 1
                    pass
                pass
            line=f.readline()
            pass
        f.close()
        os.remove(sauvFile)
        pass
开发者ID:mndjinga,项目名称:CDMATH,代码行数:64,代码来源:SauvLoaderTest.py


注:本文中的MEDLoaderDataForTest.MEDLoaderDataForTest.buildAMEDFileDataWithGroupOnOneFamilyForSauv方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。