On Mon, Aug 3, 2009 at 2:46 AM, Geordie McBain <[email protected]>wrote:
> ....
By the way, I note that there are a few white-space-only changes in
> your patch.
> ...
Thanks for the remark I hadn't noticed the whitespace changes. I sent the
patch again with them removed.
Kostas
diff -rup ./gmsh-2.4.0-cvs-20090730-orig/Common/Context.h ./gmsh-2.4.0-cvs-20090730/Common/Context.h
--- ./gmsh-2.4.0-cvs-20090730-orig/Common/Context.h 2009-06-16 01:03:10.000000000 +0300
+++ ./gmsh-2.4.0-cvs-20090730/Common/Context.h 2009-07-30 23:18:49.207588696 +0300
@@ -178,7 +178,8 @@ class CTX {
int order, secondOrderLinear, secondOrderIncomplete;
int secondOrderExperimental, meshOnlyVisible;
int smoothInternalEdges, minCircPoints, minCurvPoints;
- int saveAll, saveGroupsOfNodes, binary, bdfFieldFormat, saveParametric;
+ int saveAll, saveGroupsOfNodes, binary, saveParametric;
+ int bdfFieldFormat, bdfElementPID;
int smoothNormals, reverseAllNormals, zoneDefinition, clip;
} mesh;
// FIXME: putting these in the mesh struct (where they belong) causes
diff -rup ./gmsh-2.4.0-cvs-20090730-orig/Common/CreateFile.cpp ./gmsh-2.4.0-cvs-20090730/Common/CreateFile.cpp
--- ./gmsh-2.4.0-cvs-20090730-orig/Common/CreateFile.cpp 2009-06-27 01:03:24.000000000 +0300
+++ ./gmsh-2.4.0-cvs-20090730/Common/CreateFile.cpp 2009-07-30 23:21:53.211655607 +0300
@@ -194,7 +194,8 @@ void CreateOutputFile(std::string fileNa
case FORMAT_BDF:
GModel::current()->writeBDF
- (fileName, CTX::instance()->mesh.bdfFieldFormat, CTX::instance()->mesh.saveAll,
+ (fileName, CTX::instance()->mesh.bdfFieldFormat,
+ CTX::instance()->mesh.bdfElementPID, CTX::instance()->mesh.saveAll,
CTX::instance()->mesh.scalingFactor);
break;
diff -rup ./gmsh-2.4.0-cvs-20090730-orig/Common/DefaultOptions.h ./gmsh-2.4.0-cvs-20090730/Common/DefaultOptions.h
--- ./gmsh-2.4.0-cvs-20090730-orig/Common/DefaultOptions.h 2009-06-16 01:03:10.000000000 +0300
+++ ./gmsh-2.4.0-cvs-20090730/Common/DefaultOptions.h 2009-07-30 23:07:46.627586541 +0300
@@ -932,6 +932,8 @@ StringXNumber MeshOptions_Number[] = {
{ F|O, "BdfFieldFormat" , opt_mesh_bdf_field_format , 1. ,
"Field format for Nastran BDF files (0=free, 1=small, 2=large)" },
+ { F|O, "BdfElementPID" , opt_mesh_bdf_element_pid , 1. ,
+ "Element PID for Nastran BDF files (0=by element type, 1=by elementary entity, 2=by physical entity, 3=by partition)" },
{ F|O, "Binary" , opt_mesh_binary , 0. ,
"Write mesh files in binary format (if possible)" },
diff -rup ./gmsh-2.4.0-cvs-20090730-orig/Common/Options.cpp ./gmsh-2.4.0-cvs-20090730/Common/Options.cpp
--- ./gmsh-2.4.0-cvs-20090730-orig/Common/Options.cpp 2009-06-27 10:04:16.000000000 +0300
+++ ./gmsh-2.4.0-cvs-20090730/Common/Options.cpp 2009-08-17 16:17:04.407520057 +0300
@@ -5402,6 +5402,17 @@ double opt_mesh_bdf_field_format(OPT_ARG
return CTX::instance()->mesh.bdfFieldFormat;
}
+double opt_mesh_bdf_element_pid(OPT_ARGS_NUM)
+{
+ if(action & GMSH_SET){
+ CTX::instance()->mesh.bdfElementPID = (int)val;
+ if(CTX::instance()->mesh.bdfElementPID < 0 ||
+ CTX::instance()->mesh.bdfElementPID > 3)
+ CTX::instance()->mesh.bdfElementPID = 1;
+ }
+ return CTX::instance()->mesh.bdfElementPID;
+}
+
double opt_mesh_nb_smoothing(OPT_ARGS_NUM)
{
if(action & GMSH_SET)
diff -rup ./gmsh-2.4.0-cvs-20090730-orig/Common/Options.h ./gmsh-2.4.0-cvs-20090730/Common/Options.h
--- ./gmsh-2.4.0-cvs-20090730-orig/Common/Options.h 2009-06-16 01:03:11.000000000 +0300
+++ ./gmsh-2.4.0-cvs-20090730/Common/Options.h 2009-08-17 16:17:31.290077404 +0300
@@ -490,6 +490,7 @@ double opt_mesh_format(OPT_ARGS_NUM);
double opt_mesh_msh_file_version(OPT_ARGS_NUM);
double opt_mesh_binary(OPT_ARGS_NUM);
double opt_mesh_bdf_field_format(OPT_ARGS_NUM);
+double opt_mesh_bdf_element_pid(OPT_ARGS_NUM);
double opt_mesh_nb_smoothing(OPT_ARGS_NUM);
double opt_mesh_algo2d(OPT_ARGS_NUM);
double opt_mesh_algo3d(OPT_ARGS_NUM);
diff -rup ./gmsh-2.4.0-cvs-20090730-orig/Fltk/fileDialogs.cpp ./gmsh-2.4.0-cvs-20090730/Fltk/fileDialogs.cpp
--- ./gmsh-2.4.0-cvs-20090730-orig/Fltk/fileDialogs.cpp 2009-06-02 01:03:11.000000000 +0300
+++ ./gmsh-2.4.0-cvs-20090730/Fltk/fileDialogs.cpp 2009-08-17 16:17:52.384710170 +0300
@@ -853,6 +853,7 @@ int bdf_dialog(const char *name)
struct _bdf_dialog{
Fl_Window *window;
Fl_Choice *c;
+ Fl_Choice *d;
Fl_Check_Button *b;
Fl_Button *ok, *cancel;
};
@@ -865,17 +866,28 @@ int bdf_dialog(const char *name)
{0}
};
- int BBB = BB + 9; // labels too long
+ static Fl_Menu_Item pidmenu[] = {
+ {"by element type", 0, 0, 0},
+ {"by elementary entity", 0, 0, 0},
+ {"by physical entity", 0, 0, 0},
+ {"by partition", 0, 0, 0},
+ {0}
+ };
+
+ int BBB = BB + 19; // labels too long
if(!dialog){
dialog = new _bdf_dialog;
- int h = 3 * WB + 3 * BH, w = 2 * BBB + 3 * WB, y = WB;
+ int h = 6 * WB + 3 * BH, w = 2 * BBB + 6 * WB, y = WB;
dialog->window = new Fl_Double_Window(w, h, "BDF Options");
dialog->window->box(GMSH_WINDOW_BOX);
dialog->window->set_modal();
dialog->c = new Fl_Choice(WB, y, BBB + BBB / 2, BH, "Format"); y += BH;
dialog->c->menu(formatmenu);
dialog->c->align(FL_ALIGN_RIGHT);
+ dialog->d = new Fl_Choice(WB, y, BBB + BBB / 2, BH, "Element PID"); y += BH;
+ dialog->d->menu(pidmenu);
+ dialog->d->align(FL_ALIGN_RIGHT);
dialog->b = new Fl_Check_Button
(WB, y, 2 * BBB + WB, BH, "Save all (ignore physical groups)"); y += BH;
dialog->b->type(FL_TOGGLE_BUTTON);
@@ -886,6 +898,7 @@ int bdf_dialog(const char *name)
}
dialog->c->value(CTX::instance()->mesh.bdfFieldFormat);
+ dialog->d->value(CTX::instance()->mesh.bdfElementPID);
dialog->b->value(CTX::instance()->mesh.saveAll ? 1 : 0);
dialog->window->show();
@@ -896,6 +909,7 @@ int bdf_dialog(const char *name)
if (!o) break;
if (o == dialog->ok) {
opt_mesh_bdf_field_format(0, GMSH_SET | GMSH_GUI, dialog->c->value());
+ opt_mesh_bdf_element_pid(0, GMSH_SET | GMSH_GUI, dialog->d->value());
opt_mesh_save_all(0, GMSH_SET | GMSH_GUI, dialog->b->value() ? 1 : 0);
CreateOutputFile(name, FORMAT_BDF);
dialog->window->hide();
diff -rup ./gmsh-2.4.0-cvs-20090730-orig/Geo/GModel.h ./gmsh-2.4.0-cvs-20090730/Geo/GModel.h
--- ./gmsh-2.4.0-cvs-20090730-orig/Geo/GModel.h 2009-07-08 01:03:14.000000000 +0300
+++ ./gmsh-2.4.0-cvs-20090730/Geo/GModel.h 2009-08-17 16:18:15.624713573 +0300
@@ -356,7 +356,7 @@ class GModel
// Nastran Bulk Data File format
int readBDF(const std::string &name);
- int writeBDF(const std::string &name, int format=0,
+ int writeBDF(const std::string &name, int format=0, int pidType=1,
bool saveAll=false, double scalingFactor=1.0);
// Plot3D structured mesh format
diff -rup ./gmsh-2.4.0-cvs-20090730-orig/Geo/GModelIO_Mesh.cpp ./gmsh-2.4.0-cvs-20090730/Geo/GModelIO_Mesh.cpp
--- ./gmsh-2.4.0-cvs-20090730-orig/Geo/GModelIO_Mesh.cpp 2009-07-17 01:03:16.000000000 +0300
+++ ./gmsh-2.4.0-cvs-20090730/Geo/GModelIO_Mesh.cpp 2009-08-17 16:19:39.992710977 +0300
@@ -1852,7 +1852,7 @@ int GModel::readBDF(const std::string &n
return 1;
}
-int GModel::writeBDF(const std::string &name, int format, bool saveAll,
+int GModel::writeBDF(const std::string &name, int format, int pidType, bool saveAll,
double scalingFactor)
{
FILE *fp = fopen(name.c_str(), "w");
@@ -1876,10 +1876,24 @@ int GModel::writeBDF(const std::string &
entities[i]->mesh_vertices[j]->writeBDF(fp, format, scalingFactor);
// elements
+ int pid = 1;
for(unsigned int i = 0; i < entities.size(); i++)
for(unsigned int j = 0; j < entities[i]->getNumMeshElements(); j++)
- if(saveAll || entities[i]->physicals.size())
- entities[i]->getMeshElement(j)->writeBDF(fp, format, entities[i]->tag());
+ if(saveAll || entities[i]->physicals.size()){
+ if (pidType == 0){
+ pid = entities[i]->getMeshElement(j)->getType();
+ }
+ else if (pidType == 1){
+ pid = entities[i]->tag();
+ }
+ else if (pidType == 2){
+ pid = entities[i]->physicals[0]; //FIXME
+ }
+ else if (pidType == 3){
+ pid = entities[i]->getMeshElement(j)->getPartition();
+ }
+ entities[i]->getMeshElement(j)->writeBDF(fp, format, pid);
+ }
fprintf(fp, "ENDDATA\n");
diff -rup ./gmsh-2.4.0-cvs-20090730-orig/Geo/MElement.cpp ./gmsh-2.4.0-cvs-20090730/Geo/MElement.cpp
--- ./gmsh-2.4.0-cvs-20090730-orig/Geo/MElement.cpp 2009-07-17 01:03:17.000000000 +0300
+++ ./gmsh-2.4.0-cvs-20090730/Geo/MElement.cpp 2009-08-17 16:20:16.404710549 +0300
@@ -587,7 +587,7 @@ void MElement::writeMESH(FILE *fp, int e
fprintf(fp, " %d\n", elementary);
}
-void MElement::writeBDF(FILE *fp, int format, int elementary)
+void MElement::writeBDF(FILE *fp, int format, int pid)
{
const char *str = getStringForBDF();
if(!str) return;
@@ -598,7 +598,7 @@ void MElement::writeBDF(FILE *fp, int fo
int ncont = 0;
if(format == 0){ // free field format
- fprintf(fp, "%s,%d,%d", str, _num, elementary);
+ fprintf(fp, "%s,%d,%d", str, _num, pid);
for(int i = 0; i < n; i++){
fprintf(fp, ",%d", getVertexBDF(i)->getIndex());
if(i != n - 1 && !((i + 3) % 8)){
@@ -611,7 +611,7 @@ void MElement::writeBDF(FILE *fp, int fo
fprintf(fp, "\n");
}
else{ // small or large field format
- fprintf(fp, "%-8s%-8d%-8d", str, _num, elementary);
+ fprintf(fp, "%-8s%-8d%-8d", str, _num, pid);
for(int i = 0; i < n; i++){
fprintf(fp, "%-8d", getVertexBDF(i)->getIndex());
if(i != n - 1 && !((i + 3) % 8)){
diff -rup ./gmsh-2.4.0-cvs-20090730-orig/Geo/MElement.h ./gmsh-2.4.0-cvs-20090730/Geo/MElement.h
--- ./gmsh-2.4.0-cvs-20090730-orig/Geo/MElement.h 2009-07-17 01:03:17.000000000 +0300
+++ ./gmsh-2.4.0-cvs-20090730/Geo/MElement.h 2009-07-31 00:58:01.947862664 +0300
@@ -227,7 +227,7 @@ class MElement
virtual void writeUNV(FILE *fp, int num=0, int elementary=1, int physical=1);
virtual void writeVTK(FILE *fp, bool binary=false, bool bigEndian=false);
virtual void writeMESH(FILE *fp, int elementary=1);
- virtual void writeBDF(FILE *fp, int format=0, int elementary=1);
+ virtual void writeBDF(FILE *fp, int format=0, int pid=1);
virtual void writeDIFF(FILE *fp, int num, bool binary=false, int physical_property=1);
// info for specific IO formats (returning 0 means that the element
_______________________________________________
gmsh mailing list
[email protected]
http://www.geuz.org/mailman/listinfo/gmsh