/*************************************************************************** dh.cc - Data Hierarchy A grid hierarchy plus ghost zones ------------------- begin : Sun Jun 11 2000 copyright : (C) 2000 by Erik Schnetter email : schnetter@astro.psu.edu $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/dh.cc,v 1.21 2002/10/14 20:40:38 schnetter Exp $ ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include #include "defs.hh" #include "dist.hh" #include "ggf.hh" #include "vect.hh" #include "dh.hh" #undef DEBUG_OUTPUT using namespace std; // Constructors template dh::dh (gh& h, const ivect& lghosts, const ivect& ughosts, int prolongation_order_space) : dimgeneric_dh(prolongation_order_space), h(h), lghosts(lghosts), ughosts(ughosts) { assert (all(lghosts>=0 && ughosts>=0)); h.add(this); CHECKPOINT; recompose(); } // Destructors template dh::~dh () { CHECKPOINT; h.remove(this); } // Modifiers template void dh::recompose () { CHECKPOINT; boxes.clear(); boxes.resize(h.reflevels()); for (int rl=0; rl0) { const int csm1 = h.components(rl-1); boxes[rl][c][ml].send_ref_coarse.resize(csm1); boxes[rl][c][ml].recv_ref_coarse.resize(csm1); boxes[rl][c][ml].recv_ref_bnd_coarse.resize(csm1); } if (rl0) { const ibbox intrf = boxes[rl][c][ml-1].interior; const ibbox extrf = boxes[rl][c][ml-1].exterior; // Restriction (interior) { // (the restriction must fill all of the interior of the // coarse grid, and may use the exterior of the fine grid) const ibbox recv = intr; const ibbox send = recv.expanded_for(extrf); assert (send.is_contained_in(extrf)); boxes[rl][c][ml-1].send_mg_coarse.push_back(send); boxes[rl][c][ml ].recv_mg_fine .push_back(recv); } // Prolongation (interior) { // (the prolongation may use the exterior of the coarse // grid, and may fill only the interior of the fine grid, // and the bbox must be as large as possible) const ibbox recv = extr.contracted_for(intrf) & intrf; const ibbox send = recv.expanded_for(extr); boxes[rl][c][ml-1].recv_mg_coarse.push_back(recv); boxes[rl][c][ml ].send_mg_fine .push_back(send); } } // Refinement boxes if (rlbegin(); li!=lvi->end(); ++li) { sync_not -= *li; recv_not -= *li; } } // Subtract all boxes received const iblistvect& recv_ref_bnd_coarse = boxes[rl][c][ml].recv_ref_bnd_coarse; for (typename iblistvect::const_iterator lvi=recv_ref_bnd_coarse.begin(); lvi!=recv_ref_bnd_coarse.end(); ++lvi) { for (typename iblist::const_iterator li=lvi->begin(); li!=lvi->end(); ++li) { recv_not -= *li; } } // Check that no boundaries are left over if (rl==0) assert (sync_not.empty()); assert (recv_not.empty()); } // for ml } // for c } // for rl bases.resize(h.reflevels()); for (int rl=0; rl:" << "ghosts=[" << lghosts << "," << ughosts << "]," << "gfs={"; int cnt=0; for (typename list*>::const_iterator f = gfs.begin(); f != gfs.end(); ++f) { if (cnt++) os << ","; (*f)->output(os); } os << "}"; } template class dh<3>;