Exemple #1
0
NMPlane::NMPlane(int xtess, int ytess)
{
    this->xtess = xtess;
    this->ytess = ytess;
    int arraysize = xtess * ytess * 4;
    verts = new Vector4[arraysize];
    norms = new Vector4[arraysize];
    tans = new Vector4[arraysize];
    texs = new vec2<REAL>[arraysize];

    makeGeometry();

}
int
main(int argc, char** argv)
{

#ifdef CH_MPI
  MPI_Init(&argc, &argv);
#endif
  //begin forever present scoping trick
  {
    const char* in_file;
    if (argc < 2 || argv[1][0] == '-')
      {
        in_file = "ramp.inputs";
      }
    else
      {
        in_file = argv[1];
      }
    //parse input file
    ParmParse pp(0,NULL,NULL,in_file);
    int eekflag = 0;
    //define the geometry object.
    Box domain;
    eekflag =  makeGeometry(domain);
    if (eekflag != 0)
      {
        pout() << "non zero eek detected = " << eekflag << endl;
        MayDay::Error("problem in makeGeometry");
      }

    //check that total coarse vol = total fine vol
    //check that total coarse vol centroid = total fine vol centroid
    eekflag = checkCoarseAssortment(domain);

    if (eekflag != 0)
      {
        pout() << "checkCoarse: eek = " << eekflag << endl;
        MayDay::Error("problem in checkEBISL");
      }

    pout() << "pointCoarsening test passed" << endl;
  }//end scoping trick
  EBIndexSpace* ebisPtr = Chombo_EBIS::instance();
  ebisPtr->clear();
#ifdef CH_MPI
  MPI_Finalize();
#endif
  return 0;
}
Exemple #3
0
int
main(int argc, char** argv)
{

#ifdef CH_MPI
  MPI_Init(&argc, &argv);
#endif
  //begin scoping trick
  {

    int eekflag = 0;
    //define the geometry object.
    //need the new and delete because of
    //strong construction
    Box domain, coveredDomain;
    Real dx;
    //make the gometry.  this makes the first Chombo_EBIS
    //and defines it using a geometryservice
    eekflag =  makeGeometry(domain, dx, coveredDomain);
    if (eekflag != 0)
      {
        pout() << "non zero eek detected = " << eekflag << endl;
        MayDay::Error("problem in makeGeometry");
      }

    eekflag = checkIrregFabCopy(domain);
    if (eekflag != 0)
      {
        pout() << "non zero eek detected = " << eekflag << endl;
        MayDay::Error("problem in checkIrregFabCopy");
      }

    eekflag = checkRegularFabCopy(domain);
    if (eekflag != 0)
      {
        pout() << "non zero eek detected = " << eekflag << endl;
        MayDay::Error("problem in checkRegularFabCopy");
      }

    pout() << "fab copy test passed" << endl;
  }//end scoping trick
  EBIndexSpace* ebisPtr = Chombo_EBIS::instance();
  ebisPtr->clear();
#ifdef CH_MPI
  MPI_Finalize();
#endif
  return 0;
}
Exemple #4
0
int
main(int argc,char **argv)
{
#ifdef CH_MPI
  MPI_Init(&argc, &argv);
#endif

  // begin forever present scoping trick
  {
    const char* in_file;
    if (argc < 2 || argv[1][0] == '-')
      {
        in_file = "correct12.inputs";
      }
    else
      {
        in_file = argv[1];
      }
    //parse input file
    ParmParse pp(0,NULL,NULL,in_file);
    Box domain;
    int eekflag = 0;
    eekflag =  makeGeometry(domain);
    if (eekflag != 0)
      {
        pout() << "non zero eek detected = " << eekflag << endl;
        MayDay::Error("problem in makeGeometry");
      }

    eekflag = checkCorrection(domain);
    if (eekflag != 0)
      {
        pout() << "checkCorrection: eek = " << eekflag << endl;
        MayDay::Error("problem in checkCorrection");
      }
    pout() << "correct1d2d test passed" << endl;
  } // end scoping trick

  EBIndexSpace* ebisPtr = Chombo_EBIS::instance();
  ebisPtr->clear();

#ifdef CH_MPI
  MPI_Finalize();
#endif

  return 0;
}
void VideoViewer::initializeGL()
{

    glEnable(GL_VERTEX_ARRAY);
    glEnable(GL_TEXTURE_2D);

    makeShaders();
    makeGeometry();
    //updateTexture();

    glGenTextures(1, &_textureId);
    glBindTexture(GL_TEXTURE_2D, _textureId);

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,     GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,     GL_CLAMP_TO_EDGE);

}
Exemple #6
0
int main (int argc, char** argv)
{
#ifdef CH_MPI
  MPI_Init(&argc,&argv);
#endif

  // Begin forever present scoping trick
  {
    const char* in_file = "plane.inputs";

    if (argc > 1)
    {
      in_file = argv[1];
    }

    // Parse input file
    ParmParse pp(0,NULL,NULL,in_file);

    Box domain;
    RealVect origin;
    Real dx;

    BaseIF* implicit;

    // Make geometry
    implicit = makeGeometry(domain,origin,dx);

    // Make grids
    DisjointBoxLayout grids;
    makeLayout(grids,domain);

    // Create ebislayout
    int nghost = 0;
    EBISLayout ebisl;
    makeEBISL(ebisl,grids,domain,nghost);

    // Make a LevelData
    int nComps = 1;

    IntVect ghost = IntVect::Unit;
    ghost *= nghost;

    RefCountedPtr<DataFactory<EBCellFAB> > rcpFactory(new EBCellFactory(ebisl));
    LevelData<EBCellFAB> level(grids,nComps,ghost,*rcpFactory);

    // Put some data in the data holders
    fillData(level,origin,dx,*implicit);

    // Done with this object
    delete implicit;

    // Write the data and the EB out
    const char* basename = "plane";

    char name[1000];
    sprintf(name,"%s%dd.hdf5",basename,SpaceDim);
#ifdef CH_USE_HDF5
    writeEBLevelname(&level,name);
#endif
  } // End scoping trick

  // Clean up
  EBIndexSpace* ebisPtr = Chombo_EBIS::instance();
  ebisPtr->clear();

  CH_TIMER_REPORT();

#ifdef CH_MPI
  MPI_Finalize();
#endif

  return 0;
}
Exemple #7
0
int
main(int argc, char** argv)
{

#ifdef CH_MPI
    MPI_Init(&argc, &argv);
#endif
    //begin forever present scoping trick
    {
        const char* in_file = "ramp.inputs";
        //parse input file
        ParmParse pp(0,NULL,NULL,in_file);
        int eekflag = 0;
        //define the geometry object.
        //need the new and delete because of
        //strong construction
        //make the gometry.  this makes the first Chombo_EBIS
        Box domain;
        Real dx;
        RealVect origin;
        int upDir;
        int indepVar;
        Real startPt;
        Real slope;
        //and defines it using a geometryservice
        eekflag =  makeGeometry(domain,  dx, origin,
                                upDir, indepVar, startPt, slope);
        if (eekflag != 0)
        {
            pout() << "non zero eek detected = " << eekflag << endl;
            MayDay::Error("problem in makeGeometry");
        }

        //make grids
        DisjointBoxLayout grids;
        eekflag = makeLayout(grids, domain);
        if (eekflag != 0)
        {
            pout() << "non zero eek detected = " << eekflag << endl;
            MayDay::Error("problem in makeLayouts");
        }

        ///create ebislayout
        int nghost = 2;
        EBISLayout ebisl;
        eekflag = makeEBISL(ebisl, grids, domain, nghost);
        if (eekflag != 0)
        {
            pout() << "non zero eek detected = " << eekflag << endl;
            MayDay::Error("problem in makeEBISL");
        }

        //check everything i can think of on finest level
        eekflag = checkEBISL(ebisl, grids, domain, dx, origin,
                             upDir, indepVar, startPt, slope);
        if (eekflag != 0)
        {
            pout() << "non zero eek detected = " << eekflag << endl;
            MayDay::Error("problem in checkEBISL");
        }

        pout() << "ramp test passed" << endl;
    }//end scoping trick
    EBIndexSpace* ebisPtr = Chombo_EBIS::instance();
    ebisPtr->clear();
#ifdef CH_MPI
    MPI_Finalize();
#endif
    return 0;
}
Exemple #8
0
int main (int argc, char** argv)
{
#ifdef CH_MPI
  MPI_Init(&argc,&argv);
#endif

  // begin forever present scoping trick
  {
    const char* in_file = "impFuncTest.inputs";

    // parse input file
    ParmParse pp(0,NULL,NULL,in_file);

    RealVect center;
    Real radius;

    bool insideRegular;

    RealVect origin;
    Real dx;

    Box domain;

    int eekflag = 0;

    // make geometry
    eekflag = makeGeometry(domain,
                           dx,
                           origin,
                           center,
                           radius,
                           insideRegular);

    if (eekflag != 0)
    {
      pout() << "non zero eek detected = " << eekflag << endl;
      MayDay::Error("problem in makeGeometry");
    }

    // make grids
    DisjointBoxLayout grids;
    eekflag = makeLayout(grids,domain);

    if (eekflag != 0)
    {
      pout() << "non zero eek detected = " << eekflag << endl;
      MayDay::Error("problem in makeLayouts");
    }

    // create ebislayout
    int nghost = 2;
    EBISLayout ebisl;
    eekflag = makeEBISL(ebisl,grids,domain,nghost);

    // make a LevelData
    int nComps = 2;

    IntVect ghost = IntVect::Unit;
    ghost *= nghost;

    RefCountedPtr<DataFactory<EBCellFAB> > rcpFactory(new EBCellFactory(ebisl));
    LevelData<EBCellFAB> level(grids,nComps,ghost,*rcpFactory);

    // writeEBLevelname(&level,"level.hdf5");

    if (eekflag != 0)
    {
      pout() << "non zero eek detected = " << eekflag << endl;
      MayDay::Error("problem in makeEBISL");
    }

    // check volume and surface area of approximate sphere
    eekflag = checkEBISL(ebisl,
                         grids,
                         domain,
                         dx,
                         origin,
                         radius,
                         center,
                         insideRegular);

    if (eekflag != 0)
    {
      pout() << "non zero eek detected = " << eekflag << endl;
      MayDay::Error("problem in checkEBISL");
    }

    pout() << "implicit function test passed" << endl;
  } // end scoping trick

  CH_XD::EBIndexSpace* ebisPtr = Chombo_EBIS::instance();
  ebisPtr->clear();

#ifdef CH_MPI
  MPI_Finalize();
#endif

  return 0;
}
Exemple #9
0
int fluxRegTest()
{
  int nref = 2;
  int eekflag = 0;
  ParmParse pp;

  Box domainCoar, domainFine;
  eekflag = makeGeometry(domainFine);
  if (eekflag != 0)
    return eekflag;
  domainCoar = coarsen(domainFine, nref);

  DisjointBoxLayout dblFine,dblCoar;
  eekflag = makeLayouts(dblCoar, dblFine, domainCoar, domainFine);

  Interval interv(0,0);

  EBISLayout ebislFine, ebislCoar;
  int nghost = 3;
  makeEBISL(ebislFine, dblFine, domainFine, nghost);
  makeEBISL(ebislCoar, dblCoar, domainCoar, nghost);

  EBCellFactory factFine(ebislFine);
  EBCellFactory factCoar(ebislCoar);
  IntVect ivghost = IntVect::Unit;

  LevelData<EBCellFAB> fineData(dblFine, 1,ivghost, factFine);
  LevelData<EBCellFAB> coarData(dblCoar, 1,ivghost, factCoar);

  LevelData<EBCellFAB> extraDense(dblCoar, 1,ivghost, factCoar);

  //set data and flux registers to zero
  for (DataIterator coarIt = coarData.dataIterator();
      coarIt.ok(); ++coarIt)
      coarData[coarIt()].setVal(0.);
  for (DataIterator fineIt = fineData.dataIterator();
      fineIt.ok(); ++fineIt)
    fineData[fineIt()].setVal(0.);
  {
    //    pout() << "before constructor" << endl;
    EBFluxRegister fluxReg(dblFine,
                           dblCoar,
                           ebislFine,
                           ebislCoar,
                           domainCoar,
                           nref, 1, Chombo_EBIS::instance());
    //    pout() << "after constructor" << endl;
    fluxReg.setToZero();
    //    pout() << "after settozero" << endl;
    //loop through directions
    Real scale = 1.0;
    Real fluxVal = 4.77;
    for (int idir = 0; idir < SpaceDim; idir++)
      {

        //        pout() << "idir = " << idir <<  endl;
        //        MPI_Barrier(Chombo_MPI::comm);
        //increment and decrement
        //flux registers with equal size fluxes
        for (DataIterator coarIt = coarData.dataIterator();
            coarIt.ok(); ++coarIt)
          {
            const Box&  boxCoar = dblCoar.get(coarIt());
            const EBISBox& ebisBox = ebislCoar[coarIt()];
            IntVectSet ivsBC(boxCoar);
            EBFaceFAB edgeFluxReg(ebisBox, boxCoar, idir, 1);
            BaseIFFAB<Real> edgeFluxIrr(ivsBC, ebisBox.getEBGraph(), idir, 1);
            edgeFluxReg.setVal(fluxVal);
            edgeFluxIrr.setVal(fluxVal);
            fluxReg.incrementCoarseRegular(edgeFluxReg, scale,
                                           coarIt(), interv, idir);
            //        pout() << "after increment coar regular"<< endl;
            fluxReg.incrementCoarseIrregular(edgeFluxIrr, scale,
                                             coarIt(), interv, idir);

            //        pout() << "after increment coar irregular"<< endl;
          }
        //        pout() << "after increment coar"<< endl;
        //        MPI_Barrier(Chombo_MPI::comm);
        for (DataIterator fineIt = fineData.dataIterator();
            fineIt.ok(); ++fineIt)
          {
            const Box&  boxFine = dblFine.get(fineIt());
            const EBISBox& ebisBox = ebislFine[fineIt()];
            IntVectSet ivsBF(boxFine);
            EBFaceFAB edgeFluxReg(ebisBox, boxFine, idir, 1);
            BaseIFFAB<Real> edgeFluxIrr(ivsBF, ebisBox.getEBGraph(), idir, 1);
            edgeFluxReg.setVal(fluxVal);
            edgeFluxIrr.setVal(fluxVal);

            for (SideIterator sit; sit.ok(); ++sit)
              {
                fluxReg.incrementFineRegular(edgeFluxReg, scale,
                                             fineIt(),  interv, idir, sit());

                fluxReg.incrementFineIrregular(edgeFluxIrr, scale,
                                               fineIt(),  interv, idir, sit());

              }
          }
        //        pout() << "after increment fine"<< endl;
        //        MPI_Barrier(Chombo_MPI::comm);
      }

    //reflux what ought to be zero into zero and the result should be zero
    //except where the coarse-fine boundary gets crossed by the embedded
    //boundary.  That should get fixed by the extramass thing.
    fluxReg.reflux(coarData, interv, scale);
    //    pout() << "after reflux"<< endl;

    for (DataIterator coarIt = coarData.dataIterator();
        coarIt.ok(); ++coarIt)
      extraDense[coarIt()].setVal(0.);

    // now add extra density to soltuion
    //in the end the solution should return to zero
    fluxReg.incrementDensityArray(extraDense, interv, scale);
  }
  //  pout() << "after fluxreg destruction" << endl;
  //  pout() << "after incementDensityArray"<< endl;
  for (DataIterator coarIt = coarData.dataIterator();
      coarIt.ok(); ++coarIt)
    coarData[coarIt()] += extraDense[coarIt()];
  //  MPI_Barrier(Chombo_MPI::comm);
  //  pout() << "after  += operation "<< endl;
  DataIterator datIt = coarData.dataIterator();
  for (datIt.reset(); datIt.ok(); ++datIt)
    {
      const EBCellFAB& data = coarData[datIt()];
      IntVectSet ivsBox(dblCoar.get(datIt()));
      const EBISBox& ebisBox = ebislCoar[datIt()];
      Real rmax = 0.;
      Real rmin = 0.;
      for (VoFIterator vofit(ivsBox, ebisBox.getEBGraph());
          vofit.ok(); ++vofit)
        {
          const VolIndex& vof = vofit();
          rmax = Max(rmax, Abs(data(vof, 0)));
          rmin = Min(rmax, Abs(data(vof, 0)));

#ifdef CH_USE_FLOAT
          Real tolerance = 1.0e-6;
#else
          Real tolerance = 1.0e-10;
#endif
          if ((rmax > tolerance)||(rmin > tolerance))
            {
              pout() << "EBFluxRegister failed the test at  "
                     << " vof = " << vof << endl;
              pout() << "   rmax: "      << rmax      << ", or"
                     <<   " rmin: "      << rmin      << " >"
                     <<   " tolerance: " << tolerance << ")" << endl;
              eekflag = 42;
              return eekflag;
            }
        }
    }

  //  pout() << "about to return "<< endl;
  return eekflag;
}
Exemple #10
0
int
main(int argc, char** argv)

