// member functions void Matrix::read(istream &in) { clear(); set<string> opt; bool IsSymmetric; readHeader(in, opt); if (isDefined(opt, "symmetric")) { IsSymmetric = true; } else if (isDefined(opt, "general")) { IsSymmetric = false; } else throw MatrixError::ReadError("Matrix: Not general, neither symmetric"); size_t n, m, nnz; in >> n >> m; if (IsSymmetric && (m != n)) throw MatrixError::ReadError(stringAndTwoNumbers("Matrix: Symmetric but number of columns is not equal to number of rows", n, m)); resize(n, m); if (isDefined(opt, "array")) { readData(in, n, m, IsSymmetric); } else if (isDefined(opt, "coordinate")) { in >> nnz; readDataSparse(in, nnz, IsSymmetric); }
void ShaderPart::preprocess() { processed_source.clear(); // NOTE: this preprocessor only handles basic ifdef / endif blocks std::vector<std::string> matches; std::stringstream in(raw_source); std::string line; bool skipdef = false; while( std::getline(in,line) ) { if(Shader_ifdef.match(line, &matches)) { if( (matches[0] == "ifdef" && !isDefined(matches[1])) || (matches[0] == "ifndef" && isDefined(matches[1])) ) { skipdef = true; } continue; } if(Shader_endif.match(line, &matches)) { skipdef = false; continue; } if(!skipdef) { applyDefines(line); processed_source.append(line); processed_source.append("\n"); } } }
//----------------------------------------------------------------------------// void ImageManager::elementImageStart(const XMLAttributes& attributes) { const String image_name(s_texture->getName() + '/' + attributes.getValueAsString(ImageNameAttribute)); if (isDefined(image_name)) { Logger::getSingleton().logEvent( "[ImageManager] WARNING: Using existing image :" + image_name); return; } XMLAttributes rw_attrs(attributes); // rewrite the name attribute to include the texture name rw_attrs.add(ImageNameAttribute, image_name); if (!rw_attrs.exists(ImageTextureAttribute)) rw_attrs.add(ImageTextureAttribute, s_texture->getName()); if (!rw_attrs.exists(ImagesetAutoScaledAttribute)) rw_attrs.add(ImagesetAutoScaledAttribute, PropertyHelper<AutoScaledMode>::toString(s_autoScaled)); if (!rw_attrs.exists(ImagesetNativeHorzResAttribute)) rw_attrs.add(ImagesetNativeHorzResAttribute, PropertyHelper<float>::toString(s_nativeResolution.d_width)); if (!rw_attrs.exists(ImagesetNativeVertResAttribute)) rw_attrs.add(ImagesetNativeVertResAttribute, PropertyHelper<float>::toString(s_nativeResolution.d_height)); d_deleteChaniedHandler = false; d_chainedHandler = &create(rw_attrs); }
EBCellFAB& EBCellFAB::divide(const EBCellFAB& a_src, int a_srccomp, int a_destcomp, int a_numcomp) { CH_assert(isDefined()); CH_assert(a_src.isDefined()); // Dan G. feels strongly that the assert below should NOT be commented out // Brian feels that a weaker version of the CH_assert (if possible) is needed // Terry is just trying to get his code to work //CH_assert(m_ebisBox == a_src.m_ebisBox); CH_assert(a_srccomp + a_numcomp <= a_src.m_nComp); CH_assert(a_destcomp + a_numcomp <= m_nComp); bool sameRegBox = (a_src.m_regFAB.box() == m_regFAB.box()); Box locRegion = a_src.m_region & m_region; if (!locRegion.isEmpty()) { FORT_DIVIDETWOFAB(CHF_FRA(m_regFAB), CHF_CONST_FRA(a_src.m_regFAB), CHF_BOX(locRegion), CHF_INT(a_srccomp), CHF_INT(a_destcomp), CHF_INT(a_numcomp)); if (sameRegBox && (locRegion == m_region && locRegion == a_src.m_region)) { Real* l = m_irrFAB.dataPtr(a_destcomp); const Real* r = a_src.m_irrFAB.dataPtr(a_srccomp); int nvof = m_irrFAB.numVoFs(); CH_assert(nvof == a_src.m_irrFAB.numVoFs()); for (int i=0; i<a_numcomp*nvof; i++) l[i]/=r[i]; } else { IntVectSet ivsMulti = a_src.getMultiCells(); ivsMulti &= getMultiCells(); ivsMulti &= locRegion; IVSIterator ivsit(ivsMulti); for (ivsit.reset(); ivsit.ok(); ++ivsit) { const IntVect& iv = ivsit(); Vector<VolIndex> vofs = m_ebisBox.getVoFs(iv); for (int ivof = 0; ivof < vofs.size(); ivof++) { const VolIndex& vof = vofs[ivof]; for (int icomp = 0; icomp < a_numcomp; ++icomp) { m_irrFAB(vof, a_destcomp+icomp) /= a_src.m_irrFAB(vof, a_srccomp+icomp); } } } } } return *this; }
// Number of flux variables int PolytropicPhysics::numFluxes() { CH_assert(isDefined()); // In some computations there may be more fluxes than conserved variables return UNUM; }
/* * Generate a class reference, including its owning module if necessary and * handling forward references if necessary. */ static void prClassRef(classDef *cd, moduleDef *mod, ifaceFileList *defined, int pep484, FILE *fp) { if (pep484) { /* * We assume that an external class will be handled properly by some * handwritten type hint code. */ int is_defined = (isExternal(cd) || isDefined(cd->iff, cd->ecd, mod, defined)); if (!is_defined) fprintf(fp, "'"); if (cd->iff->module != mod) fprintf(fp, "%s.", cd->iff->module->name); prScopedPythonName(fp, cd->ecd, cd->pyname->text); if (!is_defined) fprintf(fp, "'"); } else { prScopedPythonName(fp, cd->ecd, cd->pyname->text); } }
EBCellFAB& EBCellFAB::operator+=(const Real& a_src) { CH_assert(isDefined()); FORT_ADDFABR(CHF_FRA(m_regFAB), CHF_CONST_REAL(a_src), CHF_BOX(m_region)); Real* l = m_irrFAB.dataPtr(0); int nvof = m_irrFAB.numVoFs(); for (int i=0; i<m_nComp*nvof; i++) l[i] += a_src; // const IntVectSet& ivsMulti = getMultiCells(); // IVSIterator ivsit(ivsMulti); // for (ivsit.reset(); ivsit.ok(); ++ivsit) // { // const IntVect& iv = ivsit(); // Vector<VolIndex> vofs = m_ebisBox.getVoFs(iv); // for (int ivof = 0; ivof < vofs.size(); ivof++) // { // const VolIndex& vof = vofs[ivof]; // for (int icomp = 0; icomp < m_nComp; ++icomp) // { // m_irrFAB(vof, icomp) += a_src; // } // } // } return *this; }
/** Return the number of flux variables. This can be greater than the number of conserved variables if addition fluxes/face-centered quantities are computed. */ int LinElastPhysics::numFluxes() { CH_assert(isDefined()); // In some computations there may be more fluxes than conserved variables return numConserved(); }
void ScriptPreprocessor::parseDirective(std::string & str, size_t & i) { size_t begin = i; // Skip the beginChar if (++i >= str.size()) return; std::string directive; parseWord(str, i, directive); if (directive == "if") { std::string expression; parseExpression(str, i, expression); if (!isDefined(expression)) { disableBlock(str, i); } } else { u32 lineNumber = retrieveLineNumber(str, i); SN_ERROR("Unrecognized preprocessor directive '" << directive << "' in file '" << m_fileName << "' near line " << (lineNumber + 1)); return; } }
/** Return the names of the conserved variables. */ Vector<string> LinElastPhysics::stateNames() { CH_assert(isDefined()); Vector<string> retval; retval.push_back("v_x^1"); retval.push_back("v_y^1"); retval.push_back("v_z^1"); retval.push_back("sig_xx^1"); retval.push_back("sig_yy^1"); retval.push_back("sig_zz^1"); retval.push_back("sig_xy^1"); retval.push_back("sig_xz^1"); retval.push_back("sig_yz^1"); retval.push_back("lambda^1"); retval.push_back("gamma^1"); retval.push_back("v_x^2"); retval.push_back("v_y^2"); retval.push_back("v_z^2"); retval.push_back("sig_xx^2"); retval.push_back("sig_yy^2"); retval.push_back("sig_zz^2"); retval.push_back("sig_xy^2"); retval.push_back("sig_xz^2"); retval.push_back("sig_yz^2"); retval.push_back("lambda^2"); retval.push_back("gamma^2"); return retval; }
inline void QtXorArg::check() const { if( isRequired() && !isDefined() ) throw QtArgNotDefinedMandatoryArgumentEx( QString::fromLatin1( "Not defined mandatory argument: %1" ) .arg( m_name ) ); QString definedArgumentName; foreach( QtArgIface * arg, m_args ) { arg->check(); if( arg->isDefined() && !definedArgumentName.isEmpty() ) throw QtArgXORMaskNotObservedEx( QString::fromLatin1( "Defined more than one argument under XOR mask." " First defined argument: %1. Second defined argument: %2." ) .arg( definedArgumentName ) .arg( arg->names().size() ? arg->names().front() : arg->flags().front() ) ); if( arg->isDefined() ) definedArgumentName = ( arg->names().size() ? arg->names().front() : arg->flags().front() ); }
EBCellFAB& EBCellFAB::negate(void) { CH_assert(isDefined()); (*this) *= -1.0; return *this; }
void PatchGodunov::updateState(FArrayBox& a_U, FluxBox& a_F, Real& a_maxWaveSpeed, const FArrayBox& a_S, const Real& a_dt, const Box& a_box) { CH_assert(isDefined()); CH_assert(a_box == m_currentBox); int numPrim = m_gdnvPhysics->numPrimitives(); int numFlux = m_gdnvPhysics->numFluxes(); FluxBox whalf(a_box,numPrim); whalf.setVal(0.0); a_F.resize(a_box,numFlux); a_F.setVal(0.0); computeWHalf(whalf, a_U, a_S, a_dt, a_box); FArrayBox dU(a_U.box(),a_U.nComp()); computeUpdate(dU, a_F, a_U, whalf, a_dt, a_box); a_U += dU; // Get and return the maximum wave speed on this patch/grid a_maxWaveSpeed = m_gdnvPhysics->getMaxWaveSpeed(a_U, m_currentBox); }
DefineManager::DefineManagerReturnCode DefineManager::addDefineMap(const string& src, const DefineRec& rec) { if(eDefMgrDefined == isDefined(src)) { return eDefMgrDoubleDefineMacro; } if (rec.key != src) { return eDefMgrKeyDiffFromSrc; } mSrcLexMap[src] = rec; #ifdef DEBUG JZWRITE_DEBUG("add define:[key:%s,value:%s,isVarArgs:%d]",src.c_str(),rec.defineStr.c_str(), rec.isVarArgs); for(int i = 0 ; i < rec.formalParam.size(); i++) { JZWRITE_DEBUG("param : %s", rec.formalParam[i].word.c_str()); } #endif for(int i = 0; i < rec.formalParam.size() ; i++ ) { string word = rec.formalParam[i].word; mSrcLexMap[src].paramMap[word] = i; } return eDefMgrNoError; }
const DefineRec* DefineManager::findDefineMap(const string& srcDefine) { if (eDefMgrNotDefined == isDefined(srcDefine)) { return NULL; } //for define macro ,use the one that is latest defined auto it = mSrcLexMap.find(srcDefine); if (mSrcLexMap.end() != it) { return &(it->second); } DefineManager* globalInstance = DefineManager::getGlobalInstance(); if (this != globalInstance && NULL != globalInstance) { auto ret = globalInstance->findDefineMap(srcDefine); if(NULL != ret) { return ret; } } return NULL; }
void TableInfo::get(const RecordType &rec, UINT n, String &v) const { if(!isDefined(rec,n)) { return; } USES_CONVERSION; switch(getColumn(n).getType()) { case DBTYPE_CSTRING : case DBTYPE_CSTRINGN : { char tmp[MAXRECSIZE+1]; getBytes(rec,n,tmp); tmp[m_columns[n].getMaxStringLen()] = 0; v = tmp; } break; case DBTYPE_WSTRING : case DBTYPE_WSTRINGN : { wchar_t tmp[MAXRECSIZE+1]; getBytes(rec,n,tmp); tmp[m_columns[n].getMaxStringLen()] = 0; v = tmp; } break; default: THROWFIELDNOTSTRING(n); } }
// --------------------------------------------------------- void NodeQCFI::coarseFineInterp(LevelData<NodeFArrayBox>& a_phiFine, const LevelData<NodeFArrayBox>& a_phiCoarse, bool a_inhomogeneous) { CH_assert(isDefined()); CH_assert(a_phiFine.nComp() == m_ncomp); CH_assert(a_phiCoarse.nComp() == m_ncomp); if (m_coarsenings == 1) { m_qcfi2[0]->coarseFineInterp(a_phiFine, a_phiCoarse); } else // m_coarsenings >= 2 { // if m_coarsenings == 2: // m_qcfi2[1] = new NodeQuadCFInterp2(a_grids, true); // m_qcfi2[0] = new NodeQuadCFInterp2(a_grids.coarsen(2), false); // m_inter[0] = new LevelData(a_grids.coarsen(2)); // m_qcfi2[0] interpolates m_inter[0] from a_phiCoarse on all of it. // m_qcfi2[1] interpolates a_phiFine from m_inter[0] on interface only. m_qcfi2[0]->coarseFineInterp(*m_inter[0], a_phiCoarse); m_inter[0]->exchange(m_inter[0]->interval()); // Set domain and dx for coarsest level refined by 2. ProblemDomain domain(m_domainPenultimate); Real dx = m_dxPenultimate; bool homogeneous = !a_inhomogeneous; const DisjointBoxLayout& dbl0 = m_inter[0]->disjointBoxLayout(); for (DataIterator dit = dbl0.dataIterator(); dit.ok(); ++dit) { m_bc((*m_inter[0])[dit()], dbl0.get(dit()), domain, dx, homogeneous); } for (int interlev = 1; interlev < m_coarsenings - 1; interlev++) { m_qcfi2[interlev]->coarseFineInterp(*m_inter[interlev], *m_inter[interlev-1]); m_inter[interlev]->exchange(m_inter[interlev]->interval()); domain.refine(2); dx *= 0.5; const DisjointBoxLayout& dbl = m_inter[interlev]->disjointBoxLayout(); for (DataIterator dit = dbl.dataIterator(); dit.ok(); ++dit) { m_bc((*m_inter[interlev])[dit()], dbl.get(dit()), domain, dx, homogeneous); } } m_qcfi2[m_coarsenings-1]->coarseFineInterp(a_phiFine, *m_inter[m_coarsenings-2]); // Don't need to set boundary conditions for a_phiFine // because the calling function will do that. } }
/** Given input left and right states in a direction, a_dir, compute a Riemann problem and generate fluxes at the faces within a_box. */ void LinElastPhysics::riemann(/// face-centered solution to Riemann problem FArrayBox& a_WStar, /// left state, on cells to left of each face const FArrayBox& a_WLeft, /// right state, on cells to right of each face const FArrayBox& a_WRight, /// state on cells, used to set boundary conditions const FArrayBox& a_W, /// current time const Real& a_time, /// direction of faces const int& a_dir, /// face-centered box on which to set a_WStar const Box& a_box) { //JK pout() << "LinElastPhysics::riemann" << endl; CH_assert(isDefined()); CH_assert(a_WStar.box().contains(a_box)); // Get the numbers of relevant variables int numPrim = numPrimitives(); CH_assert(a_WStar .nComp() == numPrim); CH_assert(a_WLeft .nComp() == numPrim); CH_assert(a_WRight.nComp() == numPrim); // Cast away "const" inputs so their boxes can be shifted left or right // 1/2 cell and then back again (no net change is made!) FArrayBox& shiftWLeft = (FArrayBox&)a_WLeft; FArrayBox& shiftWRight = (FArrayBox&)a_WRight; // Solution to the Riemann problem // Shift the left and right primitive variable boxes 1/2 cell so they are // face centered shiftWLeft .shiftHalf(a_dir, 1); shiftWRight.shiftHalf(a_dir,-1); CH_assert(shiftWLeft .box().contains(a_box)); CH_assert(shiftWRight.box().contains(a_box)); // Riemann solver computes Wgdnv all edges that are not on the physical // boundary. FORT_RIEMANNF(CHF_FRA(a_WStar), CHF_CONST_FRA(shiftWLeft), CHF_CONST_FRA(shiftWRight), CHF_CONST_INT(a_dir), CHF_BOX(a_box)); // Call boundary Riemann solver (note: periodic BC's are handled there). m_bc->primBC(a_WStar,shiftWLeft ,a_W,a_dir,Side::Hi,a_time); m_bc->primBC(a_WStar,shiftWRight,a_W,a_dir,Side::Lo,a_time); // Shift the left and right primitive variable boxes back to their original // position. shiftWLeft .shiftHalf(a_dir,-1); shiftWRight.shiftHalf(a_dir, 1); }
/** Return the number of primitive variables. This may be greater than the number of conserved variables if derived/redundant quantities are also stored for convenience. */ int LinElastPhysics::numPrimitives() { CH_assert(isDefined()); //JK pout() << "LinElastPhysics::numPrimitives" << endl; //JK Same for us return numConserved(); }
// Number of primitive variables int PolytropicPhysics::numPrimitives() { CH_assert(isDefined()); // This doesn't equal the number of conserved variables because // auxiliary/redundant variable may be computed and stored return WNUM; }
bool Possibilities::isSolved() { for (int i = 0; i < PUZZLE_SIZE; i++) for (int j = 0; j < PUZZLE_SIZE; j++) if (! isDefined(i, j)) return false; return true; }
void EBMGAverage::averageFAB(EBCellFAB& a_coar, const Box& a_boxCoar, const EBCellFAB& a_refCoar, const DataIndex& a_datInd, const Interval& a_variables) const { CH_TIMERS("EBMGAverage::average"); CH_TIMER("regular_average", t1); CH_TIMER("irregular_average", t2); CH_assert(isDefined()); const Box& coarBox = a_boxCoar; //do all cells as if they were regular Box refBox(IntVect::Zero, IntVect::Zero); refBox.refine(m_refRat); int numFinePerCoar = refBox.numPts(); BaseFab<Real>& coarRegFAB = a_coar.getSingleValuedFAB(); const BaseFab<Real>& refCoarRegFAB = a_refCoar.getSingleValuedFAB(); //set to zero because the fortran is a bit simpleminded //and does stuff additively a_coar.setVal(0.); CH_START(t1); for (int comp = a_variables.begin(); comp <= a_variables.end(); comp++) { FORT_REGAVERAGE(CHF_FRA1(coarRegFAB,comp), CHF_CONST_FRA1(refCoarRegFAB,comp), CHF_BOX(coarBox), CHF_BOX(refBox), CHF_CONST_INT(numFinePerCoar), CHF_CONST_INT(m_refRat)); } CH_STOP(t1); //this is really volume-weighted averaging even though it does //not look that way. //so (in the traditional sense) we want to preserve //rhoc * volc = sum(rhof * volf) //this translates to //volfrac_C * rhoC = (1/numFinePerCoar)(sum(volFrac_F * rhoF)) //but the data input to this routine is all kappa weigthed so //the volumefractions have already been multiplied //which means // rhoC = (1/numFinePerCoar)(sum(rhoF)) //which is what this does CH_START(t2); for (int comp = a_variables.begin(); comp <= a_variables.end(); comp++) { m_averageEBStencil[a_datInd]->apply(a_coar, a_refCoar, false, comp); } CH_STOP(t2); }
void EBCoarseAverage::average(LevelData<EBFluxFAB>& a_coarData, const LevelData<EBFluxFAB>& a_fineData, const Interval& a_variables) { CH_TIME("EBCoarseAverage::average(LD<EBFluxFAB>)"); LevelData<EBFluxFAB> coarFiData; LevelData<EBFluxFAB> fineBuffer; CH_assert(isDefined()); { CH_TIME("buffer allocation"); EBFluxFactory factCoFi(m_eblgCoFi.getEBISL()); coarFiData.define( m_eblgCoFi.getDBL(), m_nComp, IntVect::Zero, factCoFi); if (m_useFineBuffer) { EBFluxFactory factFine(m_eblgFine.getEBISL()); fineBuffer.define(m_eblgFine.getDBL(), m_nComp, IntVect::Zero, factFine); } } if (m_useFineBuffer) { CH_TIME("fine_copy"); a_fineData.copyTo(a_variables, fineBuffer, a_variables); } { CH_TIME("averaging"); for (DataIterator dit = m_eblgFine.getDBL().dataIterator(); dit.ok(); ++dit) { const EBFluxFAB* fineFABPtr = NULL; if (m_useFineBuffer) { fineFABPtr = &fineBuffer[dit()]; } else { fineFABPtr = &a_fineData[dit()]; } EBFluxFAB& cofiFAB = coarFiData[dit()]; const EBFluxFAB& fineFAB = *fineFABPtr; for (int idir = 0; idir < SpaceDim; idir++) { averageFAB(cofiFAB[idir], fineFAB[idir], dit(), a_variables, idir); } } } { CH_TIME("copy_coar"); coarFiData.copyTo(a_variables, a_coarData, a_variables); } }
void MappedLevelFluxRegister::incrementCoarse(const FArrayBox& a_coarseFlux, Real a_scale, const DataIndex& a_coarseDataIndex, const Interval& a_srcInterval, const Interval& a_dstInterval, int a_dir, Side::LoHiSide a_sd) { CH_assert(isDefined()); if (!(m_isDefined & FluxRegCoarseDefined)) return; CH_TIME("MappedLevelFluxRegister::incrementCoarse"); const Vector<Box>& intersect = m_coarseLocations[a_dir + a_sd * CH_SPACEDIM][a_coarseDataIndex]; FArrayBox& coarse = m_coarFlux[a_coarseDataIndex]; // We cast away the constness in a_coarseFlux for the scope of this function. This // should be acceptable, since at the end of the day there is no change to it. -JNJ FArrayBox& coarseFlux = const_cast<FArrayBox&>(a_coarseFlux); // Muhahaha. coarseFlux.shiftHalf(a_dir, sign(a_sd)); Real scale = -sign(a_sd) * a_scale; int s = a_srcInterval.begin(); int d = a_dstInterval.begin(); int size = a_srcInterval.size(); for (int b = 0; b < intersect.size(); ++b) { const Box& box = intersect[b]; Vector<Real> regbefore(coarse.nComp()); Vector<Real> regafter(coarse.nComp()); if (s_verbose && (a_dir == debugdir) && box.contains(ivdebnoeb)) { for (int ivar = 0; ivar < coarse.nComp(); ivar++) { regbefore[ivar] = coarse(ivdebnoeb, ivar); } } coarse.plus(coarseFlux, box, box, scale, s, d, size); if (s_verbose && (a_dir == debugdir) && box.contains(ivdebnoeb)) { for (int ivar = 0; ivar < coarse.nComp(); ivar++) { regafter[ivar] = coarse(ivdebnoeb, ivar); } pout() << "levelfluxreg::incrementCoar: scale = " << scale << ", "; for (int ivar = 0; ivar < coarse.nComp(); ivar++) { pout() << " input flux = " << coarseFlux(ivdebnoeb, ivar) << ", "; pout() << " reg before = " << regbefore[ivar] << ", "; pout() << " reg after = " << regafter[ivar] << ", "; } pout() << endl; } } coarseFlux.shiftHalf(a_dir, - sign(a_sd)); }
/** * Convert PDB type representation into common type representation. * @param type PDB type. * @return Common type representation. */ retdec_config::Type DebugFormat::loadPdbType(pdbparser::PDBTypeDef* type) { if (type == nullptr) { return retdec_config::Type("i32"); } auto t = retdec_config::Type(type->to_llvm()); return t.isDefined() ? t : retdec_config::Type("i32"); }
void EBCoarseAverage::average(LevelData<BaseIVFAB<Real> >& a_coarData, const LevelData<BaseIVFAB<Real> >& a_fineData, const Interval& a_variables) { CH_TIME("EBCoarseAverage::average(LD<BaseIVFAB>)"); LevelData<BaseIVFAB<Real> > coarFiData; LevelData<BaseIVFAB<Real> > fineBuffer; CH_assert(isDefined()); { CH_TIME("buffer allocation"); BaseIVFactory<Real> factCoFi(m_eblgCoFi.getEBISL(), m_irregSetsCoFi); coarFiData.define(m_eblgCoFi.getDBL(), m_nComp, IntVect::Zero, factCoFi); if (m_useFineBuffer) { BaseIVFactory<Real> factFine(m_eblgFine.getEBISL(), m_irregSetsFine); coarFiData.define(m_eblgFine.getDBL(), m_nComp, IntVect::Zero, factFine); } } if (m_useFineBuffer) { CH_TIME("fine_copy"); a_fineData.copyTo(a_variables, fineBuffer, a_variables); } { CH_TIME("averaging"); int ifnerg = 0; for (DataIterator dit = m_eblgFine.getDBL().dataIterator(); dit.ok(); ++dit) { const BaseIVFAB<Real>* fineFABPtr = NULL; if (m_useFineBuffer) { fineFABPtr = &fineBuffer[dit()]; } else { fineFABPtr = &a_fineData[dit()]; } BaseIVFAB<Real>& cofiFAB = coarFiData[dit()]; const BaseIVFAB<Real>& fineFAB = *fineFABPtr; averageFAB(cofiFAB, fineFAB, dit(), a_variables); ifnerg++; } } { CH_TIME("copy_coar"); coarFiData.copyTo(a_variables, a_coarData, a_variables); } }
EBCellFAB& EBCellFAB::plus(const EBCellFAB& a_src, const Box& a_region, int a_srccomp, int a_destcomp, int a_numcomp) { CH_assert(isDefined()); CH_assert(a_src.isDefined()); CH_assert(a_srccomp + a_numcomp <= a_src.m_nComp); CH_assert(a_destcomp + a_numcomp <= m_nComp); const Box& locRegion = a_region; bool sameRegBox = (a_src.m_regFAB.box() == m_regFAB.box()); if (!locRegion.isEmpty()) { FORT_ADDTWOFAB(CHF_FRA(m_regFAB), CHF_CONST_FRA(a_src.m_regFAB), CHF_BOX(locRegion), CHF_INT(a_srccomp), CHF_INT(a_destcomp), CHF_INT(a_numcomp)); if (sameRegBox && (locRegion == m_region && locRegion == a_src.m_region)) { Real* l = m_irrFAB.dataPtr(a_destcomp); const Real* r = a_src.m_irrFAB.dataPtr(a_srccomp); int nvof = m_irrFAB.numVoFs(); CH_assert(nvof == a_src.m_irrFAB.numVoFs()); for (int i=0; i<a_numcomp*nvof; i++) l[i]+=r[i]; } else { IntVectSet ivsMulti = a_src.getMultiCells(); ivsMulti &= getMultiCells(); ivsMulti &= locRegion; IVSIterator ivsit(ivsMulti); for (ivsit.reset(); ivsit.ok(); ++ivsit) { const IntVect& iv = ivsit(); Vector<VolIndex> vofs = m_ebisBox.getVoFs(iv); for (int ivof = 0; ivof < vofs.size(); ivof++) { const VolIndex& vof = vofs[ivof]; for (int icomp = 0; icomp < a_numcomp; ++icomp) { m_irrFAB(vof, a_destcomp+icomp) += a_src.m_irrFAB(vof, a_srccomp+icomp); } } } } } return *this; }
AST * PreProcessor::expression() { List<Token> exps; while (!tokenit.eof() && !tokenit.is(_PP_END)) { const Token &t = tokenit.get(0); switch (t.id) { case _IDENT: { bool replaced = identifier(); if (!replaced) { exps.push_back(t); } continue; } //'defined' expression is pre-evaluated here case _PP_DEFINED: { tokenit.next(); bool lparen = tokenit.eat(_LPAREN); if (!tokenit.is(_IDENT)){ ERROR("'defined' error"); } bool defined = isDefined(tokenit.val()->toString()); tokenit.next(); if (lparen && !tokenit.eat(_RPAREN)) { ERROR("'defined' error"); return false; } Token newt; newt.id = _DECIMAL_CONSTANT; if (defined) { newt.val = new TokenInt("<defined 1>", 1); } else { newt.val = new TokenInt("<defined 0>", 0); } exps.push_back(newt); continue; } case _SPC: //don't push spaces break; default: exps.push_back(t); } tokenit.next(); } DBG("expression %d", exps.size()); ptokens(exps); DBG("---------"); if (tokenit.is(_PP_END)) { tokenit.next(); } return parser.parseConstantExpression(exps); }
/** Compute the characteristic values (eigenvalues) IMPORTANT NOTE: It is assumed that the characteristic analysis puts the smallest eigenvalue first, the largest eigenvalue last, and orders the characteristic variables accordingly. */ void LinElastPhysics::charValues(FArrayBox& a_lambda, const FArrayBox& a_W, const int& a_dir, const Box& a_box) { //JK pout() << "LinElastPhysics::charValues" << endl; CH_assert(isDefined()); FORT_CHARVALUESF(CHF_FRA(a_lambda), CHF_BOX(a_box)); }
// static int32_t ColorUtils::wrapColorAspectsIntoColorRange(ColorAspects::Range range) { ColorRange res; if (sRanges.map(range, &res)) { return res; } else if (!isValid(range)) { return kColorRangeUnspecified; } else { CHECK(!isDefined(range)); // all platform values are in sRanges return kColorRangeVendorStart + range; } }