scalar arakawaKonorStripesTracerField::tracerAt ( const point& p, const Time& t ) const { scalar x = p.x() - xOffset; if (mag(x) <= wavelength / 2) { if (p.z() >= z1Start - 1 && p.z() <= z1End - 1) { return -rho0*Foam::sin(2*M_PI*x/wavelength); } else if (p.z() >= z2Start - 1 && p.z() <= z2End - 1) { return rho0*Foam::sin(2*M_PI*x/wavelength); } else { return 0; } } else { return 0; } }
bool Foam::octreeDataBoundBox::findTightest ( const label index, const point& sample, treeBoundBox& tightest ) const { // Get furthest away vertex point myNear, myFar; allBb_[index].calcExtremities(sample, myNear, myFar); const point dist = myFar - sample; scalar myFarDist = mag(dist); point tightestNear, tightestFar; tightest.calcExtremities(sample, tightestNear, tightestFar); scalar tightestFarDist = mag(tightestFar - sample); if (tightestFarDist < myFarDist) { // Keep current tightest. return false; } else { // Construct bb around sample and myFar const point dist2(fabs(dist.x()), fabs(dist.y()), fabs(dist.z())); tightest.min() = sample - dist2; tightest.max() = sample + dist2; return true; } }
vector horizontalVelocityField::streamfunctionAt ( const point& p, const Time& t ) const { const vector unitNormal(0, -1, 0); const dimensionedScalar z("z", dimLength, p.z()); dimensionedScalar psi("psi", cmptMultiply(dimVelocity, dimLength), scalar(0)); if (z.value() <= z1.value()) { // psi is zero } else if (z.value() <= z2.value()) { psi = -0.5*u0*(z - z1 - (z2-z1)/M_PI*Foam::sin(M_PI*(z-z1)/(z2-z1))); } else { psi = -0.5*u0*(2*z - z2 - z1); } return unitNormal * psi.value(); }
bool Foam::treeLeaf<Foam::octreeDataTriSurface>::findNearest ( const octreeDataTriSurface& shapes, const point& sample, treeBoundBox& tightest, label& tightestI, scalar& tightestDist ) const { // Some aliases const treeBoundBoxList& allBb = shapes.allBb(); point& min = tightest.min(); point& max = tightest.max(); point nearest; bool changed = false; forAll(indices_, i) { label faceI = indices_[i]; // Quick rejection test. if (tightest.overlaps(allBb[faceI])) { // Full calculation scalar dist = shapes.calcNearest(faceI, sample, nearest); if (dist < tightestDist) { // Update bb (centered around sample, span is dist) min.x() = sample.x() - dist; min.y() = sample.y() - dist; min.z() = sample.z() - dist; max.x() = sample.x() + dist; max.y() = sample.y() + dist; max.z() = sample.z() + dist; tightestI = faceI; tightestDist = dist; changed = true; } } }
Foam::point Foam::scaleSearchableSurface::inverseTransform(const point &p) const { return point ( p.x()/scale_.x(), p.y()/scale_.y(), p.z()/scale_.z() ); }
point horizontalVelocityField::initialPositionOf ( const point& p, const Time& t ) const { const dimensionedScalar z("z", dimLength, p.z()); if (z.value() <= z1.value()) { return p; } else if (z.value() <= z2.value()) { return point(p.x() - (u0*sqr(Foam::sin(0.5*M_PI*(z-z1)/(z2-z1)))*t).value(), p.y(), p.z()); } else { return point(p.x() - u0.value()*t.value(), p.y(), p.z()); } }
std::string stringify(point p) { std::stringstream ss; ss << "#<point:"; ss << " x="; ss << p.x(); ss << " y="; ss << p.y(); ss << " z="; ss << p.z(); ss << ">"; return ss.str(); }
forAll(order, sortI) { label pointI = order[sortI]; // Convert to scalar precision const point pt ( scalar(d[pointI].x()), scalar(d[pointI].y()), scalar(d[pointI].z()) ); sortedTol[sortI] = 2*mergeTol*(mag(pt.x())+mag(pt.y())+mag(pt.z())); }
void Foam::surfaceIntersection::writeOBJ(const point& pt, Ostream& os) { os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << endl; }
void Foam::coupledPolyPatch::writeOBJ(Ostream& os, const point& pt) { os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << endl; }
bool in_range(point p, point min, point max) { return (min.x() <= p.x() && p.x() <= max.x() && min.y() <= p.y() && p.y() <= max.y() && min.z() <= p.z() && p.z() <= max.z()); }
bool lineRefinement::intersectsObject(const boundBox& bb) const { //- check if the cube contains start point or end point const scalar l = bb.max().x() - bb.min().x(); const point min = bb.min() - l * vector(SMALL, SMALL, SMALL); const point max = bb.max() + l * vector(SMALL, SMALL, SMALL); //- check for intersections of line with the cube faces const vector v(p1_ - p0_); if( mag(v.x()) > SMALL ) { if( ((p0_.x() < min.x()) && (p1_.x() < min.x())) || ((p0_.x() > max.x()) && (p1_.x() > max.x())) ) return false; { //- x-min face const vector n(-1, 0, 0); const scalar t = (n & (min - p0_)) / (n & v); const point i = p0_ + t * v; if( (t > -SMALL) && (t < (1.0+SMALL)) ) if( (i.y() > min.y()) && (i.y() < max.y()) && (i.z() > min.z()) && (i.z() < max.z()) ) return true; } { //- x-max face const vector n(1, 0, 0); const scalar t = (n & (max - p0_)) / (n & v); const point i = p0_ + t * v; if( (t > -SMALL) && (t < (1.0+SMALL)) ) if( (i.y() > min.y()) && (i.y() < max.y()) && (i.z() > min.z()) && (i.z() < max.z()) ) return true; } } if( mag(v.y()) > SMALL) { if( ((p0_.y() < min.y()) && (p1_.y() < min.y())) || ((p0_.y() > max.y()) && (p1_.y() > max.y())) ) return false; { //- y-min face const vector n(0, -1, 0); const scalar t = (n & (min - p0_)) / (n & v); const point i = p0_ + t * v; if( (t > -SMALL) && (t < (1.0+SMALL)) ) if( (i.x() > min.x()) && (i.x() < max.x()) && (i.z() > min.z()) && (i.z() < max.z()) ) return true; } { //- y-max face const vector n(0, 1, 0); const scalar t = (n & (max - p0_)) / (n & v); const point i = p0_ + t * v; if( (t > -SMALL) && (t < (1.0+SMALL)) ) if( (i.x() > min.x()) && (i.x() < max.x()) && (i.z() > min.z()) && (i.z() < max.z()) ) return true; } } if( mag(v.z()) > SMALL ) { if( ((p0_.z() < min.z()) && (p1_.z() < min.z())) || ((p0_.z() > max.z()) && (p1_.z() > max.z())) ) return false; { //- z-min face const vector n(0, 0, -1); const scalar t = (n & (min - p0_)) / (n & v); const point i = p0_ + t * v; if( (t > -SMALL) && (t < (1.0+SMALL)) && (i.x() > min.x()) && (i.x() < max.x()) && (i.y() > min.y()) && (i.y() < max.y()) ) return true; } { //- z-min face const vector n(0, 0, 1); const scalar t = (n & (max - p0_)) / (n & v); const point i = p0_ + t * v; if( (t > -SMALL) && (t < (1.0+SMALL)) && (i.x() > min.x()) && (i.x() < max.x()) && (i.y() > min.y()) && (i.y() < max.y()) ) return true; } } if( (p0_.x() > min.x()) && (p0_.x() < max.x()) && (p0_.y() > min.y()) && (p0_.y() < max.y()) && (p0_.z() > min.z()) && (p0_.z() < max.z()) ) return true; return false; }
void Foam::layerSmooth::addZonesAndModifiers() { // Add the zones and mesh modifiers to operate piston motion if ( /* pointZones().size() > 0 || faceZones().size() > 0 || cellZones().size() > 0 || topoChanger_.size() > 0 */ pointZones().size() > 0 && faceZones().size() > 0 && topoChanger_.size() > 0 ) { Info<< "Time = " << engTime().theta() << endl; Info<< "void Foam::layerSmooth::addZonesAndModifiers() : " << "Zones and modifiers already present. Skipping." << endl; setVirtualPositions(); checkAndCalculate(); Info << "Point zones found = " << pointZones().size() << endl; Info << "Face zones found = " << faceZones().size() << endl; Info << "Cell zones found = " << cellZones().size() << endl; return; } else { pointZones().setSize(0); faceZones().setSize(0); cellZones().setSize(0); topoChanger_.setSize(0); } if ( engTime().engineDict().found("zOffsetGambit") && engTime().engineDict().found("zDisplGambit") ) { Info << "Assembling the cylinder mesh" << endl; scalar zOffset ( readScalar(engTime().engineDict().lookup("zOffsetGambit")) ); scalar zDispl ( readScalar(engTime().engineDict().lookup("zDisplGambit")) ); const pointField& ap = allPoints(); pointField pDispl = allPoints(); forAll(ap, pointI) { const point p = ap[pointI]; if (p.z() >= zOffset) { pDispl[pointI].z() -= zDispl; } } movePoints(pDispl); write(); resetMotion(); Info << "Cylinder mesh assembled" << endl; }
void Foam::directions::writeOBJ(Ostream& os, const point& pt) { os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << endl; }