aboutsummaryrefslogtreecommitdiff
path: root/CarpetDev/CarpetIOF5/src/meta_data_region.cc
blob: 505508eb92fe10d1cb2469253076136c08516a09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <cassert>
#include <cstdlib>
#include <sstream>
#include <string>

#include "cctk.h"

#include "carpet.hh"

#include "data_region.hh"
#include "meta_data_region.hh"
#include "utils.hh"



namespace CarpetIOF5 {
  
  namespace F5 {
    
    using std::ostringstream;
    
    
    
    meta_data_region_t::
    meta_data_region_t (tensor_component_t & tensor_component,
                        bbox<int, dim> const & region)
      : m_tensor_component (tensor_component),
        m_region (region)
    {
      assert (not region.empty());
      
      string const namestr = data_region_t::name_from_region (region);
      char const * const name = namestr.c_str();
      assert (name != 0);
      
      assert (invariant());
    }
    
    
    
    meta_data_region_t::
    ~ meta_data_region_t ()
    {
    }
    
    
    
    tensor_component_t & meta_data_region_t::
    get_tensor_component ()
      const
    {
      return m_tensor_component;
    }
    
    
    
    void meta_data_region_t::
    write (int const proc)
      const
    {
      string filename;
      string objectname;
      get_tensor_component().get_link_destination (filename, objectname);
      
      string const name = data_region_t::name_from_region (m_region);
      
      hid_t const hdf5_tensor_component
        = m_tensor_component.get_hdf5_tensor_component();
      
      herr_t const herr
        = H5Lcreate_external (filename.c_str(),
                              objectname.c_str(),
                              hdf5_tensor_component,
                              name.c_str(),
                              H5P_DEFAULT, H5P_DEFAULT);
      assert (not herr);
    }
    
    
    
    bool meta_data_region_t::
    invariant ()
      const
    {
      return not m_region.empty();
    }
    
  } // namespace F5

} // namespace CarpetIOF5