void test_disassembleBytecodes_should_disassemble_an_array_of_bytecode(void) { char buffer[500] = {0}; int bytecode[20] = {0}; bytecode[0] = ldrImm(REG_4, -128); bytecode[1] = ldrMem(REG_0, REG_1, 8); bytecode[2] = strMem(REG_0, REG_1, 8); bytecode[3] = ldrMemSafe(REG_0, REG_1, 8); bytecode[4] = strMemSafe(REG_0, REG_1, 8); bytecode[5] = movReg(REG_0, DATA, REG_4, NOP, NOP); bytecode[6] = movReg(REG_0, DATA, REG_4, LSL, 4); bytecode[7] = movReg(REG_0, DATA, REG_4, LSR, 2); bytecode[8] = movReg(REG_0, DATA, REG_4, ASR, 6); bytecode[9] = movReg(REG_0, DATA, REG_4, RR, 5); bytecode[10] = ldm(REG_7, R4|R5|R6, INC, UPDATE); bytecode[11] = ldm(REG_7, R0|R5|R6, DEC, NO_UPDATE); bytecode[12] = stm(REG_7, R1|R2|R5|R6, DEC, UPDATE); bytecode[13] = stm(REG_7, R3|R4|R5|R6, INC, NO_UPDATE); bytecode[14] = ldms(REG_7, R3|R4|R5|R6, INC, NO_UPDATE); bytecode[15] = stms(REG_7, R0|R1|R2|R3|R4|R5|R6, DEC, NO_UPDATE); bytecode[16] = halt(); // Indicates end of bytecodes disassembleBytecodes(buffer, bytecode); printf("test_disassembleBytecodes_should_disassemble_an_array_of_bytecode\n"); printf("%s\n", &buffer[0]); }
//------------------------------------------------------------------------------ bool EstimationStateManager::MapObjectsToSTM() { bool retval = true; // Fill in the STM based on the objects that comprise the state vector GmatBase* obj; Integer elementId; //, elementLength; for (UnsignedInt h = 0; h < stateMap.size(); ++h) { obj = stateMap[h]->object; if (stateMap[h]->subelement == 1) { elementId = stateMap[h]->parameterID; // elementLength = stateMap[h]->length; bool hasDstm = obj->HasDynamicParameterSTM(elementId); #ifdef DEBUG_STM_MAPPING MessageInterface::ShowMessage("Prepping for STM; element %s for " "object %s has ID %d and length %d, and %s a dynamic STM " "contribution\n", stateMap[h]->elementName.c_str(), obj->GetName().c_str(), elementId, elementLength, (hasDstm ? "has" : "does not have")); #endif if (hasDstm) { const Rmatrix* dstm = obj->GetParameterSTM(elementId); Integer stmSize = dstm->GetNumRows(); // Fill in the master stm with the current data for (Integer i = 0; i < stmSize; ++i) for (Integer j = 0; j < stmSize; ++j) stm(h+i, h+j) = (*dstm)(i,j); } } } #ifdef DEBUG_STM_MAPPING MessageInterface::ShowMessage("Loaded object STM's; esm STM now contains\n"); for (Integer i = 0; i < stateSize; ++i) { for (Integer j = 0; j < stateSize; ++j) MessageInterface::ShowMessage(" %.12lf", stm(i,j)); MessageInterface::ShowMessage("\n"); } MessageInterface::ShowMessage("\n"); #endif return retval; }
MeasureResult SortMethodAnalyzer::measureSort(const InitializeParameters ¶meters) { int compareCount; SortTimeFunction stm(m_sortMethod, parameters, compareCount); double timeUsage = measureTime(stm, MEASURE_PROCESSTIME); return MeasureResult(parameters.m_elementCount, compareCount, timeUsage*1000); }
void MacroAssembler::lowLevelDebug(const char *s, Register ra, Register rb, Register rc) { Q_ASSERT(ra.code() < 13 && rb.code() < 13 && rc.code() < 13); int preserved = 0x1fff | lr.bit(); stm(db_w, sp, preserved); add(fp, sp, Operand(12*4)); mrs(r4, CPSR); Label omitString; b(&omitString); int sPtr = intptr_t(buffer_ + pcOffset()); do { db(*s); } while (*(s++)); while (pcOffset() & 3) db('\0'); bind(&omitString); ldr(r3, MemOperand(sp, rc.code()*4)); ldr(r2, MemOperand(sp, rb.code()*4)); ldr(r1, MemOperand(sp, ra.code()*4)); mov(r0, Operand(sPtr)); void (*qDebugPtr)(const char *,...) = &qDebug; mov(ip, Operand(intptr_t(qDebugPtr))); blx(ip); msr(CPSR_f, Operand(r4)); ldm(ia_w, sp, preserved); }
/* MAIN::MESSAGE* MAIN::getmessage(){ int DataHead[2]; readdata((char*)DataHead,8); MESSAGE* buffer =(MESSAGE*) new BYTE[DataHead[1]+8]; buffer->Datasize=DataHead[1]; buffer->Mid=DataHead[0]; readdata((char*)buffer->DATA,buffer->Datasize); return buffer; } */ map<string,wstring>* MAIN::getmessage(){ int len; readdata((char*)&len,4); //4 bytes for length and last one for \0 RUNNER* buffer = (RUNNER*)new BYTE[len+5]; memset(buffer,0,len+5); buffer->Datasize=len; readdata((char*)buffer->DATA,len); stringstream stm(buffer->DATA); string line; map<string,wstring> *ret=new map<string,wstring>(); while(getline(stm,line)){ string::size_type pos = line.find(':'); if(pos==string::npos) throw runtime_error("Bad Config"); WCHAR* buf=GetWideChar(line.substr(pos+1,line.length()-pos-1).c_str()); (*ret)[line.substr(0,pos)]=buf; delete[] buf; } if((*ret)["standard-in"][0]=='.' && (*ret)["standard-in"][1]=='/') (*ret)["standard-in"]=(*ret)["working-directory"]+(*ret)["standard-in"].substr(2,(*ret)["standard-in"].length()-2); if((*ret)["standard-out"][0]=='.' && (*ret)["standard-out"][1]=='/') (*ret)["standard-out"]=(*ret)["working-directory"]+(*ret)["standard-out"].substr(2,(*ret)["standard-out"].length()-2); if((*ret)["standard-err"][0]=='.' && (*ret)["standard-err"][1]=='/') (*ret)["standard-err"]=(*ret)["working-directory"]+(*ret)["standard-err"].substr(2,(*ret)["standard-err"].length()-2); wstring cmd=(*ret)["command"]; if(cmd[0]=='.'&&cmd[1]=='/') (*ret)["command"]=(*ret)["working-directory"]+cmd.substr(2,cmd.length()-2); return ret; }
BOOL CSymData::Format(__out wstring* str) { SymPtr symType; HRESULT hr = m_sym->get_type(&symType); if (FAILED(hr)) return FALSE; CComBSTR bsName; m_sym->get_name(&bsName); // declare wstring strDeclare; CSym* type = CSym::NewSym(symType); type->Declare(&strDeclare, (PCWSTR)bsName); CSym::Delete(type); // size & offset ULONGLONG size = 0; LONG offset = 0; symType->get_length(&size); m_sym->get_offset(&offset); // " <type> <var>; // +<offset>(<size>)" wstringstream stm(L" "); stm << strDeclare << L"<font class=\"comment\">// +0x" << hex << offset << L"(0x" << size << L")</font>" << L"<br />\r\n"; *str = stm.str(); return TRUE; }
BOOL CSymUDT::GetType(__out wstring* str) { UdtKind enKind = (UdtKind)-1; HRESULT hr = m_sym->get_udtKind((PDWORD)&enKind); if (FAILED(hr)) return FALSE; PCWSTR kind = NULL; switch (enKind) { case UdtStruct: kind = L"struct"; break; case UdtClass: kind = L"class"; break; case UdtUnion: kind = L"union"; break; default: ATLASSERT(false); } DWORD id; CComBSTR bsName; m_sym->get_symIndexId(&id); m_sym->get_name(&bsName); wstringstream stm(L"<font class=\"key\">"); stm << kind << L"</font> <a href=\"sym://" << id << L"\">" << bsName << L"</a>"; *str = stm.str(); return TRUE; }
std::wostream& operator<<(std::wostream& stream, const log_item& log) { #ifndef _CLOSE_RPC_LOG auto now = std::chrono::system_clock::now(); auto tm = std::chrono::system_clock::to_time_t(now); auto time_string = std::put_time(std::localtime(&tm),"%H:%M:%S"); std::string byte_string; std::ostringstream stm(byte_string); stm << time_string; stream << "[" << rpclog::_to_unicode(stm.str()) << "]-"; stream << "thread_id:[" << log.log_thread << "]-"; auto wlock = ISU_AUTO_WLOCK(rpclog::_id_map_lock); auto iter = rpclog::_id_map.find(log.log_thread); if (iter != rpclog::_id_map.end()) { stream << "thread_name:[" << iter->second << "]-"; } stream << "level:[" << log_item::level_to_string[log.level] << "]-"; stream << "msg:[" << log.str << log.exstr << ']'; #endif return stream; }
void NesCpuTranslator::mEntryPoint() { cpuRecData.entryPointPtr = intptr_t(m_codeBuffer + m_masm->pcOffset()); // save caller registers and return address #if defined(FRAME_POINTER_FOR_GDB) __ stm(db_w, sp, kCalleeSaved | fp.bit() | lr.bit()); __ add(fp, sp, Operand(kNumCalleeSaved*4)); #else __ stm(db_w, sp, kCalleeSaved | lr.bit()); #endif // load base of the data structure needed by the recompiler __ mov(mDataBase, Operand(intptr_t(&cpuRecData))); // make sure we pass 0 on first nesSync() call __ mov(mCycles, Operand(0)); // jump to sync() which will call nesSync() __ b(&m_syncLabel); }
//------------------------------------------------------------------------------ bool EstimationStateManager::MapSTMToObjects() { bool retval = true; #ifdef DEBUG_STM_MAPPING MessageInterface::ShowMessage("Setting object STM's to\n"); for (Integer i = 0; i < stateSize; ++i) { for (Integer j = 0; j < stateSize; ++j) MessageInterface::ShowMessage(" %.12lf", stm(i,j)); MessageInterface::ShowMessage("\n"); } MessageInterface::ShowMessage("\n"); #endif // Fill in the STM based on the objects that comprise the state vector GmatBase* obj; Integer elementId; //, elementLength; for (UnsignedInt h = 0; h < stateMap.size(); ++h) { obj = stateMap[h]->object; if (stateMap[h]->subelement == 1) { elementId = stateMap[h]->parameterID; // elementLength = stateMap[h]->length; bool hasDstm = obj->HasDynamicParameterSTM(elementId); if (hasDstm) { Rmatrix* dstm = obj->GetParameterSTM(elementId); Integer stmSize = dstm->GetNumRows(); // Fill in the object stm's from the master stm for (Integer i = 0; i < stmSize; ++i) for (Integer j = 0; j < stmSize; ++j) (*dstm)(i,j) = stm(h+i, h+j); } } } return retval; }
vector <string> searchForNetworkHardware() { string word; vector <string> resultVector; string str = getOutputFromConsole("ifconfig | grep wlan | awk '{print $1}'"); istringstream stm(str); while(stm >> word) { resultVector.push_back(word); }; return resultVector; };
vector<bool> GetCoinsByTxHash(const HashValue& hash) override { DbDataReader dr = m_cmdTxFindCoins.Bind(1, ReducedHashValue(hash)).ExecuteVector(); vector<bool> vec; if (!dr.IsDBNull(0)) { CMemReadStream stm(dr.GetBytes(0)); for (int v; (v=stm.ReadByte())!=-1;) { for (int i=0; i<8; ++i) vec.push_back(v & (1 << i)); } } return vec; }
int read_symbols(int& ind, bool mand = false) { ind = op_ind(SYMBOLS); int symbols = -1; if(ind > 0) { string sym_op; if(get_opt(ind + 1,sym_op)) { istringstream stm(sym_op); stm >> symbols; }
bool to_course( const std::string& line, course& c ) { std::istringstream stm(line) ; if( std::getline( stm, c.course_name, delimiter ) && std::getline( stm, c.course_code, delimiter ) && std::getline( stm, c.number_of_credits, delimiter ) && std::getline( stm, c.professor_name, delimiter ) ) return true ; c = course() ; return false ; }
BOOL CSymEnum::GetType(__out wstring* str) { CComBSTR bsName; m_sym->get_name(&bsName); DWORD id; m_sym->get_symIndexId(&id); wstringstream stm(L"<font class=\"key\">enum</font> <a href=\"sym://"); stm << id << L"\">" << bsName << L"</a>"; *str = stm.str(); return TRUE; }
bool to_student( const std::string& line, student& s ) { std::istringstream stm(line) ; if( std::getline( stm, s.first_name, delimiter ) && std::getline( stm, s.last_name, delimiter ) && std::getline( stm, s.credits, delimiter ) && std::getline( stm, s.gpa, delimiter ) && std::getline( stm, s.first_date, delimiter ) && std::getline( stm, s.second_date ) ) return true ; s = student() ; return false ; }
BOOL CSymEnum::OnEnum(IDiaSymbol* sym, PVOID param) { wstring* str = (wstring*)param; CComVariant v; CComBSTR bsName; sym->get_name(&bsName); sym->get_value(&v); wstringstream stm(L" "); stm << bsName << L" = 0x" << hex << v.intVal << L";<br />\r\n"; *str += stm.str(); return FALSE; }
void NesCpuTranslator::mDebugStep() { // regList from mHandleEvent RegList regList = r0.bit() | r2.bit() | mA.bit() | mX.bit() | mY.bit() | mS.bit(); __ bind(&m_debugStepLabel); __ push(lr); // mStoreCurrentCycles(); mSaveInternalFlags(); mPackFlags(r2); __ stm(ia, mDataBase, regList); mCallCFunction(offsetof(NesCpuRecData,debugStep)); mRestoreInternalFlags(); __ pop(pc); }
void NesCpuTranslator::mHandleEvent() { Label saveState; Label loadState; Label exit; // arguments: r1 = event // reg list for saving state // r0 contains 6502.PC address // r2 contains 6502.P flags RegList regList = r0.bit() | r2.bit() | mA.bit() | mX.bit() | mY.bit() | mS.bit(); // regs member of NesCpuRecData should be placed at the start of the object Q_ASSERT(offsetof(NesCpuRecData,regs) == 0); __ cmp(r1, Operand(NesCpuBase::SaveStateEvent)); __ b(&saveState, eq); __ cmp(r1, Operand(NesCpuBase::LoadStateEvent)); __ b(&loadState, eq); // exitEvent: mExitPoint(); // loadState: __ bind(&loadState); __ ldm(ia, mDataBase, regList); mUnpackFlags(r2, r1); mSaveInternalFlags(); mLoadLabelAddress(r0, lr); // mCycles is zeroed later __ b(&exit); // saveState: __ bind(&saveState); mRestoreInternalFlags(); mPackFlags(r2); __ stm(ia, mDataBase, regList); // saveState occurs on frame end, ticks() will be used on new frame // so set it to zero __ mov(ip, Operand(0)); __ str(ip, MemOperand(mDataBase, offsetof(NesCpuRecData,currentCycles))); // exit: __ bind(&exit); }
int main() { std::istringstream stm( "123 456" ) ; int i ; stm >> i ; show_results( stm ) ; // bad: false fail: false eof: false good: true bool(stm): true !stm: false stm >> i ; show_results( stm ) ; // bad: false fail: false eof: true good: false bool(stm): true !stm: false stm >> i ; show_results( stm ) ; // bad: false fail: true eof: true good: false bool(stm): false !stm: true }
void CSymArrayType::Declare(__out wstring* str, __in PCWSTR lpName) { SymPtr type; m_sym->get_type(&type); ULONGLONG arrsize; ULONGLONG elemsize; m_sym->get_length(&arrsize); type->get_length(&elemsize); wstringstream stm(lpName); stm << L"[0x" << hex << arrsize / elemsize << ']'; CSym* sym = CSym::NewSym(type); sym->Declare(str, stm.str().c_str()); CSym::Delete(sym); }
//------------------------------------------------------------------------------ EventData::EventData() : participantName (""), participantIndex (-1), fixedState (false), epoch (-1.0), position (7000.0, 0.0, 0.0), velocity (0.0, 0.0, 7.2) { // Default STM is 6x6 stm.SetSize(6, 6); // Initialize the matrices to identity matrices for (Integer i = 0; i < 3; ++i) rInertial2obj(i,i) = 1.0; for (Integer i = 0; i < 6; ++i) stm(i,i) = 1.0; }
//Load the Vertex Buffer from the <Geometry> Tag in the Dae file void ColladaMesh::LoadVertexBuffer(daeElement *mesh) { //Load all the vertex data for the current mesh daeTArray<daeElementRef> source = mesh->getChildren(); if(source[0]->getAttribute("id").find("positions") != string::npos) { daeElement* float_array = source[0]->getChild("float_array"); int count = atoi(float_array->getAttribute("count").data()); string positionArray = float_array->getCharData(); std::stringstream stm(positionArray); for(int i = 0; i < count / 3; i++) { float x,y,z; stm >> x; stm >> y; stm >> z; m_vPositions.push_back(XMFLOAT3(x,y,z)); } }
void NesSyncCompiler::mEntryPoint() { // r0 = additionalCpuCycles - the amount of cycles that CPU emulation // executed minus requested cycles to execute __ stm(db_w, sp, m_regList | lr.bit()); #if defined(FRAME_POINTER_FOR_GDB) __ add(fp, sp, Operand(3*4)); // point to lr - omit r9,r10,fp #endif // one step before we passed an amount of cycles that CPU should run, // but it's almost impossible to clock CPU by exact cycles, it will // often run more, and we must track these additional cycles // save additional CPU cycles, they will be used later in mClock __ mov(m_additionalCpuCycles, r0); // jump to the point the frame generation was before __ mov(m_dataBase, Operand(reinterpret_cast<int>(&syncData))); __ ldr(pc, MemOperand(m_dataBase, offsetof(NesSyncData,nextPc))); }
bool CibIdMgr::saveIds(const std::string& idsFilePath, const CibParams& cibParams) const { std::ofstream stm(idsFilePath, std::ios_base::out); stm << "#pragma once\n\n"; CppIndent indentation; for (const auto& cls : cibIdTable_) { if (cls.second.numMethods() == 0) continue; const auto& className = cls.first; const auto& cibIdData = cls.second; const auto& classNsName = cls.second.getFullNsName(); stm << "namespace __zz_cib_ { " << expandNs(classNsName.begin(), classNsName.end()) << '\n'; stm << ++indentation << "//#= FullClassName: " << className << '\n'; stm << indentation << "enum { __zz_cib_classid = " << cibIdData.getId() << " };\n"; stm << --indentation << closingNs(classNsName.begin(), classNsName.end()) << "}\n\n"; } stm << indentation << "namespace __zz_cib_ { namespace " << cibParams.moduleName << " {\n"; stm << ++indentation << "enum { __zz_cib_next_class_id = " << nextClassId_ << " };\n"; --indentation; stm << --indentation << "}}\n\n"; for (const auto& cls : cibIdTable_) { if (cls.second.numMethods() == 0) continue; const auto& cibIdData = cls.second; const auto& classNsName = cibIdData.getFullNsName(); stm << "namespace __zz_cib_ { " << expandNs(classNsName.begin(), classNsName.end()) << " namespace __zz_cib_methodid {\n"; stm << ++indentation << "enum {\n"; ++indentation; auto nextMethodId = cibIdData.forEachMethod( [&](CibMethodId methodId, const CibMethodCAPIName& methodName, const CibMethodSignature& methodSig) { stm << indentation << "//#= " << methodSig << '\n'; stm << indentation << methodName << " = " << methodId << ",\n"; }); stm << indentation << "__zz_cib_next_method_id = " << nextMethodId << '\n'; stm << --indentation << "};\n"; stm << --indentation << closingNs(classNsName.begin(), classNsName.end()) << "}}\n\n"; } return true; }
std::string get_file_hash(std::string file) { struct stat buf; auto result = stat(file.c_str(), &buf); if (result) throw os_error::make_os_error(errno); size_t sz = buf.st_blksize ? buf.st_blksize : 1024; std::unique_ptr<uint8_t[]> data(new uint8_t[sz]); std::ifstream stm(file.c_str(), std::ios_base::in | std::ios_base::binary); File_Hash context; while (stm.good()) { // note that return value of read is unusable. stm.read(reinterpret_cast<char*>(data.get()), sz); size_t len = stm.gcount(); context.update(data.get(), len); } context.finalize(); return context.hex_digest(); }
BOOL CSymUDT::GetHeader(__out wstring* str) { UdtKind enKind = (UdtKind)-1; HRESULT hr = m_sym->get_udtKind((PDWORD)&enKind); if (FAILED(hr)) return FALSE; PCWSTR tmp = NULL; switch (enKind) { case UdtStruct: tmp = L"struct"; break; case UdtClass: tmp = L"class"; break; case UdtUnion: tmp = L"union"; break; default: ATLASSERT(false); } CComBSTR bsName; ULONGLONG size; m_sym->get_name(&bsName); m_sym->get_length(&size); // base wstring strBase; CSym::Enum(m_sym, SymTagBaseClass, EnumBase, &strBase); // header wstringstream stm(L"<font class=\"key\">"); stm << tmp << L"</font> " << bsName << strBase << L" <font class=\"comment\">// 0x" << hex << size << L"</font><br />{<br />\r\n"; *str = stm.str(); return TRUE; }
Color::Color(Token &token): Value() { int len; this->tokens.push_back(token); type = Value::COLOR; if (token.size() == 4) len = 1; else if (token.size() == 7) len = 2; else { throw new ValueException("A color value requires either three " "or six hexadecimal characters.", *this->getTokens()); } for (int i = 0; i < 3; i++) { istringstream stm(token.substr(1 + (i * len), len)); stm >> hex >> color[i]; if (len == 1) color[i] = color[i] * 0x11; } alpha = 1; }
int main(int argc, char *argv[]) { #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" #include "createFields.H" #include "initContinuityErrs.H" // create cfdemCloud #include "readGravitationalAcceleration.H" cfdemCloud particleCloud(mesh); #include "checkModelType.H" // create a scalarTransportModel autoPtr<scalarTransportModel> stm ( scalarTransportModel::New(particleCloud.couplingProperties(),particleCloud) ); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; #include "readPISOControls.H" #include "CourantNo.H" // do particle stuff bool hasEvolved = particleCloud.evolve(voidfraction,Us,U); if(hasEvolved) { particleCloud.smoothingM().smoothen(particleCloud.forceM(0).impParticleForces()); } Info << "update Ksl.internalField()" << endl; Ksl = particleCloud.momCoupleM(0).impMomSource(); Ksl.correctBoundaryConditions(); #include "solverDebugInfo.H" /*// get scalar source from DEM particleCloud.forceM(1).manipulateScalarField(Tsource); Tsource.correctBoundaryConditions();*/ stm().update(); /*// solve scalar transport equation fvScalarMatrix TEqn ( fvm::ddt(voidfraction,T) - fvm::Sp(fvc::ddt(voidfraction),T) + fvm::div(phi, T) - fvm::Sp(fvc::div(phi),T) - fvm::laplacian(DT*voidfraction, T) == Tsource ); TEqn.relax(); TEqn.solve();*/ if(particleCloud.solveFlow()) { // Pressure-velocity PISO corrector { // Momentum predictor fvVectorMatrix UEqn ( fvm::ddt(voidfraction,U) - fvm::Sp(fvc::ddt(voidfraction),U) + fvm::div(phi,U) - fvm::Sp(fvc::div(phi),U) // + turbulence->divDevReff(U) + particleCloud.divVoidfractionTau(U, voidfraction) == - fvm::Sp(Ksl/rho,U) ); UEqn.relax(); if (momentumPredictor && (modelType=="B" || modelType=="Bfull")) solve(UEqn == - fvc::grad(p) + Ksl/rho*Us); else if (momentumPredictor) solve(UEqn == - voidfraction*fvc::grad(p) + Ksl/rho*Us); // --- PISO loop //for (int corr=0; corr<nCorr; corr++) int nCorrSoph = nCorr + 5 * pow((1-particleCloud.dataExchangeM().timeStepFraction()),1); for (int corr=0; corr<nCorrSoph; corr++) { volScalarField rUA = 1.0/UEqn.A(); surfaceScalarField rUAf("(1|A(U))", fvc::interpolate(rUA)); volScalarField rUAvoidfraction("(voidfraction2|A(U))",rUA*voidfraction); surfaceScalarField rUAfvoidfraction("(voidfraction2|A(U)F)", fvc::interpolate(rUAvoidfraction)); U = rUA*UEqn.H(); #ifdef version23 phi = ( fvc::interpolate(U*voidfraction) & mesh.Sf() ) + rUAfvoidfraction*fvc::ddtCorr(U, phi); #else phi = ( fvc::interpolate(U*voidfraction) & mesh.Sf() ) + fvc::ddtPhiCorr(rUAvoidfraction, U, phi); #endif surfaceScalarField phiS(fvc::interpolate(Us*voidfraction) & mesh.Sf()); surfaceScalarField phiGes = phi + rUAf*(fvc::interpolate(Ksl/rho) * phiS); if (modelType=="A") rUAvoidfraction = volScalarField("(voidfraction2|A(U))",rUA*voidfraction*voidfraction); // Non-orthogonal pressure corrector loop for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { // Pressure corrector fvScalarMatrix pEqn ( fvm::laplacian(rUAvoidfraction, p) == fvc::div(phiGes) + particleCloud.ddtVoidfraction() ); pEqn.setReference(pRefCell, pRefValue); if ( corr == nCorr-1 && nonOrth == nNonOrthCorr ) { pEqn.solve(mesh.solver("pFinal")); } else { pEqn.solve(); } if (nonOrth == nNonOrthCorr) { phiGes -= pEqn.flux(); phi = phiGes; } } // end non-orthogonal corrector loop #include "continuityErrorPhiPU.H" if (modelType=="B" || modelType=="Bfull") U -= rUA*fvc::grad(p) - Ksl/rho*Us*rUA; else U -= voidfraction*rUA*fvc::grad(p) - Ksl/rho*Us*rUA; U.correctBoundaryConditions(); } // end piso loop } turbulence->correct(); }// end solveFlow else { Info << "skipping flow solution." << endl; } runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; } Info<< "End\n" << endl; return 0; }
int cra_con::GetMetaData() { int error = 0; string fn; fn.assign(path); fn.append("\\"); fn.append(filename); ifstream file(fn); if(!file.is_open()) { error = -1; return error; } string line; int centre_cnt = 0; while( getline( file, line ) ) { for(int i = 0; i < STRINGS; i++) if(!line.find(prs[i])) { line.erase(0,prs[i].length()); istringstream stm(line); switch (i) { case 0: header.raw_file = line; break; case 1: header.source_name = line; break; case 2: stm >> header.sample_spacing; break; case 3: stm >> header.distance; break; case 4: stm >> header.detector_x; break; case 5: stm >> header.detector_z; break; case 6: stm >> header.num_of_projections; break; case 7: stm >> header.x_dimension; break; case 8: stm >> header.z_dimension; break; case 9: stm >> header.rotate_angle; break; case 10: stm >> header.centre_of_rotation[centre_cnt]; centre_cnt++; break; case 11: stm >> header.num_of_blocks; break; case 12: header.clockwise = true; break; case 13: stm >> header.scale; break; } } }