This source file includes following definitions.
- name
- main
- print_errMsg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 #include "esfem.h"
19
20 void print_errMsg(const std::exception&);
21 template<typename FEFun>
22 std::string name(const FEFun& fef){
23 constexpr auto base_dir = "/Users/christianpower/cpp/DISS_surfaces/test/";
24 return base_dir + fef.name() + ".dgf";
25 }
26
27 using namespace std;
28
29 int main(int argc, char** argv) try{
30 class {
31 int i {0};
32 public:
33 void operator()(const string& m = "Hello"){
34 clog << m << ' ' << i++ << endl;
35 }
36 } hello;
37
38 const string this_dir {"/Users/christianpower/cpp/DISS_surfaces/test/"};
39
40 Dune::Fem::MPIManager::initialize(argc, argv);
41
42 const auto parameter_file = this_dir + "test_parameter.txt";
43 Esfem::Io::Parameter data {argc, argv, parameter_file};
44
45 const auto dgf_inputFile = this_dir + "input_test00.dgf";
46 const auto dgf_outputFile = "/Users/christianpower/cpp/DISS_surfaces/test/"
47 "output_test00.dgf";
48
49 const Esfem::Io::Dgf::Handler dgf_interpreter {dgf_inputFile};
50 Esfem::Grid::Grid_and_time grid {data};
51 Esfem::Grid::Scal_FEfun fef {"fef", grid};
52 Esfem::Grid::Vec_FEfun vfef {"vfef", grid};
53
54 dgf_interpreter.read(dgf_inputFile, vfef);
55 vfef *= -1.;
56 dgf_interpreter.write(name(vfef), vfef);
57
58 fef += 1.;
59 dgf_interpreter.write(name(fef), fef);
60
61 try{
62 hello(name(fef));
63 dgf_interpreter.read(name(fef), vfef); }
64 catch(const exception& e){
65 clog << "Caught error 0 as expected." << endl;
66 print_errMsg(e);
67 }
68 try{
69 hello(name(vfef));
70 dgf_interpreter.read(name(vfef), fef); }
71 catch(const exception& e){
72 clog << "Caught error 1 as expected." << endl;
73 print_errMsg(e);
74 }
75 }
76 catch(const exception& e){
77 print_errMsg(e);
78 return 1;
79 }
80 catch(const Dune::Exception& e){
81 cerr << "Dune error: " << e << endl;
82 return 2;
83 }
84 catch(...){
85 cerr << "Unkown error in main().\n";
86 return 3;
87 }
88
89
90
91
92 void print_errMsg(const std::exception& e){
93 std::cerr << e.what() << '\n';
94 try{
95 std::rethrow_if_nested(e);
96 }
97 catch(const std::exception& nested){
98 print_errMsg(nested);
99 }
100 }
101
102
103