MOAB: Mesh Oriented datABase  (version 5.5.0)
tqdcfr_test.cpp File Reference
#include "Tqdcfr.hpp"
#include "moab/Core.hpp"
#include "moab/Range.hpp"
#include "moab/FileOptions.hpp"
#include "TestUtil.hpp"
#include <iostream>
#include <string>
+ Include dependency graph for tqdcfr_test.cpp:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 30 of file tqdcfr_test.cpp.

31 {
32 #ifdef MOAB_HAVE_MPI
33  MPI_Init( &argc, &argv );
34 #endif
35  // Check command line arg
36  std::string def_file( TestDir + "unittest/io/brick_cubit10.2.cub" );
37  const char* file = def_file.c_str();
38  if( argc < 2 )
39  {
40  std::cout << "Usage: tqdcfr <cub_file_name>" << std::endl;
41  // exit(1);
42  }
43  else
44  file = argv[1];
45 
46  Core* my_impl = new Core();
47  Tqdcfr* my_tqd = new Tqdcfr( my_impl );
48  FileOptions opts( NULL );
49 
50  ErrorCode result = my_tqd->load_file( file, 0, opts, 0, 0 );
51 
52  if( MB_SUCCESS == result )
53  std::cout << "Success." << std::endl;
54  else
55  {
56  std::cout << "load_file returned error:" << std::endl;
57  std::string errs;
58  result = my_impl->get_last_error( errs );
59  if( MB_SUCCESS == result )
60  std::cout << errs << std::endl;
61  else
62  std::cout << "(no message)" << std::endl;
63  }
64 
65  delete my_tqd;
66  delete my_impl;
67 
68  // now check for multiple procs
69  my_impl = new Core;
70  my_tqd = new Tqdcfr( my_impl );
71 
72  result = my_tqd->load_file( file, 0, opts, 0, 0 );
73 
74  if( MB_SUCCESS == result )
75  std::cout << "Success." << std::endl;
76  else
77  {
78  std::cout << "load_file returned error:" << std::endl;
79  std::string errstr;
80  result = my_impl->get_last_error( errstr );
81  if( MB_SUCCESS == result )
82  std::cout << errstr << std::endl;
83  else
84  std::cout << "(no message)" << std::endl;
85  }
86 
87  delete my_tqd;
88  delete my_impl;
89 
90 #ifdef MOAB_HAVE_MPI
91  int nprocs, rank;
92  MPI_Comm_size( MPI_COMM_WORLD, &nprocs );
93  MPI_Comm_rank( MPI_COMM_WORLD, &rank );
94 
95  // create MOAB instance based on that
96  my_impl = new Core; //(rank, nprocs);
97  if( NULL == my_impl ) return 1;
98 
99  std::string options = "PARALLEL=READ_DELETE;PARTITION=MATERIAL_SET;PARTITION_DISTRIBUTE";
100  std::cout << "Testing parallel..." << std::endl;
101 
102  result = my_impl->load_file( file, 0, options.c_str() );
103 
104  if( MB_SUCCESS == result )
105  std::cout << "Success." << std::endl;
106  else
107  {
108  std::cout << "load_file returned error:" << std::endl;
109  std::string errstr;
110  result = my_impl->get_last_error( errstr );
111  if( MB_SUCCESS == result )
112  std::cout << errstr << std::endl;
113  else
114  std::cout << "(no message)" << std::endl;
115  }
116 
117  delete my_impl; // done with the read
118  MPI_Finalize();
119 #endif
120 
121  return result;
122 }

References ErrorCode, moab::Core::get_last_error(), moab::Tqdcfr::load_file(), moab::Core::load_file(), MB_SUCCESS, MPI_COMM_WORLD, and rank.