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

simple mesh partitioner (slices_

parent b50469fb
No related branches found
No related tags found
No related merge requests found
...@@ -818,7 +818,7 @@ static int getNumElementsMSH(GModel *m, bool saveAll, int saveSinglePartition) ...@@ -818,7 +818,7 @@ static int getNumElementsMSH(GModel *m, bool saveAll, int saveSinglePartition)
int GModel::_writeMSH2(const std::string &name, double version, bool binary, int GModel::_writeMSH2(const std::string &name, double version, bool binary,
bool saveAll, bool saveParametric, double scalingFactor, bool saveAll, bool saveParametric, double scalingFactor,
int elementStartNum, int saveSinglePartition,bool multipleView) int elementStartNum, int saveSinglePartition, bool multipleView)
{ {
FILE *fp; FILE *fp;
if(multipleView) if(multipleView)
......
...@@ -31,6 +31,7 @@ set(SRC ...@@ -31,6 +31,7 @@ set(SRC
Scal2Vec.cpp Scal2Vec.cpp
CutMesh.cpp CutMesh.cpp
NewView.cpp NewView.cpp
SimplePartition.cpp
) )
file(GLOB HDR RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.h) file(GLOB HDR RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.h)
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "AnalyseCurvedMesh.h" #include "AnalyseCurvedMesh.h"
#include "MathEval.h" #include "MathEval.h"
#include "ExtractElements.h" #include "ExtractElements.h"
#include "SimplePartition.h"
#include "HarmonicToTime.h" #include "HarmonicToTime.h"
#include "ModulusPhase.h" #include "ModulusPhase.h"
#include "Integrate.h" #include "Integrate.h"
...@@ -240,8 +241,10 @@ void PluginManager::registerDefaultPlugins() ...@@ -240,8 +241,10 @@ void PluginManager::registerDefaultPlugins()
("DiscretizationError", GMSH_RegisterDiscretizationErrorPlugin())); ("DiscretizationError", GMSH_RegisterDiscretizationErrorPlugin()));
allPlugins.insert(std::pair<std::string, GMSH_Plugin*> allPlugins.insert(std::pair<std::string, GMSH_Plugin*>
("Scal2Vec", GMSH_RegisterScal2VecPlugin())); ("Scal2Vec", GMSH_RegisterScal2VecPlugin()));
allPlugins.insert(std::pair<std::string, GMSH_Plugin*> allPlugins.insert(std::pair<std::string, GMSH_Plugin*>
("NewView", GMSH_RegisterNewViewPlugin())); ("NewView", GMSH_RegisterNewViewPlugin()));
allPlugins.insert(std::pair<std::string, GMSH_Plugin*>
("SimplePartition", GMSH_RegisterSimplePartitionPlugin()));
#if defined(HAVE_TETGEN) #if defined(HAVE_TETGEN)
allPlugins.insert(std::pair<std::string, GMSH_Plugin*> allPlugins.insert(std::pair<std::string, GMSH_Plugin*>
("Tetrahedralize", GMSH_RegisterTetrahedralizePlugin())); ("Tetrahedralize", GMSH_RegisterTetrahedralizePlugin()));
......
// Gmsh - Copyright (C) 1997-2013 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to the public mailing list <gmsh@geuz.org>.
#include "SimplePartition.h"
#include "GModel.h"
#include "MElement.h"
#if defined(HAVE_MESH)
#include "meshPartition.h"
#endif
StringXNumber SimplePartitionOptions_Number[] = {
{GMSH_FULLRC, "NumSlices", NULL, 4.},
{GMSH_FULLRC, "Direction", NULL, 0.},
};
extern "C"
{
GMSH_Plugin *GMSH_RegisterSimplePartitionPlugin()
{
return new GMSH_SimplePartitionPlugin();
}
}
std::string GMSH_SimplePartitionPlugin::getHelp() const
{
return "Plugin(SimplePartition) partitions the current mesh into "
"`NumSlices' slices, along the X-, Y- or Z-axis depending on "
"the value of `Direction' (0,1,2).";
}
int GMSH_SimplePartitionPlugin::getNbOptions() const
{
return sizeof(SimplePartitionOptions_Number) / sizeof(StringXNumber);
}
StringXNumber *GMSH_SimplePartitionPlugin::getOption(int iopt)
{
return &SimplePartitionOptions_Number[iopt];
}
PView *GMSH_SimplePartitionPlugin::execute(PView *v)
{
int numSlices = (int)SimplePartitionOptions_Number[0].def;
int direction = (int)SimplePartitionOptions_Number[1].def;
// partition the current model
GModel *m = GModel::current();
SBoundingBox3d bbox = m->bounds();
double pmin = bbox.min()[direction], pmax = bbox.max()[direction];
std::vector<GEntity*> entities;
m->getEntities(entities);
for(unsigned int i = 0; i < entities.size(); i++){
int n = entities[i]->getNumMeshElements();
for(int j = 0; j < n; j++){
MElement *e = entities[i]->getMeshElement(j);
double val = pmax;
for(int k = 0; k < e->getNumVertices(); k++){
MVertex *v = e->getVertex(k);
val = std::min(val, v->point()[direction]);
}
for(int p = 0; p < numSlices; p++){
double p1 = pmin + p * (pmax - pmin) / numSlices;
double p2 = pmin + (p + 1) * (pmax - pmin) / numSlices;
if(val >= p1 && val < p2){
e->setPartition(p + 1);
break;
}
}
}
}
m->recomputeMeshPartitions();
#if defined(HAVE_MESH)
CreatePartitionBoundaries(m, false, false);
#endif
return v;
}
// Gmsh - Copyright (C) 1997-2013 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to the public mailing list <gmsh@geuz.org>.
#ifndef _SIMPLE_PARTITION_H_
#define _SIMPLE_PARTITION_H_
#include "Plugin.h"
extern "C"
{
GMSH_Plugin *GMSH_RegisterSimplePartitionPlugin();
}
class GMSH_SimplePartitionPlugin : public GMSH_PostPlugin
{
public:
GMSH_SimplePartitionPlugin(){}
std::string getName() const { return "SimplePartition"; }
std::string getShortHelp() const
{
return "Simple mesh partitioner";
}
std::string getHelp() const;
int getNbOptions() const;
StringXNumber* getOption(int iopt);
PView *execute(PView *);
};
#endif
...@@ -176,8 +176,8 @@ bool PViewData::writePOS(const std::string &fileName, bool binary, bool parsed, ...@@ -176,8 +176,8 @@ bool PViewData::writePOS(const std::string &fileName, bool binary, bool parsed,
return true; return true;
} }
bool PViewData::writeMSH(const std::string &fileName, double version, bool binary, bool savemesh, bool PViewData::writeMSH(const std::string &fileName, double version, bool binary,
bool multipleView) bool savemesh, bool multipleView)
{ {
Msg::Error("MSH export not implemented for this view type"); Msg::Error("MSH export not implemented for this view type");
return false; return false;
......
Mesh.Algorithm3D=4; //1-Delaunay, 4-Frontal, 5-Frontal Delaunay 6-Frontal hex, 7-MMG3D, 9-RTree Mesh.Algorithm3D=4; //1-Delaunay, 4-Frontal, 5-Frontal Delaunay 6-Frontal hex, 7-MMG3D, 9-RTree
Mesh.CharacteristicLengthFactor = 1.2; Mesh.CharacteristicLengthFactor = 1.2/10;
Merge "SurfaceMeshAnisoCurvature.stl"; Merge "InitialMeshFalcon.stl";
//Merge "SurfaceMeshUniform.stl";
//Merge "SurfaceMeshAnisoCurvature.stl";
CreateTopology; CreateTopology;
......
Mesh.RemeshParametrization=7; //0=harmonic_circle, 1=conformal, 2=rbf, 3=harmonic_plane, 4=convex_circle, 5=convex_plane, 6=harmonic square Mesh.RemeshParametrization=7; //0=harmonic_circle, 1=conformal, 2=rbf, 3=harmonic_plane, 4=convex_circle, 5=convex_plane, 6=harmonic square
Mesh.RemeshAlgorithm=1; //(0) nosplit (1) automatic (2) split only with metis Mesh.RemeshAlgorithm=1; //(0) nosplit (1) automatic (2) split only with metis
Mesh.Algorithm=7; //(1=MeshAdapt, 2=Automatic, 5=Delaunay, 6=Frontal, 7=bamg, 8=delquad) Mesh.Algorithm=7; //(1=MeshAdapt, 2=Automatic, 5=Delaunay, 6=Frontal, 7=bamg, 8=delquad)
...@@ -34,10 +34,10 @@ For i In {0 : #ss[]-1} ...@@ -34,10 +34,10 @@ For i In {0 : #ss[]-1}
Physical Surface(i+1) = { i+100 }; Physical Surface(i+1) = { i+100 };
EndFor EndFor
// The trailing edge of the horizontal tail surface // The trailing edge of the horizontal tail surface
// should be an attractor // should be an attractor
//Point(100000) = {16.858,2.0482,0.018793,0.1}; //Point(100000) = {16.858,2.0482,0.018793,0.1};
Point(100000) = {-1.16411804,1.83824622,0.29113513}; Point(100000) = {-1.16411804,1.83824622,0.29113513};
Field[1] = Attractor; Field[1] = Attractor;
Field[1].NodesList = { 100000 }; Field[1].NodesList = { 100000 };
......
Mesh.RemeshParametrization=7; //0=harmonic_circle, 1=conformal, 2=rbf, 3=harmonic_plane, 4=convex_circle, 5=convex_plane, 6=harmonic square
Mesh.RemeshAlgorithm=1; //(0) nosplit (1) automatic (2) split only with metis
Mesh.Algorithm=6; //(1=MeshAdapt, 2=Automatic, 5=Delaunay, 6=Frontal, 7=bamg, 8=delquad)
Mesh.CharacteristicLengthFromPoints = 0;
Mesh.CharacteristicLengthMin = 0.02;
Mesh.CharacteristicLengthMax = 0.02;
Mesh.LcIntegrationPrecision = 1.e-5;
Mesh.MinimumCirclePoints = 50;
Mesh.CharacteristicLengthExtendFromBoundary = 0;
Mesh.CharacteristicLengthFromCurvature = 0;
Mesh.CharacteristicLengthFromPoints = 0;
Merge "InitialMeshFalcon.msh";
CreateTopology;
// Make all lines compound:
ll[] = Line "*";
For j In {0 : #ll[]-1}
Compound Line(1000+j) = ll[j];
Physical Line(1000+j) = (1000+j);
EndFor
// Make all surfaces compound and physical:
ss[] = Surface "*";
For i In {0 : #ss[]-1}
Compound Surface(i+100) = ss[i];
Physical Surface(i+1) = { i+100 };
EndFor
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment