def copyAndCleanState(self,
                          results,
                          periodSaveGIE,
                          stateFileName,
                          velocityFileName=None,
                          gie=None):
        '''
        '''

        u.checkExistance(self.debugDir)

        if os.path.exists(self.debugDir + stateFileName):
            os.remove(self.debugDir + stateFileName)
        if velocityFileName and os.path.exists(self.debugDir +
                                               velocityFileName):
            os.remove(self.debugDir + velocityFileName)
        if gie:
            for fileName in gie:
                if os.path.exists(self.debugDir + fileName):
                    os.remove(self.debugDir + fileName)

        for res in results:
            u.copyFileIntoAnother(res["directory"] + slash + "stateFile.state",
                                  self.debugDir + stateFileName)

            if velocityFileName is not None:
                u.copyFileIntoAnother(
                    res["directory"] + "/stateFileVelocity.state",
                    self.debugDir + velocityFileName)
            if gie:
                for fileName in gie:
                    u.copyFileIntoAnother(res["directory"] + slash + fileName,
                                          self.debugDir + fileName)

        self.cleanStateFile(periodSaveGIE, stateFileName)
Exemplo n.º 2
0
    def phase2(self):
        """
        **With the previous result obtain in during :py:func:`phase1` we compute the modes**

        See :py:mod:`.ReadStateFilesAndComputeModes` for the way the modes are determined.

        It will set ``nbrOfModes`` to its maximum, but it can be changed has argument to the next step : :py:func:`phase3`

        """
        # MOR IMPORT
        from mor.reduction.script import readStateFilesAndComputeModes

        start_time = time.time()

        u.checkExistance(self.packageBuilder.dataDir)

        self.reductionParam.nbrOfModes = readStateFilesAndComputeModes(
            stateFilePath=self.packageBuilder.debugDir +
            self.reductionParam.stateFileName,
            modesFileName=self.packageBuilder.dataDir +
            self.reductionParam.modesFileName,
            tol=self.reductionParam.tolModes,
            addRigidBodyModes=self.reductionParam.addRigidBodyModes,
            verbose=self.verbose)

        if self.reductionParam.nbrOfModes == -1:
            raise ValueError(
                "problem of execution of readStateFilesAndComputeModes")

        print("PHASE 2 --- %s seconds ---" % (time.time() - start_time))
    def finalizePackage(self,result):
        '''
        '''

        shutil.move(result['directory']+slash+self.packageName+'.py', self.outputDir+slash+self.packageName+'.py')

        with open(result['directory']+slash+'meshFiles.txt', "r") as meshFiles:
            self.meshes = meshFiles.read().splitlines()

        u.checkExistance(self.meshDir)

        if self.meshes:
            for mesh in self.meshes:
                u.copy(mesh, self.meshDir)

        if self.addToLibBool :

            self.addToLib()