test/parallel-fem.cpp

00001 #include "DAPTA.hpp"
00002 
00003 #include <set>
00004 #include <fstream>
00005 #include <iostream>
00006 #include <iomanip>
00007 #undef SEEK_SET
00008 #undef SEEK_CUR
00009 #undef SEEK_END
00010 #include "mpi.h"
00011 using namespace DAPTA;
00012 
00013 typedef Mesh<Tri3MeshTraits> TriMesh;
00014 typedef MeshParalleliser<Tri3MeshTraits> TriMeshParalleliser;
00015 
00016 int main(int argc, char **argv) {
00017    // Initialize MPI
00018    MPI_Init(&argc, &argv);
00019    MPI_Status status;
00020    
00021    // Load in the complete mesh
00022    TriMesh *mesh = new TriMesh();
00023    mesh->ClearMesh();
00024    std::ifstream meshfile;
00025    meshfile.open(argv[1]);
00026    if(!meshfile) {
00027       std::cout << "ERROR READING FILE!" << std::endl;
00028       exit(1);
00029    }
00030    mesh->ReadFile(meshfile);
00031    meshfile.close();
00032    
00033    TriMeshParalleliser *mesh_paralleliser = new TriMeshParalleliser(MPI_COMM_WORLD, mesh);
00034    mesh_paralleliser->initialiseCommunication();
00035    
00036    // ********************
00037    // * BEGIN FEM CODE
00038    // ********************
00039    
00040    int myRank, numProcs;
00041    MPI_Comm_rank(MPI_COMM_WORLD, &myRank);
00042    MPI_Comm_size(MPI_COMM_WORLD, &numProcs);
00043    
00044    int timestep=1;
00045    
00046    while(true) {
00047       if(myRank == 0) {
00048          std::cout << "STEP: " << timestep << std::endl;
00049       }
00050       
00051       for(TriMesh::ElementMapIterator e_iter=mesh->ElementMapBegin(); e_iter!=mesh->ElementMapEnd(); ++e_iter) {
00052       }
00053       
00054       timestep++;
00055       sleep(1);
00056    }
00057    
00058    // ********************
00059    // * END FEM CODE
00060    // ********************
00061    
00062    // Shut Down MPI
00063    MPI_Finalize();
00064    
00065    return 0;
00066 }

Generated on Tue May 29 17:13:49 2007 for DAPTA by  doxygen 1.5.1