int gfc3d_LmgcDriver(double *reaction, double *velocity, double *globalVelocity, double *q, double *b, double *mu, double *Mdata, unsigned int nzM, unsigned int *rowM, unsigned int *colM, double* Hdata, unsigned int nzH, unsigned int *rowH, unsigned int *colH, unsigned int n, unsigned int nc, int solver_id, int isize, int *iparam, int dsize, double *dparam, int verbose, int outputFile, int freq_output) { /* NumericsMatrix M, H; */ NumericsMatrix * M =newNumericsMatrix(); M->storageType = 2; /* sparse */ M->size0 = n; M->size1 = n; NumericsMatrix * H =newNumericsMatrix(); H->storageType = 2; H->size0 = M->size0; H->size1 = 3 * nc; NumericsSparseMatrix * SM =newNumericsSparseMatrix(); M->matrix2 = SM; SM->triplet = (CSparseMatrix * )malloc(sizeof(CSparseMatrix)); CSparseMatrix * _M = SM->triplet; SM->origin = NS_TRIPLET; csi * _colM = alloc_memory_csi(nzM, colM); csi * _rowM = alloc_memory_csi(nzM, rowM); _M->nzmax = nzM; _M->nz = nzM; _M->m = M->size0; _M->n = M->size1; _M->p = (csi *) _colM; _M->i = (csi *) _rowM; double * _Mdata = alloc_memory_double(nzM, Mdata); _M->x = _Mdata; DEBUG_PRINTF("_M->n=%li\t",_M->n); DEBUG_PRINTF("_M->m=%li\n",_M->m); NumericsSparseMatrix * SH =newNumericsSparseMatrix(); H->matrix2 = SH; SH->triplet = (CSparseMatrix * )malloc(sizeof(CSparseMatrix)); CSparseMatrix * _H = SH->triplet; SH->origin = NS_TRIPLET; csi * _colH = alloc_memory_csi(nzH, colH); csi * _rowH = alloc_memory_csi(nzH, rowH); _H->nzmax = nzH; _H->nz = nzH; _H->m = H->size0; _H->n = H->size1; _H->p = _colH; _H->i = _rowH; double * _Hdata = alloc_memory_double(nzH, Hdata); _H->x = _Hdata; for (int i=0; i< _M->nz; ++i) { _M->p[i] --; _M->i[i] --; /* DEBUG_PRINTF("%d -> %d,%d\n", i, _M->p[i], _M->i[i]); */ } for (int i=0; i< _H->nz; ++i) { _H->p[i] --; _H->i[i] --; /* DEBUG_PRINTF("%d -> %d,%d\n", i, _H->p[i], _H->i[i]); */ } GlobalFrictionContactProblem * problem =(GlobalFrictionContactProblem*)malloc(sizeof(GlobalFrictionContactProblem)); problem->dimension = 3; problem->numberOfContacts = nc; problem->env = NULL; problem->workspace = NULL; problem->M = M; problem->H = H; problem->q = q; problem->b = b; problem->mu = mu; SolverOptions numerics_solver_options; gfc3d_setDefaultSolverOptions(&numerics_solver_options, solver_id); int iSize_min = isize < numerics_solver_options.iSize ? isize : numerics_solver_options.iSize; for (int i = 0; i < iSize_min; ++i) numerics_solver_options.iparam[i] = iparam[i]; int dSize_min = dsize < numerics_solver_options.dSize ? dsize : numerics_solver_options.dSize; for (int i=0; i < dSize_min; ++i) numerics_solver_options.dparam[i] = dparam[i]; /* solver_options_print(&numerics_solver_options); */ /* FILE * file = fopen("toto.dat", "w"); */ /* globalFrictionContact_printInFile(problem, file); */ /* fclose(file); */ int rinfo = gfc3d_driver(problem, reaction, velocity, globalVelocity, &numerics_solver_options); /* FILE * file1 = fopen("tutu.dat", "w"); */ /* globalFrictionContact_printInFile(problem, file1); */ /* fclose(file1); */ if(outputFile == 1) { /* dump in C format */ } else if (outputFile == 2) { /* dump in Numerics .dat format */ } else if (outputFile == 3) { #ifdef WITH_FCLIB fccounter++; if (fccounter % freq_output == 0) { char fname[256]; snprintf(fname, sizeof(fname), "LMGC_GFC3D-i%.5d-%i-%.5d.hdf5", numerics_solver_options.iparam[7], nc, fccounter); printf("Dump LMGC_GFC3D-i%.5d-%i-%.5d.hdf5.\n", numerics_solver_options.iparam[7], nc, fccounter); /* printf("ndof = %i.\n", ndof); */ FILE * foutput = fopen(fname, "w"); int n = 100; char * title = (char *)malloc(n * sizeof(char *)); strncpy(title, "LMGC dump in hdf5", n); char * description = (char *)malloc(n * sizeof(char *)); snprintf(description, n, "Rewriting in hdf5 through siconos of %s in FCLIB format", fname); char * mathInfo = (char *)malloc(n * sizeof(char *)); strncpy(mathInfo, "unknown", n); globalFrictionContact_fclib_write(problem, title, description, mathInfo, fname); fclose(foutput); } #else printf("Fclib is not available ...\n"); #endif } freeNumericsMatrix(M); freeNumericsMatrix(H); free(M); free(H); free(problem); /* free(_colM); */ /* free(_colH); */ /* free(_rowM); */ /* free(_rowH); */ return rinfo; }
int gfc3d_LmgcDriver(double *reaction, double *velocity, double *globalVelocity, double *q, double *b, double *mu, double *Mdata, unsigned int nzM, unsigned int *rowM, unsigned int *colM, double* Hdata, unsigned int nzH, unsigned int *rowH, unsigned int *colH, unsigned int n, unsigned int nc, int solver_id, int isize, int *iparam, int dsize, double *dparam, int verbose_in, int outputFile, int freq_output) { verbose = verbose_in; /* NumericsMatrix M, H; */ NumericsMatrix * M =NM_new(); M->storageType = 2; /* sparse */ M->size0 = n; M->size1 = n; NumericsMatrix * H =NM_new(); H->storageType = 2; H->size0 = M->size0; H->size1 = 3 * nc; NumericsSparseMatrix * SM =NSM_new(); M->matrix2 = SM; SM->triplet = (CSparseMatrix * )malloc(sizeof(CSparseMatrix)); CSparseMatrix * _M = SM->triplet; SM->origin = NSM_TRIPLET; CS_INT * _colM = alloc_memory_csi(nzM, colM); CS_INT * _rowM = alloc_memory_csi(nzM, rowM); _M->nzmax = nzM; _M->nz = nzM; _M->m = M->size0; _M->n = M->size1; _M->p = (CS_INT *) _colM; _M->i = (CS_INT *) _rowM; double * _Mdata = alloc_memory_double(nzM, Mdata); _M->x = _Mdata; DEBUG_PRINTF("_M->n=%lli\t",_M->n); DEBUG_PRINTF("_M->m=%lli\n",_M->m); NumericsSparseMatrix * SH =NSM_new(); H->matrix2 = SH; SH->triplet = (CSparseMatrix * )malloc(sizeof(CSparseMatrix)); CSparseMatrix * _H = SH->triplet; SH->origin = NSM_TRIPLET; CS_INT * _colH = alloc_memory_csi(nzH, colH); CS_INT * _rowH = alloc_memory_csi(nzH, rowH); _H->nzmax = nzH; _H->nz = nzH; _H->m = H->size0; _H->n = H->size1; _H->p = _colH; _H->i = _rowH; double * _Hdata = alloc_memory_double(nzH, Hdata); _H->x = _Hdata; for (int i=0; i< _M->nz; ++i) { _M->p[i] --; _M->i[i] --; /* DEBUG_PRINTF("%d -> %d,%d\n", i, _M->p[i], _M->i[i]); */ } for (int i=0; i< _H->nz; ++i) { _H->p[i] --; _H->i[i] --; /* DEBUG_PRINTF("%d -> %d,%d\n", i, _H->p[i], _H->i[i]); */ } #ifdef USE_NM_DENSE assert(M); assert(H); NumericsMatrix *MMtmp = NM_new(); NumericsMatrix *HHtmp = NM_new(); NM_copy(M,MMtmp); NM_copy(H,HHtmp); NM_clearSparse(M); NM_clearSparse(H); M = NM_create(NM_DENSE, H->size0, H->size0); H = NM_create(NM_DENSE, H->size0, H->size1); NM_to_dense(MMtmp,M); NM_to_dense(HHtmp,H); /* NM_display(M); */ /* NM_display(H); */ #endif GlobalFrictionContactProblem * problem =(GlobalFrictionContactProblem*)malloc(sizeof(GlobalFrictionContactProblem)); problem->dimension = 3; problem->numberOfContacts = nc; problem->env = NULL; problem->M = M; problem->H = H; problem->q = q; problem->b = b; problem->mu = mu; SolverOptions numerics_solver_options; int infi = 0; infi = gfc3d_setDefaultSolverOptions(&numerics_solver_options, solver_id); assert(!infi); int iSize_min = isize < numerics_solver_options.iSize ? isize : numerics_solver_options.iSize; DEBUG_PRINTF("iSize_min = %i", iSize_min); for (int i = 0; i < iSize_min; ++i) if (abs(iparam[i])>0) numerics_solver_options.iparam[i] = iparam[i]; int dSize_min = dsize < numerics_solver_options.dSize ? dsize : numerics_solver_options.dSize; for (int i=0; i < dSize_min; ++i) if (fabs(dparam[i]) > 0) numerics_solver_options.dparam[i] = dparam[i]; /* solver_options_print(&numerics_solver_options); */ /* FILE * file = fopen("toto.dat", "w"); */ /* globalFrictionContact_printInFile(problem, file); */ /* fclose(file); */ int rinfo = gfc3d_driver(problem, reaction, velocity, globalVelocity, &numerics_solver_options); iparam[SICONOS_IPARAM_ITER_DONE] = numerics_solver_options.iparam[SICONOS_IPARAM_ITER_DONE]; dparam[SICONOS_DPARAM_TOL] = numerics_solver_options.dparam[SICONOS_DPARAM_TOL]; /* FILE * file1 = fopen("tutu.dat", "w"); */ /* globalFrictionContact_printInFile(problem, file1); */ /* fclose(file1); */ if(outputFile == 1) { /* dump in C format */ } else if (outputFile == 2) { /* dump in Numerics .dat format */ } else if (outputFile == 3) { #ifdef WITH_FCLIB gfccounter++; struct stat st = {}; if (stat("./fclib-hdf5/", &st) == -1) { mkdir("./fclib-hdf5/", 0700); } printf("################################## gfcccounter = %i\n", gfccounter); if (gfccounter % freq_output == 0) { char fname[256]; snprintf(fname, sizeof(fname), "./fclib-hdf5/LMGC_GFC3D-i%.5d-%i-%.5d.hdf5", numerics_solver_options.iparam[SICONOS_IPARAM_ITER_DONE], nc, gfccounter); printf("Dump ./fclib-hdf5/LMGC_GFC3D-i%.5d-%i-%.5d.hdf5.\n", numerics_solver_options.iparam[SICONOS_IPARAM_ITER_DONE], nc, gfccounter); /* printf("ndof = %i.\n", ndof); */ FILE * foutput = fopen(fname, "w"); int n = 100; char * title = (char *)malloc(n * sizeof(char *)); strncpy(title, "LMGC dump in hdf5", n); char * description = (char *)malloc(n * sizeof(char *)); snprintf(description, n, "Rewriting in hdf5 through siconos of %s in FCLIB format", fname); char * mathInfo = (char *)malloc(n * sizeof(char *)); strncpy(mathInfo, "unknown", n); globalFrictionContact_fclib_write(problem, title, description, mathInfo, fname); fclose(foutput); } #else printf("Fclib is not available ...\n"); #endif } NM_free(M); NM_free(H); free(M); free(H); free(problem); /* free(_colM); */ /* free(_colH); */ /* free(_rowM); */ /* free(_rowH); */ return rinfo; }
int main(int argc, char* argv[]) { // Problem Definition int info = -1; int NC = 1;//Number of contacts int Ndof = 9;//Number of DOF // Problem Definition double M11[9] = {1, 0, 0, 0, 1, 0, 0, 0, 1}; // Warning Fortran Storage double M22[9] = {1, 0, 0, 0, 1, 0, 0, 0, 1}; // Warning Fortran Storage double M33[9] = {1, 0, 0, 0, 1, 0, 0, 0, 1}; // Warning Fortran Storage /* double M[81] = {1, 0, 0, 0, 0, 0, 0, 0, 0, */ /* 0, 1, 0, 0, 0, 0, 0, 0, 0, */ /* 0, 0, 1, 0, 0, 0, 0, 0, 0, */ /* 0, 0, 0, 1, 0, 0, 0, 0, 0, */ /* 0, 0, 0, 0, 1, 0, 0, 0, 0, */ /* 0, 0, 0, 0, 0, 1, 0, 0, 0, */ /* 0, 0, 0, 0, 0, 0, 1, 0, 0, */ /* 0, 0, 0, 0, 0, 0, 0, 1, 0, */ /* 0, 0, 0, 0, 0, 0, 0, 0, 1}; */ double H00[9] = {1, 0, 0, 0, 1, 0, 0, 0, 1}; double H20[9] = { -1, 0, 0, 0, -1, 0, 0, 0, -1}; /* double H[27] = {1, 0, 0, 0, 0, 0, -1, 0, 0, */ /* 0, 1, 0, 0, 0, 0, 0, -1, 0, */ /* 0, 0, 1, 0, 0, 0, 0, 0, -1}; */ double q[9] = { -3, -3, -3, -1, 1, 3, -1, 1, 3}; double b[3] = {0, 0, 0}; double mu[1] = {0.1}; /* DSCAL(9,-1.0,q,1); */ /* int NC = 3;//Number of contacts */ /* int Ndof = 9;//Number of DOF */ /* double M[81] = {1, 0, 0, 0, 0, 0, 0, 0, 0, */ /* 0, 1, 0, 0, 0, 0, 0, 0, 0, */ /* 0, 0, 1, 0, 0, 0, 0, 0, 0, */ /* 0, 0, 0, 1, 0, 0, 0, 0, 0, */ /* 0, 0, 0, 0, 1, 0, 0, 0, 0, */ /* 0, 0, 0, 0, 0, 1, 0, 0, 0, */ /* 0, 0, 0, 0, 0, 0, 1, 0, 0, */ /* 0, 0, 0, 0, 0, 0, 0, 1, 0, */ /* 0, 0, 0, 0, 0, 0, 0, 0, 1}; */ /* double H[81] = {1, 0, 0, 0, 0, 0, 0, 0, 0, */ /* 0, 1, 0, 0, 0, 0, 0, 0, 0, */ /* 0, 0, 1, 0, 0, 0, 0, 0, 0, */ /* 0, 0, 0, 1, 0, 0, 0, 0, 0, */ /* 0, 0, 0, 0, 1, 0, 0, 0, 0, */ /* 0, 0, 0, 0, 0, 1, 0, 0, 0, */ /* 0, 0, 0, 0, 0, 0, 1, 0, 0, */ /* 0, 0, 0, 0, 0, 0, 0, 1, 0, */ /* 0, 0, 0, 0, 0, 0, 0, 0, 1}; */ /* double q[9] = {-1, 1, 3, -1, 1, 3, -1, 1, 3}; */ /* double b[9] = {0, 0, 0,0, 0, 0,0, 0, 0 }; */ /* double mu[3] = {0.1,0.1,0.1}; */ int k; int m = 3 * NC; int n = Ndof; GlobalFrictionContactProblem numericsProblem; globalFrictionContact_null(&numericsProblem); numericsProblem.numberOfContacts = NC; numericsProblem.dimension = 3; numericsProblem.mu = mu; numericsProblem.q = q; numericsProblem.b = b; numericsProblem.M = newNumericsMatrix(); NumericsMatrix *MM = numericsProblem.M; MM->storageType = NM_SPARSE_BLOCK; MM->size0 = Ndof; MM->size1 = Ndof; MM->matrix1 = newSBM(); SparseBlockStructuredMatrix *MBlockMatrix = MM->matrix1; MBlockMatrix->nbblocks = 3; double * block[3] = {M11, M22, M33}; MBlockMatrix->block = block; MBlockMatrix->blocknumber0 = 3; MBlockMatrix->blocknumber1 = 3; unsigned int blocksize[3] = {3, 6, 9} ; MBlockMatrix->blocksize0 = blocksize; MBlockMatrix->blocksize1 = blocksize; MBlockMatrix->filled1 = 4; MBlockMatrix->filled2 = 3; size_t index1_data[4] = {0, 1, 2, 3} ; size_t index2_data[3] = {0, 1, 2} ; MBlockMatrix->index1_data = index1_data; MBlockMatrix->index2_data = index2_data; numericsProblem.H = newNumericsMatrix(); NumericsMatrix *HH = numericsProblem.H; HH->storageType = 1; HH->size0 = Ndof; HH->size1 = 3 * NC; HH->matrix1 = (SparseBlockStructuredMatrix*)malloc(sizeof(SparseBlockStructuredMatrix)); SparseBlockStructuredMatrix *HBlockMatrix = HH->matrix1; HBlockMatrix->nbblocks = 2; double * hblock[3] = {H00, H20}; HBlockMatrix->block = hblock; HBlockMatrix->blocknumber0 = 3; HBlockMatrix->blocknumber1 = 1; unsigned int blocksize0[3] = {3, 6, 9} ; unsigned int blocksize1[1] = {3} ; HBlockMatrix->blocksize0 = blocksize0; HBlockMatrix->blocksize1 = blocksize1; HBlockMatrix->filled1 = 4; HBlockMatrix->filled2 = 2; size_t hindex1_data[4] = {0, 1, 1, 2} ; size_t hindex2_data[3] = {0, 0} ; HBlockMatrix->index1_data = hindex1_data; HBlockMatrix->index2_data = hindex2_data; FILE * foutput = fopen("Example_GlobalFrictionContact_SBM.dat", "w"); globalFrictionContact_printInFile(&numericsProblem, foutput); fclose(foutput); // Unknown Declaration double *reaction = (double*)calloc(m, sizeof(double)); double *velocity = (double*)calloc(m, sizeof(double)); double *globalVelocity = (double*)calloc(n, sizeof(double)); // Solver Options SolverOptions * numerics_solver_options = (SolverOptions *)malloc(sizeof(SolverOptions)); // char solvername[10]= "NSGS"; /*\warning Must be adpated for future globalFrictionContact3D_setDefaultSolverOptions*/ gfc3d_setDefaultSolverOptions(numerics_solver_options, SICONOS_GLOBAL_FRICTION_3D_NSGS); numerics_solver_options->dparam[0] = 1e-14; numerics_solver_options->iparam[0] = 100000; //Driver call info = gfc3d_driver(&numericsProblem, reaction , velocity, globalVelocity, numerics_solver_options); solver_options_delete(numerics_solver_options); free(numerics_solver_options); // Solver output printf("\n"); for (k = 0 ; k < m; k++) printf("velocity[%i] = %12.8e \t \t reaction[%i] = %12.8e \n ", k, velocity[k], k , reaction[k]); for (k = 0 ; k < n; k++) printf("globalVelocity[%i] = %12.8e \t \n ", k, globalVelocity[k]); printf("\n"); free(reaction); free(velocity); free(globalVelocity); // freeSBM(MM->matrix1); // freeSBM(HH->matrix1); free(MM->matrix1); MM->matrix1 = NULL; free(HH->matrix1); HH->matrix1 = NULL; freeNumericsMatrix(MM); freeNumericsMatrix(HH); free(MM); free(HH); gfc3d_free_workspace(&numericsProblem); /* while (1) sleep(60); */ return info; }
int globalFrictionContact_test_function(FILE * f, SolverOptions * options) { int k, info = -1 ; GlobalFrictionContactProblem* problem = (GlobalFrictionContactProblem *)malloc(sizeof(GlobalFrictionContactProblem)); info = globalFrictionContact_newFromFile(problem, f); globalFrictionContact_display(problem); FILE * foutput = fopen("checkinput.dat", "w"); info = globalFrictionContact_printInFile(problem, foutput); NumericsOptions global_options; setDefaultNumericsOptions(&global_options); global_options.verboseMode = 1; // turn verbose mode to off by default int NC = problem->numberOfContacts; int dim = problem->dimension; int n = problem->M->size1; double *reaction = (double*)malloc(dim * NC * sizeof(double)); double *velocity = (double*)malloc(dim * NC * sizeof(double)); double *globalvelocity = (double*)malloc(n * sizeof(double)); for (k = 0 ; k < dim * NC; k++) { velocity[k] = 0.0; reaction[k] = 0.0; } for (k = 0 ; k < n; k++) { globalvelocity[k] = 0.0; } if (dim == 2) { info = 1; } else if (dim == 3) { info = gfc3d_driver(problem, reaction , velocity, globalvelocity, options, &global_options); } printf("\n"); for (k = 0 ; k < dim * NC; k++) { printf("Velocity[%i] = %12.8e \t \t Reaction[%i] = %12.8e\n", k, velocity[k], k , reaction[k]); } for (k = 0 ; k < n; k++) { printf("GlocalVelocity[%i] = %12.8e\n", k, globalvelocity[k]); } printf("\n"); if (!info) { printf("test succeeded\n"); } else { printf("test unsuccessful\n"); } free(reaction); free(velocity); free(globalvelocity); fclose(foutput); freeGlobalFrictionContactProblem(problem); return info; }
int main(int argc, char* argv[]) { // Problem Definition int info = -1; int NC = 1;//Number of contacts int m = 3; int n = 9; double M[81] = {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; double H[27] = {1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1 }; double q[9] = { -3, -3, -3, -1, 1, 3, -1, 1, 3}; double b[3] = {0, 0, 0}; double mu[1] = {0.1}; /* int NC = 3;//Number of contacts */ /* int Ndof = 9;//Number of DOF */ /* double M[81] = {1, 0, 0, 0, 0, 0, 0, 0, 0, */ /* 0, 1, 0, 0, 0, 0, 0, 0, 0, */ /* 0, 0, 1, 0, 0, 0, 0, 0, 0, */ /* 0, 0, 0, 1, 0, 0, 0, 0, 0, */ /* 0, 0, 0, 0, 1, 0, 0, 0, 0, */ /* 0, 0, 0, 0, 0, 1, 0, 0, 0, */ /* 0, 0, 0, 0, 0, 0, 1, 0, 0, */ /* 0, 0, 0, 0, 0, 0, 0, 1, 0, */ /* 0, 0, 0, 0, 0, 0, 0, 0, 1}; */ /* double H[81] = {1, 0, 0, 0, 0, 0, 0, 0, 0, */ /* 0, 1, 0, 0, 0, 0, 0, 0, 0, */ /* 0, 0, 1, 0, 0, 0, 0, 0, 0, */ /* 0, 0, 0, 1, 0, 0, 0, 0, 0, */ /* 0, 0, 0, 0, 1, 0, 0, 0, 0, */ /* 0, 0, 0, 0, 0, 1, 0, 0, 0, */ /* 0, 0, 0, 0, 0, 0, 1, 0, 0, */ /* 0, 0, 0, 0, 0, 0, 0, 1, 0, */ /* 0, 0, 0, 0, 0, 0, 0, 0, 1}; */ /* double q[9] = {-1, 1, 3, -1, 1, 3, -1, 1, 3}; */ /* double b[9] = {0, 0, 0,0, 0, 0,0, 0, 0 }; */ /* double mu[3] = {0.1,0.1,0.1}; */ int i = 0, k = 0; GlobalFrictionContactProblem numericsProblem; globalFrictionContact_null(&numericsProblem); numericsProblem.numberOfContacts = NC; numericsProblem.dimension = 3; numericsProblem.mu = mu; numericsProblem.q = q; numericsProblem.b = b; numericsProblem.M = newNumericsMatrix(); NumericsMatrix *MM = numericsProblem.M ; MM->storageType = NM_DENSE; MM->matrix0 = M; MM->size0 = n; MM->size1 = n; numericsProblem.H = newNumericsMatrix(); NumericsMatrix *HH = numericsProblem.H; HH->storageType = NM_DENSE; HH->matrix0 = H; HH->size0 = n; HH->size1 = m; /* FILE * foutput = fopen("Example_GlobalFrictionContact.dat", "w"); */ /* globalFrictionContact_printInFile(&numericsProblem, foutput ); */ /* fclose(foutput); */ // Unknown Declaration double *reaction = (double*)calloc(m, sizeof(double)); double *velocity = (double*)calloc(m, sizeof(double)); double *globalVelocity = (double*)calloc(n, sizeof(double)); // Numerics and Solver Options NumericsOptions numerics_options; numerics_options.verboseMode = 1; // turn verbose mode to off by default SolverOptions * numerics_solver_options = (SolverOptions *)malloc(sizeof(SolverOptions)) ; //char solvername[10]= "NSGS"; /*\warning Must be adpated for future globalFrictionContact3D_setDefaultSolverOptions*/ gfc3d_setDefaultSolverOptions(numerics_solver_options, SICONOS_GLOBAL_FRICTION_3D_NSGS); numerics_solver_options->dparam[0] = 1e-14; numerics_solver_options->iparam[0] = 100000; //Driver call i = 0; info = gfc3d_driver(&numericsProblem, reaction , velocity, globalVelocity, numerics_solver_options, &numerics_options); deleteSolverOptions(numerics_solver_options); // Solver output printf("\n"); for (k = 0 ; k < m; k++) printf("velocity[%i] = %12.8e \t \t reaction[%i] = %12.8e \n ", k, velocity[k], k , reaction[k]); for (k = 0 ; k < n; k++) printf("globalVelocity[%i] = %12.8e \t \n ", k, globalVelocity[k]); printf("\n"); free(numerics_solver_options); free(reaction); free(velocity); free(globalVelocity); free(numericsProblem.M); free(numericsProblem.H); gfc3d_free_workspace(&numericsProblem); return info; }
int main(void) { char filename[51] = "./data/LMGC_GlobalFrictionContactProblem00046.hdf5"; printf("Test on %s\n", filename); SolverOptions * options = (SolverOptions *)malloc(sizeof(SolverOptions)); gfc3d_setDefaultSolverOptions(options, SICONOS_GLOBAL_FRICTION_3D_NSN_AC); int k, info = -1 ; GlobalFrictionContactProblem* problem = globalFrictionContact_fclib_read(filename); globalFrictionContact_display(problem); FILE * foutput = fopen("checkinput.dat", "w"); info = globalFrictionContact_printInFile(problem, foutput); NumericsOptions global_options; setDefaultNumericsOptions(&global_options); global_options.verboseMode = 1; // turn verbose mode to off by default int NC = problem->numberOfContacts; int dim = problem->dimension; int n = problem->M->size1; double *reaction = (double*)calloc(dim * NC, sizeof(double)); double *velocity = (double*)calloc(dim * NC, sizeof(double)); double *globalvelocity = (double*)calloc(n, sizeof(double)); if (dim == 2) { info = 1; } else if (dim == 3) { info = gfc3d_driver(problem, reaction , velocity, globalvelocity, options, &global_options); } printf("\n"); for (k = 0 ; k < dim * NC; k++) { printf("Velocity[%i] = %12.8e \t \t Reaction[%i] = %12.8e\n", k, velocity[k], k , reaction[k]); } for (k = 0 ; k < n; k++) { printf("GlocalVelocity[%i] = %12.8e\n", k, globalvelocity[k]); } printf("\n"); if (!info) { printf("test succeeded\n"); } else { printf("test unsuccessful\n"); } free(reaction); free(velocity); free(globalvelocity); fclose(foutput); freeGlobalFrictionContactProblem(problem); deleteSolverOptions(options); free(options); printf("End of test on %s\n", filename); return info; }