This source file includes following definitions.
- project_dir
- dune_fem_parameter_append
- get_gridKey
- get_macroGrid
- doubleVector_to_string
- file_check
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 #include <fstream>
22 #include <dassert.h>
23 #include <config.h>
24 #include <dune/fem/io/parameter.hh>
25 #include <dune/fem/io/file/dataoutput.hh>
26 #include "io_parameter_impl.h"
27 #include "grid.h"
28 #include "esfem_error.h"
29
30 using namespace std;
31
32 const std::string& Esfem::Impl::project_dir(){
33
34 static const std::string project_dir {"/home/power/cpp/DISS_surfaces/"};
35
36 return project_dir;
37 }
38 void Esfem::Impl::dune_fem_parameter_append(int argc, char** argv, const std::string& file){
39 using Dune::Fem::Parameter;
40 Parameter::append(argc, argv);
41 for( int i = 1; i < argc; ++i )
42 Parameter::append(argv[i]);
43 #ifndef NDEBUG
44 std::clog << "Using parameter file: " << file << std::endl;
45 #endif
46 Parameter::append(file);
47 }
48 std::string Esfem::Impl::get_gridKey(){
49 const auto grid_key = Dune::Fem::IOInterface::
50 defaultGridKey(Esfem::Grid::Grid_and_time::Grid::dimension);
51 #ifndef NDEBUG
52 std::clog << "grid_key: " << grid_key << std::endl;
53 #endif
54 return grid_key;
55 }
56 std::string Esfem::Impl::get_macroGrid(){
57 const auto grid_key = get_gridKey();
58 const auto macro_grid = Dune::Fem::Parameter::getValue<std::string>(grid_key);
59 if(Dune::Fem::MPIManager::rank() == 0)
60 std::clog << "Loading macro grid: " << macro_grid << std::endl;
61 return macro_grid;
62 }
63 std::string Esfem::Impl::doubleVector_to_string(const std::vector<double>& vd){
64 constexpr size_t max_vec_size = 100;
65 Assert::dynamic<Assert::level(1), Esfem::Parameter_error>
66 (vd.size() <= max_vec_size,
67 Assert::compose(__FILE__, __LINE__,
68 "Vector is to big for doubleVector_to_string()"));
69 std::ostringstream oss;
70 oss << '{';
71 for(std::size_t it = 0; it < vd.size() - 1; ++it)
72 oss << vd[it] << ", ";
73 oss << vd.back() << '}';
74 return oss.str();
75 }
76 void Esfem::Impl::file_check(const std::vector<std::string>& file_list){
77 for(const auto& file_name : file_list){
78 ofstream fs {file_name, ios_base::app};
79 Assert::dynamic<Assert::level(1), Esfem::Parameter_error>
80 (!fs.fail(),
81 Assert::compose(__FILE__, __LINE__, file_name + ".fail() == true"));
82 }
83 }