.. _program_listing_file_samplers_SampledField_SampledVelocityField.C: Program Listing for File SampledVelocityField.C =============================================== |exhale_lsh| :ref:`Return to documentation for file ` (``samplers/SampledField/SampledVelocityField.C``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp /*---------------------------------------------------------------------------* \ License This file is part of libWallModelledLES. libWallModelledLES 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. libWallModelledLES 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 libWallModelledLES. If not, see . \*---------------------------------------------------------------------------*/ #include "SampledVelocityField.H" #include "volFields.H" #include "helpers.H" #include "interpolation.H" // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) namespace Foam { defineTypeNameAndDebug(SampledVelocityField, 0); } #endif // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::SampledVelocityField::sample ( Foam::scalarListList & sampledValues, const Foam::labelList & indexList, const Foam::scalarField & h ) const { if (debug) { Info<< "Sampling velocity for patch " << patch_.name() << nl; } const vectorField & faceCentres = patch().Cf(); const tmp tfaceNormals = patch().nf(); const vectorField & faceNormals = tfaceNormals(); const volVectorField & UField = mesh().lookupObject("U"); const vectorField & Uwall = UField.boundaryField()[patch().index()]; vectorField sampledU(indexList.size()); autoPtr > interpolator; interpolator.operator= ( interpolation::New(interpolationType(), UField) ); for (int i=0; iinterpolate(p, indexList[i]); sampledU[i] = interp - Uwall[i]; scalarList temp(3, 0.0); for (int j=0; j<3; j++) { temp[j] = sampledU[i][j]; } sampledValues[i] = temp; } Helpers::projectOnPatch(patch().nf(), sampledValues); } void Foam::SampledVelocityField::sample ( Foam::scalarListListList & sampledValues, const Foam::labelListList & indexList ) const { if (debug) { Info<< "Sampling velocity for patch " << patch().name() << nl; } const volVectorField & UField = mesh().lookupObject("U"); const vectorField & Uwall = UField.boundaryField()[patch().index()]; forAll(indexList, i) { sampledValues[i] = scalarListList(indexList[i].size()); forAll(indexList[i], j) { scalarList temp(3, 0.0); for (int k=0; k<3; k++) { temp[k] = (UField[indexList[i][j]] - Uwall[i])[k]; } sampledValues[i][j] = temp; } } Helpers::projectOnPatch(patch().nf(), sampledValues); } void Foam::SampledVelocityField::registerFields ( const labelList & indexList ) const { // Initialize to 0 scalarListList sampledU(patch().size()); forAll(sampledU, i) { sampledU[i] = scalarList(3, 0.0); } if (mesh().foundObject("U")) { const volVectorField & U = mesh().lookupObject("U"); forAll(sampledU, i) { forAll(sampledU[i], j) { sampledU[i][j] = U[indexList[i]][j]; } } Helpers::projectOnPatch(patch().nf(), sampledU); } if (!db().foundObject("U")) { mesh().time().store ( new IOList ( IOobject ( "U", mesh().time().timeName(), db(), IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), sampledU ) ); } } void Foam::SampledVelocityField::registerFields ( const labelListList & indexList ) const { scalarListListList sampledU(patch().size()); forAll(sampledU, i) { sampledU[i] = scalarListList(indexList[i].size()); forAll(sampledU[i], j) { sampledU[i][j] = scalarList(3, 0.0); } } if (mesh().foundObject("U")) { const auto & U = mesh().lookupObject("U"); forAll(sampledU, i) { forAll(sampledU[i], j) { forAll(sampledU[i][j], k) { sampledU[i][j][k] = U[indexList[i][j]][k]; } } } Helpers::projectOnPatch(patch().nf(), sampledU); } if (!db().foundObject("U")) { mesh().time().store ( new scalarListListIOList ( IOobject ( "U", mesh().time().timeName(), db(), IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), sampledU ) ); } } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //