/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2025 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
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 "fvcSurfaceIntegrate.H"
#include "fvMesh.H"
#include "extrapolatedCalculatedFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace fvc
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template
void surfaceIntegrate
(
Field& ivf,
const SurfaceField& ssf
)
{
const fvMesh& mesh = ssf.mesh();
const labelUList& owner = mesh.owner();
const labelUList& neighbour = mesh.neighbour();
const Field& issf = ssf;
forAll(owner, facei)
{
ivf[owner[facei]] += issf[facei];
ivf[neighbour[facei]] -= issf[facei];
}
forAll(mesh.boundary(), patchi)
{
const labelUList& pFaceCells =
mesh.boundary()[patchi].faceCells();
const fvsPatchField& pssf = ssf.boundaryField()[patchi];
forAll(mesh.boundary()[patchi], facei)
{
ivf[pFaceCells[facei]] += pssf[facei];
}
}
ivf /= mesh.Vsc();
}
template
tmp>
surfaceIntegrate
(
const SurfaceField& ssf
)
{
const fvMesh& mesh = ssf.mesh();
tmp> tvf
(
VolInternalField::New
(
"surfaceIntegrate("+ssf.name()+')',
mesh,
dimensioned
(
"0",
ssf.dimensions()/dimVolume,
Zero
)
)
);
VolInternalField& vf = tvf.ref();
surfaceIntegrate(vf.primitiveFieldRef(), ssf);
return tvf;
}
template
tmp>
surfaceIntegrate
(
const tmp>& tssf
)
{
tmp> tvf
(
fvc::surfaceIntegrate(tssf())
);
tssf.clear();
return tvf;
}
template
tmp>
surfaceIntegrateExtrapolate
(
const SurfaceField& ssf
)
{
const fvMesh& mesh = ssf.mesh();
tmp> tvf
(
VolField::New
(
"surfaceIntegrate("+ssf.name()+')',
mesh,
dimensioned
(
"0",
ssf.dimensions()/dimVolume,
Zero
),
extrapolatedCalculatedFvPatchField::typeName
)
);
VolField& vf = tvf.ref();
surfaceIntegrate(vf.primitiveFieldRef(), ssf);
vf.correctBoundaryConditions();
return tvf;
}
template
tmp>
surfaceIntegrateExtrapolate
(
const tmp>& tssf
)
{
tmp> tvf
(
fvc::surfaceIntegrateExtrapolate(tssf())
);
tssf.clear();
return tvf;
}
template
tmp> surfaceSum(const SurfaceField& ssf)
{
const fvMesh& mesh = ssf.mesh();
tmp> tvf
(
VolInternalField::New
(
"surfaceSum("+ssf.name()+')',
mesh,
dimensioned("0", ssf.dimensions(), Zero)
)
);
VolInternalField& vf = tvf.ref();
const labelUList& owner = mesh.owner();
const labelUList& neighbour = mesh.neighbour();
forAll(owner, facei)
{
vf[owner[facei]] += ssf[facei];
vf[neighbour[facei]] += ssf[facei];
}
forAll(mesh.boundary(), patchi)
{
const labelUList& pFaceCells =
mesh.boundary()[patchi].faceCells();
const fvsPatchField& pssf = ssf.boundaryField()[patchi];
forAll(mesh.boundary()[patchi], facei)
{
vf[pFaceCells[facei]] += pssf[facei];
}
}
return tvf;
}
template
tmp> surfaceSum
(
const tmp>& tssf
)
{
tmp> tvf = surfaceSum(tssf());
tssf.clear();
return tvf;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fvc
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //