int main(void) { VariationalInequality vi; variationalInequality_clear(&vi); vi.size=10; //vi.Callback = (CallbackVI *)malloc(sizeof(CallbackVI)); vi.env = &vi; vi.F = &Ftest; vi.ProjectionOnX = &PXtest ; /* Call the callback */ double x[10], F[10], PX[10]; int i, n=10; for (i =0; i< n ; i++) { x[i] = i-5; } vi.F(&vi,n,x,F); vi.ProjectionOnX(&vi,x,PX); for (i =0; i< n ; i++) { printf("x[%i]=%f\t",i,x[i]); printf("F[%i]=%f\t",i,F[i]); printf("PX[%i]=%f\n",i,PX[i]); } }
int main(void) { VariationalInequality vi; variationalInequality_clear(&vi); vi.size=1; //vi.Callback = (CallbackVI *)malloc(sizeof(CallbackVI)); vi.env = &vi; vi.F = &Ftest; vi.ProjectionOnX = &PXtest ; /* Call the callback */ double x[1], F[1], PX[1]; int i, n=1; for (i =0; i< n ; i++) { x[i] = i-5; } vi.F(&vi,n,x,F); vi.ProjectionOnX(&vi,x,PX); for (i =0; i< n ; i++) { printf("x[%i]=%f\t",i,x[i]); printf("F[%i]=%f\t",i,F[i]); printf("PX[%i]=%f\n",i,PX[i]); } NumericsOptions global_options; setDefaultNumericsOptions(&global_options); global_options.verboseMode = 1; // turn verbose mode to off by default SolverOptions * options = (SolverOptions *) malloc(sizeof(SolverOptions)); int info = variationalInequality_setDefaultSolverOptions(options, SICONOS_VI_HP); options->dparam[0]=1e-10; options->iparam[0]=50000000; info = variationalInequality_driver(&vi, x, F, options, &global_options); for (i =0; i< n ; i++) { printf("x[%i]=%f\t",i,x[i]); printf("w[%i]=F[%i]=%f\n",i,i,F[i]); } deleteSolverOptions(options); free(options); return info; }
int main(void) { VariationalInequality vi; variationalInequality_clear(&vi); //vi.env = &vi; vi.F = &Ftest; vi.ProjectionOnX = &PXtest; vi.normVI = 0.0; vi.istheNormVIset = 0; vi.set = NULL; vi.nabla_F = NULL; NumericsOptions global_options; setDefaultNumericsOptions(&global_options); global_options.verboseMode = 1; // turn verbose mode to off by default SolverOptions * options = (SolverOptions *) malloc(sizeof(SolverOptions)); int info = variationalInequality_setDefaultSolverOptions(options, SICONOS_VI_FPP); options->dparam[0]=1e-8; FILE * finput = fopen("./data/Example1_Fc3D_SBM.dat", "r"); FrictionContactProblem* problem = (FrictionContactProblem *)malloc(sizeof(FrictionContactProblem)); info = frictionContact_newFromFile(problem, finput); // frictionContact_display(problem); Problems *pb= (Problems *)malloc(sizeof(Problems)); vi.env = pb; pb->vi = &vi; pb->fc3d = problem; frictionContact_display(pb->fc3d); int n = problem->numberOfContacts * problem->dimension; vi.size=n; double *x = (double*)calloc(n, sizeof(double)); double *w = (double*)calloc(n, sizeof(double)); PXtest(&vi, x,w); info = variationalInequality_driver(&vi, x, w, options, &global_options); int i =0; for (i =0; i< n ; i++) { printf("x[%i]=%f\t",i,x[i]); printf("w[%i]=F[%i]=%f\n",i,i,w[i]); } deleteSolverOptions(options); free(options); free(problem); free(x); free(w); return info; }