[Gmsh] Two modification patches to gmsh-2.0.7
OSHIMA Takuya
oshima at eng.niigata-u.ac.jp
Fri May 18 06:19:30 CEST 2007
Hello,
I'm attaching two small patches to gmsh-2.0.7 in the hope that someone
might find them useful.
StreamLines.patch: is a very simple hack to the Stream Lines plugin
that draws stream lines over an unsteady multistep view. If the
traveling time of particles (DT * iter) exceeds the final time in the
view, the final step field will be used until the end.
StepButtons.patch: adds "step backward" and "step forward" buttons at
the bottom of the graphics window. They do what they are supposed to
do for postprocessing views, except if the "Cycle through views
instead of time steps" option is set they cycle through views.
Cheers,
Takukya
-------------- next part --------------
--- gmsh-2.0.7/Plugin/StreamLines.cpp 2007-01-24 19:54:26.000000000 +0900
+++ gmsh-2.0.7.new/Plugin/StreamLines.cpp 2007-05-18 09:17:27.000000000 +0900
@@ -282,10 +282,31 @@
List_Add(View->VP, &X[2]);
}
+ int currentTimeStep = 0;
for(int iter = 0; iter < (int)StreamLinesOptions_Number[11].def; iter++){
double XPREV[3] = { X[0], X[1], X[2] };
+ // use the final timestep view for currentT later than the final time
+ const double currentT = DT * iter;
+ if(v1->Time->size == sizeof(float))
+ for(; currentTimeStep < v1->NbTimeStep - 1
+ && currentT > 0.5
+ * (*reinterpret_cast<float *>
+ (List_Pointer(v1->Time, currentTimeStep))
+ + *reinterpret_cast<float *>
+ (List_Pointer(v1->Time, currentTimeStep + 1)));
+ currentTimeStep++);
+ else if(v1->Time->size == sizeof(double))
+ for(; currentTimeStep < v1->NbTimeStep - 1
+ && currentT > 0.5
+ * (*reinterpret_cast<double *>
+ (List_Pointer(v1->Time, currentTimeStep))
+ + *reinterpret_cast<double *>
+ (List_Pointer(v1->Time, currentTimeStep + 1)));
+ currentTimeStep++);
+ //Msg(DEBUG, "iter = %d, currentTimeStep = %d", iter, currentTimeStep);
+
// dX/dt = V
// X1 = X + a1 * DT * V(X)
// X2 = X + a2 * DT * V(X1)
@@ -297,13 +318,13 @@
// double normV = sqrt(val[0]*val[0]+val[1]*val[1]+val[2]*val[2]);
// if (normV==0.0) normV = 1.0;
// double DT = sizeElem / normV ; // CFL = 1 ==> secure
- o.searchVector(X[0], X[1], X[2], val, 0);
+ o.searchVector(X[0], X[1], X[2], val, currentTimeStep);
for(int k = 0; k < 3; k++) X1[k] = X[k] + DT * val[k] * a1;
- o.searchVector(X1[0], X1[1], X1[2], val, 0);
+ o.searchVector(X1[0], X1[1], X1[2], val, currentTimeStep);
for(int k = 0; k < 3; k++) X2[k] = X[k] + DT * val[k] * a2;
- o.searchVector(X2[0], X2[1], X2[2], val, 0);
+ o.searchVector(X2[0], X2[1], X2[2], val, currentTimeStep);
for(int k = 0; k < 3; k++) X3[k] = X[k] + DT * val[k] * a3;
- o.searchVector(X3[0], X3[1], X3[2], val, 0);
+ o.searchVector(X3[0], X3[1], X3[2], val, currentTimeStep);
for(int k = 0; k < 3; k++) X4[k] = X[k] + DT * val[k] * a4;
for(int k = 0; k < 3; k++)
-------------- next part --------------
--- gmsh-2.0.7/Fltk/Bitmaps.h 2007-01-24 19:54:26.000000000 +0900
+++ gmsh-2.0.7.new/Fltk/Bitmaps.h 2007-05-18 09:46:46.000000000 +0900
@@ -89,4 +89,18 @@
0x02, 0x04, 0x02, 0x00, 0x24, 0x00, 0x68, 0x00, 0xf0, 0x00, 0x60, 0x00,
0x20, 0x00 };
+// 'Step backward button' bitmap
+#define stepbackward_width 12
+#define stepbackward_height 13
+static char stepbackward_bits[] = {
+ 0x00,0xf0,0xc0,0xf6,0x20,0xf5,0x90,0xf4,0x48,0xf4,0x24,0xf4,0x12,0xf4,0x24,
+ 0xf4,0x48,0xf4,0x90,0xf4,0x20,0xf5,0xc0,0xf6,0x00,0xf0};
+
+// 'Step forward button' bitmap
+#define stepforward_width 12
+#define stepforward_height 13
+static char stepforward_bits[] = {
+ 0x00,0xf0,0x36,0xf0,0x4a,0xf0,0x92,0xf0,0x22,0xf1,0x42,0xf2,0x82,0xf4,0x42,
+ 0xf2,0x22,0xf1,0x92,0xf0,0x4a,0xf0,0x36,0xf0,0x00,0xf0};
+
#endif
--- gmsh-2.0.7/Fltk/Callbacks.cpp 2007-04-03 18:40:12.000000000 +0900
+++ gmsh-2.0.7.new/Fltk/Callbacks.cpp 2007-05-13 16:38:30.000000000 +0900
@@ -566,6 +566,16 @@
Draw();
}
+void status_stepbackward_cb(CALLBACK_ARGS)
+{
+ ManualPlay(!CTX.post.anim_cycle, -1);
+}
+
+void status_stepforward_cb(CALLBACK_ARGS)
+{
+ ManualPlay(!CTX.post.anim_cycle, 1);
+}
+
// File Menu
void file_new_cb(CALLBACK_ARGS)
--- gmsh-2.0.7/Fltk/Callbacks.h 2007-01-24 19:54:26.000000000 +0900
+++ gmsh-2.0.7.new/Fltk/Callbacks.h 2007-05-13 14:02:28.000000000 +0900
@@ -42,6 +42,8 @@
void status_play_cb(CALLBACK_ARGS);
void status_pause_cb(CALLBACK_ARGS);
void status_rewind_cb(CALLBACK_ARGS);
+void status_stepbackward_cb(CALLBACK_ARGS);
+void status_stepforward_cb(CALLBACK_ARGS);
// File Menu
--- gmsh-2.0.7/Fltk/GUI.h 2007-01-24 19:54:26.000000000 +0900
+++ gmsh-2.0.7.new/Fltk/GUI.h 2007-05-13 14:09:46.000000000 +0900
@@ -131,7 +131,7 @@
Fl_Scroll *m_scroll;
// Bitmaps
- Fl_Bitmap *abort_bmp, *start_bmp, *stop_bmp, *rewind_bmp, *rotate_bmp, *ortho_bmp;
+ Fl_Bitmap *abort_bmp, *start_bmp, *stop_bmp, *rewind_bmp, *stepbackward_bmp, *stepforward_bmp, *rotate_bmp, *ortho_bmp;
void add_post_plugins(Popup_Button *button , int iView);
void add_multiline_in_browser(Fl_Browser *o, char* prefix, char *str);
@@ -156,7 +156,7 @@
// graphic window
Fl_Window *g_window;
Opengl_Window *g_opengl_window;
- Fl_Button *g_status_butt[10];
+ Fl_Button *g_status_butt[12];
Fl_Box *g_status_label[2];
// Option window
--- gmsh-2.0.7/Fltk/GUI.cpp 2007-03-31 18:38:04.000000000 +0900
+++ gmsh-2.0.7.new/Fltk/GUI.cpp 2007-05-13 14:25:53.000000000 +0900
@@ -1366,6 +1366,15 @@
rewind_bmp->label(g_status_butt[6]);
g_status_butt[6]->deactivate();
+ g_status_butt[10] = new Fl_Button(x, glheight + 2, sw, sht);
+ x += sw;
+ g_status_butt[10]->callback(status_stepbackward_cb);
+ g_status_butt[10]->tooltip("Step backward");
+ stepbackward_bmp = new Fl_Bitmap(stepbackward_bits, stepbackward_width,
+ stepbackward_height);
+ stepbackward_bmp->label(g_status_butt[10]);
+ g_status_butt[10]->deactivate();
+
g_status_butt[7] = new Fl_Button(x, glheight + 2, sw, sht);
x += sw;
g_status_butt[7]->callback(status_play_cb);
@@ -1375,7 +1384,16 @@
stop_bmp = new Fl_Bitmap(stop_bits, stop_width, stop_height);
g_status_butt[7]->deactivate();
- for(int i = 0; i < 10; i++) {
+ g_status_butt[11] = new Fl_Button(x, glheight + 2, sw, sht);
+ x += sw;
+ g_status_butt[11]->callback(status_stepforward_cb);
+ g_status_butt[11]->tooltip("Step forward");
+ stepforward_bmp = new Fl_Bitmap(stepforward_bits, stepforward_width,
+ stepforward_height);
+ stepforward_bmp->label(g_status_butt[11]);
+ g_status_butt[11]->deactivate();
+
+ for(int i = 0; i < 12; i++) {
g_status_butt[i]->box(FL_FLAT_BOX);
g_status_butt[i]->selection_color(FL_WHITE);
g_status_butt[i]->align(FL_ALIGN_CENTER | FL_ALIGN_INSIDE | FL_ALIGN_CLIP);
@@ -1453,10 +1471,14 @@
if(!play) {
g_status_butt[6]->deactivate();
g_status_butt[7]->deactivate();
+ g_status_butt[10]->deactivate();
+ g_status_butt[11]->deactivate();
}
else {
g_status_butt[6]->activate();
g_status_butt[7]->activate();
+ g_status_butt[10]->activate();
+ g_status_butt[11]->activate();
}
}