def test_gfc3d(): data_files = ('LMGC_GFC3D_CubeH8.hdf5', 'LMGC_GlobalFrictionContactProblem00046.hdf5') mark_as_failed = False for d in data_files: full_path = data_dir + d if os.path.isfile(full_path): fcp = sn.globalFrictionContact_fclib_read(full_path) for s in solvers: res = solve_global(fcp, s) if res: print('Solver {:} on problem {:} failed with info = {:}'. format(sn.solver_options_id_to_name(s), d, res)) mark_as_failed = True else: print('Solver {:} on problem {:} is ok'.format( sn.solver_options_id_to_name(s), d)) fcp_reduced = condensed_from_global(fcp) for s in solvers_reduced1: res = solve_reduced(fcp_reduced, s) if res: print( 'Solver {:} on problem {:} in reduced form failed with info = {:}' .format(sn.solver_options_id_to_name(s), d, res)) mark_as_failed = True else: print('Solver {:} on problem {:} is ok'.format( sn.solver_options_id_to_name(s), d)) assert mark_as_failed is False
def test_gfc3d(): data_files = ('CubeH8.hdf5', 'LMGC_GlobalFrictionContactProblem00046.hdf5') mark_as_failed = False for d in data_files: full_path = data_dir + d if os.path.isfile(full_path): fcp = sn.globalFrictionContact_fclib_read(full_path) for s in solvers: res = solve_global(fcp, s) if res: print('Solver {:} on problem {:} failed with info = {:}'.format(sn.solver_options_id_to_name(s), d, res)) mark_as_failed = True else: print('Solver {:} on problem {:} is ok'.format(sn.solver_options_id_to_name(s), d)) fcp_reduced = condensed_from_global(fcp) for s in solvers_reduced1: res = solve_reduced(fcp_reduced, s) if res: print('Solver {:} on problem {:} in reduced form failed with info = {:}'.format(sn.solver_options_id_to_name(s), d, res)) mark_as_failed = True else: print('Solver {:} on problem {:} is ok'.format(sn.solver_options_id_to_name(s), d)) assert mark_as_failed is False
def test_convert(): mat = [] fcp = sn.GlobalFrictionContactProblem() sn.globalFrictionContact_newFromFile( fcp, data_dir + 'problem-checkTwoRods1.dat') mat.append(fcp.M) mat.append(fcp.H) hacklist = [fcp] try: # cheap test ... data_fclib = ('CubeH8.hdf5', 'LMGC_GlobalFrictionContactProblem00046.hdf5') for d in data_fclib: fcp = sn.globalFrictionContact_fclib_read(data_dir + d) hacklist.append(fcp) # Ho LMGC Mdense = fcp.M.todense() Mdense[np.nonzero(Mdense <= 100 * dbl_eps)] = 0. MM = scipy.sparse.coo_matrix(Mdense) Hdense = fcp.H.todense() Hdense[np.nonzero(Hdense <= 100 * dbl_eps)] = 0. HH = scipy.sparse.coo_matrix(Hdense) mat.append(MM) mat.append(HH) except: pass for m in mat: print("testing") if not scipy.sparse.issparse(m) and not isinstance(m, np.ndarray): spm = SBM_tests(m) else: spm = scipy.sparse.csc_matrix(m) mdense = spm.todense() dense_tests(mdense) sparse_tests(spm)
def test_convert(): mat = [] fcp = sn.GlobalFrictionContactProblem() sn.globalFrictionContact_newFromFile(fcp, data_dir + 'GFC3D_TwoRods1.dat') mat.append(fcp.M) mat.append(fcp.H) hacklist = [fcp] try: # cheap test ... data_fclib = ('LMGC_GFC3D_CubeH8.hdf5', 'LMGC_GlobalFrictionContactProblem00046.hdf5') for d in data_fclib: fcp = sn.globalFrictionContact_fclib_read(data_dir + d) hacklist.append(fcp) # Ho LMGC Mdense = fcp.M.todense() Mdense[np.nonzero(Mdense <= 100*dbl_eps)] = 0. MM = scipy.sparse.coo_matrix(Mdense) Hdense = fcp.H.todense() Hdense[np.nonzero(Hdense <= 100*dbl_eps)] = 0. HH = scipy.sparse.coo_matrix(Hdense) mat.append(MM) mat.append(HH) except: pass for m in mat: print("testing") if not scipy.sparse.issparse(m) and not isinstance(m, np.ndarray): spm = SBM_tests(m) else: spm = scipy.sparse.csc_matrix(m) mdense = spm.todense() dense_tests(mdense) sparse_tests(spm)