REMORA
Regional Modeling of Oceans Refined Adaptively
Loading...
Searching...
No Matches
REMORA_MOAB.cpp
Go to the documentation of this file.
1
2#include <AMReX_Utility.H>
3#include "REMORA.H"
4
5using namespace amrex;
6
7void
8REMORA::InitMOABMesh()
9{
10 moab::Interface * mbi = new( std::nothrow ) moab::Core;
11 // Number of cells in this "domain" at this level
12 std::vector<int> n_cells;
13
14 int lev = 0;
15 int which_subdomain = 0;
16 int nblocks = grids[lev].size();
17
18 // We only do single-level mesh instances
19 int flev = 1; //max_level;
20
21 Box subdomain;
22 if (lev == 0) {
23 subdomain = geom[lev].Domain();
24 } else {
25 subdomain = boxes_at_level[lev][which_subdomain];
26 }
27
28 int nx = subdomain.length(0);
29 int ny = subdomain.length(1);
30 int nz = subdomain.length(2);
31
32 n_cells.push_back(nx);
33 n_cells.push_back(ny);
34 n_cells.push_back(nz);
35
36 int num_vertices = (nx+1)*(ny+1)*(nz+1);
37 int num_cells = nx * ny * nz;
38
39 std::vector<double> coords(3*num_cells);// just the center of cells?
40 long unsigned goffset = 0;
41 long unsigned glen = 0;
42 int icell = 0;
43 for (int i = 0; i < grids[lev].size(); ++i) {
44 auto box = grids[lev][i];
45 if (subdomain.contains(box)) {
46 RealBox gridloc = RealBox(grids[lev][i], geom[lev].CellSize(), geom[lev].ProbLo());
47
48 for (auto k1 = 0; k1 < grids[lev][i].length(0); ++k1) {
49 for (auto k2 = 0; k2 < grids[lev][i].length(1); ++k2) {
50 for (auto k3 = 0; k3 < grids[lev][i].length(2); ++k3) {
51 coords[3*icell] = gridloc.lo(0)+geom[lev].CellSize(0)*static_cast<Real>(k1);
52 coords[3*icell+1] = gridloc.lo(1)+geom[lev].CellSize(1)*static_cast<Real>(k2);
53 coords[3*icell+2] = gridloc.lo(2)+geom[lev].CellSize(2)*static_cast<Real>(k3);
54 icell++;
55 }
56 }
57 }
58 }
59 }
60 moab::Range cell_centers;
61 moab::ErrorCode rval = mbi->create_vertices( &coords[0], num_cells, cell_centers );
62 moab::EntityHandle file_set;
63 rval = mbi->create_meshset( moab::MESHSET_SET, file_set );
64 rval = mbi->add_entities(file_set, cell_centers);
65 rval = mbi->write_file("cell_centers.h5m",0,"PARALLEL=WRITE_PART", &file_set, 1);
66
67
68 return;
69}
amrex::Vector< amrex::Vector< amrex::Box > > boxes_at_level
the boxes specified at each level by tagging criteria
Definition REMORA.H:1091