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 {
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 // NOTE:
40 std::vector<double> coords(3*num_cells);// just the center of cells?
41 long unsigned goffset = 0;
42 long unsigned glen = 0;
43 int icell = 0;
44 for (int i = 0; i < grids[lev].size(); ++i) {
45 auto box = grids[lev][i];
46 if (subdomain.contains(box)) {
48
49 // These were originally not offset by 0.5, but were to make it cell centers.
50 // Before using this, should confirm what MOAB expects the vertex locations to be.
51 // Also should note that this assumes a regular x,y,z grid where points match AMReX logical grid
52 for (auto k1 = 0; k1 < grids[lev][i].length(0); ++k1) {
53 for (auto k2 = 0; k2 < grids[lev][i].length(1); ++k2) {
54 for (auto k3 = 0; k3 < grids[lev][i].length(2); ++k3) {
55 coords[3*icell] = gridloc.lo(0)+geom[lev].CellSize(0)*(static_cast<Real>(k1)+Real(0.5));
56 coords[3*icell+1] = gridloc.lo(1)+geom[lev].CellSize(1)*(static_cast<Real>(k2)+Real(0.5));
57 coords[3*icell+2] = gridloc.lo(2)+geom[lev].CellSize(2)*(static_cast<Real>(k3)+Real(0.5));
58 icell++;
59 }
60 }
61 }
62 }
63 }
64 moab::Range cell_centers;
65 moab::ErrorCode rval = mbi->create_vertices( &coords[0], num_cells, cell_centers );
66 moab::EntityHandle file_set;
67 rval = mbi->create_meshset( moab::MESHSET_SET, file_set );
68 rval = mbi->add_entities(file_set, cell_centers);
69 rval = mbi->write_file("cell_centers.h5m",0,"PARALLEL=WRITE_PART", &file_set, 1);
70
71
72 return;
73}
mf_h setVal(geomdata.ProbHi(2))
amrex::Vector< amrex::Vector< amrex::Box > > boxes_at_level
the boxes specified at each level by tagging criteria
Definition REMORA.H:1549