3#include <mmg/mmg2d/libmmg2d.h>
17 double v[8] = {0, -M_PI/2, 2 * M_PI, -M_PI/2, 2 * M_PI, M_PI/2, 0, M_PI/2};
25 fprintf(stderr,
"error %i during meshing.\n",
ier);
39 int np, nt, nquad, na;
41 double* verts = malloc(2 * np *
sizeof(
double));
44 for (
int i = 0; i < np; i++) {
47 double y = verts[2 * i + 1];
50 double E = cos(y) * cos(y);
61 double factor = 100.0;
64 const double eps = 1.e-1;
85 fprintf(stderr,
"error %i during remeshing.\n",
ier);
98 verts = realloc(verts, 2 * np *
sizeof(
double));
99 int* tris = malloc(3 * nt *
sizeof(
int));
103 printf(
"\n\n -- Save the final mesh 'sphere-end.mesh' at Medit file format.\n");
105 FILE *fp = fopen(
"sphere-end.mesh",
"w+");
107 fprintf(fp,
"MeshVersionFormatted 2\n\n Dimension 3\n\n Vertices %d\n\n", np);
108 for (
int i = 0; i < np; i++) {
109 double x = verts[2 * i];
110 double y = verts[2 * i + 1];
113 double newx = cos(x) * cos(y);
114 double newy = sin(x) * cos(y);
115 double newz = sin(y);
116 fprintf(fp,
"%f %f %f 0\n", newx, newy, newz);
118 fprintf(fp,
"Triangles %d\n", nt);
120 for (
int i = 0; i < nt; i++)
121 fprintf(fp,
"%i %i %i 0\n", tris[3 * i], tris[3 * i +1], tris[3 * i + 2]);
123 fprintf(fp,
"End\n");
int MMG2D_Init_mesh(const int starter,...)
int MMG2D_Set_iparameter(MMG5_pMesh mesh, MMG5_pSol sol, int iparam, MMG5_int val)
int MMG2D_Set_meshSize(MMG5_pMesh mesh, MMG5_int np, MMG5_int nt, MMG5_int nquad, MMG5_int na)
int MMG2D_Set_tensorSol(MMG5_pSol met, double m11, double m12, double m22, MMG5_int pos)
int MMG2D_Get_vertices(MMG5_pMesh mesh, double *vertices, MMG5_int *refs, int *areCorners, int *areRequired)
int MMG2D_Set_solSize(MMG5_pMesh mesh, MMG5_pSol sol, int typEntity, MMG5_int np, int typSol)
int MMG2D_Get_meshSize(MMG5_pMesh mesh, MMG5_int *np, MMG5_int *nt, MMG5_int *nquad, MMG5_int *na)
int MMG2D_Set_vertices(MMG5_pMesh mesh, double *vertices, MMG5_int *refs)
int MMG2D_Set_dparameter(MMG5_pMesh mesh, MMG5_pSol sol, int dparam, double val)
int MMG2D_Free_all(const int starter,...)
int MMG2D_Get_triangles(MMG5_pMesh mesh, MMG5_int *tria, MMG5_int *refs, int *areRequired)
program main
Example for using mmglib (basic use)
int MMG2D_saveMesh(MMG5_pMesh mesh, const char *filename)
int MMG2D_saveMshMesh(MMG5_pMesh mesh, MMG5_pSol sol, const char *filename)
int MMG2D_saveSol(MMG5_pMesh mesh, MMG5_pSol sol, const char *filename)
int MMG2D_mmg2dlib(MMG5_pMesh mesh, MMG5_pSol met)
int MMG2D_mmg2dmesh(MMG5_pMesh mesh, MMG5_pSol met)
LIBMMG2D_EXPORT void MMG2D_Free_solutions(MMG5_pMesh mesh, MMG5_pSol sol)