Implicit treatment of coupled boundary conditions

This commit is contained in:
Sergio Ferraris
2021-08-03 20:08:49 +00:00
committed by Andrew Heather
parent 11e0db96d3
commit 53af23b9fb
308 changed files with 12354 additions and 527 deletions

View File

@ -21,6 +21,7 @@ EXE_INC = \
-I$(LIB_SRC)/regionModels/regionModel/lnInclude \ -I$(LIB_SRC)/regionModels/regionModel/lnInclude \
-I$(LIB_SRC)/regionFaModels\lnInclude -I$(LIB_SRC)/regionFaModels\lnInclude
EXE_LIBS = \ EXE_LIBS = \
-lfiniteVolume \ -lfiniteVolume \
-lfvOptions \ -lfvOptions \

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017 OpenCFD Ltd. Copyright (C) 2017-2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -54,6 +54,7 @@ Description
#include "loopControl.H" #include "loopControl.H"
#include "pressureControl.H" #include "pressureControl.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[]) int main(int argc, char *argv[])
@ -80,6 +81,8 @@ int main(int argc, char *argv[])
#include "solidRegionDiffusionNo.H" #include "solidRegionDiffusionNo.H"
#include "setInitialMultiRegionDeltaT.H" #include "setInitialMultiRegionDeltaT.H"
#include "createCoupledRegions.H"
while (runTime.run()) while (runTime.run())
{ {
#include "readTimeControls.H" #include "readTimeControls.H"
@ -109,8 +112,6 @@ int main(int argc, char *argv[])
forAll(fluidRegions, i) forAll(fluidRegions, i)
{ {
Info<< "\nSolving for fluid region "
<< fluidRegions[i].name() << endl;
#include "setRegionFluidFields.H" #include "setRegionFluidFields.H"
#include "readFluidMultiRegionPIMPLEControls.H" #include "readFluidMultiRegionPIMPLEControls.H"
#include "solveFluid.H" #include "solveFluid.H"
@ -118,13 +119,35 @@ int main(int argc, char *argv[])
forAll(solidRegions, i) forAll(solidRegions, i)
{ {
Info<< "\nSolving for solid region "
<< solidRegions[i].name() << endl;
#include "setRegionSolidFields.H" #include "setRegionSolidFields.H"
#include "readSolidMultiRegionPIMPLEControls.H" #include "readSolidMultiRegionPIMPLEControls.H"
#include "solveSolid.H" #include "solveSolid.H"
} }
if (coupled)
{
Info<< "\nSolving energy coupled regions " << endl;
fvMatrixAssemblyPtr->solve();
#include "correctThermos.H"
forAll(fluidRegions, i)
{
#include "setRegionFluidFields.H"
#include "readFluidMultiRegionPIMPLEControls.H"
Info<< "\nSolving for fluid region "
<< fluidRegions[i].name() << endl;
// --- PISO loop
for (int corr=0; corr<nCorr; corr++)
{
#include "pEqn.H"
}
turbulence.correct();
rho = thermo.rho();
Info<< "Min/max T:" << min(thermo.T()).value() << ' '
<< max(thermo.T()).value() << endl;
}
}
// Additional loops for energy solution only // Additional loops for energy solution only
if (!oCorr && nOuterCorr > 1) if (!oCorr && nOuterCorr > 1)
{ {
@ -152,9 +175,27 @@ int main(int argc, char *argv[])
#include "readSolidMultiRegionPIMPLEControls.H" #include "readSolidMultiRegionPIMPLEControls.H"
#include "solveSolid.H" #include "solveSolid.H"
} }
if (coupled)
{
Info<< "\nSolving energy coupled regions " << endl;
fvMatrixAssemblyPtr->solve();
#include "correctThermos.H"
forAll(fluidRegions, i)
{
#include "setRegionFluidFields.H"
rho = thermo.rho();
} }
} }
} }
}
}
if (coupled)
{
fvMatrixAssemblyPtr->clear();
}
runTime.write(); runTime.write();

View File

@ -3,6 +3,7 @@ EXE_INC = \
-I./fluid \ -I./fluid \
-I./solid \ -I./solid \
-I../solid \ -I../solid \
-I./../include \
-I$(LIB_SRC)/finiteVolume/cfdTools \ -I$(LIB_SRC)/finiteVolume/cfdTools \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \
@ -35,3 +36,4 @@ EXE_LIBS = \
-lregionModels \ -lregionModels \
-lsampling \ -lsampling \
-lregionFaModels -lregionFaModels

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017 OpenCFD Ltd. Copyright (C) 2017-2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -66,6 +66,7 @@ int main(int argc, char *argv[])
#include "createTime.H" #include "createTime.H"
#include "createMeshes.H" #include "createMeshes.H"
#include "createFields.H" #include "createFields.H"
#include "createCoupledRegions.H"
#include "initContinuityErrs.H" #include "initContinuityErrs.H"
while (runTime.loop()) while (runTime.loop())
@ -83,13 +84,27 @@ int main(int argc, char *argv[])
forAll(solidRegions, i) forAll(solidRegions, i)
{ {
Info<< "\nSolving for solid region "
<< solidRegions[i].name() << endl;
#include "setRegionSolidFields.H" #include "setRegionSolidFields.H"
#include "readSolidMultiRegionSIMPLEControls.H" #include "readSolidMultiRegionSIMPLEControls.H"
#include "solveSolid.H" #include "solveSolid.H"
} }
if (coupled)
{
Info<< "\nSolving energy coupled regions" << endl;
fvMatrixAssemblyPtr->solve();
#include "correctThermos.H"
forAll(fluidRegions, i)
{
#include "setRegionFluidFields.H"
#include "readSolidMultiRegionSIMPLEControls.H"
#include "pEqn.H"
turb.correct();
}
}
// Additional loops for energy solution only // Additional loops for energy solution only
{ {
loopControl looping(runTime, "SIMPLE", "energyCoupling"); loopControl looping(runTime, "SIMPLE", "energyCoupling");
@ -116,8 +131,26 @@ int main(int argc, char *argv[])
#include "readSolidMultiRegionSIMPLEControls.H" #include "readSolidMultiRegionSIMPLEControls.H"
#include "solveSolid.H" #include "solveSolid.H"
} }
if (coupled)
{
Info<< "\nSolving energy coupled regions.. " << endl;
fvMatrixAssemblyPtr->solve();
#include "correctThermos.H"
forAll(fluidRegions, i)
{
#include "setRegionFluidFields.H"
turb.correct();
} }
} }
}
}
if (coupled)
{
fvMatrixAssemblyPtr->clear();
}
runTime.write(); runTime.write();

View File

@ -20,6 +20,12 @@
fvOptions.constrain(EEqn); fvOptions.constrain(EEqn);
if (coupled)
{
fvMatrixAssemblyPtr->addFvMatrix(EEqn);
}
else
{
EEqn.solve(); EEqn.solve();
fvOptions.correct(he); fvOptions.correct(he);
@ -29,4 +35,5 @@
Info<< "Min/max T:" << min(thermo.T()).value() << ' ' Info<< "Min/max T:" << min(thermo.T()).value() << ' '
<< max(thermo.T()).value() << endl; << max(thermo.T()).value() << endl;
}
} }

View File

@ -2,7 +2,7 @@
MRF.correctBoundaryVelocity(U); MRF.correctBoundaryVelocity(U);
tmp<fvVectorMatrix> tUEqn UEqn =
( (
fvm::div(phi, U) fvm::div(phi, U)
+ MRF.DDt(rho, U) + MRF.DDt(rho, U)
@ -10,7 +10,6 @@
== ==
fvOptions(rho, U) fvOptions(rho, U)
); );
fvVectorMatrix& UEqn = tUEqn.ref();
UEqn.relax(); UEqn.relax();

View File

@ -21,6 +21,8 @@ PtrList<dimensionedScalar> rhoMin(fluidRegions.size());
PtrList<IOMRFZoneList> MRFfluid(fluidRegions.size()); PtrList<IOMRFZoneList> MRFfluid(fluidRegions.size());
PtrList<fv::options> fluidFvOptions(fluidRegions.size()); PtrList<fv::options> fluidFvOptions(fluidRegions.size());
PtrList<fvVectorMatrix> UEqFluid(fluidRegions.size());
const uniformDimensionedVectorField& g = meshObjects::gravity::New(runTime); const uniformDimensionedVectorField& g = meshObjects::gravity::New(runTime);
// Populate fluid field pointer lists // Populate fluid field pointer lists
@ -222,5 +224,11 @@ forAll(fluidRegions, i)
new fv::options(fluidRegions[i]) new fv::options(fluidRegions[i])
); );
UEqFluid.set
(
i,
new fvVectorMatrix(UFluid[i], dimForce)
);
turbulence[i].validate(); turbulence[i].validate();
} }

View File

@ -2,7 +2,7 @@
volScalarField rAU("rAU", 1.0/UEqn.A()); volScalarField rAU("rAU", 1.0/UEqn.A());
surfaceScalarField rhorAUf("rhorAUf", fvc::interpolate(rho*rAU)); surfaceScalarField rhorAUf("rhorAUf", fvc::interpolate(rho*rAU));
volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p_rgh)); volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p_rgh));
tUEqn.clear(); //tUEqn.clear();
surfaceScalarField phig(-rhorAUf*ghf*fvc::snGrad(rho)*mesh.magSf()); surfaceScalarField phig(-rhorAUf*ghf*fvc::snGrad(rho)*mesh.magSf());

View File

@ -22,6 +22,8 @@
IOMRFZoneList& MRF = MRFfluid[i]; IOMRFZoneList& MRF = MRFfluid[i];
fv::options& fvOptions = fluidFvOptions[i]; fv::options& fvOptions = fluidFvOptions[i];
fvVectorMatrix& UEqn = UEqFluid[i];
const dimensionedScalar initialMass const dimensionedScalar initialMass
( (
"initialMass", "initialMass",

View File

@ -12,8 +12,10 @@
#include "UEqn.H" #include "UEqn.H"
#include "EEqn.H" #include "EEqn.H"
if (!coupled)
{
#include "pEqn.H" #include "pEqn.H"
turb.correct(); turb.correct();
} }
} }
}

View File

@ -16,13 +16,21 @@
fvOptions.constrain(hEqn); fvOptions.constrain(hEqn);
hEqn.solve(); if (coupled)
{
fvOptions.correct(h); fvMatrixAssemblyPtr->addFvMatrix(hEqn);
} }
else
{
Info<< "\nSolving for solid region "
<< solidRegions[i].name() << endl;
hEqn.solve();
fvOptions.correct(h);
thermo.correct(); thermo.correct();
Info<< "Min/max T:" << min(thermo.T()).value() << ' ' Info<< "Min/max T:" << min(thermo.T()).value() << ' '
<< max(thermo.T()).value() << endl; << max(thermo.T()).value() << endl;
}
}
} }

View File

@ -7,6 +7,7 @@ EXE_INC = \
-I${phaseSystem}/twoPhaseCompressibleTurbulenceModels/lnInclude \ -I${phaseSystem}/twoPhaseCompressibleTurbulenceModels/lnInclude \
-I${phaseSystem}/multiphaseSystem/lnInclude \ -I${phaseSystem}/multiphaseSystem/lnInclude \
-I./fluid \ -I./fluid \
-I./solid \
-I../solid \ -I../solid \
-I../fluid \ -I../fluid \
-I../include \ -I../include \

View File

@ -0,0 +1,39 @@
if (finalIter)
{
mesh.data::add("finalIteration", true);
}
{
for (int nonOrth=0; nonOrth<=nNonOrthCorr; ++nonOrth)
{
fvScalarMatrix hEqn
(
fvm::ddt(betav*rho, h)
- (
thermo.isotropic()
? fvm::laplacian(betav*thermo.alpha(), h, "laplacian(alpha,h)")
: fvm::laplacian(betav*taniAlpha(), h, "laplacian(alpha,h)")
)
==
fvOptions(rho, h)
);
hEqn.relax();
fvOptions.constrain(hEqn);
hEqn.solve(mesh.solver(h.select(finalIter)));
fvOptions.correct(h);
}
thermo.correct();
Info<< "Min/max T:" << min(thermo.T()).value() << ' '
<< max(thermo.T()).value() << endl;
}
if (finalIter)
{
mesh.data::remove("finalIteration");
}

View File

@ -27,8 +27,13 @@
fvOptions.constrain(EEqn); fvOptions.constrain(EEqn);
if (coupled)
{
fvMatrixAssemblyPtr->addFvMatrix(EEqn);
}
else
{
EEqn.solve(mesh.solver(he.select(finalIter))); EEqn.solve(mesh.solver(he.select(finalIter)));
fvOptions.correct(he); fvOptions.correct(he);
thermo.correct(); thermo.correct();
@ -36,4 +41,5 @@
Info<< "Min/max T:" << min(thermo.T()).value() << ' ' Info<< "Min/max T:" << min(thermo.T()).value() << ' '
<< max(thermo.T()).value() << endl; << max(thermo.T()).value() << endl;
}
} }

View File

@ -2,7 +2,7 @@
MRF.correctBoundaryVelocity(U); MRF.correctBoundaryVelocity(U);
tmp<fvVectorMatrix> tUEqn UEqn =
( (
fvm::ddt(rho, U) + fvm::div(phi, U) fvm::ddt(rho, U) + fvm::div(phi, U)
+ MRF.DDt(rho, U) + MRF.DDt(rho, U)
@ -10,7 +10,6 @@
== ==
fvOptions(rho, U) fvOptions(rho, U)
); );
fvVectorMatrix& UEqn = tUEqn.ref();
UEqn.relax(); UEqn.relax();

View File

@ -16,6 +16,8 @@ PtrList<multivariateSurfaceInterpolationScheme<scalar>::fieldTable>
fieldsFluid(fluidRegions.size()); fieldsFluid(fluidRegions.size());
PtrList<volScalarField> QdotFluid(fluidRegions.size()); PtrList<volScalarField> QdotFluid(fluidRegions.size());
PtrList<fvVectorMatrix> UEqFluid(fluidRegions.size());
List<scalar> initialMassFluid(fluidRegions.size()); List<scalar> initialMassFluid(fluidRegions.size());
List<bool> frozenFlowFluid(fluidRegions.size(), false); List<bool> frozenFlowFluid(fluidRegions.size(), false);
@ -293,6 +295,12 @@ forAll(fluidRegions, i)
new fv::options(fluidRegions[i]) new fv::options(fluidRegions[i])
); );
UEqFluid.set
(
i,
new fvVectorMatrix(UFluid[i], dimForce)
);
turbulenceFluid[i].validate(); turbulenceFluid[i].validate();
pRefCellFluid[i] = -1; pRefCellFluid[i] = -1;

View File

