|
From: <and...@us...> - 2013-11-05 13:48:36
|
Revision: 12653
http://sourceforge.net/p/plplot/code/12653
Author: andrewross
Date: 2013-11-05 13:48:33 +0000 (Tue, 05 Nov 2013)
Log Message:
-----------
Update C example 22 to include a vector plot with a global coordinate transformation to check recent fix. Also include a filled contour plot on this page to check that plshade works ok with global transformations.
This needs discussing on list before propagating to other languages.
Modified Paths:
--------------
trunk/examples/c/x22c.c
Modified: trunk/examples/c/x22c.c
===================================================================
--- trunk/examples/c/x22c.c 2013-11-05 13:47:05 UTC (rev 12652)
+++ trunk/examples/c/x22c.c 2013-11-05 13:48:33 UTC (rev 12653)
@@ -143,7 +143,7 @@
if ( fabs( y ) < b )
{
dbdx = ymax / 4.0 * sin( M_PI * x / xmax ) *
- y / b;
+ M_PI / xmax * y / b;
u[i][j] = Q * ymax / b;
v[i][j] = dbdx * u[i][j];
}
@@ -168,8 +168,99 @@
}
+//
+// Global transform function for a constriction using data passed in
+// This is the same transformation used in constriction.
+//
+void
+transform( PLFLT x, PLFLT y, PLFLT *xt, PLFLT *yt, PLPointer data )
+{
+ PLFLT *trdata;
+ PLFLT xmax;
+ trdata = (PLFLT *) data;
+ xmax = *trdata;
+
+ *xt = x;
+ *yt = y / 4.0 * ( 3 - cos( M_PI * x / xmax ) );
+}
+
+//
+// Vector plot of flow through a constricted pipe
+// with a coordinate transform
+//
void
+constriction2( void )
+{
+ int i, j;
+ PLFLT dx, dy, x, y;
+ PLFLT xmin, xmax, ymin, ymax;
+ PLFLT Q, b, dbdx;
+ PLcGrid2 cgrid2;
+ PLFLT **u, **v;
+ const int nx = 20;
+ const int ny = 20;
+ const int nc = 11;
+ PLFLT clev[nc];
+
+ dx = 1.0;
+ dy = 1.0;
+
+ xmin = -nx / 2 * dx;
+ xmax = nx / 2 * dx;
+ ymin = -ny / 2 * dy;
+ ymax = ny / 2 * dy;
+
+ plstransform(transform, (PLPointer) &xmax);
+
+ plAlloc2dGrid( &cgrid2.xg, nx, ny );
+ plAlloc2dGrid( &cgrid2.yg, nx, ny );
+ plAlloc2dGrid( &u, nx, ny );
+ plAlloc2dGrid( &v, nx, ny );
+
+ cgrid2.nx = nx;
+ cgrid2.ny = ny;
+
+ Q = 2.0;
+ for ( i = 0; i < nx; i++ )
+ {
+ x = ( i - nx / 2 + 0.5 ) * dx;
+ for ( j = 0; j < ny; j++ )
+ {
+ y = ( j - ny / 2 + 0.5 ) * dy;
+ cgrid2.xg[i][j] = x;
+ cgrid2.yg[i][j] = y;
+ b = ymax / 4.0 * ( 3 - cos( M_PI * x / xmax ) );
+ u[i][j] = Q * ymax / b;
+ v[i][j] = 0.0;
+ }
+ }
+
+ for ( i=0; i<nc; i++ ) {
+ clev[i] = Q + i * Q / (nc-1);
+ }
+
+ plenv( xmin, xmax, ymin, ymax, 0, 0 );
+ pllab( "(x)", "(y)", "#frPLplot Example 22 - constriction" );
+ plcol0( 2 );
+ plshades( (const PLFLT * const *) u, nx, ny, NULL,
+ xmin+dx/2, xmax-dx/2, ymin+dy/2, ymax-dy/2,
+ clev, nc, 0, 1, 1.0, plfill, 1, NULL, NULL);
+ plvect( (const PLFLT * const *) u, (const PLFLT * const *) v, nx, ny,
+ -0.5, pltr2, (void *) &cgrid2 );
+ plcol0( 1 );
+
+ plFree2dGrid( cgrid2.xg, nx, ny );
+ plFree2dGrid( cgrid2.yg, nx, ny );
+ plFree2dGrid( u, nx, ny );
+ plFree2dGrid( v, nx, ny );
+
+ plstransform(NULL, NULL);
+
+}
+
+
+void
f2mnmx( PLFLT **f, PLINT nx, PLINT ny, PLFLT *fnmin, PLFLT *fnmax )
{
int i, j;
@@ -336,6 +427,8 @@
plsvect( arrow2_x, arrow2_y, narr, fill );
constriction();
+ constriction2();
+
potential();
plend();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|