Skip to content
Snippets Groups Projects
Generator.cpp 14.4 KiB
Newer Older
// $Id: Generator.cpp,v 1.83 2006-07-11 13:41:22 remacle Exp $
Christophe Geuzaine's avatar
Christophe Geuzaine committed
//
Christophe Geuzaine's avatar
Christophe Geuzaine committed
// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
Christophe Geuzaine's avatar
Christophe Geuzaine committed
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
// 
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
// Please report all bugs and problems to <gmsh@geuz.org>.
#include "BDS.h"
#include "Mesh.h"
#include "Create.h"
#include "Context.h"
#include "OpenFile.h"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#include "Views.h"
#include "PartitionMesh.h"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#include "OS.h"
#include "meshGEdge.h"
#include "GModel.h"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
extern Mesh *THEM;
extern GModel *GMODEL;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
static int nbOrder2 = 0;

void countOrder2(void *a, void *b)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
{
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  Vertex *v = *(Vertex**)a;
  if(v->Degree == 2) nbOrder2++;
}

void GetStatistics(double stat[50])
{
  for(int i = 0; i < 50; i++)
    stat[i] = 0.;

  if(!THEM)
    return;

  stat[0] = Tree_Nbr(THEM->Points);
  stat[1] = Tree_Nbr(THEM->Curves);
  stat[2] = Tree_Nbr(THEM->Surfaces);
  stat[3] = Tree_Nbr(THEM->Volumes);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  stat[45] = List_Nbr(THEM->PhysicalGroups);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  
  stat[4] = 0.;
  if(Tree_Nbr(THEM->Curves)) {
    List_T *curves = Tree2List(THEM->Curves);
    for(int i = 0; i < List_Nbr(curves); i++){
      Curve *c;
      List_Read(curves, i, &c);
      stat[4] += List_Nbr(c->Vertices);
    }
    List_Delete(curves);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

  stat[5] = stat[7] = stat[8] = 0.;
  if(Tree_Nbr(THEM->Surfaces)) {
    List_T *surfaces = Tree2List(THEM->Surfaces);
    for(int i = 0; i < List_Nbr(surfaces); i++){
      Surface *s;
      List_Read(surfaces, i, &s);
      stat[5] += Tree_Nbr(s->Vertices);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      stat[7] += Tree_Nbr(s->Simplexes) + Tree_Nbr(s->SimplexesBase);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      stat[8] += Tree_Nbr(s->Quadrangles);
    }
    List_Delete(surfaces);
  }

  stat[6] = stat[9] = stat[10] = stat[11] = stat[12] = 0.;
  if(Tree_Nbr(THEM->Volumes)) {
    List_T *volumes = Tree2List(THEM->Volumes);
    for(int i = 0; i < List_Nbr(volumes); i++){
      Volume *v;
      List_Read(volumes, i, &v);
      stat[6] += Tree_Nbr(v->Vertices);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      stat[9] += Tree_Nbr(v->Simplexes) + Tree_Nbr(v->SimplexesBase);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      stat[10] += Tree_Nbr(v->Hexahedra);
      stat[11] += Tree_Nbr(v->Prisms);
      stat[12] += Tree_Nbr(v->Pyramids);
    }
    List_Delete(volumes);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

  // hack... (Read_Mesh does not fill-in the vertices)
  int nbnod = Tree_Nbr(THEM->Vertices);
  if(nbnod && !stat[4] && !stat[5] && !stat[6]){
    if(stat[9] || stat[10] || stat[11] || stat[12])
      stat[6] = nbnod;
    else if(stat[7] || stat[8])
      stat[5] = nbnod;
    else
      stat[4] = nbnod;
  }

  stat[13] = THEM->timing[0];
  stat[14] = THEM->timing[1];
  stat[15] = THEM->timing[2];

  nbOrder2 = 0;
  Tree_Action(THEM->Vertices, countOrder2);
  stat[16] = nbOrder2;

  stat[17] = THEM->quality_gamma[0];
  stat[18] = THEM->quality_gamma[1];
  stat[19] = THEM->quality_gamma[2];
  stat[20] = THEM->quality_eta[0];
  stat[21] = THEM->quality_eta[1];
  stat[22] = THEM->quality_eta[2];
  stat[23] = THEM->quality_rho[0];
  stat[24] = THEM->quality_rho[1];
  stat[25] = THEM->quality_rho[2];

  stat[26] = List_Nbr(CTX.post.list);
  for(int i = 0; i < List_Nbr(CTX.post.list); i++) {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    Post_View *v = *(Post_View **) List_Pointer(CTX.post.list, i);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    stat[27] += v->NbSP + v->NbVP + v->NbTP;
    stat[28] += v->NbSL + v->NbVL + v->NbTL;
    stat[29] += v->NbST + v->NbVT + v->NbTT;
    stat[30] += v->NbSQ + v->NbVQ + v->NbTQ;
    stat[31] += v->NbSS + v->NbVS + v->NbTS;
    stat[32] += v->NbSH + v->NbVH + v->NbTH;
    stat[33] += v->NbSI + v->NbVI + v->NbTI;
    stat[34] += v->NbSY + v->NbVY + v->NbTY;
    stat[35] += v->NbT2 + v->NbT3;
    if(v->Visible) {
      if(v->DrawPoints)
        stat[36] += 
	  (v->DrawScalars ? v->NbSP : 0) + (v->DrawVectors ? v->NbVP : 0) + 
	  (v->DrawTensors ? v->NbTP : 0);
      if(v->DrawLines)
        stat[37] += 
	  (v->DrawScalars ? v->NbSL : 0) + (v->DrawVectors ? v->NbVL : 0) + 
	  (v->DrawTensors ? v->NbTL : 0);
      if(v->DrawTriangles)
        stat[38] += 
	  (v->DrawScalars ? v->NbST : 0) + (v->DrawVectors ? v->NbVT : 0) + 
	  (v->DrawTensors ? v->NbTT : 0);
      if(v->DrawQuadrangles)
        stat[39] +=
	  (v->DrawScalars ? v->NbSQ : 0) + (v->DrawVectors ? v->NbVQ : 0) + 
	  (v->DrawTensors ? v->NbTQ : 0);
      if(v->DrawTetrahedra)
        stat[40] += 
	  (v->DrawScalars ? v->NbSS : 0) + (v->DrawVectors ? v->NbVS : 0) + 
	  (v->DrawTensors ? v->NbTS : 0);
      if(v->DrawHexahedra)
        stat[41] +=
	  (v->DrawScalars ? v->NbSH : 0) + (v->DrawVectors ? v->NbVH : 0) +
	  (v->DrawTensors ? v->NbTH : 0);
      if(v->DrawPrisms)
        stat[42] += 
	  (v->DrawScalars ? v->NbSI : 0) + (v->DrawVectors ? v->NbVI : 0) +
	  (v->DrawTensors ? v->NbTI : 0);
      if(v->DrawPyramids)
        stat[43] += 
	  (v->DrawScalars ? v->NbSY : 0) + (v->DrawVectors ? v->NbVY : 0) + 
	  (v->DrawTensors ? v->NbTY : 0);
      if(v->DrawStrings)
        stat[44] += v->NbT2 + v->NbT3;
    }
  }

static double SumOfAllLc = 0.;
void GetSumOfAllLc(void *a, void *b)
{
  Vertex *v = *(Vertex **) a;
  SumOfAllLc += v->lc;
}

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
void ApplyLcFactor_Point(void *a, void *b)
{
  Vertex *v = *(Vertex **) a;
  if(v->lc <= 0.0) {
    Msg(GERROR, 
	"Wrong characteristic length (%g <= 0) for Point %d, defaulting to 1.0",
        v->lc, v->Num);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    v->lc = 1.0;
  v->lc *= CTX.mesh.lc_factor;
}
Christophe Geuzaine's avatar
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
void ApplyLcFactor_Attractor(void *a, void *b)
{
  Attractor *v = *(Attractor **) a;
  v->lc1 *= CTX.mesh.lc_factor;
  v->lc2 *= CTX.mesh.lc_factor;
}
Christophe Geuzaine's avatar
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
void ApplyLcFactor(Mesh * M)
{
  Tree_Action(M->Points, ApplyLcFactor_Point);
  List_Action(M->Metric->Attractors, ApplyLcFactor_Attractor);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
void Move_SimplexBaseToSimplex(Mesh * M, int dimension)
{
  if(dimension >= 1){
    List_T *Curves = Tree2List(M->Curves);
    for(int i = 0; i < List_Nbr(Curves); i++) {
      Curve *c;
      List_Read(Curves, i, &c);
      Move_SimplexBaseToSimplex(&c->SimplexesBase, c->Simplexes);
    }
    List_Delete(Curves);
  }

  if(dimension >= 2){
    List_T *Surfaces = Tree2List(M->Surfaces);
    for(int i = 0; i < List_Nbr(Surfaces); i++){
      Surface *s;
      List_Read(Surfaces, i, &s);
      Move_SimplexBaseToSimplex(&s->SimplexesBase, s->Simplexes);
    }
    List_Delete(Surfaces);
  }
  
  if(dimension >= 3){
    List_T *Volumes = Tree2List(M->Volumes);
    for(int i = 0; i < List_Nbr(Volumes); i++){
      Volume *v;
      List_Read(Volumes, i, &v);
      Move_SimplexBaseToSimplex(&v->SimplexesBase, v->Simplexes);
    }
    List_Delete(Volumes);
  }
}

bool TooManyElements(Mesh *M, int dim){
  if(CTX.expert_mode || !Tree_Nbr(M->Points)) return false;

  // try to detect obvious mistakes in characteristic lenghts (one of
  // the most common cause for erroneous bug reports on the mailing
  // list)
  SumOfAllLc = 0.;
  Tree_Action(M->Points, GetSumOfAllLc);
  SumOfAllLc /= (double)Tree_Nbr(M->Points);
  if(pow(CTX.lc / SumOfAllLc, dim) < 1.e7) return false;
  return !GetBinaryAnswer("Your choice of characteristic lengths will likely produce\n"
			  "a very large mesh. Do you really want to continue?\n\n"
			  "(To disable this warning in the future, select `Enable\n"
			  "expert mode' in the option dialog.)",
			  "Continue", "Cancel");
}

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
void Maillage_Dimension_1(Mesh * M)
{
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  Tree_Action(M->Curves, Maillage_Curve);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

  std::for_each (GMODEL->firstEdge(),GMODEL->lastEdge(), meshGEdge() );

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  M->timing[0] = t2 - t1;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
void Maillage_Dimension_2(Mesh * M)
{
  if(TooManyElements(M, 2)) return;

  double shortest = 1.e300;
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  // create reverse 1D meshes
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  List_T *Curves = Tree2List(M->Curves);
  for(int i = 0; i < List_Nbr(Curves); i++) {
    Curve *c;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    List_Read(Curves, i, &c);
    if(c->Num > 0) {
      if(c->l < shortest)
        shortest = c->l;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      Tree_Query(M->Curves, &neew);
      neew->Vertices =
        List_Create(List_Nbr(c->Vertices), 1, sizeof(Vertex *));
      List_Invert(c->Vertices, neew->Vertices);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  List_Delete(Curves);
  Msg(DEBUG, "Shortest curve has length %g", shortest);
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  // mesh 2D
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  Tree_Action(M->Surfaces, Maillage_Surface);

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  // global "all-quad" recombine

  if(CTX.mesh.algo_recombine == 2)
    Recombine_All(M);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  M->timing[1] = t2 - t1;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
static Volume *IVOL;

void TransferData(void *a, void *b)
{
  Simplex *s = *(Simplex**)a;
  if(s->iEnt == IVOL->Num){
    Tree_Add(IVOL->Simplexes, &s);
    for(int i = 0; i < 4; i++)
      Tree_Insert(IVOL->Vertices, &s->V[i]);
  }
}

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
void Maillage_Dimension_3(Mesh * M)
{
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  // merge all the delaunay parts in a single special volume
  Volume *v = Create_Volume(99999, 99999);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  List_T *list = Tree2List(M->Volumes);
  for(int i = 0; i < List_Nbr(list); i++) {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    List_Read(list, i, &vol);
    if((!vol->Extrude || !vol->Extrude->mesh.ExtrudeMesh) &&
       (vol->Method != TRANSFINI)) {
      for(int j = 0; j < List_Nbr(vol->Surfaces); j++) {
        List_Replace(v->Surfaces, List_Pointer(vol->Surfaces, j),
                     compareSurface);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  Tree_Insert(M->Volumes, &v);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  if(CTX.mesh.oldxtrude) {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    Extrude_Mesh_Old(M); // old extrusion
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  else {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    Extrude_Mesh(M->Volumes); // new extrusion
    Tree_Action(M->Volumes, Maillage_Volume); // delaunay of remaining parts
  }

  // transfer data back to individual volumes and remove special volume
  for(int i = 0; i < List_Nbr(list); i++){
    List_Read(list, i, &IVOL);
    Tree_Action(v->Simplexes, TransferData);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  Tree_Suppress(M->Volumes, &v);
  Free_Volume_But_Not_Elements(&v, NULL);

  List_Delete(list);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  M->timing[2] = t2 - t1;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
void Init_Mesh0(Mesh * M)
{
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  THEM = M;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  M->bds = 0;
  M->bds_mesh = 0;
  M->Vertices = NULL;
  M->Simplexes = NULL;
  M->Points = NULL;
  M->Curves = NULL;
  M->SurfaceLoops = NULL;
  M->EdgeLoops = NULL;
  M->Surfaces = NULL;
  M->Volumes = NULL;
  M->PhysicalGroups = NULL;
  M->Partitions = NULL;
  M->Metric = NULL;
}
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
void Init_Mesh(Mesh * M)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
{
  M->MaxPointNum = 0;
  M->MaxLineNum = 0;
  M->MaxLineLoopNum = 0;
  M->MaxSurfaceNum = 0;
  M->MaxSurfaceLoopNum = 0;
  M->MaxVolumeNum = 0;
  M->MaxPhysicalNum = 0;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

  Element::TotalNumber = 0;
  ExitExtrude();
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  if(M->bds) delete M->bds;
  M->bds = 0;

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  Tree_Action(M->Vertices, Free_Vertex);  
  Tree_Delete(M->Vertices);

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  Tree_Action(M->Points, Free_Vertex);  
  Tree_Delete(M->Points);

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  // Note: don't free the simplices here (with Tree_Action
  // (M->Simplexes, Free_Simplex)): we free them in each curve,
  // surface, volume
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  Tree_Delete(M->Simplexes);

  Tree_Action(M->Curves, Free_Curve);
  Tree_Delete(M->Curves);

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  Tree_Action(M->SurfaceLoops, Free_SurfaceLoop);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  Tree_Delete(M->SurfaceLoops);

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  Tree_Action(M->EdgeLoops, Free_EdgeLoop);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  Tree_Delete(M->EdgeLoops);

  Tree_Action(M->Surfaces, Free_Surface);
  Tree_Delete(M->Surfaces);

  Tree_Action(M->Volumes, Free_Volume);
  Tree_Delete(M->Volumes);

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  List_Action(M->PhysicalGroups, Free_PhysicalGroup);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  List_Delete(M->PhysicalGroups);

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  List_Action(M->Partitions, Free_MeshPartition);
  List_Delete(M->Partitions);

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  if(M->Metric)
    delete M->Metric;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  if(M->normals)
    delete M->normals;

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  M->Vertices = Tree_Create(sizeof(Vertex *), compareVertex);
  M->Simplexes = Tree_Create(sizeof(Simplex *), compareSimplex);
  M->Points = Tree_Create(sizeof(Vertex *), compareVertex);
  M->Curves = Tree_Create(sizeof(Curve *), compareCurve);
  M->SurfaceLoops = Tree_Create(sizeof(SurfaceLoop *), compareSurfaceLoop);
  M->EdgeLoops = Tree_Create(sizeof(EdgeLoop *), compareEdgeLoop);
  M->Surfaces = Tree_Create(sizeof(Surface *), compareSurface);
  M->Volumes = Tree_Create(sizeof(Volume *), compareVolume);
  M->PhysicalGroups = List_Create(5, 5, sizeof(PhysicalGroup *));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  M->Partitions = List_Create(5, 5, sizeof(MeshPartition *));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  M->normals = new smooth_normals(CTX.mesh.angle_smooth_normals);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  M->BackgroundMeshType = WITHPOINTS;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

  for(int i = 0; i < 3; i++){
    M->timing[i] = 0.0;
    M->quality_gamma[i] = 0.0;
    M->quality_eta[i] = 0.0;
    M->quality_rho[i] = 0.0;
  }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  CTX.mesh.changed = 1;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
void mai3d(Mesh * M, int Asked)
{
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  if(CTX.threads_lock) {
    Msg(INFO, "I'm busy! Ask me that later...");
    return;
  }

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  // Re-read data
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  if((Asked > oldstatus && Asked >= 0 && oldstatus < 0) ||
     (Asked < oldstatus)) {
    OpenProblem(CTX.filename);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  CTX.threads_lock = 1;

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  // Clean up all the 2nd order nodes and transfer all SimplexBase
  // into "real" Simplexes

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  Degre1();

Christophe Geuzaine's avatar
Christophe Geuzaine committed
  // 1D mesh
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

  if((Asked > oldstatus && Asked > 0 && oldstatus < 1) ||
     (Asked < oldstatus && Asked > 0)) {
Christophe Geuzaine's avatar
Christophe Geuzaine committed
    Msg(STATUS2, "Mesh 1D...");
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    if(M->status > 1) {
      OpenProblem(CTX.filename);
    }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    Maillage_Dimension_1(M);
Christophe Geuzaine's avatar
Christophe Geuzaine committed
    Msg(STATUS2, "Mesh 1D complete (%g s)", t2 - t1);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Christophe Geuzaine's avatar
Christophe Geuzaine committed
  // 2D mesh
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

  if((Asked > oldstatus && Asked > 1 && oldstatus < 2) ||
     (Asked < oldstatus && Asked > 1)) {
Christophe Geuzaine's avatar
Christophe Geuzaine committed
    Msg(STATUS2, "Mesh 2D...");
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    if(M->status == 3) {
      OpenProblem(CTX.filename);
      Maillage_Dimension_1(M);
    }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    Maillage_Dimension_2(M);
Christophe Geuzaine's avatar
Christophe Geuzaine committed
    Msg(STATUS2, "Mesh 2D complete (%g s)", t2 - t1);
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  // 3D mesh
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  if((Asked > oldstatus && Asked > 2 && oldstatus < 3) ||
     (Asked < oldstatus && Asked > 2)) {
Christophe Geuzaine's avatar
Christophe Geuzaine committed
    Msg(STATUS2, "Mesh 3D...");
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    Maillage_Dimension_3(M);
Christophe Geuzaine's avatar
Christophe Geuzaine committed
    Msg(STATUS2, "Mesh 3D complete (%g s)", t2 - t1);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  // Optimize quality

  if(M->status == 3 && CTX.mesh.optimize)
    Optimize_Netgen(M);

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  // Create second order elements
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  if(M->status && CTX.mesh.order == 2)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    Degre2(M->status);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  // Partition

  if(M->status > 1 && CTX.mesh.nbPartitions != 1)
    PartitionMesh(M, CTX.mesh.nbPartitions);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  CTX.threads_lock = 0;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  CTX.mesh.changed = 1;