diff --git a/src/functionObjects/field/DMD/DMD.C b/src/functionObjects/field/DMD/DMD.C new file mode 100644 index 0000000000..e225d31cb4 --- /dev/null +++ b/src/functionObjects/field/DMD/DMD.C @@ -0,0 +1,234 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2020-2021 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 "DMD.H" +#include "DMDModel.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + defineTypeNameAndDebug(DMD, 0); + addToRunTimeSelectionTable(functionObject, DMD, dictionary); +} +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::functionObjects::DMD::snapshot() +{ + bool processed = false; + processed = processed || getSnapshot(); + processed = processed || getSnapshot(); + processed = processed || getSnapshot(); + processed = processed || getSnapshot(); + processed = processed || getSnapshot(); + + if (!processed) + { + FatalErrorInFunction + << " functionObjects::" << type() << " " << name() << ":" + << " cannot find required input field during snapshot loading: " + << fieldName_ << nl + << " Do you execute required functionObjects" + << " before executing DMD, e.g. mapFields?" + << exit(FatalError); + } +} + + +void Foam::functionObjects::DMD::initialise() +{ + const label nComps = DMDModelPtr_->nComponents(fieldName_); + + if (patch_.empty()) + { + nSnap_ = nComps*mesh_.nCells(); + } + else + { + const label patchi = mesh_.boundaryMesh().findPatchID(patch_); + + if (patchi < 0) + { + FatalErrorInFunction + << "Cannot find patch " << patch_ + << exit(FatalError); + } + + nSnap_ = nComps*(mesh_.C().boundaryField()[patchi]).size(); + } + + const label nSnapTotal = returnReduce(nSnap_, sumOp