Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

samrai_supplement/setVectorWeightsX.C.sed

Go to the documentation of this file.
00001 
00002 
00003 
00004 #include <tbox_Pointer.h>
00005 
00006 #include <hier_PatchHierarchyX.h>
00007 #include <hier_PatchLevelX.h>
00008 #include <hier_PatchX.h>
00009 #include <pdat_CellDataX.h>
00010 #include <geom_CartesianPatchGeometryX.h>
00011 #include <hier_BoxArrayX.h>
00012 #include <hier_IntVectorX.h>
00013 #include <hier_BoxX.h>
00014 
00015 #include "setVectorWeightsX.h"
00016 
00017 
00018 using namespace SAMRAI;
00019 
00020 
00021 void setVectorWeightsX(
00022   SAMRAI::tbox_Pointer<hier_PatchHierarchyX> hierarchy
00023 , int weight_id
00024 ) {
00025    for ( int amr_level = hierarchy->getFinestLevelNumber();
00026              amr_level >= 0;
00027              amr_level-- ) {
00028 
00029      /*
00030       * On every level, first assign cell volume to vector weight.
00031       */
00032 
00033       SAMRAI::tbox_Pointer<hier_PatchLevelX> level = hierarchy->getPatchLevel(amr_level);
00034       for (hier_PatchLevelX::Iterator p(level); p; p++) {
00035          SAMRAI::tbox_Pointer<hier_PatchX> patch = level->getPatch(p());
00036          SAMRAI::tbox_Pointer<geom_CartesianPatchGeometryX> patch_geometry =
00037             patch->getPatchGeometry();
00038          const double* dx = patch_geometry->getDx();
00039          double cell_vol = dx[0]*dx[1];
00040          SAMRAI::tbox_Pointer< pdat_CellDataX<double> > w =
00041             patch->getPatchData(weight_id);
00042          w->fillAll(cell_vol); 
00043       }
00044 
00045       /*
00046        * On all but the finest level, assign 0 to vector
00047        * weight to cells covered by finer cells.
00048        */
00049 
00050       if (amr_level < hierarchy->getFinestLevelNumber()) {
00051 
00052         /*
00053          * First get the boxes that describe index space of the next finer 
00054          * level and coarsen them to describe corresponding index space 
00055          * at this level.
00056          */
00057 
00058          SAMRAI::tbox_Pointer<hier_PatchLevelX> next_finer_level = 
00059             hierarchy->getPatchLevel(amr_level+1);
00060          hier_BoxArrayX coarsened_boxes = next_finer_level->getBoxes(); 
00061          hier_IntVectorX coarsen_ratio = next_finer_level->getRatio();
00062          coarsen_ratio /= level->getRatio();
00063          coarsened_boxes.coarsen(coarsen_ratio);
00064 
00065          /*
00066           * Then set vector weight to 0 wherever there is
00067           * a nonempty intersection with the next finer level.
00068           * Note that all assignments are local.
00069           */
00070 
00071          for (hier_PatchLevelX::Iterator p(level); p; p++) {
00072 
00073             SAMRAI::tbox_Pointer<hier_PatchX> patch = level->getPatch(p());
00074             for ( int i = 0; i < coarsened_boxes.getNumberOfBoxes(); i++ ) {
00075 
00076                hier_BoxX coarse_box = coarsened_boxes(i);
00077                hier_BoxX intersection = coarse_box*(patch->getBox());
00078                if ( !intersection.empty() ) {
00079                   SAMRAI::tbox_Pointer< pdat_CellDataX<double> > w =
00080                      patch->getPatchData(weight_id);
00081                   w->fillAll(0.0, intersection);
00082 
00083                }  // assignment only in non-empty intersection
00084             }  // loop over coarsened boxes from finer level
00085          }  // loop over patches in level
00086       }  // all levels except finest
00087    }  // loop over levels
00088 }

Generated on Wed Apr 17 12:51:45 2002 for samtut by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001