mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
finiteVolume: Added fvcSmooth which provides field smoothing operations: smooth, sweep and spread
This commit is contained in:
@ -337,6 +337,7 @@ $(laplacianSchemes)/laplacianScheme/laplacianSchemes.C
|
||||
$(laplacianSchemes)/gaussLaplacianScheme/gaussLaplacianSchemes.C
|
||||
|
||||
finiteVolume/fvc/fvcMeshPhi.C
|
||||
finiteVolume/fvc/fvcSmooth/fvcSmooth.C
|
||||
|
||||
general = cfdTools/general
|
||||
$(general)/findRefCell/findRefCell.C
|
||||
|
||||
318
src/finiteVolume/finiteVolume/fvc/fvcSmooth/fvcSmooth.C
Normal file
318
src/finiteVolume/finiteVolume/fvc/fvcSmooth/fvcSmooth.C
Normal file
@ -0,0 +1,318 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
|
||||
\\/ 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvcSmooth.H"
|
||||
#include "volFields.H"
|
||||
#include "FaceCellWave.H"
|
||||
#include "smoothData.H"
|
||||
#include "sweepData.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::scalar Foam::smoothData::maxRatio = 1.0;
|
||||
|
||||
void Foam::fvc::smooth
|
||||
(
|
||||
volScalarField& field,
|
||||
const scalar coeff
|
||||
)
|
||||
{
|
||||
const fvMesh& mesh = field.mesh();
|
||||
smoothData::maxRatio = 1 + coeff;
|
||||
|
||||
DynamicList<label> changedFaces(mesh.nFaces()/100 + 100);
|
||||
DynamicList<smoothData> changedFacesInfo(changedFaces.size());
|
||||
|
||||
const unallocLabelList& owner = mesh.owner();
|
||||
const unallocLabelList& neighbour = mesh.neighbour();
|
||||
|
||||
forAll(owner, facei)
|
||||
{
|
||||
const label own = owner[facei];
|
||||
const label nbr = neighbour[facei];
|
||||
|
||||
// Check if owner value much larger than neighbour value or vice versa
|
||||
if (field[own] > smoothData::maxRatio*field[nbr])
|
||||
{
|
||||
changedFaces.append(facei);
|
||||
changedFacesInfo.append(smoothData(field[own]));
|
||||
}
|
||||
else if (field[nbr] > smoothData::maxRatio*field[own])
|
||||
{
|
||||
changedFaces.append(facei);
|
||||
changedFacesInfo.append(smoothData(field[nbr]));
|
||||
}
|
||||
}
|
||||
|
||||
// Insert all faces of coupled patches - FaceCellWave will correct them
|
||||
forAll(mesh.boundaryMesh(), patchi)
|
||||
{
|
||||
const polyPatch& patch = mesh.boundaryMesh()[patchi];
|
||||
|
||||
if (patch.coupled())
|
||||
{
|
||||
forAll(patch, patchFacei)
|
||||
{
|
||||
label facei = patch.start() + patchFacei;
|
||||
label own = mesh.faceOwner()[facei];
|
||||
|
||||
changedFaces.append(facei);
|
||||
changedFacesInfo.append(smoothData(field[own]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
changedFaces.shrink();
|
||||
changedFacesInfo.shrink();
|
||||
|
||||
// Set initial field on cells
|
||||
List<smoothData> cellData(mesh.nCells());
|
||||
|
||||
forAll(field, celli)
|
||||
{
|
||||
cellData[celli] = field[celli];
|
||||
}
|
||||
|
||||
// Set initial field on faces
|
||||
List<smoothData> faceData(mesh.nFaces());
|
||||
|
||||
|
||||
// Propagate information over whole domain
|
||||
FaceCellWave<smoothData > smoothData
|
||||
(
|
||||
mesh,
|
||||
changedFaces,
|
||||
changedFacesInfo,
|
||||
faceData,
|
||||
cellData,
|
||||
mesh.globalData().nTotalCells() // max iterations
|
||||
);
|
||||
|
||||
forAll(field, celli)
|
||||
{
|
||||
field[celli] = cellData[celli].value();
|
||||
}
|
||||
|
||||
field.correctBoundaryConditions();
|
||||
}
|
||||
|
||||
|
||||
void Foam::fvc::spread
|
||||
(
|
||||
volScalarField& field,
|
||||
const volScalarField& alpha,
|
||||
const label nLayers
|
||||
)
|
||||
{
|
||||
const fvMesh& mesh = field.mesh();
|
||||
smoothData::maxRatio = 1;
|
||||
|
||||
DynamicList<label> changedFaces(mesh.nFaces()/100 + 100);
|
||||
DynamicList<smoothData> changedFacesInfo(changedFaces.size());
|
||||
|
||||
// Set initial field on cells
|
||||
List<smoothData> cellData(mesh.nCells());
|
||||
|
||||
forAll(field, celli)
|
||||
{
|
||||
cellData[celli] = field[celli];
|
||||
}
|
||||
|
||||
// Set initial field on faces
|
||||
List<smoothData> faceData(mesh.nFaces());
|
||||
|
||||
const unallocLabelList& owner = mesh.owner();
|
||||
const unallocLabelList& neighbour = mesh.neighbour();
|
||||
|
||||
forAll(owner, facei)
|
||||
{
|
||||
const label own = owner[facei];
|
||||
const label nbr = neighbour[facei];
|
||||
|
||||
if
|
||||
(
|
||||
(alpha[own] > 0.01 && alpha[own] < 0.99)
|
||||
|| (alpha[nbr] > 0.01 && alpha[nbr] < 0.99)
|
||||
)
|
||||
{
|
||||
if (mag(alpha[own] - alpha[nbr]) > 0.2)
|
||||
{
|
||||
changedFaces.append(facei);
|
||||
changedFacesInfo.append
|
||||
(
|
||||
smoothData(max(field[own], field[nbr]))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Insert all faces of coupled patches - FaceCellWave will correct them
|
||||
forAll(mesh.boundaryMesh(), patchi)
|
||||
{
|
||||
const polyPatch& patch = mesh.boundaryMesh()[patchi];
|
||||
|
||||
if (patch.coupled())
|
||||
{
|
||||
forAll(patch, patchFacei)
|
||||
{
|
||||
label facei = patch.start() + patchFacei;
|
||||
label own = mesh.faceOwner()[facei];
|
||||
|
||||
scalarField alphapn =
|
||||
alpha.boundaryField()[patchi].patchNeighbourField();
|
||||
|
||||
if
|
||||
(
|
||||
(alpha[own] > 0.01 && alpha[own] < 0.99)
|
||||
|| (alphapn[patchFacei] > 0.01 && alphapn[patchFacei] < 0.99)
|
||||
)
|
||||
{
|
||||
if (mag(alpha[own] - alphapn[patchFacei]) > 0.2)
|
||||
{
|
||||
changedFaces.append(facei);
|
||||
changedFacesInfo.append(smoothData(field[own]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
changedFaces.shrink();
|
||||
changedFacesInfo.shrink();
|
||||
|
||||
// Propagate information over whole domain
|
||||
FaceCellWave<smoothData> smoothData
|
||||
(
|
||||
mesh,
|
||||
faceData,
|
||||
cellData
|
||||
);
|
||||
|
||||
smoothData.setFaceInfo(changedFaces, changedFacesInfo);
|
||||
|
||||
smoothData.iterate(nLayers);
|
||||
|
||||
forAll(field, celli)
|
||||
{
|
||||
field[celli] = cellData[celli].value();
|
||||
}
|
||||
|
||||
field.correctBoundaryConditions();
|
||||
}
|
||||
|
||||
|
||||
void Foam::fvc::sweep
|
||||
(
|
||||
volScalarField& field,
|
||||
const volScalarField& alpha,
|
||||
const label nLayers
|
||||
)
|
||||
{
|
||||
const fvMesh& mesh = field.mesh();
|
||||
|
||||
DynamicList<label> changedFaces(mesh.nFaces()/100 + 100);
|
||||
DynamicList<sweepData> changedFacesInfo(changedFaces.size());
|
||||
|
||||
// Set initial field on cells
|
||||
List<sweepData> cellData(mesh.nCells());
|
||||
|
||||
// Set initial field on faces
|
||||
List<sweepData> faceData(mesh.nFaces());
|
||||
|
||||
const unallocLabelList& owner = mesh.owner();
|
||||
const unallocLabelList& neighbour = mesh.neighbour();
|
||||
const vectorField& Cf = mesh.faceCentres();
|
||||
|
||||
forAll(owner, facei)
|
||||
{
|
||||
const label own = owner[facei];
|
||||
const label nbr = neighbour[facei];
|
||||
|
||||
if (mag(alpha[own] - alpha[nbr]) > 0.2)
|
||||
{
|
||||
changedFaces.append(facei);
|
||||
changedFacesInfo.append
|
||||
(
|
||||
sweepData(max(field[own], field[nbr]),
|
||||
Cf[facei])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Insert all faces of coupled patches - FaceCellWave will correct them
|
||||
forAll(mesh.boundaryMesh(), patchi)
|
||||
{
|
||||
const polyPatch& patch = mesh.boundaryMesh()[patchi];
|
||||
|
||||
if (patch.coupled())
|
||||
{
|
||||
forAll(patch, patchFacei)
|
||||
{
|
||||
label facei = patch.start() + patchFacei;
|
||||
label own = mesh.faceOwner()[facei];
|
||||
|
||||
scalarField alphapn =
|
||||
alpha.boundaryField()[patchi].patchNeighbourField();
|
||||
|
||||
if (mag(alpha[own] - alphapn[patchFacei]) > 0.2)
|
||||
{
|
||||
changedFaces.append(facei);
|
||||
changedFacesInfo.append
|
||||
(
|
||||
sweepData(field[own], Cf[facei])
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
changedFaces.shrink();
|
||||
changedFacesInfo.shrink();
|
||||
|
||||
// Propagate information over whole domain
|
||||
FaceCellWave<sweepData> sweepData
|
||||
(
|
||||
mesh,
|
||||
faceData,
|
||||
cellData
|
||||
);
|
||||
|
||||
sweepData.setFaceInfo(changedFaces, changedFacesInfo);
|
||||
|
||||
sweepData.iterate(nLayers);
|
||||
|
||||
forAll(field, celli)
|
||||
{
|
||||
if (cellData[celli].valid())
|
||||
{
|
||||
field[celli] = max(field[celli], cellData[celli].value());
|
||||
}
|
||||
}
|
||||
|
||||
field.correctBoundaryConditions();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
73
src/finiteVolume/finiteVolume/fvc/fvcSmooth/fvcSmooth.H
Normal file
73
src/finiteVolume/finiteVolume/fvc/fvcSmooth/fvcSmooth.H
Normal file
@ -0,0 +1,73 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
|
||||
\\/ 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
function
|
||||
Foam::fvc::smooth
|
||||
|
||||
Description
|
||||
Function that uses smoothData to apply spatial smoothing of a
|
||||
volume field using the FaceCellWave algorithm
|
||||
|
||||
SourceFiles
|
||||
fvcSmooth.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef fvcSmooth_H
|
||||
#define fvcSmooth_H
|
||||
|
||||
#include "volFieldsFwd.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace fvc
|
||||
{
|
||||
void smooth
|
||||
(
|
||||
volScalarField& field,
|
||||
const scalar coeff
|
||||
);
|
||||
|
||||
void spread
|
||||
(
|
||||
volScalarField& field,
|
||||
const volScalarField& alpha,
|
||||
const label nLayers
|
||||
);
|
||||
|
||||
void sweep
|
||||
(
|
||||
volScalarField& field,
|
||||
const volScalarField& alpha,
|
||||
const label nLayers
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
204
src/finiteVolume/finiteVolume/fvc/fvcSmooth/smoothData.H
Normal file
204
src/finiteVolume/finiteVolume/fvc/fvcSmooth/smoothData.H
Normal file
@ -0,0 +1,204 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
|
||||
\\/ 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::smoothData
|
||||
|
||||
Description
|
||||
Helper class used by the smoothVolField class
|
||||
|
||||
Files
|
||||
smoothData.H
|
||||
smoothDataI.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef smoothData_H
|
||||
#define smoothData_H
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class smoothData Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class smoothData
|
||||
{
|
||||
scalar value_;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Update - gets information from neighbouring face/cell and
|
||||
// uses this to update itself (if necessary) and return true
|
||||
inline bool update
|
||||
(
|
||||
const smoothData& svf,
|
||||
const scalar scale,
|
||||
const scalar tol
|
||||
);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Static data members
|
||||
|
||||
//- Field fraction
|
||||
static scalar maxRatio;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
inline smoothData();
|
||||
|
||||
//- Construct from inverse field value
|
||||
inline smoothData(const scalar value);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return value
|
||||
scalar value() const
|
||||
{
|
||||
return value_;
|
||||
}
|
||||
|
||||
|
||||
// Needed by FaceCellWave
|
||||
|
||||
//- Check whether origin has been changed at all or
|
||||
// still contains original (invalid) value
|
||||
inline bool valid() const;
|
||||
|
||||
//- Check for identical geometrical data
|
||||
// Used for cyclics checking
|
||||
inline bool sameGeometry
|
||||
(
|
||||
const polyMesh&,
|
||||
const smoothData&,
|
||||
const scalar
|
||||
) const;
|
||||
|
||||
//- Convert any absolute coordinates into relative to
|
||||
// (patch)face centre
|
||||
inline void leaveDomain
|
||||
(
|
||||
const polyMesh&,
|
||||
const polyPatch&,
|
||||
const label patchFaceI,
|
||||
const point& faceCentre
|
||||
);
|
||||
|
||||
//- Reverse of leaveDomain
|
||||
inline void enterDomain
|
||||
(
|
||||
const polyMesh&,
|
||||
const polyPatch&,
|
||||
const label patchFaceI,
|
||||
const point& faceCentre
|
||||
);
|
||||
|
||||
//- Apply rotation matrix to any coordinates
|
||||
inline void transform
|
||||
(
|
||||
const polyMesh&,
|
||||
const tensor&
|
||||
);
|
||||
|
||||
//- Influence of neighbouring face
|
||||
inline bool updateCell
|
||||
(
|
||||
const polyMesh&,
|
||||
const label thisCellI,
|
||||
const label neighbourFaceI,
|
||||
const smoothData& svf,
|
||||
const scalar tol
|
||||
);
|
||||
|
||||
//- Influence of neighbouring cell
|
||||
inline bool updateFace
|
||||
(
|
||||
const polyMesh&,
|
||||
const label thisFaceI,
|
||||
const label neighbourCellI,
|
||||
const smoothData& svf,
|
||||
const scalar tol
|
||||
);
|
||||
|
||||
//- Influence of different value on same face
|
||||
inline bool updateFace
|
||||
(
|
||||
const polyMesh&,
|
||||
const label thisFaceI,
|
||||
const smoothData& svf,
|
||||
const scalar tol
|
||||
);
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
inline void operator=(const scalar value);
|
||||
|
||||
// Needed for List IO
|
||||
inline bool operator==(const smoothData&) const;
|
||||
|
||||
inline bool operator!=(const smoothData&) const;
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
friend Ostream& operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const smoothData& svf
|
||||
)
|
||||
{
|
||||
return os << svf.value_;
|
||||
}
|
||||
|
||||
friend Istream& operator>>(Istream& is, smoothData& svf)
|
||||
{
|
||||
return is >> svf.value_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "smoothDataI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
192
src/finiteVolume/finiteVolume/fvc/fvcSmooth/smoothDataI.H
Normal file
192
src/finiteVolume/finiteVolume/fvc/fvcSmooth/smoothDataI.H
Normal file
@ -0,0 +1,192 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
|
||||
\\/ 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
inline bool Foam::smoothData::update
|
||||
(
|
||||
const smoothData::smoothData& svf,
|
||||
const scalar scale,
|
||||
const scalar tol
|
||||
)
|
||||
{
|
||||
if (!valid() || (value_ < VSMALL))
|
||||
{
|
||||
// My value not set - take over neighbour
|
||||
value_ = svf.value()/scale;
|
||||
|
||||
// Something changed - let caller know
|
||||
return true;
|
||||
}
|
||||
else if (svf.value() > (1 + tol)*scale*value_)
|
||||
{
|
||||
// Neighbour is too big for me - Up my value
|
||||
value_ = svf.value()/scale;
|
||||
|
||||
// Something changed - let caller know
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Neighbour is not too big for me or change is too small
|
||||
// Nothing changed
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::smoothData::smoothData()
|
||||
:
|
||||
value_(-GREAT)
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::smoothData::smoothData(const scalar value)
|
||||
:
|
||||
value_(value)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline bool Foam::smoothData::valid() const
|
||||
{
|
||||
return value_ > -SMALL;
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::smoothData::sameGeometry
|
||||
(
|
||||
const polyMesh&,
|
||||
const smoothData&,
|
||||
const scalar
|
||||
) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::smoothData::leaveDomain
|
||||
(
|
||||
const polyMesh&,
|
||||
const polyPatch&,
|
||||
const label,
|
||||
const point&
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
inline void Foam::smoothData::transform
|
||||
(
|
||||
const polyMesh&,
|
||||
const tensor&
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
inline void Foam::smoothData::enterDomain
|
||||
(
|
||||
const polyMesh&,
|
||||
const polyPatch&,
|
||||
const label,
|
||||
const point&
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
inline bool Foam::smoothData::updateCell
|
||||
(
|
||||
const polyMesh&,
|
||||
const label,
|
||||
const label,
|
||||
const smoothData& svf,
|
||||
const scalar tol
|
||||
)
|
||||
{
|
||||
// Take over info from face if more than deltaRatio larger
|
||||
return update(svf, maxRatio, tol);
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::smoothData::updateFace
|
||||
(
|
||||
const polyMesh&,
|
||||
const label,
|
||||
const label,
|
||||
const smoothData& svf,
|
||||
const scalar tol
|
||||
)
|
||||
{
|
||||
// Take over information from cell without any scaling (scale = 1.0)
|
||||
return update(svf, 1.0, tol);
|
||||
}
|
||||
|
||||
|
||||
// Update this (face) with coupled face information.
|
||||
inline bool Foam::smoothData::updateFace
|
||||
(
|
||||
const polyMesh&,
|
||||
const label,
|
||||
const smoothData& svf,
|
||||
const scalar tol
|
||||
)
|
||||
{
|
||||
// Take over information from coupled face without any scaling (scale = 1.0)
|
||||
return update(svf, 1.0, tol);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
inline void Foam::smoothData::operator=
|
||||
(
|
||||
const scalar value
|
||||
)
|
||||
{
|
||||
value_ = value;
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::smoothData::operator==
|
||||
(
|
||||
const smoothData& rhs
|
||||
) const
|
||||
{
|
||||
return value_ == rhs.value();
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::smoothData::operator!=
|
||||
(
|
||||
const smoothData& rhs
|
||||
) const
|
||||
{
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
205
src/finiteVolume/finiteVolume/fvc/fvcSmooth/sweepData.H
Normal file
205
src/finiteVolume/finiteVolume/fvc/fvcSmooth/sweepData.H
Normal file
@ -0,0 +1,205 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
|
||||
\\/ 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::sweepData
|
||||
|
||||
Description
|
||||
Helper class used by fvcSmooth
|
||||
|
||||
Files
|
||||
sweepData.H
|
||||
sweepDataI.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef sweepData_H
|
||||
#define sweepData_H
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class sweepData Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class sweepData
|
||||
{
|
||||
scalar value_;
|
||||
point origin_;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Update - gets information from neighbouring face/cell and
|
||||
// uses this to update itself (if necessary) and return true
|
||||
inline bool update
|
||||
(
|
||||
const sweepData& svf,
|
||||
const point& position,
|
||||
const scalar tol
|
||||
);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
inline sweepData();
|
||||
|
||||
//- Construct from component
|
||||
inline sweepData(const scalar value, const point& origin);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return value
|
||||
scalar value() const
|
||||
{
|
||||
return value_;
|
||||
}
|
||||
|
||||
//- Return origin
|
||||
const point& origin() const
|
||||
{
|
||||
return origin_;
|
||||
}
|
||||
|
||||
|
||||
// Needed by FaceCellWave
|
||||
|
||||
//- Check whether origin has been changed at all or
|
||||
// still contains original (invalid) value
|
||||
inline bool valid() const;
|
||||
|
||||
//- Check for identical geometrical data
|
||||
// Used for cyclics checking
|
||||
inline bool sameGeometry
|
||||
(
|
||||
const polyMesh&,
|
||||
const sweepData&,
|
||||
const scalar
|
||||
) const;
|
||||
|
||||
//- Convert any absolute coordinates into relative to
|
||||
// (patch)face centre
|
||||
inline void leaveDomain
|
||||
(
|
||||
const polyMesh&,
|
||||
const polyPatch&,
|
||||
const label patchFaceI,
|
||||
const point& faceCentre
|
||||
);
|
||||
|
||||
//- Reverse of leaveDomain
|
||||
inline void enterDomain
|
||||
(
|
||||
const polyMesh&,
|
||||
const polyPatch&,
|
||||
const label patchFaceI,
|
||||
const point& faceCentre
|
||||
);
|
||||
|
||||
//- Apply rotation matrix to any coordinates
|
||||
inline void transform
|
||||
(
|
||||
const polyMesh&,
|
||||
const tensor&
|
||||
);
|
||||
|
||||
//- Influence of neighbouring face
|
||||
inline bool updateCell
|
||||
(
|
||||
const polyMesh&,
|
||||
const label thisCellI,
|
||||
const label neighbourFaceI,
|
||||
const sweepData& svf,
|
||||
const scalar tol
|
||||
);
|
||||
|
||||
//- Influence of neighbouring cell
|
||||
inline bool updateFace
|
||||
(
|
||||
const polyMesh&,
|
||||
const label thisFaceI,
|
||||
const label neighbourCellI,
|
||||
const sweepData& svf,
|
||||
const scalar tol
|
||||
);
|
||||
|
||||
//- Influence of different value on same face
|
||||
inline bool updateFace
|
||||
(
|
||||
const polyMesh&,
|
||||
const label thisFaceI,
|
||||
const sweepData& svf,
|
||||
const scalar tol
|
||||
);
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
inline void operator=(const scalar value);
|
||||
|
||||
// Needed for List IO
|
||||
inline bool operator==(const sweepData&) const;
|
||||
|
||||
inline bool operator!=(const sweepData&) const;
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
friend Ostream& operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const sweepData& svf
|
||||
)
|
||||
{
|
||||
return os << svf.value_ << svf.origin_;
|
||||
}
|
||||
|
||||
friend Istream& operator>>(Istream& is, sweepData& svf)
|
||||
{
|
||||
return is >> svf.value_ >> svf.origin_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "sweepDataI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
208
src/finiteVolume/finiteVolume/fvc/fvcSmooth/sweepDataI.H
Normal file
208
src/finiteVolume/finiteVolume/fvc/fvcSmooth/sweepDataI.H
Normal file
@ -0,0 +1,208 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
|
||||
\\/ 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "transform.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
inline bool Foam::sweepData::update
|
||||
(
|
||||
const sweepData::sweepData& svf,
|
||||
const point& position,
|
||||
const scalar tol
|
||||
)
|
||||
{
|
||||
if (!valid())
|
||||
{
|
||||
operator=(svf);
|
||||
return true;
|
||||
}
|
||||
|
||||
scalar myDist2 = magSqr(position - origin());
|
||||
|
||||
if (myDist2 < SMALL)
|
||||
{
|
||||
if (svf.value() > value())
|
||||
{
|
||||
operator=(svf);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
scalar dist2 = magSqr(position - svf.origin());
|
||||
|
||||
if (dist2 < myDist2)
|
||||
{
|
||||
operator=(svf);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::sweepData::sweepData()
|
||||
:
|
||||
value_(-GREAT),
|
||||
origin_(vector::max)
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::sweepData::sweepData(const scalar value, const point& origin)
|
||||
:
|
||||
value_(value),
|
||||
origin_(origin)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline bool Foam::sweepData::valid() const
|
||||
{
|
||||
return value_ > -SMALL;
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::sweepData::sameGeometry
|
||||
(
|
||||
const polyMesh&,
|
||||
const sweepData&,
|
||||
const scalar
|
||||
) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::sweepData::leaveDomain
|
||||
(
|
||||
const polyMesh&,
|
||||
const polyPatch&,
|
||||
const label,
|
||||
const point& faceCentre
|
||||
)
|
||||
{
|
||||
origin_ -= faceCentre;
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::sweepData::transform
|
||||
(
|
||||
const polyMesh&,
|
||||
const tensor& rotTensor
|
||||
)
|
||||
{
|
||||
origin_ = Foam::transform(rotTensor, origin_);
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::sweepData::enterDomain
|
||||
(
|
||||
const polyMesh&,
|
||||
const polyPatch&,
|
||||
const label,
|
||||
const point& faceCentre
|
||||
)
|
||||
{
|
||||
// back to absolute form
|
||||
origin_ += faceCentre;
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::sweepData::updateCell
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const label thisCellI,
|
||||
const label,
|
||||
const sweepData& svf,
|
||||
const scalar tol
|
||||
)
|
||||
{
|
||||
return update(svf, mesh.cellCentres()[thisCellI], tol);
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::sweepData::updateFace
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const label thisFaceI,
|
||||
const label,
|
||||
const sweepData& svf,
|
||||
const scalar tol
|
||||
)
|
||||
{
|
||||
return update(svf, mesh.faceCentres()[thisFaceI], tol);
|
||||
}
|
||||
|
||||
|
||||
// Update this (face) with coupled face information.
|
||||
inline bool Foam::sweepData::updateFace
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const label thisFaceI,
|
||||
const sweepData& svf,
|
||||
const scalar tol
|
||||
)
|
||||
{
|
||||
return update(svf, mesh.faceCentres()[thisFaceI], tol);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
inline void Foam::sweepData::operator=
|
||||
(
|
||||
const scalar value
|
||||
)
|
||||
{
|
||||
value_ = value;
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::sweepData::operator==
|
||||
(
|
||||
const sweepData& rhs
|
||||
) const
|
||||
{
|
||||
return origin() == rhs.origin();
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::sweepData::operator!=
|
||||
(
|
||||
const sweepData& rhs
|
||||
) const
|
||||
{
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user