.. _program_listing_file_samplers_SampledField_SampledWallGradUField.C: Program Listing for File SampledWallGradUField.C ================================================ |exhale_lsh| :ref:`Return to documentation for file ` (``samplers/SampledField/SampledWallGradUField.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 "SampledWallGradUField.H" #include "volFields.H" #include "codeRules.H" #include "helpers.H" // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) namespace Foam { defineTypeNameAndDebug(SampledWallGradUField, 0); } #endif // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::SampledWallGradUField::sample ( Foam::scalarListList & sampledValues, const Foam::labelList & indexList, const Foam::scalarField & h ) const { if (debug) { Info<< "Sampling wall-normal velocity gradient for patch " << patch_.name() << nl; } label pI = patch().index(); const volVectorField & wallGradU = mesh().lookupObject("wallGradU"); const vectorField & boundaryValues = wallGradU.boundaryField()[pI]; for (int i=0; i("wallGradU"); const vectorField & boundaryValues = wallGradU.boundaryField()[pI]; for (int i=0; i("wallGradU")) { const volVectorField & wallGradU = mesh().lookupObject("wallGradU"); label pI = patch().index(); const vectorField & boundaryValues = wallGradU.boundaryField()[pI]; forAll(sampledWallGradU, i) { forAll(sampledWallGradU[i], j) { sampledWallGradU[i][j] = boundaryValues[i][j]; } } Helpers::projectOnPatch(patch().nf(), sampledWallGradU); } if (!db().foundObject("wallGradU")) { mesh().time().store ( new IOList ( IOobject ( "wallGradU", mesh().time().timeName(), db(), IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), sampledWallGradU ) ); } } void Foam::SampledWallGradUField::registerFields ( const labelListList & indexListList ) const { scalarListListList sampledWallGradU(patch().size()); forAll(sampledWallGradU, i) { sampledWallGradU[i] = scalarListList(1); sampledWallGradU[i][0] = scalarList(3, 0.0); } if (mesh().foundObject("wallGradU")) { const volVectorField & wallGradU = mesh().lookupObject("wallGradU"); label pI = patch().index(); const vectorField & boundaryValues = wallGradU.boundaryField()[pI]; forAll(sampledWallGradU, i) { forAll(sampledWallGradU[i][0], j) { sampledWallGradU[i][0][j] = boundaryValues[i][j]; } } Helpers::projectOnPatch(patch().nf(), sampledWallGradU); } if (!db().foundObject("wallGradU")) { mesh().time().store ( new scalarListListIOList ( IOobject ( "wallGradU", mesh().time().timeName(), db(), IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), sampledWallGradU ) ); } } void Foam::SampledWallGradUField::recompute() const { label pI = patch().index(); volVectorField & wallGradU = const_cast ( mesh().lookupObject("wallGradU") ); const volVectorField & U = mesh().lookupObject("U"); const fvPatchVectorField & Uwall = U.boundaryField()[pI]; vectorField Udiff(Uwall.patchInternalField() - Uwall); wallGradU.boundaryFieldRef()[pI] == patch().deltaCoeffs()*Udiff; } void Foam::SampledWallGradUField::createField() const { bool foundhSampler = mesh_.foundObject("hSampler"); word hName; // Grab h for the current patch if (foundhSampler) { hName = "hSampler"; } else { hName = "h"; } const volScalarField & h = mesh_.lookupObject (hName); if (!mesh().foundObject("wallGradU")) { mesh().time().store ( new volVectorField ( IOobject ( "wallGradU", mesh().time().timeName(), mesh(), IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh(), dimensionedVector ( "wallGradU", dimVelocity/dimLength, pTraits::zero ), h.boundaryField().types() ) ); } if (mesh().foundObject("U")) { recompute(); } } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //