Esempio n. 1
0
    def compute(self, time):
        info = 0

        cont = self.preCompute(time)

        if (not cont):
            return 0

        if (self.indexSetLevel() == 999):
            return 0

        self.updateMu()

        w_backup = self.w().copy()
        z_backup = self.z().copy()
        SO = self.numericsSolverOptions()

        info = self.solve()
        problem = self.globalRollingFrictionContactProblemPtr()
        if problem.numberOfContacts > 0:
            if self.condition(SO) and has_fclib:
                #if True:
                #problem = self.getNumericsProblemPtr()
                #print(problem, type(problem))

                solver_maxiter = SO.iparam[0]
                n_format_string = len(str(solver_maxiter))
                format_string = "{0}-ndof-{1}-nc-{2}-{3}.hdf5"

                filename = format_string.format(self._params._fileName,
                                                problem.q.shape[0],
                                                problem.numberOfContacts,
                                                self._counter)
                print(filename)
                if os.path.exists(filename):
                    os.remove(filename)
                    print('WARNING: file ' + filename +
                          ' was existing and has been replaced')

                self._counter += 1

                print(type(problem))

                N.globalRollingFrictionContact_fclib_write(
                    problem, self._params._title, self._params._description,
                    self._params._mathInfo, filename)
                guess = F.fclib_solution()
                guess.u = w_backup
                guess.r = z_backup
                F.fclib_write_guesses(1, guess, filename)

                solution = F.fclib_solution()
                solution.u = self.w()
                solution.z = self.z()
                F.fclib_write_solution(solution, filename)

        self.postCompute()

        return info
Esempio n. 2
0
    def compute(self, time):
        info = 0
        self.setKeepLambdaAndYState(False)
        cont = self.preCompute(time)

        if (not cont):
            return 0

        if (self.indexSetLevel() == 999):
            return 0

        self.updateMu()

        if self.getSizeOutput() != 0:

            #            M = BlockCSRMatrix()
            #M.fillM(model.nonSmoothDynamicalSystem().topology().indexSet(1))
            #M.convert()

            #            H = BlockCSRMatrix()

            #t = GlobalFrictionContactProblem()

            #t.M = M.getNumericsMatSparse()

            w_backup = self.w().copy()
            z_backup = self.z().copy()
            SO = self.numericsSolverOptions()

            if self.condition(SO) and has_fclib:

                # problem = self.getNumericsProblemPtr()
                # print(problem, type(problem))

                problem = self.frictionContactProblemPtr()
                #print(problem, type(problem))
                solver_maxiter = SO.iparam[0]
                n_format_string = len(str(solver_maxiter))
                format_string = "{0}-i{1:0" + str(
                    n_format_string) + "d}-{2}-{3}.hdf5"
                filename = format_string.format(
                    self._params._fileName,
                    SO.iparam[N.SICONOS_IPARAM_ITER_DONE],
                    problem.numberOfContacts, self._counter)

                print('filename =', filename)
                if os.path.exists(filename):
                    os.remove(filename)
                    print('WARNING: file ' + filename +
                          ' was existing and has been replaced')

                self._counter += 1
                N.frictionContact_fclib_write(problem, self._params._title,
                                              self._params._description,
                                              self._params._mathInfo, filename,
                                              -1)
                guess = F.fclib_solution()
                guess.u = w_backup
                guess.r = z_backup
                F.fclib_write_guesses(1, guess, filename)

                with h5py.File(filename, 'r+') as fclib_file:
                    attrs = fclib_file['fclib_local']['info'].attrs
                    attrs.create('numberOfInvolvedDS',
                                 self._nsds.topology().numberOfInvolvedDS(1))

            info = self.solve()

            if self.condition(SO) and has_fclib:

                solution = F.fclib_solution()
                solution.u = self.w()
                solution.z = self.z()
                F.fclib_write_solution(solution, filename)

            self.postCompute()

        return info
Esempio n. 3
0
    def compute(self,time):
        info = 0
        self.setKeepLambdaAndYState(False)
        cont = self.preCompute(time)

        if (not cont):
            return 0

        if (self.indexSetLevel() == 999):
            return 0

        self.updateMu()

        if self.getSizeOutput() != 0:

            #            M = BlockCSRMatrix()
            #M.fillM(model.nonSmoothDynamicalSystem().topology().indexSet(1))
            #M.convert()

            #            H = BlockCSRMatrix()


            #t = GlobalFrictionContactProblem()

            #t.M = M.getNumericsMatSparse()

            w_backup = self.w().copy()
            z_backup = self.z().copy()
            SO = self.numericsSolverOptions()
            fclib_written = False
            if self.condition(SO) and has_fclib: 
           
                # problem = self.getNumericsProblemPtr()
                # print(problem, type(problem))
                    
                problem = self.frictionContactProblemPtr()
                #print(problem, type(problem))
                solver_maxiter=SO.iparam[0]
                n_format_string=len(str(solver_maxiter))
                format_string = "{0}-i{1:0"+str(n_format_string)+"d}-{2}-{3}.hdf5"
                filename = format_string.format(self._params._fileName,
                                                              SO.iparam[N.SICONOS_IPARAM_ITER_DONE],
                                                              problem.numberOfContacts,
                                                              self._counter)

                print('filename =', filename)
                if os.path.exists(filename):
                    os.remove(filename)
                    print('WARNING: file '+filename+ ' was existing and has been replaced')
                
                self._counter += 1
                N.frictionContact_fclib_write(problem,
                                              self._params._title,
                                              self._params._description,
                                              self._params._mathInfo,
                                              filename,
                                              -1)
                guess = F.fclib_solution()
                guess.u = w_backup
                guess.r = z_backup
                F.fclib_write_guesses(1, guess, filename)

                with h5py.File(filename, 'r+') as fclib_file:
                    attrs = fclib_file['fclib_local']['info'].attrs
                    attrs.create('numberOfInvolvedDS',
                                 self._nsds.topology().numberOfInvolvedDS(1))

                fclib_written =True

                    
            info = self.solve()

            if fclib_written:
                
                solution = F.fclib_solution()
                solution.u = self.w()
                solution.z = self.z()
                F.fclib_write_solution(solution, filename)



                
            self.postCompute()

        return info
Esempio n. 4
0
    def compute(self,time):
        info = 0

        cont = self.preCompute(time)

        if (not cont):
            return 0

        if (self.indexSetLevel() == 999):
            return 0

        self.updateMu()

        w_backup = self.w().copy()
        z_backup = self.z().copy()
        SO = self.numericsSolverOptions()

        info = self.solve()
        problem = self.globalFrictionContactProblemPtr()
        if problem.numberOfContacts >0 :
            if self.condition(SO) and has_fclib:
                # problem = self.getNumericsProblemPtr()
                # print(problem, type(problem))

                

                solver_maxiter=SO.iparam[0]
                n_format_string=len(str(solver_maxiter))
                format_string = "{0}-i{1:0"+str(n_format_string)+"d}-{2}-{3}.hdf5"
                filename = format_string.format(self._params._fileName,
                                                SO.iparam[N.SICONOS_IPARAM_ITER_DONE],
                                                problem.numberOfContacts,
                                                self._counter)

                if os.path.exists(filename):
                    os.remove(filename)
                    print('WARNING: file '+filename+ ' was existing and has been replaced')

                self._counter += 1
                N.globalFrictionContact_fclib_write(problem,
                                                    self._params._title,
                                                    self._params._description,
                                                    self._params._mathInfo,
                                                    filename)
                guess = F.fclib_solution()
                guess.u = w_backup
                guess.r = z_backup
                F.fclib_write_guesses(1, guess, filename)




                solution = F.fclib_solution()
                solution.u = self.w()
                solution.z = self.z()
                F.fclib_write_solution(solution, filename)
            
                
        self.postCompute()

        return info
Esempio n. 5
0
    def compute(self,time):
        info = 0
        cont = self.preCompute(time)

        if (not cont):
            return 0

        if (self.indexSetLevel() == 999):
            return 0

        self.updateMu()

        if self.getSizeOutput() != 0:

            #            M = BlockCSRMatrix()
            #M.fillM(model.nonSmoothDynamicalSystem().topology().indexSet(1))
            #M.convert()

            #            H = BlockCSRMatrix()


            #t = GlobalFrictionContactProblem()

            #t.M = M.getNumericsMatSparse()

            w_backup = self.w().copy()
            z_backup = self.z().copy()
            SO = self.numericsSolverOptions()
            SO.internalSolvers.iparam[19] = self._stepcounter


            info = self.solve()

            if self.condition(SO):
                # problem = self.getNumericsProblemPtr()
                # print(problem, type(problem))
                    
                problem = self.frictionContactProblemPtr()
                #print(problem, type(problem))
                solver_maxiter=SO.iparam[0]
                n_format_string=len(str(solver_maxiter))
                format_string = "{0}-i{1:0"+str(n_format_string)+"d}-{2}-{3}.hdf5"
                filename = format_string.format(self._params._fileName,
                                                              SO.iparam[7],
                                                              problem.numberOfContacts,
                                                              self._counter)
                self._counter += 1
                N.frictionContact_fclib_write(problem,
                                              self._params._title,
                                              self._params._description,
                                              self._params._mathInfo,
                                              filename,
                                              -1)
                guess = F.fclib_solution()
                guess.u = w_backup
                guess.r = z_backup
                F.fclib_write_guesses([guess], filename)
                
                solution = F.fclib_solution()
                solution.u = self.w()
                solution.z = self.z()
                F.fclib_write_solution(solution, filename)

                with h5py.File(filename, 'r+') as fclib_file:
                    attrs = fclib_file['fclib_local']['info'].attrs
                    attrs.create('numberOfInvolvedDS',
                                 self._model.nonSmoothDynamicalSystem().topology().numberOfInvolvedDS(1))

                
            self.postCompute()

        return info