MOAB: Mesh Oriented datABase  (version 5.2.1)
tqdcfr_test.cpp
Go to the documentation of this file.
00001 /**
00002  * MOAB, a Mesh-Oriented datABase, is a software component for creating,
00003  * storing and accessing finite element mesh data.
00004  *
00005  * Copyright 2004 Sandia Corporation.  Under the terms of Contract
00006  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
00007  * retains certain rights in this software.
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 2.1 of the License, or (at your option) any later version.
00013  *
00014  */
00015 
00016 #include "Tqdcfr.hpp"
00017 #include "moab/Core.hpp"
00018 #include "moab/Range.hpp"
00019 #include "moab/FileOptions.hpp"
00020 #include "TestUtil.hpp"
00021 #include <iostream>
00022 #include <string>
00023 
00024 #ifdef MOAB_HAVE_MPI
00025 #include "moab_mpi.h"
00026 #endif
00027 
00028 using namespace moab;
00029 
00030 int main( int argc, char* argv[] )
00031 {
00032 #ifdef MOAB_HAVE_MPI
00033     MPI_Init( &argc, &argv );
00034 #endif
00035     // Check command line arg
00036     std::string def_file( TestDir + "/io/brick_cubit10.2.cub" );
00037     const char* file = def_file.c_str();
00038     if( argc < 2 )
00039     {
00040         std::cout << "Usage: tqdcfr <cub_file_name>" << std::endl;
00041         // exit(1);
00042     }
00043     else
00044         file = argv[1];
00045 
00046     Core* my_impl  = new Core();
00047     Tqdcfr* my_tqd = new Tqdcfr( my_impl );
00048     FileOptions opts( NULL );
00049 
00050     ErrorCode result = my_tqd->load_file( file, 0, opts, 0, 0 );
00051 
00052     if( MB_SUCCESS == result )
00053         std::cout << "Success." << std::endl;
00054     else
00055     {
00056         std::cout << "load_file returned error:" << std::endl;
00057         std::string errs;
00058         result = my_impl->get_last_error( errs );
00059         if( MB_SUCCESS == result )
00060             std::cout << errs << std::endl;
00061         else
00062             std::cout << "(no message)" << std::endl;
00063     }
00064 
00065     delete my_tqd;
00066     delete my_impl;
00067 
00068     // now check for multiple procs
00069     my_impl = new Core;
00070     my_tqd  = new Tqdcfr( my_impl );
00071 
00072     result = my_tqd->load_file( file, 0, opts, 0, 0 );
00073 
00074     if( MB_SUCCESS == result )
00075         std::cout << "Success." << std::endl;
00076     else
00077     {
00078         std::cout << "load_file returned error:" << std::endl;
00079         std::string errstr;
00080         result = my_impl->get_last_error( errstr );
00081         if( MB_SUCCESS == result )
00082             std::cout << errstr << std::endl;
00083         else
00084             std::cout << "(no message)" << std::endl;
00085     }
00086 
00087     delete my_tqd;
00088     delete my_impl;
00089 
00090 #ifdef MOAB_HAVE_MPI
00091     int nprocs, rank;
00092     MPI_Comm_size( MPI_COMM_WORLD, &nprocs );
00093     MPI_Comm_rank( MPI_COMM_WORLD, &rank );
00094 
00095     // create MOAB instance based on that
00096     my_impl = new Core;  //(rank, nprocs);
00097     if( NULL == my_impl ) return 1;
00098 
00099     std::string options = "PARALLEL=READ_DELETE;PARTITION=MATERIAL_SET;PARTITION_DISTRIBUTE";
00100     std::cout << "Testing parallel..." << std::endl;
00101 
00102     result = my_impl->load_file( file, 0, options.c_str() );
00103 
00104     if( MB_SUCCESS == result )
00105         std::cout << "Success." << std::endl;
00106     else
00107     {
00108         std::cout << "load_file returned error:" << std::endl;
00109         std::string errstr;
00110         result = my_impl->get_last_error( errstr );
00111         if( MB_SUCCESS == result )
00112             std::cout << errstr << std::endl;
00113         else
00114             std::cout << "(no message)" << std::endl;
00115     }
00116 
00117     delete my_impl;  // done with the read
00118     MPI_Finalize();
00119 #endif
00120 
00121     return result;
00122 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines