1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
28 Calculates and writes the Co number as a surfaceScalarField obtained
31 The -noWrite option just outputs the max values without writing the
34 \*---------------------------------------------------------------------------*/
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 tmp<volScalarField> Co(const surfaceScalarField& Cof)
45 const fvMesh& mesh = Cof.mesh();
47 tmp<volScalarField> tCo
54 mesh.time().timeName(),
58 dimensionedScalar("0", Cof.dimensions(), 0)
62 volScalarField& Co = tCo();
64 // Set local references to mesh data
65 const unallocLabelList& owner = mesh.owner();
66 const unallocLabelList& neighbour = mesh.neighbour();
70 label own = owner[facei];
71 label nei = neighbour[facei];
73 Co[own] = max(Co[own], Cof[facei]);
74 Co[nei] = max(Co[nei], Cof[facei]);
77 forAll(Co.boundaryField(), patchi)
79 Co.boundaryField()[patchi] = Cof.boundaryField()[patchi];
87 void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
89 bool writeResults = !args.optionFound("noWrite");
99 if (phiHeader.headerOk())
101 autoPtr<surfaceScalarField> CoPtr;
103 Info<< " Reading phi" << endl;
104 surfaceScalarField phi(phiHeader, mesh);
105 Info<< " Calculating Co" << endl;
107 if (phi.dimensions() == dimensionSet(1, 0, -1, 0, 0))
124 new surfaceScalarField
134 mesh.surfaceInterpolation::deltaCoeffs()
135 * (mag(phi)/(fvc::interpolate(rho)*mesh.magSf()))
141 else if (phi.dimensions() == dimensionSet(0, 3, -1, 0, 0))
146 new surfaceScalarField
156 mesh.surfaceInterpolation::deltaCoeffs()
157 * (mag(phi)/mesh.magSf())
165 FatalErrorIn(args.executable())
166 << "Incorrect dimensions of phi: " << phi.dimensions()
167 << abort(FatalError);
170 Info<< "Co max : " << max(CoPtr()).value() << endl;
175 Co(CoPtr())().write();
180 Info<< " No phi" << endl;
183 Info<< "\nEnd\n" << endl;
187 // ************************************************************************* //