{

#ifdef CH_MPI
  MPI_Init(&argc, &argv);
#endif
  int eekflag = 0;
  {//begin forever present scoping trick

    const char* in_file = "ramp.inputs";
    //parse input file
    ParmParse pp(0,NULL,NULL,in_file);
    //define the geometry object.
    //need the new and delete because of
    //strong construction
    //make the gometry.  this makes the first Chombo_EBIS
    Box domainFine, domainCoar;
    Real dxFine, dxCoar;

    //and defines it using a geometryservice
    eekflag =  makeGeometry(domainFine,  dxFine);
    CH_assert(eekflag == 0);

    domainCoar = coarsen(domainFine, 2);
    dxCoar = 2.0*dxFine;
    //make grids
    DisjointBoxLayout gridsFine, gridsCoar;
    eekflag = makeLayout(gridsFine, domainFine);
    CH_assert(eekflag == 0);
    coarsen(gridsCoar, gridsFine, 2);

    ///create ebislayout
    int nghost = 2;
    EBISLayout ebislFine, ebislCoar;
    eekflag = makeEBISL(ebislFine, gridsFine, domainFine, nghost);
    if (eekflag != 0) return eekflag;
    eekflag = makeEBISL(ebislCoar, gridsCoar, domainCoar, nghost);
    if (eekflag != 0) return eekflag;

    int nvar = 1;
    EBCellFactory ebcellfactFine(ebislFine);
    EBCellFactory ebcellfactCoar(ebislCoar);
    IntVect ivghost = nghost*IntVect::Unit;
    LevelData<EBCellFAB> errorFine(gridsFine, nvar,
                                   ivghost,ebcellfactFine);
    LevelData<EBCellFAB> errorCoar(gridsCoar, nvar,
                                   ivghost,ebcellfactCoar);

    eekflag = getError(errorFine,ebislFine, gridsFine, domainFine, dxFine);
    if (eekflag != 0) return eekflag;

    eekflag = getError(errorCoar,ebislCoar, gridsCoar, domainCoar, dxCoar);
    if (eekflag != 0) return eekflag;

    eekflag =  compareError(errorFine, ebislFine, gridsFine, domainFine,
                            errorCoar, ebislCoar, gridsCoar, domainCoar);
    if (eekflag != 0) return eekflag;

  }//end omnipresent scoping trick
  EBIndexSpace* ebisPtr = Chombo_EBIS::instance();
  ebisPtr->clear();
  if (eekflag == 0)
    {
      pout() << "aggpwlfpTest passed" << endl;
    }

#ifdef CH_MPI
  MPI_Finalize();
#endif
  return eekflag;
}
Exemple #11
0
int
main(int argc,char **argv)
{
#ifdef CH_MPI
    MPI_Init(&argc, &argv);
#endif

    // registerDebugger();

    // begin forever present scoping trick
    {
        pout()<<std::endl;

        Vector<std::string> names0(1, "phi");
        Vector<int> refRatio(3,2);
        Vector<Real> coveredVal(1,3.0);

        const char* in_file = "sphere.inputs";
        // read in an input file or use default file
        // if (argc > 1)
        // {
        //   in_file = argv[1];
        // }

        //parse input file
        ParmParse pp(0,NULL,NULL,in_file);
        RealVect center;
        Real radius;
        RealVect origin;
        RealVect dx;
        Box domain;
        ProblemDomain pDomain(domain);

        int eekflag = 0;



        LevelData<EBCellFAB> fine, med, coarse;

        LevelData<EBCellFAB> fineRHS, medRHS, coarseRHS;
        LevelData<EBCellFAB> fineResidual, mediumResidual, coarseResidual;


        Vector<LevelData<EBCellFAB>* > ebvector(3,NULL);
        Vector<LevelData<EBCellFAB>* > vresidual(3,NULL);
        Vector<LevelData<EBCellFAB>* > rhsvector(3,NULL);
        ebvector[0]=&coarse;
        ebvector[1]=&med;
        ebvector[2]=&fine;
        vresidual[0]=&coarseResidual;
        vresidual[1]=&mediumResidual;
        vresidual[2]=&fineResidual;
        rhsvector[0] = &coarseRHS;
        rhsvector[1] = &medRHS;
        rhsvector[2] = &fineRHS;




        readGeometryInfo(domain,
                         dx,
                         origin,
                         center,
                         radius);

        Box domainFine(domain), domainMedi, domainCoar;
        ProblemDomain pFine(domain);
        RealVect dxFine(dx), dxMedi, dxCoar;

        CH_assert(eekflag == 0);

        domainMedi = coarsen(domainFine, 2);
        domainCoar = coarsen(domainMedi, 2);
        dxMedi = 2.0*dxFine;
        dxCoar = 2.0*dxMedi;
        Vector<RealVect> xVec(3, IntVect::Unit);
        xVec[0]*= dxCoar;
        xVec[1]*= dxMedi;
        xVec[2]*= dxFine;

        Vector<DisjointBoxLayout> grids(3);
        ProblemDomain baseDomain(domainCoar);
        ProblemDomain pMed(domainMedi);
        Vector<ProblemDomain> pd(3);
        pd[0] = baseDomain;
        pd[1] = pMed;
        pd[2] = ProblemDomain(domainFine);


        RefCountedPtr<BaseBCValue>value(new DirichletBC());
        DirichletPoissonDomainBC*  domainBC = new DirichletPoissonDomainBC();
        domainBC->setFunction(value);
        RefCountedPtr<BaseDomainBC> bc(domainBC);



        //make data holders
        Vector<int> comps(2,1);

        int steps= 5;
        int step = 0;


        while (step < steps)
        {


            eekflag = makeGeometry(
                          domain,
                          dx,
                          origin,
                          center,
                          radius);


            //make grids
            //IntVectSet tags = mfIndexSpace->interfaceRegion(2);
            IntVectSet   tags(domainCoar);
            tags.grow(1);
            makeHierarchy(grids, baseDomain, tags);


            const CH_XD::EBIndexSpace* ebisPtr = Chombo_EBIS::instance();

            Vector<EBISLayout> layouts(3);
            EBISLayout& fineLayout = layouts[2];
            ebisPtr->fillEBISLayout(fineLayout, grids[2], domainFine, 2);
            EBCellFactory fineFactory(fineLayout);
            ebvector[2]->define(grids[2], 1, IntVect::Unit, fineFactory);
            rhsvector[2]->define(grids[2], 1, IntVect::Zero, fineFactory);

            EBISLayout& medLayout = layouts[1];
            ebisPtr->fillEBISLayout(medLayout, grids[1], domainMedi, 2);
            EBCellFactory medFactory(medLayout);
            ebvector[1]->define(grids[1], 1, IntVect::Unit, medFactory);
            rhsvector[1]->define(grids[1], 1, IntVect::Zero, medFactory);

            EBISLayout& coarseLayout = layouts[0];
            ebisPtr->fillEBISLayout(coarseLayout, grids[0], domainCoar, 2);
            EBCellFactory coarseFactory(coarseLayout);
            ebvector[0]->define(grids[0], 1, IntVect::Unit, coarseFactory);
            rhsvector[0]->define(grids[0], 1, IntVect::Zero, coarseFactory);



            for (int lev=0; lev<3; lev++)
            {
                setValue(*rhsvector[lev], RHS(), pd[lev].domainBox(), xVec[lev], origin, true);
            }



            Vector<int> refRatio(3,2);

            int max_iter = 40;
            pp.get("max_iter", max_iter);
            Real eps = 1.e-6;
            pp.get("eps", eps);
            int relaxType;
            pp.get("relaxType",relaxType);

            DirichletPoissonDomainBCFactory* domDirBC = new DirichletPoissonDomainBCFactory();
            domDirBC->setFunction(value);
            RefCountedPtr<BaseDomainBCFactory> domBC( domDirBC );
            DirichletPoissonEBBCFactory* ebDirBC = new DirichletPoissonEBBCFactory();
            ebDirBC->setFunction(value);
            RefCountedPtr<BaseEBBCFactory> ebBC( ebDirBC );

            Vector<EBLevelGrid> eblgs(3);
            Vector<RefCountedPtr<EBQuadCFInterp> > quadCFI(3, RefCountedPtr<EBQuadCFInterp>());
            for (int i=0; i<3; i++)
            {
                eblgs[i] = EBLevelGrid(grids[i], layouts[i], pd[i]);
                if (i > 0)
                {
                    quadCFI[i] = RefCountedPtr<EBQuadCFInterp>(
                                     new EBQuadCFInterp(grids[i],
                                                        grids[i-1],
                                                        layouts[i],
                                                        layouts[i-1],
                                                        pd[i-1],
                                                        refRatio[i-1],
                                                        1, *eblgs[i].getCFIVS()));
                }
            }

            EBAMRPoissonOpFactory opFact(eblgs, refRatio, quadCFI, xVec[0], RealVect::Zero,
                                         4, relaxType, domBC, ebBC, 0.0, 1.0, 0.0,
                                         IntVect::Unit, IntVect::Zero);
            for (int i=0; i<3; i++)
            {

                LevelData<EBCellFAB> &phi=*ebvector[i], &rhs=*rhsvector[i], &residual=*vresidual[i];
                LevelData<EBCellFAB> correction;

                DisjointBoxLayout dblMGCoar;
                EBISLayout ebislMGCoar;

                EBAMRPoissonOp* opPtr = opFact.AMRnewOp(pd[i]);
                EBAMRPoissonOp& op = *opPtr;


                RelaxSolver<LevelData<EBCellFAB> > solver;
                solver.define(&op, false);
                solver.m_imax = max_iter;
                solver.m_eps  = eps;

                op.create(residual, rhs);
                op.create(correction, phi);
                op.setToZero(residual);
                op.setToZero(phi);

                op.residual(residual, phi, rhs);
                Real r2norm = op.norm(residual, 2);
                Real r0norm = op.norm(residual, 0);


                pout()<<indent<<"Residual L2 norm "<<r2norm<<"Residual max norm = "
                      <<r0norm<<std::endl;

                solver.solve(phi, rhs);

                op.residual(residual, phi, rhs);
                r2norm = op.norm(residual, 2);
                r0norm = op.norm(residual, 0);


                pout()<<indent2<<"Residual L2 norm "<<r2norm<<" Residual max norm = "
                      <<r0norm<<std::endl;

                delete opPtr;
            }


#ifdef CH_USE_HDF5
            sprintf(iter_str, "residual.%03d.%dd.hdf5",step, SpaceDim);
            Vector<std::string> names(1);
            names[0]="residual";

            writeEBHDF5(iter_str, grids, vresidual, names, domainCoar,
                        dxCoar[0], 1, step, refRatio, 3, true, coveredVal);

            sprintf(iter_str, "phi.%03d.%dd.hdf5",step, SpaceDim);
            names[0]="phi";
            writeEBHDF5(iter_str, grids, ebvector ,names, domainCoar,
                        dxCoar[0], 1, step, refRatio, 3, true, coveredVal);
#endif
            step++;

            center[0]-= dx[0]/3.0;
            center[1]-= dx[1]/2.0;
            radius += dx[0]/6.0;

            Chombo_EBIS::instance()->clear();
            pout()<<step<<std::endl;
        }

        pout() <<"\n "<<indent2<<pgmname<<" test passed " << endl;



    } // end scoping trick





#ifdef CH_MPI
    MPI_Finalize();
#endif

    return 0;
}
Exemple #12
0
int
main(int argc, char** argv)

