next up previous
Next: EBHyperCLaw Up: Working notes on developing Previous: So what's the big

Initializing an IrregGeom

This is straightforward but tedious. Make the cell frags, then assign the edges. For proper connectivity, the order in which you do this matters. The following hundred lines or so embeds a 6x6 square in a 16x16 domain.

void
EBHyperCLaw::irreg_init(BOX& b)
{
    // this thing defines an IrregGeom for a solid 6X6 box embedded in
    // a 16x16 grid.

    const int length = 6;

    //define body cells
    solid = new BitFab(b);
    for(int i = 5; i < 11; i++) {
        for(int j = 5; j < 11; j++) {
            solid->set(IntVect(i,j));
        }
    }
   
    // define CellFrags
    std::list<CellFrag*> frags;

    //bottom face of box
    CellFrag* cf_bottom[length];
    //top face of box
    CellFrag* cf_top[length];
    //left face of box
    CellFrag* cf_left[length];
    //right face of box
    CellFrag* cf_right[length];

// instantiate all CellFrags and assign outer edges
    // bottom
    int j = 4;
    for(int i = 5; i < 11; i++) {
        cf_bottom[i-length+1]= new CellFrag(IntVect(i,j),1.0);
        cf_bottom[i-length+1]->add(CellFrag::Edge(1,0), CellFrag::YLO);
    }
    // top
    j = 11;
    for(int i = 5; i < 11; i++) {
        cf_top[i-length+1]= new CellFrag(IntVect(i,j),1.0);
        cf_top[i-length+1]->add(CellFrag::Edge(1,0), CellFrag::YHI);
    }
    // left
    int i = 4;
    for(int j = 5; j < 11; j++) {
        cf_left[j-length+1]= new CellFrag(IntVect(i,j),1.0);
        cf_left[j-length+1]->add(CellFrag::Edge(1,0), CellFrag::XLO);
    }
    // right
    i = 11;
    for(int j = 5; j < 11; j++) {
        cf_right[j-length+1]= new CellFrag(IntVect(i,j),1.0);
        cf_right[j-length+1]->add(CellFrag::Edge(1,0), CellFrag::XHI);
    }

  // outer edges at corners
    //bottom left
    cf_bottom[0]->add(CellFrag::Edge(1,0), CellFrag::XLO);
    cf_left[0]->add(CellFrag::Edge(1,0), CellFrag::YLO);
    //bottom right
    cf_bottom[length-1]->add(CellFrag::Edge(1,0), CellFrag::XHI);
    cf_right[0]->add(CellFrag::Edge(1,0), CellFrag::YLO);
    // top left
    cf_top[0]->add(CellFrag::Edge(1,0), CellFrag::XLO);
    cf_left[length-1]->add(CellFrag::Edge(1,0), CellFrag::YHI);
    // top right
    cf_top[length-1]->add(CellFrag::Edge(1,0), CellFrag::XHI);
    cf_right[length-1]->add(CellFrag::Edge(1,0), CellFrag::YHI);

//  fill interior edge frags
    //bottom
    for(int i = 5; i < 10; i++) {
        cf_bottom[i-length+1]->add(CellFrag::Edge(1,cf_bottom[i-length+2]),
                                   CellFrag::XHI);
        cf_bottom[i-length+2]->add(CellFrag::Edge(1,cf_bottom[i-length+1]),
                                   CellFrag::XLO);
    }

    //top
    for(int i = 5; i < 10; i++) {
        cf_top[i-length+1]->add(CellFrag::Edge(1,cf_top[i-length+2]),
                                   CellFrag::XHI);
        cf_top[i-length+2]->add(CellFrag::Edge(1,cf_top[i-length+1]),
                                   CellFrag::XLO);
    }

    // left
    for(int j = 5; j < 10; j++) {
        cf_left[j-length+1]->add(CellFrag::Edge(1,cf_left[j-length+2]),
                                 CellFrag::YHI);
        cf_left[j-length+2]->add(CellFrag::Edge(1,cf_left[j-length+1]),
                               CellFrag::YLO);
    }

    // right
    for(int j = 5; j < 10; j++) {
        cf_right[j-length+1]->add(CellFrag::Edge(1,cf_right[j-length+2]),
                                 CellFrag::YHI);
        cf_right[j-length+2]->add(CellFrag::Edge(1,cf_right[j-length+1]),
                               CellFrag::YLO);
    }

    for(int i = 0; i < length; i++) {
        frags.push_back(cf_bottom[i]);
        frags.push_back(cf_left[i]);
        frags.push_back(cf_top[i]);
        frags.push_back(cf_right[i]);
    }

     igl =  new IrregGeomLevels(frags, *solid, b, 0);
     assert(igl);

     // suck level_0 IrregGeom out of this IrregGeomLevels
     ig = &((*igl)[0]);

}



Marcus S. Day
Thu Jan 30 17:36:57 PST 1997