void DynamicGroupUpdateCallback::operator()( osg::Node* node, osg::NodeVisitor* nv ) { //сформировать массив данных о видимых патчах m_VisiblePatchArray.Update(); //обновить коэффициенты из файла // UpdateKof(); //обновить статистику UpdateStatistic(); osg::ref_ptr< osg::Group > group = dynamic_cast< osg::Group* >( node ); if ( group ) { //вернуть ссылку на массив видимых патчей const std::vector< dataPatch > &data_vis = m_VisiblePatchArray.GetVisibleArray(); if ( !data_vis.empty() ) { //FindMax(); //std::cout << data_vis.size() << "-" << FindMax() << " "; //очистить всех детей group->removeChildren( 0 , group->getNumChildren() ); //перебрать все видимые узлы for( int i = 0 ; i < data_vis.size() ; ++i ) { //сформировать геометрию //GeometryPatch patch( data_vis[ i ].m_iX , // data_vis[ i ].m_iY , 65 , // data_vis[ i ].m_iSize ); osg::ref_ptr< osg::Geode > geode = new osg::Geode; if ( data_vis[ i ].m_iSize == 1024 ) { GeometryTexturePatch1 patch( data_vis[ i ].m_iX , data_vis[ i ].m_iY , 66 , data_vis[ i ].m_iSize , m_ImageIndex.get() , 2 , -64 ); //1 -32 geode->addDrawable( patch.GetGeometry().get() ); } else if ( data_vis[ i ].m_iSize == 512 ) { GeometryTexturePatch patch( data_vis[ i ].m_iX , data_vis[ i ].m_iY , 65 , data_vis[ i ].m_iSize , m_ImageIndex.get() , 1 , 30 ); geode->addDrawable( patch.GetGeometry().get() ); } else if ( data_vis[ i ].m_iSize == 2048 ) { GeometryTexturePatch2 patch( data_vis[ i ].m_iX , data_vis[ i ].m_iY , 68 , data_vis[ i ].m_iSize , m_ImageIndex.get() , 2 , -64 ); geode->addDrawable( patch.GetGeometry().get() ); } else if ( data_vis[ i ].m_iSize == 4096 ) { GeometryTexturePatch4 patch( data_vis[ i ].m_iX , data_vis[ i ].m_iY , 64 + 8, data_vis[ i ].m_iSize , m_ImageIndex.get() , 2 , -128 ); geode->addDrawable( patch.GetGeometry().get() ); } else if ( data_vis[ i ].m_iSize == 8192 ) { GeometryTexturePatch8 patch( data_vis[ i ].m_iX , data_vis[ i ].m_iY , 64 + 16, data_vis[ i ].m_iSize , m_ImageIndex.get() , 2 , -128 ); geode->addDrawable( patch.GetGeometry().get() ); } else if ( data_vis[ i ].m_iSize == 16384 ) { GeometryTexturePatch16 patch( data_vis[ i ].m_iX , data_vis[ i ].m_iY , 64 + 32, data_vis[ i ].m_iSize , m_ImageIndex.get() , 2 , -128 ); geode->addDrawable( patch.GetGeometry().get() ); } else if ( data_vis[ i ].m_iSize == 32768 ) { GeometryTexturePatch32 patch( data_vis[ i ].m_iX , data_vis[ i ].m_iY , 64 + 64, data_vis[ i ].m_iSize , m_ImageIndex.get() , 2 , -128 ); geode->addDrawable( patch.GetGeometry().get() ); } //else //{ // std::cout << "65536 "; //} //добавить геометрию в сцену group->addChild( geode.get() ); } } } }
ofxPDSPStereoFader& ofxPDSPStereoFader::operator=(const ofxPDSPStereoFader & other){ patch(); return *this; }
ofxPDSPStereoFader::ofxPDSPStereoFader(const ofxPDSPStereoFader & other) : ofxPDSPStereoFader(){ patch(); }
void Foam::inclinedFilmNusseltInletVelocityFvPatchVectorField::updateCoeffs() { if (updated()) { return; } const label patchi = patch().index(); // retrieve the film region from the database const regionModels::regionModel& region = db().time().lookupObject<regionModels::regionModel> ( "surfaceFilmProperties" ); const regionModels::surfaceFilmModels::kinematicSingleLayer& film = dynamic_cast < const regionModels::surfaceFilmModels::kinematicSingleLayer& >(region); // calculate the vector tangential to the patch // note: normal pointing into the domain const vectorField n(-patch().nf()); // TODO: currently re-evaluating the entire gTan field to return this patch const scalarField gTan(film.gTan()().boundaryField()[patchi] & n); if (patch().size() && (max(mag(gTan)) < SMALL)) { WarningInFunction << "is designed to operate on patches inclined with respect to " << "gravity" << endl; } const volVectorField& nHat = film.nHat(); const vectorField nHatp(nHat.boundaryField()[patchi].patchInternalField()); vectorField nTan(nHatp ^ n); nTan /= mag(nTan) + ROOTVSMALL; // calculate distance in patch tangential direction const vectorField& Cf = patch().Cf(); scalarField d(nTan & Cf); // calculate the wavy film height const scalar t = db().time().timeOutputValue(); const scalar GMean = GammaMean_->value(t); const scalar a = a_->value(t); const scalar omega = omega_->value(t); const scalarField G(GMean + a*sin(omega*constant::mathematical::twoPi*d)); const volScalarField& mu = film.mu(); const scalarField mup(mu.boundaryField()[patchi].patchInternalField()); const volScalarField& rho = film.rho(); const scalarField rhop(rho.boundaryField()[patchi].patchInternalField()); const scalarField Re(max(G, scalar(0.0))/mup); operator==(n*pow(gTan*mup/(3.0*rhop), 0.333)*pow(Re, 0.666)); fixedValueFvPatchVectorField::updateCoeffs(); }
void swit2(C1 *q, int nc, int32 def, Node *n) { C1 *r; int i; int32 v; Prog *sp; if(nc >= 3) { i = (q+nc-1)->val - (q+0)->val; if(i > 0 && i < nc*2) goto direct; } if(nc < 5) { for(i=0; i<nc; i++) { if(debug['W']) print("case = %.8ux\n", q->val); gopcode(OEQ, nodconst(q->val), n, Z); patch(p, q->label); q++; } gbranch(OGOTO); patch(p, def); return; } i = nc / 2; r = q+i; if(debug['W']) print("case > %.8ux\n", r->val); gopcode(OGT, nodconst(r->val), n, Z); sp = p; gopcode(OEQ, nodconst(r->val), n, Z); /* just gen the B.EQ */ patch(p, r->label); swit2(q, i, def, n); if(debug['W']) print("case < %.8ux\n", r->val); patch(sp, pc); swit2(r+1, nc-i-1, def, n); return; direct: v = q->val; if(v != 0) gopcode(OSUB, nodconst(v), Z, n); gopcode(OCASE, nodconst((q+nc-1)->val - v), n, Z); patch(p, def); for(i=0; i<nc; i++) { if(debug['W']) print("case = %.8ux\n", q->val); while(q->val != v) { nextpc(); p->as = ABCASE; patch(p, def); v++; } nextpc(); p->as = ABCASE; patch(p, q->label); q++; v++; } gbranch(OGOTO); /* so that regopt() won't be confused */ patch(p, def); }
void UGen::patch( AudioOutput & output ) { patch( output.mSummer ); setSampleRate( output.sampleRate() ); setAudioChannelCount( output.getFormat().getChannels() ); }
void CFDHAMfluidMoistureCoupledMixedFvPatchScalarField::updateCoeffs() { if (updated()) { return; } // Since we're inside initEvaluate/evaluate there might be processor // comms underway. Change the tag we use. int oldTag = UPstream::msgType(); UPstream::msgType() = oldTag+1; // Get the coupling information from the mappedPatchBase const mappedPatchBase& mpp = refCast<const mappedPatchBase>(patch().patch()); const polyMesh& nbrMesh = mpp.sampleMesh(); const label samplePatchI = mpp.samplePolyPatch().index(); const fvPatch& nbrPatch = refCast<const fvMesh>(nbrMesh).boundary()[samplePatchI]; // scalarField Tc(patchInternalField()); scalarField& Tp = *this; /* const mixedFvPatchScalarField& //CFDHAMfluidMoistureCoupledMixedFvPatchScalarField& nbrField = refCast <const mixedFvPatchScalarField> ( nbrPatch.lookupPatchField<volScalarField, scalar>(wnbrName_) ); */ const mixedFvPatchScalarField& //CFDHAMfluidMoistureCoupledMixedFvPatchScalarField& nbrTField = refCast <const mixedFvPatchScalarField> ( nbrPatch.lookupPatchField<volScalarField, scalar>(TnbrName_) ); const mixedFvPatchScalarField& //CFDHAMfluidMoistureCoupledMixedFvPatchScalarField& nbrpcField = refCast <const mixedFvPatchScalarField> ( nbrPatch.lookupPatchField<volScalarField, scalar>("pc") ); // Swap to obtain full local values of neighbour internal field // scalarField wcNbr(nbrField.patchInternalField()); // mpp.distribute(wcNbr); scalarField TNbr(nbrTField.patchInternalField()); mpp.distribute(TNbr); scalarField pcNbr(nbrpcField.patchInternalField()); mpp.distribute(pcNbr); scalarField p(Tp.size(), 0.0); p = patch().lookupPatchField<volScalarField, scalar>("p"); scalarField rhoair(Tp.size(), 0.0); rhoair = patch().lookupPatchField<volScalarField, scalar>("rho"); scalar rhol=1.0e3; scalar Rv=8.31451*1000/(18.01534); scalarField pvsat_s = exp(6.58094e1-7.06627e3/TNbr-5.976*log(TNbr)); scalarField pv_s = pvsat_s*exp((pcNbr)/(rhol*Rv*TNbr)); valueFraction() = 1.0;//KDeltaNbr/(KDeltaNbr + KDelta); refValue() = 0.62198*pv_s/p;//pv_s/pvsat_s; refGrad() = 0.0;//(Qr + QrNbr + Qs + QsNbr)/(kappa(Tp)); mixedFvPatchScalarField::updateCoeffs(); /* if (debug) { scalar Q = gSum(kappa(Tp)*patch().magSf()*snGrad()); Info<< patch().boundaryMesh().mesh().name() << ':' << patch().name() << ':' << this->dimensionedInternalField().name() << " <- " << nbrMesh.name() << ':' << nbrPatch.name() << ':' << this->dimensionedInternalField().name() << " :" << " heat transfer rate:" << Q << " walltemperature " << " min:" << gMin(Tp) << " max:" << gMax(Tp) << " avg:" << gAverage(Tp) << endl; } */ // Restore tag UPstream::msgType() = oldTag; }
int encode_contact (struct sip_msg *msg, char *encoding_prefix,char *public_ip) { contact_body_t *cb; contact_t *c; str* uri; str newUri; int res; char separator; /* * I have a list of contacts in contact->parsed which is of type contact_body_t * inside i have a contact->parsed->contact which is the head of the list of contacts * inside it is a * str uri; * struct contact *next; * I just have to visit each uri and encode each uri according to a scheme */ if ((msg->contact == NULL)&&((parse_headers(msg,HDR_CONTACT_F,0) == -1) || (msg->contact == NULL) )) { LOG(L_ERR,"ERROR: encode_contact: no Contact header present\n"); return -1; } separator = DEFAULT_SEPARATOR[0]; if (contact_flds_separator != NULL) if (strlen(contact_flds_separator)>=1) separator = contact_flds_separator[0]; if (msg->contact->parsed == NULL) parse_contact (msg->contact); if (msg->contact->parsed != NULL) { cb = (contact_body_t *) msg->contact->parsed; c = cb->contacts; /* we visit each contact */ if (c != NULL) { uri = &c->uri; res = encode_uri(msg, uri, encoding_prefix, public_ip, separator, &newUri); if (res != 0) { LOG (L_ERR,"ERROR: encode_contact: Failed encoding contact.Code %d\n", res); return res; } else if (patch (msg, uri->s, uri->len, newUri.s, newUri.len) < 0) { LOG (L_ERR,"ERROR: encode_contact: lumping failed in mangling port \n"); return -2; } /* encoding next contacts too?*/ #ifdef ENCODE_ALL_CONTACTS while (c->next != NULL) { c = c->next; uri = &c->uri; res = encode_uri (msg, uri, encoding_prefix, public_ip, separator, &newUri); if (res != 0) { LOG(L_ERR,"ERROR: encode_contact: Failed encode_uri.Code %d\n",res); #ifdef STRICT_CHECK return res; #endif } else if (patch (msg, uri->s, uri->len, newUri.s, newUri.len)< 0) { LOG (L_ERR,"ERROR: encode_contact: lumping failed in mangling port \n"); return -3; } } /* while */ #endif /* ENCODE_ALL_CONTACTS */ } /* if c != NULL */ } /* end if */ else /* after parsing still NULL */ { LOG(L_ERR,"ERROR: encode_contact: Unable to parse Contact header\n"); #ifdef EXTRA_DEBUG printf("ERROR: encode_contact: Unable to parse Contact header\n"); #endif return -4; } #ifdef EXTRA_DEBUG fprintf (stdout,"---END--------ENCODE CONTACT-----------------\n"); #endif return 1; }
void Foam::totalPressureFvPatchScalarField::updateCoeffs ( const scalarField& p0p, const vectorField& Up ) { if (updated()) { return; } const fvsPatchField<scalar>& phip = patch().lookupPatchField<surfaceScalarField, scalar>(phiName_); if (psiName_ == "none" && rhoName_ == "none") { operator==(p0p - 0.5*(1.0 - pos(phip))*magSqr(Up)); } else if (rhoName_ == "none") { const fvPatchField<scalar>& psip = patch().lookupPatchField<volScalarField, scalar>(psiName_); if (gamma_ > 1.0) { scalar gM1ByG = (gamma_ - 1.0)/gamma_; operator== ( p0p /pow ( (1.0 + 0.5*psip*gM1ByG*(1.0 - pos(phip))*magSqr(Up)), 1.0/gM1ByG ) ); } else { operator==(p0p/(1.0 + 0.5*psip*(1.0 - pos(phip))*magSqr(Up))); } } else if (psiName_ == "none") { const fvPatchField<scalar>& rho = patch().lookupPatchField<volScalarField, scalar>(rhoName_); operator==(p0p - 0.5*rho*(1.0 - pos(phip))*magSqr(Up)); } else { FatalErrorIn ( "totalPressureFvPatchScalarField::updateCoeffs()" ) << " rho or psi set inconsistently, rho = " << rhoName_ << ", psi = " << psiName_ << ".\n" << " Set either rho or psi or neither depending on the " "definition of total pressure." << nl << " Set the unused variable(s) to 'none'.\n" << " on patch " << this->patch().name() << " of field " << this->dimensionedInternalField().name() << " in file " << this->dimensionedInternalField().objectPath() << exit(FatalError); } fixedValueFvPatchScalarField::updateCoeffs(); }
tmp<scalarField> alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField::calcAlphat ( const scalarField& prevAlphat ) const { // Lookup the fluid model const phaseSystem& fluid = db().lookupObject<phaseSystem>("phaseProperties"); const phaseModel& phase ( fluid.phases()[internalField().group()] ); const label patchi = patch().index(); // Retrieve turbulence properties from model const phaseCompressibleTurbulenceModel& turbModel = db().lookupObject<phaseCompressibleTurbulenceModel> ( IOobject::groupName(turbulenceModel::propertiesName, phase.name()) ); const scalar Cmu25 = pow025(Cmu_); const scalarField& y = turbModel.y()[patchi]; const tmp<scalarField> tmuw = turbModel.mu(patchi); const scalarField& muw = tmuw(); const tmp<scalarField> talphaw = phase.thermo().alpha(patchi); const scalarField& alphaw = talphaw(); const tmp<volScalarField> tk = turbModel.k(); const volScalarField& k = tk(); const fvPatchScalarField& kw = k.boundaryField()[patchi]; const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchi]; const scalarField magUp(mag(Uw.patchInternalField() - Uw)); const scalarField magGradUw(mag(Uw.snGrad())); const fvPatchScalarField& rhow = turbModel.rho().boundaryField()[patchi]; const fvPatchScalarField& hew = phase.thermo().he().boundaryField()[patchi]; const fvPatchScalarField& Tw = phase.thermo().T().boundaryField()[patchi]; scalarField Tp(Tw.patchInternalField()); // Heat flux [W/m2] - lagging alphatw const scalarField qDot ( (prevAlphat + alphaw)*hew.snGrad() ); scalarField uTau(Cmu25*sqrt(kw)); scalarField yPlus(uTau*y/(muw/rhow)); scalarField Pr(muw/alphaw); // Molecular-to-turbulent Prandtl number ratio scalarField Prat(Pr/Prt_); // Thermal sublayer thickness scalarField P(this->Psmooth(Prat)); scalarField yPlusTherm(this->yPlusTherm(P, Prat)); tmp<scalarField> talphatConv(new scalarField(this->size())); scalarField& alphatConv = talphatConv.ref(); // Populate boundary values forAll(alphatConv, facei) { // Evaluate new effective thermal diffusivity scalar alphaEff = 0.0; if (yPlus[facei] < yPlusTherm[facei]) { scalar A = qDot[facei]*rhow[facei]*uTau[facei]*y[facei]; scalar B = qDot[facei]*Pr[facei]*yPlus[facei]; scalar C = Pr[facei]*0.5*rhow[facei]*uTau[facei]*sqr(magUp[facei]); alphaEff = A/(B + C + vSmall); } else { scalar A = qDot[facei]*rhow[facei]*uTau[facei]*y[facei]; scalar B = qDot[facei]*Prt_*(1.0/kappa_*log(E_*yPlus[facei]) + P[facei]); scalar magUc = uTau[facei]/kappa_*log(E_*yPlusTherm[facei]) - mag(Uw[facei]); scalar C = 0.5*rhow[facei]*uTau[facei] *(Prt_*sqr(magUp[facei]) + (Pr[facei] - Prt_)*sqr(magUc)); alphaEff = A/(B + C + vSmall); } // Update convective heat transfer turbulent thermal diffusivity alphatConv[facei] = max(0.0, alphaEff - alphaw[facei]); }
int decode_contact_header (struct sip_msg *msg,char *unused1,char *unused2) { contact_body_t *cb; contact_t *c; str* uri; str newUri; char separator; int res; if ((msg->contact == NULL)&&((parse_headers(msg,HDR_CONTACT_F,0) == -1) || (msg->contact== NULL) )) { LOG(L_ERR,"ERROR: decode_contact_header: no Contact header present\n"); return -1; } separator = DEFAULT_SEPARATOR[0]; if (contact_flds_separator != NULL) if (strlen(contact_flds_separator)>=1) separator = contact_flds_separator[0]; if (msg->contact->parsed == NULL) parse_contact (msg->contact); if (msg->contact->parsed != NULL) { cb = (contact_body_t *) msg->contact->parsed; c = cb->contacts; // we visit each contact if (c != NULL) { uri = &c->uri; res = decode_uri (uri, separator, &newUri, 0); if (res != 0) { LOG (L_ERR,"ERROR: decode_contact_header:Failed decoding contact.Code %d\n", res); #ifdef STRICT_CHECK return res; #endif } else if (patch (msg, uri->s, uri->len, newUri.s, newUri.len) < 0) { LOG (L_ERR,"ERROR: decode_contact:lumping failed in mangling port \n"); return -2; } #ifdef DECODE_ALL_CONTACTS while (c->next != NULL) { c = c->next; uri = &c->uri; res = decode_uri (uri, separator, &newUri, 0); if (res != 0) { LOG (L_ERR,"ERROR: decode_contact: Failed decoding contact.Code %d\n",res); #ifdef STRICT_CHECK return res; #endif } else if (patch (msg, uri->s, uri->len, newUri.s, newUri.len) < 0) { LOG (L_ERR,"ERROR: decode_contact:lumping failed in mangling port \n"); return -3; } } // end while #endif } // if c!= NULL } // end if else // after parsing still NULL { LOG(L_ERR,"ERROR: decode_contact: Unable to parse Contact header\n"); return -4; } return 1; }
void Foam::uniformTotalPressureFvPatchScalarField::updateCoeffs() { updateCoeffs(patch().lookupPatchField<volVectorField, vector>(UName_)); }
void Foam::processorTetPolyPatchFaceDecomp::calcMeshPoints() const { if (meshPointsPtr_) { FatalErrorIn ( "void processorTetPolyPatchFaceDecomp::calcMeshPoints() const" ) << "meshPointsPtr_ already allocated" << abort(FatalError); } // Algorithm: // Depending on whether the patch is a master or a slave, get the primitive // patch points and filter away the points from the global patch. labelList mp(0); if (isMaster()) { mp = procPolyPatch_.meshPoints(); } else { // Slave side. Create the reversed patch and pick up its points // so that the order is correct const polyPatch& pp = patch(); faceList masterFaces(pp.size()); forAll (pp, faceI) { masterFaces[faceI] = pp[faceI].reverseFace(); } mp = primitiveFacePatch ( masterFaces, pp.points() ).meshPoints(); } // Get reference to shared processor points const labelList& sharedPoints = boundaryMesh().globalPatch().meshPoints(); // Filter the shared points out of the list meshPointsPtr_ = new labelList(mp.size() + procPolyPatch_.size()); labelList& filtPoints = *meshPointsPtr_; label noFiltPoints = 0; forAll (mp, pointI) { label curP = mp[pointI]; bool found = false; forAll (sharedPoints, sharedI) { if (sharedPoints[sharedI] == curP) { found = true; break; } } if (!found) { filtPoints[noFiltPoints] = curP; noFiltPoints++; } }
found = true; break; } } if (!found) { filtPoints[noFiltPoints] = curP; noFiltPoints++; } } // insert faces using the offset // These cannot be shared const label faceOffset = boundaryMesh().mesh().faceOffset(); const label polyPatchStart = patch().start() + faceOffset; const label polyPatchStartPlusSize = polyPatchStart + patch().size(); for (label i = polyPatchStart; i < polyPatchStartPlusSize; i++) { filtPoints[noFiltPoints] = i; noFiltPoints++; } filtPoints.setSize(noFiltPoints); } // ************************************************************************* //
int HttpClient::patch(const char* aURLPath, const char* aContentType, const char* aBody) { return patch(aURLPath, aContentType, strlen(aBody), (const byte*)aBody); }
inline patch patch_rep::get_child (int i) { FAILED ("not a composite patch"); (void) i; return patch (); }
int HttpClient::patch(const String& aURLPath, const String& aContentType, const String& aBody) { return patch(aURLPath.c_str(), aContentType.c_str(), aBody.length(), (const byte*)aBody.c_str()); }
tmp<scalarField> nutLowReWallFunctionFvPatchScalarField::calcNut() const { return tmp<scalarField>(new scalarField(patch().size(), 0.0)); }
void _cgen(Node *n, Node *nn, int inrel) { Node *l, *r; Prog *p1; Node nod, nod1, nod2, nod3, nod4; int o, t; int32 v, curs; if(debug['g']) { prtree(nn, "cgen lhs"); prtree(n, "cgen"); } if(n == Z || n->type == T) return; if(typesuv[n->type->etype]) { sugen(n, nn, n->type->width); return; } l = n->left; r = n->right; o = n->op; if(n->addable >= INDEXED) { if(nn == Z) { switch(o) { default: nullwarn(Z, Z); break; case OINDEX: nullwarn(l, r); break; } return; } gmove(n, nn); return; } curs = cursafe; if(n->complex >= FNX) if(l->complex >= FNX) if(r != Z && r->complex >= FNX) switch(o) { default: regret(&nod, r); cgen(r, &nod); regsalloc(&nod1, r); gopcode(OAS, &nod, Z, &nod1); regfree(&nod); nod = *n; nod.right = &nod1; cgen(&nod, nn); return; case OFUNC: case OCOMMA: case OANDAND: case OOROR: case OCOND: case ODOT: break; } switch(o) { default: diag(n, "unknown op in cgen: %O", o); break; case OAS: if(l->op == OBIT) goto bitas; if(l->addable >= INDEXED && l->complex < FNX) { if(nn != Z || r->addable < INDEXED) { if(r->complex >= FNX && nn == Z) regret(&nod, r); else regalloc(&nod, r, nn); cgen(r, &nod); gmove(&nod, l); if(nn != Z) gmove(&nod, nn); regfree(&nod); } else gmove(r, l); break; } if(l->complex >= r->complex) { reglcgen(&nod1, l, Z); if(r->addable >= INDEXED) { gmove(r, &nod1); if(nn != Z) gmove(r, nn); regfree(&nod1); break; } regalloc(&nod, r, nn); cgen(r, &nod); } else { regalloc(&nod, r, nn); cgen(r, &nod); reglcgen(&nod1, l, Z); } gmove(&nod, &nod1); regfree(&nod); regfree(&nod1); break; bitas: n = l->left; regalloc(&nod, r, nn); if(l->complex >= r->complex) { reglcgen(&nod1, n, Z); cgen(r, &nod); } else { cgen(r, &nod); reglcgen(&nod1, n, Z); } regalloc(&nod2, n, Z); gopcode(OAS, &nod1, Z, &nod2); bitstore(l, &nod, &nod1, &nod2, nn); break; case OBIT: if(nn == Z) { nullwarn(l, Z); break; } bitload(n, &nod, Z, Z, nn); gopcode(OAS, &nod, Z, nn); regfree(&nod); break; case ODIV: case OMOD: if(nn != Z) if((t = vlog(r)) >= 0) { /* signed div/mod by constant power of 2 */ cgen(l, nn); gopcode(OGE, nodconst(0), nn, Z); p1 = p; if(o == ODIV) { gopcode(OADD, nodconst((1<<t)-1), Z, nn); patch(p1, pc); gopcode(OASHR, nodconst(t), Z, nn); } else { gopcode(OSUB, nn, nodconst(0), nn); gopcode(OAND, nodconst((1<<t)-1), Z, nn); gopcode(OSUB, nn, nodconst(0), nn); gbranch(OGOTO); patch(p1, pc); p1 = p; gopcode(OAND, nodconst((1<<t)-1), Z, nn); patch(p1, pc); } break; } goto muldiv; case OSUB: if(nn != Z) if(l->op == OCONST) if(!typefd[n->type->etype]) { cgen(r, nn); gopcode(o, Z, l, nn); break; } case OADD: case OAND: case OOR: case OXOR: case OLSHR: case OASHL: case OASHR: /* * immediate operands */ if(nn != Z) if(r->op == OCONST) if(!typefd[n->type->etype]) { cgen(l, nn); if(r->vconst == 0) if(o != OAND) break; if(nn != Z) gopcode(o, r, Z, nn); break; } case OLMUL: case OLDIV: case OLMOD: case OMUL: muldiv: if(nn == Z) { nullwarn(l, r); break; } if(o == OMUL || o == OLMUL) { if(mulcon(n, nn)) break; } if(l->complex >= r->complex) { regalloc(&nod, l, nn); cgen(l, &nod); regalloc(&nod1, r, Z); cgen(r, &nod1); gopcode(o, &nod1, Z, &nod); } else { regalloc(&nod, r, nn); cgen(r, &nod); regalloc(&nod1, l, Z); cgen(l, &nod1); gopcode(o, &nod, &nod1, &nod); } gopcode(OAS, &nod, Z, nn); regfree(&nod); regfree(&nod1); break; case OASLSHR: case OASASHL: case OASASHR: case OASAND: case OASADD: case OASSUB: case OASXOR: case OASOR: if(l->op == OBIT) goto asbitop; if(r->op == OCONST) if(!typefd[r->type->etype]) if(!typefd[n->type->etype]) { if(l->addable < INDEXED) reglcgen(&nod2, l, Z); else nod2 = *l; regalloc(&nod, r, nn); gopcode(OAS, &nod2, Z, &nod); gopcode(o, r, Z, &nod); gopcode(OAS, &nod, Z, &nod2); regfree(&nod); if(l->addable < INDEXED) regfree(&nod2); break; } case OASLMUL: case OASLDIV: case OASLMOD: case OASMUL: case OASDIV: case OASMOD: if(l->op == OBIT) goto asbitop; if(l->complex >= r->complex) { if(l->addable < INDEXED) reglcgen(&nod2, l, Z); else nod2 = *l; regalloc(&nod1, r, Z); cgen(r, &nod1); } else { regalloc(&nod1, r, Z); cgen(r, &nod1); if(l->addable < INDEXED) reglcgen(&nod2, l, Z); else nod2 = *l; } regalloc(&nod, n, nn); gmove(&nod2, &nod); gopcode(o, &nod1, Z, &nod); gmove(&nod, &nod2); if(nn != Z) gopcode(OAS, &nod, Z, nn); regfree(&nod); regfree(&nod1); if(l->addable < INDEXED) regfree(&nod2); break; asbitop: regalloc(&nod4, n, nn); if(l->complex >= r->complex) { bitload(l, &nod, &nod1, &nod2, &nod4); regalloc(&nod3, r, Z); cgen(r, &nod3); } else { regalloc(&nod3, r, Z); cgen(r, &nod3); bitload(l, &nod, &nod1, &nod2, &nod4); } gmove(&nod, &nod4); gopcode(o, &nod3, Z, &nod4); regfree(&nod3); gmove(&nod4, &nod); regfree(&nod4); bitstore(l, &nod, &nod1, &nod2, nn); break; case OADDR: if(nn == Z) { nullwarn(l, Z); break; } lcgen(l, nn); break; case OFUNC: if(l->complex >= FNX) { if(l->op != OIND) diag(n, "bad function call"); regret(&nod, l->left); cgen(l->left, &nod); regsalloc(&nod1, l->left); gopcode(OAS, &nod, Z, &nod1); regfree(&nod); nod = *n; nod.left = &nod2; nod2 = *l; nod2.left = &nod1; nod2.complex = 1; cgen(&nod, nn); return; } if(REGARG >= 0) o = reg[REGARG]; gargs(r, &nod, &nod1); if(l->addable < INDEXED) { reglcgen(&nod, l, Z); gopcode(OFUNC, Z, Z, &nod); regfree(&nod); } else gopcode(OFUNC, Z, Z, l); if(REGARG >= 0) if(o != reg[REGARG]) reg[REGARG]--; if(nn != Z) { regret(&nod, n); gopcode(OAS, &nod, Z, nn); regfree(&nod); } break; case OIND: if(nn == Z) { nullwarn(l, Z); break; } regialloc(&nod, n, nn); r = l; while(r->op == OADD) r = r->right; if(sconst(r) && (v = r->vconst+nod.xoffset) > -4096 && v < 4096) { v = r->vconst; r->vconst = 0; cgen(l, &nod); nod.xoffset += v; r->vconst = v; } else cgen(l, &nod); regind(&nod, n); gopcode(OAS, &nod, Z, nn); regfree(&nod); break; case OEQ: case ONE: case OLE: case OLT: case OGE: case OGT: case OLO: case OLS: case OHI: case OHS: if(nn == Z) { nullwarn(l, r); break; } boolgen(n, 1, nn); break; case OANDAND: case OOROR: boolgen(n, 1, nn); if(nn == Z) patch(p, pc); break; case ONOT: if(nn == Z) { nullwarn(l, Z); break; } boolgen(n, 1, nn); break; case OCOMMA: cgen(l, Z); cgen(r, nn); break; case OCAST: if(nn == Z) { nullwarn(l, Z); break; } /* * convert from types l->n->nn */ if(nocast(l->type, n->type)) { if(nocast(n->type, nn->type)) { cgen(l, nn); break; } } regalloc(&nod, l, nn); cgen(l, &nod); regalloc(&nod1, n, &nod); if(inrel) gmover(&nod, &nod1); else gopcode(OAS, &nod, Z, &nod1); gopcode(OAS, &nod1, Z, nn); regfree(&nod1); regfree(&nod); break; case ODOT: sugen(l, nodrat, l->type->width); if(nn != Z) { warn(n, "non-interruptable temporary"); nod = *nodrat; if(!r || r->op != OCONST) { diag(n, "DOT and no offset"); break; } nod.xoffset += (int32)r->vconst; nod.type = n->type; cgen(&nod, nn); } break; case OCOND: bcgen(l, 1); p1 = p; cgen(r->left, nn); gbranch(OGOTO); patch(p1, pc); p1 = p; cgen(r->right, nn); patch(p1, pc); break; case OPOSTINC: case OPOSTDEC: v = 1; if(l->type->etype == TIND) v = l->type->link->width; if(o == OPOSTDEC) v = -v; if(l->op == OBIT) goto bitinc; if(nn == Z) goto pre; if(l->addable < INDEXED) reglcgen(&nod2, l, Z); else nod2 = *l; regalloc(&nod, l, nn); gopcode(OAS, &nod2, Z, &nod); regalloc(&nod1, l, Z); if(typefd[l->type->etype]) { regalloc(&nod3, l, Z); if(v < 0) { gopcode(OAS, nodfconst(-v), Z, &nod3); gopcode(OSUB, &nod3, &nod, &nod1); } else { gopcode(OAS, nodfconst(v), Z, &nod3); gopcode(OADD, &nod3, &nod, &nod1); } regfree(&nod3); } else gopcode(OADD, nodconst(v), &nod, &nod1); gopcode(OAS, &nod1, Z, &nod2); regfree(&nod); regfree(&nod1); if(l->addable < INDEXED) regfree(&nod2); break; case OPREINC: case OPREDEC: v = 1; if(l->type->etype == TIND) v = l->type->link->width; if(o == OPREDEC) v = -v; if(l->op == OBIT) goto bitinc; pre: if(l->addable < INDEXED) reglcgen(&nod2, l, Z); else nod2 = *l; regalloc(&nod, l, nn); gopcode(OAS, &nod2, Z, &nod); if(typefd[l->type->etype]) { regalloc(&nod3, l, Z); if(v < 0) { gopcode(OAS, nodfconst(-v), Z, &nod3); gopcode(OSUB, &nod3, Z, &nod); } else { gopcode(OAS, nodfconst(v), Z, &nod3); gopcode(OADD, &nod3, Z, &nod); } regfree(&nod3); } else gopcode(OADD, nodconst(v), Z, &nod); gopcode(OAS, &nod, Z, &nod2); regfree(&nod); if(l->addable < INDEXED) regfree(&nod2); break; bitinc: if(nn != Z && (o == OPOSTINC || o == OPOSTDEC)) { bitload(l, &nod, &nod1, &nod2, Z); gopcode(OAS, &nod, Z, nn); gopcode(OADD, nodconst(v), Z, &nod); bitstore(l, &nod, &nod1, &nod2, Z); break; } bitload(l, &nod, &nod1, &nod2, nn); gopcode(OADD, nodconst(v), Z, &nod); bitstore(l, &nod, &nod1, &nod2, nn); break; } cursafe = curs; return; }
void main(int argc, char *argv[]) { int c; char *name, *val; Binit(&bso, 1, OWRITE); listinit(); memset(debug, 0, sizeof(debug)); nerrors = 0; outfile = nil; HEADTYPE = -1; INITTEXT = -1; INITDAT = -1; INITRND = -1; INITENTRY = 0; nuxiinit(); ARGBEGIN { default: c = ARGC(); if(c == 'l') usage(); if(c >= 0 && c < sizeof(debug)) debug[c]++; break; case 'o': /* output to (next arg) */ outfile = EARGF(usage()); break; case 'E': INITENTRY = EARGF(usage()); break; case 'H': HEADTYPE = headtype(EARGF(usage())); break; case 'I': interpreter = EARGF(usage()); break; case 'L': Lflag(EARGF(usage())); break; case 'T': INITTEXT = atolwhex(EARGF(usage())); break; case 'D': INITDAT = atolwhex(EARGF(usage())); break; case 'R': INITRND = atolwhex(EARGF(usage())); break; case 'r': rpath = EARGF(usage()); break; case 'V': print("%cl version %s\n", thechar, getgoversion()); errorexit(); case 'X': name = EARGF(usage()); val = EARGF(usage()); addstrdata(name, val); break; } ARGEND if(argc != 1) usage(); mywhatsys(); // get goos if(HEADTYPE == -1) HEADTYPE = headtype(goos); if(outfile == nil) { if(HEADTYPE == Hwindows) outfile = "8.out.exe"; else outfile = "8.out"; } libinit(); switch(HEADTYPE) { default: diag("unknown -H option"); errorexit(); case Hgarbunix: /* this is garbage */ HEADR = 20L+56L; if(INITTEXT == -1) INITTEXT = 0x40004CL; if(INITDAT == -1) INITDAT = 0x10000000L; if(INITRND == -1) INITRND = 0; break; case Hunixcoff: /* is unix coff */ HEADR = 0xd0L; if(INITTEXT == -1) INITTEXT = 0xd0; if(INITDAT == -1) INITDAT = 0x400000; if(INITRND == -1) INITRND = 0; break; case Hplan9x32: /* plan 9 */ tlsoffset = -8; HEADR = 32L; if(INITTEXT == -1) INITTEXT = 4096+32; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 4096; break; case Hmsdoscom: /* MS-DOS .COM */ HEADR = 0; if(INITTEXT == -1) INITTEXT = 0x0100; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 4; break; case Hmsdosexe: /* fake MS-DOS .EXE */ HEADR = 0x200; if(INITTEXT == -1) INITTEXT = 0x0100; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 4; HEADR += (INITTEXT & 0xFFFF); if(debug['v']) Bprint(&bso, "HEADR = 0x%d\n", HEADR); break; case Hdarwin: /* apple MACH */ /* * OS X system constant - offset from %gs to our TLS. * Explained in ../../pkg/runtime/cgo/gcc_darwin_386.c. */ tlsoffset = 0x468; machoinit(); HEADR = INITIAL_MACHO_HEADR; if(INITTEXT == -1) INITTEXT = 4096+HEADR; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 4096; break; case Hlinux: /* elf32 executable */ case Hfreebsd: case Hnetbsd: case Hopenbsd: /* * ELF uses TLS offsets negative from %gs. * Translate 0(GS) and 4(GS) into -8(GS) and -4(GS). * Also known to ../../pkg/runtime/sys_linux_386.s * and ../../pkg/runtime/cgo/gcc_linux_386.c. */ tlsoffset = -8; elfinit(); HEADR = ELFRESERVE; if(INITTEXT == -1) INITTEXT = 0x08048000+HEADR; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 4096; break; case Hwindows: /* PE executable */ peinit(); HEADR = PEFILEHEADR; if(INITTEXT == -1) INITTEXT = PEBASE+PESECTHEADR; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = PESECTALIGN; break; } if(INITDAT != 0 && INITRND != 0) print("warning: -D0x%ux is ignored because of -R0x%ux\n", INITDAT, INITRND); if(debug['v']) Bprint(&bso, "HEADER = -H0x%d -T0x%ux -D0x%ux -R0x%ux\n", HEADTYPE, INITTEXT, INITDAT, INITRND); Bflush(&bso); instinit(); zprg.link = P; zprg.pcond = P; zprg.back = 2; zprg.as = AGOK; zprg.from.type = D_NONE; zprg.from.index = D_NONE; zprg.from.scale = 1; zprg.to = zprg.from; pcstr = "%.6ux "; histgen = 0; pc = 0; dtype = 4; version = 0; cbp = buf.cbuf; cbc = sizeof(buf.cbuf); addlibpath("command line", "command line", argv[0], "main"); loadlib(); deadcode(); patch(); follow(); doelf(); if(HEADTYPE == Hdarwin) domacho(); if(HEADTYPE == Hwindows) dope(); dostkoff(); if(debug['p']) if(debug['1']) doprof1(); else doprof2(); span(); addexport(); textaddress(); pclntab(); symtab(); dodata(); address(); doweak(); reloc(); asmb(); undef(); if(debug['v']) { Bprint(&bso, "%5.2f cpu time\n", cputime()); Bprint(&bso, "%d symbols\n", nsymbol); Bprint(&bso, "%d sizeof adr\n", sizeof(Adr)); Bprint(&bso, "%d sizeof prog\n", sizeof(Prog)); } Bflush(&bso); errorexit(); }
int go() { TCHAR filename[MAX_PATH + 1]; HANDLE file; GetModuleFileName(NULL, filename, MAX_PATH); file = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if(file != INVALID_HANDLE_VALUE) { footer_t footer; DWORD read; int offset = -sizeof(footer_t); SetFilePointer(file, offset, NULL, FILE_END); ReadFile(file, &footer, sizeof(footer_t), &read, NULL); if(memcmp(footer.sig, SIG, sizeof(SIG) - 1) == 0) { // sig ok int i; char *buffer; int buffer_size = 1; patch_footer_t patch_footer; g_exe_name = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, footer.exe_name_len + 1); // get exe name offset -= footer.exe_name_len; SetFilePointer(file, offset, NULL, FILE_END); ReadFile(file, g_exe_name, footer.exe_name_len, &read, NULL); // create process if(! process()) return 0; // read patch information buffer = HeapAlloc(GetProcessHeap(), 0, buffer_size); for(i = 0; i < footer.npatches; i++) { offset -= sizeof(patch_footer_t); SetFilePointer(file, offset, NULL, FILE_END); ReadFile(file, &patch_footer, sizeof(patch_footer_t), &read, NULL); if(patch_footer.size * 2 > buffer_size) { buffer = HeapReAlloc(GetProcessHeap(), 0, buffer, patch_footer.size * 2); buffer_size = patch_footer.size * 2; } offset -= patch_footer.size * 2; SetFilePointer(file, offset, NULL, FILE_END); ReadFile(file, buffer, patch_footer.size * 2, &read, NULL); if(! patch(patch_footer.address, buffer, buffer + patch_footer.size, patch_footer.size)) return 0; } HeapFree(GetProcessHeap(), 0, g_exe_name); HeapFree(GetProcessHeap(), 0, buffer); } CloseHandle(file); } return 1; }
(C[facei].y()*inletDirCCS[facei].x() + C[facei].x()*inletDirCCS[facei].y())/radius; } else { inletDir[facei].x() = 0.0; inletDir[facei].y() = 0.0; } } } const surfaceScalarField& phi = db().lookupObject<surfaceScalarField>(phiName_); const fvsPatchField<scalar>& phip = patch().patchField<surfaceScalarField, scalar>(phi); if (phi.dimensions() == dimVelocity*dimArea) { vectorField n = patch().nf(); scalarField ndmagS = (n & inletDir_)*patch().magSf(); refValue() = inletDir*phip/ndmagS - rotationVelocity; } else if (phi.dimensions() == dimDensity*dimVelocity*dimArea) { const fvPatchField<scalar>& Tp = patch().lookupPatchField<volScalarField, scalar>(TName_); const basicThermo& thermo = db().lookupObject<basicThermo>("thermophysicalProperties");
/******************************************************************** * keyboard * * Callback function called by GLUT when a key is pressed. * * Parameters: * key - The key pressed. * x, y - Mouse position when the key is pressed. *******************************************************/ void keyboard (unsigned char key, int x, int y) { int i=0; char *o = "output.bmp"; switch (key) { //----Close the window case 'q': case 'Q': case 'x': case 'X': exit(0); //----increase budhabrot scale case '+': if (disp==BUDDHA) dark*=2; break; case '*': maxItr*=2; break; case '/': maxItr/=2; break; //----Fill the image with a single color case '1': disp = MANDEL; break; //----Fill the image with a top-to-bottom color gradient case '2': disp = BUDDHA; break; //----create a patch of initial conditions to follow case '3': stepPatch(); disp = PATCH; break; //print image to a file case 'p': rtWriteImage(pixels,o); /*CAREFUL THIS WRITES 100 images makePatch(); for (i=0;i<100;i++) { stepPatch(); patch(); itoa(i,c,10); strcat(c,o); rtWriteImage(pixels,c); } */ break; } if (disp==MANDEL) mandel(); else if (disp==BUDDHA) buddha(); else if (disp==PATCH) patch(); //automatically call display glutPostRedisplay(); }
/* * Convert postfix regular expression to NFA. * Return start state. */ State* post2nfa(char *postfix) { char *p; Frag stack[1000], *stackp, e1, e2, e; State *s; // fprintf(stderr, "postfix: %s\n", postfix); if(postfix == NULL) return NULL; memset(stack, 0, sizeof(Frag) * 1000); #define push(s) *stackp++ = s #define pop() *--stackp stackp = stack; for(p=postfix; *p; p++){ switch(*p){ default: s = state(*p, NULL, NULL); push(frag(s, list1(&s->out))); break; case '.': /* catenate */ e2 = pop(); e1 = pop(); patch(e1.out, e2.start); push(frag(e1.start, e2.out)); break; case '|': /* alternate */ e2 = pop(); e1 = pop(); s = state(Split, e1.start, e2.start); push(frag(s, append(e1.out, e2.out))); break; case '?': /* zero or one */ e = pop(); s = state(Split, e.start, NULL); push(frag(s, append(e.out, list1(&s->out1)))); break; case '*': /* zero or more */ e = pop(); s = state(Split, e.start, NULL); patch(e.out, s); push(frag(s, list1(&s->out1))); break; case '+': /* one or more */ e = pop(); s = state(Split, e.start, NULL); patch(e.out, s); push(frag(e.start, list1(&s->out1))); break; } } e = pop(); if(stackp != stack) return NULL; patch(e.out, &matchstate); return e.start; #undef pop #undef push }
bool Foam::solidParticle::move(solidParticle::trackData& td) { td.switchProcessor = false; td.keepParticle = true; const polyMesh& mesh = cloud().pMesh(); const polyBoundaryMesh& pbMesh = mesh.boundaryMesh(); scalar deltaT = mesh.time().deltaT().value(); scalar tEnd = (1.0 - stepFraction())*deltaT; scalar dtMax = tEnd; while (td.keepParticle && !td.switchProcessor && tEnd > SMALL) { if (debug) { Info<< "Time = " << mesh.time().timeName() << " deltaT = " << deltaT << " tEnd = " << tEnd << " steptFraction() = " << stepFraction() << endl; } // set the lagrangian time-step scalar dt = min(dtMax, tEnd); // remember which cell the parcel is in // since this will change if a face is hit label celli = cell(); dt *= trackToFace(position() + dt*U_, td); tEnd -= dt; stepFraction() = 1.0 - tEnd/deltaT; cellPointWeight cpw(mesh, position(), celli, face()); scalar rhoc = td.rhoInterp().interpolate(cpw); vector Uc = td.UInterp().interpolate(cpw); scalar nuc = td.nuInterp().interpolate(cpw); scalar rhop = td.spc().rhop(); scalar magUr = mag(Uc - U_); scalar ReFunc = 1.0; scalar Re = magUr*d_/nuc; if (Re > 0.01) { ReFunc += 0.15*pow(Re, 0.687); } scalar Dc = (24.0*nuc/d_)*ReFunc*(3.0/4.0)*(rhoc/(d_*rhop)); U_ = (U_ + dt*(Dc*Uc + (1.0 - rhoc/rhop)*td.g()))/(1.0 + dt*Dc); if (onBoundary() && td.keepParticle) { // Bug fix. HJ, 25/Aug/2010 if (face() > -1) { if (isType<processorPolyPatch>(pbMesh[patch(face())])) { td.switchProcessor = true; } } } } return td.keepParticle; }
void filmPyrolysisRadiativeCoupledMixedFvPatchScalarField::updateCoeffs() { if (updated()) { return; } // Get the coupling information from the mappedPatchBase const mappedPatchBase& mpp = refCast<const mappedPatchBase>(patch().patch()); const label patchI = patch().index(); const label nbrPatchI = mpp.samplePolyPatch().index(); const polyMesh& mesh = patch().boundaryMesh().mesh(); const polyMesh& nbrMesh = mpp.sampleMesh(); const fvPatch& nbrPatch = refCast<const fvMesh>(nbrMesh).boundary()[nbrPatchI]; scalarField intFld(patchInternalField()); const filmPyrolysisRadiativeCoupledMixedFvPatchScalarField& nbrField = refCast < const filmPyrolysisRadiativeCoupledMixedFvPatchScalarField > ( nbrPatch.lookupPatchField<volScalarField, scalar>(TnbrName_) ); // Swap to obtain full local values of neighbour internal field scalarField nbrIntFld(nbrField.patchInternalField()); mpp.distribute(nbrIntFld); scalarField& Tp = *this; const scalarField K(this->kappa(*this)); const scalarField nbrK(nbrField.kappa(*this)); // Swap to obtain full local values of neighbour K*delta scalarField KDeltaNbr(nbrK*nbrPatch.deltaCoeffs()); mpp.distribute(KDeltaNbr); scalarField myKDelta(K*patch().deltaCoeffs()); scalarList Tfilm(patch().size(), 0.0); scalarList htcwfilm(patch().size(), 0.0); scalarList filmDelta(patch().size(), 0.0); const pyrolysisModelType& pyrolysis = pyrModel(); const filmModelType& film = filmModel(); // Obtain Rad heat (Qr) scalarField Qr(patch().size(), 0.0); label coupledPatchI = -1; if (pyrolysisRegionName_ == mesh.name()) { coupledPatchI = patchI; if (QrName_ != "none") { Qr = nbrPatch.lookupPatchField<volScalarField, scalar>(QrName_); mpp.distribute(Qr); } } else if (pyrolysis.primaryMesh().name() == mesh.name()) { coupledPatchI = nbrPatch.index(); if (QrName_ != "none") { Qr = patch().lookupPatchField<volScalarField, scalar>(QrName_); } } else { FatalErrorIn ( "void filmPyrolysisRadiativeCoupledMixedFvPatchScalarField::" "updateCoeffs()" ) << type() << " condition is intended to be applied to either the " << "primary or pyrolysis regions only" << exit(FatalError); } const label filmPatchI = pyrolysis.nbrCoupledPatchID(film, coupledPatchI); const scalarField htcw(film.htcw().h()().boundaryField()[filmPatchI]); // Obtain htcw htcwfilm = pyrolysis.mapRegionPatchField ( film, coupledPatchI, filmPatchI, htcw, true ); // Obtain Tfilm at the boundary through Ts. // NOTE: Tf is not good as at the boundary it will retrieve Tp Tfilm = film.Ts().boundaryField()[filmPatchI]; film.toPrimary(filmPatchI, Tfilm); // Obtain delta filmDelta = pyrolysis.mapRegionPatchField<scalar> ( film, "deltaf", coupledPatchI, true ); // Estimate wetness of the film (1: wet , 0: dry) scalarField ratio ( min ( max ( (filmDelta - filmDeltaDry_)/(filmDeltaWet_ - filmDeltaDry_), scalar(0.0) ), scalar(1.0) ) ); scalarField qConv(ratio*htcwfilm*(Tfilm - Tp)*convectiveScaling_); scalarField qRad((1.0 - ratio)*Qr); scalarField alpha(KDeltaNbr - (qRad + qConv)/Tp); valueFraction() = alpha/(alpha + (1.0 - ratio)*myKDelta); refValue() = ratio*Tfilm + (1.0 - ratio)*(KDeltaNbr*nbrIntFld)/alpha; mixedFvPatchScalarField::updateCoeffs(); if (debug) { scalar Qc = gSum(qConv*patch().magSf()); scalar Qr = gSum(qRad*patch().magSf()); scalar Qt = gSum((qConv + qRad)*patch().magSf()); Info<< mesh.name() << ':' << patch().name() << ':' << this->dimensionedInternalField().name() << " <- " << nbrMesh.name() << ':' << nbrPatch.name() << ':' << this->dimensionedInternalField().name() << " :" << nl << " convective heat[W] : " << Qc << nl << " radiative heat [W] : " << Qr << nl << " total heat [W] : " << Qt << nl << " wall temperature " << " min:" << gMin(*this) << " max:" << gMax(*this) << " avg:" << gAverage(*this) << endl; } }
ofxPDSPStereoFader::ofxPDSPStereoFader(){ patch(); }
int HttpClient::patch(const String& aURLPath) { return patch(aURLPath.c_str()); }
void Foam::JohnsonJacksonParticleSlipFvPatchVectorField::updateCoeffs() { if (updated()) { return; } // lookup the fluid model and the phase const twoPhaseSystem& fluid = db().lookupObject<twoPhaseSystem> ( "phaseProperties" ); const phaseModel& phased ( fluid.phase1().name() == internalField().group() ? fluid.phase1() : fluid.phase2() ); // lookup all the fields on this patch const fvPatchScalarField& alpha ( patch().lookupPatchField<volScalarField, scalar> ( phased.volScalarField::name() ) ); const fvPatchScalarField& gs0 ( patch().lookupPatchField<volScalarField, scalar> ( IOobject::groupName("gs0", phased.name()) ) ); const scalarField nu ( patch().lookupPatchField<volScalarField, scalar> ( IOobject::groupName("nut", phased.name()) ) ); const scalarField nuFric ( patch().lookupPatchField<volScalarField, scalar> ( IOobject::groupName("nuFric", phased.name()) ) ); word ThetaName(IOobject::groupName("Theta", phased.name())); const fvPatchScalarField& Theta ( db().foundObject<volScalarField>(ThetaName) ? patch().lookupPatchField<volScalarField, scalar>(ThetaName) : alpha ); // lookup the packed volume fraction dimensionedScalar alphaMax ( "alphaMax", dimless, db() .lookupObject<IOdictionary> ( IOobject::groupName("turbulenceProperties", phased.name()) ) .subDict("RAS") .subDict("kineticTheoryCoeffs") .lookup("alphaMax") ); // calculate the slip value fraction scalarField c ( constant::mathematical::pi *alpha *gs0 *specularityCoefficient_.value() *sqrt(3*Theta) /max(6*(nu - nuFric)*alphaMax.value(), small) ); this->valueFraction() = c/(c + patch().deltaCoeffs()); partialSlipFvPatchVectorField::updateCoeffs(); }
int decode_contact_header (struct sip_msg *msg,char *unused1,char *unused2) { contact_body_t *cb; contact_t *c; str uri; str newUri; char separator; int res; #ifdef DEBUG fprintf (stdout,"---START--------DECODE CONTACT HEADER-----------------\n"); #endif if ((msg->contact == NULL)&&((parse_headers(msg,HDR_CONTACT_F,0) == -1) || (msg->contact== NULL) )) { LOG(L_ERR,"ERROR: decode_contact_header: no Contact header present\n"); return -1; } separator = DEFAULT_SEPARATOR[0]; if (contact_flds_separator != NULL) if (strlen(contact_flds_separator)>=1) separator = contact_flds_separator[0]; #ifdef DEBUG fprintf (stdout,"Using separator %c\n",separator); str* ruri; ruri = GET_RURI(msg); fprintf (stdout,"[len = %d]New uri is->%*.s\n",ruri->len,ruri->len,ruri->s); ruri = &msg->first_line.u.request.uri; fprintf (stdout, "INITIAL.s=[%.*s]\n", ruri->len, ruri->s); #endif if (msg->contact->parsed == NULL) parse_contact (msg->contact); if (msg->contact->parsed != NULL) { cb = (contact_body_t *) msg->contact->parsed; c = cb->contacts; // we visit each contact if (c != NULL) { uri = c->uri; res = decode_uri (uri, separator, &newUri); #ifdef DEBUG fprintf (stdout, "newuri.s=[%.*s]\n", newUri.len, newUri.s); #endif if (res != 0) { LOG (L_ERR,"ERROR: decode_contact_header:Failed decoding contact.Code %d\n", res); #ifdef STRICT_CHECK return res; #endif } else if (patch (msg, uri.s, uri.len, newUri.s, newUri.len) < 0) { LOG (L_ERR,"ERROR: decode_contact:lumping failed in mangling port \n"); return -2; } #ifdef DECODE_ALL_CONTACTS while (c->next != NULL) { c = c->next; uri = c->uri; res = decode_uri (uri, separator, &newUri); if (res != 0) { LOG (L_ERR,"ERROR: decode_contact: Failed decoding contact.Code %d\n",res); #ifdef STRICT_CHECK return res; #endif } else if (patch (msg, uri.s, uri.len, newUri.s, newUri.len) < 0) { LOG (L_ERR,"ERROR: decode_contact:lumping failed in mangling port \n"); return -3; } } // end while #endif } // if c!= NULL } // end if else // after parsing still NULL { LOG(L_ERR,"ERROR: decode_contact: Unable to parse Contact header\n"); return -4; } #ifdef DEBUG fprintf (stdout,"---END--------DECODE CONTACT HEADER-----------------\n");fflush(stdout); #endif return 1; }