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
00031
00032
00033
00034
00035
00036 #include <X11Renderer.h>
00037 #include <DofColorMap.h>
00038
00039 #define numP 8
00040
00041 #define BLAS_EXISTS 1
00042
00043
00044 #include <stdlib.h>
00045 #include <iOPS_Stream.h>
00046
00047 #include <Timer.h>
00048 #include <TrianglePlaneStress.h>
00049
00050 #include <Node.h>
00051 #include <Domain.h>
00052
00053 #include <AnalysisModel.h>
00054
00055 #include <Linear.h>
00056 #include <NewtonRaphson.h>
00057
00058 #include <PlainHandler.h>
00059 #include <PenaltyConstraintHandler.h>
00060
00061 #include <PlainNumberer.h>
00062 #include <DOF_Numberer.h>
00063
00064 #include <StaticIntegrator.h>
00065 #include <LoadControl.h>
00066
00067 #include <CTestNormUnbalance.h>
00068 #include <CTestNormDispIncr.h>
00069 #include <CTestEnergyIncr.h>
00070
00071 #include <StaticAnalysis.h>
00072
00073 #include <SlowLinearSOE.h>
00074 #include <SlowLinearSOESolver.h>
00075 #include <ProfileSPDLinSOE.h>
00076 #include <ProfileSPDLinDirectSolver.h>
00077 #include <ProfileSPDLinDirectBlockSolver.h>
00078
00079 #ifdef BLAS_EXISTS
00080 #include <BandSPDLinSOE.h>
00081 #include <BandSPDLinLapackSolver.h>
00082 #include <BandGenLinSOE.h>
00083 #include <BandGenLinLapackSolver.h>
00084 #include <FullGenLinSOE.h>
00085 #include <FullGenLinLapackSolver.h>
00086 #include <ProfileSPDLinDirectThreadSolver.h>
00087 #include <ProfileSPDLinDirectSkypackSolver.h>
00088 #include <SparseGenLinSOE.h>
00089 #include <SparseGenSuperLuSolver.h>
00090 #include <SparseGenSuperLuThreadSolver.h>
00091 #endif
00092
00093 #ifdef PETSC_EXISTS
00094 #include <PetscSOE.h>
00095 #include <PetscSolver.h>
00096 #include <mpi.h>
00097 #endif
00098
00099 #include <Graph.h>
00100 #include <RCM.h>
00101 #include <Metis.h>
00102
00103 int main(int argc, char **argv)
00104 {
00105
00106
00107
00108
00109
00110
00111
00112 int numReps;
00113 opserr << "Enter Number of Iterations: ";
00114 cin >> numReps;
00115
00116 #ifdef PETSC_EXISTS
00117 int numP;
00118 int me;
00119 MPI_Init(&argc, &argv);
00120 MPI_Comm_rank(MPI_COMM_WORLD, &me);
00121 MPI_Comm_size(MPI_COMM_WORLD, &numP);
00122 static char help[] = "My daft little program\n";
00123 PetscInitialize(&argc, &argv, (char *)0, help);
00124 #endif
00125
00126
00127
00128
00129
00130
00131 Domain *theDomain = new Domain();
00132 TrianglePlaneStress *theModelBuilder
00133 = new TrianglePlaneStress(*theDomain);
00134 theModelBuilder->buildFE_Model();
00135
00136
00137 theModelBuilder->fixNodeXdirnXloc(100.0,0.0);
00138 theModelBuilder->fixNodeYdirnYloc(100.0,0.0);
00139
00140 theModelBuilder->addPointLoad(0.0,100.0, -50.0, 0.0);
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152 AnalysisModel *theModel = new AnalysisModel();
00153 EquiSolnAlgo *theSolnAlgo = new Linear();
00154 ConvergenceTest *theTest = new CTestNormUnbalance(1.0e-8);
00155
00156 StaticIntegrator *theIntegrator = new LoadControl(1);
00157
00158 ConstraintHandler *theHandler;
00159 cout << "Enter ConstraintHandler type: [1]-Plain, [2]-Penalty: ";
00160 int handlerType;
00161 cin >> handlerType;
00162 if (handlerType == 1)
00163 theHandler = new PlainHandler();
00164 else
00165 theHandler = new PenaltyConstraintHandler(1.0e16,1.0e16);
00166
00167
00168 cout << "[1]-RCM, [2]-Metis : ";
00169 int numType;
00170 cin >> numType;
00171
00172 DOF_Numberer *theNumberer;
00173 GraphNumberer *theGN;
00174 if (numType == 1) {
00175 theGN = new RCM;
00176 theNumberer = new DOF_Numberer(*theGN);
00177 } else {
00178 theGN = new Metis(numP);
00179 theNumberer = new DOF_Numberer(*theGN);
00180 }
00181
00182
00183 LinearSOE *theSOE;
00184
00185 #ifdef PETSC_EXISTS
00186 cout << "Enter SystemOfEquation type: [1]-FullGen, [2]-BandGen, ";
00187 cout << "[3]-BandSPD, [4]-ProfileSPD, [5]-SparseGEN, [6]-Petsc : ";
00188 int soeType;
00189 cin >> soeType;
00190 if (soeType == 1) {
00191 FullGenLinSolver *theSolver = new FullGenLinLapackSolver();
00192 theSOE = new FullGenLinSOE(*theSolver);
00193 } else if (soeType == 2) {
00194 BandGenLinSolver *theSolver = new BandGenLinLapackSolver();
00195 theSOE = new BandGenLinSOE(*theSolver);
00196 } else if (soeType == 3) {
00197 BandSPDLinSolver *theSolver = new BandSPDLinLapackSolver();
00198 theSOE = new BandSPDLinSOE(*theSolver);
00199 } else if (soeType == 4) {
00200
00201 ProfileSPDLinSolver *theSolver;
00202 cout << "Enter Solver Type: [1]-Normal, [2]-Block, [3]-Skypack: ";
00203 int solverType;
00204 cin >> solverType;
00205 if (solverType == 1)
00206 theSolver = new ProfileSPDLinDirectSolver();
00207 else if (solverType == 2) {
00208 cout << "Enter blockSize: ";
00209 int blockSize;
00210 cin >> blockSize;
00211 theSolver = new ProfileSPDLinDirectBlockSolver(1.0e-12,blockSize);
00212 } else {
00213 cout << "Enter mRows, mCols [e.g. 64 128] ";
00214 int mRows, mCols;
00215 cin >> mRows >> mCols;
00216 theSolver = new ProfileSPDLinDirectSkypackSolver(mCols, mRows);
00217 }
00218 theSOE = new ProfileSPDLinSOE(*theSolver);
00219 }
00220 else if (soeType == 5) {
00221
00222
00223
00224 cout << "Enter Ordering [0]: natural, [1]-min Degree A^tA ";
00225 cout << "[2]-min Degree A^t+A: ";
00226 int perm;
00227 cin >> perm;
00228 SparseGenLinSolver *
00229 theSolver = new SparseGenSuperLuSolver(perm,3,3,0.0);
00230
00231
00232 theSOE = new SparseGenLinSOE(*theSolver);
00233 }
00234 else {
00235 PetscSolver *theSolver = new PetscSolver(KSPCG, PCJACOBI);
00236 theSOE = new PetscSOE(*theSolver);
00237
00238 }
00239 #endif
00240
00241 #ifdef BLAS_EXISTS
00242 cout << "Enter SystemOfEquation type: [1]-FullGen, [2]-BandGen, ";
00243 cout << "[3]-BandSPD, [4]-ProfileSPD, [5]-SparseGEN : ";
00244 int soeType;
00245 cin >> soeType;
00246 if (soeType == 1) {
00247 FullGenLinSolver *theSolver = new FullGenLinLapackSolver();
00248 theSOE = new FullGenLinSOE(*theSolver);
00249 } else if (soeType == 2) {
00250 BandGenLinSolver *theSolver = new BandGenLinLapackSolver();
00251 theSOE = new BandGenLinSOE(*theSolver);
00252 } else if (soeType == 3) {
00253 BandSPDLinSolver *theSolver = new BandSPDLinLapackSolver();
00254 theSOE = new BandSPDLinSOE(*theSolver);
00255 } else if (soeType == 4) {
00256
00257 ProfileSPDLinSolver *theSolver;
00258 cout << "Enter Solver Type: [1]-Normal, [2]-Block, [3]-Skypack: ";
00259 int solverType;
00260 cin >> solverType;
00261 if (solverType == 1)
00262 theSolver = new ProfileSPDLinDirectSolver();
00263 else if (solverType == 2) {
00264 cout << "Enter blockSize: ";
00265 int blockSize;
00266 cin >> blockSize;
00267 theSolver = new ProfileSPDLinDirectBlockSolver(1.0e-12,blockSize);
00268 } else {
00269 cout << "Enter mRows, mCols [e.g. 64 128] ";
00270 int mRows, mCols;
00271 cin >> mRows >> mCols;
00272 theSolver = new ProfileSPDLinDirectSkypackSolver(mCols, mRows);
00273 }
00274 theSOE = new ProfileSPDLinSOE(*theSolver);
00275 }
00276 else {
00277
00278
00279
00280 cout << "Enter Ordering [0]: natural, [1]-min Degree A^tA ";
00281 cout << "[2]-min Degree A^t+A: ";
00282 int perm;
00283 cin >> perm;
00284 SparseGenLinSolver *
00285 theSolver = new SparseGenSuperLuSolver(perm,3,3,0.0);
00286
00287
00288 theSOE = new SparseGenLinSOE(*theSolver);
00289 }
00290 #endif
00291
00292
00293
00294 StaticAnalysis theAnalysis(*theDomain,
00295 *theHandler,
00296 *theNumberer,
00297 *theModel,
00298 *theSolnAlgo,
00299 *theSOE,
00300 *theIntegrator);
00301
00302
00303
00304
00305
00306 Timer timer;
00307 Timer timer1;
00308
00309 timer.start();
00310 timer1.start();
00311
00312
00313 for (int j=0; j<numReps; j++) {
00314 timer.start();
00315 theAnalysis.analyze();
00316 timer.pause();
00317 theSolnAlgo->Print(opserr);
00318 timer1.pause();
00319 cout << "Main::Time To Analyse Rep: " <<
00320 j+1 << " real: " << timer.getReal();
00321 cout << " cpu: " << timer.getCPU() <<
00322 " page: " << timer.getNumPageFaults() << endln;
00323 cout << "Main::Time Since Start: "
00324 << j+1 << " real: " << timer1.getReal();
00325 cout << " cpu: " << timer1.getCPU()
00326 << " page: " << timer1.getNumPageFaults() << endln;
00327
00328 }
00329
00330
00331
00332
00333 Node *theNode = theDomain->getNode(2);
00334 if (theNode != 0) {
00335 opserr << *theNode;
00336 }
00337
00338
00339
00340
00341 DofColorMap theMap(theSOE->getNumEqn(),numP);
00342 WindowRenderer *theViewer = new X11Renderer(600,600,*theDomain, theMap);
00343 theViewer->setPRP(50, 50, 100);
00344 theViewer->setVRP(50, 50, 0);
00345 theViewer->setVUP(0,1,0);
00346 theViewer->setVPN(0,0,1);
00347 theViewer->setViewWindow(-5,105,-5, 105);
00348 theViewer->setPlaneDist(0,150);
00349 theViewer->setPortWindow(-1,1,-1, 1);
00350 theViewer->setProjectionMode(0);
00351 theViewer->setFillMode(1);
00352
00353 theViewer->displayModel(0,0);
00354
00355 int data;
00356 cin >> data;
00357
00358 #ifdef PETSC_EXISTS
00359 MPI_Finalize();
00360 PetscFinalize();
00361 #endif
00362 exit(0);
00363 }
00364