00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifdef IPPL_USE_STANDARD_HEADERS
00031 #include <iostream>
00032 using namespace std;
00033 #else
00034 #include <iostream.h>
00035 #endif
00036
00037 #include <vtk.h>
00038 #include "Profile/Profiler.h"
00039
00040 float Pr = 10.0;
00041 float b = 2.667;
00042 float r = 28.0;
00043 float x, y, z;
00044 float h = 0.01;
00045 int resolution=200;
00046
00047 int iter = 100;
00048 float xmin = -30.0;
00049 float xmax = 30.0;
00050 float ymin = -30.0;
00051 float ymax = 30.0;
00052 float zmin = -10.0;
00053 float zmax = 60.0;
00054
00055 int randomMode = 1;
00056 float xIncr, yIncr, zIncr;
00057 short *slice;
00058
00059 void Lorenz(vtkStructuredPoints *vizdata, float Pr) {
00060 TAU_PROFILE("Lorenz()", "void (vtkStructuredPoints *, float)", TAU_VIZ);
00061
00062 vtkShortScalars *scalars;
00063
00064 int i, j;
00065 float xx, yy, zz;
00066 short xxx, yyy, zzz;
00067 int sliceSize;
00068
00069 short *s;
00070 void options(int, char**);
00071 int numPts, index;
00072 vtkMath math;
00073
00074
00075 xIncr = resolution / (xmax - xmin);
00076 yIncr = resolution / (ymax - ymin);
00077 zIncr = resolution / (zmax - zmin);
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091 x = math.Random(xmin,xmax);
00092 y = math.Random(ymin,ymax);
00093 z = math.Random(zmin,zmax);
00094
00095
00096
00097 sliceSize = resolution * resolution;
00098 numPts = sliceSize * resolution;
00099 scalars = new vtkShortScalars(numPts);
00100
00101 s = scalars->WritePtr(0,numPts);
00102 for (i=0; i < numPts; i++) s[i] = 0;
00103
00104
00105 for (j = 0; j < iter; j++)
00106 {
00107
00108 xx = x + h * Pr * (y - x);
00109 yy = y + h * (x * (r - z) - y);
00110 zz = z + h * (x * y - (b * z));
00111
00112 x = xx; y = yy; z = zz;
00113
00114
00115 if (x < xmax && x > xmin && y < ymax && y > ymin && z < zmax && z > zmin)
00116 {
00117 xxx = (short) ((float)(xx - xmin) * xIncr);
00118 yyy = (short) ((float)(yy - ymin) * yIncr);
00119 zzz = (short) ((float)(zz - zmin) * zIncr);
00120 index = xxx + yyy*resolution + zzz*sliceSize;
00121 s[index] += 1;
00122 }
00123 }
00124 scalars->WrotePtr();
00125 vizdata->GetPointData()->SetScalars(scalars);
00126 vizdata->SetDimensions(resolution,resolution,resolution);
00127 vizdata->SetOrigin(xmin,ymin,zmin);
00128 vizdata->SetAspectRatio((xmax-xmin)/resolution, (ymax-ymin)/resolution, (zmax-zmin)/resolution);
00129 scalars->Delete();
00130 }
00131
00132
00133 #include "aclvis/ipplstub.h"
00134
00135 ConnectStub::ConnectStub(int type_param) {
00136 TAU_PROFILE("ConnectStub::ConnectStub()", "void (int)", TAU_VIZ);
00137 type = type_param;
00138 if (type == ACLVIS) {
00139 connection = new VizTool();
00140 }
00141 }
00142
00143 int ConnectStub::GetType(){
00144 TAU_PROFILE("ConnectStub::GetType()", "int ()", TAU_VIZ);
00145 return type;
00146 }
00147
00148 void ConnectStub::SetType(int type_param){
00149 TAU_PROFILE("ConnectStub::SetType()", "void (int)", TAU_VIZ);
00150 type = type_param;
00151 }
00152
00153 void *ConnectStub::GetConnection(){
00154 TAU_PROFILE("ConnectStub::GetConnection()", "void ()", TAU_VIZ);
00155 return connection;
00156 }
00157
00158 void ConnectStub::SetConnection(void *connection_param) {
00159 TAU_PROFILE("ConnectStub::SetConnection()", "void (void *)", TAU_VIZ);
00160 connection = connection_param;
00161 }
00162
00163 void FieldStub::connect(ConnectStub *connect_stub_param,
00164 char *name, ConnectDataType ctype){
00165 TAU_PROFILE("FieldStub::connect()", "void (ConnectStub *, char *, ConnectDataType)",
00166 TAU_VIZ);
00167 VizTool *viztool;
00168
00169 connectDataType = ctype;
00170 if (ctype == FieldDataType) {
00171 readtool = new ReadFieldTool;
00172 } else {
00173 readtool = new ReadParticleTool;
00174 }
00175
00176 connect_stub = connect_stub_param;
00177 if (connect_stub->GetType() == ACLVIS) {
00178 viztool = (VizTool *)connect_stub->GetConnection();
00179 viztool->connect(this, name, readtool, ctype);
00180 }
00181 }
00182
00183 void FieldStub::update(float Pr){
00184 TAU_PROFILE("FieldStub::update()", "void (float)", TAU_VIZ);
00185 VizTool *viztool;
00186
00187 if (connectDataType == FieldDataType) {
00188 ReadFieldTool *readFieldTool;
00189 readFieldTool = (ReadFieldTool *)readtool;
00190 Lorenz(readFieldTool->GetOutput(),Pr);
00191 }
00192
00193
00194 if (connect_stub->GetType() == ACLVIS) {
00195 viztool = (VizTool *)connect_stub->GetConnection();
00196 viztool->update(this);
00197 }
00198 }
00199
00200 void FieldStub::interact(int flag){
00201 TAU_PROFILE("FieldStub::interact()", "void (int)", TAU_VIZ);
00202 VizTool *viztool;
00203
00204 if (connect_stub->GetType() == ACLVIS) {
00205
00206 viztool = (VizTool *)connect_stub->GetConnection();
00207 viztool->Interact(flag);
00208 }
00209 }
00210
00211 void FieldStub::disconnect(){
00212 TAU_PROFILE("FieldStub::disconnect()", "void ()", TAU_VIZ);
00213 VizTool *viztool;
00214
00215 if (connect_stub->GetType() == ACLVIS) {
00216 viztool = (VizTool *)connect_stub->GetConnection();
00217 viztool->disconnect(this);
00218 }
00219 }
00220
00221
00222
00223
00224
00225
00226