/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2015 OpenFOAM Foundation Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . \*---------------------------------------------------------------------------*/ #include "turbulentDFSEMInletFvPatchVectorField.H" #include "addToRunTimeSelectionTable.H" #include "momentOfInertia.H" #include "OFstream.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // Foam::label Foam::turbulentDFSEMInletFvPatchVectorField::seedIterMax_ = 1000; // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // void Foam::turbulentDFSEMInletFvPatchVectorField::writeEddyOBJ() const { { // Output the bounding box OFstream os(db().time().path()/"eddyBox.obj"); const polyPatch& pp = this->patch().patch(); const labelList& boundaryPoints = pp.boundaryPoints(); const pointField& localPoints = pp.localPoints(); const vector offset(patchNormal_*maxSigmaX_); forAll(boundaryPoints, i) { point p = localPoints[boundaryPoints[i]]; p += offset; os << "v " << p.x() << " " << p.y() << " " << p.z() << nl; } forAll(boundaryPoints, i) { point p = localPoints[boundaryPoints[i]]; p -= offset; os << "v " << p.x() << " " << p.y() << " " << p.z() << nl; } } { const Time& time = db().time(); OFstream os ( time.path()/"eddies_" + Foam::name(time.timeIndex()) + ".obj" ); label pointOffset = 0; forAll(eddies_, eddyI) { const eddy& e = eddies_[eddyI]; pointOffset += e.writeSurfaceOBJ(pointOffset, patchNormal_, os); } } } void Foam::turbulentDFSEMInletFvPatchVectorField::writeLumleyCoeffs() const { // Output list of xi vs eta OFstream os(db().time().path()/"lumley_interpolated.out"); os << "# xi" << token::TAB << "eta" << endl; const scalar t = db().time().timeOutputValue(); const symmTensorField R(R_->value(t)/sqr(Uref_)); forAll(R, faceI) { // Normalised anisotropy tensor const symmTensor devR(dev(R[faceI]/(tr(R[faceI])))); // Second tensor invariant const scalar ii = min(0, invariantII(devR)); // Third tensor invariant const scalar iii = invariantIII(devR); // xi, eta // See Pope - characterization of Reynolds-stress anisotropy const scalar xi = cbrt(0.5*iii); const scalar eta = sqrt(-ii/3.0); os << xi << token::TAB << eta << token::TAB << ii << token::TAB << iii << endl; } } void Foam::turbulentDFSEMInletFvPatchVectorField::initialisePatch() { const vectorField nf(patch().nf()); // Patch normal points into domain patchNormal_ = -gAverage(nf); // Check that patch is planar const scalar error = max(magSqr(patchNormal_ + nf)); if (error > SMALL) { WarningInFunction << "Patch " << patch().name() << " is not planar" << endl; } patchNormal_ /= mag(patchNormal_) + ROOTVSMALL; // Decompose the patch faces into triangles to enable point search const polyPatch& patch = this->patch().patch(); const pointField& points = patch.points(); // Triangulate the patch faces and create addressing DynamicList