/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | Copyright (C) 2015 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 "faceSource.H" #include "surfaceFields.H" #include "volFields.H" #include "sampledSurface.H" #include "interpolationCellPoint.H" // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // template bool Foam::fieldValues::faceSource::validField(const word& fieldName) const { typedef GeometricField sf; typedef GeometricField vf; if (source_ != stSampledSurface && obr_.foundObject(fieldName)) { return true; } else if (obr_.foundObject(fieldName)) { return true; } return false; } template Foam::tmp > Foam::fieldValues::faceSource::setFieldValues ( const word& fieldName, const bool mustGet, const bool applyOrientation ) const { typedef GeometricField sf; typedef GeometricField vf; if (source_ != stSampledSurface && obr_.foundObject(fieldName)) { return filterField(obr_.lookupObject(fieldName), applyOrientation); } else if (obr_.foundObject(fieldName)) { const vf& fld = obr_.lookupObject(fieldName); if (surfacePtr_.valid()) { if (surfacePtr_().interpolate()) { const interpolationCellPoint interp(fld); tmp > tintFld(surfacePtr_().interpolate(interp)); const Field& intFld = tintFld(); // Average const faceList& faces = surfacePtr_().faces(); tmp > tavg ( new Field(faces.size(), pTraits::zero) ); Field& avg = tavg(); forAll(faces, faceI) { const face& f = faces[faceI]; forAll(f, fp) { avg[faceI] += intFld[f[fp]]; } avg[faceI] /= f.size(); } return tavg; } else { return surfacePtr_().sample(fld); } } else { return filterField(fld, applyOrientation); } } if (mustGet) { FatalErrorIn ( "Foam::tmp > " "Foam::fieldValues::faceSource::setFieldValues" "(" "const word&, " "const bool, " "const bool" ") const" ) << "Field " << fieldName << " not found in database" << abort(FatalError); } return tmp >(new Field(0)); } template Type Foam::fieldValues::faceSource::processSameTypeValues ( const Field& values, const vectorField& Sf, const scalarField& weightField ) const { Type result = pTraits::zero; switch (operation_) { case opSum: { result = gSum(values); break; } case opSumMag: { result = gSum(cmptMag(values)); break; } case opSumDirection: { FatalErrorIn ( "template" "Type Foam::fieldValues::faceSource::processSameTypeValues" "(" "const Field&, " "const vectorField&, " "const scalarField&" ") const" ) << "Operation " << operationTypeNames_[operation_] << " not available for values of type " << pTraits::typeName << exit(FatalError); result = pTraits::zero; break; } case opSumDirectionBalance: { FatalErrorIn ( "template" "Type Foam::fieldValues::faceSource::processSameTypeValues" "(" "const Field&, " "const vectorField&, " "const scalarField&" ") const" ) << "Operation " << operationTypeNames_[operation_] << " not available for values of type " << pTraits::typeName << exit(FatalError); result = pTraits::zero; break; } case opAverage: { label n = returnReduce(values.size(), sumOp