From 0cec25f70819c0a150a97b772b2a7ea7ce75ce66 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Tue, 20 Aug 2013 15:43:24 +0000
Subject: [PATCH] Mesh.FlexibleTransfinite to allow transfinite constraints to
 be modified by global mesh size factor + modified for Blossom

---
 Common/DefaultOptions.h |  2 ++
 Common/Options.cpp      |  8 ++++++++
 Common/Options.h        |  1 +
 Mesh/meshGEdge.cpp      | 10 ++++++++--
 4 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h
index 05b4b71a54..2d03cca6fe 100644
--- a/Common/DefaultOptions.h
+++ b/Common/DefaultOptions.h
@@ -955,6 +955,8 @@ StringXNumber MeshOptions_Number[] = {
   { F|O, "Explode" , opt_mesh_explode , 1.0 ,
     "Element shrinking factor (between 0 and 1)" },
 
+  { F|O, "FlexibleTransfinite" , opt_mesh_flexible_transfinite , 0 ,
+    "Allow transfinite contraints to be modified for Blossom or by global mesh size factor" },
   { F|O, "Format" , opt_mesh_file_format , FORMAT_AUTO ,
     "Mesh output format (1=msh, 2=unv, 10=automatic, 19=vrml, 27=stl, 30=mesh, 31=bdf, "
     "32=cgns, 33=med, 40=ply2)" },
diff --git a/Common/Options.cpp b/Common/Options.cpp
index 851da3d11f..b656f991f5 100644
--- a/Common/Options.cpp
+++ b/Common/Options.cpp
@@ -5433,6 +5433,14 @@ double opt_mesh_recombine3d_all(OPT_ARGS_NUM)
   return CTX::instance()->mesh.recombine3DAll;
 }
 
+double opt_mesh_flexible_transfinite(OPT_ARGS_NUM)
+{
+  if(action & GMSH_SET){
+    CTX::instance()->mesh.flexibleTransfinite = (int)val;
+  }
+  return CTX::instance()->mesh.flexibleTransfinite;
+}
+
 double opt_mesh_do_recombination_test(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET){
diff --git a/Common/Options.h b/Common/Options.h
index c4f8e3246e..87c0dbe202 100644
--- a/Common/Options.h
+++ b/Common/Options.h
@@ -433,6 +433,7 @@ double opt_mesh_algo3d(OPT_ARGS_NUM);
 double opt_mesh_algo_recombine(OPT_ARGS_NUM);
 double opt_mesh_recombine_all(OPT_ARGS_NUM);
 double opt_mesh_recombine3d_all(OPT_ARGS_NUM);
+double opt_mesh_flexible_transfinite(OPT_ARGS_NUM);
 double opt_mesh_do_recombination_test(OPT_ARGS_NUM);
 double opt_mesh_recombination_test_start(OPT_ARGS_NUM);
 double opt_mesh_recombination_no_greedy_strat(OPT_ARGS_NUM);
diff --git a/Mesh/meshGEdge.cpp b/Mesh/meshGEdge.cpp
index c82d71fef2..901e4b82be 100644
--- a/Mesh/meshGEdge.cpp
+++ b/Mesh/meshGEdge.cpp
@@ -149,6 +149,9 @@ static double F_Transfinite(GEdge *ge, double t_)
   int type = ge->meshAttributes.typeTransfinite;
   int nbpt = ge->meshAttributes.nbPointsTransfinite;
 
+  if(CTX::instance()->mesh.flexibleTransfinite && CTX::instance()->mesh.lcFactor)
+    nbpt /= CTX::instance()->mesh.lcFactor;
+
   Range<double> bounds = ge->parBounds(0);
   double t_begin = bounds.low();
   double t_end = bounds.high();
@@ -388,6 +391,8 @@ void meshGEdge::operator() (GEdge *ge)
     a = Integration(ge, t_begin, t_end, F_Transfinite, Points,
                     CTX::instance()->mesh.lcIntegrationPrecision);
     N = ge->meshAttributes.nbPointsTransfinite;
+    if(CTX::instance()->mesh.flexibleTransfinite && CTX::instance()->mesh.lcFactor)
+      N /= CTX::instance()->mesh.lcFactor;
   }
   else{
     if (CTX::instance()->mesh.algo2d == ALGO_2D_BAMG || blf){
@@ -410,9 +415,10 @@ void meshGEdge::operator() (GEdge *ge)
   }
 
   // force odd number of points if blossom is used for recombination
-  if(ge->meshAttributes.method != MESH_TRANSFINITE &&
+  if((ge->meshAttributes.method != MESH_TRANSFINITE ||
+      CTX::instance()->mesh.flexibleTransfinite) &&
      CTX::instance()->mesh.algoRecombine == 1 && N % 2 == 0){
-    if(/* 1 ||*/ CTX::instance()->mesh.recombineAll){
+    if(CTX::instance()->mesh.recombineAll){
       N++;
     }
     else{
-- 
GitLab