PARTICLEDLL_API void pRandomVelocity(PDomainEnum dtype, float a0, float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8) { PARandomVelocity S; S.gen_vel = pDomain(dtype, a0, a1, a2, a3, a4, a5, a6, a7, a8); _pSendAction(&S, PARandomVelocityID, sizeof(PARandomVelocity)); }
PARTICLEDLL_API void pRandomDisplace(PDomainEnum dtype, float a0, float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8) { PARandomDisplace S; S.gen_disp = pDomain(dtype, a0, a1, a2, a3, a4, a5, a6, a7, a8); _pSendAction(&S, PARandomDisplaceID, sizeof(PARandomDisplace)); }
PARTICLEDLL_API void pRandomAccel(PDomainEnum dtype, float a0, float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8) { PARandomAccel S; S.gen_acc = pDomain(dtype, a0, a1, a2, a3, a4, a5, a6, a7, a8); _pSendAction(&S, PARandomAccelID, sizeof(PARandomAccel)); }
PARTICLEDLL_API void pSinkVelocity(bool kill_inside, PDomainEnum dtype, float a0, float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8) { PASinkVelocity S; S.kill_inside = kill_inside; S.velocity = pDomain(dtype, a0, a1, a2, a3, a4, a5, a6, a7, a8); _pSendAction(&S, PASinkVelocityID, sizeof(PASinkVelocity)); }
BOOL AppDomainStackEntry::IsHomogeneousWithNoStackModifiers(void) { LIMITED_METHOD_CONTRACT; if (m_domainID.m_dwId == INVALID_APPDOMAIN_ID || m_dwOverridesCount != 0 || m_dwAsserts != 0) return FALSE; AppDomainFromIDHolder pDomain(m_domainID, FALSE); if (pDomain.IsUnloaded()) return FALSE; IApplicationSecurityDescriptor *currAppSecDesc = pDomain->GetSecurityDescriptor(); if (currAppSecDesc == NULL) return FALSE; return (currAppSecDesc->IsHomogeneous() && !currAppSecDesc->ContainsAnyRefusedPermissions()); }
BOOL AppDomainStackEntry::IsFullyTrustedWithNoStackModifiers(void) { LIMITED_METHOD_CONTRACT; if (m_domainID.m_dwId == INVALID_APPDOMAIN_ID || m_dwOverridesCount != 0 || m_dwAsserts != 0) return FALSE; AppDomainFromIDHolder pDomain(m_domainID, FALSE); if (pDomain.IsUnloaded()) return FALSE; IApplicationSecurityDescriptor *currAppSecDesc = pDomain->GetSecurityDescriptor(); if (currAppSecDesc == NULL) return FALSE; return Security::CheckDomainWideSpecialFlag(currAppSecDesc, 1 << SECURITY_FULL_TRUST); }
PARTICLEDLL_API void pBounce(float friction, float resilience, float cutoff, PDomainEnum dtype, float a0, float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8) { PABounce S; S.position = pDomain(dtype, a0, a1, a2, a3, a4, a5, a6, a7, a8); S.oneMinusFriction = 1.0f - friction; S.resilience = resilience; S.cutoffSqr = fsqr(cutoff); _pSendAction(&S, PABounceID, sizeof(PABounce)); }
PARTICLEDLL_API void pAvoid(float magnitude, float epsilon, float look_ahead, PDomainEnum dtype, float a0, float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8) { PAAvoid S; S.position = pDomain(dtype, a0, a1, a2, a3, a4, a5, a6, a7, a8); S.magnitude = magnitude; S.epsilon = epsilon; S.look_ahead = look_ahead; _pSendAction(&S, PAAvoidID, sizeof(PAAvoid)); }
BOOL AppDomainStackEntry::HasFlagsOrFullyTrustedWithNoStackModifiers(DWORD flags) { LIMITED_METHOD_CONTRACT; if (m_domainID.m_dwId == INVALID_APPDOMAIN_ID || m_dwOverridesCount != 0 || m_dwAsserts != 0) return FALSE; AppDomainFromIDHolder pDomain(m_domainID, FALSE); if (pDomain.IsUnloaded()) return FALSE; IApplicationSecurityDescriptor *currAppSecDesc = pDomain->GetSecurityDescriptor(); if (currAppSecDesc == NULL) return FALSE; // either the desired flag (often 0) or fully trusted will do flags |= (1<<SECURITY_FULL_TRUST); return Security::CheckDomainWideSpecialFlag(currAppSecDesc, flags); }
PARTICLEDLL_API void pSource(float particle_rate, PDomainEnum dtype, float a0, float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8) { _ParticleState &_ps = _GetPState(); PASource S; S.particle_rate = particle_rate; S.position = pDomain(dtype, a0, a1, a2, a3, a4, a5, a6, a7, a8); S.positionB = _ps.VertexB; S.size = _ps.Size; S.velocity = _ps.Vel; S.color = _ps.Color; S.alpha = _ps.Alpha; S.age = _ps.Age; S.age_sigma = _ps.AgeSigma; S.vertexB_tracks = _ps.vertexB_tracks; _pSendAction(&S, PASourceID, sizeof(PASource)); }
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; }