Foam::tmp<Foam::Field<Type> > Foam::fieldValues::faceSource::filterField ( const GeometricField<Type, fvPatchField, volMesh>& field, const bool applyOrientation ) const { tmp<Field<Type> > tvalues(new Field<Type>(faceId_.size())); Field<Type>& values = tvalues(); forAll(values, i) { label faceI = faceId_[i]; label patchI = facePatchId_[i]; if (patchI >= 0) { values[i] = field.boundaryField()[patchI][faceI]; } else { FatalErrorIn ( "fieldValues::faceSource::filterField" "(" "const GeometricField<Type, fvPatchField, volMesh>&" ") const" ) << type() << " " << name_ << ": " << sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl << " Unable to process internal faces for volume field " << field.name() << nl << abort(FatalError); } }
Foam::tmp<Foam::Field<Type> > Foam::sampledIsoSurfaceCell::interpolateField ( const interpolation<Type>& interpolator ) const { // Recreate geometry if time has changed updateGeometry(); // One value per point tmp<Field<Type> > tvalues(new Field<Type>(points().size())); Field<Type>& values = tvalues(); boolList pointDone(points().size(), false); forAll(faces(), cutFaceI) { const face& f = faces()[cutFaceI]; forAll(f, faceVertI) { label pointI = f[faceVertI]; if (!pointDone[pointI]) { values[pointI] = interpolator.interpolate ( points()[pointI], meshCells_[cutFaceI] ); pointDone[pointI] = true; } } }
Foam::tmp<Foam::Field<Type> > Foam::sampledPlane::interpolateField ( const interpolation<Type>& interpolator ) const { // One value per point tmp<Field<Type> > tvalues(new Field<Type>(points().size())); Field<Type>& values = tvalues(); boolList pointDone(points().size(), false); forAll(faces(), cutFaceI) { const face& f = faces()[cutFaceI]; forAll(f, faceVertI) { label pointI = f[faceVertI]; if (!pointDone[pointI]) { values[pointI] = interpolator.interpolate ( points()[pointI], meshCells()[cutFaceI] ); pointDone[pointI] = true; } } }
tmp<Field<Type1> > PointPatchField<PatchField, Mesh, PointPatch, MatrixType, Type>:: patchInternalField ( const Field<Type1>& iF ) const { // Check size if (iF.size() != internalField().size()) { FatalErrorIn ( "tmp<Field<Type1> > PointPatchField<PatchField, PointPatch, " "Type>::" "patchInternalField(const Field<Type1>& iF) const" ) << "given internal field does not correspond to the mesh. " << "Field size: " << iF.size() << " mesh size: " << internalField().size() << abort(FatalError); } // get addressing const labelList& meshPoints = patch().meshPoints(); tmp<Field<Type1> > tvalues(new Field<Type1>(meshPoints.size())); Field<Type1>& values = tvalues(); forAll (meshPoints, pointI) { values[pointI] = iF[meshPoints[pointI]]; } return tvalues; }
Foam::tmp<Foam::Field<Type>> Foam::sampledPatch::sampleField ( const GeometricField<Type, fvPatchField, volMesh>& vField ) const { // One value per face tmp<Field<Type>> tvalues(new Field<Type>(patchFaceLabels_.size())); Field<Type>& values = tvalues(); forAll(patchFaceLabels_, i) { label patchI = patchIDs_[patchIndex_[i]]; const Field<Type>& bField = vField.boundaryField()[patchI]; values[i] = bField[patchFaceLabels_[i]]; }
void WedgePointPatchField <PatchField, Mesh, PointPatch, WedgePointPatch, MatrixType, Type>::evaluate ( const Pstream::commsTypes commsType ) { // In order to ensure that the wedge patch is always flat, take the // normal vector from the first point const vector& nHat = this->patch().pointNormals()[0]; tmp<Field<Type> > tvalues = transform(I - nHat*nHat, this->patchInternalField()); const Field<Type>& values = tvalues(); // Get internal field to insert values into Field<Type>& iF = const_cast<Field<Type>&>(this->internalField()); // Get addressing const labelList& meshPoints = this->patch().meshPoints(); forAll (meshPoints, pointI) { iF[meshPoints[pointI]] = values[pointI]; } }
void basicSymmetryPointPatchField<Type>::evaluate(const Pstream::commsTypes) { const vectorField& nHat = this->patch().pointNormals(); tmp<Field<Type> > tvalues = transform(I - nHat*nHat, this->patchInternalField()); // Get internal field to insert values into Field<Type>& iF = const_cast<Field<Type>&>(this->internalField()); setInInternalField(iF, tvalues()); }
void Foam::wedgePointPatchField<Type>::evaluate(const Pstream::commsTypes) { // In order to ensure that the wedge patch is always flat, take the // normal vector from the first point const vector& nHat = this->patch().pointNormals()[0]; tmp<Field<Type> > tvalues = transform(I - nHat*nHat, this->patchInternalField()); // Get internal field to insert values into Field<Type>& iF = const_cast<Field<Type>&>(this->internalField()); this->setInInternalField(iF, tvalues()); }
void Foam::cyclicSlipPointPatchField<Type>::evaluate(const Pstream::commsTypes) { const vectorField& nHat = this->patch().pointNormals(); tmp<Field<Type> > tvalues = ( ( this->patchInternalField() + transform(I - 2.0*sqr(nHat), this->patchInternalField()) )/2.0 ); // Get internal field to insert values into Field<Type>& iF = const_cast<Field<Type>&>(this->internalField()); this->setInInternalField(iF, tvalues()); }
void Foam::symmetryPlanePointPatchField<Type>::evaluate ( const Pstream::commsTypes ) { vector nHat = symmetryPlanePatch_.n(); tmp<Field<Type>> tvalues = ( ( this->patchInternalField() + transform(I - 2.0*sqr(nHat), this->patchInternalField()) )/2.0 ); // Get internal field to insert values into Field<Type>& iF = const_cast<Field<Type>&>(this->primitiveField()); this->setInInternalField(iF, tvalues()); }
baseline_reml::baseline_reml(MCMCoptions * o, const datamatrix & d, const datamatrix & leftint, const datamatrix & lefttrunc, const unsigned & nrk, const unsigned & degr, const unsigned & tgr, const unsigned & nrq, const unsigned & nrb, const knotpos & kp, const fieldtype & ft, const ST::string & ti, const ST::string & fp, const ST::string & pres, const double & l, const double & sl, const knotpos & gp, const int & gs, const bool & catsp, const double & rv) : spline_basis(o,d,nrk,degr,kp,ft,ti,fp,pres,l,sl,catsp,0.0,0.0,0.0,0.0,gs,rv) { unsigned i,j,k; baseline=true; varcoeff=false; // refcheck=false; gridpos = gp; double tmax=d.max(0); if(gridpos == MCMC::equidistant) { tgrid = tgr; tvalues = datamatrix(tgrid+1,1); tstep = tmax / tgrid; for(i=0;i<tvalues.rows();i++) tvalues(i,0) = i*tstep; } else if(gridpos == MCMC::quantiles) { tgrid = nrq*nrb; tvalues = datamatrix(tgrid+1,1); nrquant = nrq; nrbetween = nrb; datamatrix tquantiles = datamatrix(nrquant+1,1,0); for(i=1; i<nrquant; i++) { tquantiles(i,0) = d.quantile(((double)i/nrquant)*100,0); } tquantiles(nrquant,0) = tmax; double intmax, intmin, intstep; for(i=0; i<nrquant; i++) { intmin=tquantiles(i,0); intmax=tquantiles(i+1,0); intstep=(intmax-intmin)/nrbetween; for(j=0; j<nrbetween; j++) { tvalues(i*nrbetween+j,0) = intmin + j*intstep; } } tvalues(tgrid,0) = tmax; } else { make_index(d); vector<int>::iterator freqwork = freqoutput.begin(); int * workindex = index.getV(); tvalues = datamatrix(nrdiffobs,1,0); for(j=0;j<d.rows();j++,freqwork++,workindex++) if(freqwork==freqoutput.begin() || *freqwork!=*(freqwork-1)) tvalues(*freqwork,0) = d(*workindex,0); } tsteps = datamatrix(tvalues.rows()-1,1,0); for(i=0; i<tsteps.rows(); i++) tsteps(i,0) = tvalues(i+1,0)-tvalues(i,0); interact_var = datamatrix(d.rows(),1,1); datamatrix betahelp(nrpar,1,0); DG = datamatrix(tvalues.rows(),degree+1,0); DGfirst = vector<int>(tvalues.rows()); for(i=0;i<tvalues.rows();i++) { betahelp.assign( bspline(tvalues(i,0)) ); j=degree+1; while(knot[j] <= tvalues(i,0) && j<nrknots+degree) j++; for(k=0;k<degree+1;k++) DG(i,k) = betahelp(k+j-(degree+1),0); DGfirst[i] = j-(degree+1); } tleft = vector<unsigned>(d.rows(),0); tright = vector<unsigned>(d.rows(),1); ttrunc = vector<unsigned>(d.rows(),0); // indices for truncation times if(lefttrunc.rows()>1) { for(i=0; i<lefttrunc.rows(); i++) { j=1; while(j<tvalues.rows() && tvalues(j,0) < lefttrunc(i,0)) { ttrunc[i]++; j++; } } } for(i=0; i<d.rows(); i++) { j=0; while(j<tvalues.rows()-2 && tvalues(j,0)<d(i,0)) { tright[i]++; j++; } } if(leftint.rows()>1) { for(i=0; i<d.rows(); i++) { if( leftint(i,0) < d(i,0)) { j=0; while(j<tvalues.rows()-1 && tvalues(j,0)<leftint(i,0)) { tleft[i]++; j++; } } else if(leftint(i,0)> d(i,0)) { tleft[i] = tright[i]+1; } else { tleft[i] = tright[i]; } } } else { for(i=0; i<d.rows(); i++) { tleft[i] = tright[i]; } } }