Exemple #1
0
FrictionContactProblem* from_fclib_local(const struct fclib_local* fclib_problem)
{
  FrictionContactProblem* problem;

  problem = malloc(sizeof(FrictionContactProblem));

  problem->dimension = fclib_problem->spacedim;
  problem->mu = fclib_problem->mu;
  problem->q = fclib_problem->q;

  problem->numberOfContacts = fclib_problem->W->m / fclib_problem->spacedim; /* cf fclib spec */

  problem->M = newNumericsMatrix();

  problem->M->storageType = 1; /* sparse */
  problem->M->size0 = fclib_problem->W->m;
  problem->M->size1 = fclib_problem->W->n;

  problem->M->matrix0 = NULL;
  problem->M->matrix1 = newSBM();

  problem->M->matrix1->block = NULL;
  problem->M->matrix1->index1_data = NULL;
  problem->M->matrix1->index2_data = NULL;

  sparseToSBM(problem->dimension, (CSparseMatrix*)fclib_problem->W, problem->M->matrix1);

  return problem;

}
Exemple #2
0
FrictionContactProblem* from_fclib_local(const struct fclib_local* fclib_problem)
{
  FrictionContactProblem* problem;

  problem = malloc(sizeof(FrictionContactProblem));

  problem->dimension = fclib_problem->spacedim;
  problem->mu = fclib_problem->mu;
  problem->q = fclib_problem->q;

  problem->numberOfContacts = fclib_problem->W->m / fclib_problem->spacedim; /* cf fclib spec */

  problem->M = newNumericsMatrix();

  problem->M->storageType = 1; /* sparse */
  problem->M->size0 = fclib_problem->W->m;
  problem->M->size1 = fclib_problem->W->n;

  problem->M->matrix0 = NULL;
  problem->M->matrix1 = newSBM();

  problem->M->matrix1->block = NULL;
  problem->M->matrix1->index1_data = NULL;
  problem->M->matrix1->index2_data = NULL;

  CSparseMatrix W;

  W.nzmax = (csi) fclib_problem->W->nzmax;
  W.m = (csi) fclib_problem->W->m;
  W.n = (csi) fclib_problem->W->n;

  if (fclib_problem->W->nz == -1)
  {
    /* compressed colums */
    W.p = (csi*) malloc(sizeof(csi)*(W.n+1));
    int_to_csi(fclib_problem->W->p, W.p, (unsigned) (W.n+1));
  }
  else if (fclib_problem->W->nz == -2)
  {
    /* compressed rows */
    W.p = (csi*) malloc(sizeof(csi)*(W.m+1));
    int_to_csi(fclib_problem->W->p, W.p, (unsigned) (W.m+1));
  }
  else
  {
    /* triplet */
    W.p = (csi*) malloc(sizeof(csi)*W.nzmax);
    int_to_csi(fclib_problem->W->p, W.p, (unsigned) W.nzmax);
  }

  W.i = (csi*) malloc(sizeof(csi)*W.nzmax);
  int_to_csi(fclib_problem->W->i, W.i, (unsigned) W.nzmax);

  W.x = fclib_problem->W->x;

  W.nz = fclib_problem->W->nz;

  sparseToSBM(problem->dimension, &W, problem->M->matrix1);

  free(W.p);
  free(W.i);

  return problem;

}