{

#ifdef CH_MPI
  MPI_Init(&argc, &argv);
#endif
  int eekflag = 0;
  {//begin forever present scoping trick

    const char* in_file = "pwlinterp.inputs";
    //parse input file
    ParmParse pp(0,NULL,NULL,in_file);
    //define the geometry object.
    //need the new and delete because of
    //strong construction
    //make the gometry.  this makes the first Chombo_EBIS
    Box domainFineFull, domainCoarFull;
    Box domainFinePart, domainCoarPart;
    Real dxFineFull, dxCoarFull;
    Real dxFinePart, dxCoarPart;
    //and defines it using a geometryservice
    eekflag =  makeGeometry(domainFinePart,  dxFinePart);
    CH_assert(eekflag == 0);
    int nlevels = 2;
    Vector<int> refRatio(nlevels);
    pp.getarr("ref_ratio", refRatio,0,nlevels);

    domainCoarPart = coarsen(domainFinePart, 2);
    domainFineFull = coarsen(domainFinePart, refRatio[0]);
    domainCoarFull = coarsen(domainFineFull, 2);

    dxCoarPart =         2.0*dxFinePart;
    dxFineFull = refRatio[0]*dxFinePart;
    dxCoarFull =         2.0*dxFineFull;

    //make grids
    DisjointBoxLayout gridsFinePart, gridsCoarPart;
    DisjointBoxLayout gridsFineFull, gridsCoarFull;

    eekflag = makeLayoutPart(gridsCoarPart, domainCoarFull);
    eekflag = makeLayoutFull(gridsCoarFull, domainCoarFull);
    CH_assert(eekflag == 0);
    refine(gridsFinePart, gridsCoarPart, 2);
    refine(gridsFineFull, gridsCoarFull, 2);

    ///create ebislayout
    int nghost = 0;
    EBISLayout ebislFinePart, ebislCoarPart;
    EBISLayout ebislFineFull, ebislCoarFull;

    eekflag = makeEBISL(ebislFinePart, gridsFinePart, domainFinePart, nghost);
    if (eekflag != 0) return eekflag;
    eekflag = makeEBISL(ebislCoarPart, gridsCoarPart, domainCoarPart, nghost);
    if (eekflag != 0) return eekflag;
    eekflag = makeEBISL(ebislFineFull, gridsFineFull, domainFineFull, nghost);
    if (eekflag != 0) return eekflag;
    eekflag = makeEBISL(ebislCoarFull, gridsCoarFull, domainCoarFull, nghost);
    if (eekflag != 0) return eekflag;

    int nvar = 1;
    EBCellFactory ebcellfactFinePart(ebislFinePart);
    EBCellFactory ebcellfactCoarPart(ebislCoarPart);
    LevelData<EBCellFAB> errorFinePart(gridsFinePart, nvar,
                                   IntVect::Zero,ebcellfactFinePart);
    LevelData<EBCellFAB> errorCoarPart(gridsCoarPart, nvar,
                                   IntVect::Zero,ebcellfactCoarPart);

    eekflag = getError(errorFinePart,
                       ebislFinePart, gridsFinePart, domainFinePart, dxFinePart,
                       ebislFineFull, gridsFineFull, domainFineFull, dxFineFull,
                       refRatio[0]);
    if (eekflag != 0) return eekflag;

    eekflag = getError(errorCoarPart,
                       ebislCoarPart, gridsCoarPart, domainCoarPart, dxCoarPart,
                       ebislCoarFull, gridsCoarFull, domainCoarFull, dxCoarFull,
                       refRatio[0]);
    if (eekflag != 0) return eekflag;

    eekflag =  compareError(errorFinePart, ebislFinePart, gridsFinePart, domainFinePart,
                            errorCoarPart, ebislCoarPart, gridsCoarPart, domainCoarPart);
    if (eekflag != 0) return eekflag;


#if CH_SPACEDIM==2
    string fileFine("pltFineError.2d.hdf5");
    string fileCoar("pltCoarError.2d.hdf5");
#else
    string fileFine("pltFineError.3d.hdf5");
    string fileCoar("pltCoarError.3d.hdf5");
#endif

    outputError(errorFinePart,
                errorCoarPart,
                gridsFinePart,
                gridsCoarPart,
                domainFinePart,
                domainCoarPart,
                fileFine,
                fileCoar);

  }//end omnipresent scoping trick
  CH_XD::EBIndexSpace* ebisPtr = Chombo_EBIS::instance();
  ebisPtr->clear();
#ifdef CH_MPI
  MPI_Finalize();
#endif
  return eekflag;
}