@ -49,6 +49,8 @@
IOMRFZoneList& MRF = MRFfluid[i]; IOMRFZoneList& MRF = MRFfluid[i];
fv::options& fvOptions = fluidFvOptions[i]; fv::options& fvOptions = fluidFvOptions[i];
fvVectorMatrix& UEqn = UEqFluid[i];
const dimensionedScalar initialMass const dimensionedScalar initialMass
( (
"initialMass", "initialMass",

View File

@ -18,6 +18,10 @@ else
#include "YEqn.H" #include "YEqn.H"
#include "EEqn.H" #include "EEqn.H"
if (!coupled)
{
Info<< "\nSolving for fluid region " << fluidRegions[i].name() << endl;
// --- PISO loop // --- PISO loop
for (int corr=0; corr<nCorr; corr++) for (int corr=0; corr<nCorr; corr++)
{ {
@ -27,6 +31,7 @@ else
turbulence.correct(); turbulence.correct();
rho = thermo.rho(); rho = thermo.rho();
}
} }
if (finalIter) if (finalIter)

View File

@ -0,0 +1,20 @@
forAll(fluidRegions, i)
{
rhoThermo& thermo = thermoFluid[i];
radiation::radiationModel& rad = radiation[i];
fv::options& fvOptions = fluidFvOptions[i];
volScalarField& he = thermo.he();
fvOptions.correct(he);
thermo.correct();
rad.correct();
}
forAll(solidRegions, i)
{
solidThermo& thermo = thermos[i];
fv::options& fvOptions = solidHeatSources[i];
volScalarField& h = thermo.he();
fvOptions.correct(h);
thermo.correct();
}

View File

@ -0,0 +1,51 @@
fvSolution solutionDict(runTime);
bool coupled(solutionDict.getOrDefault("coupledEnergyField", false));
autoPtr<fvMatrix<scalar>> fvMatrixAssemblyPtr;
forAll(fluidRegions, i)
{
const rhoThermo& thermo = refCast<const rhoThermo>(thermoFluid[i]);
const auto& bpsi = thermo.T().boundaryField();
forAll (bpsi, patchI)
{
if (bpsi[patchI].useImplicit())
{
coupled = true;
}
}
}
forAll(solidRegions, i)
{
solidThermo& thermo = thermos[i];
const auto& bpsi = thermo.T().boundaryField();
forAll (bpsi, patchI)
{
if (bpsi[patchI].useImplicit())
{
coupled = true;
}
}
}
forAll(fluidRegions, i)
{
const rhoThermo& thermo = refCast<const rhoThermo>(thermoFluid[i]);
if (coupled)
{
Info << "Create fvMatrixAssembly." << endl;
fvMatrixAssemblyPtr.reset
(
new fvMatrix<scalar>
(
thermo.he(),
dimEnergy/dimTime
)
);
break;
}
}

View File

@ -1,11 +1,4 @@
if (finalIter)
{ {
mesh.data::add("finalIteration", true);
}
{
for (int nonOrth=0; nonOrth<=nNonOrthCorr; ++nonOrth)
{
fvScalarMatrix hEqn fvScalarMatrix hEqn
( (
fvm::ddt(betav*rho, h) fvm::ddt(betav*rho, h)
@ -22,18 +15,31 @@ if (finalIter)
fvOptions.constrain(hEqn); fvOptions.constrain(hEqn);
if (coupled)
{
fvMatrixAssemblyPtr->addFvMatrix(hEqn);
}
else
{
Info<< "\nSolving for solid region "<< solidRegions[i].name() << endl;
if (finalIter)
{
mesh.data::add("finalIteration", true);
}
hEqn.solve(mesh.solver(h.select(finalIter))); hEqn.solve(mesh.solver(h.select(finalIter)));
fvOptions.correct(h); fvOptions.correct(h);
}
thermo.correct(); thermo.correct();
Info<< "Min/max T:" << min(thermo.T()).value() << ' ' Info<< "Min/max T:" << min(thermo.T()).value() << ' '
<< max(thermo.T()).value() << endl; << max(thermo.T()).value() << endl;
}
if (finalIter) if (finalIter)
{ {
mesh.data::remove("finalIteration"); mesh.data::remove("finalIteration");
}
}
} }

View File

@ -11,6 +11,7 @@ else
phiHbyA += MRF.zeroFilter(fvc::interpolate(rAU)); phiHbyA += MRF.zeroFilter(fvc::interpolate(rAU));
} }
MRF.makeRelative(phiHbyA); MRF.makeRelative(phiHbyA);
if (p.needReference()) if (p.needReference())

View File

@ -1,5 +1,6 @@
EXE_INC = \ EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/transportModels \ -I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/transportModels/twoPhaseMixture/lnInclude \ -I$(LIB_SRC)/transportModels/twoPhaseMixture/lnInclude \
@ -9,6 +10,7 @@ EXE_INC = \
LIB_LIBS = \ LIB_LIBS = \
-lfiniteVolume \ -lfiniteVolume \
-lmeshTools \
-lgeometricVoF \ -lgeometricVoF \
-ltwoPhaseMixture \ -ltwoPhaseMixture \
-linterfaceProperties \ -linterfaceProperties \

View File

@ -1,6 +1,7 @@
EXE_INC = \ EXE_INC = \
-I$(LIB_SRC)/transportModels/twoPhaseMixture/lnInclude \ -I$(LIB_SRC)/transportModels/twoPhaseMixture/lnInclude \
-I$(LIB_SRC)/transportModels \ -I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/transportModels/incompressible/lnInclude \ -I$(LIB_SRC)/transportModels/incompressible/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude -I$(LIB_SRC)/finiteVolume/lnInclude
@ -8,4 +9,5 @@ LIB_LIBS = \
-ltwoPhaseMixture \ -ltwoPhaseMixture \
-ltwoPhaseProperties \ -ltwoPhaseProperties \
-lincompressibleTransportModels \ -lincompressibleTransportModels \
-lfiniteVolume -lfiniteVolume \
-lmeshTools

View File

@ -431,6 +431,7 @@ $(lduAddressing)/lduAddressing.C
$(lduAddressing)/lduInterface/lduInterface.C $(lduAddressing)/lduInterface/lduInterface.C
$(lduAddressing)/lduInterface/processorLduInterface.C $(lduAddressing)/lduInterface/processorLduInterface.C
$(lduAddressing)/lduInterface/cyclicLduInterface.C $(lduAddressing)/lduInterface/cyclicLduInterface.C
$(lduAddressing)/lduInterface/lduPrimitiveProcessorInterface.C
lduInterfaceFields = $(lduAddressing)/lduInterfaceFields lduInterfaceFields = $(lduAddressing)/lduInterfaceFields
$(lduInterfaceFields)/lduInterfaceField/lduInterfaceField.C $(lduInterfaceFields)/lduInterfaceField/lduInterfaceField.C

View File

@ -48,8 +48,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Forward declarations
class lduMatrix; class lduMatrix;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
@ -101,6 +100,8 @@ public:
( (
Field<Type>&, Field<Type>&,
const bool add, const bool add,
const lduAddressing&,
const label interfacei,
const Field<Type>&, const Field<Type>&,
const scalarField&, const scalarField&,
const Pstream::commsTypes commsType const Pstream::commsTypes commsType
@ -115,6 +116,8 @@ public:
( (
Field<Type>&, Field<Type>&,
const bool add, const bool add,
const lduAddressing&,
const label interfacei,
const Field<Type>&, const Field<Type>&,
const scalarField&, const scalarField&,
const Pstream::commsTypes commsType const Pstream::commsTypes commsType

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -53,6 +54,8 @@ void Foam::LduMatrix<Type, DType, LUType>::initMatrixInterfaces
( (
result, result,
add, add,
lduMesh_.lduAddr(),
interfacei,
psiif, psiif,
interfaceCoeffs[interfacei], interfaceCoeffs[interfacei],
//Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]), //Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
@ -80,6 +83,8 @@ void Foam::LduMatrix<Type, DType, LUType>::initMatrixInterfaces
( (
result, result,
add, add,
lduMesh_.lduAddr(),
interfacei,
psiif, psiif,
interfaceCoeffs[interfacei], interfaceCoeffs[interfacei],
//Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]), //Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
@ -128,6 +133,8 @@ void Foam::LduMatrix<Type, DType, LUType>::updateMatrixInterfaces
( (
result, result,
add, add,
lduMesh_.lduAddr(),
interfacei,
psiif, psiif,
interfaceCoeffs[interfacei], interfaceCoeffs[interfacei],
//Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]), //Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
@ -153,6 +160,8 @@ void Foam::LduMatrix<Type, DType, LUType>::updateMatrixInterfaces
( (
result, result,
add, add,
lduMesh_.lduAddr(),
interfacei,
psiif, psiif,
interfaceCoeffs[interfacei], interfaceCoeffs[interfacei],
//Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]), //Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
@ -165,6 +174,8 @@ void Foam::LduMatrix<Type, DType, LUType>::updateMatrixInterfaces
( (
result, result,
add, add,
lduMesh_.lduAddr(),
interfacei,
psiif, psiif,
interfaceCoeffs[interfacei], interfaceCoeffs[interfacei],
//Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]), //Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
@ -189,6 +200,8 @@ void Foam::LduMatrix<Type, DType, LUType>::updateMatrixInterfaces
( (
result, result,
add, add,
lduMesh_.lduAddr(),
interfacei,
psiif, psiif,
interfaceCoeffs[interfacei], interfaceCoeffs[interfacei],
//Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]), //Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),

View File

@ -72,6 +72,7 @@ public:
// Member Functions // Member Functions
// Access // Access
//- Return faceCell addressing //- Return faceCell addressing
@ -87,6 +88,14 @@ public:
const labelUList& internalData const labelUList& internalData
) const = 0; ) const = 0;
//- Return the values of the given internal data adjacent to
//- the interface as a field using faceCell mapping
virtual tmp<labelField> interfaceInternalField
(
const labelUList& internalData,
const labelUList& faceCells
) const = 0;
//- Initialise transfer of internal field adjacent to the interface //- Initialise transfer of internal field adjacent to the interface
virtual void initInternalFieldTransfer virtual void initInternalFieldTransfer
( (
@ -95,12 +104,23 @@ public:
) const ) const
{} {}
//- Initialise transfer of internal field adjacent to the interface
//- using faceCells mapping
virtual void initInternalFieldTransfer
(
const Pstream::commsTypes commsType,
const labelUList& iF,
const labelUList& faceCells
) const
{}
//- Transfer and return internal field adjacent to the interface //- Transfer and return internal field adjacent to the interface
virtual tmp<labelField> internalFieldTransfer virtual tmp<labelField> internalFieldTransfer
( (
const Pstream::commsTypes commsType, const Pstream::commsTypes commsType,
const labelUList& iF const labelUList& iF
) const = 0; ) const = 0;
}; };

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2017 OpenCFD Ltd. Copyright (C) 2016-2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -65,11 +65,23 @@ Foam::lduPrimitiveProcessorInterface::interfaceInternalField
const labelUList& internalData const labelUList& internalData
) const ) const
{ {
tmp<labelField> tfld(new labelField(faceCells_.size())); return interfaceInternalField(internalData, faceCells_);
labelField& fld = tfld.ref(); }
forAll(faceCells_, i)
Foam::tmp<Foam::labelField>
Foam::lduPrimitiveProcessorInterface::interfaceInternalField
(
const labelUList& internalData,
const labelUList& faceCells
) const
{
auto tfld = tmp<labelField>::New(faceCells.size());
auto& fld = tfld.ref();
forAll(faceCells, i)
{ {
fld[i] = internalData[faceCells_[i]]; fld[i] = internalData[faceCells[i]];
} }
return tfld; return tfld;
} }
@ -85,6 +97,21 @@ void Foam::lduPrimitiveProcessorInterface::initInternalFieldTransfer
} }
void Foam::lduPrimitiveProcessorInterface::initInternalFieldTransfer
(
const Pstream::commsTypes commsType,
const labelUList& iF,
const labelUList& faceCells
) const
{
processorLduInterface::send
(
commsType,
interfaceInternalField(iF, faceCells)()
);
}
Foam::tmp<Foam::labelField> Foam::tmp<Foam::labelField>
Foam::lduPrimitiveProcessorInterface::internalFieldTransfer Foam::lduPrimitiveProcessorInterface::internalFieldTransfer
( (
@ -95,5 +122,4 @@ Foam::lduPrimitiveProcessorInterface::internalFieldTransfer
return processorLduInterface::receive<label>(commsType, faceCells_.size()); return processorLduInterface::receive<label>(commsType, faceCells_.size());
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -56,7 +56,7 @@ class lduPrimitiveProcessorInterface
public lduInterface, public lduInterface,
public processorLduInterface public processorLduInterface
{ {
// Private data // Private Data
const labelList faceCells_; const labelList faceCells_;
@ -126,12 +126,20 @@ public:
// Interface transfer functions // Interface transfer functions
//- Return the values of the given internal data adjacent to //- Return the values of the given internal data adjacent to
// the interface as a field //- the interface as a field
virtual tmp<labelField> interfaceInternalField virtual tmp<labelField> interfaceInternalField
( (
const labelUList& internalData const labelUList& internalData
) const; ) const;
//- Return the values of the given internal data adjacent to
//- the interface as a field using faceCells mapping
virtual tmp<labelField> interfaceInternalField
(
const labelUList& internalData,
const labelUList& faceCells
) const;
//- Initialise neighbour field transfer //- Initialise neighbour field transfer
virtual void initInternalFieldTransfer virtual void initInternalFieldTransfer
( (
@ -139,6 +147,14 @@ public:
const labelUList& iF const labelUList& iF
) const; ) const;
//- Initialise neighbour field transfer using faceCells
virtual void initInternalFieldTransfer
(
const Pstream::commsTypes commsType,
const labelUList& iF,
const labelUList& faceCells
) const;
//- Transfer and return internal field adjacent to the interface //- Transfer and return internal field adjacent to the interface
virtual tmp<labelField> internalFieldTransfer virtual tmp<labelField> internalFieldTransfer
( (

View File

@ -42,14 +42,14 @@ SourceFiles
#include "lduInterface.H" #include "lduInterface.H"
#include "primitiveFieldsFwd.H" #include "primitiveFieldsFwd.H"
#include "Pstream.H" #include "Pstream.H"
#include "lduAddressing.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Forward declarations
class lduMatrix; class lduMatrix;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
@ -58,7 +58,7 @@ class lduMatrix;
class lduInterfaceField class lduInterfaceField
{ {
// Private data // Private Data
//- Reference to the coupled patch this field is defined for //- Reference to the coupled patch this field is defined for
const lduInterface& interface_; const lduInterface& interface_;
@ -140,6 +140,8 @@ public:
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing&,
const label interfacei,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction cmpt, const direction cmpt,
@ -153,6 +155,8 @@ public:
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing&,
const label interfacei,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction cmpt, const direction cmpt,
@ -165,6 +169,7 @@ public:
( (
Field<Type>& result, Field<Type>& result,
const bool add, const bool add,
const labelUList& faceCells,
const scalarField& coeffs, const scalarField& coeffs,
const Field<Type>& vals const Field<Type>& vals
) const; ) const;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017 OpenCFD Ltd. Copyright (C) 2017-2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -32,24 +32,23 @@ void Foam::lduInterfaceField::addToInternalField
( (
Field<Type>& result, Field<Type>& result,
const bool add, const bool add,
const labelUList& faceCells,
const scalarField& coeffs, const scalarField& coeffs,
const Field<Type>& vals const Field<Type>& vals
) const ) const
{ {
const labelUList& faceCells = this->interface().faceCells();
if (add) if (add)
{ {
forAll(faceCells, elemI) forAll(faceCells, elemi)
{ {
result[faceCells[elemI]] += coeffs[elemI]*vals[elemI]; result[faceCells[elemi]] += coeffs[elemi]*vals[elemi];
} }
} }
else else
{ {
forAll(faceCells, elemI) forAll(faceCells, elemi)
{ {
result[faceCells[elemI]] -= coeffs[elemI]*vals[elemI]; result[faceCells[elemi]] -= coeffs[elemi]*vals[elemi];
} }
} }
} }

View File

@ -325,7 +325,7 @@ void Foam::lduMatrix::setResidualField
const bool initial const bool initial
) const ) const
{ {
if (!lduMesh_.hasDb()) if (!mesh().hasDb())
{ {
return; return;
} }
@ -341,12 +341,12 @@ void Foam::lduMatrix::setResidualField
} }
scalarIOField* residualPtr = scalarIOField* residualPtr =
lduMesh_.thisDb().getObjectPtr<scalarIOField>(lookupName); mesh().thisDb().getObjectPtr<scalarIOField>(lookupName);
if (residualPtr) if (residualPtr)
{ {
const IOdictionary* dataPtr = const IOdictionary* dataPtr =
lduMesh_.thisDb().findObject<IOdictionary>("data"); mesh().thisDb().findObject<IOdictionary>("data");
if (dataPtr) if (dataPtr)
{ {

View File

@ -86,7 +86,8 @@ class lduMatrix
// private data // private data
//- LDU mesh reference //- LDU mesh reference
const lduMesh& lduMesh_; //const lduMesh& lduMesh_;
std::reference_wrapper<const lduMesh> lduMesh_;
//- Coefficients (not including interfaces) //- Coefficients (not including interfaces)
scalarField *lowerPtr_, *diagPtr_, *upperPtr_; scalarField *lowerPtr_, *diagPtr_, *upperPtr_;
@ -569,10 +570,16 @@ public:
return lduMesh_; return lduMesh_;
} }
//- Set the LDU mesh containing the addressing is obtained
void setLduMesh(const lduMesh& m)
{
lduMesh_ = m;
}
//- Return the LDU addressing //- Return the LDU addressing
const lduAddressing& lduAddr() const const lduAddressing& lduAddr() const
{ {
return lduMesh_.lduAddr(); return mesh().lduAddr();
} }
//- Return the patch evaluation schedule //- Return the patch evaluation schedule

View File

@ -204,13 +204,13 @@ Foam::solveScalarField::cmptType Foam::lduMatrix::solver::normFactor
// --- Calculate A dot reference value of psi // --- Calculate A dot reference value of psi
matrix_.sumA(tmpField, interfaceBouCoeffs_, interfaces_); matrix_.sumA(tmpField, interfaceBouCoeffs_, interfaces_);
tmpField *= gAverage(psi, matrix_.lduMesh_.comm()); tmpField *= gAverage(psi, matrix_.mesh().comm());
return return
gSum gSum
( (
(mag(Apsi - tmpField) + mag(source - tmpField))(), (mag(Apsi - tmpField) + mag(source - tmpField))(),
matrix_.lduMesh_.comm() matrix_.mesh().comm()
) )
+ solverPerformance::small_; + solverPerformance::small_;

View File

@ -54,6 +54,8 @@ void Foam::lduMatrix::initMatrixInterfaces
( (
result, result,
add, add,
mesh().lduAddr(),
interfacei,
psiif, psiif,
coupleCoeffs[interfacei], coupleCoeffs[interfacei],
cmpt, cmpt,
@ -81,6 +83,8 @@ void Foam::lduMatrix::initMatrixInterfaces
( (
result, result,
add, add,
mesh().lduAddr(),
interfacei,
psiif, psiif,
coupleCoeffs[interfacei], coupleCoeffs[interfacei],
cmpt, cmpt,
@ -120,6 +124,8 @@ void Foam::lduMatrix::updateMatrixInterfaces
( (
result, result,
add, add,
mesh().lduAddr(),
interfacei,
psiif, psiif,
coupleCoeffs[interfacei], coupleCoeffs[interfacei],
cmpt, cmpt,
@ -149,6 +155,8 @@ void Foam::lduMatrix::updateMatrixInterfaces
( (
result, result,
add, add,
mesh().lduAddr(),
interfacei,
psiif, psiif,
coupleCoeffs[interfacei], coupleCoeffs[interfacei],
cmpt, cmpt,
@ -197,6 +205,8 @@ void Foam::lduMatrix::updateMatrixInterfaces
( (
result, result,
add, add,
mesh().lduAddr(),
interfacei,
psiif, psiif,
coupleCoeffs[interfacei], coupleCoeffs[interfacei],
cmpt, cmpt,
@ -210,18 +220,20 @@ void Foam::lduMatrix::updateMatrixInterfaces
const lduSchedule& patchSchedule = this->patchSchedule(); const lduSchedule& patchSchedule = this->patchSchedule();
// Loop over all the "normal" interfaces relating to standard patches // Loop over all the "normal" interfaces relating to standard patches
forAll(patchSchedule, i) for (const auto& sched : patchSchedule)
{ {
label interfacei = patchSchedule[i].patch; const label interfacei = sched.patch;
if (interfaces.set(interfacei)) if (interfaces.set(interfacei))
{ {
if (patchSchedule[i].init) if (sched.init)
{ {
interfaces[interfacei].initInterfaceMatrixUpdate interfaces[interfacei].initInterfaceMatrixUpdate
( (
result, result,
add, add,
mesh().lduAddr(),
interfacei,
psiif, psiif,
coupleCoeffs[interfacei], coupleCoeffs[interfacei],
cmpt, cmpt,
@ -234,6 +246,8 @@ void Foam::lduMatrix::updateMatrixInterfaces
( (
result, result,
add, add,
mesh().lduAddr(),
interfacei,
psiif, psiif,
coupleCoeffs[interfacei], coupleCoeffs[interfacei],
cmpt, cmpt,
@ -258,6 +272,8 @@ void Foam::lduMatrix::updateMatrixInterfaces
( (
result, result,
add, add,
mesh().lduAddr(),
interfacei,
psiif, psiif,
coupleCoeffs[interfacei], coupleCoeffs[interfacei],
cmpt, cmpt,

View File

@ -29,6 +29,7 @@ License
#include "GAMGAgglomeration.H" #include "GAMGAgglomeration.H"
#include "GAMGInterface.H" #include "GAMGInterface.H"
#include "processorGAMGInterface.H" #include "processorGAMGInterface.H"
#include "cyclicLduInterface.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -43,7 +44,7 @@ void Foam::GAMGAgglomeration::agglomerateLduAddressing
const labelUList& upperAddr = fineMeshAddr.upperAddr(); const labelUList& upperAddr = fineMeshAddr.upperAddr();
const labelUList& lowerAddr = fineMeshAddr.lowerAddr(); const labelUList& lowerAddr = fineMeshAddr.lowerAddr();
label nFineFaces = upperAddr.size(); const label nFineFaces = upperAddr.size();
// Get restriction map for current level // Get restriction map for current level
const labelField& restrictMap = restrictAddressing(fineLevelIndex); const labelField& restrictMap = restrictAddressing(fineLevelIndex);
@ -282,9 +283,22 @@ void Foam::GAMGAgglomeration::agglomerateLduAddressing
const label nReq = Pstream::nRequests(); const label nReq = Pstream::nRequests();
// Initialise transfer of restrict addressing on the interface // Initialise transfer of restrict addressing on the interface
// The finest mesh uses patchAddr from the original lduAdressing.
// the coarser levels create their own adressing for faceCells
forAll(fineInterfaces, inti) forAll(fineInterfaces, inti)
{ {
if (fineInterfaces.set(inti)) if (fineInterfaces.set(inti))
{
if (fineLevelIndex == 0)
{
fineInterfaces[inti].initInternalFieldTransfer
(
Pstream::commsTypes::nonBlocking,
restrictMap,
fineMeshAddr.patchAddr(inti)
);
}
else
{ {
fineInterfaces[inti].initInternalFieldTransfer fineInterfaces[inti].initInternalFieldTransfer
( (
@ -293,6 +307,7 @@ void Foam::GAMGAgglomeration::agglomerateLduAddressing
); );
} }
} }
}
if (Pstream::parRun()) if (Pstream::parRun())
{ {
@ -320,6 +335,51 @@ void Foam::GAMGAgglomeration::agglomerateLduAddressing
{ {
if (fineInterfaces.set(inti)) if (fineInterfaces.set(inti))
{ {
tmp<labelField> restrictMapInternalField;
// The finest mesh uses patchAddr from the original lduAdressing.
// the coarser levels create thei own adressing for faceCells
if (fineLevelIndex == 0)
{
restrictMapInternalField =
fineInterfaces[inti].interfaceInternalField
(
restrictMap,
fineMeshAddr.patchAddr(inti)
);
}
else
{
restrictMapInternalField =
fineInterfaces[inti].interfaceInternalField
(
restrictMap
);
}
tmp<labelField> nbrRestrictMapInternalField =
fineInterfaces[inti].internalFieldTransfer
(
Pstream::commsTypes::nonBlocking,
restrictMap
);
coarseInterfaces.set
(
inti,
GAMGInterface::New
(
inti,
meshLevels_[fineLevelIndex].rawInterfaces(),
fineInterfaces[inti],
restrictMapInternalField(),
nbrRestrictMapInternalField(),
fineLevelIndex,
fineMesh.comm()
).ptr()
);
/* Same as below:
coarseInterfaces.set coarseInterfaces.set
( (
inti, inti,
@ -338,6 +398,7 @@ void Foam::GAMGAgglomeration::agglomerateLduAddressing
fineMesh.comm() fineMesh.comm()
).ptr() ).ptr()
); );
*/
nPatchFaces[inti] = coarseInterfaces[inti].faceCells().size(); nPatchFaces[inti] = coarseInterfaces[inti].faceCells().size();
patchFineToCoarse[inti] = refCast<const GAMGInterface> patchFineToCoarse[inti] = refCast<const GAMGInterface>

View File

@ -295,13 +295,17 @@ const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New
const dictionary& controlDict const dictionary& controlDict
) )
{ {
if const GAMGAgglomeration* agglomPtr =
( mesh.thisDb().cfindObject<GAMGAgglomeration>
!mesh.thisDb().foundObject<GAMGAgglomeration>
( (
GAMGAgglomeration::typeName GAMGAgglomeration::typeName
) );
)
if (agglomPtr)
{
return *agglomPtr;
}
{ {
const word agglomeratorType const word agglomeratorType
( (
@ -331,13 +335,6 @@ const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New
return store(cstrIter()(mesh, controlDict).ptr()); return store(cstrIter()(mesh, controlDict).ptr());
} }
else
{
return mesh.thisDb().lookupObject<GAMGAgglomeration>
(
GAMGAgglomeration::typeName
);
}
} }
@ -349,13 +346,17 @@ const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New
{ {
const lduMesh& mesh = matrix.mesh(); const lduMesh& mesh = matrix.mesh();
if const GAMGAgglomeration* agglomPtr =
( mesh.thisDb().cfindObject<GAMGAgglomeration>
!mesh.thisDb().foundObject<GAMGAgglomeration>
( (
GAMGAgglomeration::typeName GAMGAgglomeration::typeName
) );
)
if (agglomPtr)
{
return *agglomPtr;
}
{ {
const word agglomeratorType const word agglomeratorType
( (
@ -385,17 +386,10 @@ const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New
return store(cstrIter()(matrix, controlDict).ptr()); return store(cstrIter()(matrix, controlDict).ptr());
} }
} }
else
{
return mesh.thisDb().lookupObject<GAMGAgglomeration>
(
GAMGAgglomeration::typeName
);
}
} }
Foam::autoPtr<Foam::GAMGAgglomeration> Foam::GAMGAgglomeration::New const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New
( (
const lduMesh& mesh, const lduMesh& mesh,
const scalarField& cellVolumes, const scalarField& cellVolumes,
@ -403,12 +397,25 @@ Foam::autoPtr<Foam::GAMGAgglomeration> Foam::GAMGAgglomeration::New
const dictionary& controlDict const dictionary& controlDict
) )
{ {
const word agglomeratorType
const GAMGAgglomeration* agglomPtr =
mesh.thisDb().cfindObject<GAMGAgglomeration>
( (
controlDict.getOrDefault<word>("agglomerator", "faceAreaPair") GAMGAgglomeration::typeName
); );
mesh.thisDb().time().libs().open if (agglomPtr)
{
return *agglomPtr;
}
{
const word agglomeratorType
(
controlDict.lookupOrDefault<word>("agglomerator", "faceAreaPair")
);
const_cast<Time&>(mesh.thisDb().time()).libs().open
( (
controlDict, controlDict,
"geometricGAMGAgglomerationLibs", "geometricGAMGAgglomerationLibs",
@ -427,7 +434,7 @@ Foam::autoPtr<Foam::GAMGAgglomeration> Foam::GAMGAgglomeration::New
<< exit(FatalError); << exit(FatalError);
} }
return autoPtr<GAMGAgglomeration> return store
( (
cstrIter() cstrIter()
( (
@ -435,8 +442,9 @@ Foam::autoPtr<Foam::GAMGAgglomeration> Foam::GAMGAgglomeration::New
cellVolumes, cellVolumes,
faceAreas, faceAreas,
controlDict controlDict
) ).ptr()
); );
}
} }
@ -609,8 +617,8 @@ bool Foam::GAMGAgglomeration::checkRestriction
forAll(lower, facei) forAll(lower, facei)
{ {
label own = lower[facei]; const label own = lower[facei];
label nei = upper[facei]; const label nei = upper[facei];
if (restriction[own] == restriction[nei]) if (restriction[own] == restriction[nei])
{ {
@ -683,7 +691,7 @@ bool Foam::GAMGAgglomeration::checkRestriction
{ {
const label coarseI = restriction[celli]; const label coarseI = restriction[celli];
label index = coarseToMasters[coarseI].find(master[celli]); const label index = coarseToMasters[coarseI].find(master[celli]);
newRestrict[celli] = coarseToNewCoarse[coarseI][index]; newRestrict[celli] = coarseToNewCoarse[coarseI][index];
} }

View File

@ -306,7 +306,7 @@ public:
); );
//- Return the selected geometric agglomerator //- Return the selected geometric agglomerator
static autoPtr<GAMGAgglomeration> New static const GAMGAgglomeration& New
( (
const lduMesh& mesh, const lduMesh& mesh,
const scalarField& cellVolumes, const scalarField& cellVolumes,

View File

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

View File

@ -107,6 +107,8 @@ void Foam::cyclicGAMGInterfaceField::updateInterfaceMatrix
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction cmpt, const direction cmpt,
@ -114,14 +116,20 @@ void Foam::cyclicGAMGInterfaceField::updateInterfaceMatrix
) const ) const
{ {
// Get neighbouring field // Get neighbouring field
solveScalarField pnf
const labelList& nbrFaceCells =
lduAddr.patchAddr
( (
cyclicInterface_.neighbPatch().interfaceInternalField(psiInternal) cyclicInterface_.neighbPatchID()
); );
solveScalarField pnf(psiInternal, nbrFaceCells);
transformCoupleField(pnf, cmpt); transformCoupleField(pnf, cmpt);
this->addToInternalField(result, !add, coeffs, pnf); const labelList& faceCells = lduAddr.patchAddr(patchId);
this->addToInternalField(result, !add, faceCells, coeffs, pnf);
} }

View File

@ -150,6 +150,8 @@ public:
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction cmpt, const direction cmpt,

View File

@ -91,6 +91,8 @@ void Foam::processorGAMGInterfaceField::initInterfaceMatrixUpdate
( (
solveScalarField&, solveScalarField&,
const bool, const bool,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField&, const scalarField&,
const direction, const direction,
@ -142,6 +144,8 @@ void Foam::processorGAMGInterfaceField::updateInterfaceMatrix
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField&, const solveScalarField&,
const scalarField& coeffs, const scalarField& coeffs,
const direction cmpt, const direction cmpt,
@ -153,6 +157,8 @@ void Foam::processorGAMGInterfaceField::updateInterfaceMatrix
return; return;
} }
const labelUList& faceCells = lduAddr.patchAddr(patchId);
if if
( (
commsType == Pstream::commsTypes::nonBlocking commsType == Pstream::commsTypes::nonBlocking
@ -178,7 +184,7 @@ void Foam::processorGAMGInterfaceField::updateInterfaceMatrix
transformCoupleField(scalarReceiveBuf_, cmpt); transformCoupleField(scalarReceiveBuf_, cmpt);
// Multiply the field by coefficients and add into the result // Multiply the field by coefficients and add into the result
addToInternalField(result, !add, coeffs, scalarReceiveBuf_); addToInternalField(result, !add, faceCells, coeffs, scalarReceiveBuf_);
} }
else else
{ {
@ -192,7 +198,7 @@ void Foam::processorGAMGInterfaceField::updateInterfaceMatrix
); );
transformCoupleField(pnf, cmpt); transformCoupleField(pnf, cmpt);
addToInternalField(result, !add, coeffs, pnf); addToInternalField(result, !add, faceCells, coeffs, pnf);
} }
const_cast<processorGAMGInterfaceField&>(*this).updatedMatrix() = true; const_cast<processorGAMGInterfaceField&>(*this).updatedMatrix() = true;

View File

@ -142,6 +142,8 @@ public:
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction cmpt, const direction cmpt,
@ -153,6 +155,8 @@ public:
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction cmpt, const direction cmpt,

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -77,13 +78,23 @@ Foam::tmp<Foam::labelField> Foam::GAMGInterface::interfaceInternalField
} }
Foam::tmp<Foam::labelField> Foam::GAMGInterface::interfaceInternalField
(
const labelUList& internalData,
const labelUList& faceCells
) const
{
return interfaceInternalField<label>(internalData, faceCells);
}
Foam::tmp<Foam::scalarField> Foam::GAMGInterface::agglomerateCoeffs Foam::tmp<Foam::scalarField> Foam::GAMGInterface::agglomerateCoeffs
( (
const scalarField& fineCoeffs const scalarField& fineCoeffs
) const ) const
{ {
tmp<scalarField> tcoarseCoeffs(new scalarField(size(), Zero)); auto tcoarseCoeffs = tmp<scalarField>::New(size(), Zero);
scalarField& coarseCoeffs = tcoarseCoeffs.ref(); auto& coarseCoeffs = tcoarseCoeffs.ref();
if (fineCoeffs.size() != faceRestrictAddressing_.size()) if (fineCoeffs.size() != faceRestrictAddressing_.size())
{ {

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -55,7 +56,6 @@ class GAMGInterface
: :
public lduInterface public lduInterface
{ {
protected: protected:
// Protected data // Protected data
@ -73,9 +73,7 @@ protected:
labelList faceRestrictAddressing_; labelList faceRestrictAddressing_;
private: // Protected Member Functions
// Private Member Functions
//- No copy construct //- No copy construct
GAMGInterface(const GAMGInterface&) = delete; GAMGInterface(const GAMGInterface&) = delete;
@ -245,6 +243,15 @@ public:
const UList<Type>& internalData const UList<Type>& internalData
) const; ) const;
//- Return the interface internal field of the given field
//- using faceCell mapping
template<class Type>
tmp<Field<Type>> interfaceInternalField
(
const UList<Type>& internalData,
const labelUList& faceCells
) const;
//- Get the interface internal field of the given field //- Get the interface internal field of the given field
template<class Type> template<class Type>
void interfaceInternalField void interfaceInternalField
@ -260,6 +267,14 @@ public:
const labelUList& internalData const labelUList& internalData
) const; ) const;
//- Return the values of the given internal data adjacent to
//- the interface as a field using faceCell mapping
virtual tmp<labelField> interfaceInternalField
(
const labelUList& internalData,
const labelUList& faceCells
) const;
// Agglomeration // Agglomeration

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -35,12 +36,30 @@ Foam::tmp<Foam::Field<Type>> Foam::GAMGInterface::interfaceInternalField
const UList<Type>& iF const UList<Type>& iF
) const ) const
{ {
tmp<Field<Type>> tresult(new Field<Type>(size())); auto tresult = tmp<Field<Type>>::New(size());
interfaceInternalField(iF, tresult.ref()); interfaceInternalField(iF, tresult.ref());
return tresult; return tresult;
} }
template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::GAMGInterface::interfaceInternalField
(
const UList<Type>& iF,
const labelUList& faceCells
) const
{
auto tresult = tmp<Field<Type>>::New(faceCells.size());
auto& result = tresult.ref();
forAll(result, elemi)
{
result[elemi] = iF[faceCells[elemi]];
}
return tresult;
}
template<class Type> template<class Type>
void Foam::GAMGInterface::interfaceInternalField void Foam::GAMGInterface::interfaceInternalField
( (
@ -48,11 +67,11 @@ void Foam::GAMGInterface::interfaceInternalField
List<Type>& result List<Type>& result
) const ) const
{ {
result.setSize(size()); result.resize(size());
forAll(result, elemI) forAll(result, elemi)
{ {
result[elemI] = iF[faceCells_[elemI]]; result[elemi] = iF[faceCells_[elemi]];
} }
} }

View File

@ -166,7 +166,7 @@ Foam::cyclicGAMGInterface::cyclicGAMGInterface
Foam::tmp<Foam::labelField> Foam::cyclicGAMGInterface::internalFieldTransfer Foam::tmp<Foam::labelField> Foam::cyclicGAMGInterface::internalFieldTransfer
( (
const Pstream::commsTypes, const Pstream::commsTypes commsType,
const labelUList& iF const labelUList& iF
) const ) const
{ {

View File

@ -162,7 +162,7 @@ public:
// I/O // I/O
//- Write to stream //- Write to stream
virtual void write(Ostream&) const; virtual void write(Ostream& os) const;
}; };

View File

@ -191,13 +191,24 @@ void Foam::processorGAMGInterface::initInternalFieldTransfer
} }
void Foam::processorGAMGInterface::initInternalFieldTransfer
(
const Pstream::commsTypes commsType,
const labelUList& iF,
const labelUList& faceCells
) const
{
send(commsType, interfaceInternalField(iF, faceCells)());
}
Foam::tmp<Foam::labelField> Foam::processorGAMGInterface::internalFieldTransfer Foam::tmp<Foam::labelField> Foam::processorGAMGInterface::internalFieldTransfer
( (
const Pstream::commsTypes commsType, const Pstream::commsTypes commsType,
const labelUList& iF const labelUList& iF
) const ) const
{ {
tmp<Field<label>> tfld(receive<label>(commsType, this->size())); tmp<labelField> tfld(receive<label>(commsType, this->size()));
return tfld; return tfld;
} }

View File

@ -90,7 +90,7 @@ public:
// Constructors // Constructors
//- Construct from fine-level interface, //- Construct from fine-level interface,
// local and neighbour restrict addressing //- local and neighbour restrict addressing
processorGAMGInterface processorGAMGInterface
( (
const label index, const label index,
@ -140,6 +140,15 @@ public:
const labelUList& iF const labelUList& iF
) const; ) const;
//- Initialise neighbour field transfer using faceCells mapping
virtual void initInternalFieldTransfer
(
const Pstream::commsTypes commsType,
const labelUList& iF,
const labelUList& faceCells
) const;
//- Transfer and return internal field adjacent to the interface //- Transfer and return internal field adjacent to the interface
virtual tmp<labelField> internalFieldTransfer virtual tmp<labelField> internalFieldTransfer
( (
@ -184,7 +193,7 @@ public:
// I/O // I/O
//- Write to stream //- Write to stream
virtual void write(Ostream&) const; virtual void write(Ostream& os) const;
}; };

View File

@ -89,7 +89,7 @@ public:
virtual const lduAddressing& lduAddr() const = 0; virtual const lduAddressing& lduAddr() const = 0;
//- Return a list of pointers for each patch //- Return a list of pointers for each patch
// with only those pointing to interfaces being set //- with only those pointing to interfaces being set
virtual lduInterfacePtrsList interfaces() const = 0; virtual lduInterfacePtrsList interfaces() const = 0;
//- Return communicator used for parallel communication //- Return communicator used for parallel communication

View File

@ -41,23 +41,24 @@ namespace Foam
//- Less operator for pairs of \<processor\>\<index\> //- Less operator for pairs of \<processor\>\<index\>
class procLess class procLess
{ {
const labelPairList& lst_; const labelPairList& list_;
public: public:
procLess(const labelPairList& lst) procLess(const labelPairList& list)
: :
lst_(lst) list_(list)
{} {}
bool operator()(const label a, const label b) bool operator()(const label a, const label b)
{ {
return lst_[a].first() < lst_[b].first(); return list_[a].first() < list_[b].first();
} }
}; };
} }
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::lduPrimitiveMesh::checkUpperTriangular void Foam::lduPrimitiveMesh::checkUpperTriangular
@ -85,7 +86,7 @@ void Foam::lduPrimitiveMesh::checkUpperTriangular
} }
} }
for (label facei=1; facei < l.size(); facei++) for (label facei=1; facei < l.size(); ++facei)
{ {
if (l[facei-1] > l[facei]) if (l[facei-1] > l[facei])
{ {
@ -113,6 +114,132 @@ void Foam::lduPrimitiveMesh::checkUpperTriangular
} }
Foam::labelListList Foam::lduPrimitiveMesh::globalCellCells
(
const lduMesh& mesh,
const globalIndex& globalNumbering
)
{
const lduAddressing& addr = mesh.lduAddr();
lduInterfacePtrsList interfaces = mesh.interfaces();
const labelList globalIndices
(
identity
(
addr.size(),
globalNumbering.localStart(UPstream::myProcNo(mesh.comm()))
)
);
// Get the interface cells
PtrList<labelList> nbrGlobalCells(interfaces.size());
{
// Initialise transfer of restrict addressing on the interface
forAll(interfaces, inti)
{
if (interfaces.set(inti))
{
interfaces[inti].initInternalFieldTransfer
(
Pstream::commsTypes::nonBlocking,
globalIndices
);
}
}
if (Pstream::parRun())
{
Pstream::waitRequests();
}
forAll(interfaces, inti)
{
if (interfaces.set(inti))
{
nbrGlobalCells.set
(
inti,
new labelList
(
interfaces[inti].internalFieldTransfer
(
Pstream::commsTypes::nonBlocking,
globalIndices
)
)
);
}
}
}
// Scan the neighbour list to find out how many times the cell
// appears as a neighbour of the face. Done this way to avoid guessing
// and resizing list
labelList nNbrs(addr.size(), Zero);
const labelUList& nbr = addr.upperAddr();
const labelUList& own = addr.lowerAddr();
{
forAll(nbr, facei)
{
nNbrs[nbr[facei]]++;
nNbrs[own[facei]]++;
}
forAll(interfaces, inti)
{
if (interfaces.set(inti))
{
for (const label celli : interfaces[inti].faceCells())
{
nNbrs[celli]++;
}
}
}
}
// Create cell-cells addressing
labelListList cellCells(addr.size());
forAll(cellCells, celli)
{
cellCells[celli].setSize(nNbrs[celli], -1);
}
// Reset the list of number of neighbours to zero
nNbrs = 0;
// Scatter the neighbour faces
forAll(nbr, facei)
{
const label c0 = own[facei];
const label c1 = nbr[facei];
cellCells[c0][nNbrs[c0]++] = globalIndices[c1];
cellCells[c1][nNbrs[c1]++] = globalIndices[c0];
}
forAll(interfaces, inti)
{
if (interfaces.set(inti))
{
const labelUList& faceCells = interfaces[inti].faceCells();
forAll(faceCells, facei)
{
const label c0 = faceCells[facei];
cellCells[c0][nNbrs[c0]++] = nbrGlobalCells[inti][facei];
}
}
}
return cellCells;
}
Foam::label Foam::lduPrimitiveMesh::totalSize Foam::label Foam::lduPrimitiveMesh::totalSize
( (
const PtrList<lduPrimitiveMesh>& meshes const PtrList<lduPrimitiveMesh>& meshes
@ -164,7 +291,7 @@ Foam::labelList Foam::lduPrimitiveMesh::upperTriOrder
labelList cellToFaces(offsets.last()); labelList cellToFaces(offsets.last());
forAll(upper, facei) forAll(upper, facei)
{ {
label celli = lower[facei]; const label celli = lower[facei];
cellToFaces[nNbrs[celli]++] = facei; cellToFaces[nNbrs[celli]++] = facei;
} }
@ -172,17 +299,19 @@ Foam::labelList Foam::lduPrimitiveMesh::upperTriOrder
labelList oldToNew(lower.size()); labelList oldToNew(lower.size());
labelList order; DynamicList<label> order;
labelList nbr; DynamicList<label> nbr;
label newFacei = 0; label newFacei = 0;
for (label celli = 0; celli < nCells; celli++) for (label celli = 0; celli < nCells; ++celli)
{ {
label startOfCell = offsets[celli]; const label startOfCell = offsets[celli];
label nNbr = offsets[celli+1] - startOfCell; const label nNbr = offsets[celli+1] - startOfCell;
nbr.resize(nNbr);
order.resize(nNbr);
nbr.setSize(nNbr);
forAll(nbr, i) forAll(nbr, i)
{ {
nbr[i] = upper[cellToFaces[offsets[celli]+i]]; nbr[i] = upper[cellToFaces[offsets[celli]+i]];
@ -216,7 +345,6 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
comm_(comm) comm_(comm)
{} {}
void Foam::lduPrimitiveMesh::addInterfaces void Foam::lduPrimitiveMesh::addInterfaces
( (
lduInterfacePtrsList& interfaces, lduInterfacePtrsList& interfaces,
@ -238,6 +366,16 @@ void Foam::lduPrimitiveMesh::addInterfaces
} }
Foam::lduPrimitiveMesh::lduPrimitiveMesh
(
const label nCells
)
:
lduAddressing(nCells),
comm_(0)
{}
Foam::lduPrimitiveMesh::lduPrimitiveMesh Foam::lduPrimitiveMesh::lduPrimitiveMesh
( (
const label nCells, const label nCells,
@ -251,7 +389,7 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
lduAddressing(nCells), lduAddressing(nCells),
lowerAddr_(l, true), lowerAddr_(l, true),
upperAddr_(u, true), upperAddr_(u, true),
primitiveInterfaces_(0), primitiveInterfaces_(),
patchSchedule_(ps), patchSchedule_(ps),
comm_(comm) comm_(comm)
{ {
@ -286,10 +424,6 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
) )
: :
lduAddressing(myMesh.lduAddr().size() + totalSize(otherMeshes)), lduAddressing(myMesh.lduAddr().size() + totalSize(otherMeshes)),
lowerAddr_(0),
upperAddr_(0),
interfaces_(0),
patchSchedule_(0),
comm_(comm) comm_(comm)
{ {
const label currentComm = myMesh.comm(); const label currentComm = myMesh.comm();
@ -338,7 +472,7 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
// Cells get added in order. // Cells get added in order.
cellOffsets.setSize(nMeshes+1); cellOffsets.setSize(nMeshes+1);
cellOffsets[0] = 0; cellOffsets[0] = 0;
for (label procMeshI = 0; procMeshI < nMeshes; procMeshI++) for (label procMeshI = 0; procMeshI < nMeshes; ++procMeshI)
{ {
const lduMesh& procMesh = mesh(myMesh, otherMeshes, procMeshI); const lduMesh& procMesh = mesh(myMesh, otherMeshes, procMeshI);
@ -351,7 +485,7 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
// Faces initially get added in order, sorted later // Faces initially get added in order, sorted later
labelList internalFaceOffsets(nMeshes+1); labelList internalFaceOffsets(nMeshes+1);
internalFaceOffsets[0] = 0; internalFaceOffsets[0] = 0;
for (label procMeshI = 0; procMeshI < nMeshes; procMeshI++) for (label procMeshI = 0; procMeshI < nMeshes; ++procMeshI)
{ {
const lduMesh& procMesh = mesh(myMesh, otherMeshes, procMeshI); const lduMesh& procMesh = mesh(myMesh, otherMeshes, procMeshI);
@ -380,7 +514,7 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
label nOtherInterfaces = 0; label nOtherInterfaces = 0;
labelList nCoupledFaces(nMeshes, Zero); labelList nCoupledFaces(nMeshes, Zero);
for (label procMeshI = 0; procMeshI < nMeshes; procMeshI++) for (label procMeshI = 0; procMeshI < nMeshes; ++procMeshI)
{ {
const lduInterfacePtrsList interfaces = const lduInterfacePtrsList interfaces =
mesh(myMesh, otherMeshes, procMeshI).interfaces(); mesh(myMesh, otherMeshes, procMeshI).interfaces();
@ -539,7 +673,7 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
faceOffsets.setSize(nMeshes+1); faceOffsets.setSize(nMeshes+1);
faceOffsets[0] = 0; faceOffsets[0] = 0;
faceMap.setSize(nMeshes); faceMap.setSize(nMeshes);
for (label procMeshI = 0; procMeshI < nMeshes; procMeshI++) for (label procMeshI = 0; procMeshI < nMeshes; ++procMeshI)
{ {
const lduMesh& procMesh = mesh(myMesh, otherMeshes, procMeshI); const lduMesh& procMesh = mesh(myMesh, otherMeshes, procMeshI);
label nInternal = procMesh.lduAddr().lowerAddr().size(); label nInternal = procMesh.lduAddr().lowerAddr().size();
@ -566,7 +700,7 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
// Old internal faces and resolved coupled interfaces // Old internal faces and resolved coupled interfaces
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
for (label procMeshI = 0; procMeshI < nMeshes; procMeshI++) for (label procMeshI = 0; procMeshI < nMeshes; ++procMeshI)
{ {
const lduMesh& procMesh = mesh(myMesh, otherMeshes, procMeshI); const lduMesh& procMesh = mesh(myMesh, otherMeshes, procMeshI);
@ -961,7 +1095,7 @@ void Foam::lduPrimitiveMesh::gather
otherMeshes.setSize(procIDs.size()-1); otherMeshes.setSize(procIDs.size()-1);
// Slave meshes // Slave meshes
for (label i = 1; i < procIDs.size(); i++) for (label i = 1; i < procIDs.size(); ++i)
{ {
//Pout<< "on master :" //Pout<< "on master :"
// << " receiving from slave " << procIDs[i] << endl; // << " receiving from slave " << procIDs[i] << endl;

View File

@ -28,7 +28,7 @@ Class
Foam::lduPrimitiveMesh Foam::lduPrimitiveMesh
Description Description
Simplest contrete lduMesh which stores the addressing needed by lduMatrix. Simplest concrete lduMesh that stores the addressing needed by lduMatrix.
SourceFiles SourceFiles
lduPrimitiveMesh.C lduPrimitiveMesh.C
@ -99,6 +99,9 @@ public:
// Constructors // Constructors
//- Construct from number of cells
explicit lduPrimitiveMesh(const label nCells);
//- Construct from components but without interfaces. Add interfaces //- Construct from components but without interfaces. Add interfaces
// separately using addInterfaces // separately using addInterfaces
lduPrimitiveMesh lduPrimitiveMesh
@ -110,6 +113,7 @@ public:
bool reuse bool reuse
); );
//- Add interfaces to a mesh constructed without //- Add interfaces to a mesh constructed without
void addInterfaces void addInterfaces
( (
@ -186,13 +190,32 @@ public:
return *this; return *this;
} }
//- Return non-const ldu addressing
virtual lduAddressing& lduAddr()
{
return *this;
}
//- Return a list of pointers for each patch //- Return a list of pointers for each patch
// with only those pointing to interfaces being set //- with only those pointing to interfaces being set
virtual lduInterfacePtrsList interfaces() const virtual lduInterfacePtrsList interfaces() const
{ {
return interfaces_; return interfaces_;
} }
//- Return a non-const list of pointers for each patch
//- with only those pointing to interfaces being set
virtual lduInterfacePtrsList& interfaces()
{
return interfaces_;
}
//- Return a non-const list of primitive interfaces
PtrList<const lduInterface>& primitiveInterfaces()
{
return primitiveInterfaces_;
}
//- Return a list of pointers for each patch //- Return a list of pointers for each patch
// with only those pointing to interfaces being set // with only those pointing to interfaces being set
// (reference to cached interfaces) // (reference to cached interfaces)
@ -219,6 +242,18 @@ public:
return upperAddr_; return upperAddr_;
} }
//- Return non-const Lower addressing
virtual labelList& lowerAddr()
{
return lowerAddr_;
}
//- Return non-const Upper addressing
virtual labelList& upperAddr()
{
return upperAddr_;
}
//- Return patch addressing //- Return patch addressing
virtual const labelUList& patchAddr(const label i) const virtual const labelUList& patchAddr(const label i) const
{ {
@ -271,6 +306,13 @@ public:
const labelUList& l, const labelUList& l,
const labelUList& u const labelUList& u
); );
//- Calculate global cell-cells
static labelListList globalCellCells
(
const lduMesh& mesh,
const globalIndex& globalNumbering
);
}; };

View File

@ -70,9 +70,9 @@ void Foam::coupledPolyPatch::writeOBJ
const labelList& pointLabels const labelList& pointLabels
) )
{ {
forAll(pointLabels, i) for (const label pointi : pointLabels)
{ {
writeOBJ(os, points[pointLabels[i]]); writeOBJ(os, points[pointi]);
} }
} }
@ -108,10 +108,8 @@ void Foam::coupledPolyPatch::writeOBJ
label vertI = 0; label vertI = 0;
forAll(faces, i) for (const face& f : faces)
{ {
const face& f = faces[i];
forAll(f, fp) forAll(f, fp)
{ {
if (foamToObj.insert(f[fp], vertI)) if (foamToObj.insert(f[fp], vertI))
@ -526,6 +524,18 @@ Foam::coupledPolyPatch::coupledPolyPatch
{} {}
Foam::coupledPolyPatch::coupledPolyPatch
(
const coupledPolyPatch& pp,
const labelList& faceCells
)
:
polyPatch(pp, faceCells),
matchTolerance_(pp.matchTolerance_),
transform_(pp.transform_)
{}
Foam::coupledPolyPatch::coupledPolyPatch Foam::coupledPolyPatch::coupledPolyPatch
( (
const coupledPolyPatch& pp, const coupledPolyPatch& pp,

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -207,11 +208,14 @@ public:
const word& patchType const word& patchType
); );
//- Construct as copy, resetting the boundary mesh //- Copy construct, resetting the boundary mesh
coupledPolyPatch(const coupledPolyPatch&, const polyBoundaryMesh&); coupledPolyPatch(const coupledPolyPatch&, const polyBoundaryMesh& bm);
//- Copy construct, resetting the faceCells
coupledPolyPatch(const coupledPolyPatch&, const labelList& faceCells);
//- Construct given the original patch and resetting the //- Construct given the original patch and resetting the
// face list and boundary mesh information //- face list and boundary mesh information
coupledPolyPatch coupledPolyPatch
( (
const coupledPolyPatch& pp, const coupledPolyPatch& pp,
@ -238,6 +242,7 @@ public:
// Member Functions // Member Functions
// Access // Access
//- Return true because this patch is coupled //- Return true because this patch is coupled
@ -360,7 +365,7 @@ public:
); );
//- Write the polyPatch data as a dictionary //- Write the polyPatch data as a dictionary
virtual void write(Ostream&) const; virtual void write(Ostream& os) const;
}; };

View File

@ -734,6 +734,28 @@ Foam::cyclicPolyPatch::cyclicPolyPatch
} }
Foam::cyclicPolyPatch::cyclicPolyPatch
(
const cyclicPolyPatch& pp,
const label nrbPatchID,
const labelList& faceCells
)
:
coupledPolyPatch(pp, faceCells),
neighbPatchName_(pp.neighbPatchName_),
coupleGroup_(pp.coupleGroup_),
neighbPatchID_(nrbPatchID),
rotationAxis_(pp.rotationAxis_),
rotationCentre_(pp.rotationCentre_),
separationVector_(pp.separationVector_),
coupledPointsPtr_(nullptr),
coupledEdgesPtr_(nullptr)
{
// Neighbour patch might not be valid yet so no transformation
// calculation possible.
}
Foam::cyclicPolyPatch::cyclicPolyPatch Foam::cyclicPolyPatch::cyclicPolyPatch
( (
const cyclicPolyPatch& pp, const cyclicPolyPatch& pp,

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -234,11 +235,19 @@ public:
const word& patchType const word& patchType
); );
//- Construct as copy, resetting the boundary mesh //- Copy construct, resetting the boundary mesh
cyclicPolyPatch(const cyclicPolyPatch&, const polyBoundaryMesh&); cyclicPolyPatch(const cyclicPolyPatch&, const polyBoundaryMesh&);
//- Copy construct, resetting nbrPatchID and faceCells
cyclicPolyPatch
(
const cyclicPolyPatch&,
label nbrPatchID,
const labelList& faceCells
);
//- Construct given the original patch and resetting the //- Construct given the original patch and resetting the
// face list and boundary mesh information //- face list and boundary mesh information
cyclicPolyPatch cyclicPolyPatch
( (
const cyclicPolyPatch& pp, const cyclicPolyPatch& pp,
@ -312,6 +321,49 @@ public:
// Member Functions // Member Functions
// Implicit Functions
//- Return number of new internal of this polyPatch faces
virtual void newInternalProcFaces
(
label& newFaces,
label& newProcFaces
) const
{
newFaces = this->size();
newProcFaces = neighbPatch().size() - this->size();
}
//- Return nbrCells
virtual const labelUList& nbrCells() const
{
return neighbPatch().faceCells();
}
virtual label neighbPolyPatchID() const
{
return this->neighbPatchID();
}
virtual refPtr<labelListList> mapCollocatedFaces() const
{
refPtr<labelListList> tMap(new labelListList(this->size()));
labelListList& map = tMap.ref();
forAll (map, i)
{
labelList& subMap = map[i];
subMap.setSize(1);
subMap[0] = i;
}
return tMap;
}
//- Return implicit master
virtual bool masterImplicit() const
{
return owner();
}
//- Neighbour patch name //- Neighbour patch name
const word& neighbPatchName() const; const word& neighbPatchName() const;

View File

@ -252,6 +252,18 @@ Foam::polyPatch::polyPatch(const polyPatch& p)
{} {}
Foam::polyPatch::polyPatch
(
const polyPatch& p,
const labelList& faceCells
)
:
polyPatch(p)
{
faceCellsPtr_ = new labelList::subList(faceCells, faceCells.size());
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::polyPatch::~polyPatch() Foam::polyPatch::~polyPatch()

View File

@ -203,11 +203,11 @@ public:
const word& patchType const word& patchType
); );
//- Construct as copy, resetting the boundary mesh //- Copy construct, resetting the boundary mesh
polyPatch(const polyPatch&, const polyBoundaryMesh&); polyPatch(const polyPatch&, const polyBoundaryMesh&);
//- Construct given the original patch and resetting the //- Construct given the original patch and resetting the
// face list and boundary mesh information //- face list and boundary mesh information
polyPatch polyPatch
( (
const polyPatch& pp, const polyPatch& pp,
@ -227,8 +227,19 @@ public:
const label newStart const label newStart
); );
//- Construct as copy //- Copy construct
polyPatch(const polyPatch&); polyPatch(const polyPatch& p);
//- Copy construct, setting faceCells
// \note The faceCells are held by the caller
polyPatch(const polyPatch& p, const labelList& faceCells);
//- Construct and return a clone, setting faceCells
// \note The faceCells are held by the caller
virtual autoPtr<polyPatch> clone(const labelList& faceCells) const
{
return autoPtr<polyPatch>::New(*this, faceCells);
}
//- Construct and return a clone, resetting the boundary mesh //- Construct and return a clone, resetting the boundary mesh
virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
@ -266,8 +277,7 @@ public:
// Selectors // Selectors
//- Return a pointer to a new patch created on freestore from //- Return pointer to a new patch created on freestore from components
// components
static autoPtr<polyPatch> New static autoPtr<polyPatch> New
( (
const word& patchType, const word& patchType,
@ -278,8 +288,7 @@ public:
const polyBoundaryMesh& bm const polyBoundaryMesh& bm
); );
//- Return a pointer to a new patch created on freestore from //- Return pointer to a new patch created on freestore from dictionary
// dictionary
static autoPtr<polyPatch> New static autoPtr<polyPatch> New
( (
const word& name, const word& name,
@ -288,8 +297,7 @@ public:
const polyBoundaryMesh& bm const polyBoundaryMesh& bm
); );
//- Return a pointer to a new patch created on freestore from //- Return pointer to a new patch created on freestore from dictionary
// dictionary
static autoPtr<polyPatch> New static autoPtr<polyPatch> New
( (
const word& patchType, const word& patchType,
@ -306,6 +314,51 @@ public:
// Member Functions // Member Functions
// Implicit treatment functions
//- Return number of new internal of this polyPatch faces
virtual void newInternalProcFaces(label&, label&) const
{
NotImplemented;
}
//- Return nbrCells
virtual const labelUList& nbrCells() const
{
NotImplemented
return faceCells();
}
//- Return nbr patchID
virtual label neighbPolyPatchID() const
{
NotImplemented;
return -1;
}
//- Return mapped collocated faces
virtual refPtr<labelListList> mapCollocatedFaces() const
{
NotImplemented;
refPtr<labelListList> tMap(new labelListList(size()));
return tMap;
}
//- Return implicit master
virtual bool masterImplicit() const
{
NotImplemented;
return false;
}
//- Return neighbour region name
virtual word neighbRegionID() const
{
return word("none");
}
//- The offset where this patch starts in the boundary face list //- The offset where this patch starts in the boundary face list
// The value is the same as patch.start() - mesh.nInternalFaces() // The value is the same as patch.start() - mesh.nInternalFaces()
label offset() const; label offset() const;
@ -364,7 +417,7 @@ public:
//- Write the polyPatch data as a dictionary //- Write the polyPatch data as a dictionary
virtual void write(Ostream&) const; virtual void write(Ostream& os) const;
// Geometric data; point list required // Geometric data; point list required

View File

@ -2,6 +2,7 @@ EXE_INC = \
-I../turbulenceModels/lnInclude \ -I../turbulenceModels/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/regionCoupled/lnInclude \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \ -I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude \

View File

@ -118,6 +118,23 @@ turbulentTemperatureCoupledBaffleMixedFvPatchScalarField
kappaLayers_(0), kappaLayers_(0),
contactRes_(0.0) contactRes_(0.0)
{ {
if (!isA<mappedPatchBase>(this->patch().patch()))
{
FatalErrorInFunction
<< "' not type '" << mappedPatchBase::typeName << "'"
<< "\n for patch " << p.name()
<< " of field " << internalField().name()
<< " in file " << internalField().objectPath()
<< exit(FatalError);
}
WarningInFunction
<< "This BC has been superseded by "
<< "compressible::turbulentTemperatureRadCoupledMixed "
<< "which has more functionalities and it can handle "
<< "the assemble coupled option for energy. "
<< endl;
if (dict.readIfPresent("thicknessLayers", thicknessLayers_)) if (dict.readIfPresent("thicknessLayers", thicknessLayers_))
{ {
dict.readEntry("kappaLayers", kappaLayers_); dict.readEntry("kappaLayers", kappaLayers_);
@ -349,6 +366,53 @@ void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::updateCoeffs()
} }
void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::manipulateMatrix
(
fvMatrix<scalar>& m,
const label iMatrix,
const direction cmpt
)
{
FatalErrorInFunction
<< "This BC does not support energy coupling "
<< "Use compressible::turbulentTemperatureRadCoupledMixed "
<< "which has more functionalities and it can handle "
<< "the assemble coupled option for energy. "
<< abort(FatalError);
}
tmp<Field<scalar>>
turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::coeffs
(
fvMatrix<scalar>& matrix,
const Field<scalar>& coeffs,
const label mat
) const
{
FatalErrorInFunction
<< "This BC does not support energy coupling "
<< "Use compressible::turbulentTemperatureRadCoupledMixed "
<< "which has more functionalities and it can handle "
<< "the assemble coupled option for energy. "
<< abort(FatalError);
/*
const label index(this->patch().index());
const label nSubFaces(matrix.lduMesh().cellBoundMap()[mat][index].size());
Field<scalar> mapCoeffs(nSubFaces, Zero);
label subFaceI = 0;
forAll(*this, faceI)
{
}
*/
return tmp<Field<scalar>>(new Field<scalar>());
}
void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::write void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::write
( (
Ostream& os Ostream& os

View File

@ -117,6 +117,17 @@ class turbulentTemperatureCoupledBaffleMixedFvPatchScalarField
scalar contactRes_; scalar contactRes_;
// Private member functions
//- Calculate coefficients for assembly matrix
tmp<Field<scalar>> coeffs
(
fvMatrix<scalar>& matrix,
const Field<scalar>&,
const label
) const;
public: public:
//- Runtime type information //- Runtime type information
@ -193,13 +204,22 @@ public:
} }
// Member functions // Member Functions
//- Update the coefficients associated with the patch field //- Update the coefficients associated with the patch field
virtual void updateCoeffs(); virtual void updateCoeffs();
//- Manipulate matrix
virtual void manipulateMatrix
(
fvMatrix<scalar>& m,
const label iMatrix,
const direction cmpt
);
//- Write //- Write
virtual void write(Ostream&) const; virtual void write(Ostream& os) const;
}; };

View File

@ -69,6 +69,7 @@ turbulentTemperatureRadCoupledMixedFvPatchScalarField
this->refValue() = 0.0; this->refValue() = 0.0;
this->refGrad() = 0.0; this->refGrad() = 0.0;
this->valueFraction() = 1.0; this->valueFraction() = 1.0;
this->source() = 0.0;
} }
@ -152,6 +153,19 @@ turbulentTemperatureRadCoupledMixedFvPatchScalarField
refGrad() = 0.0; refGrad() = 0.0;
valueFraction() = 1.0; valueFraction() = 1.0;
} }
if (dict.found("useImplicit"))
{
useImplicit() = dict.get<Switch>("useImplicit");
}
if (dict.found("source"))
{
source() = scalarField("source", dict, p.size());
}
else
{
source() = 0.0;
}
} }
@ -320,6 +334,19 @@ void turbulentTemperatureRadCoupledMixedFvPatchScalarField::updateCoeffs()
refGrad() = (qr + qrNbr)/kappa(Tp); refGrad() = (qr + qrNbr)/kappa(Tp);
} }
source() = Zero;
// If useImplicit is true we need the source term associated with this BC
if (this->useImplicit())
{
source() =
alphaSfDelta()*
(
valueFraction()*deltaH()
+ (qr + qrNbr)/beta()
);
}
mixedFvPatchScalarField::updateCoeffs(); mixedFvPatchScalarField::updateCoeffs();
if (debug) if (debug)
@ -345,6 +372,138 @@ void turbulentTemperatureRadCoupledMixedFvPatchScalarField::updateCoeffs()
} }
void turbulentTemperatureRadCoupledMixedFvPatchScalarField::manipulateMatrix
(
fvMatrix<scalar>& m,
const label iMatrix,
const direction cmpt
)
{
FatalErrorInFunction
<< "This T BC does not support energy coupling "
<< "It is implemented on he field "
<< abort(FatalError);
}
tmp<Field<scalar>> turbulentTemperatureRadCoupledMixedFvPatchScalarField::coeffs
(
fvMatrix<scalar>& matrix,
const Field<scalar>& coeffs,
const label mat
) const
{
FatalErrorInFunction
<< "This BC does not support energy coupling "
<< "Use compressible::turbulentTemperatureRadCoupledMixed "
<< "which has more functionalities and it can handle "
<< "the assemble coupled option for energy. "
<< abort(FatalError);
return tmp<Field<scalar>>(new Field<scalar>());
}
tmp<scalarField>
turbulentTemperatureRadCoupledMixedFvPatchScalarField::alphaSfDelta() const
{
return (alpha(*this)*patch().deltaCoeffs()*patch().magSf());
}
tmp<scalarField> turbulentTemperatureRadCoupledMixedFvPatchScalarField::
beta() const
{
const mappedPatchBase& mpp =
refCast<const mappedPatchBase>(patch().patch());
const label samplePatchi = mpp.samplePolyPatch().index();
const polyMesh& nbrMesh = mpp.sampleMesh();
const fvPatch& nbrPatch =
refCast<const fvMesh>(nbrMesh).boundary()[samplePatchi];
const turbulentTemperatureRadCoupledMixedFvPatchScalarField&
nbrField = refCast
<const turbulentTemperatureRadCoupledMixedFvPatchScalarField>
(
nbrPatch.lookupPatchField<volScalarField, scalar>(TnbrName_)
);
// Swap to obtain full local values of neighbour internal field
scalarField TcNbr(nbrField.patchInternalField());
mpp.distribute(TcNbr);
scalarField alphaDeltaNbr
(
nbrField.alpha(TcNbr)*nbrPatch.deltaCoeffs()
);
mpp.distribute(alphaDeltaNbr);
scalarField alphaDelta
(
alpha(*this)*patch().deltaCoeffs()
);
return (alphaDeltaNbr + alphaDelta);
}
tmp<scalarField> turbulentTemperatureRadCoupledMixedFvPatchScalarField::
deltaH() const
{
const mappedPatchBase& mpp =
refCast<const mappedPatchBase>(patch().patch());
const polyMesh& nbrMesh = mpp.sampleMesh();
const basicThermo* nbrThermo =
nbrMesh.cfindObject<basicThermo>(basicThermo::dictName);
const polyMesh& mesh = patch().boundaryMesh().mesh();
const basicThermo* localThermo =
mesh.cfindObject<basicThermo>(basicThermo::dictName);
if (nbrThermo && localThermo)
{
const label patchi = patch().index();
const scalarField& pp = localThermo->p().boundaryField()[patchi];
const scalarField& Tp = *this;
const mappedPatchBase& mpp =
refCast<const mappedPatchBase>(patch().patch());
const label patchiNrb = mpp.samplePolyPatch().index();
const scalarField& ppNbr = nbrThermo->p().boundaryField()[patchiNrb];
//const scalarField& TpNbr = nbrThermo->T().boundaryField()[patchiNrb];
// Use this Tp to evaluate he jump as this is updated while doing
// updateCoeffs on boundary fields which set T values on patches
// then non consistent Tp and Tpnbr could be used from different
// updated values (specially when T changes drastically between time
// steps/
return
(
- localThermo->he(pp, Tp, patchi)
+ nbrThermo->he(ppNbr, Tp, patchiNrb)
);
}
else
{
FatalErrorInFunction
<< "Can't find thermos on mapped patch "
<< " method, but thermo package not available"
<< exit(FatalError);
}
return tmp<scalarField>::New(patch().size(), Zero);
}
void turbulentTemperatureRadCoupledMixedFvPatchScalarField::write void turbulentTemperatureRadCoupledMixedFvPatchScalarField::write
( (
Ostream& os Ostream& os

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2017 OpenCFD Ltd Copyright (C) 2017-2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -100,7 +100,8 @@ class turbulentTemperatureRadCoupledMixedFvPatchScalarField
public mixedFvPatchScalarField, public mixedFvPatchScalarField,
public temperatureCoupledBase public temperatureCoupledBase
{ {
// Private data
// Private Data
//- Name of field on the neighbour region //- Name of field on the neighbour region
const word TnbrName_; const word TnbrName_;
@ -124,6 +125,27 @@ class turbulentTemperatureRadCoupledMixedFvPatchScalarField
Switch thermalInertia_; Switch thermalInertia_;
// Private Functions
//- Return local alphaSfDelta
tmp<scalarField> alphaSfDelta() const;
//- Return delta enthalpy between regions
tmp<scalarField> deltaH() const;
//- Return the sum of deltaCoeff*alpha from nbr and local
tmp<scalarField> beta() const;
//- Calculate coefficients for assembly matrix
tmp<Field<scalar>> coeffs
(
fvMatrix<scalar>& matrix,
const Field<scalar>&,
const label
) const;
public: public:
//- Runtime type information //- Runtime type information
@ -195,13 +217,22 @@ public:
} }
// Member functions // Member Functions
//- Update the coefficients associated with the patch field //- Update the coefficients associated with the patch field
virtual void updateCoeffs(); virtual void updateCoeffs();
//- Manipulate matrix
virtual void manipulateMatrix
(
fvMatrix<scalar>& m,
const label iMatrix,
const direction cmpt
);
//- Write //- Write
virtual void write(Ostream&) const; virtual void write(Ostream& os) const;
}; };

View File

@ -130,8 +130,7 @@ void Foam::porousBafflePressureFvPatchField::updateCoeffs()
return; return;
} }
const surfaceScalarField& phi = const auto& phi = db().lookupObject<surfaceScalarField>(phiName_);
db().lookupObject<surfaceScalarField>(phiName_);
const fvsPatchField<scalar>& phip = const fvsPatchField<scalar>& phip =
patch().patchField<surfaceScalarField, scalar>(phi); patch().patchField<surfaceScalarField, scalar>(phi);

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -48,6 +49,7 @@ void Foam::cyclicFaPatch::calcTransforms()
{ {
if (size() > 0) if (size() > 0)
{ {
// const label sizeby2 = this->size()/2;
pointField half0Ctrs(size()/2); pointField half0Ctrs(size()/2);
pointField half1Ctrs(size()/2); pointField half1Ctrs(size()/2);
for (label i=0; i<size()/2; ++i) for (label i=0; i<size()/2; ++i)
@ -153,7 +155,7 @@ void Foam::cyclicFaPatch::makeWeights(scalarField& w) const
const scalarField& magL = magEdgeLengths(); const scalarField& magL = magEdgeLengths();
const scalarField deltas(edgeNormals() & faPatch::delta()); const scalarField deltas(edgeNormals() & faPatch::delta());
label sizeby2 = deltas.size()/2; const label sizeby2 = deltas.size()/2;
scalar maxMatchError = 0; scalar maxMatchError = 0;
label errorEdge = -1; label errorEdge = -1;
@ -206,7 +208,7 @@ void Foam::cyclicFaPatch::makeWeights(scalarField& w) const
void Foam::cyclicFaPatch::makeDeltaCoeffs(scalarField& dc) const void Foam::cyclicFaPatch::makeDeltaCoeffs(scalarField& dc) const
{ {
const scalarField deltas(edgeNormals() & faPatch::delta()); const scalarField deltas(edgeNormals() & faPatch::delta());
label sizeby2 = deltas.size()/2; const label sizeby2 = deltas.size()/2;
for (label edgei = 0; edgei < sizeby2; ++edgei) for (label edgei = 0; edgei < sizeby2; ++edgei)
{ {
@ -248,10 +250,10 @@ void Foam::cyclicFaPatch::movePoints(const pointField& p)
Foam::tmp<Foam::vectorField> Foam::cyclicFaPatch::delta() const Foam::tmp<Foam::vectorField> Foam::cyclicFaPatch::delta() const
{ {
const vectorField patchD(faPatch::delta()); const vectorField patchD(faPatch::delta());
label sizeby2 = patchD.size()/2; const label sizeby2 = patchD.size()/2;
tmp<vectorField> tpdv(new vectorField(patchD.size())); auto tpdv = tmp<vectorField>::New(patchD.size());
vectorField& pdv = tpdv.ref(); auto& pdv = tpdv.ref();
// Do the transformation if necessary // Do the transformation if necessary
if (parallel()) if (parallel())
@ -290,16 +292,26 @@ Foam::tmp<Foam::labelField> Foam::cyclicFaPatch::interfaceInternalField
} }
Foam::tmp<Foam::labelField> Foam::cyclicFaPatch::interfaceInternalField
(
const labelUList& internalData,
const labelUList& edgeFaces
) const
{
return patchInternalField(internalData, edgeFaces);
}
Foam::tmp<Foam::labelField> Foam::cyclicFaPatch::transfer Foam::tmp<Foam::labelField> Foam::cyclicFaPatch::transfer
( (
const Pstream::commsTypes, const Pstream::commsTypes commsType,
const labelUList& interfaceData const labelUList& interfaceData
) const ) const
{ {
tmp<labelField> tpnf(new labelField(this->size())); auto tpnf = tmp<labelField>::New(this->size());
labelField& pnf = tpnf.ref(); auto& pnf = tpnf.ref();
label sizeby2 = this->size()/2; const label sizeby2 = this->size()/2;
for (label edgei=0; edgei<sizeby2; ++edgei) for (label edgei=0; edgei<sizeby2; ++edgei)
{ {
@ -317,12 +329,21 @@ Foam::tmp<Foam::labelField> Foam::cyclicFaPatch::internalFieldTransfer
const labelUList& iF const labelUList& iF
) const ) const
{ {
const labelUList& edgeCells = this->faceCells(); return internalFieldTransfer(commsType, iF, this->faceCells());
}
tmp<labelField> tpnf(new labelField(this->size()));
labelField& pnf = tpnf.ref();
label sizeby2 = this->size()/2; Foam::tmp<Foam::labelField> Foam::cyclicFaPatch::internalFieldTransfer
(
const Pstream::commsTypes commsType,
const labelUList& iF,
const labelUList& edgeCells
) const
{
auto tpnf = tmp<labelField>::New(this->size());
auto& pnf = tpnf.ref();
const label sizeby2 = this->size()/2;
for (label edgei=0; edgei<sizeby2; ++edgei) for (label edgei=0; edgei<sizeby2; ++edgei)
{ {

View File

@ -167,12 +167,22 @@ public:
// Interface transfer functions // Interface transfer functions
//- Return the values of the given internal data adjacent to //- Return the values of the given internal data adjacent to
// the interface as a field //- the interface as a field
virtual tmp<labelField> interfaceInternalField virtual tmp<labelField> interfaceInternalField
( (
const labelUList& internalData const labelUList& internalData
) const; ) const;
//- Return the values of the given internal data adjacent to
//- the interface as a field using edgeFace mapping
virtual tmp<labelField> interfaceInternalField
(
const labelUList& internalData,
const labelUList& edgeFaces
) const;
//- Transfer and return neighbour field //- Transfer and return neighbour field
virtual tmp<labelField> transfer virtual tmp<labelField> transfer
( (
@ -186,6 +196,15 @@ public:
const Pstream::commsTypes commsType, const Pstream::commsTypes commsType,
const labelUList& internalData const labelUList& internalData
) const; ) const;
//- Return neighbour field using edgeCells mapping
virtual tmp<labelField> internalFieldTransfer
(
const Pstream::commsTypes commsType,
const labelUList& internalData,
const labelUList& edgeCells
) const;
}; };

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -77,7 +78,6 @@ void Foam::processorFaPatch::makeNonGlobalPatchPoints() const
( (
!Pstream::parRun() !Pstream::parRun()
|| !boundaryMesh().mesh()().globalData().nGlobalPoints() || !boundaryMesh().mesh()().globalData().nGlobalPoints()
// || !boundaryMesh().mesh().globalData().nGlobalPoints()
) )
{ {
nonGlobalPatchPointsPtr_ = new labelList(nPoints()); nonGlobalPatchPointsPtr_ = new labelList(nPoints());
@ -464,6 +464,16 @@ Foam::tmp<Foam::labelField> Foam::processorFaPatch::interfaceInternalField
} }
Foam::tmp<Foam::labelField> Foam::processorFaPatch::interfaceInternalField
(
const labelUList& internalData,
const labelUList& edgeFaces
) const
{
return patchInternalField(internalData, edgeFaces);
}
void Foam::processorFaPatch::initTransfer void Foam::processorFaPatch::initTransfer
( (
const Pstream::commsTypes commsType, const Pstream::commsTypes commsType,
@ -504,6 +514,17 @@ Foam::tmp<Foam::labelField> Foam::processorFaPatch::internalFieldTransfer
} }
Foam::tmp<Foam::labelField> Foam::processorFaPatch::internalFieldTransfer
(
const Pstream::commsTypes commsType,
const labelUList&,
const labelUList&
) const
{
return receive<label>(commsType, this->size());
}
void Foam::processorFaPatch::write(Ostream& os) const void Foam::processorFaPatch::write(Ostream& os) const
{ {
faPatch::write(os); faPatch::write(os);

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -264,12 +265,20 @@ public:
// Interface transfer functions // Interface transfer functions
//- Return the values of the given internal data adjacent to //- Return the values of the given internal data adjacent to
// the interface as a field //- the interface as a field
virtual tmp<labelField> interfaceInternalField virtual tmp<labelField> interfaceInternalField
( (
const labelUList& internalData const labelUList& internalData
) const; ) const;
//- Return the values of the given internal data adjacent to
//- the interface as a field using edgeFaces
virtual tmp<labelField> interfaceInternalField
(
const labelUList& internalData,
const labelUList& edgeFaces
) const;
//- Initialise interface data transfer //- Initialise interface data transfer
virtual void initTransfer virtual void initTransfer
( (
@ -298,8 +307,16 @@ public:
const labelUList& internalData const labelUList& internalData
) const; ) const;
//- Return neighbour field using mapping
virtual tmp<labelField> internalFieldTransfer
(
const Pstream::commsTypes commsType,
const labelUList& internalData,
const labelUList& edgeCells
) const;
//- Write the patch data as a dictionary //- Write the patch data as a dictionary
virtual void write(Ostream&) const; virtual void write(Ostream& os) const;
}; };

View File

@ -357,6 +357,15 @@ public:
template<class Type> template<class Type>
tmp<Field<Type>> patchInternalField(const UList<Type>&) const; tmp<Field<Type>> patchInternalField(const UList<Type>&) const;
//- Return given internal field next to patch as patch field
// providing addressing
template<class Type>
tmp<Foam::Field<Type>> patchInternalField
(
const UList<Type>& f,
const labelUList& edgeFaces
) const;
//- Return the corresponding patchField of the named field //- Return the corresponding patchField of the named field
template<class GeometricField, class Type> template<class GeometricField, class Type>
const typename GeometricField::Patch& patchField const typename GeometricField::Patch& patchField

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -35,10 +36,19 @@ Foam::tmp<Foam::Field<Type>> Foam::faPatch::patchInternalField
const UList<Type>& f const UList<Type>& f
) const ) const
{ {
tmp<Field<Type>> tpif (new Field<Type>(size())); return patchInternalField(f, this->edgeFaces());
Field<Type>& pif = tpif.ref(); }
const labelUList& edgeFaces = this->edgeFaces();
template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::faPatch::patchInternalField
(
const UList<Type>& f,
const labelUList& edgeFaces
) const
{
auto tpif = tmp<Field<Type>>::New(size());
auto& pif = tpif.ref();
forAll(pif, facei) forAll(pif, facei)
{ {

View File

@ -193,6 +193,8 @@ public:
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction, const direction,
@ -204,6 +206,8 @@ public:
( (
Field<Type>& result, Field<Type>& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const Field<Type>&, const Field<Type>&,
const scalarField& coeffs, const scalarField& coeffs,
const Pstream::commsTypes commsType const Pstream::commsTypes commsType

View File

@ -129,7 +129,7 @@ Foam::cyclicFaPatchField<Type>::patchNeighbourField() const
tmp<Field<Type>> tpnf(new Field<Type>(this->size())); tmp<Field<Type>> tpnf(new Field<Type>(this->size()));
Field<Type>& pnf = tpnf.ref(); Field<Type>& pnf = tpnf.ref();
label sizeby2 = this->size()/2; const label sizeby2 = this->size()/2;
if (doTransform()) if (doTransform())
{ {
@ -164,6 +164,8 @@ void Foam::cyclicFaPatchField<Type>::updateInterfaceMatrix
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction cmpt, const direction cmpt,
@ -172,7 +174,7 @@ void Foam::cyclicFaPatchField<Type>::updateInterfaceMatrix
{ {
solveScalarField pnf(this->size()); solveScalarField pnf(this->size());
label sizeby2 = this->size()/2; const label sizeby2 = this->size()/2;
const labelUList& faceCells = cyclicPatch_.faceCells(); const labelUList& faceCells = cyclicPatch_.faceCells();
for (label facei = 0; facei < sizeby2; ++facei) for (label facei = 0; facei < sizeby2; ++facei)
@ -207,6 +209,8 @@ void Foam::cyclicFaPatchField<Type>::updateInterfaceMatrix
( (
Field<Type>& result, Field<Type>& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const Field<Type>& psiInternal, const Field<Type>& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const Pstream::commsTypes commsType const Pstream::commsTypes commsType
@ -214,7 +218,7 @@ void Foam::cyclicFaPatchField<Type>::updateInterfaceMatrix
{ {
Field<Type> pnf(this->size()); Field<Type> pnf(this->size());
label sizeby2 = this->size()/2; const label sizeby2 = this->size()/2;
const labelUList& faceCells = cyclicPatch_.faceCells(); const labelUList& faceCells = cyclicPatch_.faceCells();
for (label facei = 0; facei < sizeby2; ++facei) for (label facei = 0; facei < sizeby2; ++facei)

View File

@ -179,6 +179,8 @@ public:
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction cmpt, const direction cmpt,
@ -190,6 +192,8 @@ public:
( (
Field<Type>& result, Field<Type>& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const Field<Type>&, const Field<Type>&,
const scalarField& coeffs, const scalarField& coeffs,
const Pstream::commsTypes commsType const Pstream::commsTypes commsType

View File

@ -192,6 +192,8 @@ void Foam::processorFaPatchField<Type>::initInterfaceMatrixUpdate
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction, const direction,
@ -211,6 +213,8 @@ void Foam::processorFaPatchField<Type>::updateInterfaceMatrix
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField&, const solveScalarField&,
const scalarField& coeffs, const scalarField& coeffs,
const direction cmpt, const direction cmpt,
@ -251,6 +255,8 @@ void Foam::processorFaPatchField<Type>::initInterfaceMatrixUpdate
( (
Field<Type>& result, Field<Type>& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const Field<Type>& psiInternal, const Field<Type>& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const Pstream::commsTypes commsType const Pstream::commsTypes commsType
@ -269,6 +275,8 @@ void Foam::processorFaPatchField<Type>::updateInterfaceMatrix
( (
Field<Type>& result, Field<Type>& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const Field<Type>&, const Field<Type>&,
const scalarField& coeffs, const scalarField& coeffs,
const Pstream::commsTypes commsType const Pstream::commsTypes commsType

View File

@ -193,6 +193,8 @@ public:
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction cmpt, const direction cmpt,
@ -204,6 +206,8 @@ public:
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction cmpt, const direction cmpt,
@ -215,6 +219,8 @@ public:
( (
Field<Type>& result, Field<Type>& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const Field<Type>&, const Field<Type>&,
const scalarField& coeffs, const scalarField& coeffs,
const Pstream::commsTypes commsType const Pstream::commsTypes commsType
@ -225,6 +231,8 @@ public:
( (
Field<Type>& result, Field<Type>& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const Field<Type>&, const Field<Type>&,
const scalarField& coeffs, const scalarField& coeffs,
const Pstream::commsTypes commsType const Pstream::commsTypes commsType

View File

@ -44,6 +44,8 @@ void Foam::processorFaPatchField<Foam::scalar>::initInterfaceMatrixUpdate
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction, const direction,
@ -63,6 +65,8 @@ void Foam::processorFaPatchField<Foam::scalar>::updateInterfaceMatrix
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField&, const solveScalarField&,
const scalarField& coeffs, const scalarField& coeffs,
const direction, const direction,

View File

@ -51,6 +51,8 @@ void processorFaPatchField<scalar>::initInterfaceMatrixUpdate
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField&, const solveScalarField&,
const scalarField& coeffs, const scalarField& coeffs,
const direction, const direction,
@ -63,6 +65,8 @@ void processorFaPatchField<scalar>::updateInterfaceMatrix
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField&, const solveScalarField&,
const scalarField& coeffs, const scalarField& coeffs,
const direction, const direction,

View File

@ -142,6 +142,7 @@ $(constraintFvPatchFields)/jumpCyclicAMI/jumpCyclicAMIFvPatchFields.C
$(constraintFvPatchFields)/nonuniformTransformCyclic/nonuniformTransformCyclicFvPatchFields.C $(constraintFvPatchFields)/nonuniformTransformCyclic/nonuniformTransformCyclicFvPatchFields.C
$(constraintFvPatchFields)/processor/processorFvPatchFields.C $(constraintFvPatchFields)/processor/processorFvPatchFields.C
$(constraintFvPatchFields)/processorCyclic/processorCyclicFvPatchFields.C $(constraintFvPatchFields)/processorCyclic/processorCyclicFvPatchFields.C
$(constraintFvPatchFields)/calculatedProcessor/calculatedProcessorFvPatchFields.C
$(constraintFvPatchFields)/symmetryPlane/symmetryPlaneFvPatchFields.C $(constraintFvPatchFields)/symmetryPlane/symmetryPlaneFvPatchFields.C
$(constraintFvPatchFields)/symmetryPlane/symmetryPlaneFvPatchScalarField.C $(constraintFvPatchFields)/symmetryPlane/symmetryPlaneFvPatchScalarField.C
$(constraintFvPatchFields)/symmetry/symmetryFvPatchFields.C $(constraintFvPatchFields)/symmetry/symmetryFvPatchFields.C
@ -516,4 +517,9 @@ $(fvOptions)/fvOptionIO.C
$(fvOptions)/fvOptionList.C $(fvOptions)/fvOptionList.C
$(fvOptions)/fvOptions.C $(fvOptions)/fvOptions.C
lduPrimitiveMeshAssembly/AssemblyFvPatches.C
lduPrimitiveMeshAssembly/lduPrimitiveMeshAssembly.C
lduPrimitiveMeshAssembly/assemblyFaceAreaPairGAMGAgglomeration/assemblyFaceAreaPairGAMGAgglomeration.C
LIB = $(FOAM_LIBBIN)/libfiniteVolume LIB = $(FOAM_LIBBIN)/libfiniteVolume

View File

@ -9,3 +9,4 @@ LIB_LIBS = \
-lfileFormats \ -lfileFormats \
-lsurfMesh \ -lsurfMesh \
-lmeshTools -lmeshTools

View File

@ -211,6 +211,8 @@ public:
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction, const direction,
@ -222,6 +224,8 @@ public:
( (
Field<Type>&, Field<Type>&,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const Field<Type>&, const Field<Type>&,
const scalarField&, const scalarField&,
const Pstream::commsTypes commsType const Pstream::commsTypes commsType

View File

@ -39,7 +39,8 @@ Foam::mixedFvPatchField<Type>::mixedFvPatchField
fvPatchField<Type>(p, iF), fvPatchField<Type>(p, iF),
refValue_(p.size()), refValue_(p.size()),
refGrad_(p.size()), refGrad_(p.size()),
valueFraction_(p.size()) valueFraction_(p.size()),
source_(p.size(), Zero)
{} {}
@ -54,7 +55,8 @@ Foam::mixedFvPatchField<Type>::mixedFvPatchField
fvPatchField<Type>(p, iF, dict, false), fvPatchField<Type>(p, iF, dict, false),
refValue_("refValue", dict, p.size()), refValue_("refValue", dict, p.size()),
refGrad_("refGradient", dict, p.size()), refGrad_("refGradient", dict, p.size()),
valueFraction_("valueFraction", dict, p.size()) valueFraction_("valueFraction", dict, p.size()),
source_(p.size(), Zero)
{ {
// Could also check/clip fraction to 0-1 range // Could also check/clip fraction to 0-1 range
evaluate(); evaluate();
@ -73,7 +75,8 @@ Foam::mixedFvPatchField<Type>::mixedFvPatchField
fvPatchField<Type>(ptf, p, iF, mapper), fvPatchField<Type>(ptf, p, iF, mapper),
refValue_(ptf.refValue_, mapper), refValue_(ptf.refValue_, mapper),
refGrad_(ptf.refGrad_, mapper), refGrad_(ptf.refGrad_, mapper),
valueFraction_(ptf.valueFraction_, mapper) valueFraction_(ptf.valueFraction_, mapper),
source_(ptf.source_, mapper)
{ {
if (notNull(iF) && mapper.hasUnmapped()) if (notNull(iF) && mapper.hasUnmapped())
{ {
@ -96,7 +99,8 @@ Foam::mixedFvPatchField<Type>::mixedFvPatchField
fvPatchField<Type>(ptf), fvPatchField<Type>(ptf),
refValue_(ptf.refValue_), refValue_(ptf.refValue_),
refGrad_(ptf.refGrad_), refGrad_(ptf.refGrad_),
valueFraction_(ptf.valueFraction_) valueFraction_(ptf.valueFraction_),
source_(ptf.source_)
{} {}
@ -110,7 +114,8 @@ Foam::mixedFvPatchField<Type>::mixedFvPatchField
fvPatchField<Type>(ptf, iF), fvPatchField<Type>(ptf, iF),
refValue_(ptf.refValue_), refValue_(ptf.refValue_),
refGrad_(ptf.refGrad_), refGrad_(ptf.refGrad_),
valueFraction_(ptf.valueFraction_) valueFraction_(ptf.valueFraction_),
source_(ptf.source_)
{} {}
@ -126,6 +131,7 @@ void Foam::mixedFvPatchField<Type>::autoMap
refValue_.autoMap(m); refValue_.autoMap(m);
refGrad_.autoMap(m); refGrad_.autoMap(m);
valueFraction_.autoMap(m); valueFraction_.autoMap(m);
source_.autoMap(m);
} }
@ -144,12 +150,14 @@ void Foam::mixedFvPatchField<Type>::rmap
refValue_.rmap(mptf.refValue_, addr); refValue_.rmap(mptf.refValue_, addr);
refGrad_.rmap(mptf.refGrad_, addr); refGrad_.rmap(mptf.refGrad_, addr);
valueFraction_.rmap(mptf.valueFraction_, addr); valueFraction_.rmap(mptf.valueFraction_, addr);
source_.rmap(mptf.source_, addr);
} }
template<class Type> template<class Type>
void Foam::mixedFvPatchField<Type>::evaluate(const Pstream::commsTypes) void Foam::mixedFvPatchField<Type>::evaluate(const Pstream::commsTypes)
{ {
if (!this->updated()) if (!this->updated())
{ {
this->updateCoeffs(); this->updateCoeffs();
@ -158,9 +166,8 @@ void Foam::mixedFvPatchField<Type>::evaluate(const Pstream::commsTypes)
Field<Type>::operator= Field<Type>::operator=
( (
valueFraction_*refValue_ valueFraction_*refValue_
+ + (1.0 - valueFraction_)
(1.0 - valueFraction_)* *(
(
this->patchInternalField() this->patchInternalField()
+ refGrad_/this->patch().deltaCoeffs() + refGrad_/this->patch().deltaCoeffs()
) )
@ -190,7 +197,6 @@ Foam::mixedFvPatchField<Type>::valueInternalCoeffs
) const ) const
{ {
return Type(pTraits<Type>::one)*(1.0 - valueFraction_); return Type(pTraits<Type>::one)*(1.0 - valueFraction_);
} }
@ -232,6 +238,7 @@ void Foam::mixedFvPatchField<Type>::write(Ostream& os) const
refValue_.writeEntry("refValue", os); refValue_.writeEntry("refValue", os);
refGrad_.writeEntry("refGradient", os); refGrad_.writeEntry("refGradient", os);
valueFraction_.writeEntry("valueFraction", os); valueFraction_.writeEntry("valueFraction", os);
source_.writeEntry("source", os);
this->writeEntry("value", os); this->writeEntry("value", os);
} }

View File

@ -100,6 +100,9 @@ class mixedFvPatchField
//- Fraction (0-1) of value used for boundary condition //- Fraction (0-1) of value used for boundary condition
scalarField valueFraction_; scalarField valueFraction_;
//- Source field
Field<Type> source_;
public: public:
@ -219,6 +222,16 @@ public:
return valueFraction_; return valueFraction_;
} }
virtual Field<Type>& source()
{
return source_;
}
virtual const Field<Type>& source() const
{
return source_;
}
// Mapping functions // Mapping functions

View File

@ -37,7 +37,6 @@ Foam::calculatedProcessorFvPatchField<Type>::calculatedProcessorFvPatchField
const DimensionedField<Type, volMesh>& iF const DimensionedField<Type, volMesh>& iF
) )
: :
//lduInterfaceField(interface),
coupledFvPatchField<Type>(p, iF), coupledFvPatchField<Type>(p, iF),
procInterface_(refCast<const lduPrimitiveProcessorInterface>(interface)), procInterface_(refCast<const lduPrimitiveProcessorInterface>(interface)),
sendBuf_(interface.faceCells().size()), sendBuf_(interface.faceCells().size()),
@ -55,7 +54,6 @@ Foam::calculatedProcessorFvPatchField<Type>::calculatedProcessorFvPatchField
const calculatedProcessorFvPatchField<Type>& ptf const calculatedProcessorFvPatchField<Type>& ptf
) )
: :
//lduInterfaceField(ptf.procInterface_),
coupledFvPatchField<Type>(ptf), coupledFvPatchField<Type>(ptf),
procInterface_(ptf.procInterface_), procInterface_(ptf.procInterface_),
sendBuf_(procInterface_.faceCells().size()), sendBuf_(procInterface_.faceCells().size()),
@ -75,7 +73,6 @@ Foam::calculatedProcessorFvPatchField<Type>::calculatedProcessorFvPatchField
const DimensionedField<Type, volMesh>& iF const DimensionedField<Type, volMesh>& iF
) )
: :
//lduInterfaceField(ptf.procInterface_),
coupledFvPatchField<Type>(ptf, iF), coupledFvPatchField<Type>(ptf, iF),
procInterface_(ptf.procInterface_), procInterface_(ptf.procInterface_),
sendBuf_(procInterface_.faceCells().size()), sendBuf_(procInterface_.faceCells().size()),
@ -98,9 +95,7 @@ bool Foam::calculatedProcessorFvPatchField<Type>::ready() const
&& this->outstandingSendRequest_ < Pstream::nRequests() && this->outstandingSendRequest_ < Pstream::nRequests()
) )
{ {
bool finished = if (!UPstream::finishedRequest(this->outstandingSendRequest_))
UPstream::finishedRequest(this->outstandingSendRequest_);
if (!finished)
{ {
return false; return false;
} }
@ -113,9 +108,7 @@ bool Foam::calculatedProcessorFvPatchField<Type>::ready() const
&& this->outstandingRecvRequest_ < Pstream::nRequests() && this->outstandingRecvRequest_ < Pstream::nRequests()
) )
{ {
bool finished = if (!UPstream::finishedRequest(this->outstandingRecvRequest_))
UPstream::finishedRequest(this->outstandingRecvRequest_);
if (!finished)
{ {
return false; return false;
} }
@ -130,7 +123,7 @@ template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::tmp<Foam::Field<Type>>
Foam::calculatedProcessorFvPatchField<Type>::patchNeighbourField() const Foam::calculatedProcessorFvPatchField<Type>::patchNeighbourField() const
{ {
if (debug && !this->ready()) if (!this->ready())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "On patch of size " << procInterface_.faceCells().size() << "On patch of size " << procInterface_.faceCells().size()
@ -217,6 +210,8 @@ void Foam::calculatedProcessorFvPatchField<Type>::initInterfaceMatrixUpdate
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction cmpt, const direction cmpt,
@ -224,14 +219,16 @@ void Foam::calculatedProcessorFvPatchField<Type>::initInterfaceMatrixUpdate
) const ) const
{ {
// Bypass patchInternalField since uses fvPatch addressing // Bypass patchInternalField since uses fvPatch addressing
const labelList& fc = procInterface_.faceCells();
const labelList& fc = lduAddr.patchAddr(patchId);
scalarSendBuf_.setSize(fc.size()); scalarSendBuf_.setSize(fc.size());
forAll(fc, i) forAll(fc, i)
{ {
scalarSendBuf_[i] = psiInternal[fc[i]]; scalarSendBuf_[i] = psiInternal[fc[i]];
} }
if (debug && !this->ready()) if (!this->ready())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "On patch " //<< interface_.name() << "On patch " //<< interface_.name()
@ -240,8 +237,10 @@ void Foam::calculatedProcessorFvPatchField<Type>::initInterfaceMatrixUpdate
} }
scalarReceiveBuf_.setSize(scalarSendBuf_.size()); scalarReceiveBuf_.setSize(scalarSendBuf_.size());
outstandingRecvRequest_ = UPstream::nRequests(); outstandingRecvRequest_ = UPstream::nRequests();
UIPstream::read UIPstream::read
( (
Pstream::commsTypes::nonBlocking, Pstream::commsTypes::nonBlocking,
@ -253,6 +252,7 @@ void Foam::calculatedProcessorFvPatchField<Type>::initInterfaceMatrixUpdate
); );
outstandingSendRequest_ = UPstream::nRequests(); outstandingSendRequest_ = UPstream::nRequests();
UOPstream::write UOPstream::write
( (
Pstream::commsTypes::nonBlocking, Pstream::commsTypes::nonBlocking,
@ -303,6 +303,8 @@ void Foam::calculatedProcessorFvPatchField<Type>::updateInterfaceMatrix
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction cmpt, const direction cmpt,
@ -314,6 +316,7 @@ void Foam::calculatedProcessorFvPatchField<Type>::updateInterfaceMatrix
return; return;
} }
if if
( (
outstandingRecvRequest_ >= 0 outstandingRecvRequest_ >= 0
@ -337,13 +340,4 @@ void Foam::calculatedProcessorFvPatchField<Type>::updateInterfaceMatrix
} }
//template<class Type>
//void Foam::calculatedProcessorFvPatchField<Type>::write(Ostream& os) const
//{
// //zeroGradientFvPatchField<Type>::write(os);
// fvPatchField<Type>::write(os);
// this->writeEntry("value", os);
//}
// ************************************************************************* // // ************************************************************************* //

View File

@ -30,7 +30,7 @@ Group
grpGenericBoundaryConditions grpGenericBoundaryConditions
Description Description
processorFvPatchField type bypassing fvPatch A processorFvPatchField type bypassing fvPatch
Used to temporarily add updateInterfaceMatrix capabilities to a matrix Used to temporarily add updateInterfaceMatrix capabilities to a matrix
during overset solving. Supplies: during overset solving. Supplies:
@ -68,7 +68,7 @@ class calculatedProcessorFvPatchField
{ {
protected: protected:
// Private data // Protected data
//- Local reference cast into the interface //- Local reference cast into the interface
const lduPrimitiveProcessorInterface& procInterface_; const lduPrimitiveProcessorInterface& procInterface_;
@ -94,8 +94,7 @@ protected:
mutable label outstandingRecvRequest_; mutable label outstandingRecvRequest_;
// Protected Member Functions
// Private Member Functions
void addToInternalField void addToInternalField
( (
@ -234,6 +233,8 @@ public:
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction cmpt, const direction cmpt,
@ -245,6 +246,8 @@ public:
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction cmpt, const direction cmpt,
@ -256,6 +259,8 @@ public:
( (
Field<Type>& result, Field<Type>& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const Field<Type>& psiInternal, const Field<Type>& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const Pstream::commsTypes commsType const Pstream::commsTypes commsType
@ -269,6 +274,8 @@ public:
( (
Field<Type>& result, Field<Type>& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const Field<Type>& psiInternal, const Field<Type>& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const Pstream::commsTypes commsType const Pstream::commsTypes commsType
@ -278,7 +285,7 @@ public:
} }
//- Write //- Write
//virtual void write(Ostream&) const; // virtual void write(Ostream& os) const;
}; };

View File

@ -37,15 +37,31 @@ namespace Foam
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineNamedTemplateTypeNameAndDebug(calculatedProcessorFvPatchScalarField, 0); defineNamedTemplateTypeNameAndDebug
defineNamedTemplateTypeNameAndDebug(calculatedProcessorFvPatchVectorField, 0); (
calculatedProcessorFvPatchScalarField,
0
);
defineNamedTemplateTypeNameAndDebug
(
calculatedProcessorFvPatchVectorField,
0
);
defineNamedTemplateTypeNameAndDebug defineNamedTemplateTypeNameAndDebug
( (
calculatedProcessorFvPatchSphericalTensorField, calculatedProcessorFvPatchSphericalTensorField,
0 0
); );
defineNamedTemplateTypeNameAndDebug(calculatedProcessorFvPatchSymmTensorField, 0); defineNamedTemplateTypeNameAndDebug
defineNamedTemplateTypeNameAndDebug(calculatedProcessorFvPatchTensorField, 0); (
calculatedProcessorFvPatchSymmTensorField,
0
);
defineNamedTemplateTypeNameAndDebug
(
calculatedProcessorFvPatchTensorField,
0
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -26,8 +26,10 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "fvMatrix.H"
#include "cyclicFvPatchField.H" #include "cyclicFvPatchField.H"
#include "transformField.H" #include "transformField.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -174,27 +176,36 @@ Foam::cyclicFvPatchField<Type>::neighbourPatchField() const
} }
template<class Type> template<class Type>
void Foam::cyclicFvPatchField<Type>::updateInterfaceMatrix void Foam::cyclicFvPatchField<Type>::updateInterfaceMatrix
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction cmpt, const direction cmpt,
const Pstream::commsTypes const Pstream::commsTypes commsType
) const ) const
{ {
const labelUList& nbrFaceCells = const labelUList& nbrFaceCells =
cyclicPatch().cyclicPatch().neighbPatch().faceCells(); lduAddr.patchAddr
(
this->cyclicPatch().neighbPatchID()
);
solveScalarField pnf(psiInternal, nbrFaceCells); solveScalarField pnf(psiInternal, nbrFaceCells);
// Transform according to the transformation tensors // Transform according to the transformation tensors
transformCoupleField(pnf, cmpt); transformCoupleField(pnf, cmpt);
const labelUList& faceCells = lduAddr.patchAddr(patchId);
// Multiply the field by coefficients and add into the result // Multiply the field by coefficients and add into the result
this->addToInternalField(result, !add, coeffs, pnf); this->addToInternalField(result, !add, faceCells, coeffs, pnf);
} }
@ -203,21 +214,28 @@ void Foam::cyclicFvPatchField<Type>::updateInterfaceMatrix
( (
Field<Type>& result, Field<Type>& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const Field<Type>& psiInternal, const Field<Type>& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const Pstream::commsTypes const Pstream::commsTypes
) const ) const
{ {
const labelUList& nbrFaceCells = const labelList& nbrFaceCells =
cyclicPatch().cyclicPatch().neighbPatch().faceCells(); lduAddr.patchAddr
(
this->cyclicPatch().neighbPatchID()
);
Field<Type> pnf(psiInternal, nbrFaceCells); Field<Type> pnf(psiInternal, nbrFaceCells);
// Transform according to the transformation tensors // Transform according to the transformation tensors
transformCoupleField(pnf); transformCoupleField(pnf);
const labelUList& faceCells = lduAddr.patchAddr(patchId);
// Multiply the field by coefficients and add into the result // Multiply the field by coefficients and add into the result
this->addToInternalField(result, !add, coeffs, pnf); this->addToInternalField(result, !add, faceCells, coeffs, pnf);
} }
@ -228,4 +246,81 @@ void Foam::cyclicFvPatchField<Type>::write(Ostream& os) const
} }
template<class Type>
void Foam::cyclicFvPatchField<Type>::manipulateMatrix
(
fvMatrix<Type>& matrix,
const label mat,
const direction cmpt
)
{
if (this->cyclicPatch().owner())
{
label index = this->patch().index();
const label globalPatchID =
matrix.lduMeshAssembly().patchLocalToGlobalMap()[mat][index];
const Field<scalar> intCoeffsCmpt
(
matrix.internalCoeffs()[globalPatchID].component(cmpt)
);
const Field<scalar> boundCoeffsCmpt
(
matrix.boundaryCoeffs()[globalPatchID].component(cmpt)
);
const labelUList& u = matrix.lduAddr().upperAddr();
const labelUList& l = matrix.lduAddr().lowerAddr();
const labelList& faceMap =
matrix.lduMeshAssembly().faceBoundMap()[mat][index];
forAll (faceMap, faceI)
{
label globalFaceI = faceMap[faceI];
const scalar boundCorr = -boundCoeffsCmpt[faceI];
const scalar intCorr = -intCoeffsCmpt[faceI];
matrix.upper()[globalFaceI] += boundCorr;
matrix.diag()[u[globalFaceI]] -= boundCorr;
matrix.diag()[l[globalFaceI]] -= intCorr;
if (matrix.asymmetric())
{
matrix.lower()[globalFaceI] += intCorr;
}
}
if (matrix.psi(mat).mesh().fluxRequired(this->internalField().name()))
{
matrix.internalCoeffs().set
(
globalPatchID, intCoeffsCmpt*pTraits<Type>::one
);
matrix.boundaryCoeffs().set
(
globalPatchID, boundCoeffsCmpt*pTraits<Type>::one
);
const label nbrPathID = this->cyclicPatch().neighbPatchID();
const label nbrGlobalPatchID =
matrix.lduMeshAssembly().patchLocalToGlobalMap()[mat][nbrPathID];
matrix.internalCoeffs().set
(
nbrGlobalPatchID, intCoeffsCmpt*pTraits<Type>::one
);
matrix.boundaryCoeffs().set
(
nbrGlobalPatchID, boundCoeffsCmpt*pTraits<Type>::one
);
}
}
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -93,6 +93,7 @@ class cyclicFvPatchField
public: public:
//- Runtime type information //- Runtime type information
TypeName(cyclicFvPatch::typeName_()); TypeName(cyclicFvPatch::typeName_());
@ -183,6 +184,8 @@ public:
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction cmpt, const direction cmpt,
@ -194,12 +197,24 @@ public:
( (
Field<Type>& result, Field<Type>& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const Field<Type>& psiInternal, const Field<Type>& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const Pstream::commsTypes commsType const Pstream::commsTypes commsType
) const; ) const;
//- Manipulate matrix
virtual void manipulateMatrix
(
fvMatrix<Type>& m,
const label iMatrix,
const direction cmp
);
// Cyclic coupled interface functions // Cyclic coupled interface functions
//- Does the patch field perform the transformation //- Does the patch field perform the transformation

View File

@ -26,6 +26,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "fvMatrix.H"
#include "cyclicACMIFvPatchField.H" #include "cyclicACMIFvPatchField.H"
#include "transformField.H" #include "transformField.H"
@ -160,7 +161,13 @@ Foam::tmp<Foam::Field<Type>>
Foam::cyclicACMIFvPatchField<Type>::patchNeighbourField() const Foam::cyclicACMIFvPatchField<Type>::patchNeighbourField() const
{ {
const Field<Type>& iField = this->primitiveField(); const Field<Type>& iField = this->primitiveField();
const cyclicACMIPolyPatch& cpp = cyclicACMIPatch_.cyclicACMIPatch(); //const cyclicACMIPolyPatch& cpp = cyclicACMIPatch_.cyclicACMIPatch();
// By pass polyPatch to get nbrId. Instead use cyclicAMIFvPatch virtual
// neighbPatch()
const cyclicACMIFvPatch& neighbPatch = cyclicACMIPatch_.neighbPatch();
const labelUList& nbrFaceCells = neighbPatch.faceCells();
tmp<Field<Type>> tpnf tmp<Field<Type>> tpnf
( (
cyclicACMIPatch_.interpolate cyclicACMIPatch_.interpolate
@ -168,7 +175,8 @@ Foam::cyclicACMIFvPatchField<Type>::patchNeighbourField() const
Field<Type> Field<Type>
( (
iField, iField,
cpp.neighbPatch().faceCells() nbrFaceCells
//cpp.neighbPatch().faceCells()
) )
) )
); );
@ -209,6 +217,7 @@ Foam::cyclicACMIFvPatchField<Type>::nonOverlapPatchField() const
this->primitiveField() this->primitiveField()
); );
// WIP: Needs to re-direct nonOverlapPatchID to new patchId for assembly?
return fld.boundaryField()[cyclicACMIPatch_.nonOverlapPatchID()]; return fld.boundaryField()[cyclicACMIPatch_.nonOverlapPatchID()];
} }
@ -218,17 +227,24 @@ void Foam::cyclicACMIFvPatchField<Type>::updateInterfaceMatrix
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction cmpt, const direction cmpt,
const Pstream::commsTypes const Pstream::commsTypes
) const ) const
{ {
const cyclicACMIPolyPatch& cpp = cyclicACMIPatch_.cyclicACMIPatch(); // note: only applying coupled contribution
// Note: only applying coupled contribution // const labelUList& nbrFaceCellsCoupled =
// lduAddr.patchAddr
// (
// cyclicACMIPatch_.cyclicACMIPatch().neighbPatchID()
// );
const labelUList& nbrFaceCellsCoupled = cpp.neighbPatch().faceCells(); const labelUList& nbrFaceCellsCoupled =
lduAddr.patchAddr(cyclicACMIPatch_.neighbPatchID());
solveScalarField pnf(psiInternal, nbrFaceCellsCoupled); solveScalarField pnf(psiInternal, nbrFaceCellsCoupled);
@ -237,7 +253,9 @@ void Foam::cyclicACMIFvPatchField<Type>::updateInterfaceMatrix
pnf = cyclicACMIPatch_.interpolate(pnf); pnf = cyclicACMIPatch_.interpolate(pnf);
this->addToInternalField(result, !add, coeffs, pnf); const labelUList& faceCells = lduAddr.patchAddr(patchId);
this->addToInternalField(result, !add, faceCells, coeffs, pnf);
} }
@ -246,16 +264,17 @@ void Foam::cyclicACMIFvPatchField<Type>::updateInterfaceMatrix
( (
Field<Type>& result, Field<Type>& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const Field<Type>& psiInternal, const Field<Type>& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const Pstream::commsTypes const Pstream::commsTypes
) const ) const
{ {
const cyclicACMIPolyPatch& cpp = cyclicACMIPatch_.cyclicACMIPatch(); // note: only applying coupled contribution
// Note: only applying coupled contribution const labelUList& nbrFaceCellsCoupled =
lduAddr.patchAddr(cyclicACMIPatch_.neighbPatchID());
const labelUList& nbrFaceCellsCoupled = cpp.neighbPatch().faceCells();
Field<Type> pnf(psiInternal, nbrFaceCellsCoupled); Field<Type> pnf(psiInternal, nbrFaceCellsCoupled);
@ -264,7 +283,9 @@ void Foam::cyclicACMIFvPatchField<Type>::updateInterfaceMatrix
pnf = cyclicACMIPatch_.interpolate(pnf); pnf = cyclicACMIPatch_.interpolate(pnf);
this->addToInternalField(result, !add, coeffs, pnf); const labelUList& faceCells = lduAddr.patchAddr(patchId);
this->addToInternalField(result, !add, faceCells, coeffs, pnf);
} }
@ -284,6 +305,141 @@ void Foam::cyclicACMIFvPatchField<Type>::manipulateMatrix
} }
template<class Type>
void Foam::cyclicACMIFvPatchField<Type>::manipulateMatrix
(
fvMatrix<Type>& matrix,
const label mat,
const direction cmpt
)
{
if (this->cyclicACMIPatch().owner())
{
label index = this->patch().index();
const label globalPatchID =
matrix.lduMeshAssembly().patchLocalToGlobalMap()[mat][index];
const Field<scalar> intCoeffsCmpt
(
matrix.internalCoeffs()[globalPatchID].component(cmpt)
);
const Field<scalar> boundCoeffsCmpt
(
matrix.boundaryCoeffs()[globalPatchID].component(cmpt)
);
tmp<Field<scalar>> tintCoeffs(coeffs(matrix, intCoeffsCmpt, mat));
tmp<Field<scalar>> tbndCoeffs(coeffs(matrix, boundCoeffsCmpt, mat));
const Field<scalar>& intCoeffs = tintCoeffs.ref();
const Field<scalar>& bndCoeffs = tbndCoeffs.ref();
const labelUList& u = matrix.lduAddr().upperAddr();
const labelUList& l = matrix.lduAddr().lowerAddr();
label subFaceI = 0;
const labelList& faceMap =
matrix.lduMeshAssembly().faceBoundMap()[mat][index];
forAll (faceMap, j)
{
label globalFaceI = faceMap[j];
const scalar boundCorr = -bndCoeffs[subFaceI];
const scalar intCorr = -intCoeffs[subFaceI];
matrix.upper()[globalFaceI] += boundCorr;
matrix.diag()[u[globalFaceI]] -= intCorr;
matrix.diag()[l[globalFaceI]] -= boundCorr;
if (matrix.asymmetric())
{
matrix.lower()[globalFaceI] += intCorr;
}
subFaceI++;
}
// Set internalCoeffs and boundaryCoeffs in the assembly matrix
// on clyclicAMI patches to be used in the individual matrix by
// matrix.flux()
if (matrix.psi(mat).mesh().fluxRequired(this->internalField().name()))
{
matrix.internalCoeffs().set
(
globalPatchID, intCoeffs*pTraits<Type>::one
);
matrix.boundaryCoeffs().set
(
globalPatchID, bndCoeffs*pTraits<Type>::one
);
const label nbrPathID =
cyclicACMIPatch_.cyclicACMIPatch().neighbPatchID();
const label nbrGlobalPatchID =
matrix.lduMeshAssembly().patchLocalToGlobalMap()
[mat][nbrPathID];
matrix.internalCoeffs().set
(
nbrGlobalPatchID, intCoeffs*pTraits<Type>::one
);
matrix.boundaryCoeffs().set
(
nbrGlobalPatchID, bndCoeffs*pTraits<Type>::one
);
}
}
}
template<class Type>
Foam::tmp<Foam::Field<Foam::scalar>>
Foam::cyclicACMIFvPatchField<Type>::coeffs
(
fvMatrix<Type>& matrix,
const Field<scalar>& coeffs,
const label mat
) const
{
const label index(this->patch().index());
const label nSubFaces
(
matrix.lduMeshAssembly().cellBoundMap()[mat][index].size()
);
Field<scalar> mapCoeffs(nSubFaces, Zero);
const scalarListList& srcWeight =
cyclicACMIPatch_.cyclicACMIPatch().AMI().srcWeights();
const scalarField& mask = cyclicACMIPatch_.cyclicACMIPatch().mask();
const scalar tol = cyclicACMIPolyPatch::tolerance();
label subFaceI = 0;
forAll(mask, faceI)
{
const scalarList& w = srcWeight[faceI];
for(label i=0; i<w.size(); i++)
{
if (mask[faceI] > tol)
{
const label localFaceId =
matrix.lduMeshAssembly().facePatchFaceMap()
[mat][index][subFaceI];
mapCoeffs[subFaceI] = w[i]*coeffs[localFaceId];
}
subFaceI++;
}
}
return tmp<Field<scalar>>(new Field<scalar>(mapCoeffs));
}
template<class Type> template<class Type>
void Foam::cyclicACMIFvPatchField<Type>::updateCoeffs() void Foam::cyclicACMIFvPatchField<Type>::updateCoeffs()
{ {

View File

@ -89,6 +89,15 @@ class cyclicACMIFvPatchField
const Field<Type2>& const Field<Type2>&
) const; ) const;
//- Return new matrix coeffs
tmp<Field<scalar>> coeffs
(
fvMatrix<Type>& matrix,
const Field<scalar>&,
const label
) const;
public: public:
@ -206,6 +215,8 @@ public:
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction cmpt, const direction cmpt,
@ -217,6 +228,8 @@ public:
( (
Field<Type>&, Field<Type>&,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const Field<Type>&, const Field<Type>&,
const scalarField&, const scalarField&,
const Pstream::commsTypes commsType const Pstream::commsTypes commsType
@ -225,6 +238,14 @@ public:
//- Manipulate matrix //- Manipulate matrix
virtual void manipulateMatrix(fvMatrix<Type>& matrix); virtual void manipulateMatrix(fvMatrix<Type>& matrix);
//- Manipulate matrix
virtual void manipulateMatrix
(
fvMatrix<Type>& m,
const label iMatrix,
const direction cmpt
);
//- Update the coefficients associated with the patch field //- Update the coefficients associated with the patch field
virtual void updateCoeffs(); virtual void updateCoeffs();

View File

@ -26,6 +26,10 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "fvMatrix.H"
#include "volFields.H"
//#include "cylicFvPatchField.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type> template<class Type>
@ -142,15 +146,20 @@ Foam::tmp<Foam::Field<Type>>
Foam::cyclicAMIFvPatchField<Type>::patchNeighbourField() const Foam::cyclicAMIFvPatchField<Type>::patchNeighbourField() const
{ {
const Field<Type>& iField = this->primitiveField(); const Field<Type>& iField = this->primitiveField();
const labelUList& nbrFaceCells =
cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().faceCells(); // By pass polyPatch to get nbrId. Instead use cyclicAMIFvPatch virtual
// neighbPatch()
const cyclicAMIFvPatch& neighbPatch = cyclicAMIPatch_.neighbPatch();
const labelUList& nbrFaceCells = neighbPatch.faceCells();
Field<Type> pnf(iField, nbrFaceCells); Field<Type> pnf(iField, nbrFaceCells);
tmp<Field<Type>> tpnf; tmp<Field<Type>> tpnf;
if (cyclicAMIPatch_.applyLowWeightCorrection()) if (cyclicAMIPatch_.applyLowWeightCorrection())
{ {
tpnf = cyclicAMIPatch_.interpolate(pnf, this->patchInternalField()()); Field<Type> pnfInternal(iField, cyclicAMIPatch_.faceCells());
tpnf = cyclicAMIPatch_.interpolate(pnf, pnfInternal);
} }
else else
{ {
@ -188,6 +197,8 @@ void Foam::cyclicAMIFvPatchField<Type>::updateInterfaceMatrix
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction cmpt, const direction cmpt,
@ -195,7 +206,7 @@ void Foam::cyclicAMIFvPatchField<Type>::updateInterfaceMatrix
) const ) const
{ {
const labelUList& nbrFaceCells = const labelUList& nbrFaceCells =
cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().faceCells(); lduAddr.patchAddr(cyclicAMIPatch_.neighbPatchID());
solveScalarField pnf(psiInternal, nbrFaceCells); solveScalarField pnf(psiInternal, nbrFaceCells);
@ -212,8 +223,10 @@ void Foam::cyclicAMIFvPatchField<Type>::updateInterfaceMatrix
pnf = cyclicAMIPatch_.interpolate(pnf); pnf = cyclicAMIPatch_.interpolate(pnf);
} }
const labelUList& faceCells = lduAddr.patchAddr(patchId);
// Multiply the field by coefficients and add into the result // Multiply the field by coefficients and add into the result
this->addToInternalField(result, !add, coeffs, pnf); this->addToInternalField(result, !add, faceCells, coeffs, pnf);
} }
@ -222,13 +235,15 @@ void Foam::cyclicAMIFvPatchField<Type>::updateInterfaceMatrix
( (
Field<Type>& result, Field<Type>& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const Field<Type>& psiInternal, const Field<Type>& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const Pstream::commsTypes const Pstream::commsTypes
) const ) const
{ {
const labelUList& nbrFaceCells = const labelUList& nbrFaceCells =
cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().faceCells(); lduAddr.patchAddr(cyclicAMIPatch_.neighbPatchID());
Field<Type> pnf(psiInternal, nbrFaceCells); Field<Type> pnf(psiInternal, nbrFaceCells);
@ -245,8 +260,178 @@ void Foam::cyclicAMIFvPatchField<Type>::updateInterfaceMatrix
pnf = cyclicAMIPatch_.interpolate(pnf); pnf = cyclicAMIPatch_.interpolate(pnf);
} }
const labelUList& faceCells = lduAddr.patchAddr(patchId);
// Multiply the field by coefficients and add into the result // Multiply the field by coefficients and add into the result
this->addToInternalField(result, !add, coeffs, pnf); this->addToInternalField(result, !add, faceCells, coeffs, pnf);
}
template<class Type>
void Foam::cyclicAMIFvPatchField<Type>::manipulateMatrix
(
fvMatrix<Type>& matrix,
const label mat,
const direction cmpt
)
{
if (this->cyclicAMIPatch().owner())
{
label index = this->patch().index();
const label globalPatchID =
matrix.lduMeshAssembly().patchLocalToGlobalMap()[mat][index];
const Field<scalar> intCoeffsCmpt
(
matrix.internalCoeffs()[globalPatchID].component(cmpt)
);
const Field<scalar> boundCoeffsCmpt
(
matrix.boundaryCoeffs()[globalPatchID].component(cmpt)
);
tmp<Field<scalar>> tintCoeffs(coeffs(matrix, intCoeffsCmpt, mat));
tmp<Field<scalar>> tbndCoeffs(coeffs(matrix, boundCoeffsCmpt, mat));
const Field<scalar>& intCoeffs = tintCoeffs.ref();
const Field<scalar>& bndCoeffs = tbndCoeffs.ref();
const labelUList& u = matrix.lduAddr().upperAddr();
const labelUList& l = matrix.lduAddr().lowerAddr();
label subFaceI = 0;
const labelList& faceMap =
matrix.lduMeshAssembly().faceBoundMap()[mat][index];
forAll (faceMap, j)
{
label globalFaceI = faceMap[j];
const scalar boundCorr = -bndCoeffs[subFaceI];
const scalar intCorr = -intCoeffs[subFaceI];
matrix.upper()[globalFaceI] += boundCorr;
matrix.diag()[u[globalFaceI]] -= intCorr;
matrix.diag()[l[globalFaceI]] -= boundCorr;
if (matrix.asymmetric())
{
matrix.lower()[globalFaceI] += intCorr;
}
subFaceI++;
}
// Set internalCoeffs and boundaryCoeffs in the assembly matrix
// on clyclicAMI patches to be used in the individual matrix by
// matrix.flux()
if (matrix.psi(mat).mesh().fluxRequired(this->internalField().name()))
{
matrix.internalCoeffs().set
(
globalPatchID, intCoeffs*pTraits<Type>::one
);
matrix.boundaryCoeffs().set
(
globalPatchID, bndCoeffs*pTraits<Type>::one
);
const label nbrPathID =
cyclicAMIPatch_.cyclicAMIPatch().neighbPatchID();
const label nbrGlobalPatchID =
matrix.lduMeshAssembly().patchLocalToGlobalMap()
[mat][nbrPathID];
matrix.internalCoeffs().set
(
nbrGlobalPatchID, intCoeffs*pTraits<Type>::one
);
matrix.boundaryCoeffs().set
(
nbrGlobalPatchID, bndCoeffs*pTraits<Type>::one
);
}
}
}
template<class Type>
Foam::tmp<Foam::Field<Foam::scalar>>
Foam::cyclicAMIFvPatchField<Type>::coeffs
(
fvMatrix<Type>& matrix,
const Field<scalar>& coeffs,
const label mat
) const
{
const label index(this->patch().index());
const label nSubFaces
(
matrix.lduMeshAssembly().cellBoundMap()[mat][index].size()
);
Field<scalar> mapCoeffs(nSubFaces, Zero);
const scalarListList& srcWeight =
cyclicAMIPatch_.cyclicAMIPatch().AMI().srcWeights();
label subFaceI = 0;
forAll(*this, faceI)
{
const scalarList& w = srcWeight[faceI];
for(label i=0; i<w.size(); i++)
{
const label localFaceId =
matrix.lduMeshAssembly().facePatchFaceMap()[mat][index][subFaceI];
mapCoeffs[subFaceI] = w[i]*coeffs[localFaceId];
subFaceI++;
}
}
return tmp<Field<scalar>>(new Field<scalar>(mapCoeffs));
}
template<class Type>
template<class Type2>
void Foam::cyclicAMIFvPatchField<Type>::collectStencilData
(
const refPtr<mapDistribute>& mapPtr,
const labelListList& stencil,
const Type2& data,
List<Type2>& expandedData
)
{
expandedData.setSize(stencil.size());
if (mapPtr.valid())
{
Type2 work(data);
mapPtr().distribute(work);
forAll(stencil, facei)
{
const labelList& slots = stencil[facei];
expandedData[facei].append
(
UIndirectList<typename Type2::value_type>(work, slots)
);
}
}
else
{
forAll(stencil, facei)
{
const labelList& slots = stencil[facei];
expandedData[facei].append
(
UIndirectList<typename Type2::value_type>(data, slots)
);
}
}
} }
@ -259,3 +444,4 @@ void Foam::cyclicAMIFvPatchField<Type>::write(Ostream& os) const
// ************************************************************************* // // ************************************************************************* //

View File

@ -60,6 +60,7 @@ SourceFiles
#ifndef cyclicAMIFvPatchField_H #ifndef cyclicAMIFvPatchField_H
#define cyclicAMIFvPatchField_H #define cyclicAMIFvPatchField_H
#include "coupledFvPatchField.H" #include "coupledFvPatchField.H"
#include "cyclicAMILduInterfaceField.H" #include "cyclicAMILduInterfaceField.H"
#include "cyclicAMIFvPatch.H" #include "cyclicAMIFvPatch.H"
@ -95,6 +96,25 @@ class cyclicAMIFvPatchField
) const; ) const;
//- Return new matrix coeffs
tmp<Field<scalar>> coeffs
(
fvMatrix<Type>& matrix,
const Field<scalar>&,
const label
) const;
template<class Type2>
void collectStencilData
(
const refPtr<mapDistribute>& mapPtr,
const labelListList& stencil,
const Type2& data,
List<Type2>& expandedData
);
public: public:
//- Runtime type information //- Runtime type information
@ -187,6 +207,8 @@ public:
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction cmpt, const direction cmpt,
@ -198,12 +220,23 @@ public:
( (
Field<Type>&, Field<Type>&,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const Field<Type>&, const Field<Type>&,
const scalarField&, const scalarField&,
const Pstream::commsTypes commsType const Pstream::commsTypes commsType
) const; ) const;
//- Manipulate matrix
virtual void manipulateMatrix
(
fvMatrix<Type>& m,
const label iMatrix,
const direction cmpt
);
// Cyclic AMI coupled interface functions // Cyclic AMI coupled interface functions
//- Does the patch field perform the transformation //- Does the patch field perform the transformation

View File

@ -101,8 +101,8 @@ Foam::jumpCyclicFvPatchField<Type>::patchNeighbourField() const
const labelUList& nbrFaceCells = const labelUList& nbrFaceCells =
this->cyclicPatch().neighbFvPatch().faceCells(); this->cyclicPatch().neighbFvPatch().faceCells();
tmp<Field<Type>> tpnf(new Field<Type>(this->size())); auto tpnf = tmp<Field<Type>>::New(this->size());
Field<Type>& pnf = tpnf.ref(); auto& pnf = tpnf.ref();
Field<Type> jf(this->jump()); Field<Type> jf(this->jump());
if (!this->cyclicPatch().owner()) if (!this->cyclicPatch().owner())
@ -137,6 +137,8 @@ void Foam::jumpCyclicFvPatchField<Type>::updateInterfaceMatrix
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction cmpt, const direction cmpt,
@ -152,6 +154,8 @@ void Foam::jumpCyclicFvPatchField<Type>::updateInterfaceMatrix
( (
Field<Type>& result, Field<Type>& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const Field<Type>& psiInternal, const Field<Type>& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const Pstream::commsTypes const Pstream::commsTypes
@ -160,7 +164,10 @@ void Foam::jumpCyclicFvPatchField<Type>::updateInterfaceMatrix
Field<Type> pnf(this->size()); Field<Type> pnf(this->size());
const labelUList& nbrFaceCells = const labelUList& nbrFaceCells =
this->cyclicPatch().neighbFvPatch().faceCells(); lduAddr.patchAddr
(
this->cyclicPatch().neighbPatchID()
);
// only apply jump to original field // only apply jump to original field
if (&psiInternal == &this->primitiveField()) if (&psiInternal == &this->primitiveField())
@ -188,8 +195,10 @@ void Foam::jumpCyclicFvPatchField<Type>::updateInterfaceMatrix
// Transform according to the transformation tensors // Transform according to the transformation tensors
this->transformCoupleField(pnf); this->transformCoupleField(pnf);
const labelUList& faceCells = lduAddr.patchAddr(patchId);
// Multiply the field by coefficients and add into the result // Multiply the field by coefficients and add into the result
this->addToInternalField(result, !add, coeffs, pnf); this->addToInternalField(result, !add, faceCells, coeffs, pnf);
} }

View File

@ -133,6 +133,8 @@ public:
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction cmpt, const direction cmpt,
@ -144,6 +146,8 @@ public:
( (
Field<Type>&, Field<Type>&,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const Field<Type>&, const Field<Type>&,
const scalarField&, const scalarField&,
const Pstream::commsTypes commsType const Pstream::commsTypes commsType
@ -156,6 +160,8 @@ void jumpCyclicFvPatchField<scalar>::updateInterfaceMatrix
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction cmpt, const direction cmpt,
@ -168,6 +174,8 @@ void jumpCyclicFvPatchField<vector>::updateInterfaceMatrix
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction cmpt, const direction cmpt,

View File

@ -44,6 +44,8 @@ void Foam::jumpCyclicFvPatchField<Foam::scalar>::updateInterfaceMatrix
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction cmpt, const direction cmpt,
@ -53,7 +55,10 @@ void Foam::jumpCyclicFvPatchField<Foam::scalar>::updateInterfaceMatrix
solveScalarField pnf(this->size()); solveScalarField pnf(this->size());
const labelUList& nbrFaceCells = const labelUList& nbrFaceCells =
this->cyclicPatch().neighbFvPatch().faceCells(); lduAddr.patchAddr
(
this->cyclicPatch().neighbPatchID()
);
// only apply jump to original field // only apply jump to original field
if if
@ -85,8 +90,10 @@ void Foam::jumpCyclicFvPatchField<Foam::scalar>::updateInterfaceMatrix
// Transform according to the transformation tensors // Transform according to the transformation tensors
this->transformCoupleField(pnf, cmpt); this->transformCoupleField(pnf, cmpt);
const labelUList& faceCells = lduAddr.patchAddr(patchId);
// Multiply the field by coefficients and add into the result // Multiply the field by coefficients and add into the result
this->addToInternalField(result, !add, coeffs, pnf); this->addToInternalField(result, !add, faceCells, coeffs, pnf);
} }
@ -95,6 +102,8 @@ void Foam::jumpCyclicFvPatchField<Foam::vector>::updateInterfaceMatrix
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction cmpt, const direction cmpt,
@ -104,7 +113,10 @@ void Foam::jumpCyclicFvPatchField<Foam::vector>::updateInterfaceMatrix
solveScalarField pnf(this->size()); solveScalarField pnf(this->size());
const labelUList& nbrFaceCells = const labelUList& nbrFaceCells =
this->cyclicPatch().neighbFvPatch().faceCells(); lduAddr.patchAddr
(
this->cyclicPatch().neighbPatchID()
);
const Field<vector>& iField = this->primitiveField(); const Field<vector>& iField = this->primitiveField();
@ -140,8 +152,10 @@ void Foam::jumpCyclicFvPatchField<Foam::vector>::updateInterfaceMatrix
// Transform according to the transformation tensors // Transform according to the transformation tensors
this->transformCoupleField(pnf, cmpt); this->transformCoupleField(pnf, cmpt);
const labelUList& faceCells = lduAddr.patchAddr(patchId);
// Multiply the field by coefficients and add into the result // Multiply the field by coefficients and add into the result
this->addToInternalField(result, !add, coeffs, pnf); this->addToInternalField(result, !add, faceCells, coeffs, pnf);
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -138,6 +138,8 @@ void Foam::jumpCyclicAMIFvPatchField<Type>::updateInterfaceMatrix
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction cmpt, const direction cmpt,
@ -153,13 +155,18 @@ void Foam::jumpCyclicAMIFvPatchField<Type>::updateInterfaceMatrix
( (
Field<Type>& result, Field<Type>& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const Field<Type>& psiInternal, const Field<Type>& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const Pstream::commsTypes const Pstream::commsTypes
) const ) const
{ {
const labelUList& nbrFaceCells = const labelUList& nbrFaceCells =
this->cyclicAMIPatch().cyclicAMIPatch().neighbPatch().faceCells(); lduAddr.patchAddr
(
this->cyclicAMIPatch().neighbPatchID()
);
Field<Type> pnf(psiInternal, nbrFaceCells); Field<Type> pnf(psiInternal, nbrFaceCells);
@ -193,8 +200,10 @@ void Foam::jumpCyclicAMIFvPatchField<Type>::updateInterfaceMatrix
// Transform according to the transformation tensors // Transform according to the transformation tensors
this->transformCoupleField(pnf); this->transformCoupleField(pnf);
const labelUList& faceCells = lduAddr.patchAddr(patchId);
// Multiply the field by coefficients and add into the result // Multiply the field by coefficients and add into the result
this->addToInternalField(result, !add, coeffs, pnf); this->addToInternalField(result, !add,faceCells, coeffs, pnf);
} }

View File

@ -135,6 +135,8 @@ public:
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction cmpt, const direction cmpt,
@ -146,6 +148,8 @@ public:
( (
Field<Type>&, Field<Type>&,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const Field<Type>&, const Field<Type>&,
const scalarField&, const scalarField&,
const Pstream::commsTypes commsType const Pstream::commsTypes commsType
@ -159,6 +163,8 @@ void jumpCyclicAMIFvPatchField<scalar>::updateInterfaceMatrix
( (
solveScalarField& result, solveScalarField& result,
const bool add, const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal, const solveScalarField& psiInternal,
const scalarField& coeffs, const scalarField& coeffs,
const direction cmpt, const direction cmpt,

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