/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation \\/ M anipulation | Copyright (C) 2015-2016 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 "blendingFactor.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { namespace functionObjects { defineTypeNameAndDebug(blendingFactor, 0); addToRunTimeSelectionTable(functionObject, blendingFactor, dictionary); } } // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // void Foam::functionObjects::blendingFactor::writeFileHeader(Ostream& os) const { writeHeader(os, "Blending factor"); writeCommented(os, "Time"); writeTabbed(os, "Scheme1"); writeTabbed(os, "Scheme2"); writeTabbed(os, "Blended"); os << endl; } bool Foam::functionObjects::blendingFactor::calc() { bool processed = false; processed = processed || calcBF(); processed = processed || calcBF(); return processed; } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::functionObjects::blendingFactor::blendingFactor ( const word& name, const Time& runTime, const dictionary& dict ) : fieldExpression(name, runTime, dict), writeFile(obr, name) { read(dict); writeFileHeader(file()); tmp indicatorPtr ( new volScalarField ( IOobject ( resultName_, mesh.time().timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh, dimensionedScalar("0", dimless, 0.0), zeroGradientFvPatchScalarField::typeName ) ); store(indicatorPtr, resultName_); setResultName(typeName, fieldName_); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::functionObjects::blendingFactor::~blendingFactor() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // bool Foam::functionObjects::blendingFactor::read(const dictionary& dict) { fieldExpression::read(dict); phiName_ = dict.lookupOrDefault("phi", "phi"); return true; } bool Foam::functionObjects::forces::write() { if (fieldExpression::write()) { const volScalarField& indictator = lookupObject(resultName_); // Generate scheme statistics label nCellsScheme1 = 0; label nCellsScheme2 = 0; label nCellsBlended = 0; forAll(indicator, celli) { scalar i = indicator[celli]; if (i < tolerance_) { nCellsScheme1++; } else if (i > (1 - tolerance_)) { nCellsScheme2++; } else { nCellsBlended++; } } reduce(nCellsScheme1, sumOp