-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset_tag.cpp
More file actions
79 lines (65 loc) · 2.52 KB
/
set_tag.cpp
File metadata and controls
79 lines (65 loc) · 2.52 KB
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
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include "moab/Core.hpp"
#include "moab/Interface.hpp"
#include "moab/Range.hpp"
#include "moab/AdaptiveKDTree.hpp"
#include "moab/ElemEvaluator.hpp"
#include "moab/CN.hpp"
#include "moab/SpatialLocator.hpp"
#include "moab/Util.hpp"
#include "moab/GeomUtil.hpp"
#include "MBTagConventions.hpp"
moab::Core mbi;
moab::Tag flux_tag;
int main(int argc, char **argv){
moab::ErrorCode rval;
moab::Range ves;
moab::EntityHandle fileset;
std::string filename = argv[1];
std::cout << filename << std::endl;
// Load mesh from file 1 into fileset 1
rval = mbi.create_meshset(moab::MESHSET_SET, fileset); MB_CHK_ERR(rval);
rval = mbi.load_file(filename.c_str(), &fileset);
MB_CHK_SET_ERR(rval, "Error loading file.");
// Get all 3D elements in fileset 1
rval = mbi.get_entities_by_dimension(fileset, 3, ves);MB_CHK_SET_ERR(rval, "Error getting 3d elements");
MB_CHK_SET_ERR(rval, "Error getting entities by dimension.");
//// Get flux tag
//std::string flux_tag_name ("flux");
//rval = mbi.tag_get_handle(flux_tag_name.c_str(),
//// moab::MB_TAG_VARLEN,
//// moab::MB_TYPE_DOUBLE,
// 1,
// moab::MB_TYPE_INTEGER,
// flux_tag,
// moab::MB_TAG_SPARSE|moab::MB_TAG_CREAT);
//MB_CHK_SET_ERR(rval, "Error getting flux tag.");
//int flux = std::stoi(argv[2]);
////int flux =1 ;
// Get flux tag
std::string flux_tag_name ("flux");
rval = mbi.tag_get_handle(flux_tag_name.c_str(),
moab::MB_TAG_VARLEN,
moab::MB_TYPE_DOUBLE,
flux_tag,
moab::MB_TAG_SPARSE|moab::MB_TAG_CREAT);
int num_e_groups = 217;//num_groups(flux_tag);
std::vector<double> flux(num_e_groups);
std::fill (flux.begin(), flux.end(), 5);
moab::Range::iterator it;
for( it = ves.begin(); it != ves.end(); ++ it){
// set the flux tag on the ve from set 2 we are mapping to
rval = mbi.tag_set_data(flux_tag, &(*it), 1, &flux[0]);MB_CHK_ERR(rval);
rval = mbi.tag_get_data(flux_tag, &(*it), 1, &flux[0]);MB_CHK_ERR(rval);
MB_CHK_SET_ERR(rval, "Error setting flux tag.");
}
std::cout << "flux tag " << flux[0] << std::endl;
// Write out mesh 2 w/ mapped data
moab::EntityHandle output_list[] = {fileset};
//std::string filenum = std::to_string(flux);
std::string filenum = "zero";
std::string basename = "taggeddata.h5m";
//rval = mbi.write_mesh((filenum+basename).c_str(), output_list, 1);
}