4.4 Metric definition/initialization

To adapt the mesh according to a metric, you must define it in a MMG_Sol structure, like that:
  1. Define a pointer on a Sol structure:

    MMG_pSol sol;

  2. Allocate this pointer:

    sol = (MMG_pSol)calloc(1,sizeof(MMG_Sol));

  3. Give the points number:

    sol->np = nbpoint; (this number is equal to mesh->np)
    sol->npmax = nbpointmax; (this number is equal to mesh->npmax)

  4. Give the metric type, i.e. isotropic or anisotropic:

    sol->offset = 6 for an anisotropic metric
    sol->offset = 1 for an isotropic metric

  5. Allocate the tabular containing the metric field:

    sol->met = (double*)calloc(sol->npmax+1,sol->offset*sizeof(double));
    sol->metold = (double*)calloc(sol->npmax+1,sol->offset*sizeof(double));

  6. Initialize the met structure, that means, give on each point the metric values:

    for (k=1; k<=mesh->np; k++) {
    isol = (k-1) * sol->offset + 1;
    for (i=0; i<sol->offset; i++)
    sol->met[isol + i] = metrique[ pointindice_k + i ];
    }

back to the content


Dobrzynski 2012-03-23