Finite area port, Hrvoje Jasak

- with sphereSurfactantFoam and sphereTransport test case
This commit is contained in:
Hrvoje Jasak
2017-09-15 12:02:25 +01:00
committed by Andrew Heather
parent 4c81ee202d
commit 0c64622341
424 changed files with 96950 additions and 0 deletions

View File

@ -0,0 +1,3 @@
liquidFilmFoam.C
EXE = $(FOAM_APPBIN)/liquidFilmFoam

View File

@ -0,0 +1,10 @@
EXE_INC = \
-I$(LIB_SRC)/finiteArea/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/cfdTools/general/lnInclude
EXE_LIBS = \
-lfiniteArea \
-lfiniteVolume \
-lmeshTools

View File

@ -0,0 +1,7 @@
{
// Stabilisation of friction factor calculation
// Friction factor is defined with standard gravity
frictionFactor.primitiveFieldRef() =
mag(2*9.81*sqr(manningField.primitiveField())/
pow(mag(h.primitiveField()) + 1e-7, 1.0/3.0));
}

View File

@ -0,0 +1,13 @@
{
scalar CoNumSigma = max
(
sqrt
(
2*M_PI*sigma*sqr(aMesh.edgeInterpolation::deltaCoeffs())
*aMesh.edgeInterpolation::deltaCoeffs()
/rhol
)
).value()*runTime.deltaT().value();
Info<< "Max Capillary Courant Number = " << CoNumSigma << '\n' << endl;
}

View File

