MCPcopy Create free account
hub / github.com/AMReX-Codes/amrex / EBGridCoverage

Method EBGridCoverage

Src/EB/AMReX_EBToPVD.cpp:430–502  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

428}
429
430void EBToPVD::EBGridCoverage(const int myID, const Real* problo, const Real* dx,
431 const Box &bx, Array4<EBCellFlag const> const& flag)
432{
433 int lc1 = 0;
434
435 const auto lo = lbound(bx);
436 const auto hi = ubound(bx);
437
438 std::array<int,3> nodes = {hi.x-lo.x + 1, hi.y-lo.y + 1, hi.z-lo.z + 1};
439 std::array<int,3> low = {lo.x, lo.y, lo.z};
440
441 for(int k = lo.z; k <= hi.z; ++k) {
442 for(int j = lo.y; j <= hi.y; ++j) {
443 for(int i = lo.x; i <= hi.x; ++i)
444 {
445 if(flag(i,j,k).isSingleValued()) {
446 lc1 = lc1 + 1;
447 }
448 }
449 }
450 };
451
452 ++m_grid;
453 if(lc1 == 0) { return; }
454
455 std::stringstream ss;
456 ss << std::setw(4) << std::setfill('0') << myID;
457 std::string cID = ss.str();
458
459 ss.str("");
460 ss.clear();
461 ss << std::setw(4) << std::setfill('0') << m_grid;
462 std::string cgrid = ss.str();
463 std::string fname = "eb_grid_" + cID + "_" + cgrid + ".vtr";
464
465 std::ofstream myfile(fname);
466 if(myfile.is_open()) {
467 myfile.precision(6);
468 myfile << "<?xml version=\"1.0\"?>\n";
469 myfile << "<VTKFile type=\"RectilinearGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
470 myfile << "<RectilinearGrid WholeExtent=\" 0 "
471 << nodes[0] << " 0 " << nodes[1] << " 0 " << nodes[2] << "\">\n";
472 myfile << "<Piece Extent=\" 0 "
473 << nodes[0] << " 0 " << nodes[1] << " 0 " << nodes[2] << "\">\n";
474 myfile << "<Coordinates>\n";
475
476 for(int idim = 0; idim < 3; ++idim) {
477 std::vector<Real> lines(nodes[idim]+1);
478 Real grid_start = problo[idim] + static_cast<Real>(low[idim])*dx[idim];
479 for(int llc = 0; llc <= nodes[idim]; ++llc) {
480 lines[llc] = grid_start + static_cast<Real>(llc)*dx[idim];
481 }
482
483 myfile << "<DataArray type=\"Float32\" format=\"ascii\" RangeMin=\"" // NOLINT
484 << std::fixed
485 << lines[0] << "\" RangeMax=\"" << lines[nodes[idim]] << "\">\n";
486
487 for(auto line : lines) {

Callers 1

WriteEBSurfaceFunction · 0.80

Calls 2

isSingleValuedMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected