Skip to content
Snippets Groups Projects
Commit d8f925f8 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

provide mapping for non-uniform partitioning

parent 7e9208e3
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@
#include "MQuadrangle.h"
#include "MFace.h"
#include "MEdge.h"
#include "mathEvaluator.h"
#if defined(HAVE_MESH)
#include "meshPartition.h"
#endif
......@@ -23,6 +24,10 @@ StringXNumber SimplePartitionOptions_Number[] = {
{GMSH_FULLRC, "CreateBoundaries", NULL, 1.},
};
StringXString SimplePartitionOptions_String[] = {
{GMSH_FULLRC, "Mapping", NULL, "t"}
};
extern "C"
{
GMSH_Plugin *GMSH_RegisterSimplePartitionPlugin()
......@@ -49,11 +54,23 @@ StringXNumber *GMSH_SimplePartitionPlugin::getOption(int iopt)
return &SimplePartitionOptions_Number[iopt];
}
int GMSH_SimplePartitionPlugin::getNbOptionsStr() const
{
return sizeof(SimplePartitionOptions_String) / sizeof(StringXString);
}
StringXString *GMSH_SimplePartitionPlugin::getOptionStr(int iopt)
{
return &SimplePartitionOptions_String[iopt];
}
PView *GMSH_SimplePartitionPlugin::execute(PView *v)
{
int numSlices = (int)SimplePartitionOptions_Number[0].def;
int direction = (int)SimplePartitionOptions_Number[1].def;
int createBoundaries = (int)SimplePartitionOptions_Number[2].def;
std::vector<std::string> expr(1);
expr[0] = SimplePartitionOptions_String[0].def;
// partition the highest dimension elements in the current model (lower
// dimension elements on boundaries cannot be tagged a priori: there are
......@@ -63,8 +80,17 @@ PView *GMSH_SimplePartitionPlugin::execute(PView *v)
SBoundingBox3d bbox = m->bounds();
double pmin = bbox.min()[direction], pmax = bbox.max()[direction];
std::vector<double> pp(numSlices + 1);
for(int p = 0; p <= numSlices; p++)
pp[p] = pmin + p * (pmax - pmin) / numSlices;
std::vector<std::string> variables(1);
variables[0] = "t";
mathEvaluator f(expr, variables);
if(expr.empty()) return v;
std::vector<double> values(1), res(1);
for(int p = 0; p <= numSlices; p++){
double t = values[0] = (double)p / (double)numSlices;
if(f.eval(values, res)) t = res[0];
pp[p] = pmin + t * (pmax - pmin);
}
int dim = m->getDim();
std::vector<GEntity*> entities;
m->getEntities(entities);
......
......@@ -25,6 +25,8 @@ class GMSH_SimplePartitionPlugin : public GMSH_PostPlugin
std::string getHelp() const;
int getNbOptions() const;
StringXNumber* getOption(int iopt);
int getNbOptionsStr() const;
StringXString* getOptionStr(int iopt);
PView *execute(PView *);
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment