ENH: Adding interTrack code

1) New skewCorrectedSnGrad for non-orthogonal and skewness corrector
2) New freeSurfacePressure and freeSurfacePressure working with
   interfaceTrackingFvMesh
3) New interfaceTrackingFvMesh
This commit is contained in:
Zeljko Tukovic
2019-12-03 16:49:23 +01:00
committed by Andrew Heather
parent 3a5bcde5ab
commit 79588b9b53
28 changed files with 5553 additions and 23 deletions

View File

@ -7,7 +7,8 @@ EXE_INC = \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
-I$(LIB_SRC)/dynamicFvMesh/interfaceTrackingFvMesh/lnInclude
EXE_LIBS = \
-lfiniteVolume \
@ -20,4 +21,5 @@ EXE_LIBS = \
-ldynamicMesh \
-ldynamicFvMesh \
-ltopoChangerFvMesh \
-latmosphericModels
-latmosphericModels \
-linterfaceTrackingFvMesh

View File

@ -98,6 +98,8 @@ wmake $targetType waveModels
wmake $targetType engine
conversion/Allwmake $targetType $*
phaseSystemModels/Allwmake $targetType $*
functionObjects/Allwmake $targetType $*
wmake $targetType lumpedPointMotion
@ -109,7 +111,10 @@ wmake $targetType semiPermeableBaffle
wmake $targetType atmosphericModels
wmake $targetType optimisation/adjointOptimisation/adjoint
phaseSystemModels/Allwmake $targetType $*
# interfaceTracking libs
wmake dynamicFvMesh/interfaceTrackingFvMesh
# Needs access to Turbulence

View File

@ -0,0 +1,9 @@
interfaceTrackingFvMesh.C
freeSurfacePointDisplacement.C
fvPatchFields/freeSurfacePressure/freeSurfacePressureFvPatchScalarField.C
fvPatchFields/freeSurfaceVelocity/freeSurfaceVelocityFvPatchVectorField.C
functionObjects/pointHistory/pointHistory.C
functionObjects/writeFreeSurface/writeFreeSurface.C
LIB = $(FOAM_LIBBIN)/libinterfaceTrackingFvMesh

View File

@ -0,0 +1,23 @@
EXE_INC = \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/finiteArea/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/fvMotionSolver/lnInclude
LIB_LIBS = \
-lturbulenceModels \
-lincompressibleTurbulenceModels \
-lincompressibleTransportModels \
-lfiniteVolume \
-lfiniteArea \
-lmeshTools \
-ldynamicFvMesh \
-lfvMotionSolvers \
-ldynamicMesh

View File

@ -0,0 +1,44 @@
// Boundary processor patch points
{
const labelList& curPointEdges = pointEdges[curPoint];
label patchID = -1;
label edgeID = -1;
for (const label curEdgei : curPointEdges)
{
if (edgeFaces[curEdgei].size() == 1)
{
forAll(aMesh().boundary(), patchI)
{
const labelList& curEdges = aMesh().boundary()[patchI];
label index = curEdges.find(curEdgei);
if (index != -1)
{
if
(
aMesh().boundary()[patchI].type()
!= processorFaPatch::typeName
)
{
patchID = patchI;
edgeID = index;
break;
}
}
}
}
}
if (patchID != -1)
{
vector mirrorCtrlPoint =
patchMirrorPoints[patchID][edgeID];
lsPoints[curPatchPoint].setSize(lsPoints[curPatchPoint].size() + 1);
lsPoints[curPatchPoint][lsPoints[curPatchPoint].size() - 1] =
mirrorCtrlPoint;
}
}

View File