@ -0,0 +1,158 @@
Info<< "Reading field h" << endl;
areaScalarField h
(
IOobject
(
"h",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
aMesh
);
Info<< "Reading field Us" << endl;
areaVectorField Us
(
IOobject
(
"Us",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
aMesh
);
edgeScalarField phis
(
IOobject
(
"phis",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
fac::interpolate(Us) & aMesh.Le()
);
edgeScalarField phi2s
(
IOobject
(
"phi2s",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
fac::interpolate(h*Us) & aMesh.Le()
);
const areaVectorField& Ns = aMesh.faceAreaNormals();
areaVectorField Gs = g - Ns*(Ns & g);
areaScalarField Gn = mag(g - Gs);
// Mass source
areaScalarField Sm
(
IOobject
(
"Sm",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
aMesh,
dimensionedScalar("Sm", dimLength/dimTime, 0)
);
// Mass sink
areaScalarField Sd
(
IOobject
(
"Sd",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
aMesh,
dimensionedScalar("Sd", dimLength/dimTime, 0)
);
areaVectorField Ug
(
IOobject
(
"Sg",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
aMesh,
dimensionedVector("Ug", dimVelocity, vector::zero)
);
// Surface pressure
areaScalarField ps
(
IOobject
(
"ps",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
rhol*Gn*h - sigma*fac::laplacian(h)
);
// Friction factor
areaScalarField dotProduct
(
aMesh.faceAreaNormals() & (g/mag(g))
);
Info<< "View factor: min = " << min(dotProduct.internalField())
<< " max = " << max(dotProduct.internalField()) << endl;
areaScalarField manningField
(
IOobject
(
"manningField",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
aMesh
);
areaScalarField frictionFactor
(
IOobject
(
"frictionFactor",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
aMesh,
dimensionedScalar("one", dimless, 0.01)
);
aMesh.schemesDict().setFluxRequired("h");

View File

@ -0,0 +1,31 @@
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedVector("0", dimVelocity, vector::zero)
);
volScalarField H
(
IOobject
(
"H",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("0", dimLength, 0)
);
// Create volume-to surface mapping object
volSurfaceMapping vsm(aMesh);

View File

@ -0,0 +1,155 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
liquidFilmFoam
Description
Transient solver for incompressible, laminar flow of Newtonian fluids in
liquid film formulation.
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "faCFD.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"
#include "createFaMesh.H"
#include "readGravitationalAcceleration.H"
#include "readTransportProperties.H"
#include "createFaFields.H"
#include "createFvFields.H"
#include "createTimeControls.H"
Info<< "\nStarting time loop\n" << endl;
while (runTime.run())
{
#include "readSolutionControls.H"
#include "readTimeControls.H"
#include "surfaceCourantNo.H"
#include "capillaryCourantNo.H"
#include "setDeltaT.H"
runTime++;
Info<< "Time = " << runTime.timeName() << nl << endl;
while (runTime.loop())
{
phi2s = fac::interpolate(h)*phis;
#include "calcFrictionFactor.H"
faVectorMatrix UsEqn
(
fam::ddt(h, Us)
+ fam::div(phi2s, Us)
+ fam::Sp(0.0125*frictionFactor*mag(Us), Us)
==
Gs*h
- fam::Sp(Sd, Us)
);
UsEqn.relax();
solve(UsEqn == - fac::grad(ps*h)/rhol + ps*fac::grad(h)/rhol);
areaScalarField UsA = UsEqn.A();
Us = UsEqn.H()/UsA;
Us.correctBoundaryConditions();
phis = (fac::interpolate(Us) & aMesh.Le())
- fac::interpolate(1.0/(rhol*UsA))
*fac::lnGrad(ps*h)*aMesh.magLe()
+ fac::interpolate(ps/(rhol*UsA))
*fac::lnGrad(h)*aMesh.magLe();
faScalarMatrix hEqn
(
fam::ddt(h)
+ fam::div(phis, h)
==
Sm
- fam::Sp
(
Sd/(h + dimensionedScalar("small", dimLength, SMALL)),
h
)
);
hEqn.relax();
hEqn.solve();
phi2s = hEqn.flux();
// Bound h
h.primitiveFieldRef() = max
(
max
(
h.primitiveField(),
fac::average(max(h, h0))().primitiveField()
*pos(h0.value() - h.primitiveField())
),
h0.value()
);
ps = rhol*Gn*h - sigma*fac::laplacian(h);
ps.correctBoundaryConditions();
Us -= (1.0/(rhol*UsA))*fac::grad(ps*h)
- (ps/(rhol*UsA))*fac::grad(h);
Us.correctBoundaryConditions();
}
if (runTime.outputTime())
{
vsm.mapToVolume(h, H.boundaryFieldRef());
vsm.mapToVolume(Us, U.boundaryFieldRef());
runTime.write();
}
Info<< "ExecutionTime = "
<< scalar(runTime.elapsedCpuTime())
<< " s\n" << endl << endl;
}
return 0;
}
// ************************************************************************* //

View File

@ -0,0 +1,13 @@
int nCorr = 0;
if (aMesh.solutionDict().found("nOuterCorrectors"))
{
nCorr =
readInt(aMesh.solutionDict().lookup("nOuterCorrectors"));
}
else
{
FatalErrorIn(args.executable())
<< "Cannot find number of correctors"
<< abort(FatalError);
}

View File

@ -0,0 +1,41 @@
IOdictionary transportProperties
(
IOobject
(
"transportProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
dimensionedScalar mug
(
transportProperties.lookup("mug")
);
dimensionedScalar mul
(
transportProperties.lookup("mul")
);
dimensionedScalar sigma
(
transportProperties.lookup("sigma")
);
dimensionedScalar rhol
(
transportProperties.lookup("rhol")
);
dimensionedScalar rhog
(
transportProperties.lookup("rhog")
);
dimensionedScalar h0
(
transportProperties.lookup("h0")
);

View File

@ -0,0 +1,60 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Global
surfaceCourantNo
Author
Hrvoje Jasak, Wikki Ltd.
Description
Calculates and outputs the mean and maximum Courant Numbers for the
Finite Area method.
\*---------------------------------------------------------------------------*/
scalar CoNum = 0.0;
scalar meanCoNum = 0.0;
scalar velMag = 0.0;
if (aMesh.nInternalEdges())
{
edgeScalarField SfUfbyDelta =
aMesh.edgeInterpolation::deltaCoeffs()*mag(phis);
CoNum = max(SfUfbyDelta/aMesh.magLe())
.value()*runTime.deltaT().value();
meanCoNum = (sum(SfUfbyDelta)/sum(aMesh.magLe()))
.value()*runTime.deltaT().value();
velMag = max(mag(phis)/aMesh.magLe()).value();
}
Info<< "Courant Number mean: " << meanCoNum
<< " max: " << CoNum
<< " velocity magnitude: " << velMag << endl;
// ************************************************************************* //

View File

@ -0,0 +1,3 @@
surfactantFoam.C
EXE = $(FOAM_USER_APPBIN)/sphereSurfactantFoam

View File

@ -0,0 +1,10 @@
EXE_INC = \
-I$(LIB_SRC)/finiteArea/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/cfdTools/general/lnInclude
EXE_LIBS = \
-lfiniteArea \
-lfiniteVolume \
-lmeshTools

View File

@ -0,0 +1,78 @@
Info<< "Reading field Cs" << endl;
areaScalarField Cs
(
IOobject
(
"Cs",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
aMesh
);
dimensioned<scalar> Cs0
(
"Cs0",
dimensionSet(1, -2, 0, 0, 0, 0, 0),
1.0
);
const areaVectorField& R = aMesh.areaCentres();
Cs = Cs0*(1.0 + R.component(vector::X)/mag(R));
dimensioned<scalar> Ds
(
"Ds",
dimensionSet(0, 2, -1, 0, 0, 0, 0),
1.0
);
areaVectorField Us
(
IOobject
(
"Us",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
aMesh,
dimensioned<vector>("Us", dimVelocity, vector::zero)
);
dimensioned<scalar> Uinf("Uinf", dimVelocity, 1.0);
forAll (Us, faceI)
{
Us[faceI].x() =
Uinf.value()*(0.25*(3.0 + sqr(R[faceI].x()/mag(R[faceI]))) - 1.0);
Us[faceI].y() =
Uinf.value()*0.25*R[faceI].x()*R[faceI].y()/sqr(mag(R[faceI]));
Us[faceI].z() =
Uinf.value()*0.25*R[faceI].x()*R[faceI].z()/sqr(mag(R[faceI]));
}
Us -= aMesh.faceAreaNormals()*(aMesh.faceAreaNormals() & Us);
edgeScalarField phis
(
IOobject
(
"phis",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
linearEdgeInterpolate(Us) & aMesh.Le()
);

View File

@ -0,0 +1,2 @@
// Create Finite Area mesh
faMesh aMesh(mesh);

View File

@ -0,0 +1,36 @@
// Create volume-to surface mapping object
volSurfaceMapping vsm(aMesh);
volScalarField Cvf
(
IOobject
(
"Cvf",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("0", dimless/dimLength, 0)
);
vsm.mapToVolume(Cs, Cvf.boundaryFieldRef());
Cvf.write();
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedVector("zero", dimVelocity, vector::zero)
);
vsm.mapToVolume(Us, U.boundaryFieldRef());
U.write();

View File

@ -0,0 +1,86 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
surfactantFoam for sphere transport
Description
Passive scalar transport equation solver on a sphere
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "faCFD.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"
#include "createFaMesh.H"
#include "createFaFields.H"
#include "createVolFields.H"
Info<< "Total mass of surfactant: "
<< sum(Cs.internalField()*aMesh.S()) << endl;
Info<< "\nStarting time loop\n" << endl;
while (runTime.loop())
{
Info<< "Time = " << runTime.value() << endl;
faScalarMatrix CsEqn
(
fam::ddt(Cs)
+ fam::div(phis, Cs)
- fam::laplacian(Ds, Cs)
);
CsEqn.solve();
if (runTime.outputTime())
{
vsm.mapToVolume(Cs, Cvf.boundaryFieldRef());
runTime.write();
}
Info<< "Total mass of surfactant: "
<< sum(Cs.internalField()*aMesh.S()) << endl;
Info<< "ExecutionTime = "
<< scalar(runTime.elapsedCpuTime())
<< " s\n" << endl << endl;
}
return 0;
}
// ************************************************************************* //

View File

@ -0,0 +1,3 @@
surfactantFoam.C
EXE = $(FOAM_APPBIN)/surfactantFoam

View File

@ -0,0 +1,10 @@
EXE_INC = \
-I$(LIB_SRC)/finiteArea/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/cfdTools/general/lnInclude
EXE_LIBS = \
-lfiniteArea \
-lfiniteVolume \
-lmeshTools

View File

@ -0,0 +1,63 @@
Info<< "Reading field Cs" << endl;
areaScalarField Cs
(
IOobject
(
"Cs",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
aMesh
);
Info<< "Reading transportProperties\n" << endl;
IOdictionary transportProperties
(
IOobject
(
"transportProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
Info<< "Reading diffusivity D\n" << endl;
dimensionedScalar Ds
(
transportProperties.lookup("Ds")
);
areaVectorField Us
(
IOobject
(
"Us",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
),
aMesh
);
edgeScalarField phis
(
IOobject
(
"phis",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
linearEdgeInterpolate(Us) & aMesh.Le()
);

View File

@ -0,0 +1,2 @@
// Create Finite Area mesh
faMesh aMesh(mesh);

View File

@ -0,0 +1,36 @@
// Create volume-to surface mapping object
volSurfaceMapping vsm(aMesh);
volScalarField Cvf
(
IOobject
(
"Cvf",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("0", dimless/dimLength, 0)
);
vsm.mapToVolume(Cs, Cvf.boundaryFieldRef());
Cvf.write();
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedVector("zero", dimVelocity, vector::zero)
);
vsm.mapToVolume(Us, U.boundaryFieldRef());
U.write();

View File

@ -0,0 +1,112 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
surfactantFoam
Group
grpBasicSolvers
Description
Passive scalar transport equation solver.
\heading Solver details
The equation is given by:
\f[
\ddt{Cs} + \div \left(\vec{U} Cs\right) - \div \left(D_T \grad Cs \right)
= 0
\f]
Where:
\vartable
Cs | Passive scalar
Ds | Diffusion coefficient
\endvartable
\heading Required fields
\plaintable
Cs | Passive scalar
Us | Velocity [m/s]
\endplaintable
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "faCFD.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"
#include "createFaMesh.H"
#include "createFaFields.H"
#include "createVolFields.H"
Info<< "Total mass of surfactant: "
<< sum(Cs.internalField()*aMesh.S()) << endl;
Info<< "\nStarting time loop\n" << endl;
while (runTime.loop())
{
Info<< "Time = " << runTime.value() << endl;
faScalarMatrix CsEqn
(
fam::ddt(Cs)
+ fam::div(phis, Cs)
- fam::laplacian(Ds, Cs)
);
CsEqn.solve();
if (runTime.outputTime())
{
vsm.mapToVolume(Cs, Cvf.boundaryFieldRef());
runTime.write();
}
Info<< "Total mass of surfactant: "
<< sum(Cs.internalField()*aMesh.S()) << endl;
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}
return 0;
}
// ************************************************************************* //

View File

@ -0,0 +1,3 @@
checkFaMesh.C
EXE = $(FOAM_APPBIN)/checkFaMesh

View File

@ -0,0 +1,9 @@
EXE_INC = \
-I$(LIB_SRC)/finiteArea/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
EXE_LIBS = \
-lfiniteVolume \
-lmeshTools \
-lfiniteArea

View File

@ -0,0 +1,83 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
makeFaMesh
Description
Check a Finite Area mesh
Author
Zeljko Tukovic, FAMENA
Hrvoje Jasak, Wikki Ltd.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "faCFD.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
# include "addRegionOption.H"
# include "setRootCase.H"
# include "createTime.H"
# include "createNamedMesh.H"
# include "createFaMesh.H"
Info<< "Time = " << runTime.timeName() << nl << endl;
// General mesh statistics
Info<< "Number of points: " << aMesh.nPoints() << nl
<< "Number of internal edges: " << aMesh.nInternalEdges() << nl
<< "Number of edges: " << aMesh.nEdges() << nl
<< "Number of faces: " << aMesh.nFaces() << nl
<< endl;
// Check geometry
Info<< "Face area: min = " << min(aMesh.S().field())
<< " max = " << max(aMesh.S().field()) << nl
<< "Internal edge length: min = "
<< min(aMesh.magLe().internalField()) << nl
<< " max = " << max(aMesh.magLe().internalField()) << nl
<< "Edge length: min = "
<< min(aMesh.magLe()).value() << nl
<< " max = " << max(aMesh.magLe()).value() << nl
<< "Face area normals: min = " << min(aMesh.faceAreaNormals().field())
<< " max = " << max(aMesh.faceAreaNormals().field()) << nl
<< endl;
return(0);
}
// ************************************************************************* //

View File

@ -0,0 +1,3 @@
makeFaMesh.C
EXE = $(FOAM_APPBIN)/makeFaMesh

View File

@ -0,0 +1,8 @@
EXE_INC = \
-I$(LIB_SRC)/finiteArea/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/cfdTools/general/lnInclude
EXE_LIBS = \
-lfiniteArea \
-lfiniteVolume

View File

@ -0,0 +1,356 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
makeFaMesh
Description
A mesh generator for finite area mesh.
Author
Zeljko Tukovic, FAMENA
Hrvoje Jasak, Wikki Ltd.
\*---------------------------------------------------------------------------*/
#include "objectRegistry.H"
#include "Time.H"
#include "argList.H"
#include "OSspecific.H"
#include "faMesh.H"
#include "fvMesh.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
class faPatchData
{
public:
word name_;
word type_;
dictionary dict_;
label ownPolyPatchID_;
label ngbPolyPatchID_;
labelList edgeLabels_;
faPatchData()
:
name_(word::null),
type_(word::null),
ownPolyPatchID_(-1),
ngbPolyPatchID_(-1)
{}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
# include "addRegionOption.H"
# include "setRootCase.H"
# include "createTime.H"
# include "createNamedMesh.H"
// Reading faMeshDefinition dictionary
IOdictionary faMeshDefinition
(
IOobject
(
"faMeshDefinition",
runTime.constant(),
"faMesh",
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
wordList polyMeshPatches
(
faMeshDefinition.lookup("polyMeshPatches")
);
dictionary bndDict = faMeshDefinition.subDict("boundary");
wordList faPatchNames = bndDict.toc();
List<faPatchData> faPatches(faPatchNames.size()+1);
forAll (faPatchNames, patchI)
{
dictionary curPatchDict =
bndDict.subDict(faPatchNames[patchI]);
faPatches[patchI].name_ = faPatchNames[patchI];
faPatches[patchI].type_ =
word(curPatchDict.lookup("type"));
word ownName = curPatchDict.lookup("ownerPolyPatch");
faPatches[patchI].ownPolyPatchID_ =
mesh.boundaryMesh().findPatchID(ownName);
if ( faPatches[patchI].ownPolyPatchID_ < 0 )
{
FatalErrorIn("makeFaMesh:")
<< "neighbourPolyPatch " << ownName << " does not exist"
<< exit(FatalError);
}
word neiName = curPatchDict.lookup("neighbourPolyPatch");
faPatches[patchI].ngbPolyPatchID_ =
mesh.boundaryMesh().findPatchID(neiName);
if ( faPatches[patchI].ngbPolyPatchID_ < 0 )
{
FatalErrorIn("makeFaMesh:")
<< "neighbourPolyPatch " << neiName << " does not exist"
<< exit(FatalError);
}
}
// Setting faceLabels list size
label size = 0;
labelList patchIDs(polyMeshPatches.size(), -1);
forAll (polyMeshPatches, patchI)
{
patchIDs[patchI] =
mesh.boundaryMesh().findPatchID(polyMeshPatches[patchI]);
if ( patchIDs[patchI] < 0 )
{
FatalErrorIn("makeFaMesh:")
<< "Patch " << polyMeshPatches[patchI] << " does not exist"
<< exit(FatalError);
}
size += mesh.boundaryMesh()[patchIDs[patchI]].size();
}
labelList faceLabels(size, -1);
sort(patchIDs);
// Filling of faceLabels list
label faceI = -1;
forAll (polyMeshPatches, patchI)
{
label start = mesh.boundaryMesh()[patchIDs[patchI]].start();
label size = mesh.boundaryMesh()[patchIDs[patchI]].size();
for(label i = 0; i < size; i++)
{
faceLabels[++faceI] = start + i;
}
}
// Creating faMesh
Info << "Create faMesh ... ";
faMesh areaMesh
(
mesh,
faceLabels
);
Info << "Done" << endl;
// Determination of faPatch ID for each boundary edge.
// Result is in the bndEdgeFaPatchIDs list
const indirectPrimitivePatch& patch = areaMesh.patch();
labelList faceCells(faceLabels.size(), -1);
forAll (faceCells, faceI)
{
label faceID = faceLabels[faceI];
faceCells[faceI] = mesh.faceOwner()[faceID];
}
labelList meshEdges =
patch.meshEdges
(
mesh.edges(),
mesh.cellEdges(),
faceCells
);
const labelListList& edgeFaces = mesh.edgeFaces();
const label nTotalEdges = patch.nEdges();
const label nInternalEdges = patch.nInternalEdges();
labelList bndEdgeFaPatchIDs(nTotalEdges - nInternalEdges, -1);
for (label edgeI = nInternalEdges; edgeI < nTotalEdges; edgeI++)
{
label curMeshEdge = meshEdges[edgeI];
labelList curEdgePatchIDs(2, -1);
label patchI = -1;
forAll (edgeFaces[curMeshEdge], faceI)
{
label curFace = edgeFaces[curMeshEdge][faceI];
label curPatchID = mesh.boundaryMesh().whichPatch(curFace);
if (curPatchID != -1)
{
curEdgePatchIDs[++patchI] = curPatchID;
}
}
for(label pI = 0; pI < faPatches.size() - 1; pI++)
{
if
(
(
curEdgePatchIDs[0] == faPatches[pI].ownPolyPatchID_
&& curEdgePatchIDs[1] == faPatches[pI].ngbPolyPatchID_
)
||
(
curEdgePatchIDs[1] == faPatches[pI].ownPolyPatchID_
&& curEdgePatchIDs[0] == faPatches[pI].ngbPolyPatchID_
)
)
{
bndEdgeFaPatchIDs[edgeI - nInternalEdges] = pI;
break;
}
}
}
// Set edgeLabels for each faPatch
for(label pI=0; pI<(faPatches.size()-1); pI++)
{
SLList<label> tmpList;
forAll (bndEdgeFaPatchIDs, eI)
{
if (bndEdgeFaPatchIDs[eI] == pI)
{
tmpList.append(nInternalEdges + eI);
}
}
faPatches[pI].edgeLabels_ = tmpList;
}
// Check for undefined edges
SLList<label> tmpList;
forAll (bndEdgeFaPatchIDs, eI)
{
if (bndEdgeFaPatchIDs[eI] == -1)
{
tmpList.append(nInternalEdges + eI);
}
}
if (tmpList.size() > 0)
{
label pI = faPatches.size()-1;
faPatches[pI].name_ = "undefined";
faPatches[pI].type_ = "patch";
faPatches[pI].edgeLabels_ = tmpList;
}
// Add good patches to faMesh
SLList<faPatch*> faPatchLst;
for(label pI = 0; pI < faPatches.size(); pI++)
{
faPatches[pI].dict_.add("type", faPatches[pI].type_);
faPatches[pI].dict_.add("edgeLabels", faPatches[pI].edgeLabels_);
faPatches[pI].dict_.add
(
"ngbPolyPatchIndex",
faPatches[pI].ngbPolyPatchID_
);
if(faPatches[pI].edgeLabels_.size() > 0)
{
faPatchLst.append
(
faPatch::New
(
faPatches[pI].name_,
faPatches[pI].dict_,
pI,
areaMesh.boundary()
).ptr()
);
}
}
if (args.optionFound("addEmptyPatch"))
{
word emptyPatchName(args.optionLookup("addEmptyPatch")());
dictionary emptyPatchDict;
emptyPatchDict.add("type", "empty");
emptyPatchDict.add("edgeLabels", labelList());
emptyPatchDict.add("ngbPolyPatchIndex", -1);
faPatchLst.append
(
faPatch::New
(
emptyPatchName,
emptyPatchDict,
faPatchLst.size(),
areaMesh.boundary()
).ptr()
);
}
Info << "Add faPatches ... ";
areaMesh.addFaPatches(List<faPatch*>(faPatchLst));
Info << "Done" << endl;
// Writing faMesh
Info << "Write finite area mesh ... ";
areaMesh.write();
Info << "Done" << endl;
return(0);
}
// ************************************************************************* //

View File

@ -4,6 +4,8 @@ domainDecompositionMesh.C
domainDecompositionDistribute.C
dimFieldDecomposer.C
pointFieldDecomposer.C
faMeshDecomposition.C
faFieldDecomposer.C
lagrangianFieldDecomposer.C
EXE = $(FOAM_APPBIN)/decomposePar

View File

@ -2,6 +2,7 @@ EXE_INC = \
-I$(LIB_SRC)/parallel/decompose/decompose/lnInclude \
-I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/finiteArea/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
@ -14,6 +15,7 @@ EXE_LIBS = \
-ldecompositionMethods \
-L$(FOAM_LIBBIN)/dummy \
-lkahipDecomp -lmetisDecomp -lscotchDecomp \
-lfiniteArea \
-llagrangian \
-ldynamicMesh \
-lregionModels

View File

@ -106,6 +106,11 @@ Usage
#include "decompositionModel.H"
#include "collatedFileOperation.H"
#include "faCFD.H"
#include "emptyFaPatch.H"
#include "faMeshDecomposition.H"
#include "faFieldDecomposer.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
@ -1239,6 +1244,178 @@ int main(int argc, char *argv[])
processorDbList.set(proci, nullptr);
}
}
// Finite area mesh and field decomposition
IOobject faMeshBoundaryIOobj
(
"faBoundary",
mesh.time().findInstance
(
mesh.dbDir()/polyMesh::meshSubDir,
"boundary"
),
faMesh::meshSubDir,
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE
);
if (faMeshBoundaryIOobj.typeHeaderOk<faBoundaryMesh>(true))
{
Info << "\nFinite area mesh decomposition" << endl;
faMeshDecomposition aMesh(mesh);
aMesh.decomposeMesh();
aMesh.writeDecomposition();
// Construct the area fields
// ~~~~~~~~~~~~~~~~~~~~~~~~
PtrList<areaScalarField> areaScalarFields;
readFields(aMesh, objects, areaScalarFields);
PtrList<areaVectorField> areaVectorFields;
readFields(aMesh, objects, areaVectorFields);
PtrList<areaSphericalTensorField> areaSphericalTensorFields;
readFields(aMesh, objects, areaSphericalTensorFields);
PtrList<areaSymmTensorField> areaSymmTensorFields;
readFields(aMesh, objects, areaSymmTensorFields);
PtrList<areaTensorField> areaTensorFields;
readFields(aMesh, objects, areaTensorFields);
// Construct the edge fields
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PtrList<edgeScalarField> edgeScalarFields;
readFields(aMesh, objects, edgeScalarFields);
Info << endl;
// Split the fields over processors
for (label procI = 0; procI < mesh.nProcs(); procI++)
{
Info<< "Processor " << procI
<< ": finite area field transfer" << endl;
// open the database
Time processorDb
(
Time::controlDictName,
args.rootPath(),
args.caseName()/
fileName(word("processor") + name(procI))
);
processorDb.setTime(runTime);
// Read the mesh
fvMesh procFvMesh
(
IOobject
(
regionName,
processorDb.timeName(),
processorDb
)
);
faMesh procMesh(procFvMesh);
// // Does not work. HJ, 15/Aug/2017
// const labelIOList& faceProcAddressing =
// procAddressing
// (
// procMeshList,
// procI,
// "faceProcAddressing",
// faceProcAddressingList
// );
// const labelIOList& boundaryProcAddressing =
// procAddressing
// (
// procMeshList,
// procI,
// "boundaryProcAddressing",
// boundaryProcAddressingList
// );
labelIOList faceProcAddressing
(
IOobject
(
"faceProcAddressing",
"constant",
procMesh.meshSubDir,
procFvMesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
labelIOList boundaryProcAddressing
(
IOobject
(
"boundaryProcAddressing",
"constant",
procMesh.meshSubDir,
procFvMesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
// FA fields
if
(
areaScalarFields.size()
|| areaVectorFields.size()
|| areaSphericalTensorFields.size()
|| areaSymmTensorFields.size()
|| areaTensorFields.size()
|| edgeScalarFields.size()
)
{
labelIOList edgeProcAddressing
(
IOobject
(
"edgeProcAddressing",
"constant",
procMesh.meshSubDir,
procFvMesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
faFieldDecomposer fieldDecomposer
(
aMesh,
procMesh,
edgeProcAddressing,
faceProcAddressing,
boundaryProcAddressing
);
fieldDecomposer.decomposeFields(areaScalarFields);
fieldDecomposer.decomposeFields(areaVectorFields);
fieldDecomposer.decomposeFields(areaSphericalTensorFields);
fieldDecomposer.decomposeFields(areaSymmTensorFields);
fieldDecomposer.decomposeFields(areaTensorFields);
fieldDecomposer.decomposeFields(edgeScalarFields);
}
}
}
}
}
}

View File

@ -0,0 +1,238 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "faFieldDecomposer.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
faFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
(
const label sizeBeforeMapping,
const labelUList& addressingSlice,
const label addressingOffset
)
:
sizeBeforeMapping_(sizeBeforeMapping),
directAddressing_(addressingSlice)
{
forAll (directAddressing_, i)
{
// Subtract one to align addressing.
// directAddressing_[i] -= addressingOffset + 1;
// ZT, 12/Nov/2010
directAddressing_[i] -= addressingOffset;
}
}
faFieldDecomposer::processorAreaPatchFieldDecomposer::
processorAreaPatchFieldDecomposer
(
const faMesh& mesh,
const labelUList& addressingSlice
)
:
sizeBeforeMapping_(mesh.nFaces()),
addressing_(addressingSlice.size()),
weights_(addressingSlice.size())
{
const scalarField& weights = mesh.weights().internalField();
const labelList& own = mesh.edgeOwner();
const labelList& neighb = mesh.edgeNeighbour();
forAll (addressing_, i)
{
// Subtract one to align addressing.
label ai = addressingSlice[i];
// label ai = mag(addressingSlice[i]) - 1;
if (ai < neighb.size())
{
// This is a regular edge. it has been an internal edge
// of the original mesh and now it has become a edge
// on the parallel boundary
addressing_[i].setSize(2);
weights_[i].setSize(2);
addressing_[i][0] = own[ai];
addressing_[i][1] = neighb[ai];
weights_[i][0] = weights[ai];
weights_[i][1] = 1.0 - weights[ai];
}
else
{
// This is a edge that used to be on a cyclic boundary
// but has now become a parallel patch edge. I cannot
// do the interpolation properly (I would need to look
// up the different (edge) list of data), so I will
// just grab the value from the owner face
//
addressing_[i].setSize(1);
weights_[i].setSize(1);
addressing_[i][0] = own[ai];
weights_[i][0] = 1.0;
}
}
}
faFieldDecomposer::processorEdgePatchFieldDecomposer::
processorEdgePatchFieldDecomposer
(
label sizeBeforeMapping,
const labelUList& addressingSlice
)
:
sizeBeforeMapping_(sizeBeforeMapping),
addressing_(addressingSlice.size()),
weights_(addressingSlice.size())
{
forAll (addressing_, i)
{
addressing_[i].setSize(1);
weights_[i].setSize(1);
addressing_[i][0] = mag(addressingSlice[i]) - 1;
weights_[i][0] = sign(addressingSlice[i]);
}
}
faFieldDecomposer::faFieldDecomposer
(
const faMesh& completeMesh,
const faMesh& procMesh,
const labelList& edgeAddressing,
const labelList& faceAddressing,
const labelList& boundaryAddressing
)
:
completeMesh_(completeMesh),
procMesh_(procMesh),
edgeAddressing_(edgeAddressing),
faceAddressing_(faceAddressing),
boundaryAddressing_(boundaryAddressing),
patchFieldDecomposerPtrs_
(
procMesh_.boundary().size(),
static_cast<patchFieldDecomposer*>(NULL)
),
processorAreaPatchFieldDecomposerPtrs_
(
procMesh_.boundary().size(),
static_cast<processorAreaPatchFieldDecomposer*>(NULL)
),
processorEdgePatchFieldDecomposerPtrs_
(
procMesh_.boundary().size(),
static_cast<processorEdgePatchFieldDecomposer*>(NULL)
)
{
forAll (boundaryAddressing_, patchi)
{
if (boundaryAddressing_[patchi] >= 0)
{
patchFieldDecomposerPtrs_[patchi] = new patchFieldDecomposer
(
completeMesh_.boundary()[boundaryAddressing_[patchi]].size(),
procMesh_.boundary()[patchi].patchSlice(edgeAddressing_),
// completeMesh_.boundaryMesh()
completeMesh_.boundary()
[
boundaryAddressing_[patchi]
].start()
);
}
else
{
processorAreaPatchFieldDecomposerPtrs_[patchi] =
new processorAreaPatchFieldDecomposer
(
completeMesh_,
procMesh_.boundary()[patchi].patchSlice(edgeAddressing_)
);
processorEdgePatchFieldDecomposerPtrs_[patchi] =
new processorEdgePatchFieldDecomposer
(
procMesh_.boundary()[patchi].size(),
static_cast<const labelUList&>
(
procMesh_.boundary()[patchi].patchSlice
(
edgeAddressing_
)
)
);
}
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
faFieldDecomposer::~faFieldDecomposer()
{
forAll (patchFieldDecomposerPtrs_, patchi)
{
if (patchFieldDecomposerPtrs_[patchi])
{
delete patchFieldDecomposerPtrs_[patchi];
}
}
forAll (processorAreaPatchFieldDecomposerPtrs_, patchi)
{
if (processorAreaPatchFieldDecomposerPtrs_[patchi])
{
delete processorAreaPatchFieldDecomposerPtrs_[patchi];
}
}
forAll (processorEdgePatchFieldDecomposerPtrs_, patchi)
{
if (processorEdgePatchFieldDecomposerPtrs_[patchi])
{
delete processorEdgePatchFieldDecomposerPtrs_[patchi];
}
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,319 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
faFieldDecomposer
Description
Finite Area area and edge field decomposer.
Author
Zeljko Tukovic, FSB Zagreb
Hrvoje Jasak, Wikki Ltd.
SourceFiles
faFieldDecomposer.C
faFieldDecomposerDecomposeFields.C
\*---------------------------------------------------------------------------*/
#ifndef faFieldDecomposer_H
#define faFieldDecomposer_H
#include "faMesh.H"
#include "faPatchFieldMapper.H"
#include "edgeFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class IOobjectList;
/*---------------------------------------------------------------------------*\
Class faFieldDecomposer Declaration
\*---------------------------------------------------------------------------*/
class faFieldDecomposer
{
public:
//- Patch field decomposer class
class patchFieldDecomposer
:
public faPatchFieldMapper
{
// Private data
label sizeBeforeMapping_;
labelList directAddressing_;
public:
// Constructors
//- Construct given addressing
patchFieldDecomposer
(
const label sizeBeforeMapping,
const labelUList& addressingSlice,
const label addressingOffset
);
// Member functions
label size() const
{
return directAddressing_.size();
}
virtual label sizeBeforeMapping() const
{
return sizeBeforeMapping_;
}
bool direct() const
{
return true;
}
virtual bool hasUnmapped() const
{
return false;
}
const labelUList& directAddressing() const
{
return directAddressing_;
}
};
//- Processor patch field decomposer class
class processorAreaPatchFieldDecomposer
:
public faPatchFieldMapper
{
// Private data
label sizeBeforeMapping_;
labelListList addressing_;
scalarListList weights_;
public:
//- Construct given addressing
processorAreaPatchFieldDecomposer
(
const faMesh& mesh,
const labelUList& addressingSlice
);
// Member functions
label size() const
{
return addressing_.size();
}
virtual label sizeBeforeMapping() const
{
return sizeBeforeMapping_;
}
bool direct() const
{
return false;
}
virtual bool hasUnmapped() const
{
return false;
}
const labelListList& addressing() const
{
return addressing_;
}
const scalarListList& weights() const
{
return weights_;
}
};
//- Processor patch field decomposer class
class processorEdgePatchFieldDecomposer
:
public faPatchFieldMapper
{
label sizeBeforeMapping_;
labelListList addressing_;
scalarListList weights_;
public:
//- Construct given addressing
processorEdgePatchFieldDecomposer
(
label sizeBeforeMapping,
const labelUList& addressingSlice
);
// Member functions
label size() const
{
return addressing_.size();
}
virtual label sizeBeforeMapping() const
{
return sizeBeforeMapping_;
}
bool direct() const
{
return false;
}
virtual bool hasUnmapped() const
{
return false;
}
const labelListList& addressing() const
{
return addressing_;
}
const scalarListList& weights() const
{
return weights_;
}
};
private:
// Private data
//- Reference to complete mesh
const faMesh& completeMesh_;
//- Reference to processor mesh
const faMesh& procMesh_;
//- Reference to edge addressing
const labelList& edgeAddressing_;
//- Reference to face addressing
const labelList& faceAddressing_;
//- Reference to boundary addressing
const labelList& boundaryAddressing_;
//- List of patch field decomposers
List<patchFieldDecomposer*> patchFieldDecomposerPtrs_;
List<processorAreaPatchFieldDecomposer*>
processorAreaPatchFieldDecomposerPtrs_;
List<processorEdgePatchFieldDecomposer*>
processorEdgePatchFieldDecomposerPtrs_;
// Private Member Functions
//- Disallow default bitwise copy construct
faFieldDecomposer(const faFieldDecomposer&);
//- Disallow default bitwise assignment
void operator=(const faFieldDecomposer&);
public:
// Constructors
//- Construct from components
faFieldDecomposer
(
const faMesh& completeMesh,
const faMesh& procMesh,
const labelList& edgeAddressing,
const labelList& faceAddressing,
const labelList& boundaryAddressing
);
// Destructor
~faFieldDecomposer();
// Member Functions
//- Decompose area field
template<class Type>
tmp<GeometricField<Type, faPatchField, areaMesh> >
decomposeField
(
const GeometricField<Type, faPatchField, areaMesh>& field
) const;
//- Decompose surface field
template<class Type>
tmp<GeometricField<Type, faePatchField, edgeMesh> >
decomposeField
(
const GeometricField<Type, faePatchField, edgeMesh>& field
) const;
template<class GeoField>
void decomposeFields(const PtrList<GeoField>& fields) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "faFieldDecomposerDecomposeFields.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,237 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "faFieldDecomposer.H"
#include "processorFaPatchField.H"
#include "processorFaePatchField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
tmp<GeometricField<Type, faPatchField, areaMesh> >
faFieldDecomposer::decomposeField
(
const GeometricField<Type, faPatchField, areaMesh>& field
) const
{
// Create and map the internal field values
Field<Type> internalField(field.internalField(), faceAddressing_);
// Create and map the patch field values
PtrList<faPatchField<Type> > patchFields(boundaryAddressing_.size());
forAll (boundaryAddressing_, patchi)
{
if (boundaryAddressing_[patchi] >= 0)
{
patchFields.set
(
patchi,
faPatchField<Type>::New
(
field.boundaryField()[boundaryAddressing_[patchi]],
procMesh_.boundary()[patchi],
DimensionedField<Type, areaMesh>::null(),
*patchFieldDecomposerPtrs_[patchi]
)
);
}
else
{
patchFields.set
(
patchi,
new processorFaPatchField<Type>
(
procMesh_.boundary()[patchi],
DimensionedField<Type, areaMesh>::null(),
Field<Type>
(
field.internalField(),
*processorAreaPatchFieldDecomposerPtrs_[patchi]
)
)
);
}
}
// Create the field for the processor
return tmp<GeometricField<Type, faPatchField, areaMesh> >
(
new GeometricField<Type, faPatchField, areaMesh>
(
IOobject
(
field.name(),
procMesh_.time().timeName(),
procMesh_(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
procMesh_,
field.dimensions(),
internalField,
patchFields
)
);
}
template<class Type>
tmp<GeometricField<Type, faePatchField, edgeMesh> >
faFieldDecomposer::decomposeField
(
const GeometricField<Type, faePatchField, edgeMesh>& field
) const
{
labelList mapAddr
(
labelList::subList
(
edgeAddressing_,
procMesh_.nInternalEdges()
)
);
forAll (mapAddr, i)
{
mapAddr[i] -= 1;
}
// Create and map the internal field values
Field<Type> internalField
(
field.internalField(),
mapAddr
);
// Problem with addressing when a processor patch picks up both internal
// edges and edges from cyclic boundaries. This is a bit of a hack, but
// I cannot find a better solution without making the internal storage
// mechanism for edgeFields correspond to the one of edges in polyMesh
// (i.e. using slices)
Field<Type> allEdgeField(field.mesh().nEdges());
forAll (field.internalField(), i)
{
allEdgeField[i] = field.internalField()[i];
}
forAll (field.boundaryField(), patchi)
{
const Field<Type> & p = field.boundaryField()[patchi];
const label patchStart = field.mesh().boundary()[patchi].start();
forAll (p, i)
{
allEdgeField[patchStart + i] = p[i];
}
}
// Create and map the patch field values
PtrList<faePatchField<Type> > patchFields(boundaryAddressing_.size());
forAll (boundaryAddressing_, patchi)
{
if (boundaryAddressing_[patchi] >= 0)
{
patchFields.set
(
patchi,
faePatchField<Type>::New
(
field.boundaryField()[boundaryAddressing_[patchi]],
procMesh_.boundary()[patchi],
DimensionedField<Type, edgeMesh>::null(),
*patchFieldDecomposerPtrs_[patchi]
)
);
}
else
{
patchFields.set
(
patchi,
new processorFaePatchField<Type>
(
procMesh_.boundary()[patchi],
DimensionedField<Type, edgeMesh>::null(),
Field<Type>
(
allEdgeField,
*processorEdgePatchFieldDecomposerPtrs_[patchi]
)
)
);
}
}
// Create the field for the processor
return tmp<GeometricField<Type, faePatchField, edgeMesh> >
(
new GeometricField<Type, faePatchField, edgeMesh>
(
IOobject
(
field.name(),
procMesh_.time().timeName(),
procMesh_(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
procMesh_,
field.dimensions(),
internalField,
patchFields
)
);
}
template<class GeoField>
void faFieldDecomposer::decomposeFields
(
const PtrList<GeoField>& fields
) const
{
forAll (fields, fieldI)
{
decomposeField(fields[fieldI])().write();
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,178 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
faMeshDecomposition
Description
Automatic faMesh decomposition class
Author
Zeljko Tukovic, FSB Zagreb
Hrvoje Jasak, Wikki Ltd.
SourceFiles
faMeshDecomposition.C
\*---------------------------------------------------------------------------*/
#ifndef faMeshDecomposition_H
#define faMeshDecomposition_H
#include "fvMesh.H"
#include "faMesh.H"
#include "labelList.H"
#include "SLList.H"
#include "PtrList.H"
#include "point.H"
#ifndef namespaceFoam
#define namespaceFoam
using namespace Foam;
#endif
/*---------------------------------------------------------------------------*\
Class faMeshDecomposition Declaration
\*---------------------------------------------------------------------------*/
class faMeshDecomposition
:
public faMesh
{
// Private data
//- Mesh decomposition control dictionary
IOdictionary decompositionDict_;
//- Number of processors in decomposition
label nProcs_;
//- Is the decomposition data to be distributed for each processor
bool distributed_;
//- Processor label for each cell
labelList faceToProc_;
//- Face labels for each processor mesh
labelListList procFaceLabels_;
//-
List<Map<label> > procMeshEdgesMap_;
//- Number of internal edges for each processor mesh
labelList procNInternalEdges_;
//- Edge labels for patches of processor meshes
List<List<List<label> > > procPatchEdgeLabels_;
//- Labels of points for each processor
labelListList procPatchPointAddressing_;
//- Labels of edges for each processor
labelListList procPatchEdgeAddressing_;
//- Labels of edges for each processor
labelListList procEdgeAddressing_;
//- Labels of faces for each processor
labelListList procFaceAddressing_;
//- Original patch index for every processor patch
labelListList procBoundaryAddressing_;
//- Sizes for processor mesh patches
// Excludes inter-processor boundaries
labelListList procPatchSize_;
//- Start indices for processor patches
// Excludes inter-processor boundaries
labelListList procPatchStartIndex_;
//- Neighbour processor ID for inter-processor boundaries
labelListList procNeighbourProcessors_;
//- Sizes for inter-processor patches
labelListList procProcessorPatchSize_;
//- Start indices for inter-processor patches
labelListList procProcessorPatchStartIndex_;
//- List of globally shared point labels
labelList globallySharedPoints_;
//- Are there cyclic-parallel faces
bool cyclicParallel_;
// Private Member Functions
void distributeFaces();
public:
// Constructors
//- Construct from fvMesh
faMeshDecomposition(const fvMesh& mesh);
// Destructor
~faMeshDecomposition();
// Member Functions
//- Number of processor in decomposition
label nProcs() const
{
return nProcs_;
}
//- Is the decomposition data to be distributed for each processor
bool distributed() const
{
return distributed_;
}
//- Decompose mesh
void decomposeMesh();
//- Write decomposition
bool writeDecomposition();
//- Cell-processor decomposition labels
const labelList& faceToProc() const
{
return faceToProc_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,3 +1,5 @@
processorFaMeshes.C
faFieldReconstructor.C
reconstructPar.C
EXE = $(FOAM_APPBIN)/reconstructPar

View File

@ -1,5 +1,6 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/finiteArea/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
@ -10,6 +11,7 @@ EXE_LIBS = \
-lfiniteVolume \
-lgenericPatchFields \
-llagrangian \
-lfiniteArea \
-ldynamicMesh \
-lmeshTools \
-lreconstruct \

View File

@ -0,0 +1,49 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "faFieldReconstructor.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::faFieldReconstructor::faFieldReconstructor
(
faMesh& mesh,
const PtrList<faMesh>& procMeshes,
const PtrList<labelIOList>& edgeProcAddressing,
const PtrList<labelIOList>& faceProcAddressing,
const PtrList<labelIOList>& boundaryProcAddressing
)
:
mesh_(mesh),
procMeshes_(procMeshes),
edgeProcAddressing_(edgeProcAddressing),
faceProcAddressing_(faceProcAddressing),
boundaryProcAddressing_(boundaryProcAddressing)
{}
// ************************************************************************* //

View File

@ -0,0 +1,205 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
faFieldReconstructor
Description
FA area and edge field reconstructor.
Author
Zeljko Tukovic, FSB Zagreb
Hrvoje Jasak, Wikki Ltd.
SourceFiles
faFieldReconstructor.C
faFieldReconstructorReconstructFields.C
\*---------------------------------------------------------------------------*/
#ifndef faFieldReconstructor_H
#define faFieldReconstructor_H
#include "PtrList.H"
#include "faMesh.H"
#include "IOobjectList.H"
#include "faPatchFieldMapper.H"
#include "labelIOList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class faFieldReconstructor Declaration
\*---------------------------------------------------------------------------*/
class faFieldReconstructor
{
// Private data
//- Reconstructed mesh reference
faMesh& mesh_;
//- List of processor meshes
const PtrList<faMesh>& procMeshes_;
//- List of processor edge addressing lists
const PtrList<labelIOList>& edgeProcAddressing_;
//- List of processor face addressing lists
const PtrList<labelIOList>& faceProcAddressing_;
//- List of processor boundary addressing lists
const PtrList<labelIOList>& boundaryProcAddressing_;
// Private Member Functions
//- Disallow default bitwise copy construct
faFieldReconstructor(const faFieldReconstructor&);
//- Disallow default bitwise assignment
void operator=(const faFieldReconstructor&);
public:
class faPatchFieldReconstructor
:
public faPatchFieldMapper
{
label size_;
label sizeBeforeMapping_;
public:
// Constructors
//- Construct given size
faPatchFieldReconstructor
(
const label size,
const label sizeBeforeMapping
)
:
size_(size),
sizeBeforeMapping_(sizeBeforeMapping)
{}
// Member functions
virtual label size() const
{
return size_;
}
virtual label sizeBeforeMapping() const
{
return sizeBeforeMapping_;
}
virtual bool direct() const
{
return true;
}
virtual bool hasUnmapped() const
{
return false;
}
virtual const labelUList& directAddressing() const
{
return labelUList::null();
}
};
// Constructors
//- Construct from components
faFieldReconstructor
(
faMesh& mesh,
const PtrList<faMesh>& procMeshes,
const PtrList<labelIOList>& edgeProcAddressing,
const PtrList<labelIOList>& faceProcAddressing,
const PtrList<labelIOList>& boundaryProcAddressing
);
// Member Functions
//- Reconstruct area field
template<class Type>
tmp<GeometricField<Type, faPatchField, areaMesh> >
reconstructFaAreaField
(
const IOobject& fieldIoObject
);
//- Reconstruct edge field
template<class Type>
tmp<GeometricField<Type, faePatchField, edgeMesh> >
reconstructFaEdgeField
(
const IOobject& fieldIoObject
);
//- Reconstruct and write all area fields
template<class Type>
void reconstructFaAreaFields
(
const IOobjectList& objects
);
//- Reconstruct and write all area fields
template<class Type>
void reconstructFaEdgeFields
(
const IOobjectList& objects
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "faFieldReconstructorReconstructFields.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,642 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "faFieldReconstructor.H"
#include "Time.H"
#include "PtrList.H"
#include "faPatchFields.H"
#include "emptyFaPatch.H"
#include "emptyFaPatchField.H"
#include "emptyFaePatchField.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::faPatchField, Foam::areaMesh> >
Foam::faFieldReconstructor::reconstructFaAreaField
(
const IOobject& fieldIoObject
)
{
// Read the field for all the processors
PtrList<GeometricField<Type, faPatchField, areaMesh> > procFields
(
procMeshes_.size()
);
forAll (procMeshes_, procI)
{
procFields.set
(
procI,
new GeometricField<Type, faPatchField, areaMesh>
(
IOobject
(
fieldIoObject.name(),
procMeshes_[procI].time().timeName(),
procMeshes_[procI](),
IOobject::MUST_READ,
IOobject::NO_WRITE
),
procMeshes_[procI]
)
);
}
// Create the internalField
Field<Type> internalField(mesh_.nFaces());
// Create the patch fields
PtrList<faPatchField<Type> > patchFields(mesh_.boundary().size());
// Create global mesh patchs starts
labelList gStarts(mesh_.boundary().size(), -1);
if (mesh_.boundary().size() > 0)
{
gStarts[0] = mesh_.nInternalEdges();
}
for(label i=1; i<mesh_.boundary().size(); i++)
{
gStarts[i] = gStarts[i-1] + mesh_.boundary()[i-1].labelList::size();
}
forAll (procMeshes_, procI)
{
const GeometricField<Type, faPatchField, areaMesh>& procField =
procFields[procI];
// Set the face values in the reconstructed field
internalField.rmap
(
procField.internalField(),
faceProcAddressing_[procI]
);
// Set the boundary patch values in the reconstructed field
labelList starts(procMeshes_[procI].boundary().size(), -1);
if(procMeshes_[procI].boundary().size() > 0)
{
starts[0] = procMeshes_[procI].nInternalEdges();
}
for(label i=1; i<procMeshes_[procI].boundary().size(); i++)
{
starts[i] =
starts[i-1]
+ procMeshes_[procI].boundary()[i-1].labelList::size();
}
forAll(boundaryProcAddressing_[procI], patchI)
{
// Get patch index of the original patch
const label curBPatch = boundaryProcAddressing_[procI][patchI];
// Get addressing slice for this patch
// const labelList::subList cp =
// procMeshes_[procI].boundary()[patchI].patchSlice
// (
// edgeProcAddressing_[procI]
// );
const labelList::subList cp =
labelList::subList
(
edgeProcAddressing_[procI],
procMeshes_[procI].boundary()[patchI].size(),
starts[patchI]
);
// check if the boundary patch is not a processor patch
if (curBPatch >= 0)
{
// Regular patch. Fast looping
if (!patchFields(curBPatch))
{
patchFields.set
(
curBPatch,
faPatchField<Type>::New
(
procField.boundaryField()[patchI],
mesh_.boundary()[curBPatch],
DimensionedField<Type, areaMesh>::null(),
faPatchFieldReconstructor
(
mesh_.boundary()[curBPatch].size(),
procField.boundaryField()[patchI].size()
)
)
);
}
const label curPatchStart = gStarts[curBPatch];
// mesh_.boundary()[curBPatch].start();
labelList reverseAddressing(cp.size());
forAll(cp, edgeI)
{
// Subtract one to take into account offsets for
// face direction.
// reverseAddressing[edgeI] = cp[edgeI] - 1 - curPatchStart;
reverseAddressing[edgeI] = cp[edgeI] - curPatchStart;
}
patchFields[curBPatch].rmap
(
procField.boundaryField()[patchI],
reverseAddressing
);
}
else
{
const Field<Type>& curProcPatch =
procField.boundaryField()[patchI];
// In processor patches, there's a mix of internal faces (some
// of them turned) and possible cyclics. Slow loop
forAll(cp, edgeI)
{
// Subtract one to take into account offsets for
// face direction.
// label curE = cp[edgeI] - 1;
label curE = cp[edgeI];
// Is the face on the boundary?
if (curE >= mesh_.nInternalEdges())
{
// label curBPatch = mesh_.boundary().whichPatch(curE);
label curBPatch = -1;
forAll (mesh_.boundary(), pI)
{
if
(
curE >= gStarts[pI]
&& curE <
(
gStarts[pI]
+ mesh_.boundary()[pI].labelList::size()
)
)
{
curBPatch = pI;
}
}
if (!patchFields(curBPatch))
{
patchFields.set
(
curBPatch,
faPatchField<Type>::New
(
mesh_.boundary()[curBPatch].type(),
mesh_.boundary()[curBPatch],
DimensionedField<Type, areaMesh>::null()
)
);
}
// add the edge
// label curPatchEdge =
// mesh_.boundary()
// [curBPatch].whichEdge(curE);
label curPatchEdge = curE - gStarts[curBPatch];
patchFields[curBPatch][curPatchEdge] =
curProcPatch[edgeI];
}
}
}
}
}
forAll(mesh_.boundary(), patchI)
{
// add empty patches
if
(
typeid(mesh_.boundary()[patchI]) == typeid(emptyFaPatch)
&& !patchFields(patchI)
)
{
patchFields.set
(
patchI,
faPatchField<Type>::New
(
emptyFaPatchField<Type>::typeName,
mesh_.boundary()[patchI],
DimensionedField<Type, areaMesh>::null()
)
);
}
}
// Now construct and write the field
// setting the internalField and patchFields
return tmp<GeometricField<Type, faPatchField, areaMesh> >
(
new GeometricField<Type, faPatchField, areaMesh>
(
IOobject
(
fieldIoObject.name(),
mesh_.time().timeName(),
mesh_(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
procFields[0].dimensions(),
internalField,
patchFields
)
);
}
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::faePatchField, Foam::edgeMesh> >
Foam::faFieldReconstructor::reconstructFaEdgeField
(
const IOobject& fieldIoObject
)
{
// Read the field for all the processors
PtrList<GeometricField<Type, faePatchField, edgeMesh> > procFields
(
procMeshes_.size()
);
forAll (procMeshes_, procI)
{
procFields.set
(
procI,
new GeometricField<Type, faePatchField, edgeMesh>
(
IOobject
(
fieldIoObject.name(),
procMeshes_[procI].time().timeName(),
procMeshes_[procI](),
IOobject::MUST_READ,
IOobject::NO_WRITE
),
procMeshes_[procI]
)
);
}
// Create the internalField
Field<Type> internalField(mesh_.nInternalEdges());
// Create the patch fields
PtrList<faePatchField<Type> > patchFields(mesh_.boundary().size());
labelList gStarts(mesh_.boundary().size(), -1);
if(mesh_.boundary().size() > 0)
{
gStarts[0] = mesh_.nInternalEdges();
}
for(label i=1; i<mesh_.boundary().size(); i++)
{
gStarts[i] = gStarts[i-1] + mesh_.boundary()[i-1].labelList::size();
}
forAll (procMeshes_, procI)
{
const GeometricField<Type, faePatchField, edgeMesh>& procField =
procFields[procI];
// Set the face values in the reconstructed field
// It is necessary to create a copy of the addressing array to
// take care of the face direction offset trick.
//
{
labelList curAddr(edgeProcAddressing_[procI]);
// forAll (curAddr, addrI)
// {
// curAddr[addrI] -= 1;
// }
internalField.rmap
(
procField.internalField(),
curAddr
);
}
// Set the boundary patch values in the reconstructed field
labelList starts(procMeshes_[procI].boundary().size(), -1);
if(procMeshes_[procI].boundary().size() > 0)
{
starts[0] = procMeshes_[procI].nInternalEdges();
}
for(label i=1; i<procMeshes_[procI].boundary().size(); i++)
{
starts[i] =
starts[i-1]
+ procMeshes_[procI].boundary()[i-1].labelList::size();
}
forAll(boundaryProcAddressing_[procI], patchI)
{
// Get patch index of the original patch
const label curBPatch = boundaryProcAddressing_[procI][patchI];
// Get addressing slice for this patch
// const labelList::subList cp =
// procMeshes_[procI].boundary()[patchI].patchSlice
// (
// faceProcAddressing_[procI]
// );
const labelList::subList cp =
labelList::subList
(
edgeProcAddressing_[procI],
procMeshes_[procI].boundary()[patchI].size(),
starts[patchI]
);
// check if the boundary patch is not a processor patch
if (curBPatch >= 0)
{
// Regular patch. Fast looping
if (!patchFields(curBPatch))
{
patchFields.set
(
curBPatch,
faePatchField<Type>::New
(
procField.boundaryField()[patchI],
mesh_.boundary()[curBPatch],
DimensionedField<Type, edgeMesh>::null(),
faPatchFieldReconstructor
(
mesh_.boundary()[curBPatch].size(),
procField.boundaryField()[patchI].size()
)
)
);
}
const label curPatchStart = gStarts[curBPatch];
// mesh_.boundary()[curBPatch].start();
labelList reverseAddressing(cp.size());
forAll(cp, edgeI)
{
// Subtract one to take into account offsets for
// face direction.
// reverseAddressing[faceI] = cp[faceI] - 1 - curPatchStart;
reverseAddressing[edgeI] = cp[edgeI] - curPatchStart;
}
patchFields[curBPatch].rmap
(
procField.boundaryField()[patchI],
reverseAddressing
);
}
else
{
const Field<Type>& curProcPatch =
procField.boundaryField()[patchI];
// In processor patches, there's a mix of internal faces (some
// of them turned) and possible cyclics. Slow loop
forAll(cp, edgeI)
{
// label curF = cp[edgeI] - 1;
label curE = cp[edgeI];
// Is the face turned the right side round
if (curE >= 0)
{
// Is the face on the boundary?
if (curE >= mesh_.nInternalEdges())
{
// label curBPatch =
// mesh_.boundary().whichPatch(curF);
label curBPatch = -1;
forAll (mesh_.boundary(), pI)
{
if
(
curE >= gStarts[pI]
&& curE <
(
gStarts[pI]
+ mesh_.boundary()[pI].labelList::size()
)
)
{
curBPatch = pI;
}
}
if (!patchFields(curBPatch))
{
patchFields.set
(
curBPatch,
faePatchField<Type>::New
(
mesh_.boundary()[curBPatch].type(),
mesh_.boundary()[curBPatch],
DimensionedField<Type, edgeMesh>
::null()
)
);
}
// add the face
// label curPatchFace =
// mesh_.boundary()
// [curBPatch].whichEdge(curF);
label curPatchEdge = curE - gStarts[curBPatch];
patchFields[curBPatch][curPatchEdge] =
curProcPatch[edgeI];
}
else
{
// Internal face
internalField[curE] = curProcPatch[edgeI];
}
}
}
}
}
}
forAll(mesh_.boundary(), patchI)
{
// add empty patches
if
(
typeid(mesh_.boundary()[patchI]) == typeid(emptyFaPatch)
&& !patchFields(patchI)
)
{
patchFields.set
(
patchI,
faePatchField<Type>::New
(
emptyFaePatchField<Type>::typeName,
mesh_.boundary()[patchI],
DimensionedField<Type, edgeMesh>::null()
)
);
}
}
// Now construct and write the field
// setting the internalField and patchFields
return tmp<GeometricField<Type, faePatchField, edgeMesh> >
(
new GeometricField<Type, faePatchField, edgeMesh>
(
IOobject
(
fieldIoObject.name(),
mesh_.time().timeName(),
mesh_(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
procFields[0].dimensions(),
internalField,
patchFields
)
);
}
// Reconstruct and write all area fields
template<class Type>
void Foam::faFieldReconstructor::reconstructFaAreaFields
(
const IOobjectList& objects
)
{
const word& fieldClassName =
GeometricField<Type, faPatchField, areaMesh>::typeName;
IOobjectList fields = objects.lookupClass(fieldClassName);
if (fields.size())
{
Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
for
(
IOobjectList::const_iterator fieldIter = fields.begin();
fieldIter != fields.end();
++fieldIter
)
{
Info << " " << fieldIter()->name() << endl;
reconstructFaAreaField<Type>(*fieldIter())().write();
}
Info<< endl;
}
}
// Reconstruct and write all edge fields
template<class Type>
void Foam::faFieldReconstructor::reconstructFaEdgeFields
(
const IOobjectList& objects
)
{
const word& fieldClassName =
GeometricField<Type, faePatchField, edgeMesh>::typeName;
IOobjectList fields = objects.lookupClass(fieldClassName);
if (fields.size())
{
Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
for
(
IOobjectList::const_iterator fieldIter = fields.begin();
fieldIter != fields.end();
++fieldIter
)
{
Info<< " " << fieldIter()->name() << endl;
reconstructFaEdgeField<Type>(*fieldIter())().write();
}
Info<< endl;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,260 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "processorFaMeshes.H"
#include "Time.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::processorFaMeshes::read()
{
forAll (fvMeshes_, procI)
{
meshes_.set
(
procI,
new faMesh(fvMeshes_[procI])
);
pointProcAddressing_.set
(
procI,
new labelIOList
(
IOobject
(
"pointProcAddressing",
meshes_[procI].time().findInstance
(
meshes_[procI].meshDir(),
"pointProcAddressing"
),
meshes_[procI].meshSubDir,
fvMeshes_[procI],
IOobject::MUST_READ,
IOobject::NO_WRITE
)
)
);
edgeProcAddressing_.set
(
procI,
new labelIOList
(
IOobject
(
"edgeProcAddressing",
meshes_[procI].time().findInstance
(
meshes_[procI].meshDir(),
"edgeProcAddressing"
),
meshes_[procI].meshSubDir,
fvMeshes_[procI],
IOobject::MUST_READ,
IOobject::NO_WRITE
)
)
);
faceProcAddressing_.set
(
procI,
new labelIOList
(
IOobject
(
"faceProcAddressing",
meshes_[procI].time().findInstance
(
meshes_[procI].meshDir(),
"faceProcAddressing"
),
meshes_[procI].meshSubDir,
fvMeshes_[procI],
IOobject::MUST_READ,
IOobject::NO_WRITE
)
)
);
boundaryProcAddressing_.set
(
procI,
new labelIOList
(
IOobject
(
"boundaryProcAddressing",
meshes_[procI].time().findInstance
(
meshes_[procI].meshDir(),
"faceProcAddressing"
),
meshes_[procI].meshSubDir,
fvMeshes_[procI],
IOobject::MUST_READ,
IOobject::NO_WRITE
)
)
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::processorFaMeshes::processorFaMeshes
(
const PtrList<fvMesh>& processorFvMeshes
)
:
fvMeshes_(processorFvMeshes),
meshes_(processorFvMeshes.size()),
pointProcAddressing_(processorFvMeshes.size()),
edgeProcAddressing_(processorFvMeshes.size()),
faceProcAddressing_(processorFvMeshes.size()),
boundaryProcAddressing_(processorFvMeshes.size())
{
read();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Foam::fvMesh::readUpdateState Foam::processorFaMeshes::readUpdate()
// {
// fvMesh::readUpdateState stat = fvMesh::UNCHANGED;
// forAll (databases_, procI)
// {
// // Check if any new meshes need to be read.
// fvMesh::readUpdateState procStat = meshes_[procI].readUpdate();
// /*
// if (procStat != fvMesh::UNCHANGED)
// {
// Info<< "Processor " << procI
// << " at time " << databases_[procI].timeName()
// << " detected mesh change " << procStat
// << endl;
// }
// */
// // Combine into overall mesh change status
// if (stat == fvMesh::UNCHANGED)
// {
// stat = procStat;
// }
// else
// {
// if (stat != procStat)
// {
// FatalErrorIn("processorFaMeshes::readUpdate()")
// << "Processor " << procI
// << " has a different polyMesh at time "
// << databases_[procI].timeName()
// << " compared to any previous processors." << nl
// << "Please check time " << databases_[procI].timeName()
// << " directories on all processors for consistent"
// << " mesh files."
// << exit(FatalError);
// }
// }
// }
// if
// (
// stat == fvMesh::TOPO_CHANGE
// || stat == fvMesh::TOPO_PATCH_CHANGE
// )
// {
// // Reread all meshes and addresssing
// read();
// }
// return stat;
// }
// void Foam::processorFaMeshes::reconstructPoints(fvMesh& mesh)
// {
// // Read the field for all the processors
// PtrList<pointIOField> procsPoints(meshes_.size());
// forAll (meshes_, procI)
// {
// procsPoints.set
// (
// procI,
// new pointIOField
// (
// IOobject
// (
// "points",
// meshes_[procI].time().timeName(),
// polyMesh::meshSubDir,
// meshes_[procI],
// IOobject::MUST_READ,
// IOobject::NO_WRITE
// )
// )
// );
// }
// // Create the new points
// vectorField newPoints(mesh.nPoints());
// forAll (meshes_, procI)
// {
// const vectorField& procPoints = procsPoints[procI];
// // Set the cell values in the reconstructed field
// const labelList& pointProcAddressingI = pointProcAddressing_[procI];
// if (pointProcAddressingI.size() != procPoints.size())
// {
// FatalErrorIn("processorFaMeshes")
// << "problem :"
// << " pointProcAddressingI:" << pointProcAddressingI.size()
// << " procPoints:" << procPoints.size()
// << abort(FatalError);
// }
// forAll(pointProcAddressingI, pointI)
// {
// newPoints[pointProcAddressingI[pointI]] = procPoints[pointI];
// }
// }
// mesh.movePoints(newPoints);
// mesh.write();
// }
// ************************************************************************* //

View File

@ -0,0 +1,142 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
processorFaMeshes
Description
Container for processor mesh addressing.
Author
Zeljko Tukovic, FSB Zagreb
SourceFiles
processorFaMeshes.C
\*---------------------------------------------------------------------------*/
#ifndef processorFaMeshes_H
#define processorFaMeshes_H
#include "PtrList.H"
#include "fvMesh.H"
#include "faMesh.H"
#include "IOobjectList.H"
#include "labelIOList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class processorFaMeshes Declaration
\*---------------------------------------------------------------------------*/
class processorFaMeshes
{
// Private data
//- List of processor finite volume meshes
const PtrList<fvMesh>& fvMeshes_;
//- List of processor finite area meshes
PtrList<faMesh> meshes_;
//- List of processor point addressing lists
PtrList<labelIOList> pointProcAddressing_;
//- List of processor face addressing lists
PtrList<labelIOList> edgeProcAddressing_;
//- List of processor cell addressing lists
PtrList<labelIOList> faceProcAddressing_;
//- List of processor boundary addressing lists
PtrList<labelIOList> boundaryProcAddressing_;
// Private Member Functions
//- Read all meshes
void read();
//- Disallow default bitwise copy construct
processorFaMeshes(const processorFaMeshes&);
//- Disallow default bitwise assignment
void operator=(const processorFaMeshes&);
public:
// Constructors
//- Construct from components
processorFaMeshes(const PtrList<fvMesh>& processorFvMeshes);
// Member Functions
//- Update the meshes based on the mesh files saved in
// time directories
// fvMesh::readUpdateState readUpdate();
//- Reconstruct point position after motion in parallel
// void reconstructPoints(faMesh& mesh);
PtrList<faMesh>& meshes()
{
return meshes_;
}
const PtrList<labelIOList>& pointProcAddressing() const
{
return pointProcAddressing_;
}
PtrList<labelIOList>& edgeProcAddressing()
{
return edgeProcAddressing_;
}
const PtrList<labelIOList>& faceProcAddressing() const
{
return faceProcAddressing_;
}
const PtrList<labelIOList>& boundaryProcAddressing() const
{
return boundaryProcAddressing_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -44,6 +44,11 @@ Description
#include "pointFieldReconstructor.H"
#include "reconstructLagrangian.H"
#include "faCFD.H"
#include "faMesh.H"
#include "processorFaMeshes.H"
#include "faFieldReconstructor.H"
#include "cellSet.H"
#include "faceSet.H"
#include "pointSet.H"
@ -710,6 +715,47 @@ int main(int argc, char *argv[])
}
// If there are any FA fields, reconstruct them
if
(
objects.lookupClass(areaScalarField::typeName).size()
|| objects.lookupClass(areaVectorField::typeName).size()
|| objects.lookupClass(areaSphericalTensorField::typeName).size()
|| objects.lookupClass(areaSymmTensorField::typeName).size()
|| objects.lookupClass(areaTensorField::typeName).size()
|| objects.lookupClass(edgeScalarField::typeName).size()
)
{
Info << "Reconstructing FA fields" << nl << endl;
faMesh aMesh(mesh);
processorFaMeshes procFaMeshes(procMeshes.meshes());
faFieldReconstructor faReconstructor
(
aMesh,
procFaMeshes.meshes(),
procFaMeshes.edgeProcAddressing(),
procFaMeshes.faceProcAddressing(),
procFaMeshes.boundaryProcAddressing()
);
faReconstructor.reconstructFaAreaFields<scalar>(objects);
faReconstructor.reconstructFaAreaFields<vector>(objects);
faReconstructor
.reconstructFaAreaFields<sphericalTensor>(objects);
faReconstructor.reconstructFaAreaFields<symmTensor>(objects);
faReconstructor.reconstructFaAreaFields<tensor>(objects);
faReconstructor.reconstructFaEdgeFields<scalar>(objects);
}
else
{
Info << "No FA fields" << nl << endl;
}
if (!noReconstructSets)
{
// Scan to find all sets

View File

@ -147,6 +147,12 @@ cleanUcomponents()
}
cleanFaMesh ()
{
rm -rf ./constant/faMesh/{faceLabels*,faBoundary*} \
> /dev/null 2>&1
}
cleanApplication()
{
echo "Cleaning application $PWD"

View File

@ -42,6 +42,8 @@ wmake $targetType lagrangian/basic
wmake $targetType lagrangian/distributionModels
wmake $targetType genericPatchFields
wmake $targetType finiteArea
conversion/Allwmake $targetType $*
wmake $targetType mesh/extrudeModel
wmake $targetType dynamicMesh

125
src/finiteArea/Make/files Normal file
View File

@ -0,0 +1,125 @@
faMesh/faGlobalMeshData/faGlobalMeshData.C
faMesh/faMesh.C
faMesh/faMeshDemandDrivenData.C
faMesh/faMeshUpdate.C
faMesh/faBoundaryMesh/faBoundaryMesh.C
faPatches = faMesh/faPatches
$(faPatches)/faPatch/faPatch.C
$(faPatches)/faPatch/newFaPatch.C
$(faPatches)/basic/coupled/coupledFaPatch.C
$(faPatches)/constraint/empty/emptyFaPatch.C
$(faPatches)/constraint/processor/processorFaPatch.C
$(faPatches)/constraint/wedge/wedgeFaPatch.C
$(faPatches)/constraint/cyclic/cyclicFaPatch.C
$(faPatches)/constraint/symmetry/symmetryFaPatch.C
faMeshMapper = faMesh/faMeshMapper
$(faMeshMapper)/faMeshMapper.C
$(faMeshMapper)/faAreaMapper.C
$(faMeshMapper)/faEdgeMapper.C
$(faMeshMapper)/faPatchMapper.C
faPatchFields = fields/faPatchFields
$(faPatchFields)/faPatchField/faPatchFields.C
basicFaPatchFields = $(faPatchFields)/basic
$(basicFaPatchFields)/basicSymmetry/basicSymmetryFaPatchFields.C
$(basicFaPatchFields)/basicSymmetry/basicSymmetryFaPatchScalarField.C
$(basicFaPatchFields)/calculated/calculatedFaPatchFields.C
$(basicFaPatchFields)/coupled/coupledFaPatchFields.C
$(basicFaPatchFields)/zeroGradient/zeroGradientFaPatchFields.C
$(basicFaPatchFields)/fixedValue/fixedValueFaPatchFields.C
$(basicFaPatchFields)/fixedGradient/fixedGradientFaPatchFields.C
$(basicFaPatchFields)/mixed/mixedFaPatchFields.C
$(basicFaPatchFields)/transform/transformFaPatchFields.C
$(basicFaPatchFields)/transform/transformFaPatchScalarField.C
constraintFaPatchFields = $(faPatchFields)/constraint
$(constraintFaPatchFields)/empty/emptyFaPatchFields.C
$(constraintFaPatchFields)/processor/processorFaPatchFields.C
$(constraintFaPatchFields)/processor/processorFaPatchScalarField.C
$(constraintFaPatchFields)/wedge/wedgeFaPatchFields.C
$(constraintFaPatchFields)/wedge/wedgeFaPatchScalarField.C
$(constraintFaPatchFields)/cyclic/cyclicFaPatchFields.C
$(constraintFaPatchFields)/symmetry/symmetryFaPatchFields.C
derivedFaPatchFields = $(faPatchFields)/derived
$(derivedFaPatchFields)/fixedValueOutflow/fixedValueOutflowFaPatchFields.C
$(derivedFaPatchFields)/inletOutlet/inletOutletFaPatchFields.C
$(derivedFaPatchFields)/slip/slipFaPatchFields.C
$(derivedFaPatchFields)/edgeNormalFixedValue/edgeNormalFixedValueFaPatchVectorField.C
$(derivedFaPatchFields)/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchFields.C
faePatchFields = fields/faePatchFields
$(faePatchFields)/faePatchField/faePatchFields.C
basicFaePatchFields = $(faePatchFields)/basic
$(basicFaePatchFields)/calculated/calculatedFaePatchFields.C
$(basicFaePatchFields)/coupled/coupledFaePatchFields.C
$(basicFaePatchFields)/fixedValue/fixedValueFaePatchFields.C
constraintFaePatchFields = $(faePatchFields)/constraint
$(constraintFaePatchFields)/empty/emptyFaePatchFields.C
$(constraintFaePatchFields)/processor/processorFaePatchFields.C
$(constraintFaePatchFields)/wedge/wedgeFaePatchFields.C
$(constraintFaePatchFields)/cyclic/cyclicFaePatchFields.C
$(constraintFaePatchFields)/symmetry/symmetryFaePatchFields.C
fields/areaFields/areaFields.C
fields/edgeFields/edgeFields.C
faMatrices/faMatrices.C
faMatrices/faScalarMatrix/faScalarMatrix.C
edgeInterpolation = interpolation/edgeInterpolation
$(edgeInterpolation)/edgeInterpolation.C
$(edgeInterpolation)/edgeInterpolationScheme/edgeInterpolationSchemes.C
schemes = $(edgeInterpolation)/schemes
$(schemes)/linear/linearEdgeInterpolationMake.C
$(schemes)/upwind/upwindEdgeInterpolationMake.C
$(schemes)/linearUpwind/linearUpwindEdgeInterpolationMake.C
$(schemes)/Gamma/GammaEdgeInterpolationMake.C
$(schemes)/blended/blendedEdgeInterpolationMake.C
finiteArea/fa/fa.C
finiteArea/faSchemes/faSchemes.C
ddtSchemes = finiteArea/ddtSchemes
$(ddtSchemes)/faDdtScheme/faDdtSchemes.C
$(ddtSchemes)/steadyStateFaDdtScheme/steadyStateFaDdtSchemes.C
$(ddtSchemes)/EulerFaDdtScheme/EulerFaDdtSchemes.C
$(ddtSchemes)/backwardFaDdtScheme/backwardFaDdtSchemes.C
$(ddtSchemes)/boundedBackwardFaDdtScheme/boundedBackwardFaDdtScheme.C
divSchemes = finiteArea/divSchemes
finiteArea/fam/vectorFamDiv.C
$(divSchemes)/faDivScheme/faDivSchemes.C
$(divSchemes)/gaussFaDivScheme/gaussFaDivSchemes.C
gradSchemes = finiteArea/gradSchemes
$(gradSchemes)/faGradScheme/faGradSchemes.C
$(gradSchemes)/gaussFaGrad/gaussFaGrads.C
$(gradSchemes)/leastSquaresFaGrad/leastSquaresFaVectors.C
$(gradSchemes)/leastSquaresFaGrad/leastSquaresFaGrads.C
limitedGradSchemes = $(gradSchemes)/limitedGradSchemes
$(limitedGradSchemes)/faceLimitedFaGrad/faceLimitedFaGrads.C
$(limitedGradSchemes)/edgeLimitedFaGrad/edgeLimitedFaGrads.C
lnGradSchemes = finiteArea/lnGradSchemes
$(lnGradSchemes)/lnGradScheme/lnGradSchemes.C
$(lnGradSchemes)/correctedLnGrad/correctedLnGrads.C
$(lnGradSchemes)/limitedLnGrad/limitedLnGrads.C
$(lnGradSchemes)/fourthLnGrad/fourthLnGrads.C
laplacianSchemes = finiteArea/laplacianSchemes
$(laplacianSchemes)/faLaplacianScheme/faLaplacianSchemes.C
$(laplacianSchemes)/gaussFaLaplacianScheme/gaussFaLaplacianSchemes.C
convectionSchemes = finiteArea/convectionSchemes
$(convectionSchemes)/faConvectionScheme/faConvectionSchemes.C
$(convectionSchemes)/gaussFaConvectionScheme/gaussFaConvectionSchemes.C
LIB = $(FOAM_LIBBIN)/libfiniteArea

View File

@ -0,0 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude
LIB_LIBS = \
-lmeshTools

View File

@ -0,0 +1,90 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
areaMesh
Description
Mesh data needed to do the Finite Area discretisation.
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
\*---------------------------------------------------------------------------*/
#ifndef areaFaMesh_H
#define areaFaMesh_H
#include "GeoMesh.H"
#include "faMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class areaMesh Declaration
\*---------------------------------------------------------------------------*/
class areaMesh
:
public GeoMesh<faMesh>
{
public:
explicit areaMesh(const faMesh& mesh)
:
GeoMesh<faMesh>(mesh)
{}
label size() const
{
return size(mesh_);
}
static label size(const Mesh& mesh)
{
return mesh.nFaces();
}
const areaVectorField& C()
{
return mesh_.areaCentres();
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,90 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
edgeMesh
Description
Mesh data needed to do the Finite Area discretisation.
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
\*---------------------------------------------------------------------------*/
#ifndef edgeFaMesh_H
#define edgeFaMesh_H
#include "GeoMesh.H"
#include "faMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class edgeMesh Declaration
\*---------------------------------------------------------------------------*/
class edgeMesh
:
public GeoMesh<faMesh>
{
public:
explicit edgeMesh(const faMesh& mesh)
:
GeoMesh<faMesh>(mesh)
{}
label size() const
{
return size(mesh_);
}
static label size(const Mesh& mesh)
{
return mesh.nInternalEdges();
}
const edgeVectorField& C()
{
return mesh_.edgeCentres();
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,48 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Finite-Volume matrix member static data members
\*---------------------------------------------------------------------------*/
#include "faMatrices.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTemplateTypeNameAndDebug(faScalarMatrix, 0);
defineTemplateTypeNameAndDebug(faVectorMatrix, 0);
defineTemplateTypeNameAndDebug(faTensorMatrix, 0);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,65 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
faMatrix
Description
A special matrix type and solver, designed for finite area
solutions of scalar equations.
Face addressing is used to make all matrix assembly
and solution loops vectorise.
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
\*---------------------------------------------------------------------------*/
#ifndef faMatrices_H
#define faMatrices_H
#include "faScalarMatrix.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef faMatrix<scalar> faScalarMatrix;
typedef faMatrix<vector> faVectorMatrix;
typedef faMatrix<tensor> faTensorMatrix;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,756 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
faMatrix<Type>
Description
Finite-Area matrix.
SourceFiles
faMatrix.C
faMatrixSolve.C
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
\*---------------------------------------------------------------------------*/
#ifndef faMatrix_H
#define faMatrix_H
#include "areaFields.H"
#include "edgeFields.H"
#include "lduMatrix.H"
#include "tmp.H"
#include "autoPtr.H"
#include "dimensionedTypes.H"
#include "className.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * Forward declaration of template friend fuctions * * * * * * * //
template<class Type>
class faMatrix;
template<class Type>
Ostream& operator<<(Ostream&, const faMatrix<Type>&);
/*---------------------------------------------------------------------------*\
Class faMatrix Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class faMatrix
:
public tmp<faMatrix<Type>>::refCount,
public lduMatrix
{
// Private data
// Reference to GeometricField<Type, faPatchField, areaMesh>
const GeometricField<Type, faPatchField, areaMesh>& psi_;
//- Dimension set
dimensionSet dimensions_;
//- Source term
Field<Type> source_;
//- Boundary scalar field containing pseudo-matrix coeffs
// for internal faces
FieldField<Field, Type> internalCoeffs_;
//- Boundary scalar field containing pseudo-matrix coeffs
// for boundary faces
FieldField<Field, Type> boundaryCoeffs_;
//- Face flux field for non-orthogonal correction
mutable GeometricField<Type, faePatchField, edgeMesh>
*faceFluxCorrectionPtr_;
// Private member functions
//- Add patch contribution to internal field
template<class Type2>
void addToInternalField
(
const labelUList& addr,
const Field<Type2>& pf,
Field<Type2>& intf
) const;
template<class Type2>
void addToInternalField
(
const labelUList& addr,
const tmp<Field<Type2> >& tpf,
Field<Type2>& intf
) const;
//- Subtract patch contribution from internal field
template<class Type2>
void subtractFromInternalField
(
const labelUList& addr,
const Field<Type2>& pf,
Field<Type2>& intf
) const;
template<class Type2>
void subtractFromInternalField
(
const labelUList& addr,
const tmp<Field<Type2> >& tpf,
Field<Type2>& intf
) const;
// Matrix completion functionality
void addBoundaryDiag
(
scalarField& diag,
const direction cmpt
) const;
void addCmptAvBoundaryDiag(scalarField& diag) const;
void addBoundarySource
(
Field<Type>& source,
const bool couples = true
) const;
public:
//- Solver class returned by the solver function
class faSolver
{
faMatrix<Type>& faMat_;
autoPtr<lduMatrix::solver> solver_;
public:
// Constructors
faSolver(faMatrix<Type>& faMat, autoPtr<lduMatrix::solver> sol)
:
faMat_(faMat),
solver_(sol)
{}
// Member functions
//- Solve returning the solution statistics.
// Solver controls read from dictionary
SolverPerformance<Type> solve(const dictionary&);
//- Solve returning the solution statistics.
// Solver controls read from faSolution
SolverPerformance<Type> solve();
};
ClassName("faMatrix");
// Constructors
//- Construct given a field to solve for
faMatrix
(
const GeometricField<Type, faPatchField, areaMesh>&,
const dimensionSet&
);
//- Construct as copy
faMatrix(const faMatrix<Type>&);
//- Construct from Istream given field to solve for
faMatrix
(
const GeometricField<Type, faPatchField, areaMesh>&,
Istream&
);
//- Destructor
virtual ~faMatrix();
// Member functions
// Access
const GeometricField<Type, faPatchField, areaMesh>& psi() const
{
return psi_;
}
const dimensionSet& dimensions() const
{
return dimensions_;
}
Field<Type>& source()
{
return source_;
}
const Field<Type>& source() const
{
return source_;
}
//- faBoundary scalar field containing pseudo-matrix coeffs
// for internal cells
FieldField<Field, Type>& internalCoeffs()
{
return internalCoeffs_;
}
//- faBoundary scalar field containing pseudo-matrix coeffs
// for boundary cells
FieldField<Field, Type>& boundaryCoeffs()
{
return boundaryCoeffs_;
}
//- Declare return type of the faceFluxCorrectionPtr() function
typedef GeometricField<Type, faePatchField, edgeMesh>
*edgeTypeFieldPtr;
//- Return pointer to face-flux non-orthogonal correction field
edgeTypeFieldPtr& faceFluxCorrectionPtr()
{
return faceFluxCorrectionPtr_;
}
// Operations
//- Set solution in given cells and eliminate corresponding
// equations from the matrix
void setValues
(
const labelUList& faces,
const UList<Type>& values
);
//- Set reference level for solution
void setReference
(
const label facei,
const Type& value
);
//- Set reference level for a component of the solution
// on a given patch face
void setComponentReference
(
const label patchi,
const label facei,
const direction cmpt,
const scalar value
);
//- Relax matrix (for steady-state solution).
// alpha = 1 : diagonally equal
// alpha < 1 : ,, dominant
// alpha = 0 : do nothing
void relax(const scalar alpha);
//- Relax matrix (for steadty-state solution).
// alpha is read from controlDict
void relax();
//- Solve returning the solution statistics.
// Solver controls read Istream
SolverPerformance<Type> solve(const dictionary&);
//- Solve returning the solution statistics.
// Solver controls read from faSolution
SolverPerformance<Type> solve();
//- Return the matrix residual
tmp<Field<Type> > residual() const;
//- Return the matrix diagonal
tmp<scalarField> D() const;
//- Return the central coefficient
tmp<areaScalarField> A() const;
//- Return the H operation source
tmp<GeometricField<Type, faPatchField, areaMesh> > H() const;
//- Return the face-flux field from the matrix
tmp<GeometricField<Type, faePatchField, edgeMesh> > flux() const;
// Member operators
void operator=(const faMatrix<Type>&);
void operator=(const tmp<faMatrix<Type> >&);
void negate();
void operator+=(const faMatrix<Type>&);
void operator+=(const tmp<faMatrix<Type> >&);
void operator-=(const faMatrix<Type>&);
void operator-=(const tmp<faMatrix<Type> >&);
void operator+=(const GeometricField<Type,faPatchField,areaMesh>&);
void operator+=(const tmp<GeometricField<Type,faPatchField,areaMesh> >&);
void operator-=(const GeometricField<Type,faPatchField,areaMesh>&);
void operator-=(const tmp<GeometricField<Type,faPatchField,areaMesh> >&);
void operator+=(const dimensioned<Type>&);
void operator-=(const dimensioned<Type>&);
void operator*=(const areaScalarField&);
void operator*=(const tmp<areaScalarField>&);
void operator*=(const dimensioned<scalar>&);
// Ostream operator
friend Ostream& operator<< <Type>
(
Ostream&,
const faMatrix<Type>&
);
};
// * * * * * * * * * * * * * * * Global functions * * * * * * * * * * * * * //
template<class Type>
void checkMethod
(
const faMatrix<Type>&,
const faMatrix<Type>&,
const char*
);
template<class Type>
void checkMethod
(
const faMatrix<Type>&,
const GeometricField<Type, faPatchField, areaMesh>&,
const char*
);
template<class Type>
void checkMethod
(
const faMatrix<Type>&,
const dimensioned<Type>&,
const char*
);
//- Solve returning the solution statistics given convergence tolerance
// Solver controls read Istream
template<class Type>
SolverPerformance<Type> solve(faMatrix<Type>&, Istream&);
//- Solve returning the solution statistics given convergence tolerance,
// deleting temporary matrix after solution.
// Solver controls read Istream
template<class Type>
SolverPerformance<Type> solve(const tmp<faMatrix<Type> >&, Istream&);
//- Solve returning the solution statistics given convergence tolerance
// Solver controls read faSolution
template<class Type>
SolverPerformance<Type> solve(faMatrix<Type>&);
//- Solve returning the solution statistics given convergence tolerance,
// deleting temporary matrix after solution.
// Solver controls read faSolution
template<class Type>
SolverPerformance<Type> solve(const tmp<faMatrix<Type> >&);
// * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * //
template<class Type>
tmp<faMatrix<Type> > operator-
(
const faMatrix<Type>&
);
template<class Type>
tmp<faMatrix<Type> > operator-
(
const tmp<faMatrix<Type> >&
);
template<class Type>
tmp<faMatrix<Type> > operator+
(
const faMatrix<Type>&,
const faMatrix<Type>&
);
template<class Type>
tmp<faMatrix<Type> > operator+
(
const tmp<faMatrix<Type> >&,
const faMatrix<Type>&
);
template<class Type>
tmp<faMatrix<Type> > operator+
(
const faMatrix<Type>&,
const tmp<faMatrix<Type> >&
);
template<class Type>
tmp<faMatrix<Type> > operator+
(
const tmp<faMatrix<Type> >&,
const tmp<faMatrix<Type> >&
);
template<class Type>
tmp<faMatrix<Type> > operator-
(
const faMatrix<Type>&,
const faMatrix<Type>&
);
template<class Type>
tmp<faMatrix<Type> > operator-
(
const tmp<faMatrix<Type> >&,
const faMatrix<Type>&
);
template<class Type>
tmp<faMatrix<Type> > operator-
(
const faMatrix<Type>&,
const tmp<faMatrix<Type> >&
);
template<class Type>
tmp<faMatrix<Type> > operator-
(
const tmp<faMatrix<Type> >&,
const tmp<faMatrix<Type> >&
);
template<class Type>
tmp<faMatrix<Type> > operator==
(
const faMatrix<Type>&,
const faMatrix<Type>&
);
template<class Type>
tmp<faMatrix<Type> > operator==
(
const tmp<faMatrix<Type> >&,
const faMatrix<Type>&
);
template<class Type>
tmp<faMatrix<Type> > operator==
(
const faMatrix<Type>&,
const tmp<faMatrix<Type> >&
);
template<class Type>
tmp<faMatrix<Type> > operator==
(
const tmp<faMatrix<Type> >&,
const tmp<faMatrix<Type> >&
);
template<class Type>
tmp<faMatrix<Type> > operator+
(
const faMatrix<Type>&,
const GeometricField<Type, faPatchField, areaMesh>&
);
template<class Type>
tmp<faMatrix<Type> > operator+
(
const tmp<faMatrix<Type> >&,
const GeometricField<Type, faPatchField, areaMesh>&
);
template<class Type>
tmp<faMatrix<Type> > operator+
(
const faMatrix<Type>&,
const tmp<GeometricField<Type, faPatchField, areaMesh> >&
);
template<class Type>
tmp<faMatrix<Type> > operator+
(
const tmp<faMatrix<Type> >&,
const tmp<GeometricField<Type, faPatchField, areaMesh> >&
);
template<class Type>
tmp<faMatrix<Type> > operator+
(
const GeometricField<Type, faPatchField, areaMesh>&,
const faMatrix<Type>&
);
template<class Type>
tmp<faMatrix<Type> > operator+
(
const GeometricField<Type, faPatchField, areaMesh>&,
const tmp<faMatrix<Type> >&
);
template<class Type>
tmp<faMatrix<Type> > operator+
(
const tmp<GeometricField<Type, faPatchField, areaMesh> >&,
const faMatrix<Type>&
);
template<class Type>
tmp<faMatrix<Type> > operator+
(
const tmp<GeometricField<Type, faPatchField, areaMesh> >&,
const tmp<faMatrix<Type> >&
);
template<class Type>
tmp<faMatrix<Type> > operator-
(
const faMatrix<Type>&,
const GeometricField<Type, faPatchField, areaMesh>&
);
template<class Type>
tmp<faMatrix<Type> > operator-
(
const tmp<faMatrix<Type> >&,
const GeometricField<Type, faPatchField, areaMesh>&
);
template<class Type>
tmp<faMatrix<Type> > operator-
(
const faMatrix<Type>&,
const tmp<GeometricField<Type, faPatchField, areaMesh> >&
);
template<class Type>
tmp<faMatrix<Type> > operator-
(
const tmp<faMatrix<Type> >&,
const tmp<GeometricField<Type, faPatchField, areaMesh> >&
);
template<class Type>
tmp<faMatrix<Type> > operator-
(
const GeometricField<Type, faPatchField, areaMesh>&,
const faMatrix<Type>&
);
template<class Type>
tmp<faMatrix<Type> > operator-
(
const GeometricField<Type, faPatchField, areaMesh>&,
const tmp<faMatrix<Type> >&
);
template<class Type>
tmp<faMatrix<Type> > operator-
(
const tmp<GeometricField<Type, faPatchField, areaMesh> >&,
const faMatrix<Type>&
);
template<class Type>
tmp<faMatrix<Type> > operator-
(
const tmp<GeometricField<Type, faPatchField, areaMesh> >&,
const tmp<faMatrix<Type> >&
);
template<class Type>
tmp<faMatrix<Type> > operator+
(
const tmp<faMatrix<Type> >&,
const dimensioned<Type>&
);
template<class Type>
tmp<faMatrix<Type> > operator+
(
const dimensioned<Type>&,
const tmp<faMatrix<Type> >&
);
template<class Type>
tmp<faMatrix<Type> > operator-
(
const tmp<faMatrix<Type> >&,
const dimensioned<Type>&
);
template<class Type>
tmp<faMatrix<Type> > operator-
(
const dimensioned<Type>&,
const tmp<faMatrix<Type> >&
);
template<class Type>
tmp<faMatrix<Type> > operator==
(
const faMatrix<Type>&,
const GeometricField<Type, faPatchField, areaMesh>&
);
template<class Type>
tmp<faMatrix<Type> > operator==
(
const tmp<faMatrix<Type> >&,
const GeometricField<Type, faPatchField, areaMesh>&
);
template<class Type>
tmp<faMatrix<Type> > operator==
(
const faMatrix<Type>&,
const tmp<GeometricField<Type, faPatchField, areaMesh> >&
);
template<class Type>
tmp<faMatrix<Type> > operator==
(
const tmp<faMatrix<Type> >&,
const tmp<GeometricField<Type, faPatchField, areaMesh> >&
);
template<class Type>
tmp<faMatrix<Type> > operator==
(
const faMatrix<Type>&,
const dimensioned<Type>&
);
template<class Type>
tmp<faMatrix<Type> > operator==
(
const tmp<faMatrix<Type> >&,
const dimensioned<Type>&
);
template<class Type>
tmp<faMatrix<Type> > operator*
(
const areaScalarField&,
const faMatrix<Type>&
);
template<class Type>
tmp<faMatrix<Type> > operator*
(
const areaScalarField&,
const tmp<faMatrix<Type> >&
);
template<class Type>
tmp<faMatrix<Type> > operator*
(
const tmp<areaScalarField>&,
const faMatrix<Type>&
);
template<class Type>
tmp<faMatrix<Type> > operator*
(
const tmp<areaScalarField>&,
const tmp<faMatrix<Type> >&
);
template<class Type>
tmp<faMatrix<Type> > operator*
(
const dimensioned<scalar>&,
const faMatrix<Type>&
);
template<class Type>
tmp<faMatrix<Type> > operator*
(
const dimensioned<scalar>&,
const tmp<faMatrix<Type> >&
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "faMatrix.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,233 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Finite-Area matrix basic solvers.
\*---------------------------------------------------------------------------*/
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Set reference level for a component of the solution
// on a given patch face
template<class Type>
void faMatrix<Type>::setComponentReference
(
const label patchi,
const label facei,
const direction cmpt,
const scalar value
)
{
internalCoeffs_[patchi][facei].component(cmpt) +=
diag()[psi_.mesh().boundary()[patchi].faceCells()[facei]];
boundaryCoeffs_[patchi][facei].component(cmpt) +=
diag()[psi_.mesh().boundary()[patchi].faceCells()[facei]]*value;
}
template<class Type>
SolverPerformance<Type> faMatrix<Type>::solve(const dictionary& solverControls)
{
if (debug)
{
Info<< "faMatrix<Type>::solve(const dictionary&) : "
"solving faMatrix<Type>"
<< endl;
}
SolverPerformance<Type> solverPerfVec
(
"faMatrix<Type>::solve",
psi_.name()
);
scalarField saveDiag = diag();
Field<Type> source = source_;
addBoundarySource(source);
// Make a copy of interfaces: no longer a reference
// HJ, 20/Nov/2007
lduInterfaceFieldPtrsList interfaces =
psi_.boundaryField().scalarInterfaces();
// Cast into a non-const to solve. HJ, 6/May/2016
GeometricField<Type, faPatchField, areaMesh>& psi =
const_cast<GeometricField<Type, faPatchField, areaMesh>&>(psi_);
for (direction cmpt = 0; cmpt < Type::nComponents; cmpt++)
{
// copy field and source
scalarField psiCmpt = psi_.primitiveField().component(cmpt);
addBoundaryDiag(diag(), cmpt);
scalarField sourceCmpt = source.component(cmpt);
FieldField<Field, scalar> bouCoeffsCmpt
(
boundaryCoeffs_.component(cmpt)
);
FieldField<Field, scalar> intCoeffsCmpt
(
internalCoeffs_.component(cmpt)
);
// Use the initMatrixInterfaces and updateMatrixInterfaces to correct
// bouCoeffsCmpt for the explicit part of the coupled boundary
// conditions
initMatrixInterfaces
(
true,
bouCoeffsCmpt,
interfaces,
psiCmpt,
sourceCmpt,
cmpt
);
updateMatrixInterfaces
(
true,
bouCoeffsCmpt,
interfaces,
psiCmpt,
sourceCmpt,
cmpt
);
solverPerformance solverPerf;
// Solver call
solverPerf = lduMatrix::solver::New
(
psi_.name() + pTraits<Type>::componentNames[cmpt],
*this,
bouCoeffsCmpt,
intCoeffsCmpt,
interfaces,
solverControls
)->solve(psiCmpt, sourceCmpt, cmpt);
if (SolverPerformance<Type>::debug)
{
solverPerf.print(Info);
}
solverPerfVec.replace(cmpt, solverPerf);
solverPerfVec.solverName() = solverPerf.solverName();
psi.primitiveFieldRef().replace(cmpt, psiCmpt);
diag() = saveDiag;
}
psi.correctBoundaryConditions();
return solverPerfVec;
}
template<class Type>
SolverPerformance<Type> faMatrix<Type>::faSolver::solve()
{
return solvei
(
faMat_.psi().mesh().solutionDict().solverDict
(
faMat_.psi().name()
)
);
}
template<class Type>
SolverPerformance<Type> faMatrix<Type>::solve()
{
return solve
(
this->psi().mesh().solutionDict().solverDict
(
this->psi().name()
)
);
}
// Return the matrix residual
template<class Type>
tmp<Field<Type> > faMatrix<Type>::residual() const
{
tmp<Field<Type> > tres(source_);
Field<Type>& res = tres();
addBoundarySource(res);
// Make a copy of interfaces: no longer a reference
// HJ, 20/Nov/2007
lduInterfaceFieldPtrsList interfaces =
psi_.boundaryField().scalarInterfaces();
// Loop over field components
for (direction cmpt = 0; cmpt < Type::nComponents; cmpt++)
{
scalarField psiCmpt = psi_.internalField().component(cmpt);
scalarField boundaryDiagCmpt(psi_.size(), 0.0);
addBoundaryDiag(boundaryDiagCmpt, cmpt);
FieldField<Field, scalar> bouCoeffsCmpt
(
boundaryCoeffs_.component(cmpt)
);
res.replace
(
cmpt,
lduMatrix::residual
(
psiCmpt,
res.component(cmpt) - boundaryDiagCmpt*psiCmpt,
bouCoeffsCmpt,
interfaces,
cmpt
)
);
}
return tres;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,167 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Finite-Area scalar matrix member functions and operators
\*---------------------------------------------------------------------------*/
#include "faScalarMatrix.H"
#include "zeroGradientFaPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Set reference level for a component of the solution
// on a given patch face
template<>
void faMatrix<scalar>::setComponentReference
(
const label patchI,
const label edgeI,
const direction,
const scalar value
)
{
const labelUList& faceLabels =
psi_.mesh().boundary()[patchI].edgeFaces();
internalCoeffs_[patchI][edgeI] +=
diag()[faceLabels[edgeI]];
boundaryCoeffs_[patchI][edgeI] = value;
}
template<>
solverPerformance faMatrix<scalar>::solve
(
const dictionary& solverControls
)
{
if (debug)
{
Info<< "faMatrix<scalar>::solve(const dictionary&) : "
"solving faMatrix<scalar>"
<< endl;
}
GeometricField<scalar, faPatchField, areaMesh>& psi =
const_cast<GeometricField<scalar, faPatchField, areaMesh>&>(psi_);
scalarField saveDiag = diag();
addBoundaryDiag(diag(), 0);
scalarField totalSource = source_;
addBoundarySource(totalSource, 0);
// Solver call
solverPerformance solverPerf = lduMatrix::solver::New
(
psi_.name(),
*this,
boundaryCoeffs_,
internalCoeffs_,
psi_.boundaryField().scalarInterfaces(),
solverControls
)->solve(psi.ref(), totalSource);
solverPerf.print(Info);
diag() = saveDiag;
psi.correctBoundaryConditions();
return solverPerf;
}
// Return the matrix residual
template<>
tmp<scalarField> faMatrix<scalar>::residual() const
{
scalarField boundaryDiag(psi_.size(), 0.0);
addBoundaryDiag(boundaryDiag, 0);
tmp<scalarField> tres
(
lduMatrix::residual
(
psi_.internalField(),
source_ - boundaryDiag*psi_.internalField(),
boundaryCoeffs_,
psi_.boundaryField().scalarInterfaces(),
0
)
);
addBoundarySource(tres.ref());
return tres;
}
// H operator
template<>
tmp<areaScalarField> faMatrix<scalar>::H() const
{
tmp<areaScalarField> tHphi
(
new areaScalarField
(
IOobject
(
"H("+psi_.name()+')',
psi_.instance(),
psi_.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
psi_.mesh(),
dimensions_/dimArea,
zeroGradientFaPatchScalarField::typeName
)
);
areaScalarField Hphi = tHphi();
Hphi.primitiveFieldRef() = (lduMatrix::H(psi_.primitiveField()) + source_);
addBoundarySource(Hphi.primitiveFieldRef());
Hphi.ref() /= psi_.mesh().S();
Hphi.correctBoundaryConditions();
return tHphi;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,84 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
faScalarMatrix
Description
Template specialisation for scalar faMatrix
SourceFiles
faScalarMatrix.C
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
\*---------------------------------------------------------------------------*/
#ifndef faScalarMatrix_H
#define faScalarMatrix_H
#include "faMatrix.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Set reference level for a component of the solution
// on a given patch face
template<>
void faMatrix<scalar>::setComponentReference
(
const label patchi,
const label facei,
const direction,
const scalar value
);
template<>
SolverPerformance<scalar> faMatrix<scalar>::solve(const dictionary&);
// Return the matrix residual
template<>
tmp<scalarField> faMatrix<scalar>::residual() const;
// H operator
template<>
tmp<areaScalarField> faMatrix<scalar>::H() const;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,400 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
\*---------------------------------------------------------------------------*/
#include "faBoundaryMesh.H"
#include "faMesh.H"
#include "primitiveMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(faBoundaryMesh, 0);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from dictionary
faBoundaryMesh::faBoundaryMesh
(
const IOobject& io,
const faMesh& mesh
)
:
faPatchList(),
regIOobject(io),
mesh_(mesh)
{
if (readOpt() == IOobject::MUST_READ)
{
faPatchList& patches = *this;
// Read polyPatchList
Istream& is = readStream(typeName);
PtrList<entry> patchEntries(is);
patches.setSize(patchEntries.size());
forAll(patches, patchI)
{
patches.set
(
patchI,
faPatch::New
(
patchEntries[patchI].keyword(),
patchEntries[patchI].dict(),
patchI,
*this
)
);
}
// Check state of IOstream
is.check
(
"faBoundaryMesh::polyBoundaryMesh"
"(const IOobject&, const faMesh&)"
);
close();
}
}
// Construct given size. Patches will be set later
faBoundaryMesh::faBoundaryMesh
(
const IOobject& io,
const faMesh& pm,
const label size
)
:
faPatchList(size),
regIOobject(io),
mesh_(pm)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Calculate the geometry for the patches (transformation tensors etc.)
void faBoundaryMesh::calcGeometry()
{
forAll(*this, patchi)
{
operator[](patchi).initGeometry();
}
forAll(*this, patchi)
{
operator[](patchi).calcGeometry();
}
}
// Return the mesh reference
const faMesh& faBoundaryMesh::mesh() const
{
return mesh_;
}
lduInterfacePtrsList faBoundaryMesh::interfaces() const
{
lduInterfacePtrsList interfaces(size());
forAll (interfaces, patchi)
{
if (isA<lduInterface>(this->operator[](patchi)))
{
interfaces.set
(
patchi,
&refCast<const lduInterface>(this->operator[](patchi))
);
}
}
return interfaces;
}
// Return a list of patch types
wordList faBoundaryMesh::types() const
{
const faPatchList& patches = *this;
wordList t(patches.size());
forAll (patches, patchI)
{
t[patchI] = patches[patchI].type();
}
return t;
}
// Return a list of patch names
wordList faBoundaryMesh::names() const
{
const faPatchList& patches = *this;
wordList t(patches.size());
forAll (patches, patchI)
{
t[patchI] = patches[patchI].name();
}
return t;
}
label faBoundaryMesh::findPatchID(const word& patchName) const
{
const faPatchList& patches = *this;
forAll (patches, patchI)
{
if (patches[patchI].name() == patchName)
{
return patchI;
}
}
// Patch not found
return -1;
}
Foam::labelList Foam::faBoundaryMesh::findIndices
(
const keyType& key,
const bool usePatchGroups
) const
{
DynamicList<label> indices;
if (!key.empty())
{
if (key.isPattern())
{
indices = findStrings(key, this->names());
}
else
{
// Literal string. Special version of above to avoid
// unnecessary memory allocations
indices.setCapacity(1);
forAll(*this, i)
{
if (key == operator[](i).name())
{
indices.append(i);
break;
}
}
}
}
return indices;
}
// Return patch index for a given edge label
label faBoundaryMesh::whichPatch(const label edgeIndex) const
{
// Find out which patch the current face belongs to by comparing label
// with patch start labels.
// If the face is internal, return -1;
// if it is off the end of the list, abort
if (edgeIndex >= mesh().nEdges())
{
FatalErrorIn
(
"faBoundaryMesh::whichPatch(const label edgeIndex) const"
) << "given label greater than the number of edges"
<< abort(FatalError);
}
if (edgeIndex < mesh().nInternalEdges())
{
return -1;
}
forAll (*this, patchI)
{
label start = mesh_.patchStarts()[patchI];
label size = operator[](patchI).faPatch::size();
if
(
edgeIndex >= start
&& edgeIndex < start + size
)
{
return patchI;
}
}
// If not in any of above, it's trouble!
FatalErrorIn
(
"label faBoundaryMesh::whichPatch(const label edgeIndex) const"
) << "error in patch search algorithm"
<< abort(FatalError);
return -1;
}
bool faBoundaryMesh::checkDefinition(const bool report) const
{
label nextPatchStart = mesh().nInternalEdges();
const faBoundaryMesh& bm = *this;
bool boundaryError = false;
forAll (bm, patchI)
{
if (bm[patchI].start() != nextPatchStart)
{
boundaryError = true;
Info
<< "bool faBoundaryMesh::checkDefinition("
<< "const bool report) const : "
<< "Problem with boundary patch " << patchI
<< ".\nThe patch should start on face no " << nextPatchStart
<< " and the boundary file specifies " << bm[patchI].start()
<< "." << nl << endl;
}
nextPatchStart += bm[patchI].faPatch::size();
}
if (boundaryError)
{
SeriousErrorIn
(
"bool faBoundaryMesh::checkDefinition("
"const bool report) const"
) << "This mesh is not valid: boundary definition is in error."
<< endl;
}
else
{
if (debug || report)
{
Info << "Boundary definition OK." << endl;
}
}
return boundaryError;
}
// Correct faBoundaryMesh after moving points
void faBoundaryMesh::movePoints(const pointField& p)
{
faPatchList& patches = *this;
forAll (patches, patchI)
{
patches[patchI].initMovePoints(p);
}
forAll (patches, patchI)
{
patches[patchI].movePoints(p);
}
}
void faBoundaryMesh::updateMesh()
{
faPatchList& patches = *this;
forAll(patches, patchi)
{
patches[patchi].initUpdateMesh();
}
forAll(patches, patchi)
{
patches[patchi].updateMesh();
}
}
// writeData member function required by regIOobject
bool faBoundaryMesh::writeData(Ostream& os) const
{
const faPatchList& patches = *this;
os << patches.size() << nl << token::BEGIN_LIST << incrIndent << nl;
forAll(patches, patchi)
{
os << indent << patches[patchi].name() << nl
<< indent << token::BEGIN_BLOCK << nl
<< incrIndent << patches[patchi] << decrIndent
<< indent << token::END_BLOCK << endl;
}
os << decrIndent << token::END_LIST;
// Check state of IOstream
os.check("polyBoundaryMesh::writeData(Ostream& os) const");
return os.good();
}
Ostream& operator<<(Ostream& os, const faBoundaryMesh& bm)
{
bm.writeData(os);
return os;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,171 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
faBoundaryMesh
Description
Finite area boundary mesh
SourceFiles
faBoundaryMesh.C
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
\*---------------------------------------------------------------------------*/
#ifndef faBoundaryMesh_H
#define faBoundaryMesh_H
#include "faPatchList.H"
#include "lduInterfacePtrsList.H"
#include "wordList.H"
#include "pointField.H"
#include "regIOobject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
class faMesh;
/*---------------------------------------------------------------------------*\
Class faBoundaryMesh Declaration
\*---------------------------------------------------------------------------*/
class faBoundaryMesh
:
public faPatchList,
public regIOobject
{
// private data
//- Reference to mesh
const faMesh& mesh_;
//- Disallow construct as copy
faBoundaryMesh(const faBoundaryMesh&);
//- Disallow assignment
void operator=(const faBoundaryMesh&);
public:
//- Runtime type information
TypeName("faBoundaryMesh");
// Constructors
//- Construct from dictionary
faBoundaryMesh
(
const IOobject& io,
const faMesh& fam
);
//- Construct given size
faBoundaryMesh
(
const IOobject& io,
const faMesh& fam,
const label size
);
// Destructor - default
// Member functions
// Access
//- Calculate the geometry for the patches
// (transformation tensors etc.)
void calcGeometry();
//- Return the mesh reference
const faMesh& mesh() const;
//- Return a list of pointers for each patch
// with only those pointing to interfaces being set
lduInterfacePtrsList interfaces() const;
//- Return a list of patch types
wordList types() const;
//- Return a list of patch names
wordList names() const;
//- Find patch index given a name
label findPatchID(const word& patchName) const;
//- Find patch indices given a name
// Compatibility change HJ, 12/Aug/2017
labelList findIndices
(
const keyType&,
const bool useGroups = false
) const;
//- Return patch index for a given edge label
label whichPatch(const label edgeIndex) const;
//- Check boundary definition
bool checkDefinition(const bool report = false) const;
// Edit
//- Correct faBoundaryMesh after moving points
void movePoints(const pointField&);
//- Correct faBoundaryMesh after topology update
void updateMesh();
//- writeData member function required by regIOobject
bool writeData(Ostream&) const;
// Ostream operator
friend Ostream& operator<<(Ostream&, const faBoundaryMesh&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,140 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Author
Hrvoje Jasak
\*----------------------------------------------------------------------------*/
#include "faGlobalMeshData.H"
#include "faMesh.H"
#include "globalMeshData.H"
#include "PstreamCombineReduceOps.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::faGlobalMeshData::faGlobalMeshData(const faMesh& mesh)
:
faProcessorTopology(mesh.boundary(), UPstream::worldComm),
mesh_(mesh),
nGlobalPoints_(-1),
sharedPointLabels_(0),
sharedPointAddr_(0)
{
updateMesh();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::faGlobalMeshData::~faGlobalMeshData()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::faMesh& Foam::faGlobalMeshData::mesh() const
{
return mesh_;
}
// Update all data after morph
void Foam::faGlobalMeshData::updateMesh()
{
label polyMeshNGlobalPoints =
mesh_().globalData().nGlobalPoints();
const labelList& polyMeshSharedPointLabels =
mesh_().globalData().sharedPointLabels();
const labelList& polyMeshSharedPointAddr =
mesh_().globalData().sharedPointAddr();
labelHashSet sharedPointLabels;
labelField globalList(polyMeshNGlobalPoints, 0);
forAll(mesh_.boundary(), patchI)
{
if(mesh_.boundary()[patchI].type() == processorFaPatch::typeName)
{
const labelList& localPointLabels =
mesh_.boundary()[patchI].pointLabels();
forAll(localPointLabels, pointI)
{
label polyMeshPoint =
mesh_.patch().meshPoints()[localPointLabels[pointI]];
label sharedPolyMeshPoint =
findIndex(polyMeshSharedPointLabels, polyMeshPoint);
if
(
sharedPolyMeshPoint != -1
&& !sharedPointLabels.found(localPointLabels[pointI])
)
{
globalList[polyMeshSharedPointAddr[sharedPolyMeshPoint]]
+= 1;
sharedPointLabels.insert(localPointLabels[pointI]);
}
}
}
}
sharedPointLabels_ = sharedPointLabels.toc();
combineReduce(globalList, plusEqOp<labelField >());
nGlobalPoints_ = 0;
for (label i=0; i<globalList.size(); i++)
{
if(globalList[i] > 0)
{
globalList[i] = ++nGlobalPoints_;
}
}
sharedPointAddr_.setSize(sharedPointLabels_.size());
forAll(sharedPointAddr_, pointI)
{
label polyMeshSharedPointIndex = findIndex
(
polyMeshSharedPointLabels,
mesh_.patch().meshPoints()[sharedPointLabels_[pointI]]
);
sharedPointAddr_[pointI] =
globalList[polyMeshSharedPointAddr[polyMeshSharedPointIndex]]
- 1;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,143 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
faGlobalMeshData
Description
Various mesh related information for a parallel run
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
\*---------------------------------------------------------------------------*/
#ifndef faGlobalMeshData_H
#define faGlobalMeshData_H
#include "faProcessorTopology.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Class forward declarations
class faMesh;
/*---------------------------------------------------------------------------*\
Class faGlobalMeshData Declaration
\*---------------------------------------------------------------------------*/
class faGlobalMeshData
:
public faProcessorTopology
{
// Private data
//- Reference to mesh
const faMesh& mesh_;
// Globally shared point addressing
//- Total number of global points
label nGlobalPoints_;
//- Indices of local points that are globally shared
labelList sharedPointLabels_;
//- Indices of globally shared points in the master list
// This list contains all the shared points in the mesh
labelList sharedPointAddr_;
// Private Member Functions
//- Disallow default bitwise copy construct
faGlobalMeshData(const faGlobalMeshData&);
//- Disallow default bitwise assignment
void operator=(const faGlobalMeshData&);
public:
//- Runtime type information
ClassName("faGlobalMeshData");
// Constructors
//- Construct from mesh
faGlobalMeshData(const faMesh& mesh);
// Destructor
~faGlobalMeshData();
// Member Functions
// Access
//- Return mesh reference
const faMesh& mesh() const;
// Globally shared point addressing
//- Return number of globally shared points
label nGlobalPoints() const
{
return nGlobalPoints_;
}
//- Return indices of local points that are globally shared
const labelList& sharedPointLabels() const
{
return sharedPointLabels_;
}
//- Return addressing into the complete globally shared points
// list
const labelList& sharedPointAddr() const
{
return sharedPointAddr_;
}
//- Change global mesh data given a topological change.
void updateMesh();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,61 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
faProcessorTopology
Description
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
\*---------------------------------------------------------------------------*/
#ifndef faProcessorTopology_H
#define faProcessorTopology_H
#include "ProcessorTopology.H"
#include "faPatchList.H"
#include "processorFaPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef ProcessorTopology<faPatchList, processorFaPatch> faProcessorTopology;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,552 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
faMesh
Description
Finite area mesh. Used for 2-D non-Euclidian finite area method.
SourceFiles
faMesh.C
faMeshDemandDrivenData.C
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
\*---------------------------------------------------------------------------*/
#ifndef faMesh_H
#define faMesh_H
#include "GeoMesh.H"
#include "MeshObject.H"
#include "polyMesh.H"
#include "lduMesh.H"
#include "faBoundaryMesh.H"
#include "edgeList.H"
#include "faceList.H"
#include "primitiveFieldsFwd.H"
#include "DimensionedField.H"
#include "areaFieldsFwd.H"
#include "edgeFieldsFwd.H"
#include "indirectPrimitivePatch.H"
#include "edgeInterpolation.H"
#include "labelIOList.H"
#include "scalarIOField.H"
#include "FieldFields.H"
#include "faGlobalMeshData.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Class forward declarations
class faMeshLduAddressing;
class faMeshMapper;
/*---------------------------------------------------------------------------*\
Class faMesh Declaration
\*---------------------------------------------------------------------------*/
class faMesh
:
public GeoMesh<polyMesh>,
public MeshObject<polyMesh, UpdateableMeshObject, faMesh>,
public lduMesh,
public edgeInterpolation
{
// Private data
//- Face labels
labelIOList faceLabels_;
//- Boundary mesh
faBoundaryMesh boundary_;
// Primitive mesh data
//- Edges, addressing into local point list
edgeList edges_;
//- Edge owner
labelList edgeOwner_;
//- Edge neighbour
labelList edgeNeighbour_;
// Primitive size data
//- Number of points
mutable label nPoints_;
//- Number of edges
mutable label nEdges_;
//- Number of internal edges
mutable label nInternalEdges_;
//- Number of faces
mutable label nFaces_;
// Communication support
//- Communicator used for parallel communication
label comm_;
// Demand-driven data
//- Primitive patch
mutable indirectPrimitivePatch* patchPtr_;
//- Ldu addressing data
mutable faMeshLduAddressing* lduPtr_;
//- Current time index for motion
// Note. The whole mechanism will be replaced once the
// dimensionedField is created and the dimensionedField
// will take care of the old-time levels.
mutable label curTimeIndex_;
//- Face areas
mutable DimensionedField<scalar, areaMesh>* SPtr_;
//- Face areas old time level
mutable DimensionedField<scalar, areaMesh>* S0Ptr_;
//- Face areas old-old time level
mutable DimensionedField<scalar, areaMesh>* S00Ptr_;
//- Patch starts in the edge list
mutable labelList* patchStartsPtr_;
//- Edge length vectors
mutable edgeVectorField* LePtr_;
//- Mag edge length vectors
mutable edgeScalarField* magLePtr_;
//- Face centres
mutable areaVectorField* centresPtr_;
//- Edge centres
mutable edgeVectorField* edgeCentresPtr_;
//- Face area normals
mutable areaVectorField* faceAreaNormalsPtr_;
//- Edge area normals
mutable edgeVectorField* edgeAreaNormalsPtr_;
//- Edge area normals
mutable vectorField* pointAreaNormalsPtr_;
//- Face curvatures
mutable areaScalarField* faceCurvaturesPtr_;
//- Edge transformation tensors
mutable FieldField<Field, tensor>* edgeTransformTensorsPtr_;
//- Whether point normals must be corrected for a patch
mutable boolList* correctPatchPointNormalsPtr_;
// Other mesh-related data
//- Parallel info
mutable faGlobalMeshData* globalMeshDataPtr_;
// Static Private Data
//- Use quadrics fit
static const int quadricsFit_;
// Private Member Functions
//- Disallow default bitwise copy construct
faMesh(const faMesh&);
//- Disallow default bitwise assignment
void operator=(const faMesh&);
//- Set primitive mesh data
void setPrimitiveMeshData();
// Private member functions to calculate demand driven data
//- Calculate ldu addressing
void calcLduAddressing() const;
//- Calculate patch starts in the edge list
void calcPatchStarts() const;
//- Calculate edge lengths
void calcLe() const;
//- Calculate mag edge lengths
void calcMagLe() const;
//- Calculate face centres
void calcAreaCentres() const;
//- Calculate edge centres
void calcEdgeCentres() const;
//- Calculate face areas
void calcS() const;
//- Calculate face area normals
void calcFaceAreaNormals() const;
//- Calculate edge area normals
void calcEdgeAreaNormals() const;
//- Calculate point area normals
void calcPointAreaNormals() const;
//- Calculate point area normals by quadrics fit
void calcPointAreaNormalsByQuadricsFit() const;
//- Calculate face curvatures
void calcFaceCurvatures() const;
//- Calculate edge transformation tensors
void calcEdgeTransformTensors() const;
//- Clear geometry but not the face areas
void clearGeomNotAreas() const;
//- Clear geometry
void clearGeom() const;
//- Clear addressing
void clearAddressing() const;
//- Clear demand-driven data
void clearOut() const;
public:
// Public typedefs
typedef faMesh Mesh;
typedef faBoundaryMesh BoundaryMesh;
//- Runtime type information
TypeName("faMesh");
//- Return the mesh sub-directory name (usually "faMesh")
static word meshSubDir;
// Constructors
//- Construct from polyMesh
explicit faMesh(const polyMesh& m);
//- Construct from components without boundary.
// Boundary is added using addFaPatches() member function
faMesh
(
const polyMesh& m,
const labelList& faceLabels
);
//- Construct from finite area mesh definition file
faMesh
(
const polyMesh& m,
const fileName& defFile
);
//- Construct from polyPatch
faMesh
(
const polyMesh& m,
const label polyPatchID
);
//- Destructor
virtual ~faMesh();
// Member Functions
// Helpers
//- Add boundary patches. Constructor helper
void addFaPatches(const List<faPatch*> &);
// Database
//- Return access to polyMesh
const polyMesh& mesh() const
{
return
MeshObject<polyMesh, UpdateableMeshObject, faMesh>::mesh();
}
//- Return the local mesh directory (dbDir()/meshSubDir)
fileName meshDir() const;
//- Return reference to time
const Time& time() const;
//- Return the current instance directory for points
// Used in the consruction of gemometric mesh data dependent
// on points
const fileName& pointsInstance() const;
//- Return the current instance directory for faces
const fileName& facesInstance() const;
//- Mesh size parameters
inline label nPoints() const
{
return nPoints_;
}
inline label nEdges() const
{
return nEdges_;
}
inline label nInternalEdges() const
{
return nInternalEdges_;
}
inline label nFaces() const
{
return nFaces_;
}
// Primitive mesh data
//- Return mesh points
const pointField& points() const;
//- Return edges
const edgeList& edges() const;
//- Return faces
const faceList& faces() const;
//- Edge owner addresing
inline const labelList& edgeOwner() const
{
return edgeOwner_;
}
//- Edge neighbour addressing
inline const labelList& edgeNeighbour() const
{
return edgeNeighbour_;
}
// Communication support
//- Return communicator used for parallel communication
label comm() const;
//- Return communicator used for parallel communication
label& comm();
// Access
//- Return reference to the mesh database
virtual const objectRegistry& thisDb() const;
//- Return constant reference to boundary mesh
const faBoundaryMesh& boundary() const;
//- Return faMesh face labels
const labelList& faceLabels() const
{
return faceLabels_;
}
//- Return parallel info
const faGlobalMeshData& globalData() const;
//- Return ldu addressing
virtual const lduAddressing& lduAddr() const;
//- Return a list of pointers for each patch
// with only those pointing to interfaces being set
virtual lduInterfacePtrsList interfaces() const
{
return boundary().interfaces();
}
//- Internal face owner
const labelUList& owner() const
{
return lduAddr().lowerAddr();
}
//- Internal face neighbour
const labelUList& neighbour() const
{
return lduAddr().upperAddr();
}
//- Return true if given edge label is internal to the mesh
inline bool isInternalEdge(const label edgeIndex) const
{
return edgeIndex < nInternalEdges();
}
// Mesh motion and mophing
//- Is mesh moving
bool moving() const
{
return mesh().moving();
}
//- Update after mesh motion
virtual bool movePoints();
//- Update after topo change
virtual void updateMesh(const mapPolyMesh&);
// Mapping
//- Map all fields in time using given map.
virtual void mapFields(const faMeshMapper& mapper) const;
//- Map face areas in time using given map.
virtual void mapOldAreas(const faMeshMapper& mapper) const;
// Demand-driven data
//- Return constant reference to primitive patch
const indirectPrimitivePatch& patch() const;
//- Return reference to primitive patch
indirectPrimitivePatch& patch();
//- Return patch starts
const labelList& patchStarts() const;
//- Return edge length vectors
const edgeVectorField& Le() const;
//- Return edge length magnitudes
const edgeScalarField& magLe() const;
//- Return face centres as areaVectorField
const areaVectorField& areaCentres() const;
//- Return edge centres as edgeVectorField
const edgeVectorField& edgeCentres() const;
//- Return face areas
const DimensionedField<scalar, areaMesh>& S() const;
//- Return old-time face areas
const DimensionedField<scalar, areaMesh>& S0() const;
//- Return old-old-time face areas
const DimensionedField<scalar, areaMesh>& S00() const;
//- Return face area normals
const areaVectorField& faceAreaNormals() const;
//- Return edge area normals
const edgeVectorField& edgeAreaNormals() const;
//- Return point area normals
const vectorField& pointAreaNormals() const;
//- Return face curvatures
const areaScalarField& faceCurvatures() const;
//- Return edge transformation tensors
const FieldField<Field, tensor>& edgeTransformTensors() const;
//- Return internal point labels
labelList internalPoints() const;
//- Return boundary point labels
labelList boundaryPoints() const;
//- Return edge length correction
tmp<edgeScalarField> edgeLengthCorrection() const;
//- Whether point normals should be corrected for a patch
bool correctPatchPointNormals(const label patchID) const;
//- Set whether point normals should be corrected for a patch
boolList& correctPatchPointNormals() const;
//- Write mesh
virtual bool write() const;
// Member Operators
bool operator!=(const faMesh& m) const;
bool operator==(const faMesh& m) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "faPatchFaMeshTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,158 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
faMeshLduAddressing
Description
lduAddressing wrapper for faMesh
SourceFiles
faMeshLduAddressing.C
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
\*---------------------------------------------------------------------------*/
#ifndef faMeshLduAddressing_H
#define faMeshLduAddressing_H
#include "lduAddressing.H"
#include "faMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class faMeshLduAddressing Declaration
\*---------------------------------------------------------------------------*/
class faMeshLduAddressing
:
public lduAddressing
{
// Private data
//- Lower as a subList of allOwner
labelList::subList lowerAddr_;
//- Upper as a reference to neighbour
const labelList& upperAddr_;
//- Patch addressing as a list of sublists
List<const labelUList*> patchAddr_;
//- Patch field evaluation schedule
const lduSchedule& patchSchedule_;
// Private Member Functions
//- Disallow default bitwise copy construct
faMeshLduAddressing(const faMeshLduAddressing&);
//- Disallow default bitwise assignment
void operator=(const faMeshLduAddressing&);
public:
// Constructors
//- Construct from components
faMeshLduAddressing(const faMesh& mesh)
:
lduAddressing(mesh.nFaces()),
lowerAddr_
(
labelList::subList
(
mesh.edgeOwner(),
mesh.nInternalEdges()
)
),
upperAddr_(mesh.edgeNeighbour()),
patchAddr_(mesh.boundary().size()),
patchSchedule_(mesh.globalData().patchSchedule())
{
forAll (mesh.boundary(), patchI)
{
patchAddr_[patchI] = &mesh.boundary()[patchI].edgeFaces();
}
}
// Destructor
virtual ~faMeshLduAddressing()
{}
// Member Functions
//- Return number of interfaces
virtual label nPatches() const
{
return patchAddr_.size();
}
//- Return lower addressing (i.e. lower label = upper triangle)
virtual const labelUList& lowerAddr() const
{
return lowerAddr_;
}
//- Return upper addressing (i.e. upper label)
virtual const labelUList& upperAddr() const
{
return upperAddr_;
}
//- Return patch addressing
virtual const labelUList& patchAddr(const label i) const
{
return *patchAddr_[i];
}
// Return patch field evaluation schedule
virtual const lduSchedule& patchSchedule() const
{
return patchSchedule_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,434 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
FV surface mapper.
\*---------------------------------------------------------------------------*/
#include "faAreaMapper.H"
#include "mapPolyMesh.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::faAreaMapper::calcAddressing() const
{
if
(
newFaceLabelsPtr_
|| newFaceLabelsMapPtr_
|| directAddrPtr_
|| interpolationAddrPtr_
|| weightsPtr_
|| insertedObjectLabelsPtr_
)
{
FatalErrorIn("void faAreaMapper::calcAddressing() const)")
<< "Addressing already calculated"
<< abort(FatalError);
}
// Mapping
const label oldNInternal = mpm_.nOldInternalFaces();
hasUnmapped_ = false;
// Calculate new face labels
// Copy old face labels
const labelList& oldFaces = mesh_.faceLabels();
// Prepare a list of new face labels and (preliminary) addressing
// Note: dimensioned to number of boundary faces of polyMesh
// HJ, 10/Aug/2011
newFaceLabelsPtr_ = new labelList
(
mesh_().nFaces() - mesh_().nInternalFaces(),
-1
);
labelList& newFaceLabels = *newFaceLabelsPtr_;
newFaceLabelsMapPtr_ = new labelList
(
mesh_().nFaces() - mesh_().nInternalFaces(),
-1
);
labelList& newFaceLabelsMap = *newFaceLabelsMapPtr_;
label nNewFaces = 0;
Info<< "Old face list size: " << oldFaces.size()
<< " estimated new size " << newFaceLabels.size() << endl;
// Get reverse face map
const labelList& reverseFaceMap = mpm_.reverseFaceMap();
// Pick up live old faces
forAll (oldFaces, faceI)
{
if (reverseFaceMap[oldFaces[faceI]] > -1)
{
// Face is live, add it and record addressing
newFaceLabels[nNewFaces] = reverseFaceMap[oldFaces[faceI]];
newFaceLabelsMap[nNewFaces] = faceI;
nNewFaces++;
}
}
// Assemble the maps
if (direct())
{
Info<< "Direct"<< endl;
// Direct mapping: no further faces to add. Resize list
newFaceLabels.setSize(nNewFaces);
directAddrPtr_ = new labelList(newFaceLabels.size());
labelList& addr = *directAddrPtr_;
// Adjust for creation of a boundary face from an internal face
forAll (addr, faceI)
{
if (newFaceLabelsMap[faceI] < oldNInternal)
{
addr[faceI] = 0;
}
else
{
addr[faceI] = newFaceLabelsMap[faceI];
}
}
}
else
{
// There are further faces to add. Prepare interpolation addressing
// and weights to full size
interpolationAddrPtr_ = new labelListList(newFaceLabels.size());
labelListList& addr = *interpolationAddrPtr_;
weightsPtr_ = new scalarListList(newFaceLabels.size());
scalarListList& w = *weightsPtr_;
// Insert single addressing and weights
for (label addrI = 0; addrI < nNewFaces; addrI++)
{
addr[addrI] = labelList(1, newFaceLabelsMap[addrI]);
w[addrI] = scalarList(1, scalar(1));
}
// Pick up faces from points, edges and faces where the origin
// Only map from faces which were previously in the faMesh, using
// fast lookup
// Set of faces previously in the mesh
labelHashSet oldFaceLookup(oldFaces);
// Go through faces-from lists and add the ones where all
// old face labels belonged to the faMesh
const List<objectMap>& ffp = mpm_.facesFromPointsMap();
forAll (ffp, ffpI)
{
// Get addressing
const labelList& mo = ffp[ffpI].masterObjects();
// Check if master objects are in faMesh
labelList validMo(mo.size());
label nValidMo = 0;
forAll (mo, moI)
{
if (oldFaceLookup.found(mo[moI]))
{
validMo[nValidMo] = oldFaceLookup[mo[moI]];
nValidMo++;
}
}
if (nValidMo > 0)
{
// Some objects found: add face and interpolation to list
newFaceLabels[nNewFaces] = ffp[ffpI].index();
// No old face available
newFaceLabelsMap[nNewFaces] = -1;
// Map from masters, uniform weights
addr[nNewFaces] = validMo;
w[nNewFaces] = scalarList(validMo.size(), 1.0/validMo.size());
nNewFaces++;
}
}
const List<objectMap>& ffe = mpm_.facesFromEdgesMap();
forAll (ffe, ffeI)
{
// Get addressing
const labelList& mo = ffe[ffeI].masterObjects();
// Check if master objects are in faMesh
labelList validMo(mo.size());
label nValidMo = 0;
forAll (mo, moI)
{
if (oldFaceLookup.found(mo[moI]))
{
validMo[nValidMo] = oldFaceLookup[mo[moI]];
nValidMo++;
}
}
if (nValidMo > 0)
{
// Some objects found: add face and interpolation to list
newFaceLabels[nNewFaces] = ffe[ffeI].index();
// No old face available
newFaceLabelsMap[nNewFaces] = -1;
// Map from masters, uniform weights
addr[nNewFaces] = validMo;
w[nNewFaces] = scalarList(validMo.size(), 1.0/validMo.size());
nNewFaces++;
}
}
const List<objectMap>& fff = mpm_.facesFromFacesMap();
forAll (fff, fffI)
{
// Get addressing
const labelList& mo = fff[fffI].masterObjects();
// Check if master objects are in faMesh
labelList validMo(mo.size());
label nValidMo = 0;
forAll (mo, moI)
{
if (oldFaceLookup.found(mo[moI]))
{
validMo[nValidMo] = oldFaceLookup[mo[moI]];
nValidMo++;
}
}
if (nValidMo > 0)
{
// Some objects found: add face and interpolation to list
newFaceLabels[nNewFaces] = fff[fffI].index();
// No old face available
newFaceLabelsMap[nNewFaces] = -1;
// Map from masters, uniform weights
addr[nNewFaces] = validMo;
w[nNewFaces] = scalarList(validMo.size(), 1.0/validMo.size());
nNewFaces++;
}
}
// All faces collected. Reset sizes of lists
newFaceLabels.setSize(nNewFaces);
newFaceLabelsMap.setSize(nNewFaces);
addr.setSize(nNewFaces);
w.setSize(nNewFaces);
Info<< "addr: " << addr << nl
<< "w: " << w << endl;
}
// Inserted objects cannot appear in the new faMesh as they have no master
// HJ, 10/Aug/2011
insertedObjectLabelsPtr_ = new labelList(0);
}
void Foam::faAreaMapper::clearOut()
{
deleteDemandDrivenData(newFaceLabelsPtr_);
deleteDemandDrivenData(newFaceLabelsMapPtr_);
deleteDemandDrivenData(directAddrPtr_);
deleteDemandDrivenData(interpolationAddrPtr_);
deleteDemandDrivenData(weightsPtr_);
deleteDemandDrivenData(insertedObjectLabelsPtr_);
hasUnmapped_ = false;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::faAreaMapper::faAreaMapper
(
const faMesh& mesh,
const mapPolyMesh& mpm
)
:
mesh_(mesh),
mpm_(mpm),
insertedFaces_(false),
direct_(false),
hasUnmapped_(false),
sizeBeforeMapping_(mesh.nFaces()),
newFaceLabelsPtr_(NULL),
newFaceLabelsMapPtr_(NULL),
directAddrPtr_(NULL),
interpolationAddrPtr_(NULL),
weightsPtr_(NULL),
insertedObjectLabelsPtr_(NULL)
{
// Check for possibility of direct mapping
if
(
mpm_.facesFromPointsMap().empty()
&& mpm_.facesFromEdgesMap().empty()
&& mpm_.facesFromFacesMap().empty()
)
{
direct_ = true;
}
else
{
direct_ = false;
}
// Inserted objects not suported: no master
// HJ, 10/Aug/2011
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::faAreaMapper::~faAreaMapper()
{
clearOut();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::labelList& Foam::faAreaMapper::newFaceLabels() const
{
if (!newFaceLabelsPtr_)
{
calcAddressing();
}
return *newFaceLabelsPtr_;
}
const Foam::labelList& Foam::faAreaMapper::newFaceLabelsMap() const
{
if (!newFaceLabelsMapPtr_)
{
calcAddressing();
}
return *newFaceLabelsMapPtr_;
}
const Foam::labelUList& Foam::faAreaMapper::directAddressing() const
{
if (!direct())
{
FatalErrorIn
(
"const labelUList& faAreaMapper::"
"directAddressing() const"
) << "Requested direct addressing for an interpolative mapper."
<< abort(FatalError);
}
if (!directAddrPtr_)
{
calcAddressing();
}
return *directAddrPtr_;
}
const Foam::labelListList& Foam::faAreaMapper::addressing() const
{
if (direct())
{
FatalErrorIn
(
"const labelListList& faAreaMapper::addressing() const"
) << "Requested interpolative addressing for a direct mapper."
<< abort(FatalError);
}
if (!interpolationAddrPtr_)
{
calcAddressing();
}
return *interpolationAddrPtr_;
}
const Foam::scalarListList& Foam::faAreaMapper::weights() const
{
if (direct())
{
FatalErrorIn
(
"const scalarListList& faAreaMapper::weights() const"
) << "Requested interpolative weights for a direct mapper."
<< abort(FatalError);
}
if (!weightsPtr_)
{
calcAddressing();
}
return *weightsPtr_;
}
const Foam::labelList& Foam::faAreaMapper::insertedObjectLabels() const
{
if (!insertedObjectLabelsPtr_)
{
calcAddressing();
}
return *insertedObjectLabelsPtr_;
}
// ************************************************************************* //

View File

@ -0,0 +1,200 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::faAreaMapper
Description
FA area mapper.
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
SourceFiles
faAreaMapper.C
\*---------------------------------------------------------------------------*/
#ifndef faAreaMapper_H
#define faAreaMapper_H
#include "morphFieldMapper.H"
#include "faMesh.H"
#include "faceMapper.H"
#include "HashSet.H"
#include "mapPolyMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class faAreaMapper Declaration
\*---------------------------------------------------------------------------*/
class faAreaMapper
:
public morphFieldMapper
{
// Private data
//- Reference to mesh mapper
const faMesh& mesh_;
//- Reference to mapPolyMesh
const mapPolyMesh& mpm_;
//- Are there any inserted (unmapped) faces
bool insertedFaces_;
//- Is the mapping direct
bool direct_;
// Demand-driven private data
mutable bool hasUnmapped_;
//- Old mesh size
label sizeBeforeMapping_;
//- New face labels after mapping
mutable labelList* newFaceLabelsPtr_;
//- New face labels after mapping
mutable labelList* newFaceLabelsMapPtr_;
//- Direct addressing (only one form of addressing is used)
mutable labelList* directAddrPtr_;
//- Interpolated addressing (only one form of addressing is used)
mutable labelListList* interpolationAddrPtr_;
//- Interpolation weights
mutable scalarListList* weightsPtr_;
//- Inserted faces
mutable labelList* insertedObjectLabelsPtr_;
// Private Member Functions
//- Disallow default bitwise copy construct
faAreaMapper(const faAreaMapper&);
//- Disallow default bitwise assignment
void operator=(const faAreaMapper&);
//- Calculate addressing
void calcAddressing() const;
//- Clear out local storage
void clearOut();
public:
// Constructors
//- Construct from components
faAreaMapper
(
const faMesh& mesh,
const mapPolyMesh& mpm
);
// Destructor
virtual ~faAreaMapper();
// Member Functions
//- Return new face labels
const labelList& newFaceLabels() const;
//- Return new face labels map
// For new faces return old face index if it exists
// If the face has been added, index will be -1
const labelList& newFaceLabelsMap() const;
//- Return size
virtual label size() const
{
return newFaceLabels().size();
}
//- Return size of field before mapping
virtual label sizeBeforeMapping() const
{
return sizeBeforeMapping_;
}
//- Is the mapping direct
virtual bool direct() const
{
return direct_;
}
virtual bool hasUnmapped() const
{
return hasUnmapped_;
}
//- Return direct addressing
virtual const labelUList& directAddressing() const;
//- Return interpolated addressing
virtual const labelListList& addressing() const;
//- Return interpolaion weights
virtual const scalarListList& weights() const;
//- Are there any inserted faces
virtual bool insertedObjects() const
{
return !insertedObjectLabels().empty();
}
//- Return list of inserted faces
virtual const labelList& insertedObjectLabels() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,101 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::faBoundaryMeshMapper
Description
Foam::faBoundaryMeshMapper
\*---------------------------------------------------------------------------*/
#ifndef faBoundaryMeshMapper_H
#define faBoundaryMeshMapper_H
#include "PtrList.H"
#include "faPatchMapper.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class faBoundaryMeshMapper Declaration
\*---------------------------------------------------------------------------*/
class faBoundaryMeshMapper
:
public PtrList<faPatchMapper>
{
// Private Member Functions
//- Disallow default bitwise copy construct
faBoundaryMeshMapper(const faBoundaryMeshMapper&);
//- Disallow default bitwise assignment
void operator=(const faBoundaryMeshMapper&);
public:
// Constructors
//- Construct from components
faBoundaryMeshMapper
(
const faMesh& mesh,
const mapPolyMesh& mpm
)
:
PtrList<faPatchMapper>(mesh.boundary().size())
{
const faBoundaryMesh& patches = mesh.boundary();
forAll (patches, patchI)
{
set
(
patchI,
new faPatchMapper
(
patches[patchI],
mpm
)
);
}
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,121 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
FV edge mapper.
\*---------------------------------------------------------------------------*/
#include "faEdgeMapper.H"
#include "mapPolyMesh.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::faEdgeMapper::calcAddressing() const
{
if (directAddrPtr_)
{
FatalErrorIn("void faEdgeMapper::calcAddressing() const)")
<< "Addressing already calculated"
<< abort(FatalError);
}
hasUnmapped_ = false;
// Dummy mapping: take value from edge 0
directAddrPtr_ = new labelList(size(), 0);
}
void Foam::faEdgeMapper::clearOut()
{
deleteDemandDrivenData(directAddrPtr_);
hasUnmapped_ = false;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::faEdgeMapper::faEdgeMapper
(
const faMesh& mesh,
const mapPolyMesh& mpm
)
:
mesh_(mesh),
mpm_(mpm),
sizeBeforeMapping_(mesh.nInternalEdges()),
hasUnmapped_(false),
directAddrPtr_(NULL)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::faEdgeMapper::~faEdgeMapper()
{
clearOut();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::labelUList& Foam::faEdgeMapper::directAddressing() const
{
if (!directAddrPtr_)
{
calcAddressing();
}
return *directAddrPtr_;
}
const Foam::labelListList& Foam::faEdgeMapper::addressing() const
{
FatalErrorIn
(
"const labelListList& faEdgeMapper::addressing() const"
) << "Requested interpolative addressing for a direct mapper."
<< abort(FatalError);
return labelListList::null();
}
const Foam::scalarListList& Foam::faEdgeMapper::weights() const
{
FatalErrorIn
(
"const scalarListList& faEdgeMapper::weights() const"
) << "Requested interpolative weights for a direct mapper."
<< abort(FatalError);
return scalarListList::null();
}
// ************************************************************************* //

View File

@ -0,0 +1,173 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::faEdgeMapper
Description
FA edge mapper. Currently, edge-based finite area data is not mapped,
but only resized, since edge-based mapping data is not available
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
SourceFiles
faEdgeMapper.C
\*---------------------------------------------------------------------------*/
#ifndef faEdgeMapper_H
#define faEdgeMapper_H
#include "morphFieldMapper.H"
#include "faMesh.H"
#include "faceMapper.H"
#include "HashSet.H"
#include "mapPolyMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class faEdgeMapper Declaration
\*---------------------------------------------------------------------------*/
class faEdgeMapper
:
public morphFieldMapper
{
// Private data
//- Reference to mesh
const faMesh& mesh_;
//- Reference to mapPolyMesh
const mapPolyMesh& mpm_;
//- Old mesh size
label sizeBeforeMapping_;
// Demand-driven private data
mutable bool hasUnmapped_;
//- Direct addressing
mutable labelList* directAddrPtr_;
// Private Member Functions
//- Disallow default bitwise copy construct
faEdgeMapper(const faEdgeMapper&);
//- Disallow default bitwise assignment
void operator=(const faEdgeMapper&);
//- Calculate addressing
void calcAddressing() const;
//- Clear out local storage
void clearOut();
public:
// Constructors
//- Construct from components
faEdgeMapper
(
const faMesh& mesh,
const mapPolyMesh& mpm
);
// Destructor
virtual ~faEdgeMapper();
// Member Functions
//- Return size
virtual label size() const
{
return mesh_.nInternalEdges();
}
//- Return size of field before mapping
virtual label sizeBeforeMapping() const
{
return sizeBeforeMapping_;
}
//- Is the mapping direct
virtual bool direct() const
{
return true;
}
virtual bool hasUnmapped() const
{
return hasUnmapped_;
}
//- Return direct addressing
virtual const labelUList& directAddressing() const;
//- Return interpolated addressing
virtual const labelListList& addressing() const;
//- Return interpolaion weights
virtual const scalarListList& weights() const;
//- Are there any inserted faces
virtual bool insertedObjects() const
{
return false;
}
//- Return list of inserted faces
virtual const labelList& insertedObjectLabels() const
{
return labelList::null();
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,66 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "faMeshMapper.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::faMeshMapper::faMeshMapper
(
const faMesh& mesh,
const mapPolyMesh& mpm
)
:
mesh_(mesh),
nOldPoints_(mesh.nPoints()),
nOldEdges_(mesh.nEdges()),
nOldInternalEdges_(mesh.nInternalEdges()),
nOldFaces_(mesh.nFaces()),
oldPatchSizes_(mesh.boundary().size(), 0),
oldPatchStarts_(mesh.boundary().size(), -1),
oldPatchEdgeFaces_(mesh.boundary().size()),
areaMap_(mesh, mpm),
edgeMap_(mesh, mpm),
boundaryMap_(mesh, mpm)
{
// Capture old patch information
const faBoundaryMesh& patches = mesh.boundary();
forAll (patches, patchI)
{
oldPatchSizes_[patchI] = patches[patchI].size();
oldPatchStarts_[patchI] = patches[patchI].start();
oldPatchEdgeFaces_[patchI] = patches[patchI].edgeFaces();
}
}
// ************************************************************************* //

View File

@ -0,0 +1,221 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::faMeshMapper
Description
Class holds all the necessary information for mapping fields associated
with faMesh
Note
In order to capture all necessary mesh sizes and mapping data, mapper
is created with the OLD mesh, and provides new mesh data.
In the process, field mapping information is assembled from the old faMesh
and the mapping data
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
SourceFiles
faMeshMapper.C
\*---------------------------------------------------------------------------*/
#ifndef faMeshMapper_H
#define faMeshMapper_H
#include "faceMapper.H"
#include "faAreaMapper.H"
#include "faEdgeMapper.H"
#include "faBoundaryMeshMapper.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class faMesh;
class mapPolyMesh;
/*---------------------------------------------------------------------------*\
Class faMeshMapper Declaration
\*---------------------------------------------------------------------------*/
class faMeshMapper
{
// Private data
//- Reference to mesh
const faMesh& mesh_;
// Old mesh data
//- Number of old points
label nOldPoints_;
//- Number of old edges
label nOldEdges_;
//- Number of old internal edges
label nOldInternalEdges_;
//- Number of old faces
label nOldFaces_;
//- Old patch sizes
labelList oldPatchSizes_;
//- Old patch starts
labelList oldPatchStarts_;
//- Old patch edgeFaces
labelListList oldPatchEdgeFaces_;
// Mappers
//- Area mapper
faAreaMapper areaMap_;
//- Edge mapper
faEdgeMapper edgeMap_;
//- Boundary mapper
faBoundaryMeshMapper boundaryMap_;
// Private Member Functions
//- Disallow default bitwise copy construct
faMeshMapper(const faMeshMapper&);
//- Disallow default bitwise assignment
void operator=(const faMeshMapper&);
public:
// Constructors
//- Construct from components
faMeshMapper(const faMesh& mesh, const mapPolyMesh& mpm);
// Member Functions
//- Return reference to mesh
const faMesh& mesh() const
{
return mesh_;
}
//- Return reference to objectRegistry storing fields. Can be
// removed once fields stored on pointMesh.
const objectRegistry& thisDb() const
{
return mesh_.thisDb();
}
// Basic sizing information
//- Return number of old points
label nOldPoints() const
{
return nOldPoints_;
}
//- Return number of old edges
label nOldEdges() const
{
return nOldEdges_;
};
//- Return number of old internal edges
label nOldInternalEdges() const
{
return nOldInternalEdges_;
};
//- Return number of old faces
label nOldFaces() const
{
return nOldFaces_;
};
//- Return old patch sizes
const labelList& oldPatchSizes() const
{
return oldPatchSizes_;
};
//- Return old patch starts
const labelList& oldPatchStarts() const
{
return oldPatchStarts_;
};
//- Return old patch edgeFaces
const labelListList& oldPatchEdgeFaces() const
{
return oldPatchEdgeFaces_;
};
// Mappers
//- Return surface mapper
const faAreaMapper& areaMap() const
{
return areaMap_;
}
//- Return edge mapper
const faEdgeMapper& edgeMap() const
{
return edgeMap_;
}
//- Return boundary mapper
const faBoundaryMeshMapper& boundaryMap() const
{
return boundaryMap_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,162 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "faPatchMapper.H"
#include "faPatch.H"
#include "faBoundaryMesh.H"
#include "faMesh.H"
#include "mapPolyMesh.H"
#include "faceMapper.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::faPatchMapper::calcAddressing() const
{
if (directAddrPtr_)
{
FatalErrorIn
(
"void faPatchMapper::calcAddressing() const)"
) << "Addressing already calculated"
<< abort(FatalError);
}
// Compatibility change HJ, 12/Aug/2017
hasUnmapped_ = false;
directAddrPtr_ = new labelList(patch_.size(), 0);
labelList& addr = *directAddrPtr_;
// Make a map of old edgeFaces, giving edge index in patch given the new
// face label next to the patch
// Create edge index lookup
Map<label> edgeIndexLookup;
const labelList& reverseFaceMap = mpm_.reverseFaceMap();
forAll (oldEdgeFaces_, oefI)
{
if (reverseFaceMap[oldEdgeFaces_[oefI]] > -1)
{
// Face has survived. Insert its label under new face index
edgeIndexLookup.insert(reverseFaceMap[oldEdgeFaces_[oefI]], oefI);
}
}
// Go through new edgeFaces and for each edge try to locate old index
const labelList& ef = patch_.edgeFaces();
forAll (ef, efI)
{
if (edgeIndexLookup.found(ef[efI]))
{
addr[efI] = edgeIndexLookup[ef[efI]];
}
else
{
// Not found: map from zero
addr[efI] = 0;
// Compatibility change HJ, 12/Aug/2017
hasUnmapped_ = true;
}
}
}
void Foam::faPatchMapper::clearOut()
{
deleteDemandDrivenData(directAddrPtr_);
hasUnmapped_ = false;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::faPatchMapper::faPatchMapper
(
const faPatch& patch,
const mapPolyMesh& mpm
)
:
patch_(patch),
mpm_(mpm),
sizeBeforeMapping_(patch.size()),
oldEdgeFaces_(patch.edgeFaces()),
hasUnmapped_(false),
directAddrPtr_(NULL)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::faPatchMapper::~faPatchMapper()
{
clearOut();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::labelUList& Foam::faPatchMapper::directAddressing() const
{
if (!directAddrPtr_)
{
calcAddressing();
}
return *directAddrPtr_;
}
const Foam::labelListList& Foam::faPatchMapper::addressing() const
{
FatalErrorIn
(
"const labelListList& faPatchMapper::addressing() const"
) << "Requested interpolative addressing for a direct mapper."
<< abort(FatalError);
return labelListList::null();
}
const Foam::scalarListList& Foam::faPatchMapper::weights() const
{
FatalErrorIn
(
"const scalarListList& faPatchMapper::weights() const"
) << "Requested interpolative weights for a direct mapper."
<< abort(FatalError);
return scalarListList::null();
}
// ************************************************************************* //

View File

@ -0,0 +1,166 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::faPatchMapper
Description
Mapping class for a faPatchField. Edge mapping is calculated based on
faceCells comparison of old and new patch
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
SourceFiles
faPatchMapper.C
\*---------------------------------------------------------------------------*/
#ifndef faPatchMapper_H
#define faPatchMapper_H
#include "faPatchFieldMapper.H"
#include "faceMapper.H"
#include "faPatch.H"
#include "primitiveFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class faPatch;
class mapPolyMesh;
/*---------------------------------------------------------------------------*\
Class faPatchMapper Declaration
\*---------------------------------------------------------------------------*/
class faPatchMapper
:
public faPatchFieldMapper
{
// Private data
//- Reference to patch
const faPatch& patch_;
//- Reference to mapPolyMesh
const mapPolyMesh& mpm_;
//- Size before mapping
const label sizeBeforeMapping_;
//- faceCells before mapping
const labelList oldEdgeFaces_;
// Demand-driven private data
mutable bool hasUnmapped_;
//- Direct addressing
mutable labelList* directAddrPtr_;
// Private Member Functions
//- Disallow default bitwise copy construct
faPatchMapper(const faPatchMapper&);
//- Disallow default bitwise assignment
void operator=(const faPatchMapper&);
//- Calculate addressing for mapping with inserted cells
void calcAddressing() const;
//- Clear out local storage
void clearOut();
public:
// Constructors
//- Construct from mappers
faPatchMapper
(
const faPatch& patch,
const mapPolyMesh& mpm
);
// Destructor
virtual ~faPatchMapper();
// Member Functions
//- Return size
virtual label size() const
{
return patch_.size();
}
//- Return size of field before mapping
virtual label sizeBeforeMapping() const
{
return sizeBeforeMapping_;
}
//- Is the mapping direct
virtual bool direct() const
{
return true;
}
virtual bool hasUnmapped() const
{
return hasUnmapped_;
}
//- Return direct addressing
virtual const labelUList& directAddressing() const;
//- Return interpolated addressing
virtual const labelListList& addressing() const;
//- Return interpolaion weights
virtual const scalarListList& weights() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,246 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
\*---------------------------------------------------------------------------*/
#include "faMesh.H"
#include "mapPolyMesh.H"
#include "MapFaFields.H"
#include "faMeshMapper.H"
#include "areaFields.H"
#include "edgeFields.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::faMesh::updateMesh(const mapPolyMesh& mpm)
{
if (debug)
{
Info<< "bool faMesh::updateMesh(const mapPolyMesh& mpm) : "
<< "Updating mesh" << endl;
}
// if (!mpm.morphing())
// {
// // No topo change
// return false;
// }
// Create fa mesh mapper, using the old mesh
const faMeshMapper mapper(*this, mpm);
// Rebuild mesh
// Cast away const for interface reasons. HJ, 12/Aug/2011
faMesh& m = const_cast<faMesh&>(*this);
// Clear existing mesh data
clearOut();
// Set new labels
m.faceLabels_ = mapper.areaMap().newFaceLabels();
const indirectPrimitivePatch& bp = patch();
// Collect patch data
const label nTotalEdges = bp.nEdges();
const label nInternalEdges = bp.nInternalEdges();
const labelListList& edgeFaces = bp.edgeFaces();
labelListList patchEdges(boundary_.size());
// Special handling required for faces that have more than one edge
// Each patch will be visited separately
labelList edgeToPatch(nTotalEdges - nInternalEdges, -1);
const labelList& newFaceLabelsMap = mapper.areaMap().newFaceLabelsMap();
const labelListList& oldPatchEdgeFaces = mapper.oldPatchEdgeFaces();
forAll (oldPatchEdgeFaces, patchI)
{
labelList& curPatchEdges = patchEdges[patchI];
curPatchEdges.setSize(nTotalEdges - nInternalEdges);
label nCurPatchEdges = 0;
// Note: it is possible to pick up the old-to-new boundary patch
// mapping, but currently this is not done. HJ, 13/Aug/2011
// Make a fast lookup
labelHashSet oldFaceLookup(oldPatchEdgeFaces[patchI]);
for (label edgeI = nInternalEdges; edgeI < nTotalEdges; edgeI++)
{
if (edgeToPatch[edgeI - nInternalEdges] > -1)
{
// Edge already found; continue with the next one
continue;
}
// Boundary edges will only have one face next to them
const label oldFaceIndex = newFaceLabelsMap[edgeFaces[edgeI][0]];
if (oldFaceIndex > -1)
{
// Old face exists. See if it has got an edge in this patch
if (oldFaceLookup.found(oldFaceIndex))
{
// Face found, add it to the patch
curPatchEdges[nCurPatchEdges] = edgeI;
nCurPatchEdges++;
edgeToPatch[edgeI - nInternalEdges] = patchI;
}
}
}
// Collected all faces for the current patch
curPatchEdges.setSize(nCurPatchEdges);
}
// Set new edges for all patches
forAll (m.boundary_, patchI)
{
m.boundary_[patchI].resetEdges(patchEdges[patchI]);
}
m.setPrimitiveMeshData();
// Create global mesh data
if (Pstream::parRun())
{
globalData();
}
// Calculate topology for the patches (processor-processor comms etc.)
m.boundary_.updateMesh();
// Calculate the geometry for the patches (transformation tensors etc.)
m.boundary_.calcGeometry();
// Map fields
mapFields(mapper);
// Map old areas
mapOldAreas(mapper);
// Update edge interpolation
edgeInterpolation::movePoints();
return;
}
void Foam::faMesh::mapFields(const faMeshMapper& mapper) const
{
// Map all the areaFields in the objectRegistry
MapGeometricFields<scalar, faPatchField, faMeshMapper, areaMesh>(mapper);
MapGeometricFields<vector, faPatchField, faMeshMapper, areaMesh>(mapper);
MapGeometricFields<sphericalTensor, faPatchField, faMeshMapper, areaMesh>
(mapper);
MapGeometricFields<symmTensor, faPatchField, faMeshMapper, areaMesh>
(mapper);
MapGeometricFields<tensor, faPatchField, faMeshMapper, areaMesh>(mapper);
// Map all the edgeFields in the objectRegistry
MapGeometricFields<scalar, faePatchField, faMeshMapper, edgeMesh>(mapper);
MapGeometricFields<vector, faePatchField, faMeshMapper, edgeMesh>(mapper);
MapGeometricFields<sphericalTensor, faePatchField, faMeshMapper, edgeMesh>
(mapper);
MapGeometricFields<symmTensor, faePatchField, faMeshMapper, edgeMesh>
(mapper);
MapGeometricFields<tensor, faePatchField, faMeshMapper, edgeMesh>(mapper);
}
void Foam::faMesh::mapOldAreas(const faMeshMapper& mapper) const
{
if (S0Ptr_)
{
if (debug)
{
InfoIn("void faMesh::mapOldAreas(const faMeshMapper& mapper)")
<< "Mapping old face areas." << endl;
}
scalarField& S0 = *S0Ptr_;
scalarField savedS0(S0);
S0.setSize(nFaces());
const labelList& faceMap = mapper.areaMap().newFaceLabelsMap();
// Map existing old areas; for new faces set area to zero
forAll (faceMap, faceI)
{
if (faceMap[faceI] > -1)
{
S0[faceI] = savedS0[faceMap[faceI]];
}
else
{
S0[faceI] = 0;
}
}
}
if (S00Ptr_)
{
if (debug)
{
InfoIn("void faMesh::mapOldAreas(const faMeshMapper& mapper)")
<< "Mapping old-old face areas." << endl;
}
scalarField& S00 = *S00Ptr_;
scalarField savedS00(S00);
S00.setSize(nFaces());
const labelList& faceMap = mapper.areaMap().newFaceLabelsMap();
// Map old areas for existing faces; for new faces, set area to zero
forAll (faceMap, faceI)
{
if (faceMap[faceI] > -1)
{
S00[faceI] = savedS00[faceMap[faceI]];
}
else
{
S00[faceI] = 0;
}
}
}
}
// ************************************************************************* //

View File

@ -0,0 +1,132 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "coupledFaPatch.H"
#include "transform.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
defineTypeNameAndDebug(coupledFaPatch, 0);
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
void coupledFaPatch::calcTransformTensors
(
const vector& Cf,
const vector& Cr,
const vector& nf,
const vector& nr
) const
{
if (mag(nf & nr) < 1 - SMALL)
{
separation_.setSize(0);
forwardT_ = tensorField(1, rotationTensor(-nr, nf));
reverseT_ = tensorField(1, rotationTensor(nf, -nr));
}
else
{
forwardT_.setSize(0);
reverseT_.setSize(0);
vector separation = (nf & (Cr - Cf))*nf;
if (mag(separation) > SMALL)
{
separation_ = vectorField(1, separation);
}
else
{
separation_.setSize(0);
}
}
}
void coupledFaPatch::calcTransformTensors
(
const vectorField& Cf,
const vectorField& Cr,
const vectorField& nf,
const vectorField& nr
) const
{
if (sum(mag(nf & nr)) < Cf.size() - SMALL)
{
separation_.setSize(0);
forwardT_.setSize(size());
reverseT_.setSize(size());
forAll (forwardT_, facei)
{
forwardT_[facei] = rotationTensor(-nr[facei], nf[facei]);
reverseT_[facei] = rotationTensor(nf[facei], -nr[facei]);
}
if (sum(mag(forwardT_ - forwardT_[0])) < SMALL)
{
forwardT_.setSize(1);
reverseT_.setSize(1);
}
}
else
{
forwardT_.setSize(0);
reverseT_.setSize(0);
separation_ = (nf&(Cr - Cf))*nf;
if (sum(mag(separation_)) < SMALL)
{
separation_.setSize(0);
}
else if (sum(mag(separation_ - separation_[0])) < SMALL)
{
separation_.setSize(1);
}
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
coupledFaPatch::~coupledFaPatch()
{}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,279 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
coupledFaPatch
Author
Zeljko Tukovic and Hrvoje Jasak
Description
coupledFaPatch is an abstract base class for patches that couple regions
of the computational domain e.g. cyclic, arbitrary interfaces, sliding
interfaces and processor-processor links.
SourceFiles
coupledFaPatch.C
\*---------------------------------------------------------------------------*/
#ifndef coupledFaPatch_H
#define coupledFaPatch_H
#include "lduInterface.H"
#include "faPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class coupledFaPatch Declaration
\*---------------------------------------------------------------------------*/
class coupledFaPatch
:
public lduInterface,
public faPatch
{
// Private data
//- offset (distance) vector from one side of the couple to the other
mutable vectorField separation_;
//- Face transformation tensor
mutable tensorField forwardT_;
//- Neighbour-cell transformation tensor
mutable tensorField reverseT_;
protected:
// Protected Member Functions
//- Make patch weighting factors
virtual void makeWeights(scalarField&) const = 0;
//- Make patch face - neighbour cell distances
virtual void makeDeltaCoeffs(scalarField&) const = 0;
//- Calculate the uniform transformation tensors
void calcTransformTensors
(
const vector& Cf,
const vector& Cr,
const vector& nf,
const vector& nr
) const;
//- Calculate the transformation tensors
void calcTransformTensors
(
const vectorField& Cf,
const vectorField& Cr,
const vectorField& nf,
const vectorField& nr
) const;
public:
//- Runtime type information
TypeName("coupled");
// Constructors
//- Construct from components
coupledFaPatch
(
const word& name,
const labelList& edgeLabels,
const label index,
const faBoundaryMesh& bm,
const label ngbPolyPatchIndex
)
:
faPatch(name, edgeLabels, index, bm, ngbPolyPatchIndex)
{}
//- Construct from dictionary
coupledFaPatch
(
const word& name,
const dictionary& dict,
const label index,
const faBoundaryMesh& bm
)
:
faPatch(name, dict, index, bm)
{}
//- Destructor
virtual ~coupledFaPatch();
// Member Functions
// Access
//- Return true because this patch is coupled
virtual bool coupled() const
{
return true;
}
//- Are the coupled planes separated
bool separated() const
{
return separation_.size();
}
//- Return the offset (distance) vector from one side of the couple
// to the other
const vectorField& separation() const
{
if (!separation_.size())
{
FatalErrorIn("coupledFaPatch::separation() const")
<< "Coupled patches are not separated"
<< abort(FatalError);
}
return separation_;
}
//- Return face transformation tensor
const tensorField& forwardT() const
{
if (!forwardT_.size())
{
FatalErrorIn("coupledFaPatch::forwardT() const")
<< "Coupled planes do not need transformation"
<< abort(FatalError);
}
return forwardT_;
}
//- Return neighbour-cell transformation tensor
const tensorField& reverseT() const
{
if (!reverseT_.size())
{
FatalErrorIn("coupledFaPatch::forwardT() const")
<< "Coupled planes do not need transformation"
<< abort(FatalError);
}
return reverseT_;
}
//- Are the cyclic planes parallel
bool parallel() const
{
return forwardT_.size() == 0;
}
//- Initialise the calculation of the patch geometry
virtual void initGeometry() = 0;
//- Calculate the patch geometry
virtual void calcGeometry() = 0;
//- Initialise the patches for moving points
virtual void initMovePoints(const pointField&) = 0;
//- Correct patches after moving points
virtual void movePoints(const pointField&) = 0;
// Access functions for demand driven data
//- Return delta (P to N) vectors across coupled patch
virtual tmp<vectorField> delta() const = 0;
// Interface transfer functions
//- Return faceCell addressing: lduInterface virtual function
virtual const labelUList& faceCells() const
{
return edgeFaces();
}
//- Return the values of the given internal data adjacent to
// the interface as a field
virtual tmp<labelField> interfaceInternalField
(
const labelUList& internalData
) const = 0;
//- Initialise interface data transfer
virtual void initTransfer
(
const Pstream::commsTypes commsType,
const labelUList& interfaceData
) const
{}
//- Transfer and return neighbour field
virtual tmp<labelField> transfer
(
const Pstream::commsTypes commsType,
const labelUList& interfaceData
) const = 0;
//- Initialise neighbour field transfer
virtual void initInternalFieldTransfer
(
const Pstream::commsTypes commsType,
labelUList& iF
) const
{}
//- Return neighbour field
virtual tmp<labelField> internalFieldTransfer
(
const Pstream::commsTypes commsType,
const labelUList& iF
) const = 0;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,356 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "cyclicFaPatch.H"
#include "coupledPolyPatch.H"
#include "addToRunTimeSelectionTable.H"
#include "transform.H"
#include "faMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
defineTypeNameAndDebug(cyclicFaPatch, 0);
addToRunTimeSelectionTable(faPatch, cyclicFaPatch, dictionary);
const Foam::scalar cyclicFaPatch::matchTol_ = 1e-3;
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::cyclicFaPatch::calcTransforms()
{
if (size() > 0)
{
pointField half0Ctrs(size()/2);
pointField half1Ctrs(size()/2);
for (label i=0; i<size()/2; i++)
{
half0Ctrs[i] = this->edgeCentres()[i];
half1Ctrs[i] = this->edgeCentres()[i+size()/2];
}
vectorField half0Normals(size()/2);
vectorField half1Normals(size()/2);
vectorField eN = edgeNormals()*magEdgeLengths();
scalar maxMatchError = 0;
label errorEdge = -1;
for (label edgei = 0; edgei < size()/2; edgei++)
{
half0Normals[edgei] = eN[edgei];
label nbrEdgei = edgei + size()/2;
half1Normals[edgei] = eN[nbrEdgei];
scalar magLe = mag(half0Normals[edgei]);
scalar nbrMagLe = mag(half1Normals[edgei]);
scalar avLe = (magLe + nbrMagLe)/2.0;
if (magLe < ROOTVSMALL && nbrMagLe < ROOTVSMALL)
{
// Undetermined normal. Use dummy normal to force separation
// check. (note use of sqrt(VSMALL) since that is how mag
// scales)
half0Normals[edgei] = point(1, 0, 0);
half1Normals[edgei] = half0Normals[edgei];
}
else if(mag(magLe - nbrMagLe)/avLe > matchTol_)
{
// Error in area matching. Find largest error
maxMatchError =
Foam::max(maxMatchError, mag(magLe - nbrMagLe)/avLe);
errorEdge = edgei;
}
else
{
half0Normals[edgei] /= magLe;
half1Normals[edgei] /= nbrMagLe;
}
}
// Check for error in edge matching
if (maxMatchError > matchTol_)
{
label nbrEdgei = errorEdge + size()/2;
scalar magLe = mag(half0Normals[errorEdge]);
scalar nbrMagLe = mag(half1Normals[errorEdge]);
scalar avLe = (magLe + nbrMagLe)/2.0;
FatalErrorIn
(
"cyclicFaPatch::calcTransforms()"
) << "edge " << errorEdge
<< " area does not match neighbour "
<< nbrEdgei << " by "
<< 100*mag(magLe - nbrMagLe)/avLe
<< "% -- possible edge ordering problem." << endl
<< "patch:" << name()
<< " my area:" << magLe
<< " neighbour area:" << nbrMagLe
<< " matching tolerance:" << matchTol_
<< endl
<< "Mesh edge:" << start() + errorEdge
<< endl
<< "Neighbour edge:" << start() + nbrEdgei
<< endl
<< "Other errors also exist, only the largest is reported. "
<< "Please rerun with cyclic debug flag set"
<< " for more information." << exit(FatalError);
}
// Calculate transformation tensors
calcTransformTensors
(
half0Ctrs,
half1Ctrs,
half0Normals,
half1Normals
);
// Check transformation tensors
if (!parallel())
{
if (forwardT().size() > 1 || reverseT().size() > 1)
{
SeriousErrorIn
(
"void cyclicFaPatch::calcTransforms()"
) << "Transformation tensor is not constant for the cyclic "
<< "patch. Please reconsider your setup and definition of "
<< "cyclic boundaries." << endl;
}
}
}
}
// Make patch weighting factors
void cyclicFaPatch::makeWeights(scalarField& w) const
{
const scalarField& magL = magEdgeLengths();
scalarField deltas = edgeNormals() & faPatch::delta();
label sizeby2 = deltas.size()/2;
scalar maxMatchError = 0;
label errorEdge = -1;
for (label edgei = 0; edgei < sizeby2; edgei++)
{
scalar avL = (magL[edgei] + magL[edgei + sizeby2])/2.0;
if
(
mag(magL[edgei] - magL[edgei + sizeby2])/avL
> matchTol_
)
{
// Found error. Look for largest matching error
maxMatchError =
Foam::max
(
maxMatchError,
mag(magL[edgei] - magL[edgei + sizeby2])/avL
);
errorEdge = edgei;
}
scalar di = deltas[edgei];
scalar dni = deltas[edgei + sizeby2];
w[edgei] = dni/(di + dni);
w[edgei + sizeby2] = 1 - w[edgei];
}
// Check for error in matching
if (maxMatchError > matchTol_)
{
scalar avL = (magL[errorEdge] + magL[errorEdge + sizeby2])/2.0;
FatalErrorIn("cyclicFaPatch::makeWeights(scalarField& w) const")
<< "edge " << errorEdge << " and " << errorEdge + sizeby2
<< " areas do not match by "
<< 100*mag(magL[errorEdge] - magL[errorEdge + sizeby2])/avL
<< "% -- possible edge ordering problem." << nl
<< "Cyclic area match tolerance = "
<< matchTol_ << " patch: " << name()
<< abort(FatalError);
}
}
// Make patch edge - neighbour cell distances
void cyclicFaPatch::makeDeltaCoeffs(scalarField& dc) const
{
scalarField deltas = edgeNormals() & faPatch::delta();
label sizeby2 = deltas.size()/2;
for (label edgei = 0; edgei < sizeby2; edgei++)
{
scalar di = deltas[edgei];
scalar dni = deltas[edgei + sizeby2];
dc[edgei] = 1.0/(di + dni);
dc[edgei + sizeby2] = dc[edgei];
}
}
void Foam::cyclicFaPatch::initGeometry()
{
faPatch::initGeometry();
}
void Foam::cyclicFaPatch::calcGeometry()
{
faPatch::calcGeometry();
calcTransforms();
}
void Foam::cyclicFaPatch::initMovePoints(const pointField& p)
{
faPatch::initMovePoints(p);
}
void Foam::cyclicFaPatch::movePoints(const pointField& p)
{
faPatch::movePoints(p);
calcTransforms();
}
// Return delta (P to N) vectors across coupled patch
tmp<vectorField> cyclicFaPatch::delta() const
{
vectorField patchD = faPatch::delta();
label sizeby2 = patchD.size()/2;
tmp<vectorField> tpdv(new vectorField(patchD.size()));
vectorField& pdv = tpdv.ref();
// Do the transformation if necessary
if (parallel())
{
for (label edgei = 0; edgei < sizeby2; edgei++)
{
vector ddi = patchD[edgei];
vector dni = patchD[edgei + sizeby2];
pdv[edgei] = ddi - dni;
pdv[edgei + sizeby2] = -pdv[edgei];
}
}
else
{
for (label edgei = 0; edgei < sizeby2; edgei++)
{
vector ddi = patchD[edgei];
vector dni = patchD[edgei + sizeby2];
pdv[edgei] = ddi - transform(forwardT()[0], dni);
pdv[edgei + sizeby2] = -transform(reverseT()[0], pdv[edgei]);
}
}
return tpdv;
}
label Foam::cyclicPolyPatch::neighbPatchID() const
{
NotImplemented;
return -1;
}
tmp<labelField> cyclicFaPatch::interfaceInternalField
(
const labelUList& internalData
) const
{
return patchInternalField(internalData);
}
tmp<labelField> cyclicFaPatch::transfer
(
const Pstream::commsTypes,
const labelUList& interfaceData
) const
{
tmp<labelField> tpnf(new labelField(this->size()));
labelField& pnf = tpnf.ref();
label sizeby2 = this->size()/2;
for (label edgei=0; edgei<sizeby2; edgei++)
{
pnf[edgei] = interfaceData[edgei + sizeby2];
pnf[edgei + sizeby2] = interfaceData[edgei];
}
return tpnf;
}
tmp<labelField> cyclicFaPatch::internalFieldTransfer
(
const Pstream::commsTypes commsType,
const labelUList& iF
) const
{
const labelUList& edgeCells = this->faceCells();
tmp<labelField> tpnf(new labelField(this->size()));
labelField& pnf = tpnf.ref();
label sizeby2 = this->size()/2;
for (label edgei=0; edgei<sizeby2; edgei++)
{
pnf[edgei] = iF[edgeCells[edgei + sizeby2]];
pnf[edgei + sizeby2] = iF[edgeCells[edgei]];
}
return tpnf;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,201 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::cyclicFaPatch
Description
Cyclic-plane patch.
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
SourceFiles
cyclicFaPatch.C
\*---------------------------------------------------------------------------*/
#ifndef cyclicFaPatch_H
#define cyclicFaPatch_H
#include "coupledFaPatch.H"
#include "cyclicLduInterface.H"
#include "cyclicPolyPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class cyclicFaPatch Declaration
\*---------------------------------------------------------------------------*/
class cyclicFaPatch
:
public coupledFaPatch,
public cyclicLduInterface
{
// Private data
// Private member functions
void calcTransforms();
protected:
// Protected static data
//- Relative tolerance (for geometric matching). Is factor of
// maximum edge length per face.
static const scalar matchTol_;
// Protected Member functions
//- Make patch weighting factors
void makeWeights(scalarField&) const;
//- Make patch face - neighbour cell distances
void makeDeltaCoeffs(scalarField&) const;
public:
//- Runtime type information
TypeName("cyclic");
// Constructors
//- Construct from dictionary
cyclicFaPatch
(
const word& name,
const dictionary& dict,
const label index,
const faBoundaryMesh& bm
)
:
coupledFaPatch(name, dict, index, bm)
{}
//- Destructor
virtual ~cyclicFaPatch()
{}
// Member functions
// Access
//- Is this the master side? Yes: it contains both sets of faces
virtual bool master() const
{
return true;
}
//- Return neighbour
virtual label neighbPatchID() const
{
NotImplemented;
return index();
}
virtual bool owner() const
{
return master();
}
//- Return processor number
virtual const cyclicLduInterface& neighbPatch() const
{
NotImplemented;
return *this;
}
//- Return face transformation tensor
virtual const tensorField& forwardT() const
{
return coupledFaPatch::forwardT();
}
//- Return neighbour-cell transformation tensor
virtual const tensorField& reverseT() const
{
return coupledFaPatch::reverseT();
}
//- Initialise the calculation of the patch geometry
virtual void initGeometry();
//- Calculate the patch geometry
virtual void calcGeometry();
//- Initialise the patches for moving points
virtual void initMovePoints(const pointField&);
//- Correct patches after moving points
virtual void movePoints(const pointField&);
//- Return delta (P to N) vectors across coupled patch
virtual tmp<vectorField> delta() const;
// Interface transfer functions
//- Return the values of the given internal data adjacent to
// the interface as a field
virtual tmp<labelField> interfaceInternalField
(
const labelUList& internalData
) const;
//- Transfer and return neighbour field
virtual tmp<labelField> transfer
(
const Pstream::commsTypes commsType,
const labelUList& interfaceData
) const;
//- Return neighbour field
virtual tmp<labelField> internalFieldTransfer
(
const Pstream::commsTypes commsType,
const labelUList& internalData
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,63 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
\*---------------------------------------------------------------------------*/
#include "emptyFaPatch.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Patch name
defineTypeNameAndDebug(emptyFaPatch, 0);
// Add the patch constructor functions to the hash tables
addToRunTimeSelectionTable(faPatch, emptyFaPatch, dictionary);
// Over-riding the face normals return from the underlying patch
// This is the only piece of info used out of the underlying primitivePatch
// I choose to store it there because it is used in primitive patch operations
// and it should not be duplicated as before. However, to ensure everything
// in the empty patch is sized to zero, we shall here return a regerence to
// a zero-sized field (it does not matter what the field is
//
// const vectorField& emptyFaPatch::edgeNormals() const
// {
// return faceAreas();
// }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,139 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
emptyFaPatch
Description
A patch which will not exist in the faMesh. Typical example is a front and
back plane of a 2-D geometry
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
SourceFiles
emptyFaPatch.C
\*---------------------------------------------------------------------------*/
#ifndef emptyFaPatch_H
#define emptyFaPatch_H
#include "faPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class emptyFaPatch Declaration
\*---------------------------------------------------------------------------*/
class emptyFaPatch
:
public faPatch
{
public:
//- Runtime type information
TypeName("empty");
// Constructors
//- Construct from components
emptyFaPatch
(
const word& name,
const labelList& edgeLabels,
const label index,
const faBoundaryMesh& bm,
const label ngbPolyPatchIndex
)
:
faPatch(name, edgeLabels, index, bm, ngbPolyPatchIndex)
{}
//- Construct from dictionary
emptyFaPatch
(
const word& name,
const dictionary& dict,
const label index,
const faBoundaryMesh& bm
)
:
faPatch(name, dict, index, bm)
{}
//- Construct and return a clone, resetting the edge list
// and boundary mesh
virtual autoPtr<faPatch> clone
(
const faBoundaryMesh& bm,
const labelList& edgeLabels,
const label index,
const label ngbPolyPatchIndex
) const
{
return autoPtr<faPatch>
(
new emptyFaPatch
(
name(),
edgeLabels,
index,
bm,
ngbPolyPatchIndex
)
);
}
// Member Functions
virtual label size() const
{
return 0;
}
//- Return face normals. Over-riding base class return to get zero size
//
// virtual const vectorField& edgeNormals() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,534 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
\*---------------------------------------------------------------------------*/
#include "processorFaPatch.H"
#include "addToRunTimeSelectionTable.H"
#include "IPstream.H"
#include "OPstream.H"
#include "transformField.H"
#include "faBoundaryMesh.H"
#include "faMesh.H"
#include "globalMeshData.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
defineTypeNameAndDebug(processorFaPatch, 0);
addToRunTimeSelectionTable(faPatch, processorFaPatch, dictionary);
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
processorFaPatch::~processorFaPatch()
{
deleteDemandDrivenData(neighbPointsPtr_);
deleteDemandDrivenData(nonGlobalPatchPointsPtr_);
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::label Foam::processorFaPatch::comm() const
{
return boundaryMesh().mesh().comm();
}
int Foam::processorFaPatch::tag() const
{
return Pstream::msgType();
}
void processorFaPatch::makeNonGlobalPatchPoints() const
{
// If it is not runing parallel or there are no global points
// create a 1->1 map
// Can not use faGlobalMeshData at this point yet
if
(
!Pstream::parRun()
|| !boundaryMesh().mesh()().globalData().nGlobalPoints()
// || !boundaryMesh().mesh().globalData().nGlobalPoints()
)
{
nonGlobalPatchPointsPtr_ = new labelList(nPoints());
labelList& ngpp = *nonGlobalPatchPointsPtr_;
forAll(ngpp, i)
{
ngpp[i] = i;
}
}
else
{
// Get reference to shared points
const labelList& sharedPoints =
boundaryMesh().mesh()().globalData().sharedPointLabels();
nonGlobalPatchPointsPtr_ = new labelList(nPoints());
labelList& ngpp = *nonGlobalPatchPointsPtr_;
const labelList& faMeshPatchPoints = pointLabels();
const labelList& meshPoints =
boundaryMesh().mesh().patch().meshPoints();
label noFiltPoints = 0;
forAll (faMeshPatchPoints, pointI)
{
label curP = meshPoints[faMeshPatchPoints[pointI]];
bool found = false;
forAll (sharedPoints, sharedI)
{
if (sharedPoints[sharedI] == curP)
{
found = true;
break;
}
}
if (!found)
{
ngpp[noFiltPoints] = pointI;
noFiltPoints++;
}
}
ngpp.setSize(noFiltPoints);
// // Get reference to shared points
// const labelList& sharedPoints =
// boundaryMesh().mesh().globalData().sharedPointLabels();
// nonGlobalPatchPointsPtr_ = new labelList(nPoints());
// labelList& ngpp = *nonGlobalPatchPointsPtr_;
// const labelList& patchPoints = pointLabels();
// label noFiltPoints = 0;
// forAll (patchPoints, pointI)
// {
// label curP = patchPoints[pointI];
// bool found = false;
// forAll (sharedPoints, pI)
// {
// if (sharedPoints[pI] == curP)
// {
// found = true;
// break;
// }
// }
// if (!found)
// {
// ngpp[noFiltPoints] = pointI;
// noFiltPoints++;
// }
// }
// ngpp.setSize(noFiltPoints);
}
}
void processorFaPatch::initGeometry()
{
if (Pstream::parRun())
{
OPstream toNeighbProc
(
Pstream::commsTypes::blocking,
neighbProcNo(),
3*(sizeof(label) + size()*sizeof(vector))
);
toNeighbProc
<< edgeCentres()
<< edgeLengths()
<< edgeFaceCentres();
}
}
void processorFaPatch::calcGeometry()
{
if (Pstream::parRun())
{
{
IPstream fromNeighbProc
(
Pstream::commsTypes::blocking,
neighbProcNo(),
3*(sizeof(label) + size()*sizeof(vector))
);
fromNeighbProc
>> neighbEdgeCentres_
>> neighbEdgeLengths_
>> neighbEdgeFaceCentres_;
}
const scalarField& magEl = magEdgeLengths();
forAll(magEl, edgei)
{
scalar nmagEl = mag(neighbEdgeLengths_[edgei]);
scalar avEl = (magEl[edgei] + nmagEl)/2.0;
if (mag(magEl[edgei] - nmagEl)/avEl > 1e-6)
{
FatalErrorIn
(
"processorFvPatch::makeWeights(scalarField& w) const"
) << "edge " << edgei
<< " length does not match neighbour by "
<< 100*mag(magEl[edgei] - nmagEl)/avEl
<< "% -- possible edge ordering problem"
<< exit(FatalError);
}
}
calcTransformTensors
(
edgeCentres(),
neighbEdgeCentres_,
edgeNormals(),
neighbEdgeLengths_/mag(neighbEdgeLengths_)
);
}
}
void processorFaPatch::initMovePoints(const pointField& p)
{
faPatch::movePoints(p);
initGeometry();
}
void processorFaPatch::movePoints(const pointField&)
{
calcGeometry();
}
void processorFaPatch::initUpdateMesh()
{
// For completeness
faPatch::initUpdateMesh();
deleteDemandDrivenData(neighbPointsPtr_);
if (Pstream::parRun())
{
// Express all points as patch edge and index in edge.
labelList patchEdge(nPoints());
labelList indexInEdge(nPoints());
const edgeList::subList patchEdges =
patchSlice(boundaryMesh().mesh().edges());
const labelListList& ptEdges = pointEdges();
for (label patchPointI = 0; patchPointI < nPoints(); patchPointI++)
{
label edgeI = ptEdges[patchPointI][0];
patchEdge[patchPointI] = edgeI;
const edge& e = patchEdges[edgeI];
indexInEdge[patchPointI] =
findIndex
(
e,
pointLabels()[patchPointI]
);
}
OPstream toNeighbProc
(
Pstream::commsTypes::blocking,
neighbProcNo(),
2*sizeof(label) + 2*nPoints()*sizeof(label)
);
toNeighbProc
<< patchEdge
<< indexInEdge;
}
}
void processorFaPatch::updateMesh()
{
// For completeness
faPatch::updateMesh();
if (Pstream::parRun())
{
labelList nbrPatchEdge(nPoints());
labelList nbrIndexInEdge(nPoints());
{
// Note cannot predict exact size since edgeList not (yet) sent as
// binary entity but as List of edges.
IPstream fromNeighbProc
(
Pstream::commsTypes::blocking,
neighbProcNo()
);
fromNeighbProc
>> nbrPatchEdge
>> nbrIndexInEdge;
}
if (nbrPatchEdge.size() == nPoints())
{
// Convert neighbour edges and indices into face back into
// my edges and points.
neighbPointsPtr_ = new labelList(nPoints());
labelList& neighbPoints = *neighbPointsPtr_;
const edgeList::subList patchEdges =
patchSlice(boundaryMesh().mesh().edges());
forAll(nbrPatchEdge, nbrPointI)
{
// Find edge and index in edge on this side.
const edge& e = patchEdges[nbrPatchEdge[nbrPointI]];
label index = 1 - nbrIndexInEdge[nbrPointI];
label patchPointI = findIndex(pointLabels(), e[index]);
neighbPoints[patchPointI] = nbrPointI;
}
}
else
{
// Differing number of points. Probably patch includes
// part of a cyclic.
neighbPointsPtr_ = NULL;
}
}
}
const labelList& processorFaPatch::neighbPoints() const
{
if (!neighbPointsPtr_)
{
// Was probably created from cyclic patch and hence the
// number of edges or points might differ on both
// sides of the processor patch since one side might have
// it merged with another bit of geometry
FatalErrorIn("processorFaPatch::neighbPoints() const")
<< "No extended addressing calculated for patch " << name()
<< nl
<< "This can happen if the number of points on both"
<< " sides of the two coupled patches differ." << nl
<< "This happens if the processorPatch was constructed from"
<< " part of a cyclic patch."
<< abort(FatalError);
}
return *neighbPointsPtr_;
}
// Make patch weighting factors
void processorFaPatch::makeWeights(scalarField& w) const
{
if (Pstream::parRun())
{
// The face normals point in the opposite direction on the other side
scalarField neighbEdgeCentresCn
(
(
neighbEdgeLengths()
/mag(neighbEdgeLengths())
)
& (
neighbEdgeCentres()
- neighbEdgeFaceCentres())
);
w = neighbEdgeCentresCn/
(
(edgeNormals() & faPatch::delta())
+ neighbEdgeCentresCn
);
}
else
{
w = 1.0;
}
}
// Make patch edge - neighbour face distances
void processorFaPatch::makeDeltaCoeffs(scalarField& dc) const
{
if (Pstream::parRun())
{
dc = (1.0 - weights())/(edgeNormals() & faPatch::delta());
}
else
{
dc = 1.0/(edgeNormals() & faPatch::delta());
}
}
// Return delta (P to N) vectors across coupled patch
tmp<vectorField> processorFaPatch::delta() const
{
if (Pstream::parRun())
{
// To the transformation if necessary
if (parallel())
{
return
faPatch::delta()
- (
neighbEdgeCentres()
- neighbEdgeFaceCentres()
);
}
else
{
return
faPatch::delta()
- transform
(
forwardT(),
(
neighbEdgeCentres()
- neighbEdgeFaceCentres()
)
);
}
}
else
{
return faPatch::delta();
}
}
const labelList& processorFaPatch::nonGlobalPatchPoints() const
{
if (!nonGlobalPatchPointsPtr_)
{
makeNonGlobalPatchPoints();
}
return *nonGlobalPatchPointsPtr_;
}
tmp<labelField> processorFaPatch::interfaceInternalField
(
const labelUList& internalData
) const
{
return patchInternalField(internalData);
}
void processorFaPatch::initTransfer
(
const Pstream::commsTypes commsType,
const labelUList& interfaceData
) const
{
send(commsType, interfaceData);
}
tmp<labelField> processorFaPatch::transfer
(
const Pstream::commsTypes commsType,
const labelUList&
) const
{
return receive<label>(commsType, this->size());
}
void processorFaPatch::initInternalFieldTransfer
(
const Pstream::commsTypes commsType,
const labelUList& iF
) const
{
send(commsType, patchInternalField(iF)());
}
tmp<labelField> processorFaPatch::internalFieldTransfer
(
const Pstream::commsTypes commsType,
const labelUList&
) const
{
return receive<label>(commsType, this->size());
}
// Write
void processorFaPatch::write(Ostream& os) const
{
faPatch::write(os);
os.writeKeyword("myProcNo") << myProcNo_
<< token::END_STATEMENT << nl;
os.writeKeyword("neighbProcNo") << neighbProcNo_
<< token::END_STATEMENT << nl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,315 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
processorFaPatch
Description
Processor patch.
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
SourceFiles
processorFaPatch.C
\*---------------------------------------------------------------------------*/
#ifndef processorFaPatch_H
#define processorFaPatch_H
#include "coupledFaPatch.H"
#include "processorLduInterface.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class processorFaPatch Declaration
\*---------------------------------------------------------------------------*/
class processorFaPatch
:
public coupledFaPatch,
public processorLduInterface
{
// Private data
//- My processro number
int myProcNo_;
//- Neighbour processor number
int neighbProcNo_;
//- Processor-neighbbour patch edge centres
vectorField neighbEdgeCentres_;
//- Processor-neighbbour patch edge lengths
vectorField neighbEdgeLengths_;
//- Processor-neighbbour patch neighbour face centres
vectorField neighbEdgeFaceCentres_;
//- Corresponding neighbouring local point label for every local point
// (so localPoints()[i] == neighb.localPoints()[neighbPoints_[i]])
mutable labelList* neighbPointsPtr_;
//- The set of labels of the processor patch points which are
// non-global, i.e. present in this processor patch
mutable labelList* nonGlobalPatchPointsPtr_;
protected:
// Protected Member functions
//- Make patch weighting factors
void makeWeights(scalarField&) const;
//- Make patch face - neighbour cell distances
void makeDeltaCoeffs(scalarField&) const;
//- Find non-globa patch points
void makeNonGlobalPatchPoints() const;
// Geometry functions
//- Initialise the calculation of the patch geometry
void initGeometry();
//- Calculate the patch geometry
void calcGeometry();
//- Initialise the patches for moving points
void initMovePoints(const pointField&);
//- Correct patches after moving points
void movePoints(const pointField&);
//- Initialise the update of the patch topology
virtual void initUpdateMesh();
//- Update of the patch topology
virtual void updateMesh();
public:
//- Runtime type information
// TypeName(processorPolyPatch::typeName_());
TypeName("processor");
// Constructors
//- Construct from components
processorFaPatch
(
const word& name,
const labelList& edgeLabels,
const label index,
const faBoundaryMesh& bm,
const label ngbPolyPatchIndex,
const label myProcNo,
const label neighbProcNo
)
:
coupledFaPatch(name, edgeLabels, index, bm, ngbPolyPatchIndex),
myProcNo_(myProcNo),
neighbProcNo_(neighbProcNo),
neighbEdgeCentres_(),
neighbEdgeLengths_(),
neighbEdgeFaceCentres_(),
neighbPointsPtr_(NULL),
nonGlobalPatchPointsPtr_(NULL)
{}
//- Construct from dictionary
processorFaPatch
(
const word& name,
const dictionary& dict,
const label index,
const faBoundaryMesh& bm
)
:
coupledFaPatch(name, dict, index, bm),
myProcNo_(readLabel(dict.lookup("myProcNo"))),
neighbProcNo_(readLabel(dict.lookup("neighbProcNo"))),
neighbEdgeCentres_(),
neighbEdgeLengths_(),
neighbEdgeFaceCentres_(),
neighbPointsPtr_(NULL),
nonGlobalPatchPointsPtr_(NULL)
{}
//- Destructor
virtual ~processorFaPatch();
// Member functions
//- Return interface size
virtual label interfaceSize() const
{
return size();
}
//- Return processor number
int myProcNo() const
{
return myProcNo_;
}
//- Return neigbour processor number
int neighbProcNo() const
{
return neighbProcNo_;
}
//- Return true if running parallel
virtual bool coupled() const
{
if (Pstream::parRun())
{
return true;
}
else
{
return false;
}
}
//- Is this the master side?
virtual bool master() const
{
return (myProcNo_ < neighbProcNo_);
}
// Communications support
//- Return communicator used for communication
virtual label comm() const;
//- Return message tag to use for communication
virtual int tag() const;
//- Return face transformation tensor
virtual const tensorField& forwardT() const
{
return coupledFaPatch::forwardT();
}
//- Return delta (P to N) vectors across coupled patch
virtual tmp<vectorField> delta() const;
//- Return processor-neighbbour patch edge centres
const vectorField& neighbEdgeCentres() const
{
return neighbEdgeCentres_;
}
//- Return processor-neighbbour patch edge lengths
const vectorField& neighbEdgeLengths() const
{
return neighbEdgeLengths_;
}
//- Return processor-neighbbour patch neighbour face centres
const vectorField& neighbEdgeFaceCentres() const
{
return neighbEdgeFaceCentres_;
}
//- Return neighbour point labels. This is for my local point the
// corresponding local point on the other side. Call
// faBoundaryMesh::updateMesh() on all processors
// before using this.
const labelList& neighbPoints() const;
//- Return the set of labels of the processor patch points which are
// non-global, i.e. present in this processorFaPatch
const labelList& nonGlobalPatchPoints() const;
// Interface transfer functions
//- Return the values of the given internal data adjacent to
// the interface as a field
virtual tmp<labelField> interfaceInternalField
(
const labelUList& internalData
) const;
//- Initialise interface data transfer
virtual void initTransfer
(
const Pstream::commsTypes commsType,
const labelUList& interfaceData
) const;
//- Transfer and return neighbour field
virtual tmp<labelField> transfer
(
const Pstream::commsTypes commsType,
const labelUList& interfaceData
) const;
//- Initialise neighbour field transfer
virtual void initInternalFieldTransfer
(
const Pstream::commsTypes commsType,
const labelUList& internalData
) const;
//- Return neighbour field
virtual tmp<labelField> internalFieldTransfer
(
const Pstream::commsTypes commsType,
const labelUList& internalData
) const;
//- Write the patch data as a dictionary
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,92 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
\*---------------------------------------------------------------------------*/
#include "symmetryFaPatch.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
defineTypeNameAndDebug(symmetryFaPatch, 0);
addToRunTimeSelectionTable(faPatch, symmetryFaPatch, dictionary);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void symmetryFaPatch::makeCorrVecs(vectorField& cv) const
{
// Non-orthogonal correction not allowed. HJ, 16/Apr/2009
cv = vector::zero;
}
// * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * * * //
// Construct from components
symmetryFaPatch::symmetryFaPatch
(
const word& name,
const labelList& edgeLabels,
const label index,
const faBoundaryMesh& bm,
const label ngbPolyPatchIndex
)
:
faPatch(name, edgeLabels, index, bm, ngbPolyPatchIndex)
{}
//- Construct from dictionary
symmetryFaPatch::symmetryFaPatch
(
const word& name,
const dictionary& dict,
const label index,
const faBoundaryMesh& bm
)
:
faPatch(name, dict, index, bm)
{
if(ngbPolyPatchIndex() == -1)
{
FatalErrorIn
(
"symmetryFaPatch::symmetryFaPatch(const word&, const dictionary&, const label, const faBoundaryMesh&)"
) << "Neighbour polyPatch index is not specified for faPatch "
<< this->name() << exit(FatalError);
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,130 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::symmetryFaPatch
Description
Symmetry-plane patch.
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
SourceFiles
symmetryFaPatch.C
\*---------------------------------------------------------------------------*/
#ifndef symmetryFaPatch_H
#define symmetryFaPatch_H
#include "faPatch.H"
#include "symmetryPolyPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class symmetryFaPatch Declaration
\*---------------------------------------------------------------------------*/
class symmetryFaPatch
:
public faPatch
{
protected:
// Protected Member Functions
//- Make patch face non-orthogonality correction vectors
virtual void makeCorrVecs(vectorField&) const;
public:
//- Runtime type information
TypeName(symmetryPolyPatch::typeName_());
// Constructors
//- Construct from components
symmetryFaPatch
(
const word& name,
const labelList& edgeLabels,
const label index,
const faBoundaryMesh& bm,
const label ngbPolyPatchIndex
);
//- Construct from dictionary
symmetryFaPatch
(
const word& name,
const dictionary& dict,
const label index,
const faBoundaryMesh& bm
);
//- Construct and return a clone, resetting the edge list
// and boundary mesh
virtual autoPtr<faPatch> clone
(
const faBoundaryMesh& bm,
const labelList& edgeLabels,
const label index,
const label ngbPolyPatchIndex
) const
{
return autoPtr<faPatch>
(
new symmetryFaPatch
(
name(), edgeLabels, index, bm, ngbPolyPatchIndex
)
);
}
// Destructor
virtual ~symmetryFaPatch()
{}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,134 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
\*---------------------------------------------------------------------------*/
#include "wedgeFaPatch.H"
#include "addToRunTimeSelectionTable.H"
#include "faBoundaryMesh.H"
#include "wedgePolyPatch.H"
#include "polyMesh.H"
#include "faMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
defineTypeNameAndDebug(wedgeFaPatch, 0);
addToRunTimeSelectionTable(faPatch, wedgeFaPatch, dictionary);
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
void wedgeFaPatch::findAxisPoint() const
{
// Find axis point
labelList ptLabels = pointLabels();
labelListList ptEdges = pointEdges();
const vectorField& points = boundaryMesh().mesh().points();
const scalarField& magL = magEdgeLengths();
forAll(ptEdges, pointI)
{
if( ptEdges[pointI].size() == 1 )
{
scalar r = mag((I-axis()*axis())&points[ptLabels[pointI]]);
if( r < magL[ptEdges[pointI][0]] )
{
axisPoint_ = ptLabels[pointI];
break;
}
}
}
axisPointChecked_ = true;
}
// * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * * * //
//- Construct from polyPatch
wedgeFaPatch::wedgeFaPatch
(
const word& name,
const dictionary& dict,
const label index,
const faBoundaryMesh& bm
)
:
faPatch(name, dict, index, bm),
wedgePolyPatchPtr_(NULL),
axisPoint_(-1),
axisPointChecked_(false)
{
if(ngbPolyPatchIndex() == -1)
{
FatalErrorIn
(
"wedgeFaPatch::wedgeFaPatch(const word&, const dictionary&, const label, const faBoundaryMesh&)"
) << "Neighbour polyPatch index is not specified for faPatch "
<< this->name() << exit(FatalError);
}
if
(
bm.mesh()().boundaryMesh()[ngbPolyPatchIndex()].type()
== wedgePolyPatch::typeName
)
{
const wedgePolyPatch& wedge =
refCast<const wedgePolyPatch>
(
bm.mesh()().boundaryMesh()[ngbPolyPatchIndex()]
);
wedgePolyPatchPtr_ = &wedge;
}
else
{
FatalErrorIn
(
"wedgeFaPatch::wedgeFaPatch(const word&, const dictionary&, const label, const faBoundaryMesh&)"
) << "Neighbour polyPatch is not of type "
<< wedgePolyPatch::typeName
<< exit(FatalError);
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,146 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
wedgeFaPatch
Description
Wedge front and back plane patch.
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
SourceFiles
wedgeFaPatch.C
\*---------------------------------------------------------------------------*/
#ifndef wedgeFaPatch_H
#define wedgeFaPatch_H
#include "faPatch.H"
#include "wedgePolyPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class wedgeFaPatch Declaration
\*---------------------------------------------------------------------------*/
class wedgeFaPatch
:
public faPatch
{
// Private data
const wedgePolyPatch* wedgePolyPatchPtr_;
//- Axis point label
mutable label axisPoint_;
//- Is it axis point looked for?
mutable bool axisPointChecked_;
//- Finde axis point
void findAxisPoint() const;
public:
//- Runtime type information
TypeName("wedge");
// Constructors
//- Construct from dictionary
wedgeFaPatch
(
const word& name,
const dictionary& dict,
const label index,
const faBoundaryMesh& bm
);
// Destructor
virtual ~wedgeFaPatch()
{}
// Member functions
// Access
//- Return axis of the wedge
const vector& axis() const
{
return wedgePolyPatchPtr_->axis();
}
//- Return plane normal between the wedge boundaries
const vector& centreNormal() const
{
return wedgePolyPatchPtr_->centreNormal();
}
//- Return face transformation tensor
const tensor& edgeT() const
{
return wedgePolyPatchPtr_->faceT();
}
//- Return neighbour-cell transformation tensor
const tensor& faceT() const
{
return wedgePolyPatchPtr_->cellT();
}
//- Return axis point label
label axisPoint() const
{
if(axisPoint_ == -1 && !axisPointChecked_)
{
findAxisPoint();
}
return axisPoint_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,504 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "faPatch.H"
#include "addToRunTimeSelectionTable.H"
#include "faBoundaryMesh.H"
#include "faMesh.H"
#include "areaFields.H"
#include "edgeFields.H"
#include "polyMesh.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(faPatch, 0);
defineRunTimeSelectionTable(faPatch, dictionary);
addToRunTimeSelectionTable(faPatch, faPatch, dictionary);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::faPatch::clearOut()
{
deleteDemandDrivenData(edgeFacesPtr_);
deleteDemandDrivenData(pointLabelsPtr_);
deleteDemandDrivenData(pointEdgesPtr_);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::faPatch::faPatch
(
const word& name,
const labelList& edgeLabels,
const label index,
const faBoundaryMesh& bm,
const label ngbPolyPatchIndex
)
:
labelList(edgeLabels),
patchIdentifier(name, index),
ngbPolyPatchIndex_(ngbPolyPatchIndex),
boundaryMesh_(bm),
edgeFacesPtr_(NULL),
pointLabelsPtr_(NULL),
pointEdgesPtr_(NULL)
{}
// Construct from dictionary
Foam::faPatch::faPatch
(
const word& name,
const dictionary& dict,
const label index,
const faBoundaryMesh& bm
)
:
labelList(dict.lookup("edgeLabels")),
patchIdentifier(name, dict, index),
ngbPolyPatchIndex_(readInt(dict.lookup("ngbPolyPatchIndex"))),
boundaryMesh_(bm),
edgeFacesPtr_(NULL),
pointLabelsPtr_(NULL),
pointEdgesPtr_(NULL)
{}
Foam::faPatch::faPatch(const faPatch& p, const faBoundaryMesh& bm)
:
labelList(p),
patchIdentifier(p, p.index()),
ngbPolyPatchIndex_(p.ngbPolyPatchIndex_),
boundaryMesh_(bm),
edgeFacesPtr_(NULL),
pointLabelsPtr_(NULL),
pointEdgesPtr_(NULL)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::faPatch::~faPatch()
{
clearOut();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::label Foam::faPatch::ngbPolyPatchIndex() const
{
return ngbPolyPatchIndex_;
}
const Foam::faBoundaryMesh& Foam::faPatch::boundaryMesh() const
{
return boundaryMesh_;
}
Foam::label Foam::faPatch::start() const
{
return boundaryMesh().mesh().patchStarts()[index()];
}
const Foam::labelList& Foam::faPatch::pointLabels() const
{
if (!pointLabelsPtr_)
{
calcPointLabels();
}
return *pointLabelsPtr_;
}
void Foam::faPatch::calcPointLabels() const
{
SLList<label> labels;
UList<edge> edges =
patchSlice(boundaryMesh().mesh().edges());
forAll(edges, edgeI)
{
bool existStart = false;
bool existEnd = false;
for
(
SLList<label>::iterator iter = labels.begin();
iter != labels.end();
++iter
)
{
if(*iter == edges[edgeI].start())
{
existStart = true;
}
if(*iter == edges[edgeI].end())
{
existEnd = true;
}
}
if(!existStart)
{
labels.append(edges[edgeI].start());
}
if(!existEnd)
{
labels.append(edges[edgeI].end());
}
}
pointLabelsPtr_ = new labelList(labels);
}
void Foam::faPatch::calcPointEdges() const
{
labelList points = pointLabels();
const edgeList::subList e =
patchSlice(boundaryMesh().mesh().edges());
// set up storage for pointEdges
List<SLList<label> > pointEdgs(points.size());
forAll (e, edgeI)
{
const edge& curPoints = e[edgeI];
forAll (curPoints, pointI)
{
label localPointIndex =
findIndex(points, curPoints[pointI]);
pointEdgs[localPointIndex].append(edgeI);
}
}
// sort out the list
pointEdgesPtr_ = new labelListList(pointEdgs.size());
labelListList& pEdges = *pointEdgesPtr_;
forAll (pointEdgs, pointI)
{
pEdges[pointI].setSize(pointEdgs[pointI].size());
label i = 0;
for
(
SLList<label>::iterator curEdgesIter = pointEdgs[pointI].begin();
curEdgesIter != pointEdgs[pointI].end();
++curEdgesIter, ++i
)
{
pEdges[pointI][i] = curEdgesIter();
}
}
}
const Foam::labelListList& Foam::faPatch::pointEdges() const
{
if (!pointEdgesPtr_)
{
calcPointEdges();
}
return *pointEdgesPtr_;
}
Foam::labelList Foam::faPatch::ngbPolyPatchFaces() const
{
labelList ngbFaces;
if(ngbPolyPatchIndex() == -1)
{
return ngbFaces;
}
ngbFaces.setSize(faPatch::size());
const faMesh& aMesh = boundaryMesh().mesh();
const polyMesh& pMesh = aMesh();
const indirectPrimitivePatch& patch = aMesh.patch();
const labelListList& edgeFaces = pMesh.edgeFaces();
labelList faceCells (patch.size(), -1);
forAll (faceCells, faceI)
{
label faceID = aMesh.faceLabels()[faceI];
faceCells[faceI] = pMesh.faceOwner()[faceID];
}
labelList meshEdges =
patch.meshEdges
(
pMesh.edges(),
pMesh.cellEdges(),
faceCells
);
forAll(ngbFaces, edgeI)
{
ngbFaces[edgeI] = -1;
label curEdge = (*this)[edgeI];
label curPMeshEdge = meshEdges[curEdge];
forAll(edgeFaces[curPMeshEdge], faceI)
{
label curFace = edgeFaces[curPMeshEdge][faceI];
label curPatchID = pMesh.boundaryMesh().whichPatch(curFace);
if (curPatchID == ngbPolyPatchIndex())
{
ngbFaces[edgeI] = curFace;
}
}
if(ngbFaces[edgeI] == -1)
{
Info<< "faPatch::edgeNgbPolyPatchFaces(): "
<< "Problem with determination of edge ngb faces!" << endl;
}
}
return ngbFaces;
}
Foam::tmp<Foam::vectorField> Foam::faPatch::ngbPolyPatchFaceNormals() const
{
tmp<vectorField> tfN(new vectorField());
vectorField& fN = tfN.ref();
if (ngbPolyPatchIndex() == -1)
{
return tfN;
}
fN.setSize(faPatch::size());
labelList ngbFaces = ngbPolyPatchFaces();
const polyMesh& pMesh = boundaryMesh().mesh()();
const faceList& faces = pMesh.faces();
const pointField& points = pMesh.points();
forAll(fN, faceI)
{
fN[faceI] = faces[ngbFaces[faceI]].normal(points)
/faces[ngbFaces[faceI]].mag(points);
}
return tfN;
}
Foam::tmp<Foam::vectorField> Foam::faPatch::ngbPolyPatchPointNormals() const
{
if (ngbPolyPatchIndex() == -1)
{
return tmp<vectorField>(new vectorField());
}
labelListList pntEdges = pointEdges();
tmp<vectorField> tpN(new vectorField(pntEdges.size(), vector::zero));
vectorField& pN = tpN.ref();
vectorField faceNormals = ngbPolyPatchFaceNormals();
forAll(pN, pointI)
{
forAll(pntEdges[pointI], edgeI)
{
pN[pointI] += faceNormals[pntEdges[pointI][edgeI]];
}
}
pN /= mag(pN);
return tpN;
}
const Foam::labelUList& Foam::faPatch::edgeFaces() const
{
if (!edgeFacesPtr_)
{
edgeFacesPtr_ = new labelList::subList
(
patchSlice(boundaryMesh().mesh().edgeOwner())
);
}
return *edgeFacesPtr_;
}
// Return the patch edge centres
const Foam::vectorField& Foam::faPatch::edgeCentres() const
{
return boundaryMesh().mesh().edgeCentres().boundaryField()[index()];
}
// Return the patch edges length vectors
const Foam::vectorField& Foam::faPatch::edgeLengths() const
{
return boundaryMesh().mesh().Le().boundaryField()[index()];
}
// Return the patch edge length magnitudes
const Foam::scalarField& Foam::faPatch::magEdgeLengths() const
{
return boundaryMesh().mesh().magLe().boundaryField()[index()];
}
// Return the patch edge unit normals
Foam::tmp<Foam::vectorField> Foam::faPatch::edgeNormals() const
{
tmp<vectorField> eN(new vectorField(size()));
eN.ref() = edgeLengths()/magEdgeLengths();
return eN;
}
// Return the patch edge neighbour face centres
Foam::tmp<Foam::vectorField> Foam::faPatch::edgeFaceCentres() const
{
tmp<vectorField> tfc(new vectorField(size()));
vectorField& fc = tfc.ref();
// get reference to global face centres
const vectorField& gfc =
boundaryMesh().mesh().areaCentres().internalField();
const labelUList& faceLabels = edgeFaces();
forAll (faceLabels, edgeI)
{
fc[edgeI] = gfc[faceLabels[edgeI]];
}
return tfc;
}
// Return cell-centre to face-centre vector
Foam::tmp<Foam::vectorField> Foam::faPatch::delta() const
{
return edgeCentres() - edgeFaceCentres();
}
// Make delta coefficients as patch face - neighbour cell distances
void Foam::faPatch::makeDeltaCoeffs(scalarField& dc) const
{
dc = 1.0/(edgeNormals() & delta());
}
// Return delta coefficients
const Foam::scalarField& Foam::faPatch::deltaCoeffs() const
{
return boundaryMesh().mesh().deltaCoeffs().boundaryField()[index()];
}
void Foam::faPatch::makeWeights(scalarField& w) const
{
w = 1.0;
}
const Foam::scalarField& Foam::faPatch::weights() const
{
return boundaryMesh().mesh().weights().boundaryField()[index()];
}
void Foam::faPatch::movePoints(const pointField& points)
{}
void Foam::faPatch::resetEdges(const labelList& newEdges)
{
Info<< "Resetting patch edges" << endl;
labelList::operator=(newEdges);
clearOut();
}
void Foam::faPatch::write(Ostream& os) const
{
os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
patchIdentifier::write(os);
const labelList& edgeLabels = *this;
edgeLabels.writeEntry("edgeLabels", os);
os.writeKeyword("ngbPolyPatchIndex") << ngbPolyPatchIndex_
<< token::END_STATEMENT << nl;
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const faPatch& p)
{
p.write(os);
os.check("Ostream& operator<<(Ostream& f, const faPatch& p)");
return os;
}
// ************************************************************************* //

View File

@ -0,0 +1,380 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
faPatch
Description
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
SourceFiles
faPatch.C
newFaPatch.C
\*---------------------------------------------------------------------------*/
#ifndef faPatch_H
#define faPatch_H
#include "patchIdentifier.H"
#include "labelList.H"
#include "pointField.H"
#include "typeInfo.H"
#include "faPatchFieldsFwd.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class faBoundaryMesh;
/*---------------------------------------------------------------------------*\
Class faPatch Declaration
\*---------------------------------------------------------------------------*/
class faPatch
:
public labelList,
public patchIdentifier
{
private:
// Private data
//- Neighbour polyPatch index
const label ngbPolyPatchIndex_;
//- Reference to boundary mesh
const faBoundaryMesh& boundaryMesh_;
// Demand-driven private data
//- Edge-face addressing
mutable labelList::subList* edgeFacesPtr_;
//- Local points labels
mutable labelList* pointLabelsPtr_;
//- Point-edge addressing
mutable labelListList* pointEdgesPtr_;
// Private Member Functions
//- Disallow construct as copy
faPatch(const faPatch&);
//- Disallow assignment
void operator=(const faPatch&);
//- Clear out topological patch data
void clearOut();
protected:
// The faPatch geometry initialisation is called by faBoundaryMesh
friend class faBoundaryMesh;
//- Calculate patch point labels
void calcPointLabels() const;
//- Calculate patch point-edge addressing
void calcPointEdges() const;
//- Initialise the calculation of the patch geometry
virtual void initGeometry()
{}
//- Calculate the patch geometry
virtual void calcGeometry()
{}
//- Initialise the patches for moving points
virtual void initMovePoints(const pointField&)
{}
//- Correct patch after moving points
virtual void movePoints(const pointField&);
//- Initialise the update of the patch topology
virtual void initUpdateMesh()
{}
//- Update of the patch topology
virtual void updateMesh()
{}
public:
typedef faBoundaryMesh BoundaryMesh;
//- Runtime type information
TypeName("patch");
// Declare run-time constructor selection tables
declareRunTimeSelectionTable
(
autoPtr,
faPatch,
dictionary,
(
const word& name,
const dictionary& dict,
const label index,
const faBoundaryMesh& bm
),
(name, dict, index, bm)
);
// Constructors
//- Construct from components
faPatch
(
const word& name,
const labelList& edgeLabels,
const label index,
const faBoundaryMesh& bm,
const label ngbPolyPatchIndex
);
//- Construct from dictionary
faPatch
(
const word& name,
const dictionary& dict,
const label index,
const faBoundaryMesh& bm
);
//- Construct as copy, resetting the boundary mesh
faPatch(const faPatch&, const faBoundaryMesh&);
//- Construct and return a clone, resetting the edge list
// and boundary mesh
virtual autoPtr<faPatch> clone
(
const faBoundaryMesh& bm,
const labelList& edgeLabels,
const label index,
const label ngbPolyPatchIndex
) const
{
return autoPtr<faPatch>
(
new faPatch(name(), edgeLabels, index, bm, ngbPolyPatchIndex)
);
}
// Selectors
//- Return a pointer to a new patch created
// on freestore from dictionary
static autoPtr<faPatch> New
(
const word& name,
const dictionary& dict,
const label index,
const faBoundaryMesh& bm
);
// Destructor
virtual ~faPatch();
// Member Functions
//- Return number of patch points
label nPoints() const
{
return pointLabels().size();
}
//- Return neighbour polyPatch index
label ngbPolyPatchIndex() const;
//- Return boundaryMesh reference
const faBoundaryMesh& boundaryMesh() const;
//- Return true if this patch is coupled
virtual bool coupled() const
{
return false;
}
//- Patch start in edge list
label start() const;
//- Patch size
virtual label size() const
{
return labelList::size();
}
//- Return label of edge in patch from global edge label
inline label whichEdge(const label l) const
{
return l - start();
}
//- Slice list to patch
template<class T>
typename List<T>::subList patchSlice(const List<T>& l) const
{
return typename List<T>::subList(l, size(), start());
}
//- Write
virtual void write(Ostream&) const;
// Acces functions for geometrical data
//- Return patch point labels
const labelList& pointLabels() const;
//- Return patch point-edge addressing
const labelListList& pointEdges() const;
//- Return edge neighbour polyPatch faces
labelList ngbPolyPatchFaces() const;
//- Return normals of neighbour polyPatch faces
tmp<vectorField> ngbPolyPatchFaceNormals() const;
//- Return normals of neighbour polyPatch joined points
tmp<vectorField> ngbPolyPatchPointNormals() const;
//- Return edge-face addressing
const labelUList& edgeFaces() const;
//- Return edge centres
const vectorField& edgeCentres() const;
//- Return edge length vectors
const vectorField& edgeLengths() const;
//- Return edge length magnitudes
const scalarField& magEdgeLengths() const;
//- Return edge normals
tmp<vectorField> edgeNormals() const;
//- Return neighbour face centres
tmp<vectorField> edgeFaceCentres() const;
//- Return cell-centre to face-centre vector
// except for coupled patches for which the cell-centre
// to coupled-cell-centre vector is returned
virtual tmp<vectorField> delta() const;
// Access functions for demand driven data
//- Make patch weighting factors
virtual void makeWeights(scalarField&) const;
//- Return patch weighting factors
const scalarField& weights() const;
//- Make patch edge - neighbour face distances
virtual void makeDeltaCoeffs(scalarField&) const;
//- Return patch edge - neighbour face distances
const scalarField& deltaCoeffs() const;
// Topological changes
//- Reset edge list
void resetEdges(const labelList&);
// Evaluation functions
//- Return given internal field next to patch as patch field
template<class Type>
tmp<Field<Type> > patchInternalField(const UList<Type>&) const;
//- Return the corresponding patchField of the named field
template<class GeometricField, class Type>
const typename GeometricField::Patch& patchField
(
const GeometricField&
) const;
//- Lookup and return the patchField of the named field from the
// local objectRegistry.
// N.B. The dummy pointer arguments are used if this function is
// instantiated within a templated function to avoid a bug in gcc.
// See inletOutletFvPatchField.C and outletInletFvPatchField.C
template<class GeometricField, class Type>
const typename GeometricField::Patch& lookupPatchField
(
const word& name,
const GeometricField* = NULL,
const Type* = NULL
) const;
// Ostream Operator
friend Ostream& operator<<(Ostream&, const faPatch&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "faPatchTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,79 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
faPatchData
Description
Class which holds data needed for faPatch construction
SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef faPatchData_H
#define faPatchData_H
#include "labelList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class faPatchData Declaration
\*---------------------------------------------------------------------------*/
struct faPatchData
{
word name_;
word type_;
dictionary dict_;
label ownPolyPatchID_;
label ngbPolyPatchID_;
labelList edgeLabels_;
faPatchData()
:
name_(word::null),
type_(word::null),
ownPolyPatchID_(-1),
ngbPolyPatchID_(-1)
{}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,50 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "faPatch.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class GeometricField, class Type>
const typename GeometricField::Patch& Foam::faPatch::lookupPatchField
(
const word& name,
const GeometricField*,
const Type*
) const
{
return patchField<GeometricField, Type>
(
boundaryMesh().mesh()().objectRegistry::lookupObject<GeometricField>
(
name
)
);
}
// ************************************************************************* //

View File

@ -0,0 +1,57 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Typedef
faPatchList
Description
Container classes for faPatch
\*---------------------------------------------------------------------------*/
#ifndef faPatchList_H
#define faPatchList_H
#include "faPatch.H"
#include "PtrList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef PtrList<faPatch> faPatchList;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,62 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*----------------------------------------------------------------------------*/
#include "faPatch.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::tmp<Foam::Field<Type> > Foam::faPatch::patchInternalField
(
const UList<Type>& f
) const
{
tmp<Field<Type> > tpif(new Field<Type>(size()));
Field<Type>& pif = tpif.ref();
const labelUList& edgeFaces = this->edgeFaces();
forAll(pif, facei)
{
pif[facei] = f[edgeFaces[facei]];
}
return tpif;
}
template<class GeometricField, class Type>
const typename GeometricField::Patch& Foam::faPatch::patchField
(
const GeometricField& gf
) const
{
return gf.boundaryField()[index()];
}
// ************************************************************************* //

View File

@ -0,0 +1,81 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
\*---------------------------------------------------------------------------*/
#include "faPatch.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
autoPtr<faPatch> faPatch::New
(
const word& name,
const dictionary& dict,
const label index,
const faBoundaryMesh& bm
)
{
if (debug)
{
Info<< "faPatch::New(const word&, const dictionary&, const label, "
"const faBoundaryMesh&) : constructing faPatch"
<< endl;
}
word patchType(dict.lookup("type"));
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(patchType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalIOErrorIn
(
"faPatch::New(const word&, const dictionary&, "
"const label, const faBoundaryMesh&)",
dict
) << "Unknown faPatch type " << patchType << endl << endl
<< "Valid faPatch types are :" << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalIOError);
}
return autoPtr<faPatch>(cstrIter()(name, dict, index, bm));
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,85 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
faSolution
Description
Selector class for finite area solution.
faMesh is derived from faSolution so that all fields have access to the
faSolution from the mesh reference they hold.
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
\*---------------------------------------------------------------------------*/
#ifndef faSolution_H
#define faSolution_H
#include "solution.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class faSolution Declaration
\*---------------------------------------------------------------------------*/
class faSolution
:
public solution
{
// Private Member Functions
//- Disallow default bitwise copy construct and assignment
faSolution(const faSolution&);
void operator=(const faSolution&);
public:
// Constructors
//- Construct from objectRegistry
faSolution(const objectRegistry& obr)
:
solution(obr, "faSolution")
{}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,77 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
\*---------------------------------------------------------------------------*/
#include "faMesh.H"
#include "areaFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTemplate2TypeNameAndDebug(areaScalarField::Internal, 0);
defineTemplate2TypeNameAndDebug(areaVectorField::Internal, 0);
defineTemplate2TypeNameAndDebug(areaSphericalTensorField::Internal, 0);
defineTemplate2TypeNameAndDebug(areaSymmTensorField::Internal, 0);
defineTemplate2TypeNameAndDebug(areaTensorField::Internal, 0);
defineTemplateTypeNameAndDebug(areaScalarField, 0);
defineTemplateTypeNameAndDebug(areaVectorField, 0);
defineTemplateTypeNameAndDebug(areaSphericalTensorField, 0);
defineTemplateTypeNameAndDebug(areaSymmTensorField, 0);
defineTemplateTypeNameAndDebug(areaTensorField, 0);
template<>
tmp<GeometricField<scalar, faPatchField, areaMesh> >
GeometricField<scalar, faPatchField, areaMesh>::component
(
const direction
) const
{
return *this;
}
template<>
void GeometricField<scalar, faPatchField, areaMesh>::replace
(
const direction,
const GeometricField<scalar, faPatchField, areaMesh>& gsf
)
{
*this == gsf;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -0,0 +1,82 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
areaFields
Description
Finite area area (element) fields
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
SourceFiles
areaFields.C
\*---------------------------------------------------------------------------*/
#ifndef areaFields_H
#define areaFields_H
#include "objectRegistry.H"
#include "GeometricFields.H"
#include "areaFaMesh.H"
#include "faMesh.H"
#include "faPatchFields.H"
#include "areaFieldsFwd.H"
#include "calculatedFaPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<>
tmp<GeometricField<scalar, faPatchField, areaMesh> >
GeometricField<scalar, faPatchField, areaMesh>::component
(
const direction
) const;
template<>
void GeometricField<scalar, faPatchField, areaMesh>::replace
(
const direction,
const GeometricField<scalar, faPatchField, areaMesh>& sf
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,72 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
areaFields
Description
SourceFiles
areaFields.C
\*---------------------------------------------------------------------------*/
#ifndef areaFieldsFwd_H
#define areaFieldsFwd_H
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
class areaMesh;
template<class Type>
class faPatchField;
template<class Type, template<class> class PatchField, class GeoMesh>
class GeometricField;
typedef GeometricField<scalar, faPatchField, areaMesh> areaScalarField;
typedef GeometricField<vector, faPatchField, areaMesh> areaVectorField;
typedef GeometricField<sphericalTensor, faPatchField, areaMesh>
areaSphericalTensorField;
typedef GeometricField<symmTensor, faPatchField, areaMesh> areaSymmTensorField;
typedef GeometricField<tensor, faPatchField, areaMesh> areaTensorField;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,58 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
\*---------------------------------------------------------------------------*/
#include "faMesh.H"
#include "edgeFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTemplate2TypeNameAndDebug(edgeScalarField::Internal, 0);
defineTemplate2TypeNameAndDebug(edgeVectorField::Internal, 0);
defineTemplate2TypeNameAndDebug(edgeSphericalTensorField::Internal, 0);
defineTemplate2TypeNameAndDebug(edgeSymmTensorField::Internal, 0);
defineTemplate2TypeNameAndDebug(edgeTensorField::Internal, 0);
defineTemplateTypeNameAndDebug(edgeScalarField, 0);
defineTemplateTypeNameAndDebug(edgeVectorField, 0);
defineTemplateTypeNameAndDebug(edgeSphericalTensorField, 0);
defineTemplateTypeNameAndDebug(edgeSymmTensorField, 0);
defineTemplateTypeNameAndDebug(edgeTensorField, 0);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

Some files were not shown because too many files have changed in this diff Show More