int main () { int x1, x2, x3; printf("\nvvedite 3 shesla sherez probel: "); scanf("%d %d %d", &x1, &x2, &x3); printf("\n\nshisla v diapazone ot -5 do 8:"); riv(x1); riv(x2); riv(x3); return 0; }
//_______________________________________________________________________________________________________ int r2iv_1 (void) { // TVolumeView *view = ATLS->FindByName("OUTE"); TR2iv riv(Oute, 1, 2); TIVShape::SetCut(3); riv.Draw("qqq.iv"); return 0; }
PetscErrorCode setupGrids( Vector<int> &a_refratios, // out Vector<ProblemDomain> &a_domains, // out Vector<DisjointBoxLayout> &a_grids, // in/out int a_nLevs, Real &a_cdx, // out Vector<RefCountedPtr<LevelData<FArrayBox> > > a_exact, Vector<RefCountedPtr<LevelData<FArrayBox> > > a_phi, Real a_max_norm_error, Vector<IntVectSet> &a_tagVects, bool &a_same // out ) { CH_TIME("setupGrids"); const int new_level=a_nLevs-1; bool isperiodic[3] = {false,false,false}; PetscFunctionBeginUser; a_cdx = 1./s_nCells0; // out a_refratios.resize(a_nLevs-1); a_domains.resize(a_nLevs); a_grids.resize(a_nLevs); if (a_nLevs==1) { Vector<int> procAssign; Vector<Box> boxvector; Box levbox(IntVect::Zero,(s_nCells0-1)*IntVect::Unit), dombox=levbox; pout() << "setupGrids for level " << new_level+1 << "/" << a_nLevs << ". level domain " << levbox << endl; domainSplit(levbox, boxvector, s_maxboxsz, s_blockingfactor); // need blocking factor of 4 for C-F LoadBalance( procAssign, boxvector ); a_grids[new_level].define(boxvector,procAssign); a_domains[new_level].define(dombox,isperiodic); a_same = false; } else { Vector<Vector<Box> > old_grids(a_nLevs-1); int new_finest_level; Real fillRatio = .8; BRMeshRefine refiner; Box curr_dom_box; static double thresh; // refratio a_refratios[new_level-1] = s_refRatio; // make new domain { Box dombox = a_domains[new_level-1].domainBox(); dombox.refine(s_refRatio); a_domains[new_level].define(dombox,isperiodic); } refiner.define(a_domains[0],a_refratios,fillRatio,s_blockingfactor,s_nesting,s_maxboxsz); Real dx = a_cdx; if (a_nLevs==2) { // get max_grad on coarsest level - has the whole domain double max_ = 0.; const DisjointBoxLayout& dbl = a_grids[0]; for (DataIterator dit = dbl.dataIterator(); dit.ok(); ++dit) { FArrayBox& exactFAB = (*a_exact[0])[dit]; FArrayBox& phiFAB = (*a_phi[0])[dit]; Box region = dbl[dit]; for (BoxIterator bit(region); bit.ok(); ++bit) { const IntVect& iv = bit(); Real grad = 0., tt; if (s_amr_type_iserror) { tt = fabs(phiFAB(iv,0)-exactFAB(iv,0)); if (tt>max_) max_ = tt; } else { for (int dir=0; dir<SpaceDim; ++dir) { IntVect liv(iv), riv(iv); liv.shift(dir,-1); riv.shift(dir,1); tt = (exactFAB(riv,0)-exactFAB(liv,0))/(2.*dx); grad += tt*tt; } grad = sqrt(grad); if (grad>max_) max_ = grad; } } } #ifdef CH_MPI MPI_Allreduce( &max_, &thresh, 1, MPI_DOUBLE, MPI_MAX, PETSC_COMM_WORLD ); #else thresh = max_; #endif // set thresh thresh /= 2.; } // make tags curr_dom_box = a_domains[0].domainBox(); // used for hard wired refinement for (int ilev=0;ilev<new_level;ilev++) { const DisjointBoxLayout& dbl = a_grids[ilev]; for (DataIterator dit = dbl.dataIterator(); dit.ok(); ++dit) { FArrayBox& exactFAB = (*a_exact[ilev])[dit]; FArrayBox& phiFAB = (*a_phi[ilev])[dit]; Box region = dbl[dit]; for (BoxIterator bit(region); bit.ok(); ++bit) { const IntVect& iv = bit(); if (s_amr_type_iserror) { Real error = fabs(phiFAB(iv,0)-exactFAB(iv,0)); if (error > thresh) a_tagVects[ilev] |= iv; // real AMR } else // grad { Real grad = 0., tt; for (int dir=0; dir<SpaceDim; ++dir) { IntVect liv(iv), riv(iv); liv.shift(dir,-1); riv.shift(dir,1); tt = (exactFAB(riv,0)-exactFAB(liv,0))/(2.*dx); grad += tt*tt; } grad = sqrt(grad); if (grad > thresh) a_tagVects[ilev] |= iv; // real AMR } } } // grid // hardwire refinement in fake place IntVect se = a_domains[ilev].domainBox().smallEnd(); //se.shift(1,curr_dom_box.size(1)-1); a_tagVects[ilev] |= se; curr_dom_box.refine(s_refRatio); dx /= s_refRatio; thresh *= s_error_thresh; } // make old_grids, need to make all because coarse grids can change after refinement for (int ilev=0;ilev<new_level;ilev++) { const DisjointBoxLayout& dbl = a_grids[ilev]; old_grids[ilev].resize(dbl.size()); LayoutIterator lit = dbl.layoutIterator(); int boxIndex = 0; for (lit.begin(); lit.ok(); ++lit, ++boxIndex) { old_grids[ilev][boxIndex] = dbl[lit()]; } } pout() << "setupGrids for level " << new_level+1 << "/" << a_nLevs << ". level domain " << a_domains[new_level].domainBox() << endl; // want to keep these Vector<IntVectSet> tagVects_copy(a_nLevs-1); for (int ilev=0;ilev<new_level;ilev++) { tagVects_copy[ilev] = a_tagVects[ilev]; } Vector<Vector<Box> > new_grids; new_finest_level = refiner.regrid( new_grids, tagVects_copy, 0, new_level-1, old_grids ); if (new_finest_level == new_level-1) { a_same = true; } else { // test to see if grids have changed, create new DBLs a_same = true; for (int ilev=1; ilev<=new_finest_level; ++ilev) { int numGridsNew = new_grids[ilev].size(); Vector<int> procIDs(numGridsNew); LoadBalance(procIDs, new_grids[ilev]); const DisjointBoxLayout newDBL( new_grids[ilev], procIDs, a_domains[ilev] ); const DisjointBoxLayout oldDBL = a_grids[ilev]; a_same &= oldDBL.sameBoxes(newDBL); a_grids[ilev] = newDBL; } } if (a_same) { pout() << "setupGrids -- grids unchanged" << endl; } } PetscFunctionReturn(0); }