@ -0,0 +1,623 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 Zeljko Tukovic, FSB Zagreb.
-------------------------------------------------------------------------------
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 "interfaceTrackingFvMesh.H"
#include "primitivePatchInterpolation.H"
#include "emptyFaPatch.H"
#include "wedgeFaPatch.H"
#include "wallFvPatch.H"
#include "PstreamCombineReduceOps.H"
#include "coordinateSystem.H"
#include "unitConversion.H"
#include "scalarMatrices.H"
#include "tensor2D.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::tmp<Foam::vectorField>
Foam::interfaceTrackingFvMesh::pointDisplacement()
{
const pointField& points = aMesh().patch().localPoints();
const labelListList& pointFaces = aMesh().patch().pointFaces();
auto tdisplacement = tmp<vectorField>::New(points.size(), Zero);
auto& displacement = tdisplacement.ref();
// Calculate displacement of internal points
const vectorField& pointNormals = aMesh().pointAreaNormals();
const edgeList& edges = aMesh().patch().edges();
labelList internalPoints = aMesh().internalPoints();
for (const label curPoint : internalPoints)
{
const labelList& curPointFaces = pointFaces[curPoint];
vectorField lsPoints(curPointFaces.size(), Zero);
for (label i=0; i<curPointFaces.size(); i++)
{
label curFace = curPointFaces[i];
lsPoints[i] = controlPoints()[curFace];
}
vectorField pointAndNormal
(
lsPlanePointAndNormal
(
lsPoints,
points[curPoint],
pointNormals[curPoint]
)
);
vector& P = pointAndNormal[0];
vector& N = pointAndNormal[1];
displacement[curPoint] =
pointsDisplacementDir()[curPoint]
*((P - points[curPoint])&N)
/(pointsDisplacementDir()[curPoint]&N);
}
// Mirror control points
FieldField<Field, vector> patchMirrorPoints(aMesh().boundary().size());
// Old faMesh points
vectorField oldPoints(aMesh().nPoints(), Zero);
const labelList& meshPoints = aMesh().patch().meshPoints();
forAll(oldPoints, pI)
{
oldPoints[pI] =
mesh().oldPoints()[meshPoints[pI]];
}
forAll(patchMirrorPoints, patchI)
{
patchMirrorPoints.set
(
patchI,
new vectorField
(
aMesh().boundary()[patchI].faPatch::size(),
Zero
)
);
vectorField N
(
aMesh().boundary()[patchI].ngbPolyPatchFaceNormals()
);
const labelList& eFaces =
aMesh().boundary()[patchI].edgeFaces();
// Correct N according to specified contact angle
if (contactAnglePtr_)
{
label ngbPolyPatchID =
aMesh().boundary()[patchI].ngbPolyPatchIndex();
if (ngbPolyPatchID != -1)
{
if
(
mesh().boundary()[ngbPolyPatchID].type()
== wallFvPatch::typeName
)
{
// Info<< aMesh().boundary()[patchI].name() << endl;
scalar rotAngle = degToRad
(
gAverage
(
90
- contactAnglePtr_->boundaryField()[patchI]
)
);
const vectorField& pEdgN =
aMesh().edgeAreaNormals().boundaryField()[patchI];
vectorField rotationAxis( N^pEdgN );
const edgeList::subList patchEdges =
aMesh().boundary()[patchI].patchSlice(aMesh().edges());
forAll(rotationAxis, edgeI)
{
vector e = patchEdges[edgeI].vec(oldPoints);
// vector e = patchEdges[edgeI].vec(aMesh().points());
// Adjust direction
rotationAxis[edgeI] =
e*(e&rotationAxis[edgeI])
/mag((e&rotationAxis[edgeI]));
}
rotationAxis /= mag(rotationAxis) + SMALL;
vectorField rotationAxis2 = rotationAxis;
forAll(rotationAxis2, edgeI)
{
rotationAxis2[edgeI] =
(N[edgeI]^facesDisplacementDir()[eFaces[edgeI]]);
// Adjust direction
rotationAxis2[edgeI] =
rotationAxis2[edgeI]
*(rotationAxis2[edgeI]&rotationAxis[edgeI])
/(
mag((rotationAxis2[edgeI]&rotationAxis[edgeI]))
+ SMALL
);
}
rotationAxis2 /= mag(rotationAxis2) + SMALL;
// Rodrigues' rotation formula
N = N*cos(rotAngle)
+ rotationAxis*(rotationAxis & N)*(1 - cos(rotAngle))
+ (rotationAxis^N)*sin(rotAngle);
N /= mag(N) + SMALL;
N = (rotationAxis^N);
N = (N^rotationAxis2);
N /= mag(N) + SMALL;
// Info<< N << endl;
}
}
}
const labelList peFaces =
labelList::subList
(
aMesh().edgeOwner(),
aMesh().boundary()[patchI].faPatch::size(),
aMesh().boundary()[patchI].start()
);
const labelList& pEdges = aMesh().boundary()[patchI];
vectorField peCentres(pEdges.size(), Zero);
forAll(peCentres, edgeI)
{
peCentres[edgeI] =
edges[pEdges[edgeI]].centre(points);
}
vectorField delta
(
vectorField(controlPoints(), peFaces)
- peCentres
);
// Info<< aMesh().boundary()[patchI].name() << endl;
// Info<< vectorField(controlPoints(), peFaces) << endl;
patchMirrorPoints[patchI] =
peCentres + ((I - 2*N*N)&delta);
// Info<< patchMirrorPoints[patchI] << endl;
}
// Calculate displacement of boundary points
labelList boundaryPoints = aMesh().boundaryPoints();
const labelListList& edgeFaces = aMesh().patch().edgeFaces();
const labelListList& pointEdges = aMesh().patch().pointEdges();
for (const label curPoint : boundaryPoints)
{
if (motionPointsMask()[curPoint] == 1)
{
// Calculating mirror points
const labelList& curPointEdges = pointEdges[curPoint];
vectorField mirrorPoints(2, Zero);
label counter = -1;
forAll(curPointEdges, edgeI)
{
label curEdge = curPointEdges[edgeI];
if(edgeFaces[curEdge].size() == 1)
{
label patchID = -1;
label edgeID = -1;
forAll(aMesh().boundary(), patchI)
{
const labelList& pEdges =
aMesh().boundary()[patchI];
label index = pEdges.find(curEdge);
if (index != -1)
{
patchID = patchI;
edgeID = index;
break;
}
}
mirrorPoints[++counter] =
patchMirrorPoints[patchID][edgeID];
}
}
// Calculating LS plane fit
const labelList& curPointFaces = pointFaces[curPoint];
vectorField lsPoints
(
curPointFaces.size() + mirrorPoints.size(),
Zero
);
counter = -1;
for (label i=0; i<curPointFaces.size(); i++)
{
label curFace = curPointFaces[i];
lsPoints[++counter] = controlPoints()[curFace];
}
for (label i=0; i<mirrorPoints.size(); i++)
{
lsPoints[++counter] = mirrorPoints[i];
}
vectorField pointAndNormal
(
lsPlanePointAndNormal
(
lsPoints,
points[curPoint],
pointNormals[curPoint]
)
);
vector& P = pointAndNormal[0];
vector& N = pointAndNormal[1];
displacement[curPoint] =
pointsDisplacementDir()[curPoint]
*((P - points[curPoint])&N)
/(pointsDisplacementDir()[curPoint]&N);
}
}
// Calculate displacement of processor patch points
forAll (aMesh().boundary(), patchI)
{
if
(
aMesh().boundary()[patchI].type()
== processorFaPatch::typeName
)
{
const processorFaPatch& procPatch =
refCast<const processorFaPatch>(aMesh().boundary()[patchI]);
const labelList& patchPointLabels =
procPatch.pointLabels();
FieldField<Field, vector> lsPoints(patchPointLabels.size());
forAll(lsPoints, pointI)
{
lsPoints.set(pointI, new vectorField(0, Zero));
}
const labelList& nonGlobalPatchPoints =
procPatch.nonGlobalPatchPoints();
forAll(nonGlobalPatchPoints, pointI)
{
label curPatchPoint =
nonGlobalPatchPoints[pointI];
label curPoint =
patchPointLabels[curPatchPoint];
const labelList& curPointFaces = pointFaces[curPoint];
lsPoints[curPatchPoint].setSize(curPointFaces.size());
forAll(curPointFaces, faceI)
{
label curFace = curPointFaces[faceI];
lsPoints[curPatchPoint][faceI] = controlPoints()[curFace];
}
#include "boundaryProcessorFaPatchPoints.H"
}
// Parallel data exchange
{
OPstream toNeighbProc
(
Pstream::commsTypes::blocking,
procPatch.neighbProcNo()
);
toNeighbProc << lsPoints;
}
FieldField<Field, vector> ngbLsPoints(patchPointLabels.size());
{
IPstream fromNeighbProc
(
Pstream::commsTypes::blocking,
procPatch.neighbProcNo()
);
fromNeighbProc >> ngbLsPoints;
}
forAll(nonGlobalPatchPoints, pointI)
{
label curPatchPoint =
nonGlobalPatchPoints[pointI];
label curPoint =
patchPointLabels[curPatchPoint];
label curNgbPoint = procPatch.neighbPoints()[curPatchPoint];
vectorField allLsPoints
(
lsPoints[curPatchPoint].size()
+ ngbLsPoints[curNgbPoint].size(),
Zero
);
label counter = -1;
forAll(lsPoints[curPatchPoint], pointI)
{
allLsPoints[++counter] = lsPoints[curPatchPoint][pointI];
}
forAll(ngbLsPoints[curNgbPoint], pointI)
{
allLsPoints[++counter] = ngbLsPoints[curNgbPoint][pointI];
}
vectorField pointAndNormal
(
lsPlanePointAndNormal
(
allLsPoints,
points[curPoint],
pointNormals[curPoint]
)
);
vector& P = pointAndNormal[0];
vector& N = pointAndNormal[1];
if (motionPointsMask()[curPoint] != 0)
{
displacement[curPoint] =
pointsDisplacementDir()[curPoint]
*((P - points[curPoint])&N)
/(pointsDisplacementDir()[curPoint]&N);
}
}
}
}
// Calculate displacement of global processor patch points
if (aMesh().globalData().nGlobalPoints() > 0)
{
const labelList& spLabels =
aMesh().globalData().sharedPointLabels();
const labelList& addr = aMesh().globalData().sharedPointAddr();
for (label k=0; k<aMesh().globalData().nGlobalPoints(); k++)
{
List<List<vector> > procLsPoints(Pstream::nProcs());
label curSharedPointIndex = addr.find(k);
if (curSharedPointIndex != -1)
{
label curPoint = spLabels[curSharedPointIndex];
const labelList& curPointFaces = pointFaces[curPoint];
procLsPoints[Pstream::myProcNo()] =
List<vector>(curPointFaces.size());
forAll(curPointFaces, faceI)
{
label curFace = curPointFaces[faceI];
procLsPoints[Pstream::myProcNo()][faceI] =
controlPoints()[curFace];
}
}
Pstream::gatherList(procLsPoints);
Pstream::scatterList(procLsPoints);
if (curSharedPointIndex != -1)
{
label curPoint = spLabels[curSharedPointIndex];
label nAllPoints = 0;
forAll(procLsPoints, procI)
{
nAllPoints += procLsPoints[procI].size();
}
vectorField allPoints(nAllPoints, Zero);
label counter = 0;
forAll(procLsPoints, procI)
{
forAll(procLsPoints[procI], pointI)
{
allPoints[counter++] =
procLsPoints[procI][pointI];
}
}
vectorField pointAndNormal
(
lsPlanePointAndNormal
(
allPoints,
points[curPoint],
pointNormals[curPoint]
)
);
const vector& P = pointAndNormal[0];
const vector& N = pointAndNormal[1];
displacement[curPoint] =
pointsDisplacementDir()[curPoint]
*((P - points[curPoint])&N)
/(pointsDisplacementDir()[curPoint]&N);
}
}
}
return tdisplacement;
}
Foam::tmp<Foam::vectorField>
Foam::interfaceTrackingFvMesh::lsPlanePointAndNormal
(
const vectorField& points,
const vector& origin,
const vector& axis
) const
{
// LS in local CS
vector dir = (points[0] - origin);
dir -= axis*(axis&dir);
dir /= mag(dir);
coordinateSystem cs("cs", origin, axis, dir);
vectorField localPoints(cs.localPosition(points));
vector avgLocalPoint = average(localPoints);
// scalarField W = 1.0/(mag(points - origin) + SMALL);
scalarField W(points.size(), scalar(1));
const label nCoeffs = 2;
scalarRectangularMatrix M(points.size(), nCoeffs, Zero);
scalar L = 2*max(mag(localPoints-avgLocalPoint));
for (label i=0; i<localPoints.size(); i++)
{
M[i][0] = (localPoints[i].x() - avgLocalPoint.x())/L;
M[i][1] = (localPoints[i].y() - avgLocalPoint.y())/L;
}
// Applying weights
for (label i=0; i<M.n(); i++)
{
for (label j=0; j<M.m(); j++)
{
M[i][j] *= W[i];
}
}
tensor2D lsM(Zero);
// scalarSquareMatrix lsM(nCoeffs, Zero);
for (label i=0; i<nCoeffs; i++)
{
for (label j=0; j<nCoeffs; j++)
{
for (label k=0; k<M.n(); k++)
{
lsM[i*nCoeffs+j] += M[k][i]*M[k][j];
// lsM(i,j) += M[k][i]*M[k][j];
}
}
}
// Calculate inverse
tensor2D invLsM = inv(lsM);
scalarRectangularMatrix curInvMatrix(nCoeffs, points.size(), Zero);
for (label i=0; i<nCoeffs; i++)
{
for (label j=0; j<M.n(); j++)
{
for (label k=0; k<nCoeffs; k++)
{
curInvMatrix[i][j] += invLsM[i*nCoeffs+k]*M[j][k]*W[j];
// curInvMatrix[i][j] += invLsM[i][k]*M[j][k]*W[j];
}
}
}
scalarField coeffs(nCoeffs, Zero);
scalarField source(points.size(), Zero);
for (label i=0; i<points.size(); i++)
{
source[i] = (localPoints[i].z() - avgLocalPoint.z())/L;
}
for (label i=0; i<nCoeffs; i++)
{
for (label j=0; j<source.size(); j++)
{
coeffs[i] += curInvMatrix[i][j]*source[j];
}
}
vector n0(-coeffs[0], -coeffs[1], 1.0);
n0 = cs.globalVector(n0);
n0 /= mag(n0);
vector p0 = avgLocalPoint;
p0 = cs.globalPosition(p0);
auto tpointAndNormal = tmp<vectorField>::New(2);
auto& pointAndNormal = tpointAndNormal.ref();
pointAndNormal[0] = p0;
pointAndNormal[1] = n0;
return tpointAndNormal;
}
// ************************************************************************* //

