How to manually define the MMG5_pSol when is a tensor

I am trying to use the library, and I want to define manually the MMG5_pSol when is a tensor (MMG5_Tensor), but I don’t understand rightly how to do it. what I am doing right now is for vectors and is not correctly working for the tensors, I do the following:

double *ma;
ma = &mmgSol->m[node_id];`

ma[0] = coeff0;
ma[1] = 0.0;
ma[2] = coeff0;
ma[3] = 0.0;
ma[4] = 0.0;
ma[5] = coeff0;

Ok, I solved the problem, they are just doubles, so what I need to do is calculated the initial index.

const int initial_index = 6 * (node_id - 1);

mmgSol->m[initial_index + 0] = coeff0;
mmgSol->m[initial_index + 1] = 0.0;
mmgSol->m[initial_index + 2] = coeff0;
mmgSol->m[initial_index + 3] = 0.0;
mmgSol->m[initial_index + 4] = 0.0;
mmgSol->m[initial_index + 5] = coeff0;

Hello,

You are right except that initial_index = 6 * node_id. (This is one of the features that have change between Mmg3d v4 and the Mmg platform (v5) ).

To avoid troubles using our library, rather than access directly to the Mmg structures, you should use the API functions (because we can choose to modify the Mmg structures, but in this case, we will try, if possible, to keep the API functions unchanged).

In your case, you must use the following API function:

if ( MMG3D_Set_tensorSol(mmgSol, coeff0., 0., coeff0,0., 0., coeff0,i) != 1 ) exit(EXIT_FAILURE);

You can find an example here:
http://www.mmgtools.org/mmg-remesher-try-mmg/mmg-remesher-tutorials/anisotropic-metric-prescription

Best Regards,

Algiane