View File

@ -0,0 +1,215 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 Zeljko Tukovic, FSB Zagreb.
-------------------------------------------------------------------------------
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 "pointHistory.H"
#include "addToRunTimeSelectionTable.H"
#include "IOmanip.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(pointHistory, 0);
addToRunTimeSelectionTable
(
functionObject,
pointHistory,
dictionary
);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
bool Foam::pointHistory::writeData()
{
const fvMesh& mesh =
time_.lookupObject<fvMesh>(polyMesh::defaultRegion);
vector position(Zero);
if (processor_ == Pstream::myProcNo())
{
position = mesh.points()[historyPointID_];
}
reduce(position, sumOp<vector>());
if (Pstream::master())
{
historyFilePtr_() << setprecision(12);
historyFilePtr_()
<< time_.time().value() << tab
<< position.x() << tab
<< position.y() << tab
<< position.z() << endl;
}
return true;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::pointHistory::pointHistory
(
const word& name,
const Time& runTime,
const dictionary& dict
)
:
functionObject(name),
name_(name),
time_(runTime),
regionName_(polyMesh::defaultRegion),
historyPointID_(-1),
refHistoryPoint_(dict.lookup("refHistoryPoint")),
processor_(-1),
fileName_(dict.get<word>("fileName")),
historyFilePtr_()
{
Info<< "Creating " << this->name() << " function object." << endl;
dict.readIfPresent("region", regionName_);
dict.readIfPresent("historyPointID", historyPointID_);
const fvMesh& mesh =
time_.lookupObject<fvMesh>(regionName_);
const vectorField& points = mesh.points();
List<scalar> minDist(Pstream::nProcs(), GREAT);
if (historyPointID_ == -1)
{
forAll(points, pointI)
{
scalar dist = mag(refHistoryPoint_ - points[pointI]);
if (dist < minDist[Pstream::myProcNo()])
{
minDist[Pstream::myProcNo()] = dist;
historyPointID_ = pointI;
}
}
}
Pstream::gatherList(minDist);
Pstream::scatterList(minDist);
processor_ = -1;
scalar min = GREAT;
forAll(minDist, procI)
{
if (minDist[procI] < min)
{
min = minDist[procI];
processor_ = procI;
}
}
if (processor_ == Pstream::myProcNo())
{
Pout<< "History point ID: " << historyPointID_ << nl
<< "History point coordinates: "
<< points[historyPointID_] << nl
<< "Reference point coordinates: " << refHistoryPoint_
<< endl;
}
// Create history file if not already created
if (historyFilePtr_.empty())
{
// File update
if (Pstream::master())
{
fileName historyDir;
word startTimeName =
time_.timeName(mesh.time().startTime().value());
if (Pstream::parRun())
{
// Put in undecomposed case (Note: gives problems for
// distributed data running)
historyDir = time_.path()/".."/"history"/startTimeName;
}
else
{
historyDir = time_.path()/"history"/startTimeName;
}
// Create directory if does not exist.
mkDir(historyDir);
// Open new file at start up
// OStringStream FileName;
// FileName() << "point_" << historyPointID_ << ".dat";
historyFilePtr_.reset
(
new OFstream(historyDir/fileName_)
);
// Add headers to output data
if (historyFilePtr_.valid())
{
historyFilePtr_()
<< "# Time" << tab << "X" << tab
<< "Y" << tab << "Z";
historyFilePtr_() << endl;
}
}
}
// Write start time data
writeData();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::pointHistory::execute()
{
return writeData();
}
bool Foam::pointHistory::read(const dictionary& dict)
{
dict.readIfPresent("region", regionName_);
return true;
}
// ************************************************************************* //

View File

@ -0,0 +1,135 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 Zeljko Tukovic, FSB Zagreb.
-------------------------------------------------------------------------------
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::pointHistory
Description
SourceFiles
pointHistory.C
\*---------------------------------------------------------------------------*/
#ifndef pointHistory_H
#define pointHistory_H
#include "functionObject.H"
#include "dictionary.H"
#include "fvMesh.H"
#include "OFstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class pointHistory Declaration
\*---------------------------------------------------------------------------*/
class pointHistory
:
public functionObject
{
// Private Data
//- Name
const word name_;
//- Reference to main object registry
const Time& time_;
//- Region name
word regionName_;
//- History point ID
label historyPointID_;
//- History point
vector refHistoryPoint_;
//- Processor of history point
label processor_;
//- Output file name
word fileName_;
//- Output file stream
autoPtr<OFstream> historyFilePtr_;
// Private Member Functions
//- Write data
bool writeData();
//- No copy construct
pointHistory(const pointHistory&) = delete;
//- No copy assignment
void operator=(const pointHistory&) = delete;
public:
//- Runtime type information
TypeName("pointHistory");
// Constructors
//- Construct from components
pointHistory
(
const word& name,
const Time& runTime,
const dictionary&
);
// Member Functions
//- execute is called at each ++ or += of the time-loop
virtual bool execute();
//- Read and set the function object if its data has changed
virtual bool read(const dictionary& dict);
//- No-op
virtual bool write()
{
return true;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,114 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 Zeljko Tukovic, FSB Zagreb.
-------------------------------------------------------------------------------
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 "writeFreeSurface.H"
#include "addToRunTimeSelectionTable.H"
#include "IOmanip.H"
#include "interfaceTrackingFvMesh.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(writeFreeSurface, 0);
addToRunTimeSelectionTable
(
functionObject,
writeFreeSurface,
dictionary
);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
bool Foam::writeFreeSurface::writeData()
{
if (time_.outputTime())
{
const fvMesh& mesh =
time_.lookupObject<fvMesh>(polyMesh::defaultRegion);
interfaceTrackingFvMesh& itm =
refCast<interfaceTrackingFvMesh>
(
const_cast<dynamicFvMesh&>
(
mesh.lookupObject<dynamicFvMesh>("fvSolution")
)
);
itm.writeVTKControlPoints();
}
return true;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::writeFreeSurface::writeFreeSurface
(
const word& name,
const Time& runTime,
const dictionary& dict
)
:
functionObject(name),
name_(name),
time_(runTime),
regionName_(polyMesh::defaultRegion)
{
Info<< "Creating " << this->name() << " function object." << endl;
dict.readIfPresent("region", regionName_);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::writeFreeSurface::start()
{
return writeData();
}
bool Foam::writeFreeSurface::execute()
{
return writeData();
}
bool Foam::writeFreeSurface::read(const dictionary& dict)
{
dict.readIfPresent("region", regionName_);
return true;
}
// ************************************************************************* //

View File

@ -0,0 +1,125 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 Zeljko Tukovic, FSB Zagreb.
-------------------------------------------------------------------------------
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::writeFreeSurface
Description
A function object to write the control points on the free surface
SourceFiles
writeFreeSurface.C
\*---------------------------------------------------------------------------*/
#ifndef writeFreeSurface_H
#define writeFreeSurface_H
#include "functionObject.H"
#include "dictionary.H"
#include "fvMesh.H"
#include "OFstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class writeFreeSurface Declaration
\*---------------------------------------------------------------------------*/
class writeFreeSurface
:
public functionObject
{
// Private Data
//- Name
const word name_;
//- Reference to main object registry
const Time& time_;
//- Region name
word regionName_;
// Private Member Functions
//- Write data
bool writeData();
//- No copy construct
writeFreeSurface(const writeFreeSurface&) = delete;
//- No copy assignment
void operator=(const writeFreeSurface&) = delete;
public:
//- Runtime type information
TypeName("writeFreeSurface");
// Constructors
//- Construct from components
writeFreeSurface
(
const word& name,
const Time& runTime,
const dictionary& dict
);
// Member Functions
//- start is called at the start of the time-loop
virtual bool start();
//- execute is called at each ++ or += of the time-loop
virtual bool execute();
//- Read and set the function object if its data has changed
virtual bool read(const dictionary& dict);
//- No-op
virtual bool write()
{
return true;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,188 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2019 Zeljko Tukovic, FSB Zagreb.
-------------------------------------------------------------------------------
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 "freeSurfacePressureFvPatchScalarField.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "gravityMeshObject.H"
#include "turbulentTransportModel.H"
#include "interfaceTrackingFvMesh.H"
#include "singlePhaseTransportModel.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::freeSurfacePressureFvPatchScalarField::
freeSurfacePressureFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(p, iF),
pa_(p.size(), Zero)
{}
Foam::freeSurfacePressureFvPatchScalarField::
freeSurfacePressureFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
fixedValueFvPatchScalarField(p, iF, dict, false),
pa_("pa", dict, p.size())
{
if (dict.found("value"))
{
fvPatchScalarField::operator=
(
scalarField("value", dict, p.size())
);
}
else
{
fvPatchField<scalar>::operator=(pa_);
}
}
Foam::freeSurfacePressureFvPatchScalarField::
freeSurfacePressureFvPatchScalarField
(
const freeSurfacePressureFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchScalarField(ptf, p, iF, mapper),
pa_(ptf.pa_, mapper)
{}
Foam::freeSurfacePressureFvPatchScalarField::
freeSurfacePressureFvPatchScalarField
(
const freeSurfacePressureFvPatchScalarField& ptf
)
:
fixedValueFvPatchScalarField(ptf),
pa_(ptf.pa_)
{}
Foam::freeSurfacePressureFvPatchScalarField::
freeSurfacePressureFvPatchScalarField
(
const freeSurfacePressureFvPatchScalarField& ptf,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(ptf, iF),
pa_(ptf.pa_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::freeSurfacePressureFvPatchScalarField::autoMap
(
const fvPatchFieldMapper& m
)
{
fixedValueFvPatchScalarField::autoMap(m);
pa_.autoMap(m);
}
void Foam::freeSurfacePressureFvPatchScalarField::rmap
(
const fvPatchScalarField& ptf,
const labelList& addr
)
{
fixedValueFvPatchScalarField::rmap(ptf, addr);
const freeSurfacePressureFvPatchScalarField& tiptf =
refCast<const freeSurfacePressureFvPatchScalarField>(ptf);
pa_.rmap(tiptf.pa_, addr);
}
void Foam::freeSurfacePressureFvPatchScalarField::updateCoeffs()
{
if (updated())
{
return;
}
const fvMesh& mesh = patch().boundaryMesh().mesh();
interfaceTrackingFvMesh& itm =
refCast<interfaceTrackingFvMesh>
(
const_cast<dynamicFvMesh&>
(
mesh.lookupObject<dynamicFvMesh>("fvSolution")
)
);
operator==
(
pa_ + itm.freeSurfacePressureJump()
);
fixedValueFvPatchScalarField::updateCoeffs();
}
void Foam::freeSurfacePressureFvPatchScalarField::write(Ostream& os) const
{
fvPatchScalarField::write(os);
pa_.writeEntry("pa", os);
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makePatchTypeField
(
fvPatchScalarField,
freeSurfacePressureFvPatchScalarField
);
}
// ************************************************************************* //

View File

@ -0,0 +1,217 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2019 Zeljko Tukovic, FSB Zagreb.
-------------------------------------------------------------------------------
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::freeSurfacePressureFvPatchScalarField
Group
grpGenericBoundaryConditions
Description
This boundary condition provides static pressure condition for p_rgh,
calculated as:
\f[
p = pa - \vec{g} & \vec{r}
\f]
where
\vartable
p | Free surface modified pressure
pa | Free surface ambient pressure
g | acceleration due to gravity [m/s^2]
\endtable
Usage
\table
Property | Description | Required | Default value
pa | static ambient pressure | yes | 0
\endtable
Example of the boundary condition specification:
\verbatim
<patchName>
{
type freeSurfacePressure;
pa uniform 0;
value uniform 0; // optional initial value
}
\endverbatim
See also
Foam::fixedValueFvPatchScalarField
SourceFiles
freeSurfacePressureFvPatchScalarField.C
\*---------------------------------------------------------------------------*/
#ifndef freeSurfacePressureFvPatchScalarField_H
#define freeSurfacePressureFvPatchScalarField_H
#include "fixedValueFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class freeSurfacePressureFvPatchScalarField Declaration
\*---------------------------------------------------------------------------*/
class freeSurfacePressureFvPatchScalarField
:
public fixedValueFvPatchScalarField
{
protected:
// Protected data
//- Ambient pressure
scalarField pa_;
public:
//- Runtime type information
TypeName("freeSurfacePressure");
// Constructors
//- Construct from patch and internal field
freeSurfacePressureFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
freeSurfacePressureFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given
// freeSurfacePressureFvPatchScalarField onto a new patch
freeSurfacePressureFvPatchScalarField
(
const freeSurfacePressureFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
freeSurfacePressureFvPatchScalarField
(
const freeSurfacePressureFvPatchScalarField&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField >
(
new freeSurfacePressureFvPatchScalarField(*this)
);
}
//- Construct as copy setting internal field reference
freeSurfacePressureFvPatchScalarField
(
const freeSurfacePressureFvPatchScalarField&,
const DimensionedField<scalar, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return tmp<fvPatchScalarField>
(
new freeSurfacePressureFvPatchScalarField(*this, iF)
);
}
// Member functions
// Access
//- Return the ambient pressure
const scalarField& pa() const
{
return pa_;
}
//- Return reference to the ambient pressure to allow adjustment
scalarField& pa()
{
return pa_;
}
// Mapping functions
//- Map (and resize as needed) from self given a mapping object
virtual void autoMap
(
const fvPatchFieldMapper&
);
//- Reverse map the given fvPatchField onto this fvPatchField
virtual void rmap
(
const fvPatchScalarField&,
const labelList&
);
// Evaluation functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,131 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 Zeljko Tukovic, FSB Zagreb.
-------------------------------------------------------------------------------
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 "freeSurfaceVelocityFvPatchVectorField.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "surfaceFields.H"
#include "interfaceTrackingFvMesh.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::freeSurfaceVelocityFvPatchVectorField::
freeSurfaceVelocityFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF
)
:
fixedGradientFvPatchVectorField(p, iF)
{}
Foam::freeSurfaceVelocityFvPatchVectorField::
freeSurfaceVelocityFvPatchVectorField
(
const freeSurfaceVelocityFvPatchVectorField& ptf,
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedGradientFvPatchVectorField(ptf, p, iF, mapper)
{}
Foam::freeSurfaceVelocityFvPatchVectorField::
freeSurfaceVelocityFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const dictionary& dict
)
:
fixedGradientFvPatchVectorField(p, iF)
{
patchType() = dict.lookupOrDefault<word>("patchType", word::null);
fvPatchVectorField::operator=(patchInternalField());
}
Foam::freeSurfaceVelocityFvPatchVectorField::
freeSurfaceVelocityFvPatchVectorField
(
const freeSurfaceVelocityFvPatchVectorField& fcvpvf,
const DimensionedField<vector, volMesh>& iF
)
:
fixedGradientFvPatchVectorField(fcvpvf, iF)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::freeSurfaceVelocityFvPatchVectorField::updateCoeffs()
{
if (updated())
{
return;
}
const fvMesh& mesh = patch().boundaryMesh().mesh();
interfaceTrackingFvMesh& itm =
refCast<interfaceTrackingFvMesh>
(
const_cast<dynamicFvMesh&>
(
mesh.lookupObject<dynamicFvMesh>("fvSolution")
)
);
gradient() = itm.freeSurfaceSnGradU();
fixedGradientFvPatchVectorField::updateCoeffs();
}
void Foam::freeSurfaceVelocityFvPatchVectorField::write(Ostream& os) const
{
fixedGradientFvPatchVectorField::write(os);
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makePatchTypeField
(
fvPatchVectorField,
freeSurfaceVelocityFvPatchVectorField
);
}
// ************************************************************************* //

View File

@ -0,0 +1,140 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 Zeljko Tukovic, FSB Zagreb.
-------------------------------------------------------------------------------
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::freeSurfaceVelocityFvPatchVectorField
Group
grpOutletBoundaryConditions
Description
This boundary condition provides a velocity outlet boundary condition for
free surface patches.
SourceFiles
freeSurfaceVelocityFvPatchVectorField.C
\*---------------------------------------------------------------------------*/
#ifndef freeSurfaceVelocityFvPatchVectorField_H
#define freeSurfaceVelocityFvPatchVectorField_H
#include "fvPatchFields.H"
#include "fixedGradientFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class freeSurfaceVelocityFvPatchVectorField Declaration
\*---------------------------------------------------------------------------*/
class freeSurfaceVelocityFvPatchVectorField
:
public fixedGradientFvPatchVectorField
{
public:
//- Runtime type information
TypeName("freeSurfaceVelocity");
// Constructors
//- Construct from patch and internal field
freeSurfaceVelocityFvPatchVectorField
(
const fvPatch&,
const DimensionedField<vector, volMesh>&
);
//- Construct from patch, internal field and dictionary
freeSurfaceVelocityFvPatchVectorField
(
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const dictionary&
);
//- Construct by mapping given freeSurfaceVelocityFvPatchVectorField
// onto a new patch
freeSurfaceVelocityFvPatchVectorField
(
const freeSurfaceVelocityFvPatchVectorField&,
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct and return a clone
virtual tmp<fvPatchVectorField> clone() const
{
return tmp<fvPatchVectorField>
(
new freeSurfaceVelocityFvPatchVectorField(*this)
);
}
//- Construct as copy setting internal field reference
freeSurfaceVelocityFvPatchVectorField
(
const freeSurfaceVelocityFvPatchVectorField&,
const DimensionedField<vector, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchVectorField> clone
(
const DimensionedField<vector, volMesh>& iF
) const
{
return tmp<fvPatchVectorField>
(
new freeSurfaceVelocityFvPatchVectorField(*this, iF)
);
}
// Member functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,442 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 Zeljko Tukovic, FSB Zagreb.
-------------------------------------------------------------------------------
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::interfaceTrackingFvMesh
Description
The interfaceTrackingFvMesh
SourceFiles
interfaceTrackingFvMesh.C
\*---------------------------------------------------------------------------*/
#ifndef interfaceTrackingFvMesh_H
#define interfaceTrackingFvMesh_H
#include "dynamicMotionSolverFvMesh.H"
#include "regIOobject.H"
#include "faCFD.H"
#include "volFields.H"
#include "surfaceFields.H"
#include "surfactantProperties.H"
#include "singlePhaseTransportModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class interfaceTrackingFvMesh Declaration
\*---------------------------------------------------------------------------*/
class interfaceTrackingFvMesh
:
public dynamicMotionSolverFvMesh
{
// Private Data
//- Finite area mesh
autoPtr<faMesh> aMeshPtr_;
//- Free surface patch index
label fsPatchIndex_;
//- Free surface faPatch-es which do not move
wordList fixedFreeSurfacePatches_;
//- Free surface faPatch-es where wave shuld not reflect
wordList nonReflectingFreeSurfacePatches_;
//- Free surface patches for which point normals must be corrected
wordList pointNormalsCorrectionPatches_;
//- Is it free-surface points displacement direction
// parallel with free-surface point normals
Switch normalMotionDir_;
//- Free-surface points displacement direction
// if not normal motion direction
vector motionDir_;
//- Interface smoothing at the begining of time step
Switch smoothing_;
//- Pure free-surface
Switch pureFreeSurface_;
//- Rigid free-surface
Switch rigidFreeSurface_;
//- Correct contact line point normals
Switch correctContactLineNormals_;
//- Surface tension coefficient of pure free-surface
dimensionedScalar sigma0_;
//- Fluid density
dimensionedScalar rho_;
//- Current interface tracking time index
label timeIndex_;
//- Free-surface velocity field
mutable areaVectorField* UsPtr_;
//- Points which are attached to the free-surface A side faces
// and which defines the free-surface shape
mutable vectorIOField* controlPointsPtr_;
//- Field which additionally determines
// the motion of free-surface points
mutable labelList* motionPointsMaskPtr_;
//- Displacement direction of free-surface points
mutable vectorField* pointsDisplacementDirPtr_;
//- Displacement direction of free-surface control points
mutable vectorField* facesDisplacementDirPtr_;
//- Free-surface net flux
mutable areaScalarField* fsNetPhiPtr_;
//- Free-surface flux
mutable edgeScalarField* phisPtr_;
//- Free-surface surfactant concetration
mutable areaScalarField* surfactConcPtr_;
//- Volume surfactant concetration
mutable volScalarField* bulkSurfactConcPtr_;
//- Surface tension field
mutable areaScalarField* surfaceTensionPtr_;
//- Surfactant properties
mutable surfactantProperties* surfactantPtr_;
//- Contact angle
mutable areaScalarField* contactAnglePtr_;
// Private Member Functions
// Make demand-driven data
//- Create free surface velocity field
void makeUs() const;
//- Create control points
void makeControlPoints();
//- Create motion points mask
void makeMotionPointsMask();
//- Create points and control point motion direction
void makeDirections();
//- Create free surface net flux
void makeFsNetPhi() const;
//- Create free-surface flux
void makePhis();
//- Create surfactant volume concentration field
void makeBulkSurfactConc() const;
//- Create surfactant concentration field
void makeSurfactConc() const;
//- Create surface tension field
void makeSurfaceTension() const;
//- Create surfactant properties
void makeSurfactant() const;
//- Create contact angle
void makeContactAngle();
//- No copy construct
interfaceTrackingFvMesh(const interfaceTrackingFvMesh&) = delete;
//- No copy assignment
void operator=(const interfaceTrackingFvMesh&) = delete;
//- Initialize data
void initializeData();
//- Update control points end displacement directions
void updateDisplacementDirections();
//- Initialize control points position
void initializeControlPointsPosition();
//- Calculate free surface points displacement
// for given new control points position
tmp<vectorField> pointDisplacement();
//- Calc least sqare plane point and normal
tmp<vectorField> lsPlanePointAndNormal
(
const vectorField& points,
const vector& origin,
const vector& axis
) const;
//- Smooth free-surface mesh
void smoothFreeSurfaceMesh();
//- Update free-surface flux
void updateSurfaceFlux();
//- Update free-surface surfactant concentration
void updateSurfactantConcentration();
//- Calculate total pressure force
vector totalPressureForce() const;
//- Calculate total viscous force
vector totalViscousForce() const;
//- Calculate total surface tension force
vector totalSurfaceTensionForce() const;
//- Maximal surface tension based Courant number
scalar maxCourantNumber();
//- Update properties
void updateProperties();
//- Correct free surface point normals at contact line
void correctContactLinePointNormals();
//- Correct free surface point displacement next to fixed contact line
void correctPointDisplacement
(
const scalarField& sweptVolCorr,
vectorField& displacement
);
public:
//- Runtime type information
TypeName("interfaceTrackingFvMesh");
// Constructors
//- Construct from IOobject
interfaceTrackingFvMesh(const IOobject& io);
//- Construct from components without boundary.
// Boundary is added using addFvPatches() member function
interfaceTrackingFvMesh
(
const IOobject& io,
pointField&& points,
faceList&& faces,
labelList&& allOwner,
labelList&& allNeighbour,
const bool syncPar = true
);
//- Destructor
~interfaceTrackingFvMesh();
// Member Functions
fvMesh& mesh()
{
return *this;
}
const fvMesh& mesh() const
{
return *this;
}
//- Return reference to finite area mesh
faMesh& aMesh()
{
return aMeshPtr_();
}
//- Return reference to finite area mesh
const faMesh& aMesh() const
{
return aMeshPtr_();
}
const label& fsPatchIndex() const
{
return fsPatchIndex_;
}
//- Pure free-surface
const Switch& pureFreeSurface() const
{
return pureFreeSurface_;
}
//- Rigid free-surface
const Switch& rigidFreeSurface() const
{
return rigidFreeSurface_;
}
//- Rigid free-surface
Switch& rigidFreeSurface()
{
return rigidFreeSurface_;
}
//- Correct contact line point normals
const Switch& correctContactLineNormals() const
{
return correctContactLineNormals_;
}
//- Correct contact line point normals
Switch& correctContactLineNormals()
{
return correctContactLineNormals_;
}
//- Surface tension coefficient of pure free-surface
const dimensionedScalar& sigma() const
{
return sigma0_;
}
//- Return free-surface velocity field
areaVectorField& Us();
//- Return free-surface velocity field
const areaVectorField& Us() const;
//- Return free-surface net flux
const areaScalarField& fsNetPhi() const;
//- Return free-surface net flux
areaScalarField& fsNetPhi();
//- Correct surface velocity boundary conditions
void correctUsBoundaryConditions();
//- Update free-surface velocity field
void updateUs();
//- Return constant reference to velocity field
const volVectorField& U() const;
//- Return constant reference to pressure field
const volScalarField& p() const;
//- Return constant reference to velocity field
const surfaceScalarField& phi() const;
//- Return free surface normal derivative of velocity
tmp<vectorField> freeSurfaceSnGradU();
//- Return free surface normal derivative of normal velocity comp
tmp<scalarField> freeSurfaceSnGradUn();
//- Return free surface pressure jump
tmp<scalarField> freeSurfacePressureJump();
//- Return control points
vectorField& controlPoints();
//- Return reference to motion points mask field
labelList& motionPointsMask();
//- Return reference to point displacement direction field
vectorField& pointsDisplacementDir();
//- Return reference to control points displacement direction field
vectorField& facesDisplacementDir();
//- Motion direction swithc
bool normalMotionDir() const
{
return normalMotionDir_;
}
//- Return free-surface fluid flux field
edgeScalarField& Phis();
//- Return free-surface surfactant concentration field
areaScalarField& surfactantConcentration();
//- Return free-surface surfactant concentration field
const areaScalarField& surfactantConcentration() const;
//- Return volume surfactant concentration field
volScalarField& bulkSurfactantConcentration();
//- Return volume surfactant concentration field
const volScalarField& bulkSurfactantConcentration() const;
//- Return surface tension field
areaScalarField& surfaceTension();
//- Return surface tension field
const areaScalarField& surfaceTension() const;
//- Return surface tension gradient
tmp<areaVectorField> surfaceTensionGrad();
//- Return surfactant properties
const surfactantProperties& surfactant() const;
//- Update the mesh for both mesh motion and topology change
virtual bool update();
//- Clear control points
void clearControlPoints()
{
deleteDemandDrivenData(controlPointsPtr_);
}
//- Write VTK freeSurface mesh
void writeVTK() const;
//- Write VTK freeSurface control points
void writeVTKControlPoints();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,46 @@
{
volScalarField& C = bulkSurfactantConcentration();
const dimensionedScalar& D = surfactant().bulkDiffusion();
scalar ka = surfactant().adsorptionCoeff().value();
scalar kb = surfactant().desorptionCoeff().value();
scalar CsInf = surfactant().saturatedConc().value();
const scalarField& Cs =
surfactantConcentration().internalField();
// const scalarField& Cfs = C.boundaryField()[fsPatchIndex()];
if
(
C.boundaryField()[fsPatchIndex()].type()
== fixedGradientFvPatchScalarField::typeName
)
{
fixedGradientFvPatchScalarField& fsC =
refCast<fixedGradientFvPatchScalarField>
(
C.boundaryFieldRef()[fsPatchIndex()]
);
fsC.gradient() = (ka*kb*Cs - ka*(CsInf-Cs)*fsC)/D.value();
}
else
{
FatalErrorInFunction
<< "Bulk concentration boundary condition "
<< "at the free-surface patch is not "
<< fixedGradientFvPatchScalarField::typeName
<< exit(FatalError);
}
fvScalarMatrix CEqn
(
fvm::ddt(C)
+ fvm::div(phi(), C, "div(phi,C)")
- fvm::laplacian(D, C, "laplacian(D,C)")
);
CEqn.solve();
}

View File

@ -0,0 +1,208 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 Zeljko Tukovic, FSB Zagreb.
-------------------------------------------------------------------------------
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
surfactantProperties
Description
SourceFiles
surfactantProperties.H
\*---------------------------------------------------------------------------*/
#ifndef SurfactantProperties_H
#define SurfactantProperties_H
#include "fvCFD.H"
#include "faCFD.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class surfactantProperties Declaration
\*---------------------------------------------------------------------------*/
class surfactantProperties
{
// Private data
//- Surfactant concentration in the bulk of fluid
dimensionedScalar bulkConc_;
//- Saturated surfactant concentration on the free-surface
dimensionedScalar saturatedConc_;
//- Adsorption coefficient of surfactant
dimensionedScalar adsorptionCoeff_;
//- Desorption coefficient of surfactant
dimensionedScalar desorptionCoeff_;
//- Diffusion coefficient of surfactant in the bulk of fluid
dimensionedScalar bulkDiffusion_;
//- Diffusion coefficient of surfactant at the free-surface
dimensionedScalar diffusion_;
//- Temperature of surfactant at the free-surface
dimensionedScalar T_;
//- Universal gas constant
dimensionedScalar R_;
//- Equilibrium surfactant concentration at the free-surface
dimensionedScalar equilibriumConc_;
//- Is the surfactant soluble?
Switch soluble_;
public:
// Constructors
explicit surfactantProperties(const dictionary& dict)
:
bulkConc_("bulkConc", dict),
saturatedConc_("saturatedConc", dict),
adsorptionCoeff_("adsorptionCoeff", dict),
desorptionCoeff_("desorptionCoeff", dict),
bulkDiffusion_("bulkDiffusion", dict),
diffusion_("diffusion", dict),
T_("temperature", dict),
R_("R", dimGasConstant*dimMass/dimMoles, 8.3144),
equilibriumConc_
(
saturatedConc_
/(
1.0
+ desorptionCoeff_
/bulkConc_
)
),
soluble_(dict.get<bool>("soluble"))
{}
// Member Functions
//- Return surfactant concentration in the bulk of fluid
const dimensionedScalar& bulkConc() const
{
return bulkConc_;
}
//- Return saturated surfactant concentration at the free-surface
const dimensionedScalar& saturatedConc() const
{
return saturatedConc_;
}
//- Return surfactant adsorption coefficient
const dimensionedScalar& adsorptionCoeff() const
{
return adsorptionCoeff_;
}
//- Return surfactant desorption coefficient
const dimensionedScalar& desorptionCoeff() const
{
return desorptionCoeff_;
}
//- Return diffusion coefficient of the surfactant in the bulk of fluid
const dimensionedScalar& bulkDiffusion() const
{
return bulkDiffusion_;
}
//- Return diffusion coefficient of the surfactant at the free-surface
const dimensionedScalar& diffusion() const
{
return diffusion_;
}
//- Return surfactant temeprature
const dimensionedScalar& T() const
{
return T_;
}
//- Return universal gas constant
const dimensionedScalar& R() const
{
return R_;
}
//- Return equilibrium surfactant concentration at the free-surface
const dimensionedScalar& equilibriumConc() const
{
return equilibriumConc_;
}
//- Is the surfactant soluble
Switch soluble() const
{
return soluble_;
}
//- Surface tension change due to presense of surfactants
tmp<areaScalarField> dSigma
(
const areaScalarField& surfactConc
) const
{
return tmp<areaScalarField>::New
(
IOobject
(
"dSigma",
surfactConc.mesh().mesh().time().timeName(),
surfactConc.mesh().mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
(
R()*T()*saturatedConc()
* log(1.0 - surfactConc/saturatedConc())
)
);
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2004-2019 OpenCFD Ltd.
Copyright (C) 2016-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.

View File

@ -434,6 +434,7 @@ $(snGradSchemes)/uncorrectedSnGrad/uncorrectedSnGrads.C
$(snGradSchemes)/orthogonalSnGrad/orthogonalSnGrads.C
$(snGradSchemes)/quadraticFitSnGrad/quadraticFitSnGrads.C
$(snGradSchemes)/linearFitSnGrad/linearFitSnGrads.C
$(snGradSchemes)/skewCorrectedSnGrad/skewCorrectedSnGrads.C
convectionSchemes = finiteVolume/convectionSchemes
$(convectionSchemes)/convectionScheme/convectionSchemes.C

View File

@ -0,0 +1,261 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 Zeljko Tukovic, FSB Zagreb.
-------------------------------------------------------------------------------
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 "skewCorrectedSnGrad.H"
#include "volFields.H"
#include "surfaceFields.H"
#include "linear.H"
#include "fvcGrad.H"
#include "gaussGrad.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh>>
Foam::fv::skewCorrectedSnGrad<Type>::fullGradCorrection
(
const GeometricField<Type, fvPatchField, volMesh>& vf
) const
{
const fvMesh& mesh = this->mesh();
auto tssf = tmp<GeometricField<Type, fvsPatchField, surfaceMesh>>::New
(
IOobject
(
"snGradCorr("+vf.name()+')',
vf.instance(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
vf.dimensions()*mesh.nonOrthDeltaCoeffs().dimensions()
);
auto& ssf = tssf.ref();
ssf.setOriented();
ssf = dimensioned<Type>(ssf.dimensions(), Zero);
typedef typename
outerProduct<vector, typename pTraits<Type>::cmptType>::type
CmptGradType;
const labelUList& owner = mesh.owner();
const labelUList& neighbour = mesh.neighbour();
const vectorField& Sf = mesh.Sf().internalField();
const scalarField& magSf = mesh.magSf().internalField();
vectorField nf(Sf/magSf);
const vectorField& Cf = mesh.Cf().internalField();
const vectorField& C = mesh.C().internalField();
const scalarField& deltaCoeffs =
mesh.deltaCoeffs().internalField();
surfaceVectorField kP
(
IOobject
(
"kP",
vf.instance(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedVector(dimLength, Zero)
);
vectorField& kPI = kP.ref().field();
surfaceVectorField kN
(
IOobject
(
"kN",
vf.instance(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedVector(dimLength, Zero)
);
vectorField& kNI = kN.ref().field();
kPI = Cf - vectorField(C, owner);
kPI -= Sf*(Sf&kPI)/sqr(magSf);
kNI = Cf - vectorField(C, neighbour);
kNI -= Sf*(Sf&kNI)/sqr(magSf);
forAll(kP.boundaryField(), patchI)
{
if (kP.boundaryField()[patchI].coupled())
{
kP.boundaryFieldRef()[patchI] =
mesh.boundary()[patchI].Cf()
- mesh.boundary()[patchI].Cn();
kP.boundaryFieldRef()[patchI] -=
mesh.boundary()[patchI].Sf()
*(
mesh.boundary()[patchI].Sf()
& kP.boundaryField()[patchI]
)
/sqr(mesh.boundary()[patchI].magSf());
kN.boundaryFieldRef()[patchI] =
mesh.Cf().boundaryField()[patchI]
- (
mesh.boundary()[patchI].Cn()
+ mesh.boundary()[patchI].delta()
);
kN.boundaryFieldRef()[patchI] -=
mesh.boundary()[patchI].Sf()
*(
mesh.boundary()[patchI].Sf()
& kN.boundaryField()[patchI]
)
/sqr(mesh.boundary()[patchI].magSf());
}
}
for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; ++cmpt)
{
GeometricField<CmptGradType, fvPatchField, volMesh> cmptGrad
(
gradScheme<typename pTraits<Type>::cmptType>::New
(
mesh,
mesh.gradScheme("grad(" + vf.name() + ')')
)()
.grad(vf.component(cmpt))
);
const Field<CmptGradType>& cmptGradI = cmptGrad.internalField();
// Skewness and non-rothogonal correction
{
ssf.ref().field().replace
(
cmpt,
(
(kNI&Field<CmptGradType>(cmptGradI, neighbour))
- (kPI&Field<CmptGradType>(cmptGradI, owner))
)
*deltaCoeffs
);
}
forAll(ssf.boundaryField(), patchI)
{
if (ssf.boundaryField()[patchI].coupled())
{
ssf.boundaryFieldRef()[patchI].replace
(
cmpt,
(
(
kN.boundaryField()[patchI]
& cmptGrad.boundaryField()[patchI]
.patchNeighbourField()
)
- (
kP.boundaryField()[patchI]
& cmptGrad.boundaryField()[patchI]
.patchInternalField()
)
)
*mesh.deltaCoeffs().boundaryField()[patchI]
);
}
}
}
// // construct GeometricField<Type, fvsPatchField, surfaceMesh>
// tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> tssf =
// linear<typename outerProduct<vector, Type>::type>(mesh).dotInterpolate
// (
// mesh.nonOrthCorrectionVectors(),
// gradScheme<Type>::New
// (
// mesh,
// mesh.gradScheme("grad(" + vf.name() + ')')
// )().grad(vf, "grad(" + vf.name() + ')')
// );
//
// tssf.ref().rename("snGradCorr(" + vf.name() + ')');
return tssf;
}
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh>>
Foam::fv::skewCorrectedSnGrad<Type>::correction
(
const GeometricField<Type, fvPatchField, volMesh>& vf
) const
{
const fvMesh& mesh = this->mesh();
auto tssf = tmp<GeometricField<Type, fvsPatchField, surfaceMesh>>::New
(
IOobject
(
"snGradCorr("+vf.name()+')',
vf.instance(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
vf.dimensions()*mesh.nonOrthDeltaCoeffs().dimensions()
);
auto& ssf = tssf.ref();
ssf.setOriented();
for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; ++cmpt)
{
ssf.replace
(
cmpt,
skewCorrectedSnGrad<typename pTraits<Type>::cmptType>(mesh)
.fullGradCorrection(vf.component(cmpt))
);
}
return tssf;
}
// ************************************************************************* //

View File

@ -0,0 +1,162 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 Zeljko Tukovic, FSB Zagreb.
-------------------------------------------------------------------------------
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::fv::skewCorrectedSnGrad
Group
grpFvSnGradSchemes
Description
Simple central-difference snGrad scheme with non-orthogonal correction.
SourceFiles
skewCorrectedSnGrad.C
\*---------------------------------------------------------------------------*/
#ifndef skewCorrectedSnGrad_H
#define skewCorrectedSnGrad_H
#include "snGradScheme.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace fv
{
/*---------------------------------------------------------------------------*\
Class skewCorrectedSnGrad Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class skewCorrectedSnGrad
:
public snGradScheme<Type>
{
// Private Member Functions
//- No copy assignment
void operator=(const skewCorrectedSnGrad&) = delete;
public:
//- Runtime type information
TypeName("skewCorrected");
// Constructors
//- Construct from mesh
skewCorrectedSnGrad(const fvMesh& mesh)
:
snGradScheme<Type>(mesh)
{}
//- Construct from mesh and data stream
skewCorrectedSnGrad(const fvMesh& mesh, Istream&)
:
snGradScheme<Type>(mesh)
{}
//- Destructor
virtual ~skewCorrectedSnGrad() = default;
// Member Functions
//- Return the interpolation weighting factors for the given field
virtual tmp<surfaceScalarField> deltaCoeffs
(
const GeometricField<Type, fvPatchField, volMesh>&
) const
{
return this->mesh().nonOrthDeltaCoeffs();
}
//- Return true if this scheme uses an explicit correction
virtual bool corrected() const
{
return true;
}
//- Return the explicit correction to the skewCorrectedSnGrad
//- for the given field using the gradient of the field
tmp<GeometricField<Type, fvsPatchField, surfaceMesh>>
fullGradCorrection
(
const GeometricField<Type, fvPatchField, volMesh>&
) const;
//- Return the explicit correction to the skewCorrectedSnGrad
//- for the given field using the gradients of the field components
virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh>>
correction(const GeometricField<Type, fvPatchField, volMesh>&) const;
};
// * * * * * * * * Template Member Function Specialisations * * * * * * * * //
template<>
tmp<surfaceScalarField> skewCorrectedSnGrad<scalar>::correction
(
const volScalarField& vsf
) const;
template<>
tmp<surfaceVectorField> skewCorrectedSnGrad<vector>::correction
(
const volVectorField& vvf
) const;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fv
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "skewCorrectedSnGrad.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,60 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 Zeljko Tukovic, FSB Zagreb.
-------------------------------------------------------------------------------
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 "skewCorrectedSnGrad.H"
#include "fvMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makeSnGradScheme(skewCorrectedSnGrad)
// * * * * * * * * * * * * Template Specializations * * * * * * * * * * * * //
template<>
Foam::tmp<Foam::surfaceScalarField>
Foam::fv::skewCorrectedSnGrad<Foam::scalar>::correction
(
const volScalarField& vsf
) const
{
return fullGradCorrection(vsf);
}
template<>
Foam::tmp<Foam::surfaceVectorField>
Foam::fv::skewCorrectedSnGrad<Foam::vector>::correction
(
const volVectorField& vvf
) const
{
return fullGradCorrection(vvf);
}
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016 OpenCFD Ltd.
Copyright (C) 2016-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -125,12 +125,19 @@ void Foam::velocityLaplacianFvMotionSolver::solve()
fv::options& fvOptions(fv::options::New(fvMesh_));
const label nNonOrthCorr
(
lookupOrDefault<label>("nNonOrthogonalCorrectors", 1)
);
for (label i=0; i<nNonOrthCorr; ++i)
{
fvVectorMatrix UEqn
(
fvm::laplacian
(
dimensionedScalar("viscosity", dimViscosity, 1.0)
*diffusivityPtr_->operator()(),
* diffusivityPtr_->operator()(),
cellMotionU_,
"laplacian(diffusivity,cellMotionU)"
)
@ -141,6 +148,7 @@ void Foam::velocityLaplacianFvMotionSolver::solve()
fvOptions.constrain(UEqn);
UEqn.solveSegregatedOrCoupled(UEqn.solverDict());
fvOptions.correct(cellMotionU_);
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2009-2019 OpenCFD Ltd.
Copyright (C) 2016-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2009-2019 OpenCFD Ltd.
Copyright (C) 2016-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2009-2019 OpenCFD Ltd.
Copyright (C) 2016-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -55,7 +55,6 @@ SourceFiles
#include "sixDoFRigidBodyMotionConstraint.H"
#include "Tuple2.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2009-2019 OpenCFD Ltd.
Copyright (C) 2016-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.