Merge branch 'master' of /home/dm4/OpenFOAM/OpenFOAM-dev

This commit is contained in:
andy
2012-11-02 17:30:58 +00:00
184 changed files with 3440 additions and 5956 deletions

View File

@ -69,14 +69,9 @@ int main(int argc, char *argv[])
Info<< "Time = " << runTime.timeName() << nl << endl; Info<< "Time = " << runTime.timeName() << nl << endl;
#include "solveChemistry.H" #include "solveChemistry.H"
{
#include "YEqn.H" #include "YEqn.H"
#include "hEqn.H" #include "hEqn.H"
#include "pEqn.H" #include "pEqn.H"
}
#include "output.H" #include "output.H"

View File

@ -9,4 +9,6 @@
{ {
h[0] = h0 + integratedHeat; h[0] = h0 + integratedHeat;
} }
thermo.correct();
} }

View File

@ -1,5 +1,4 @@
{ {
thermo.correct();
rho = thermo.rho(); rho = thermo.rho();
if (constProp == "volume") if (constProp == "volume")
{ {

View File

@ -60,14 +60,9 @@ int main(int argc, char *argv[])
#include "createFluidMeshes.H" #include "createFluidMeshes.H"
#include "createSolidMeshes.H" #include "createSolidMeshes.H"
#include "createPorousFluidRegions.H"
#include "createPorousSolidMeshes.H"
#include "createFluidFields.H" #include "createFluidFields.H"
#include "createSolidFields.H" #include "createSolidFields.H"
#include "createPorousFluidFields.H"
#include "createPorousSolidFields.H"
#include "initContinuityErrs.H" #include "initContinuityErrs.H"
#include "readTimeControls.H" #include "readTimeControls.H"
@ -116,24 +111,6 @@ int main(int argc, char *argv[])
#include "solveFluid.H" #include "solveFluid.H"
} }
forAll(porousFluidRegions, i)
{
Info<< "\nSolving for fluid porous region "
<< porousFluidRegions[i].name() << endl;
#include "setPorousFluidFields.H"
#include "readPorousFluidRegionPIMPLEControls.H"
#include "solvePorousFluid.H"
}
forAll(porousSolidRegions, i)
{
Info<< "\nSolving for porous solid region "
<< porousSolidRegions[i].name() << endl;
#include "setPorousRegionSolidFields.H"
#include "readPorousSolidMultiRegionPIMPLEControls.H"
#include "solvePorousSolid.H"
}
forAll(solidRegions, i) forAll(solidRegions, i)
{ {
Info<< "\nSolving for solid region " Info<< "\nSolving for solid region "

View File

@ -1,8 +1,7 @@
EXE_INC = \ EXE_INC = \
-Ifluid \ -Ifluid \
-Isolid \ -Isolid \
-I./porousFluid \ -I../solid \
-I./porousSolid \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/finiteVolume/cfdTools \ -I$(LIB_SRC)/finiteVolume/cfdTools \

View File

@ -50,13 +50,9 @@ int main(int argc, char *argv[])
#include "createFluidMeshes.H" #include "createFluidMeshes.H"
#include "createSolidMeshes.H" #include "createSolidMeshes.H"
#include "createPorousFluidRegions.H"
#include "createPorousSolidMeshes.H"
#include "createFluidFields.H" #include "createFluidFields.H"
#include "createSolidFields.H" #include "createSolidFields.H"
#include "createPorousFluidFields.H"
#include "createPorousSolidFields.H"
#include "initContinuityErrs.H" #include "initContinuityErrs.H"
@ -74,24 +70,6 @@ int main(int argc, char *argv[])
#include "solveFluid.H" #include "solveFluid.H"
} }
forAll(porousFluidRegions, i)
{
Info<< "\nSolving for fluid porous region "
<< porousFluidRegions[i].name() << endl;
#include "setPorousFluidFields.H"
#include "readPorousFluidRegionSIMPLEControls.H"
#include "solvePorousFluid.H"
}
forAll(porousSolidRegions, i)
{
Info<< "\nSolving for porous solid region "
<< porousSolidRegions[i].name() << endl;
#include "setPorousRegionSolidFields.H"
#include "readPorousSolidMultiRegionSIMPLEControls.H"
#include "solvePorousSolid.H"
}
forAll(solidRegions, i) forAll(solidRegions, i)
{ {
Info<< "\nSolving for solid region " Info<< "\nSolving for solid region "

View File

@ -1,11 +0,0 @@
// Solve the Momentum equation
tmp<fvVectorMatrix> porousUEqn
(
fvm::div(porousPhi, porousU)
+ turbPorous.divDevRhoReff(porousU)
+ porousSources(porousRho, porousU)
);
porousUEqn().relax();
solve(porousUEqn() == -fvc::grad(porousP));

View File

@ -1,181 +0,0 @@
// Initialise porous field pointer lists
PtrList<rhoThermo> thermoPorous(porousFluidRegions.size());
PtrList<volScalarField> rhoPorous(porousFluidRegions.size());
PtrList<volScalarField> kappaPorous(porousFluidRegions.size());
PtrList<volVectorField> UPorous(porousFluidRegions.size());
PtrList<surfaceScalarField> phiPorous(porousFluidRegions.size());
PtrList<compressible::turbulenceModel> turbulencePorous
(
porousFluidRegions.size()
);
PtrList<volScalarField> pPorous(porousFluidRegions.size());
List<scalar> initialMassFluidPorous(porousFluidRegions.size());
List<label> pRefCellFluidPorous(porousFluidRegions.size(),0);
List<scalar> pRefValueFluidPorous(porousFluidRegions.size(),0.0);
PtrList<dimensionedScalar> rhoMaxPorous(fluidRegions.size());
PtrList<dimensionedScalar> rhoMinPorous(fluidRegions.size());
PtrList<IObasicSourceList> heatPorousSources
(
porousFluidRegions.size()
);
forAll(porousFluidRegions, i)
{
Info<< "Reading fluid mesh thermophysical properties for porous "
<< porousFluidRegions[i].name() << nl << endl;
Info<< " Adding to thermoFluid porous\n" << endl;
thermoPorous.set
(
i,
rhoThermo::New(porousFluidRegions[i]).ptr()
);
Info<< " Adding to rhoPorous\n" << endl;
rhoPorous.set
(
i,
new volScalarField
(
IOobject
(
"rho",
runTime.timeName(),
porousFluidRegions[i],
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
thermoPorous[i].rho()
)
);
Info<< " Adding to UPorous\n" << endl;
UPorous.set
(
i,
new volVectorField
(
IOobject
(
"U",
runTime.timeName(),
porousFluidRegions[i],
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
porousFluidRegions[i]
)
);
Info<< " Adding to phiPorous\n" << endl;
phiPorous.set
(
i,
new surfaceScalarField
(
IOobject
(
"phi",
runTime.timeName(),
porousFluidRegions[i],
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
linearInterpolate(rhoPorous[i]*UPorous[i])
& porousFluidRegions[i].Sf()
)
);
Info<< " Adding turbulence to porous\n" << endl;
turbulencePorous.set
(
i,
compressible::turbulenceModel::New
(
rhoPorous[i],
UPorous[i],
phiPorous[i],
thermoPorous[i]
).ptr()
);
Info<< " Adding to kappaFluid\n" << endl;
kappaPorous.set
(
i,
new volScalarField
(
IOobject
(
"kappaPorous",
runTime.timeName(),
porousFluidRegions[i],
IOobject::NO_READ,
IOobject::NO_WRITE
),
thermoPorous[i].Cp()*thermoPorous[i].alpha()
)
);
pPorous.set
(
i,
new volScalarField
(
IOobject
(
"p",
runTime.timeName(),
porousFluidRegions[i],
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
porousFluidRegions[i]
)
);
setRefCell
(
thermoPorous[i].p(),
pPorous[i],
porousFluidRegions[i].solutionDict().subDict("SIMPLE"),
pRefCellFluidPorous[i],
pRefValueFluidPorous[i]
);
rhoMaxPorous.set
(
i,
new dimensionedScalar
(
porousFluidRegions[i].solutionDict().subDict("SIMPLE").lookup
(
"rhoMax"
)
)
);
rhoMinPorous.set
(
i,
new dimensionedScalar
(
porousFluidRegions[i].solutionDict().subDict("SIMPLE").lookup
(
"rhoMin"
)
)
);
heatPorousSources.set
(
i,
new IObasicSourceList(porousFluidRegions[i])
);
}

View File

@ -1,25 +0,0 @@
const wordList porousFluidNames(rp["porousFluid"]);
PtrList<fvMesh> porousFluidRegions(porousFluidNames.size());
forAll (porousFluidNames, iPorous)
{
const word porousFluidName = porousFluidNames[iPorous];
Info<< "Create porous fluid region " << porousFluidName
<< nl << endl;
porousFluidRegions.set
(
iPorous,
new fvMesh
(
IOobject
(
porousFluidName,
runTime.timeName(),
runTime,
IOobject::MUST_READ
)
)
);
}

View File

@ -1,19 +0,0 @@
{
fvScalarMatrix hPorousEqn
(
fvm::div(porousPhi, porousH)
- fvm::laplacian(turbPorous.alphaEff(), porousH)
==
- fvc::div(porousPhi, 0.5*magSqr(porousU), "div(phi,K)")
+ porousSources(porousRho, porousH)
);
hPorousEqn.relax();
hPorousEqn.solve();
porousThermo.correct();
Info<< "Min/max in the porous T:"
<< min(porousThermo.T()).value() << ' '
<< max(porousThermo.T()).value() << endl;
}

View File

@ -1,53 +0,0 @@
porousRho = porousThermo.rho();
porousRho = max(porousRho, rhoMin);
porousRho = min(porousRho, rhoMax);
porousRho.relax();
volScalarField rAUPorous(1.0/porousUEqn().A());
porousU = rAUPorous*porousUEqn().H();
porousUEqn.clear();
bool closedVolume = false;
porousPhi =
fvc::interpolate(porousRho)
*(fvc::interpolate(porousU) & porousMesh.Sf());
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
fvScalarMatrix pEqn
(
fvm::laplacian(porousRho*rAUPorous, porousP) == fvc::div(porousPhi)
);
pEqn.setReference(pRefCell, pRefValue);
pEqn.solve();
if (nonOrth == nNonOrthCorr)
{
porousPhi -= pEqn.flux();
}
}
porousP.relax();
porousU -= rAUPorous*fvc::grad(porousP);
porousU.correctBoundaryConditions();
if (closedVolume)
{
porousP += (initialMass - fvc::domainIntegrate(porousPsi*porousP))
/fvc::domainIntegrate(porousPsi);
}
porousRho = porousThermo.rho();
porousRho = max(porousRho, rhoMin);
porousRho = min(porousRho, rhoMax);
porousRho.relax();
Info<< "rho max/min : "
<< max(porousRho).value() << " "
<< min(porousRho).value() << endl;

View File

@ -1,4 +0,0 @@
const dictionary& simple = porousMesh.solutionDict().subDict("SIMPLE");
const int nNonOrthCorr =
simple.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0);

View File

@ -1,28 +0,0 @@
const fvMesh& porousMesh = porousFluidRegions[i];
rhoThermo& porousThermo = thermoPorous[i];
volScalarField& porousRho = rhoPorous[i];
volVectorField& porousU = UPorous[i];
surfaceScalarField& porousPhi = phiPorous[i];
compressible::turbulenceModel& turbPorous = turbulencePorous[i];
volScalarField& porousP = porousThermo.p();
const volScalarField& porousPsi = porousThermo.psi();
volScalarField& porousH = porousThermo.he();
const dimensionedScalar initialMass
(
"initialMass",
dimMass,
initialMassFluidPorous[i]
);
IObasicSourceList& porousSources = heatPorousSources[i];
const label pRefCell = pRefCellFluidPorous[i];
const scalar pRefValue = pRefValueFluidPorous[i];
const scalar rhoMax = rhoMaxPorous[i].value();
const scalar rhoMin = rhoMinPorous[i].value();

View File

@ -1,11 +0,0 @@
// Pressure-velocity SIMPLE corrector
porousP.storePrevIter();
porousRho.storePrevIter();
{
#include "UPorousFluidEqn.H"
#include "hPorousFluidEqn.H"
#include "pPorousFluidEqn.H"
}
turbPorous.correct();

View File

@ -1,43 +0,0 @@
// Initialise solid field pointer lists
PtrList<solidThermo> porousSolidThermos(porousSolidRegions.size());
PtrList<IObasicSourceList> solidHeatSources(porousSolidRegions.size());
PtrList<volScalarField> betavSolid(porousSolidRegions.size());
// Populate solid field pointer lists
forAll(porousSolidRegions, i)
{
Info<< "*** Reading porous solid mesh thermophysical "
<< "properties for region "
<< porousSolidRegions[i].name() << nl << endl;
Info<< " Adding to thermos\n" << endl;
porousSolidThermos.set
(
i,
solidThermo::New(porousSolidRegions[i])
);
Info<< " Adding sources\n" << endl;
solidHeatSources.set
(
i,
new IObasicSourceList(porousSolidRegions[i])
);
Info<< " Adding to betavSolid\n" << endl;
betavSolid.set
(
i,
new volScalarField
(
IOobject
(
"betavSolid",
runTime.timeName(),
porousSolidRegions[i],
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
porousSolidRegions[i]
)
);
}

View File

@ -1,24 +0,0 @@
const wordList porousSolidNames(rp["porousSolid"]);
PtrList<fvMesh> porousSolidRegions(porousSolidNames.size());
forAll(porousSolidNames, i)
{
Info<< "Create solid mesh for region " << porousSolidNames[i]
<< " for time = " << runTime.timeName() << nl << endl;
porousSolidRegions.set
(
i,
new fvMesh
(
IOobject
(
porousSolidNames[i],
runTime.timeName(),
runTime,
IOobject::MUST_READ
)
)
);
}

View File

@ -1,4 +0,0 @@
const dictionary& simple = mesh.solutionDict().subDict("SIMPLE");
const int nNonOrthCorr =
simple.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0);

View File

@ -1,23 +0,0 @@
const fvMesh& mesh = porousSolidRegions[i];
solidThermo& thermo = porousSolidThermos[i];
const volScalarField& betav = betavSolid[i];
tmp<volScalarField> trho = thermo.rho();
const volScalarField& rho = trho();
tmp<volScalarField> tcp = thermo.Cp();
const volScalarField& cp = tcp();
tmp<volScalarField> tkappa = thermo.kappa();
//tmp<volSymmTensorField> tkappa = thermo.directionalKappa()*betav;
const volScalarField& kappa = tkappa();
//const volSymmTensorField& K = tK();
tmp<volScalarField> talpha = thermo.alpha();
const volScalarField& alpha = talpha();
volScalarField& h = thermo.he();
IObasicSourceList& sources = solidHeatSources[i];

View File

@ -1,18 +0,0 @@
scalar DiNum = -GREAT;
forAll(solidRegions, i)
{
# include "setRegionSolidFields.H"
DiNum = max
(
solidRegionDiffNo
(
solidRegions[i],
runTime,
rho*cp,
K
),
DiNum
);
}

View File

@ -1,17 +0,0 @@
{
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
tmp<fvScalarMatrix> hEqn
(
- fvm::laplacian(betav*alpha, h, "laplacian(alpha,h)")
+ sources(rho, h)
);
hEqn().relax();
hEqn().solve();
}
}
thermo.correct();
Info<< "Min/max T:" << min(thermo.T()) << ' ' << max(thermo.T()) << endl;

View File

@ -1,20 +0,0 @@
// Initialise solid field pointer lists
PtrList<solidThermo> thermos(solidRegions.size());
PtrList<radiation::radiationModel> radiations(solidRegions.size());
// Populate solid field pointer lists
forAll(solidRegions, i)
{
Info<< "*** Reading solid mesh thermophysical properties for region "
<< solidRegions[i].name() << nl << endl;
Info<< " Adding to thermos\n" << endl;
thermos.set
(
i,
solidThermo::New(solidRegions[i])
);
Info<< " Adding to radiations\n" << endl;
radiations.set(i, radiation::radiationModel::New(thermos[i].T()));
}

View File

@ -1,24 +0,0 @@
const wordList solidsNames(rp["solid"]);
PtrList<fvMesh> solidRegions(solidsNames.size());
forAll(solidsNames, i)
{
Info<< "Create solid mesh for region " << solidsNames[i]
<< " for time = " << runTime.timeName() << nl << endl;
solidRegions.set
(
i,
new fvMesh
(
IOobject
(
solidsNames[i],
runTime.timeName(),
runTime,
IOobject::MUST_READ
)
)
);
}

View File

@ -1,18 +0,0 @@
fvMesh& mesh = solidRegions[i];
solidThermo& thermo = thermos[i];
const radiation::radiationModel& radiation = radiations[i];
tmp<volScalarField> trho = thermo.rho();
const volScalarField& rho = trho();
tmp<volScalarField> tcp = thermo.Cp();
const volScalarField& cp = tcp();
tmp<volScalarField> tkappa = thermo.kappa();
//tmp<volSymmTensorField> tkappa = thermo.directionalkappa();
const volScalarField& kappa = tkappa();
tmp<volScalarField> talpha = thermo.alpha();
const volScalarField& alpha = talpha();
volScalarField& h = thermo.he();

View File

@ -3,7 +3,8 @@
{ {
fvScalarMatrix hEqn fvScalarMatrix hEqn
( (
-fvm::laplacian(alpha, h) - fvm::laplacian(betav*alpha, h, "laplacian(alpha,h)")
+ sources(rho, h)
); );
hEqn.relax(); hEqn.relax();
hEqn.solve(); hEqn.solve();

View File

@ -14,7 +14,7 @@
CoNum CoNum
); );
} }
/*
forAll (porousFluidRegions, porousI) forAll (porousFluidRegions, porousI)
{ {
CoNum = max CoNum = max
@ -29,3 +29,4 @@
CoNum CoNum
); );
} }
*/

View File

@ -1,24 +0,0 @@
// Solve the Momentum equation
tmp<fvVectorMatrix> porousUEqn
(
fvm::ddt(porousRho, porousU)
+ fvm::div(porousPhi, porousU)
+ turbPorous.divDevRhoReff(porousU)
+ porousSources(porousRho, porousU)
);
porousUEqn().relax();
volScalarField rAUPorous(1.0/porousUEqn().A());
if (momentumPredictor)
{
solve(porousUEqn() == -fvc::grad(porousP));
}
else
{
porousU = rAUPorous*(porousUEqn().H() - fvc::grad(porousP));
porousU.correctBoundaryConditions();
}

View File

@ -1,147 +0,0 @@
// Initialise porous field pointer lists
PtrList<rhoThermo> thermoPorous(porousFluidRegions.size());
PtrList<volScalarField> rhoPorous(porousFluidRegions.size());
PtrList<volVectorField> UPorous(porousFluidRegions.size());
PtrList<surfaceScalarField> phiPorous(porousFluidRegions.size());
PtrList<volScalarField> KPorous(porousFluidRegions.size());
PtrList<volScalarField> dpdtPorous(fluidRegions.size());
PtrList<compressible::turbulenceModel> turbulencePorous
(
porousFluidRegions.size()
);
PtrList<volScalarField> pPorous(porousFluidRegions.size());
PtrList<IObasicSourceList> heatPorousSources
(
porousFluidRegions.size()
);
forAll(porousFluidRegions, i)
{
Info<< "Reading fluid mesh thermophysical properties for porous "
<< porousFluidRegions[i].name() << nl << endl;
Info<< " Adding to thermoFluid porous\n" << endl;
thermoPorous.set
(
i,
rhoThermo::New(porousFluidRegions[i]).ptr()
);
Info<< " Adding to rhoPorous\n" << endl;
rhoPorous.set
(
i,
new volScalarField
(
IOobject
(
"rho",
runTime.timeName(),
porousFluidRegions[i],
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
thermoPorous[i].rho()
)
);
Info<< " Adding to UPorous\n" << endl;
UPorous.set
(
i,
new volVectorField
(
IOobject
(
"U",
runTime.timeName(),
porousFluidRegions[i],
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
porousFluidRegions[i]
)
);
Info<< " Adding to phiPorous\n" << endl;
phiPorous.set
(
i,
new surfaceScalarField
(
IOobject
(
"phi",
runTime.timeName(),
porousFluidRegions[i],
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
linearInterpolate(rhoPorous[i]*UPorous[i])
& porousFluidRegions[i].Sf()
)
);
Info<< " Adding turbulence to porous\n" << endl;
turbulencePorous.set
(
i,
compressible::turbulenceModel::New
(
rhoPorous[i],
UPorous[i],
phiPorous[i],
thermoPorous[i]
).ptr()
);
Info<< " Adding to KPorous\n" << endl;
KPorous.set
(
i,
new volScalarField
(
"KPorous",
0.5*magSqr(UPorous[i])
)
);
Info<< " Adding to dpdtPorous\n" << endl;
dpdtPorous.set
(
i,
new volScalarField
(
"dpdtPorous",
fvc::ddt(thermoPorous[i].p())
)
);
pPorous.set
(
i,
new volScalarField
(
IOobject
(
"p",
runTime.timeName(),
porousFluidRegions[i],
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
porousFluidRegions[i]
)
);
heatPorousSources.set
(
i,
new IObasicSourceList(porousFluidRegions[i])
);
}

View File

@ -1,25 +0,0 @@
const wordList porousFluidNames(rp["porousFluid"]);
PtrList<fvMesh> porousFluidRegions(porousFluidNames.size());
forAll (porousFluidNames, iPorous)
{
const word porousFluidName = porousFluidNames[iPorous];
Info<< "Create porous fluid region " << porousFluidName
<< nl << endl;
porousFluidRegions.set
(
iPorous,
new fvMesh
(
IOobject
(
porousFluidName,
runTime.timeName(),
runTime,
IOobject::MUST_READ
)
)
);
}

View File

@ -1,21 +0,0 @@
{
fvScalarMatrix hPorousEqn
(
fvm::ddt(porousRho, porousH)
+ fvm::div(porousPhi, porousH)
- fvm::laplacian(turbPorous.alphaEff(), porousH)
==
porousdpdt
- (fvc::ddt(porousRho, porousK) + fvc::div(porousPhi, porousK))
+ porousSources(porousRho, porousH)
);
hPorousEqn.relax();
hPorousEqn.solve();
porousThermo.correct();
Info<< "Min/max in the porous T:"
<< min(porousThermo.T()).value() << ' '
<< max(porousThermo.T()).value() << endl;
}

View File

@ -1,63 +0,0 @@
porousRho = porousThermo.rho();
porousU = rAUPorous*porousUEqn().H();
if (nCorr <= 1)
{
porousUEqn.clear();
}
porousPhi =
fvc::interpolate(porousRho)*
(
(fvc::interpolate(porousU) & porousMesh.Sf())
+ fvc::ddtPhiCorr(rAUPorous, porousRho, porousU, porousPhi)
);
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
// Pressure corrector
fvScalarMatrix pEqn
(
fvm::ddt(porousPsi, porousP)
+ fvc::div(porousPhi)
- fvm::laplacian(porousRho*rAUPorous, porousP)
);
pEqn.solve
(
porousMesh.solver
(
porousP.select
(
oCorr == nOuterCorr-1
&& corr == nCorr-1
&& nonOrth == nNonOrthCorr
)
)
);
if (nonOrth == nNonOrthCorr)
{
porousPhi += pEqn.flux();
}
}
solve(fvm::ddt(porousRho) + fvc::div(porousPhi));
// Explicitly relax pressure for momentum corrector
porousP.relax();
// Recalculate density from the relaxed pressure
porousRho = porousThermo.rho();
porousU -= rAUPorous*fvc::grad(porousP);
porousU.correctBoundaryConditions();
porousK = 0.5*magSqr(porousU);
// Update pressure time derivative if needed
if (porousThermo.dpdt())
{
porousdpdt = fvc::ddt(porousP);
}

View File

@ -1,11 +0,0 @@
const dictionary& pimple = porousMesh.solutionDict().subDict("PIMPLE");
const int nCorr =
pimple.lookupOrDefault<int>("nCorrectors", 1);
const int nNonOrthCorr =
pimple.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0);
const bool momentumPredictor =
pimple.lookupOrDefault("momentumPredictor", true);

View File

@ -1,17 +0,0 @@
fvMesh& porousMesh = porousFluidRegions[i];
rhoThermo& porousThermo = thermoPorous[i];
volScalarField& porousRho = rhoPorous[i];
volVectorField& porousU = UPorous[i];
surfaceScalarField& porousPhi = phiPorous[i];
compressible::turbulenceModel& turbPorous = turbulencePorous[i];
volScalarField& porousK = KPorous[i];
volScalarField& porousdpdt = dpdtPorous[i];
volScalarField& porousP = porousThermo.p();
const volScalarField& porousPsi = porousThermo.psi();
volScalarField& porousH = porousThermo.he();
IObasicSourceList& porousSources = heatPorousSources[i];

View File

@ -1,28 +0,0 @@
if (finalIter)
{
porousMesh.data::add("finalIteration", true);
}
if (oCorr == 0)
{
solve(fvm::ddt(porousRho) + fvc::div(porousPhi));
}
#include "UPorousFluidEqn.H"
#include "hPorousFluidEqn.H"
// --- PISO loop
for (int corr=0; corr<nCorr; corr++)
{
#include "pPorousFluidEqn.H"
}
turbPorous.correct();
porousRho = porousThermo.rho();
if (finalIter)
{
porousMesh.data::remove("finalIteration");
}

View File

@ -1,43 +0,0 @@
// Initialise solid field pointer lists
PtrList<solidThermo> porousSolidThermos(porousSolidRegions.size());
PtrList<IObasicSourceList> solidHeatSources(porousSolidRegions.size());
PtrList<volScalarField> betavSolid(porousSolidRegions.size());
// Populate solid field pointer lists
forAll(porousSolidRegions, i)
{
Info<< "*** Reading porous solid mesh thermophysical "
<< "properties for region "
<< porousSolidRegions[i].name() << nl << endl;
Info<< " Adding to thermos\n" << endl;
porousSolidThermos.set
(
i,
solidThermo::New(porousSolidRegions[i])
);
Info<< " Adding sources\n" << endl;
solidHeatSources.set
(
i,
new IObasicSourceList(porousSolidRegions[i])
);
Info<< " Adding to betavSolid\n" << endl;
betavSolid.set
(
i,
new volScalarField
(
IOobject
(
"betavSolid",
runTime.timeName(),
porousSolidRegions[i],
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
porousSolidRegions[i]
)
);
}

View File

@ -1,24 +0,0 @@
const wordList porousSolidNames(rp["porousSolid"]);
PtrList<fvMesh> porousSolidRegions(porousSolidNames.size());
forAll(porousSolidNames, i)
{
Info<< "Create solid mesh for region " << porousSolidNames[i]
<< " for time = " << runTime.timeName() << nl << endl;
porousSolidRegions.set
(
i,
new fvMesh
(
IOobject
(
porousSolidNames[i],
runTime.timeName(),
runTime,
IOobject::MUST_READ
)
)
);
}

View File

@ -1,4 +0,0 @@
const dictionary& pimple = mesh.solutionDict().subDict("PIMPLE");
int nNonOrthCorr =
pimple.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0);

View File

@ -1,26 +0,0 @@
fvMesh& mesh = porousSolidRegions[i];
solidThermo& thermo = porousSolidThermos[i];
const volScalarField& betav = betavSolid[i];
tmp<volScalarField> trho = thermo.rho();
const volScalarField& rho = trho();
tmp<volScalarField> tcp = thermo.Cp();
const volScalarField& cp = tcp();
tmp<volScalarField> tkappa = thermo.kappa();
//tmp<volSymmTensorField> tkappa = thermo.directionalKappa()*betav;
const volScalarField& kappa = tkappa();
//const volSymmTensorField& K = tK();
//tmp<volScalarField> trhoCp = cp*rho;
//const volScalarField& rhoCp = trhoCp();
tmp<volScalarField> talpha = thermo.alpha();
const volScalarField& alpha = talpha();
volScalarField& h = thermo.he();
IObasicSourceList& sources = solidHeatSources[i];

View File

@ -1,18 +0,0 @@
scalar DiNum = -GREAT;
forAll(solidRegions, i)
{
# include "setRegionSolidFields.H"
DiNum = max
(
solidRegionDiffNo
(
solidRegions[i],
runTime,
rho*cp,
K
),
DiNum
);
}

View File

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

View File

@ -1,6 +1,8 @@
// Initialise solid field pointer lists // Initialise solid field pointer lists
PtrList<solidThermo> thermos(solidRegions.size()); PtrList<solidThermo> thermos(solidRegions.size());
PtrList<radiation::radiationModel> radiations(solidRegions.size()); PtrList<radiation::radiationModel> radiations(solidRegions.size());
PtrList<IObasicSourceList> solidHeatSources(solidRegions.size());
PtrList<volScalarField> betavSolid(solidRegions.size());
// Populate solid field pointer lists // Populate solid field pointer lists
forAll(solidRegions, i) forAll(solidRegions, i)
@ -13,4 +15,49 @@
Info<< " Adding to radiations\n" << endl; Info<< " Adding to radiations\n" << endl;
radiations.set(i, radiation::radiationModel::New(thermos[i].T())); radiations.set(i, radiation::radiationModel::New(thermos[i].T()));
Info<< " Adding sources\n" << endl;
solidHeatSources.set
(
i,
new IObasicSourceList(solidRegions[i])
);
IOobject betavSolidIO
(
"betavSolid",
runTime.timeName(),
solidRegions[i],
IOobject::MUST_READ,
IOobject::AUTO_WRITE
);
if (betavSolidIO.headerOk())
{
betavSolid.set
(
i,
new volScalarField(betavSolidIO, solidRegions[i])
);
}
else
{
betavSolid.set
(
i,
new volScalarField
(
IOobject
(
"betavSolid",
runTime.timeName(),
solidRegions[i],
IOobject::NO_READ,
IOobject::NO_WRITE
),
solidRegions[i],
dimensionedScalar("1", dimless, scalar(1.0))
)
);
}
} }

View File

@ -14,3 +14,7 @@
const volScalarField& kappa = tkappa(); const volScalarField& kappa = tkappa();
volScalarField& h = thermo.he(); volScalarField& h = thermo.he();
const volScalarField& betav = betavSolid[i];
IObasicSourceList& sources = solidHeatSources[i];

View File

@ -8,8 +8,9 @@ if (finalIter)
{ {
tmp<fvScalarMatrix> hEqn tmp<fvScalarMatrix> hEqn
( (
fvm::ddt(rho, h) fvm::ddt(betav*rho, h)
- fvm::laplacian(alpha, h) - fvm::laplacian(betav*alpha, h, "laplacian(alpha,h)")
+ sources(rho, h)
); );
hEqn().relax(); hEqn().relax();
hEqn().solve(mesh.solver(h.select(finalIter))); hEqn().solve(mesh.solver(h.select(finalIter)));

View File

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

View File

@ -0,0 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude
EXE_LIBS = \
-lspecie

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -21,48 +21,59 @@ License
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
ThermoMixture
Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "pureSolidMixture.H" #include "dictionary.H"
#include "fvMesh.H" #include "IFstream.H"
#include "specie.H"
#include "perfectGas.H"
#include "hConstThermo.H"
#include "sensibleEnthalpy.H"
#include "thermo.H"
#include "constTransport.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
namespace Foam int main(int argc, char *argv[])
{ {
typedef constTransport
<
species::thermo
<
hConstThermo<perfectGas<specie> >,
sensibleEnthalpy
>
> ThermoType;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // dictionary dict(IFstream("thermoDict")());
template<class ThermoType> ThermoType t1(dict.subDict("specie1"));
pureSolidMixture<ThermoType>::pureSolidMixture ThermoType t2(dict.subDict("specie2"));
(
const dictionary& thermoDict,
const fvMesh& mesh
)
:
basicMixture(thermoDict, mesh),
mixture_(thermoDict.subDict("mixture"))
{}
Info<< "Checking Cp of mixture of hConstThermo" << endl;
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Info<< "W 1, 2, (1 + 2) = " << t1.W() << " " << t2.W() << " "
<< (t1 + t2).W() << endl;
template<class ThermoType> Info<< "Cp 1, 2, 1 + 2 = " << t1.cp(1, 1) << " " << t2.cp(1, 1) << " "
pureSolidMixture<ThermoType>::~pureSolidMixture() << (t1 + t2).cp(1, 1) << endl;
{}
ThermoType t3(t1);
t3 += t2;
Info<< "Cp (1 += 2) = " << t3.cp(1, 1) << endl;
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Info<< "\nEnd\n" << endl;
template<class ThermoType> return 0;
void pureSolidMixture<ThermoType>::read(const dictionary& thermoDict)
{
mixture_ = ThermoType(thermoDict.subDict("mixture"));
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -0,0 +1,43 @@
specie1
{
specie
{
nMoles 1;
molWeight 1;
}
thermodynamics
{
Cp 1;
Cv 1;
Hf 0;
}
transport
{
mu 1;
Pr 1;
}
}
specie2
{
specie
{
nMoles 1;
molWeight 0.5;
}
thermodynamics
{
Cp 2;
Cv 2;
Hf 0;
}
transport
{
mu 1;
Pr 1;
}
}

View File

@ -96,20 +96,29 @@ castellatedMeshControls
// refinement. // refinement.
nCellsBetweenLevels 1; nCellsBetweenLevels 1;
// Explicit feature edge refinement // Explicit feature edge refinement
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Specifies a level for any cell intersected by explicitly provided // Specifies a level for any cell intersected by explicitly provided
// edges. // edges.
// This is a featureEdgeMesh, read from constant/triSurface for now. // This is a featureEdgeMesh, read from constant/triSurface for now.
// Specify 'levels' in the same way as the 'distance' mode in the
// refinementRegions (see below). The old specification
// level 2;
// is equivalent to
// levels ((0 2));
features features
( (
//{ //{
// file "someLine.eMesh"; // file "someLine.eMesh";
// level 2; // //level 2;
// levels ((0.0 2) (1.0 3));
//} //}
); );
// Surface based refinement // Surface based refinement
// ~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~
@ -178,7 +187,7 @@ castellatedMeshControls
// three modes // three modes
// - distance. 'levels' specifies per distance to the surface the // - distance. 'levels' specifies per distance to the surface the
// wanted refinement level. The distances need to be specified in // wanted refinement level. The distances need to be specified in
// descending order. // increasing order.
// - inside. 'levels' is only one entry and only the level is used. All // - inside. 'levels' is only one entry and only the level is used. All
// cells inside the surface get refined up to the level. The surface // cells inside the surface get refined up to the level. The surface
// needs to be closed for this to be possible. // needs to be closed for this to be possible.
@ -217,36 +226,36 @@ castellatedMeshControls
// Settings for the snapping. // Settings for the snapping.
snapControls snapControls
{ {
//- Number of patch smoothing iterations before finding correspondence // Number of patch smoothing iterations before finding correspondence
// to surface // to surface
nSmoothPatch 3; nSmoothPatch 3;
//- Maximum relative distance for points to be attracted by surface. // Maximum relative distance for points to be attracted by surface.
// True distance is this factor times local maximum edge length. // True distance is this factor times local maximum edge length.
// Note: changed(corrected) w.r.t 17x! (17x used 2* tolerance) // Note: changed(corrected) w.r.t 17x! (17x used 2* tolerance)
tolerance 2.0; tolerance 2.0;
//- Number of mesh displacement relaxation iterations. // Number of mesh displacement relaxation iterations.
nSolveIter 30; nSolveIter 30;
//- Maximum number of snapping relaxation iterations. Should stop // Maximum number of snapping relaxation iterations. Should stop
// before upon reaching a correct mesh. // before upon reaching a correct mesh.
nRelaxIter 5; nRelaxIter 5;
// Feature snapping // Feature snapping
//- Number of feature edge snapping iterations. // Number of feature edge snapping iterations.
// Leave out altogether to disable. // Leave out altogether to disable.
nFeatureSnapIter 10; nFeatureSnapIter 10;
//- Detect (geometric only) features by sampling the surface // Detect (geometric only) features by sampling the surface
// (default=false). // (default=false).
implicitFeatureSnap false; implicitFeatureSnap false;
//- Use castellatedMeshControls::features (default = true) // Use castellatedMeshControls::features (default = true)
explicitFeatureSnap true; explicitFeatureSnap true;
//- Detect features between multiple surfaces // Detect features between multiple surfaces
// (only for explicitFeatureSnap, default = false) // (only for explicitFeatureSnap, default = false)
multiRegionFeatureSnap false; multiRegionFeatureSnap false;
} }
@ -258,9 +267,43 @@ addLayersControls
// size of the refined cell outside layer (true) or absolute sizes (false). // size of the refined cell outside layer (true) or absolute sizes (false).
relativeSizes true; relativeSizes true;
// Layer thickness specification. This can be specified in one of four ways
// - expansionRatio and finalLayerThickness (cell nearest internal mesh)
// - expansionRatio and firstLayerThickness (cell on surface)
// - overall thickness and firstLayerThickness
// - overall thickness and finalLayerThickness
// Expansion factor for layer mesh
expansionRatio 1.0;
// Wanted thickness of the layer furthest away from the wall.
// If relativeSizes this is relative to undistorted size of cell
// outside layer.
finalLayerThickness 0.3;
// Wanted thickness of the layer next to the wall.
// If relativeSizes this is relative to undistorted size of cell
// outside layer.
//firstLayerThickness 0.3;
// Wanted overall thickness of layers.
// If relativeSizes this is relative to undistorted size of cell
// outside layer.
//thickness 0.5
// Minimum overall thickness of total layers. If for any reason layer
// cannot be above minThickness do not add layer.
// If relativeSizes this is relative to undistorted size of cell
// outside layer..
minThickness 0.25;
// Per final patch (so not geometry!) the layer information // Per final patch (so not geometry!) the layer information
// Note: This behaviour changed after 21x. Any non-mentioned patches // Note: This behaviour changed after 21x. Any non-mentioned patches
// now slide unless nSurfaceLayers is explicitly mentioned to be 0. // now slide unless:
// - nSurfaceLayers is explicitly mentioned to be 0.
// - angle to nearest surface < slipFeatureAngle (see below)
layers layers
{ {
sphere.stl_firstSolid sphere.stl_firstSolid
@ -285,24 +328,7 @@ addLayersControls
} }
} }
// Expansion factor for layer mesh // If points get not extruded do nGrow layers of connected faces that are
expansionRatio 1.0;
//- Wanted thickness of final added cell layer. If multiple layers
// is the
// thickness of the layer furthest away from the wall.
// Relative to undistorted size of cell outside layer.
// is the thickness of the layer furthest away from the wall.
// See relativeSizes parameter.
finalLayerThickness 0.3;
//- Minimum thickness of cell layer. If for any reason layer
// cannot be above minThickness do not add layer.
// Relative to undistorted size of cell outside layer.
// See relativeSizes parameter.
minThickness 0.25;
//- If points get not extruded do nGrow layers of connected faces that are
// also not grown. This helps convergence of the layer addition process // also not grown. This helps convergence of the layer addition process
// close to features. // close to features.
// Note: changed(corrected) w.r.t 17x! (didn't do anything in 17x) // Note: changed(corrected) w.r.t 17x! (didn't do anything in 17x)
@ -310,15 +336,15 @@ addLayersControls
// Advanced settings // Advanced settings
//- When not to extrude surface. 0 is flat surface, 90 is when two faces // When not to extrude surface. 0 is flat surface, 90 is when two faces
// make straight angle. // make straight angle.
featureAngle 60; featureAngle 60;
//- At non-patched sides allow mesh to slip if extrusion direction makes // At non-patched sides allow mesh to slip if extrusion direction makes
// angle larger than slipFeatureAngle. // angle larger than slipFeatureAngle.
slipFeatureAngle 30; slipFeatureAngle 30;
//- Maximum number of snapping relaxation iterations. Should stop // Maximum number of snapping relaxation iterations. Should stop
// before upon reaching a correct mesh. // before upon reaching a correct mesh.
nRelaxIter 5; nRelaxIter 5;
@ -365,24 +391,24 @@ addLayersControls
// where to undo. // where to undo.
meshQualityControls meshQualityControls
{ {
//- Maximum non-orthogonality allowed. Set to 180 to disable. // Maximum non-orthogonality allowed. Set to 180 to disable.
maxNonOrtho 65; maxNonOrtho 65;
//- Max skewness allowed. Set to <0 to disable. // Max skewness allowed. Set to <0 to disable.
maxBoundarySkewness 20; maxBoundarySkewness 20;
maxInternalSkewness 4; maxInternalSkewness 4;
//- Max concaveness allowed. Is angle (in degrees) below which concavity // Max concaveness allowed. Is angle (in degrees) below which concavity
// is allowed. 0 is straight face, <0 would be convex face. // is allowed. 0 is straight face, <0 would be convex face.
// Set to 180 to disable. // Set to 180 to disable.
maxConcave 80; maxConcave 80;
//- Minimum pyramid volume. Is absolute volume of cell pyramid. // Minimum pyramid volume. Is absolute volume of cell pyramid.
// Set to a sensible fraction of the smallest cell volume expected. // Set to a sensible fraction of the smallest cell volume expected.
// Set to very negative number (e.g. -1E30) to disable. // Set to very negative number (e.g. -1E30) to disable.
minVol 1e-13; minVol 1e-13;
//- Minimum quality of the tet formed by the face-centre // Minimum quality of the tet formed by the face-centre
// and variable base point minimum decomposition triangles and // and variable base point minimum decomposition triangles and
// the cell centre. This has to be a positive number for tracking // the cell centre. This has to be a positive number for tracking
// to work. Set to very negative number (e.g. -1E30) to // to work. Set to very negative number (e.g. -1E30) to
@ -392,24 +418,24 @@ meshQualityControls
// 1 = regular tet // 1 = regular tet
minTetQuality 1e-9; minTetQuality 1e-9;
//- Minimum face area. Set to <0 to disable. // Minimum face area. Set to <0 to disable.
minArea -1; minArea -1;
//- Minimum face twist. Set to <-1 to disable. dot product of face normal // Minimum face twist. Set to <-1 to disable. dot product of face normal
//- and face centre triangles normal // and face centre triangles normal
minTwist 0.05; minTwist 0.05;
//- minimum normalised cell determinant // minimum normalised cell determinant
//- 1 = hex, <= 0 = folded or flattened illegal cell // 1 = hex, <= 0 = folded or flattened illegal cell
minDeterminant 0.001; minDeterminant 0.001;
//- minFaceWeight (0 -> 0.5) // minFaceWeight (0 -> 0.5)
minFaceWeight 0.05; minFaceWeight 0.05;
//- minVolRatio (0 -> 1) // minVolRatio (0 -> 1)
minVolRatio 0.01; minVolRatio 0.01;
//must be >0 for Fluent compatibility // must be >0 for Fluent compatibility
minTriangleTwist -1; minTriangleTwist -1;
//- if >0 : preserve single cells with all points on the surface if the //- if >0 : preserve single cells with all points on the surface if the
@ -420,9 +446,9 @@ meshQualityControls
// Advanced // Advanced
//- Number of error distribution iterations // Number of error distribution iterations
nSmoothScale 4; nSmoothScale 4;
//- amount to scale back displacement at error points // amount to scale back displacement at error points
errorReduction 0.75; errorReduction 0.75;
// Optional : some meshing phases allow usage of relaxed rules. // Optional : some meshing phases allow usage of relaxed rules.

View File

@ -90,6 +90,8 @@ fields
// uniform: extra number of sampling points // uniform: extra number of sampling points
// polyLine, cloud: list of coordinates // polyLine, cloud: list of coordinates
// patchCloud: list of coordinates and set of patches to look for nearest // patchCloud: list of coordinates and set of patches to look for nearest
// patchSeed: random sampling on set of patches. Points slightly off
// face centre.
sets sets
( (
lineX1 lineX1
@ -135,6 +137,15 @@ sets
maxDistance 0.1; // maximum distance to search maxDistance 0.1; // maximum distance to search
patches (".*Wall.*"); patches (".*Wall.*");
} }
patchSeed
{
patches (".*Wall.*");
// Number of points to seed. Divided amongst all processors according
// to fraction of patches they hold.
maxPoints 100;
}
); );

View File

@ -318,7 +318,6 @@ void Foam::autoLayerDriver::handleNonManifolds
} }
} }
Info<< "Set displacement to zero for all " << nNonManif Info<< "Set displacement to zero for all " << nNonManif
<< " non-manifold points" << endl; << " non-manifold points" << endl;
} }
@ -443,86 +442,6 @@ void Foam::autoLayerDriver::handleFeatureAngle
} }
//Foam::tmp<Foam::scalarField> Foam::autoLayerDriver::undistortedEdgeLength
//(
// const indirectPrimitivePatch& pp,
// const bool relativeSizes,
// const bool faceSize
//)
//{
// const fvMesh& mesh = meshRefiner_.mesh();
//
// tmp<scalarField> tfld(new scalarField());
// scalarField& fld = tfld();
//
// if (faceSize)
// {
// fld.setSize(pp.size());
// }
// else
// {
// fld.setSize(pp.nPoints());
// }
//
//
// if (relativeSizes)
// {
// const scalar edge0Len = meshRefiner_.meshCutter().level0EdgeLength();
// const labelList& cellLevel = meshRefiner_.meshCutter().cellLevel();
//
// if (faceSize)
// {
// forAll(pp, i)
// {
// label faceI = pp.addressing()[i];
// label ownLevel = cellLevel[mesh.faceOwner()[faceI]];
// fld[i] = edge0Len/(1<<ownLevel);
// }
// }
// else
// {
// // Determine per point the max cell level of connected cells
// // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// labelList maxPointLevel(pp.nPoints(), labelMin);
//
// forAll(pp, i)
// {
// label faceI = pp.addressing()[i];
// label ownLevel = cellLevel[mesh.faceOwner()[faceI]];
//
// const face& f = pp.localFaces()[i];
// forAll(f, fp)
// {
// maxPointLevel[f[fp]] =
// max(maxPointLevel[f[fp]], ownLevel);
// }
// }
//
// syncTools::syncPointList
// (
// mesh,
// pp.meshPoints(),
// maxPointLevel,
// maxEqOp<label>(),
// labelMin // null value
// );
//
//
// forAll(maxPointLevel, pointI)
// {
// // Find undistorted edge size for this level.
// fld[i] = edge0Len/(1<<maxPointLevel[pointI]);
// }
// }
// }
// else
// {
// // Use actual cell size
// }
//}
// No extrusion on cells with warped faces. Calculates the thickness of the // No extrusion on cells with warped faces. Calculates the thickness of the
// layer and compares it to the space the warped face takes up. Disables // layer and compares it to the space the warped face takes up. Disables
// extrusion if layer thickness is more than faceRatio of the thickness of // extrusion if layer thickness is more than faceRatio of the thickness of
@ -702,7 +621,6 @@ void Foam::autoLayerDriver::handleWarpedFaces
//} //}
// No extrusion on faces with differing number of layers for points
void Foam::autoLayerDriver::setNumLayers void Foam::autoLayerDriver::setNumLayers
( (
const labelList& patchToNLayers, const labelList& patchToNLayers,
@ -865,15 +783,6 @@ Foam::autoLayerDriver::makeLayerDisplacementField
} }
//Pout<< "*** makeLayerDisplacementField : boundary conditions:" << endl;
//forAll(patchFieldTypes, patchI)
//{
// Pout<< "\t" << patchI << " name:" << pointPatches[patchI].name()
// << " type:" << patchFieldTypes[patchI]
// << " nLayers:" << numLayers[patchI]
// << endl;
//}
const polyMesh& mesh = pMesh(); const polyMesh& mesh = pMesh();
// Note: time().timeName() instead of meshRefinement::timeName() since // Note: time().timeName() instead of meshRefinement::timeName() since
@ -1053,11 +962,10 @@ void Foam::autoLayerDriver::determineSidePatches
patchDict.add("nFaces", 0); patchDict.add("nFaces", 0);
patchDict.add("startFace", mesh.nFaces()); patchDict.add("startFace", mesh.nFaces());
Pout<< "Adding patch " << patchI //Pout<< "Adding patch " << patchI
<< " name:" << name // << " name:" << name
<< " between " << Pstream::myProcNo() // << " between " << Pstream::myProcNo()
<< " and " << nbrProcI // << " and " << nbrProcI << endl;
<< endl;
label procPatchI = meshRefiner_.appendPatch label procPatchI = meshRefiner_.appendPatch
( (
@ -1090,12 +998,7 @@ void Foam::autoLayerDriver::calculateLayerThickness
( (
const indirectPrimitivePatch& pp, const indirectPrimitivePatch& pp,
const labelList& patchIDs, const labelList& patchIDs,
const scalarField& patchExpansionRatio, const layerParameters& layerParams,
const bool relativeSizes,
const scalarField& patchFinalLayerThickness,
const scalarField& patchMinThickness,
const labelList& cellLevel, const labelList& cellLevel,
const labelList& patchNLayers, const labelList& patchNLayers,
const scalar edge0Len, const scalar edge0Len,
@ -1111,12 +1014,13 @@ void Foam::autoLayerDriver::calculateLayerThickness
// Rework patch-wise layer parameters into minimum per point // Rework patch-wise layer parameters into minimum per point
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Note: only layer parameters consistent with layer specification
// method (see layerParameters) will be correct.
scalarField firstLayerThickness(pp.nPoints(), GREAT);
scalarField finalLayerThickness(pp.nPoints(), GREAT);
scalarField totalThickness(pp.nPoints(), GREAT);
scalarField expRatio(pp.nPoints(), GREAT);
// Reuse input fields
expansionRatio.setSize(pp.nPoints());
expansionRatio = GREAT;
thickness.setSize(pp.nPoints());
thickness = GREAT;
minThickness.setSize(pp.nPoints()); minThickness.setSize(pp.nPoints());
minThickness = GREAT; minThickness = GREAT;
@ -1130,20 +1034,30 @@ void Foam::autoLayerDriver::calculateLayerThickness
{ {
label ppPointI = pp.meshPointMap()[meshPoints[patchPointI]]; label ppPointI = pp.meshPointMap()[meshPoints[patchPointI]];
expansionRatio[ppPointI] = min firstLayerThickness[ppPointI] = min
( (
expansionRatio[ppPointI], firstLayerThickness[ppPointI],
patchExpansionRatio[patchI] layerParams.firstLayerThickness()[patchI]
); );
thickness[ppPointI] = min finalLayerThickness[ppPointI] = min
( (
thickness[ppPointI], finalLayerThickness[ppPointI],
patchFinalLayerThickness[patchI] layerParams.finalLayerThickness()[patchI]
);
totalThickness[ppPointI] = min
(
totalThickness[ppPointI],
layerParams.thickness()[patchI]
);
expRatio[ppPointI] = min
(
expRatio[ppPointI],
layerParams.expansionRatio()[patchI]
); );
minThickness[ppPointI] = min minThickness[ppPointI] = min
( (
minThickness[ppPointI], minThickness[ppPointI],
patchMinThickness[patchI] layerParams.minThickness()[patchI]
); );
} }
} }
@ -1152,7 +1066,7 @@ void Foam::autoLayerDriver::calculateLayerThickness
( (
mesh, mesh,
pp.meshPoints(), pp.meshPoints(),
expansionRatio, firstLayerThickness,
minEqOp<scalar>(), minEqOp<scalar>(),
GREAT // null value GREAT // null value
); );
@ -1160,7 +1074,23 @@ void Foam::autoLayerDriver::calculateLayerThickness
( (
mesh, mesh,
pp.meshPoints(), pp.meshPoints(),
thickness, finalLayerThickness,
minEqOp<scalar>(),
GREAT // null value
);
syncTools::syncPointList
(
mesh,
pp.meshPoints(),
totalThickness,
minEqOp<scalar>(),
GREAT // null value
);
syncTools::syncPointList
(
mesh,
pp.meshPoints(),
expRatio,
minEqOp<scalar>(), minEqOp<scalar>(),
GREAT // null value GREAT // null value
); );
@ -1182,14 +1112,18 @@ void Foam::autoLayerDriver::calculateLayerThickness
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// by multiplying with the internal cell size. // by multiplying with the internal cell size.
if (relativeSizes) if (layerParams.relativeSizes())
{ {
if (min(patchMinThickness) < 0 || max(patchMinThickness) > 2) if
(
min(layerParams.minThickness()) < 0
|| max(layerParams.minThickness()) > 2
)
{ {
FatalErrorIn("calculateLayerThickness(..)") FatalErrorIn("calculateLayerThickness(..)")
<< "Thickness should be factor of local undistorted cell size." << "Thickness should be factor of local undistorted cell size."
<< " Valid values are [0..2]." << nl << " Valid values are [0..2]." << nl
<< " minThickness:" << patchMinThickness << " minThickness:" << layerParams.minThickness()
<< exit(FatalError); << exit(FatalError);
} }
@ -1225,38 +1159,114 @@ void Foam::autoLayerDriver::calculateLayerThickness
{ {
// Find undistorted edge size for this level. // Find undistorted edge size for this level.
scalar edgeLen = edge0Len/(1<<maxPointLevel[pointI]); scalar edgeLen = edge0Len/(1<<maxPointLevel[pointI]);
thickness[pointI] *= edgeLen; firstLayerThickness[pointI] *= edgeLen;
finalLayerThickness[pointI] *= edgeLen;
totalThickness[pointI] *= edgeLen;
minThickness[pointI] *= edgeLen; minThickness[pointI] *= edgeLen;
} }
} }
// Rework thickness (of final layer) into overall thickness of all layers // Rework thickness parameters into overall thickness
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
forAll(thickness, pointI) forAll(firstLayerThickness, pointI)
{
// Calculate layer thickness based on expansion ratio
// and final layer height
if (expansionRatio[pointI] == 1)
{
thickness[pointI] *= patchNLayers[pointI];
}
else
{ {
thickness[pointI] = layerParams.layerThickness
(
patchNLayers[pointI],
firstLayerThickness[pointI],
finalLayerThickness[pointI],
totalThickness[pointI],
expRatio[pointI]
);
scalar invExpansion = 1.0 / expansionRatio[pointI]; expansionRatio[pointI] = layerParams.layerExpansionRatio
label nLay = patchNLayers[pointI]; (
thickness[pointI] *= patchNLayers[pointI],
(1.0 - pow(invExpansion, nLay)) firstLayerThickness[pointI],
/ (1.0 - invExpansion); finalLayerThickness[pointI],
totalThickness[pointI],
expRatio[pointI]
);
} }
}
//Info<< "calculateLayerThickness : min:" << gMin(thickness) //Info<< "calculateLayerThickness : min:" << gMin(thickness)
// << " max:" << gMax(thickness) << endl; // << " max:" << gMax(thickness) << endl;
// Print a bit
{
const polyBoundaryMesh& patches = mesh.boundaryMesh();
// Find maximum length of a patch name, for a nicer output
label maxPatchNameLen = 0;
forAll(patchIDs, i)
{
label patchI = patchIDs[i];
word patchName = patches[patchI].name();
maxPatchNameLen = max(maxPatchNameLen, label(patchName.size()));
}
Info<< nl
<< setf(ios_base::left) << setw(maxPatchNameLen) << "patch"
<< setw(0) << " faces layers avg thickness[m]" << nl
<< setf(ios_base::left) << setw(maxPatchNameLen) << " "
<< setw(0) << " near-wall overall" << nl
<< setf(ios_base::left) << setw(maxPatchNameLen) << "-----"
<< setw(0) << " ----- ------ --------- -------" << endl;
forAll(patchIDs, i)
{
label patchI = patchIDs[i];
const labelList& meshPoints = patches[patchI].meshPoints();
scalar sumThickness = 0;
scalar sumNearWallThickness = 0;
forAll(meshPoints, patchPointI)
{
label ppPointI = pp.meshPointMap()[meshPoints[patchPointI]];
sumThickness += thickness[ppPointI];
sumNearWallThickness += layerParams.firstLayerThickness
(
patchNLayers[ppPointI],
firstLayerThickness[ppPointI],
finalLayerThickness[ppPointI],
thickness[ppPointI],
expansionRatio[ppPointI]
);
}
label totNPoints = returnReduce(meshPoints.size(), sumOp<label>());
// For empty patches, totNPoints is 0.
scalar avgThickness = 0;
scalar avgNearWallThickness = 0;
if (totNPoints > 0)
{
avgThickness =
returnReduce(sumThickness, sumOp<scalar>())
/ totNPoints;
avgNearWallThickness =
returnReduce(sumNearWallThickness, sumOp<scalar>())
/ totNPoints;
}
Info<< setf(ios_base::left) << setw(maxPatchNameLen)
<< patches[patchI].name() << setprecision(3)
<< " " << setw(8)
<< returnReduce(patches[patchI].size(), sumOp<scalar>())
<< " " << setw(6) << layerParams.numLayers()[patchI]
<< " " << setw(8) << avgNearWallThickness
<< " " << setw(8) << avgThickness
<< endl;
}
Info<< endl;
}
} }
@ -2618,7 +2628,8 @@ void Foam::autoLayerDriver::addLayers
const scalar edge0Len = meshRefiner_.meshCutter().level0EdgeLength(); const scalar edge0Len = meshRefiner_.meshCutter().level0EdgeLength();
const labelList& cellLevel = meshRefiner_.meshCutter().cellLevel(); const labelList& cellLevel = meshRefiner_.meshCutter().cellLevel();
// Determine (wanted) point-wise layer thickness and expansion ratio // Determine (wanted) point-wise overall layer thickness and expansion
// ratio
scalarField thickness(pp().nPoints()); scalarField thickness(pp().nPoints());
scalarField minThickness(pp().nPoints()); scalarField minThickness(pp().nPoints());
scalarField expansionRatio(pp().nPoints()); scalarField expansionRatio(pp().nPoints());
@ -2626,12 +2637,7 @@ void Foam::autoLayerDriver::addLayers
( (
pp, pp,
meshMover().adaptPatchIDs(), meshMover().adaptPatchIDs(),
layerParams.expansionRatio(), layerParams,
layerParams.relativeSizes(), // thickness relative to cellsize?
layerParams.finalLayerThickness(), // wanted thicknes
layerParams.minThickness(), // minimum thickness
cellLevel, cellLevel,
patchNLayers, patchNLayers,
edge0Len, edge0Len,
@ -2642,87 +2648,6 @@ void Foam::autoLayerDriver::addLayers
); );
// Print a bit
{
const polyBoundaryMesh& patches = mesh.boundaryMesh();
// Find maximum length of a patch name, for a nicer output
label maxPatchNameLen = 0;
forAll(meshMover().adaptPatchIDs(), i)
{
label patchI = meshMover().adaptPatchIDs()[i];
word patchName = patches[patchI].name();
maxPatchNameLen = max(maxPatchNameLen, label(patchName.size()));
}
Info<< nl
<< setf(ios_base::left) << setw(maxPatchNameLen) << "patch"
<< setw(0) << " faces layers avg thickness[m]" << nl
<< setf(ios_base::left) << setw(maxPatchNameLen) << " "
<< setw(0) << " near-wall overall" << nl
<< setf(ios_base::left) << setw(maxPatchNameLen) << "-----"
<< setw(0) << " ----- ------ --------- -------" << endl;
forAll(meshMover().adaptPatchIDs(), i)
{
label patchI = meshMover().adaptPatchIDs()[i];
const labelList& meshPoints = patches[patchI].meshPoints();
scalar sumThickness = 0;
scalar sumNearWallThickness = 0;
forAll(meshPoints, patchPointI)
{
label ppPointI = pp().meshPointMap()[meshPoints[patchPointI]];
sumThickness += thickness[ppPointI];
label nLay = patchNLayers[ppPointI];
if (nLay > 0)
{
if (expansionRatio[ppPointI] == 1)
{
sumNearWallThickness += thickness[ppPointI]/nLay;
}
else
{
scalar s =
(1.0-pow(expansionRatio[ppPointI], nLay))
/ (1.0-expansionRatio[ppPointI]);
sumNearWallThickness += thickness[ppPointI]/s;
}
}
}
label totNPoints = returnReduce(meshPoints.size(), sumOp<label>());
// For empty patches, totNPoints is 0.
scalar avgThickness = 0;
scalar avgNearWallThickness = 0;
if (totNPoints > 0)
{
avgThickness =
returnReduce(sumThickness, sumOp<scalar>())
/ totNPoints;
avgNearWallThickness =
returnReduce(sumNearWallThickness, sumOp<scalar>())
/ totNPoints;
}
Info<< setf(ios_base::left) << setw(maxPatchNameLen)
<< patches[patchI].name() << setprecision(3)
<< " " << setw(8)
<< returnReduce(patches[patchI].size(), sumOp<scalar>())
<< " " << setw(6) << layerParams.numLayers()[patchI]
<< " " << setw(8) << avgNearWallThickness
<< " " << setw(8) << avgThickness
<< endl;
}
Info<< endl;
}
// Calculate wall to medial axis distance for smoothing displacement // Calculate wall to medial axis distance for smoothing displacement
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -2958,8 +2883,8 @@ void Foam::autoLayerDriver::addLayers
// Determine per point/per face number of layers to extrude. Also // Determine per point/per face number of layers to extrude. Also
// handles the slow termination of layers when going switching layers // handles the slow termination of layers when going switching layers
labelList nPatchPointLayers(pp().nPoints(),-1); labelList nPatchPointLayers(pp().nPoints(), -1);
labelList nPatchFaceLayers(pp().localFaces().size(),-1); labelList nPatchFaceLayers(pp().size(), -1);
setupLayerInfoTruncation setupLayerInfoTruncation
( (
meshMover(), meshMover(),
@ -2970,31 +2895,22 @@ void Foam::autoLayerDriver::addLayers
nPatchFaceLayers nPatchFaceLayers
); );
// Calculate displacement for first layer for addPatchLayer. // Calculate displacement for final layer for addPatchLayer.
// (first layer = layer of cells next to the original mesh) // (layer of cells next to the original mesh)
vectorField firstDisp(patchNLayers.size(), vector::zero); vectorField finalDisp(patchNLayers.size(), vector::zero);
forAll(nPatchPointLayers, i) forAll(nPatchPointLayers, i)
{ {
if (nPatchPointLayers[i] > 0) scalar ratio = layerParams.finalLayerThicknessRatio
{ (
if (expansionRatio[i] == 1.0) nPatchPointLayers[i],
{ expansionRatio[i]
firstDisp[i] = patchDisp[i]/nPatchPointLayers[i]; );
} finalDisp[i] = ratio*patchDisp[i];
else
{
label nLay = nPatchPointLayers[i];
scalar h =
pow(expansionRatio[i], nLay - 1)
* (1.0 - expansionRatio[i])
/ (1.0 - pow(expansionRatio[i], nLay));
firstDisp[i] = h*patchDisp[i];
}
}
} }
const scalarField invExpansionRatio(1.0 / expansionRatio);
const scalarField invExpansionRatio(1.0/expansionRatio);
// Add topo regardless of whether extrudeStatus is extruderemove. // Add topo regardless of whether extrudeStatus is extruderemove.
// Not add layer if patchDisp is zero. // Not add layer if patchDisp is zero.
@ -3009,7 +2925,7 @@ void Foam::autoLayerDriver::addLayers
labelList(0), // exposed patchIDs, not used for adding layers labelList(0), // exposed patchIDs, not used for adding layers
nPatchFaceLayers, // layers per face nPatchFaceLayers, // layers per face
nPatchPointLayers, // layers per point nPatchPointLayers, // layers per point
firstDisp, // thickness of layer nearest internal mesh finalDisp, // thickness of layer nearest internal mesh
meshMod meshMod
); );

View File

@ -237,12 +237,7 @@ class autoLayerDriver
( (
const indirectPrimitivePatch& pp, const indirectPrimitivePatch& pp,
const labelList& patchIDs, const labelList& patchIDs,
const layerParameters& layerParams,
const scalarField& patchExpansionRatio,
const bool relativeSizes,
const scalarField& patchFinalLayerThickness,
const scalarField& patchMinThickness,
const labelList& cellLevel, const labelList& cellLevel,
const labelList& patchNLayers, const labelList& patchNLayers,
const scalar edge0Len, const scalar edge0Len,

View File

@ -97,6 +97,7 @@ Foam::label Foam::autoRefineDriver::featureEdgeRefine
refineParams.curvature(), refineParams.curvature(),
true, // featureRefinement true, // featureRefinement
false, // featureDistanceRefinement
false, // internalRefinement false, // internalRefinement
false, // surfaceRefinement false, // surfaceRefinement
false, // curvatureRefinement false, // curvatureRefinement
@ -207,6 +208,7 @@ Foam::label Foam::autoRefineDriver::surfaceOnlyRefine
refineParams.curvature(), refineParams.curvature(),
false, // featureRefinement false, // featureRefinement
false, // featureDistanceRefinement
false, // internalRefinement false, // internalRefinement
true, // surfaceRefinement true, // surfaceRefinement
true, // curvatureRefinement true, // curvatureRefinement
@ -368,6 +370,7 @@ Foam::label Foam::autoRefineDriver::shellRefine
refineParams.curvature(), refineParams.curvature(),
false, // featureRefinement false, // featureRefinement
true, // featureDistanceRefinement
true, // internalRefinement true, // internalRefinement
false, // surfaceRefinement false, // surfaceRefinement
false, // curvatureRefinement false, // curvatureRefinement

View File

@ -1406,9 +1406,10 @@ void Foam::autoSnapDriver::doSnap
adaptPatchIDs adaptPatchIDs
) )
); );
indirectPrimitivePatch& pp = ppPtr();
// Distance to attract to nearest feature on surface // Distance to attract to nearest feature on surface
const scalarField snapDist(calcSnapDistance(snapParams, ppPtr())); const scalarField snapDist(calcSnapDistance(snapParams, pp));
// Construct iterative mesh mover. // Construct iterative mesh mover.
@ -1420,7 +1421,7 @@ void Foam::autoSnapDriver::doSnap
motionSmoother meshMover motionSmoother meshMover
( (
mesh, mesh,
ppPtr(), pp,
adaptPatchIDs, adaptPatchIDs,
meshRefinement::makeDisplacementField(pMesh, adaptPatchIDs), meshRefinement::makeDisplacementField(pMesh, adaptPatchIDs),
motionDict motionDict
@ -1475,7 +1476,7 @@ void Foam::autoSnapDriver::doSnap
} }
// Check for displacement being outwards. // Check for displacement being outwards.
outwardsDisplacement(ppPtr(), disp); outwardsDisplacement(pp, disp);
// Set initial distribution of displacement field (on patches) // Set initial distribution of displacement field (on patches)
// from patchDisp and make displacement consistent with b.c. // from patchDisp and make displacement consistent with b.c.
@ -1489,8 +1490,8 @@ void Foam::autoSnapDriver::doSnap
( (
mesh.time().path() mesh.time().path()
/ "patchDisplacement_" + name(iter) + ".obj", / "patchDisplacement_" + name(iter) + ".obj",
ppPtr().localPoints(), pp.localPoints(),
ppPtr().localPoints() + disp pp.localPoints() + disp
); );
} }

View File

@ -141,14 +141,6 @@ class autoSnapDriver
vectorField& pointSurfaceNormal, vectorField& pointSurfaceNormal,
vectorField& pointRotation vectorField& pointRotation
) const; ) const;
//void calcNearestFace
//(
// const label iter,
// const indirectPrimitivePatch& pp,
// vectorField& faceDisp,
// vectorField& faceSurfaceNormal,
// vectorField& faceRotation
//) const;
void calcNearestFace void calcNearestFace
( (
const label iter, const label iter,
@ -158,15 +150,19 @@ class autoSnapDriver
labelList& faceSurfaceRegion, labelList& faceSurfaceRegion,
vectorField& faceRotation vectorField& faceRotation
) const; ) const;
void interpolateFaceToPoint void calcNearestFacePointProperties
( (
const label iter, const label iter,
const indirectPrimitivePatch& pp, const indirectPrimitivePatch& pp,
const List<List<point> >& pointFaceDisp,
const List<List<point> >& pointFaceRotation, const vectorField& faceDisp,
const List<List<point> >& pointFaceCentres, const vectorField& faceSurfaceNormal,
vectorField& patchDisp const labelList& faceSurfaceRegion,
//vectorField& patchRotationDisp
List<List<point> >& pointFaceSurfNormals,
List<List<point> >& pointFaceDisp,
List<List<point> >& pointFaceCentres,
List<labelList>& pointFacePatchID
) const; ) const;
void correctAttraction void correctAttraction
( (
@ -276,6 +272,7 @@ class autoSnapDriver
( (
const label iter, const label iter,
const scalar featureCos, const scalar featureCos,
const bool multiRegionFeatureSnap,
const indirectPrimitivePatch&, const indirectPrimitivePatch&,
const scalarField&, const scalarField&,
@ -339,6 +336,7 @@ class autoSnapDriver
( (
const label iter, const label iter,
const scalar featureCos, const scalar featureCos,
const bool multiRegionFeatureSnap,
const indirectPrimitivePatch& pp, const indirectPrimitivePatch& pp,
const scalarField& snapDist, const scalarField& snapDist,

View File

@ -321,7 +321,7 @@ void Foam::autoSnapDriver::calcNearestFace
const indirectPrimitivePatch& pp, const indirectPrimitivePatch& pp,
vectorField& faceDisp, vectorField& faceDisp,
vectorField& faceSurfaceNormal, vectorField& faceSurfaceNormal,
labelList& faceSurfaceRegion, labelList& faceSurfaceGlobalRegion,
vectorField& faceRotation vectorField& faceRotation
) const ) const
{ {
@ -333,8 +333,8 @@ void Foam::autoSnapDriver::calcNearestFace
faceDisp = vector::zero; faceDisp = vector::zero;
faceSurfaceNormal.setSize(pp.size()); faceSurfaceNormal.setSize(pp.size());
faceSurfaceNormal = vector::zero; faceSurfaceNormal = vector::zero;
faceSurfaceRegion.setSize(pp.size()); faceSurfaceGlobalRegion.setSize(pp.size());
faceSurfaceRegion = -1; faceSurfaceGlobalRegion = -1;
// Divide surfaces into zoned and unzoned // Divide surfaces into zoned and unzoned
labelList zonedSurfaces = surfaces.getNamedSurfaces(); labelList zonedSurfaces = surfaces.getNamedSurfaces();
@ -419,7 +419,7 @@ void Foam::autoSnapDriver::calcNearestFace
label faceI = ppFaces[hitI]; label faceI = ppFaces[hitI];
faceDisp[faceI] = hitInfo[hitI].hitPoint() - fc[hitI]; faceDisp[faceI] = hitInfo[hitI].hitPoint() - fc[hitI];
faceSurfaceNormal[faceI] = hitNormal[hitI]; faceSurfaceNormal[faceI] = hitNormal[hitI];
faceSurfaceRegion[faceI] = surfaces.globalRegion faceSurfaceGlobalRegion[faceI] = surfaces.globalRegion
( (
hitSurface[hitI], hitSurface[hitI],
hitRegion[hitI] hitRegion[hitI]
@ -477,7 +477,11 @@ void Foam::autoSnapDriver::calcNearestFace
label faceI = ppFaces[hitI]; label faceI = ppFaces[hitI];
faceDisp[faceI] = hitInfo[hitI].hitPoint() - fc[hitI]; faceDisp[faceI] = hitInfo[hitI].hitPoint() - fc[hitI];
faceSurfaceNormal[faceI] = hitNormal[hitI]; faceSurfaceNormal[faceI] = hitNormal[hitI];
faceSurfaceRegion[faceI] = hitRegion[hitI]; faceSurfaceGlobalRegion[faceI] = surfaces.globalRegion
(
hitSurface[hitI],
hitRegion[hitI]
);
} }
} }
@ -517,6 +521,169 @@ void Foam::autoSnapDriver::calcNearestFace
} }
// Collect (possibly remote) per point data of all surrounding faces
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// - faceSurfaceNormal
// - faceDisp
// - faceCentres&faceNormal
void Foam::autoSnapDriver::calcNearestFacePointProperties
(
const label iter,
const indirectPrimitivePatch& pp,
const vectorField& faceDisp,
const vectorField& faceSurfaceNormal,
const labelList& faceSurfaceGlobalRegion,
List<List<point> >& pointFaceSurfNormals,
List<List<point> >& pointFaceDisp,
List<List<point> >& pointFaceCentres,
List<labelList>& pointFacePatchID
) const
{
const fvMesh& mesh = meshRefiner_.mesh();
// For now just get all surrounding face data. Expensive - should just
// store and sync data on coupled points only
// (see e.g PatchToolsNormals.C)
pointFaceSurfNormals.setSize(pp.nPoints());
pointFaceDisp.setSize(pp.nPoints());
pointFaceCentres.setSize(pp.nPoints());
pointFacePatchID.setSize(pp.nPoints());
// Fill local data
forAll(pp.pointFaces(), pointI)
{
const labelList& pFaces = pp.pointFaces()[pointI];
List<point>& pNormals = pointFaceSurfNormals[pointI];
pNormals.setSize(pFaces.size());
List<point>& pDisp = pointFaceDisp[pointI];
pDisp.setSize(pFaces.size());
List<point>& pFc = pointFaceCentres[pointI];
pFc.setSize(pFaces.size());
labelList& pFid = pointFacePatchID[pointI];
pFid.setSize(pFaces.size());
forAll(pFaces, i)
{
label faceI = pFaces[i];
pNormals[i] = faceSurfaceNormal[faceI];
pDisp[i] = faceDisp[faceI];
pFc[i] = pp.faceCentres()[faceI];
//label meshFaceI = pp.addressing()[faceI];
//pFid[i] = mesh.boundaryMesh().whichPatch(meshFaceI);
pFid[i] = globalToPatch_[faceSurfaceGlobalRegion[faceI]];
}
}
// Collect additionally 'normal' boundary faces for boundaryPoints of pp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// points on the boundary of pp should pick up non-pp normals
// as well for the feature-reconstruction to behave correctly.
// (the movement is already constrained outside correctly so it
// is only that the unconstrained attraction vector is calculated
// correctly)
{
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
labelList patchID(pbm.patchID());
// Unmark all non-coupled boundary faces
forAll(pbm, patchI)
{
const polyPatch& pp = pbm[patchI];
if (pp.coupled() || isA<emptyPolyPatch>(pp))
{
forAll(pp, i)
{
label meshFaceI = pp.start()+i;
patchID[meshFaceI-mesh.nInternalFaces()] = -1;
}
}
}
// Remove any meshed faces
forAll(pp.addressing(), i)
{
label meshFaceI = pp.addressing()[i];
patchID[meshFaceI-mesh.nInternalFaces()] = -1;
}
// See if pp point uses any non-meshed boundary faces
const labelList& boundaryPoints = pp.boundaryPoints();
forAll(boundaryPoints, i)
{
label pointI = boundaryPoints[i];
label meshPointI = pp.meshPoints()[pointI];
const point& pt = mesh.points()[meshPointI];
const labelList& pFaces = mesh.pointFaces()[meshPointI];
List<point>& pNormals = pointFaceSurfNormals[pointI];
List<point>& pDisp = pointFaceDisp[pointI];
List<point>& pFc = pointFaceCentres[pointI];
labelList& pFid = pointFacePatchID[pointI];
forAll(pFaces, i)
{
label meshFaceI = pFaces[i];
if (!mesh.isInternalFace(meshFaceI))
{
label patchI = patchID[meshFaceI-mesh.nInternalFaces()];
if (patchI != -1)
{
vector fn = mesh.faceAreas()[meshFaceI];
pNormals.append(fn/mag(fn));
pDisp.append(mesh.faceCentres()[meshFaceI]-pt);
pFc.append(mesh.faceCentres()[meshFaceI]);
pFid.append(patchI);
}
}
}
}
}
syncTools::syncPointList
(
mesh,
pp.meshPoints(),
pointFaceSurfNormals,
listPlusEqOp<point>(),
List<point>(),
listTransform()
);
syncTools::syncPointList
(
mesh,
pp.meshPoints(),
pointFaceDisp,
listPlusEqOp<point>(),
List<point>(),
listTransform()
);
syncTools::syncPointList
(
mesh,
pp.meshPoints(),
pointFaceCentres,
listPlusEqOp<point>(),
List<point>(),
listTransform()
);
syncTools::syncPointList
(
mesh,
pp.meshPoints(),
pointFacePatchID,
listPlusEqOp<label>(),
List<label>()
);
}
// Gets passed in offset to nearest point on feature edge. Calculates // Gets passed in offset to nearest point on feature edge. Calculates
// if the point has a different number of faces on either side of the feature // if the point has a different number of faces on either side of the feature
// and if so attracts the point to that non-dominant plane. // and if so attracts the point to that non-dominant plane.
@ -580,56 +747,7 @@ Foam::pointIndexHit Foam::autoSnapDriver::findMultiPatchPoint
} }
return pointIndexHit(false, vector::zero, labelMax); return pointIndexHit(false, vector::zero, labelMax);
} }
////XXXXXXXX
//void Foam::autoSnapDriver::attractMultiPatchPoint
//(
// const label iter,
// const scalar featureCos,
//
// const indirectPrimitivePatch& pp,
// const scalarField& snapDist,
// const label pointI,
//
// const List<List<point> >& pointFaceSurfNormals,
// const labelListList& pointFaceSurfaceRegion,
// const List<List<point> >& pointFaceDisp,
// const List<List<point> >& pointFaceCentres,
// const labelListList& pointFacePatchID,
//
// vector& patchAttraction,
// pointConstraint& patchConstraint
//) const
//{
// // Collect
//
// );
//
// if
// (
// (constraint.first() > patchConstraints[pointI].first())
// || (magSqr(attraction) < magSqr(patchAttraction[pointI]))
// )
// {
// patchAttraction[pointI] = attraction;
// patchConstraints[pointI] = constraint;
//
// // Check the number of directions
// if (patchConstraints[pointI].first() == 1)
// {
// // Flat surface. Check for different patchIDs
// pointIndexHit multiPatchPt
// (
// findMultiPatchPoint
// (
// pt,
// pointFacePatchID[pointI],
// pointFaceCentres[pointI]
// )
// );
// if (multiPatchPt.hit())
// {
// // Behave like when having two surface normals so
////XXXXXXXX
void Foam::autoSnapDriver::binFeatureFace void Foam::autoSnapDriver::binFeatureFace
( (
@ -1361,6 +1479,7 @@ void Foam::autoSnapDriver::determineFeatures
( (
const label iter, const label iter,
const scalar featureCos, const scalar featureCos,
const bool multiRegionFeatureSnap,
const indirectPrimitivePatch& pp, const indirectPrimitivePatch& pp,
const scalarField& snapDist, const scalarField& snapDist,
@ -1464,6 +1583,8 @@ void Foam::autoSnapDriver::determineFeatures
if (patchConstraints[pointI].first() == 1) if (patchConstraints[pointI].first() == 1)
{ {
// Flat surface. Check for different patchIDs // Flat surface. Check for different patchIDs
if (multiRegionFeatureSnap)
{
pointIndexHit multiPatchPt pointIndexHit multiPatchPt
( (
findMultiPatchPoint findMultiPatchPoint
@ -1531,6 +1652,7 @@ void Foam::autoSnapDriver::determineFeatures
} }
} }
} }
}
else if (patchConstraints[pointI].first() == 2) else if (patchConstraints[pointI].first() == 2)
{ {
// Mark point on the nearest feature edge. Note that we // Mark point on the nearest feature edge. Note that we
@ -1645,6 +1767,7 @@ void Foam::autoSnapDriver::featureAttractionUsingFeatureEdges
( (
const label iter, const label iter,
const scalar featureCos, const scalar featureCos,
const bool multiRegionFeatureSnap,
const indirectPrimitivePatch& pp, const indirectPrimitivePatch& pp,
const scalarField& snapDist, const scalarField& snapDist,
@ -1697,6 +1820,7 @@ void Foam::autoSnapDriver::featureAttractionUsingFeatureEdges
( (
iter, iter,
featureCos, featureCos,
multiRegionFeatureSnap,
pp, pp,
snapDist, snapDist,
@ -2131,6 +2255,7 @@ void Foam::autoSnapDriver::featureAttractionUsingFeatureEdges
//MEJ: any faces that have multi-patch points only keep the multi-patch //MEJ: any faces that have multi-patch points only keep the multi-patch
// points. The other points on the face will be dragged along // points. The other points on the face will be dragged along
// (hopefully) // (hopefully)
if (multiRegionFeatureSnap)
{ {
autoPtr<OFstream> multiPatchStr; autoPtr<OFstream> multiPatchStr;
if (debug&meshRefinement::OBJINTERSECTIONS) if (debug&meshRefinement::OBJINTERSECTIONS)
@ -2536,10 +2661,12 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurfaceFeature
{ {
const Switch implicitFeatureAttraction = snapParams.implicitFeatureSnap(); const Switch implicitFeatureAttraction = snapParams.implicitFeatureSnap();
const Switch explicitFeatureAttraction = snapParams.explicitFeatureSnap(); const Switch explicitFeatureAttraction = snapParams.explicitFeatureSnap();
const Switch multiRegionFeatureSnap = snapParams.multiRegionFeatureSnap();
Info<< "Overriding displacement on features :" << nl Info<< "Overriding displacement on features :" << nl
<< " implicit features : " << implicitFeatureAttraction << nl << " implicit features : " << implicitFeatureAttraction << nl
<< " explicit features : " << explicitFeatureAttraction << nl << " explicit features : " << explicitFeatureAttraction << nl
<< " multi-patch features : " << multiRegionFeatureSnap << nl
<< endl; << endl;
@ -2547,6 +2674,7 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurfaceFeature
const pointField& localPoints = pp.localPoints(); const pointField& localPoints = pp.localPoints();
const fvMesh& mesh = meshRefiner_.mesh(); const fvMesh& mesh = meshRefiner_.mesh();
// Displacement and orientation per pp face // Displacement and orientation per pp face
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -2554,7 +2682,7 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurfaceFeature
vectorField faceDisp(pp.size(), vector::zero); vectorField faceDisp(pp.size(), vector::zero);
// normal of surface at point on surface // normal of surface at point on surface
vectorField faceSurfaceNormal(pp.size(), vector::zero); vectorField faceSurfaceNormal(pp.size(), vector::zero);
labelList faceSurfaceRegion(pp.size(), -1); labelList faceSurfaceGlobalRegion(pp.size(), -1);
vectorField faceRotation(pp.size(), vector::zero); vectorField faceRotation(pp.size(), vector::zero);
calcNearestFace calcNearestFace
@ -2563,7 +2691,7 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurfaceFeature
pp, pp,
faceDisp, faceDisp,
faceSurfaceNormal, faceSurfaceNormal,
faceSurfaceRegion, faceSurfaceGlobalRegion,
faceRotation faceRotation
); );
@ -2587,158 +2715,25 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurfaceFeature
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// - faceSurfaceNormal // - faceSurfaceNormal
// - faceDisp // - faceDisp
// - faceRotation
// - faceCentres&faceNormal // - faceCentres&faceNormal
// For now just get all surrounding face data. Expensive - should just
// store and sync data on coupled points only
// (see e.g PatchToolsNormals.C)
List<List<point> > pointFaceSurfNormals(pp.nPoints()); List<List<point> > pointFaceSurfNormals(pp.nPoints());
List<List<point> > pointFaceDisp(pp.nPoints()); List<List<point> > pointFaceDisp(pp.nPoints());
//List<List<point> > pointFaceRotation(pp.nPoints());
List<List<point> > pointFaceCentres(pp.nPoints()); List<List<point> > pointFaceCentres(pp.nPoints());
List<labelList> pointFacePatchID(pp.nPoints()); List<labelList> pointFacePatchID(pp.nPoints());
// Fill local data calcNearestFacePointProperties
forAll(pp.pointFaces(), pointI)
{
const labelList& pFaces = pp.pointFaces()[pointI];
List<point>& pNormals = pointFaceSurfNormals[pointI];
pNormals.setSize(pFaces.size());
List<point>& pDisp = pointFaceDisp[pointI];
pDisp.setSize(pFaces.size());
//List<point>& pRot = pointFaceRotation[pointI];
//pRot.setSize(pFaces.size());
List<point>& pFc = pointFaceCentres[pointI];
pFc.setSize(pFaces.size());
labelList& pFid = pointFacePatchID[pointI];
pFid.setSize(pFaces.size());
forAll(pFaces, i)
{
label faceI = pFaces[i];
pNormals[i] = faceSurfaceNormal[faceI];
pDisp[i] = faceDisp[faceI];
//pRot[i] = faceRotation[faceI];
pFc[i] = pp.faceCentres()[faceI];
label meshFaceI = pp.addressing()[faceI];
pFid[i] = mesh.boundaryMesh().whichPatch(meshFaceI);
}
}
// Collect additionally 'normal' boundary faces for boundaryPoints of pp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// points on the boundary of pp should pick up non-pp normals
// as well for the feature-reconstruction to behave correctly.
// (the movement is already constrained outside correctly so it
// is only that the unconstrained attraction vector is calculated
// correctly)
{
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
labelList patchID(pbm.patchID());
// Unmark all non-coupled boundary faces
forAll(pbm, patchI)
{
const polyPatch& pp = pbm[patchI];
if (pp.coupled() || isA<emptyPolyPatch>(pp))
{
forAll(pp, i)
{
label meshFaceI = pp.start()+i;
patchID[meshFaceI-mesh.nInternalFaces()] = -1;
}
}
}
// Remove any meshed faces
forAll(pp.addressing(), i)
{
label meshFaceI = pp.addressing()[i];
patchID[meshFaceI-mesh.nInternalFaces()] = -1;
}
// See if pp point uses any non-meshed boundary faces
const labelList& boundaryPoints = pp.boundaryPoints();
forAll(boundaryPoints, i)
{
label pointI = boundaryPoints[i];
label meshPointI = pp.meshPoints()[pointI];
const point& pt = mesh.points()[meshPointI];
const labelList& pFaces = mesh.pointFaces()[meshPointI];
List<point>& pNormals = pointFaceSurfNormals[pointI];
List<point>& pDisp = pointFaceDisp[pointI];
List<point>& pFc = pointFaceCentres[pointI];
labelList& pFid = pointFacePatchID[pointI];
forAll(pFaces, i)
{
label meshFaceI = pFaces[i];
if (!mesh.isInternalFace(meshFaceI))
{
label patchI = patchID[meshFaceI-mesh.nInternalFaces()];
if (patchI != -1)
{
vector fn = mesh.faceAreas()[meshFaceI];
pNormals.append(fn/mag(fn));
pDisp.append(mesh.faceCentres()[meshFaceI]-pt);
pFc.append(mesh.faceCentres()[meshFaceI]);
pFid.append(patchI);
}
}
}
}
}
syncTools::syncPointList
( (
mesh, iter,
pp.meshPoints(), pp,
faceDisp,
faceSurfaceNormal,
faceSurfaceGlobalRegion,
pointFaceSurfNormals, pointFaceSurfNormals,
listPlusEqOp<point>(),
List<point>(),
listTransform()
);
syncTools::syncPointList
(
mesh,
pp.meshPoints(),
pointFaceDisp, pointFaceDisp,
listPlusEqOp<point>(),
List<point>(),
listTransform()
);
//syncTools::syncPointList
//(
// mesh,
// pp.meshPoints(),
// pointFaceRotation,
// listPlusEqOp<point>(),
// List<point>(),
// listTransform()
//);
syncTools::syncPointList
(
mesh,
pp.meshPoints(),
pointFaceCentres, pointFaceCentres,
listPlusEqOp<point>(), pointFacePatchID
List<point>(),
listTransform()
);
syncTools::syncPointList
(
mesh,
pp.meshPoints(),
pointFacePatchID,
listPlusEqOp<label>(),
List<label>()
); );
@ -2793,6 +2788,7 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurfaceFeature
( (
iter, iter,
featureCos, featureCos,
multiRegionFeatureSnap,
pp, pp,
snapDist, snapDist,

View File

@ -34,6 +34,72 @@ License
const Foam::scalar Foam::layerParameters::defaultConcaveAngle = 90; const Foam::scalar Foam::layerParameters::defaultConcaveAngle = 90;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::scalar Foam::layerParameters::layerExpansionRatio
(
const label n,
const scalar totalOverFirst
) const
{
if (n <= 1)
{
return 1.0;
}
//scalar totalOverFirst = totalThickness/firstLayerThickess;
const label maxIters = 10;
const scalar tol = 1e-8;
if (mag(n-totalOverFirst) < tol)
{
return 1.0;
}
// Calculate the bounds of the solution
scalar minR;
scalar maxR;
if (totalOverFirst < n)
{
minR = 0.0;
maxR = pow(totalOverFirst/n, 1/(n-1));
}
else
{
minR = pow(totalOverFirst/n, 1/(n-1));
maxR = totalOverFirst/(n - 1);
}
//Info<< "Solution bounds = (" << minR << ", " << maxR << ")" << nl << endl;
// Starting guess
scalar r = 0.5*(minR + maxR);
for (label i = 0; i < maxIters; ++i)
{
const scalar prevr = r;
const scalar fx = pow(r, n) - totalOverFirst*r - (1 - totalOverFirst);
const scalar dfx = n*pow(r, n - 1) - totalOverFirst;
r -= fx/dfx;
const scalar error = mag(r - prevr);
//Info<< i << " " << r << " Error = " << error << endl;
if (error < tol)
{
break;
}
}
return r;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from dictionary // Construct from dictionary
@ -44,17 +110,12 @@ Foam::layerParameters::layerParameters
) )
: :
numLayers_(boundaryMesh.size(), -1), numLayers_(boundaryMesh.size(), -1),
expansionRatio_
(
boundaryMesh.size(),
readScalar(dict.lookup("expansionRatio"))
),
relativeSizes_(dict.lookup("relativeSizes")), relativeSizes_(dict.lookup("relativeSizes")),
finalLayerThickness_ layerSpec_(ILLEGAL),
( firstLayerThickness_(boundaryMesh.size(), -123),
boundaryMesh.size(), finalLayerThickness_(boundaryMesh.size(), -123),
readScalar(dict.lookup("finalLayerThickness")) thickness_(boundaryMesh.size(), -123),
), expansionRatio_(boundaryMesh.size(), -123),
minThickness_ minThickness_
( (
boundaryMesh.size(), boundaryMesh.size(),
@ -103,24 +164,108 @@ Foam::layerParameters::layerParameters
nRelaxedIter_(labelMax), nRelaxedIter_(labelMax),
additionalReporting_(dict.lookupOrDefault("additionalReporting", false)) additionalReporting_(dict.lookupOrDefault("additionalReporting", false))
{ {
if (nGrow_ > 0) // Detect layer specification mode
label nSpec = 0;
bool haveFirst = dict.found("firstLayerThickness");
if (haveFirst)
{ {
WarningIn("layerParameters::layerParameters(..)") firstLayerThickness_ = scalarField
<< "The nGrow parameter effect has changed with respect to 1.6.x." (
<< endl boundaryMesh.size(),
<< "Please set nGrow=0 for 1.6.x behaviour." readScalar(dict.lookup("firstLayerThickness"))
);
nSpec++;
}
bool haveFinal = dict.found("finalLayerThickness");
if (haveFinal)
{
finalLayerThickness_ = scalarField
(
boundaryMesh.size(),
readScalar(dict.lookup("finalLayerThickness"))
);
nSpec++;
}
bool haveTotal = dict.found("thickness");
if (haveTotal)
{
thickness_ = scalarField
(
boundaryMesh.size(),
readScalar(dict.lookup("thickness"))
);
nSpec++;
}
bool haveExp = dict.found("expansionRatio");
if (haveExp)
{
expansionRatio_ = scalarField
(
boundaryMesh.size(),
readScalar(dict.lookup("expansionRatio"))
);
nSpec++;
}
if (haveFirst && haveTotal)
{
layerSpec_ = FIRST_AND_TOTAL;
Info<< "Layer thickness specified as first layer and overall thickness."
<< endl; << endl;
} }
else if (haveFirst && haveExp)
{
layerSpec_ = FIRST_AND_EXPANSION;
Info<< "Layer thickness specified as first layer and expansion ratio."
<< endl;
}
else if (haveFinal && haveTotal)
{
layerSpec_ = FINAL_AND_TOTAL;
Info<< "Layer thickness specified as final layer and overall thickness."
<< endl;
}
else if (haveFinal && haveExp)
{
layerSpec_ = FINAL_AND_EXPANSION;
Info<< "Layer thickness specified as final layer and expansion ratio."
<< endl;
}
if (layerSpec_ == ILLEGAL || nSpec != 2)
{
FatalIOErrorIn
(
"layerParameters::layerParameters"
"(const dictionary&, const polyBoundaryMesh&)",
dict
) << "Over- or underspecified layer thickness."
<< " Please specify" << nl
<< " first layer thickness ('firstLayerThickness')"
<< " and overall thickness ('thickness') or" << nl
<< " first layer thickness ('firstLayerThickness')"
<< " and expansion ratio ('expansionRatio') or" << nl
<< " final layer thickness ('finalLayerThickness')"
<< " and expansion ratio ('expansionRatio') or" << nl
<< " final layer thickness ('finalLayerThickness')"
<< " and overall thickness ('thickness')"
<< exit(FatalIOError);
}
dict.readIfPresent("nRelaxedIter", nRelaxedIter_); dict.readIfPresent("nRelaxedIter", nRelaxedIter_);
if (nLayerIter_ < 0 || nRelaxedIter_ < 0) if (nLayerIter_ < 0 || nRelaxedIter_ < 0)
{ {
FatalErrorIn("layerParameters::layerParameters(..)") FatalIOErrorIn("layerParameters::layerParameters(..)", dict)
<< "Layer iterations should be >= 0." << endl << "Layer iterations should be >= 0." << endl
<< "nLayerIter:" << nLayerIter_ << "nLayerIter:" << nLayerIter_
<< " nRelaxedIter:" << nRelaxedIter_ << " nRelaxedIter:" << nRelaxedIter_
<< exit(FatalError); << exit(FatalIOError);
} }
@ -130,7 +275,7 @@ Foam::layerParameters::layerParameters
{ {
if (iter().isDict()) if (iter().isDict())
{ {
const word& key = iter().keyword(); const keyType& key = iter().keyword();
const labelHashSet patchIDs const labelHashSet patchIDs
( (
boundaryMesh.patchSet(List<wordRe>(1, key)) boundaryMesh.patchSet(List<wordRe>(1, key))
@ -154,16 +299,69 @@ Foam::layerParameters::layerParameters
numLayers_[patchI] = numLayers_[patchI] =
readLabel(layerDict.lookup("nSurfaceLayers")); readLabel(layerDict.lookup("nSurfaceLayers"));
switch (layerSpec_)
{
case FIRST_AND_TOTAL:
layerDict.readIfPresent
(
"firstLayerThickness",
firstLayerThickness_[patchI]
);
layerDict.readIfPresent
(
"thickness",
thickness_[patchI]
);
break;
case FIRST_AND_EXPANSION:
layerDict.readIfPresent
(
"firstLayerThickness",
firstLayerThickness_[patchI]
);
layerDict.readIfPresent layerDict.readIfPresent
( (
"expansionRatio", "expansionRatio",
expansionRatio_[patchI] expansionRatio_[patchI]
); );
break;
case FINAL_AND_TOTAL:
layerDict.readIfPresent layerDict.readIfPresent
( (
"finalLayerThickness", "finalLayerThickness",
finalLayerThickness_[patchI] finalLayerThickness_[patchI]
); );
layerDict.readIfPresent
(
"thickness",
thickness_[patchI]
);
break;
case FINAL_AND_EXPANSION:
layerDict.readIfPresent
(
"finalLayerThickness",
finalLayerThickness_[patchI]
);
layerDict.readIfPresent
(
"expansionRatio",
expansionRatio_[patchI]
);
break;
default:
FatalIOErrorIn
(
"layerParameters::layerParameters(..)",
dict
) << "problem." << exit(FatalIOError);
break;
}
layerDict.readIfPresent layerDict.readIfPresent
( (
"minThickness", "minThickness",
@ -176,4 +374,190 @@ Foam::layerParameters::layerParameters
} }
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::scalar Foam::layerParameters::layerThickness
(
const label nLayers,
const scalar firstLayerThickess,
const scalar finalLayerThickess,
const scalar totalThickness,
const scalar expansionRatio
) const
{
switch (layerSpec_)
{
case FIRST_AND_TOTAL:
case FINAL_AND_TOTAL:
{
return totalThickness;
}
break;
case FIRST_AND_EXPANSION:
{
if (mag(expansionRatio-1) < SMALL)
{
return firstLayerThickess * nLayers;
}
else
{
return firstLayerThickess *
(1.0 - pow(expansionRatio, nLayers))
/ (1.0 - expansionRatio);
}
}
break;
case FINAL_AND_EXPANSION:
{
if (mag(expansionRatio-1) < SMALL)
{
return finalLayerThickess * nLayers;
}
else
{
scalar invExpansion = 1.0 / expansionRatio;
return finalLayerThickess *
(1.0 - pow(invExpansion, nLayers))
/ (1.0 - invExpansion);
}
}
break;
default:
{
FatalErrorIn("layerParameters::layerThickness(..)")
<< "Illegal thickness specification " << layerSpec_
<< exit(FatalError);
return -VGREAT;
}
}
}
Foam::scalar Foam::layerParameters::layerExpansionRatio
(
const label nLayers,
const scalar firstLayerThickess,
const scalar finalLayerThickess,
const scalar totalThickness,
const scalar expansionRatio
) const
{
switch (layerSpec_)
{
case FIRST_AND_EXPANSION:
case FINAL_AND_EXPANSION:
{
return expansionRatio;
}
break;
case FIRST_AND_TOTAL:
{
return layerExpansionRatio
(
nLayers,
totalThickness/firstLayerThickess
);
}
break;
case FINAL_AND_TOTAL:
{
return
1.0
/ layerExpansionRatio
(
nLayers,
totalThickness/finalLayerThickess
);
}
break;
default:
{
FatalErrorIn("layerParameters::layerThickness(..)")
<< "Illegal thickness specification" << exit(FatalError);
return -VGREAT;
}
}
}
Foam::scalar Foam::layerParameters::firstLayerThickness
(
const label nLayers,
const scalar firstLayerThickess,
const scalar finalLayerThickess,
const scalar totalThickness,
const scalar expansionRatio
) const
{
switch (layerSpec_)
{
case FIRST_AND_EXPANSION:
case FIRST_AND_TOTAL:
{
return firstLayerThickess;
}
case FINAL_AND_EXPANSION:
{
return finalLayerThickess*pow(1.0/expansionRatio, nLayers-1);
}
break;
case FINAL_AND_TOTAL:
{
scalar r = layerExpansionRatio
(
nLayers,
firstLayerThickess,
finalLayerThickess,
totalThickness,
expansionRatio
);
return finalLayerThickess/pow(r, nLayers-1);
}
break;
default:
{
FatalErrorIn("layerParameters::layerThickness(..)")
<< "Illegal thickness specification" << exit(FatalError);
return -VGREAT;
}
}
}
Foam::scalar Foam::layerParameters::finalLayerThicknessRatio
(
const label nLayers,
const scalar expansionRatio
) const
{
if (nLayers > 0)
{
if (mag(expansionRatio-1) < SMALL)
{
return 1.0/nLayers;
}
else
{
return
pow(expansionRatio, nLayers - 1)
* (1.0 - expansionRatio)
/ (1.0 - pow(expansionRatio, nLayers));
}
}
else
{
return 0.0;
}
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -55,6 +55,27 @@ class refinementSurfaces;
class layerParameters class layerParameters
{ {
public:
// Public data types
//- Enumeration defining the layer specification:
// - first and total thickness specified
// - first and expansion ratio specified
// - final and total thickness specified
// - final and expansion ratio specified
enum layerSpecification
{
ILLEGAL,
FIRST_AND_TOTAL,
FIRST_AND_EXPANSION,
FINAL_AND_TOTAL,
FINAL_AND_EXPANSION
};
private:
// Static data members // Static data members
//- Default angle for faces to be convcave //- Default angle for faces to be convcave
@ -68,12 +89,21 @@ class layerParameters
//- How many layers to add. //- How many layers to add.
labelList numLayers_; labelList numLayers_;
scalarField expansionRatio_; //- Are sizes relative to local cell size
Switch relativeSizes_; Switch relativeSizes_;
//- How thickness is specified.
layerSpecification layerSpec_;
scalarField firstLayerThickness_;
scalarField finalLayerThickness_; scalarField finalLayerThickness_;
scalarField thickness_;
scalarField expansionRatio_;
//- Minimum total thickness
scalarField minThickness_; scalarField minThickness_;
@ -111,6 +141,14 @@ class layerParameters
// Private Member Functions // Private Member Functions
//- Calculate expansion ratio from overall size v.s. thickness of
// first layer.
scalar layerExpansionRatio
(
const label n,
const scalar totalOverFirst
) const;
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
layerParameters(const layerParameters&); layerParameters(const layerParameters&);
@ -128,8 +166,6 @@ public:
// Member Functions // Member Functions
// Access
// Per patch information // Per patch information
//- How many layers to add. //- How many layers to add.
@ -142,12 +178,6 @@ public:
return numLayers_; return numLayers_;
} }
// Expansion factor for layer mesh
const scalarField& expansionRatio() const
{
return expansionRatio_;
}
//- Are size parameters relative to inner cell size or //- Are size parameters relative to inner cell size or
// absolute distances. // absolute distances.
bool relativeSizes() const bool relativeSizes() const
@ -155,9 +185,14 @@ public:
return relativeSizes_; return relativeSizes_;
} }
//- Wanted thickness of final added cell layer. If multiple // Expansion factor for layer mesh
// layers is the thickness of the layer furthest away const scalarField& expansionRatio() const
// from the wall (i.e. nearest the original mesh) {
return expansionRatio_;
}
//- Wanted thickness of the layer furthest away
// from the wall (i.e. nearest the original mesh).
// If relativeSize() this number is relative to undistorted // If relativeSize() this number is relative to undistorted
// size of the cell outside layer. // size of the cell outside layer.
const scalarField& finalLayerThickness() const const scalarField& finalLayerThickness() const
@ -165,7 +200,23 @@ public:
return finalLayerThickness_; return finalLayerThickness_;
} }
//- Minimum thickness of cell layer. If for any reason layer //- Wanted thickness of the layer nearest to the wall.
// If relativeSize() this number is relative to undistorted
// size of the cell outside layer.
const scalarField& firstLayerThickness() const
{
return firstLayerThickness_;
}
//- Wanted overall thickness of all layers.
// If relativeSize() this number is relative to undistorted
// size of the cell outside layer.
const scalarField& thickness() const
{
return thickness_;
}
//- Minimum overall thickness of cell layer. If for any reason layer
// cannot be above minThickness do not add layer. // cannot be above minThickness do not add layer.
// If relativeSize() this number is relative to undistorted // If relativeSize() this number is relative to undistorted
// size of the cell outside layer. // size of the cell outside layer.
@ -276,6 +327,48 @@ public:
} }
// Helper
//- Determine overall thickness. Uses two of the four parameters
// according to the layerSpecification
scalar layerThickness
(
const label nLayers,
const scalar firstLayerThickess,
const scalar finalLayerThickess,
const scalar totalThickness,
const scalar expansionRatio
) const;
//- Determine expansion ratio. Uses two of the four parameters
// according to the layerSpecification
scalar layerExpansionRatio
(
const label nLayers,
const scalar firstLayerThickess,
const scalar finalLayerThickess,
const scalar totalThickness,
const scalar expansionRatio
) const;
//- Determine first layer (near-wall) thickness. Uses two of the
// four parameters according to the layerSpecification
scalar firstLayerThickness
(
const label nLayers,
const scalar firstLayerThickess,
const scalar finalLayerThickess,
const scalar totalThickness,
const scalar expansionRatio
) const;
//- Determine ratio of final layer thickness to
// overall layer thickness
scalar finalLayerThicknessRatio
(
const label nLayers,
const scalar expansionRatio
) const;
}; };

View File

@ -36,7 +36,11 @@ Foam::snapParameters::snapParameters(const dictionary& dict)
nSnap_(readLabel(dict.lookup("nRelaxIter"))), nSnap_(readLabel(dict.lookup("nRelaxIter"))),
nFeatureSnap_(dict.lookupOrDefault("nFeatureSnapIter", -1)), nFeatureSnap_(dict.lookupOrDefault("nFeatureSnapIter", -1)),
explicitFeatureSnap_(dict.lookupOrDefault("explicitFeatureSnap", true)), explicitFeatureSnap_(dict.lookupOrDefault("explicitFeatureSnap", true)),
implicitFeatureSnap_(dict.lookupOrDefault("implicitFeatureSnap", false)) implicitFeatureSnap_(dict.lookupOrDefault("implicitFeatureSnap", false)),
multiRegionFeatureSnap_
(
dict.lookupOrDefault("multiRegionFeatureSnap", false)
)
{} {}

View File

@ -68,6 +68,8 @@ class snapParameters
const Switch implicitFeatureSnap_; const Switch implicitFeatureSnap_;
const Switch multiRegionFeatureSnap_;
// Private Member Functions // Private Member Functions
@ -134,6 +136,11 @@ public:
return implicitFeatureSnap_; return implicitFeatureSnap_;
} }
Switch multiRegionFeatureSnap() const
{
return multiRegionFeatureSnap_;
}
}; };

View File

@ -264,6 +264,14 @@ private:
label& nRefine label& nRefine
) const; ) const;
//- Mark cells for distance-to-feature based refinement.
label markInternalDistanceToFeatureRefinement
(
const label nAllowRefine,
labelList& refineCell,
label& nRefine
) const;
//- Mark cells for refinement-shells based refinement. //- Mark cells for refinement-shells based refinement.
label markInternalRefinement label markInternalRefinement
( (
@ -656,6 +664,7 @@ public:
const scalar curvature, const scalar curvature,
const bool featureRefinement, const bool featureRefinement,
const bool featureDistanceRefinement,
const bool internalRefinement, const bool internalRefinement,
const bool surfaceRefinement, const bool surfaceRefinement,
const bool curvatureRefinement, const bool curvatureRefinement,

View File

@ -290,7 +290,7 @@ Foam::label Foam::meshRefinement::markFeatureRefinement
forAll(features_, featI) forAll(features_, featI)
{ {
const featureEdgeMesh& featureMesh = features_[featI]; const featureEdgeMesh& featureMesh = features_[featI];
const label featureLevel = features_.levels()[featI]; const label featureLevel = features_.levels()[featI][0];
const labelListList& pointEdges = featureMesh.pointEdges(); const labelListList& pointEdges = featureMesh.pointEdges();
// Find regions on edgeMesh // Find regions on edgeMesh
@ -511,6 +511,90 @@ Foam::label Foam::meshRefinement::markFeatureRefinement
} }
// Mark cells for distance-to-feature based refinement.
Foam::label Foam::meshRefinement::markInternalDistanceToFeatureRefinement
(
const label nAllowRefine,
labelList& refineCell,
label& nRefine
) const
{
const labelList& cellLevel = meshCutter_.cellLevel();
const pointField& cellCentres = mesh_.cellCentres();
// Detect if there are any distance shells
if (features_.maxDistance() <= 0.0)
{
return 0;
}
label oldNRefine = nRefine;
// Collect cells to test
pointField testCc(cellLevel.size()-nRefine);
labelList testLevels(cellLevel.size()-nRefine);
label testI = 0;
forAll(cellLevel, cellI)
{
if (refineCell[cellI] == -1)
{
testCc[testI] = cellCentres[cellI];
testLevels[testI] = cellLevel[cellI];
testI++;
}
}
// Do test to see whether cells is inside/outside shell with higher level
labelList maxLevel;
features_.findHigherLevel(testCc, testLevels, maxLevel);
// Mark for refinement. Note that we didn't store the original cellID so
// now just reloop in same order.
testI = 0;
forAll(cellLevel, cellI)
{
if (refineCell[cellI] == -1)
{
if (maxLevel[testI] > testLevels[testI])
{
bool reachedLimit = !markForRefine
(
maxLevel[testI], // mark with any positive value
nAllowRefine,
refineCell[cellI],
nRefine
);
if (reachedLimit)
{
if (debug)
{
Pout<< "Stopped refining internal cells"
<< " since reaching my cell limit of "
<< mesh_.nCells()+7*nRefine << endl;
}
break;
}
}
testI++;
}
}
if
(
returnReduce(nRefine, sumOp<label>())
> returnReduce(nAllowRefine, sumOp<label>())
)
{
Info<< "Reached refinement limit." << endl;
}
return returnReduce(nRefine-oldNRefine, sumOp<label>());
}
// Mark cells for non-surface intersection based refinement. // Mark cells for non-surface intersection based refinement.
Foam::label Foam::meshRefinement::markInternalRefinement Foam::label Foam::meshRefinement::markInternalRefinement
( (
@ -1128,6 +1212,7 @@ Foam::labelList Foam::meshRefinement::refineCandidates
const scalar curvature, const scalar curvature,
const bool featureRefinement, const bool featureRefinement,
const bool featureDistanceRefinement,
const bool internalRefinement, const bool internalRefinement,
const bool surfaceRefinement, const bool surfaceRefinement,
const bool curvatureRefinement, const bool curvatureRefinement,
@ -1196,8 +1281,24 @@ Foam::labelList Foam::meshRefinement::refineCandidates
nRefine nRefine
); );
Info<< "Marked for refinement due to explicit features : " Info<< "Marked for refinement due to explicit features "
<< nFeatures << " cells." << endl; << ": " << nFeatures << " cells." << endl;
}
// Inside distance-to-feature shells
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (featureDistanceRefinement)
{
label nShell = markInternalDistanceToFeatureRefinement
(
nAllowRefine,
refineCell,
nRefine
);
Info<< "Marked for refinement due to distance to explicit features "
": " << nShell << " cells." << endl;
} }
// Inside refinement shells // Inside refinement shells
@ -1212,8 +1313,8 @@ Foam::labelList Foam::meshRefinement::refineCandidates
refineCell, refineCell,
nRefine nRefine
); );
Info<< "Marked for refinement due to refinement shells : " Info<< "Marked for refinement due to refinement shells "
<< nShell << " cells." << endl; << ": " << nShell << " cells." << endl;
} }
// Refinement based on intersection of surface // Refinement based on intersection of surface
@ -1230,8 +1331,8 @@ Foam::labelList Foam::meshRefinement::refineCandidates
refineCell, refineCell,
nRefine nRefine
); );
Info<< "Marked for refinement due to surface intersection : " Info<< "Marked for refinement due to surface intersection "
<< nSurf << " cells." << endl; << ": " << nSurf << " cells." << endl;
} }
// Refinement based on curvature of surface // Refinement based on curvature of surface
@ -1254,8 +1355,8 @@ Foam::labelList Foam::meshRefinement::refineCandidates
refineCell, refineCell,
nRefine nRefine
); );
Info<< "Marked for refinement due to curvature/regions : " Info<< "Marked for refinement due to curvature/regions "
<< nCurv << " cells." << endl; << ": " << nCurv << " cells." << endl;
} }
// Pack cells-to-refine // Pack cells-to-refine

View File

@ -25,6 +25,7 @@ License
#include "refinementFeatures.H" #include "refinementFeatures.H"
#include "Time.H" #include "Time.H"
#include "Tuple2.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -34,15 +35,15 @@ void Foam::refinementFeatures::read
const PtrList<dictionary>& featDicts const PtrList<dictionary>& featDicts
) )
{ {
forAll(featDicts, i) forAll(featDicts, featI)
{ {
const dictionary& dict = featDicts[i]; const dictionary& dict = featDicts[featI];
fileName featFileName(dict.lookup("file")); fileName featFileName(dict.lookup("file"));
set set
( (
i, featI,
new featureEdgeMesh new featureEdgeMesh
( (
IOobject IOobject
@ -58,15 +59,74 @@ void Foam::refinementFeatures::read
) )
); );
const featureEdgeMesh& eMesh = operator[](i); const featureEdgeMesh& eMesh = operator[](featI);
//eMesh.mergePoints(meshRefiner_.mergeDistance()); //eMesh.mergePoints(meshRefiner_.mergeDistance());
levels_[i] = readLabel(dict.lookup("level"));
Info<< "Refinement level " << levels_[i] if (dict.found("levels"))
<< " for all cells crossed by feature " << featFileName {
<< " (" << eMesh.points().size() << " points, " List<Tuple2<scalar, label> > distLevels(dict["levels"]);
if (dict.size() < 1)
{
FatalErrorIn
(
"refinementFeatures::read"
"(const objectRegistry&"
", const PtrList<dictionary>&)"
) << " : levels should be at least size 1" << endl
<< "levels : " << dict["levels"]
<< exit(FatalError);
}
distances_[featI].setSize(distLevels.size());
levels_[featI].setSize(distLevels.size());
forAll(distLevels, j)
{
distances_[featI][j] = distLevels[j].first();
levels_[featI][j] = distLevels[j].second();
// Check in incremental order
if (j > 0)
{
if
(
(distances_[featI][j] <= distances_[featI][j-1])
|| (levels_[featI][j] > levels_[featI][j-1])
)
{
FatalErrorIn
(
"refinementFeatures::read"
"(const objectRegistry&"
", const PtrList<dictionary>&)"
) << " : Refinement should be specified in order"
<< " of increasing distance"
<< " (and decreasing refinement level)." << endl
<< "Distance:" << distances_[featI][j]
<< " refinementLevel:" << levels_[featI][j]
<< exit(FatalError);
}
}
}
}
else
{
// Look up 'level' for single level
levels_[featI] = labelList(1, readLabel(dict.lookup("level")));
distances_[featI] = scalarField(1, 0.0);
}
Info<< "Refinement level according to distance to "
<< featFileName << " (" << eMesh.points().size() << " points, "
<< eMesh.edges().size() << " edges)." << endl; << eMesh.edges().size() << " edges)." << endl;
forAll(levels_[featI], j)
{
Info<< " level " << levels_[featI][j]
<< " for all cells within " << distances_[featI][j]
<< " meter." << endl;
}
} }
} }
@ -127,6 +187,80 @@ void Foam::refinementFeatures::buildTrees
} }
// Find maximum level of a shell.
void Foam::refinementFeatures::findHigherLevel
(
const pointField& pt,
const label featI,
labelList& maxLevel
) const
{
const labelList& levels = levels_[featI];
const scalarField& distances = distances_[featI];
// Collect all those points that have a current maxLevel less than
// (any of) the shell. Also collect the furthest distance allowable
// to any shell with a higher level.
pointField candidates(pt.size());
labelList candidateMap(pt.size());
scalarField candidateDistSqr(pt.size());
label candidateI = 0;
forAll(maxLevel, pointI)
{
forAllReverse(levels, levelI)
{
if (levels[levelI] > maxLevel[pointI])
{
candidates[candidateI] = pt[pointI];
candidateMap[candidateI] = pointI;
candidateDistSqr[candidateI] = sqr(distances[levelI]);
candidateI++;
break;
}
}
}
candidates.setSize(candidateI);
candidateMap.setSize(candidateI);
candidateDistSqr.setSize(candidateI);
// Do the expensive nearest test only for the candidate points.
const indexedOctree<treeDataEdge>& tree = edgeTrees_[featI];
List<pointIndexHit> nearInfo(candidates.size());
forAll(candidates, candidateI)
{
nearInfo[candidateI] = tree.findNearest
(
candidates[candidateI],
candidateDistSqr[candidateI]
);
}
// Update maxLevel
forAll(nearInfo, candidateI)
{
if (nearInfo[candidateI].hit())
{
// Check which level it actually is in.
label minDistI = findLower
(
distances,
mag(nearInfo[candidateI].hitPoint()-candidates[candidateI])
);
label pointI = candidateMap[candidateI];
// pt is inbetween shell[minDistI] and shell[minDistI+1]
maxLevel[pointI] = levels[minDistI+1];
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::refinementFeatures::refinementFeatures Foam::refinementFeatures::refinementFeatures
@ -136,6 +270,7 @@ Foam::refinementFeatures::refinementFeatures
) )
: :
PtrList<featureEdgeMesh>(featDicts.size()), PtrList<featureEdgeMesh>(featDicts.size()),
distances_(featDicts.size()),
levels_(featDicts.size()), levels_(featDicts.size()),
edgeTrees_(featDicts.size()), edgeTrees_(featDicts.size()),
pointTrees_(featDicts.size()) pointTrees_(featDicts.size())
@ -175,6 +310,7 @@ Foam::refinementFeatures::refinementFeatures
) )
: :
PtrList<featureEdgeMesh>(featDicts.size()), PtrList<featureEdgeMesh>(featDicts.size()),
distances_(featDicts.size()),
levels_(featDicts.size()), levels_(featDicts.size()),
edgeTrees_(featDicts.size()), edgeTrees_(featDicts.size()),
pointTrees_(featDicts.size()) pointTrees_(featDicts.size())
@ -336,4 +472,32 @@ void Foam::refinementFeatures::findNearestPoint
} }
void Foam::refinementFeatures::findHigherLevel
(
const pointField& pt,
const labelList& ptLevel,
labelList& maxLevel
) const
{
// Maximum level of any shell. Start off with level of point.
maxLevel = ptLevel;
forAll(*this, featI)
{
findHigherLevel(pt, featI, maxLevel);
}
}
Foam::scalar Foam::refinementFeatures::maxDistance() const
{
scalar overallMax = -GREAT;
forAll(distances_, featI)
{
overallMax = max(overallMax, max(distances_[featI]));
}
return overallMax;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -57,8 +57,11 @@ private:
// Private data // Private data
//- Refinement levels //- Per shell the list of ranges
labelList levels_; List<scalarField> distances_;
//- Per shell per distance the refinement level
labelListList levels_;
//- Edge //- Edge
PtrList<indexedOctree<treeDataEdge> > edgeTrees_; PtrList<indexedOctree<treeDataEdge> > edgeTrees_;
@ -75,6 +78,13 @@ private:
//- Build edge tree and feature point tree //- Build edge tree and feature point tree
void buildTrees(const label, const labelList&); void buildTrees(const label, const labelList&);
//- Find shell level higher than ptLevel
void findHigherLevel
(
const pointField& pt,
const label featI,
labelList& maxLevel
) const;
public: public:
@ -101,11 +111,18 @@ public:
// Access // Access
const labelList& levels() const //- Per featureEdgeMesh the list of level
const labelListList& levels() const
{ {
return levels_; return levels_;
} }
//- Per featureEdgeMesh the list of ranges
const List<scalarField>& distances() const
{
return distances_;
}
const PtrList<indexedOctree<treeDataEdge> >& edgeTrees() const const PtrList<indexedOctree<treeDataEdge> >& edgeTrees() const
{ {
return edgeTrees_; return edgeTrees_;
@ -119,6 +136,9 @@ public:
// Query // Query
//- Highest distance of all features
scalar maxDistance() const;
//- Find nearest point on nearest feature edge //- Find nearest point on nearest feature edge
void findNearestEdge void findNearestEdge
( (
@ -141,6 +161,14 @@ public:
labelList& nearIndex labelList& nearIndex
) const; ) const;
//- Find shell level higher than ptLevel
void findHigherLevel
(
const pointField& pt,
const labelList& ptLevel,
labelList& maxLevel
) const;
}; };

View File

@ -3,10 +3,10 @@ EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/chemistryModel/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/chemistryModel/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/solid/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/solidThermo/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/solidThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/solidChemistryModel/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/solidChemistryModel/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/radiationModels/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/radiationModels/lnInclude \
-I$(LIB_SRC)/turbulenceModels \ -I$(LIB_SRC)/turbulenceModels \
-I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel/lnInclude \ -I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel/lnInclude \
@ -20,12 +20,13 @@ LIB_LIBS = \
-lmeshTools \ -lmeshTools \
-lchemistryModel \ -lchemistryModel \
-lspecie \ -lspecie \
-lsolidSpecie \
-lfluidThermophysicalModels \ -lfluidThermophysicalModels \
-lsolidChemistryModel \ -lsolidChemistryModel \
-lsolidThermo \
-lcompressibleTurbulenceModel \ -lcompressibleTurbulenceModel \
-lcompressibleRASModels \ -lcompressibleRASModels \
-lcompressibleLESModels \ -lcompressibleLESModels \
-lLESdeltas \ -lLESdeltas \
-lregionModels \ -lregionModels \
-lradiationModels -lradiationModels \
-lreactionThermophysicalModels

View File

@ -1,7 +1,6 @@
EXE_INC = \ EXE_INC = \
-I$(LIB_SRC)/regionModels/regionModel/lnInclude \ -I$(LIB_SRC)/regionModels/regionModel/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/solidThermo/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/solidThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/solid/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \ -I$(LIB_SRC)/sampling/lnInclude \
@ -18,5 +17,4 @@ LIB_LIBS = \
-lfiniteVolume \ -lfiniteVolume \
-lmeshTools \ -lmeshTools \
-lOpenFOAM \ -lOpenFOAM \
-lsolidSpecie \
-lradiationModels -lradiationModels

View File

@ -18,6 +18,7 @@ sampledSet/sampledSets/sampledSetsGrouping.C
sampledSet/sampledSetsFunctionObject/sampledSetsFunctionObject.C sampledSet/sampledSetsFunctionObject/sampledSetsFunctionObject.C
sampledSet/triSurfaceMeshPointSet/triSurfaceMeshPointSet.C sampledSet/triSurfaceMeshPointSet/triSurfaceMeshPointSet.C
sampledSet/uniform/uniformSet.C sampledSet/uniform/uniformSet.C
sampledSet/array/arraySet.C
setWriters = sampledSet/writers setWriters = sampledSet/writers

View File

@ -0,0 +1,195 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "arraySet.H"
#include "sampledSet.H"
#include "meshSearch.H"
#include "DynamicList.H"
#include "polyMesh.H"
#include "addToRunTimeSelectionTable.H"
#include "word.H"
#include "transform.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(arraySet, 0);
addToRunTimeSelectionTable(sampledSet, arraySet, word);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::arraySet::calcSamples
(
DynamicList<point>& samplingPts,
DynamicList<label>& samplingCells,
DynamicList<label>& samplingFaces,
DynamicList<label>& samplingSegments,
DynamicList<scalar>& samplingCurveDist
) const
{
const meshSearch& queryMesh = searchEngine();
label nTotalSamples
(
pointsDensity_.x()
*pointsDensity_.y()
*pointsDensity_.z()
);
List<point> sampleCoords(nTotalSamples);
const scalar deltax = spanBox_.x()/(pointsDensity_.x() + 1);
const scalar deltay = spanBox_.y()/(pointsDensity_.y() + 1);
const scalar deltaz = spanBox_.z()/(pointsDensity_.z() + 1);
label p(0);
for (label k=1; k<=pointsDensity_.z(); k++)
{
for (label j=1; j<=pointsDensity_.y(); j++)
{
for (label i=1; i<=pointsDensity_.x(); i++)
{
vector t(deltax*i , deltay*j, deltaz*k);
sampleCoords[p] = coordSys_.origin() + t;
p++;
}
}
}
forAll(sampleCoords, i)
{
sampleCoords[i] = transform(coordSys_.R(), sampleCoords[i]);
}
forAll(sampleCoords, sampleI)
{
label cellI = queryMesh.findCell(sampleCoords[sampleI]);
if (cellI != -1)
{
samplingPts.append(sampleCoords[sampleI]);
samplingCells.append(cellI);
samplingFaces.append(-1);
samplingSegments.append(0);
samplingCurveDist.append(1.0 * sampleI);
}
}
}
void Foam::arraySet::genSamples()
{
// Storage for sample points
DynamicList<point> samplingPts;
DynamicList<label> samplingCells;
DynamicList<label> samplingFaces;
DynamicList<label> samplingSegments;
DynamicList<scalar> samplingCurveDist;
calcSamples
(
samplingPts,
samplingCells,
samplingFaces,
samplingSegments,
samplingCurveDist
);
samplingPts.shrink();
samplingCells.shrink();
samplingFaces.shrink();
samplingSegments.shrink();
samplingCurveDist.shrink();
setSamples
(
samplingPts,
samplingCells,
samplingFaces,
samplingSegments,
samplingCurveDist
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::arraySet::arraySet
(
const word& name,
const polyMesh& mesh,
const meshSearch& searchEngine,
const word& axis,
const coordinateSystem& origin,
const Vector<label>& pointsDensity,
const Vector<scalar>& spanBox
)
:
sampledSet(name, mesh, searchEngine, axis),
coordSys_(origin),
pointsDensity_(pointsDensity),
spanBox_(spanBox)
{
genSamples();
if (debug)
{
write(Info);
}
}
Foam::arraySet::arraySet
(
const word& name,
const polyMesh& mesh,
const meshSearch& searchEngine,
const dictionary& dict
)
:
sampledSet(name, mesh, searchEngine, dict),
coordSys_(dict),
pointsDensity_(dict.lookup("pointsDensity")),
spanBox_(dict.lookup("spanBox"))
{
genSamples();
if (debug)
{
write(Info);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::arraySet::~arraySet()
{}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -22,103 +22,99 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::IrreversibleSolidReaction Foam::arraySet
Description Description
Simple extension of Reaction to handle reversible reactions
SourceFiles SourceFiles
IrreversibleSolidReaction.C arraySet.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef IrreversibleSolidReaction_H #ifndef arraySet_H
#define IrreversibleSolidReaction_H #define arraySet_H
#include "solidReaction.H" #include "sampledSet.H"
#include "DynamicList.H"
#include "coordinateSystem.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
// Forward declaration of classes
class passiveParticle;
template<class Type> class particle;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class IrreversibleSolidReaction Declaration Class arraySet Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class ReactionRate> class arraySet
class IrreversibleSolidReaction
: :
public solidReaction public sampledSet
{ {
// Private data // Private data
// Reaction rate //- Coordinate syste
ReactionRate k_; coordinateSystem coordSys_;
// Reaction order //- Point density vector
scalar nReact_; Vector<label> pointsDensity_;
//- Span box
Vector<scalar> spanBox_;
// Private Member Functions // Private Member Functions
//- Disallow default bitwise assignment //- Samples all points in sampleCoords.
void operator= void calcSamples
( (
const IrreversibleSolidReaction<ReactionRate>& DynamicList<point>& samplingPts,
); DynamicList<label>& samplingCells,
DynamicList<label>& samplingFaces,
DynamicList<label>& samplingSegments,
DynamicList<scalar>& samplingCurveDist
) const;
//- Uses calcSamples to obtain samples. Copies them into *this.
void genSamples();
public: public:
//- Runtime type information //- Runtime type information
TypeName("irreversible"); TypeName("array");
// Constructors // Constructors
//- Construct from components //- Construct from components
IrreversibleSolidReaction arraySet
( (
const solidReaction& reaction, const word& name,
const ReactionRate& reactionRate, const polyMesh& mesh,
const scalar nReact const meshSearch& searchEngine,
const word& axis,
const coordinateSystem& coordSys,
const Vector<label>& pointsDensity,
const Vector<scalar>& spanBox
); );
//- Construct from dictionary
//- Construct from Istream arraySet
IrreversibleSolidReaction
( (
const speciesTable& components, const word& name,
Istream& is, const polyMesh& mesh,
const speciesTable& pyrolysisGases const meshSearch& searchEngine,
const dictionary& dict
); );
//- Destructor //- Destructor
virtual ~IrreversibleSolidReaction() virtual ~arraySet();
{}
// Member Functions
// IrreversibleSolidReaction rate coefficients
//- Forward rate constant
virtual scalar kf
(
const scalar p,
const scalar T,
const scalarField& c
) const;
//- Reaction order
virtual scalar nReact() const;
//- Write
virtual void write(Ostream&) const;
}; };
@ -128,12 +124,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "IrreversibleSolidReaction.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -164,17 +164,19 @@ void Foam::sampledSurfaces::write()
writeGeometry(); writeGeometry();
} }
sampleAndWrite<volScalarField>(mesh_); const IOobjectList objects(mesh_, mesh_.time().timeName());
sampleAndWrite<volVectorField>(mesh_);
sampleAndWrite<volSphericalTensorField>(mesh_);
sampleAndWrite<volSymmTensorField>(mesh_);
sampleAndWrite<volTensorField>(mesh_);
sampleAndWrite<surfaceScalarField>(mesh_); sampleAndWrite<volScalarField>(objects);
sampleAndWrite<surfaceVectorField>(mesh_); sampleAndWrite<volVectorField>(objects);
sampleAndWrite<surfaceSphericalTensorField>(mesh_); sampleAndWrite<volSphericalTensorField>(objects);
sampleAndWrite<surfaceSymmTensorField>(mesh_); sampleAndWrite<volSymmTensorField>(objects);
sampleAndWrite<surfaceTensorField>(mesh_); sampleAndWrite<volTensorField>(objects);
sampleAndWrite<surfaceScalarField>(objects);
sampleAndWrite<surfaceVectorField>(objects);
sampleAndWrite<surfaceSphericalTensorField>(objects);
sampleAndWrite<surfaceSymmTensorField>(objects);
sampleAndWrite<surfaceTensorField>(objects);
} }
} }

View File

@ -160,7 +160,7 @@ class sampledSurfaces
//- Sample and write all sampled fields //- Sample and write all sampled fields
template<class Type> template<class Type>
void sampleAndWrite(const fvMesh&); void sampleAndWrite(const IOobjectList&);
//- Disallow default bitwise copy construct and assignment //- Disallow default bitwise copy construct and assignment
sampledSurfaces(const sampledSurfaces&); sampledSurfaces(const sampledSurfaces&);

View File

@ -166,13 +166,18 @@ void Foam::sampledSurfaces::sampleAndWrite
template<class GeoField> template<class GeoField>
void Foam::sampledSurfaces::sampleAndWrite(const fvMesh& mesh) void Foam::sampledSurfaces::sampleAndWrite(const IOobjectList& allObjects)
{ {
forAll (fieldSelection_, fieldI) forAll (fieldSelection_, fieldI)
{ {
const wordRe field = fieldSelection_[fieldI]; const wordRe field = fieldSelection_[fieldI];
IOobject* fieldIOPtr = allObjects.lookup(field);
if (mesh.thisDb().foundObject<GeoField>(field)) if
(
fieldIOPtr != NULL
&& fieldIOPtr->headerClassName() == GeoField::typeName
)
{ {
if (Pstream::master() && verbose_) if (Pstream::master() && verbose_)
{ {
@ -181,17 +186,25 @@ void Foam::sampledSurfaces::sampleAndWrite(const fvMesh& mesh)
if (loadFromFiles_) if (loadFromFiles_)
{ {
const GeoField& geoField = const GeoField geoField
mesh.thisDb().lookupObject<GeoField>(field); (
IOobject
(
field,
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ
),
mesh_
);
const_cast<GeoField&>(geoField).readOpt() = IOobject::MUST_READ;
sampleAndWrite(geoField); sampleAndWrite(geoField);
} }
else else
{ {
sampleAndWrite sampleAndWrite
( (
mesh.thisDb().lookupObject<GeoField>(field) mesh_.thisDb().lookupObject<GeoField>(field)
); );
} }
} }

View File

@ -4,6 +4,7 @@ makeType=${1:-libso}
set -x set -x
wmake $makeType specie wmake $makeType specie
wmake $makeType solidSpecie
wmake $makeType thermophysicalFunctions wmake $makeType thermophysicalFunctions
./properties/Allwmake $* ./properties/Allwmake $*
@ -14,7 +15,7 @@ wmake $makeType chemistryModel
wmake $makeType barotropicCompressibilityModel wmake $makeType barotropicCompressibilityModel
wmake $makeType SLGThermo wmake $makeType SLGThermo
wmake $makeType solidSpecie
wmake $makeType solidThermo wmake $makeType solidThermo
wmake $makeType solidChemistryModel wmake $makeType solidChemistryModel

View File

@ -87,6 +87,27 @@ public:
return mixture_; return mixture_;
} }
const ThermoType& cellVolMixture
(
const scalar,
const scalar,
const label
) const
{
return mixture_;
}
const ThermoType& patchFaceVolMixture
(
const scalar,
const scalar,
const label,
const label
) const
{
return mixture_;
}
//- Read dictionary //- Read dictionary
void read(const dictionary&); void read(const dictionary&);
}; };

View File

@ -27,7 +27,7 @@ License
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "unitConversion.H" #include "unitConversion.H"
#include "zeroGradientFvPatchFields.H" #include "zeroGradientFvPatchFields.H"
#include "basicSolidMixture.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -71,7 +71,7 @@ greyMeanSolidAbsorptionEmission::X(const word specie) const
} }
} }
const scalarField& Yj = mixture_.Y(specie); const scalarField& Yj = mixture_.Y(specie);
const label mySpecieI = mixture_.components()[specie]; const label mySpecieI = mixture_.species()[specie];
forAll(Xj, iCell) forAll(Xj, iCell)
{ {
Xj[iCell] = Yj[iCell]/mixture_.rho(mySpecieI, p[iCell], T[iCell]); Xj[iCell] = Yj[iCell]/mixture_.rho(mySpecieI, p[iCell], T[iCell]);
@ -93,10 +93,10 @@ greyMeanSolidAbsorptionEmission
coeffsDict_((dict.subDict(typeName + "Coeffs"))), coeffsDict_((dict.subDict(typeName + "Coeffs"))),
thermo_(mesh.lookupObject<solidThermo>("thermophysicalProperties")), thermo_(mesh.lookupObject<solidThermo>("thermophysicalProperties")),
speciesNames_(0), speciesNames_(0),
mixture_(dynamic_cast<const basicSolidMixture&>(thermo_)), mixture_(dynamic_cast<const basicMultiComponentMixture&>(thermo_)),
solidData_(mixture_.Y().size()) solidData_(mixture_.Y().size())
{ {
if (!isA<basicSolidMixture>(thermo_)) if (!isA<basicMultiComponentMixture>(thermo_))
{ {
FatalErrorIn FatalErrorIn
( (

View File

@ -90,7 +90,7 @@ private:
HashTable<label> speciesNames_; HashTable<label> speciesNames_;
//- Basic multicomponent mixture //- Basic multicomponent mixture
const basicSolidMixture& mixture_; const basicMultiComponentMixture& mixture_;
//- List of solid species data //- List of solid species data
List<FixedList<scalar, 2> > solidData_; List<FixedList<scalar, 2> > solidData_;

View File

@ -2,10 +2,13 @@ EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/solidSpecie/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude -I$(LIB_SRC)/meshTools/lnInclude
LIB_LIBS = \ LIB_LIBS = \
-lfiniteVolume \ -lfiniteVolume \
-lfluidThermophysicalModels \ -lfluidThermophysicalModels \
-lspecie \ -lspecie \
-lsolidSpecie \
-lmeshTools -lmeshTools

View File

@ -25,6 +25,7 @@ License
#include "makeReactionThermo.H" #include "makeReactionThermo.H"
#include "thermoPhysicsTypes.H" #include "thermoPhysicsTypes.H"
#include "solidThermoPhysicsTypes.H"
#include "chemistryReader.H" #include "chemistryReader.H"
#include "foamChemistryReader.H" #include "foamChemistryReader.H"
@ -41,6 +42,8 @@ makeChemistryReader(gasThermoPhysics);
makeChemistryReader(constIncompressibleGasThermoPhysics); makeChemistryReader(constIncompressibleGasThermoPhysics);
makeChemistryReader(incompressibleGasThermoPhysics); makeChemistryReader(incompressibleGasThermoPhysics);
makeChemistryReader(icoPoly8ThermoPhysics); makeChemistryReader(icoPoly8ThermoPhysics);
makeChemistryReader(hConstSolidThermoPhysics);
makeChemistryReader(hExponentialSolidThermoPhysics);
makeChemistryReaderType(foamChemistryReader, constGasThermoPhysics); makeChemistryReaderType(foamChemistryReader, constGasThermoPhysics);
makeChemistryReaderType(foamChemistryReader, gasThermoPhysics); makeChemistryReaderType(foamChemistryReader, gasThermoPhysics);
@ -51,6 +54,8 @@ makeChemistryReaderType
); );
makeChemistryReaderType(foamChemistryReader, incompressibleGasThermoPhysics); makeChemistryReaderType(foamChemistryReader, incompressibleGasThermoPhysics);
makeChemistryReaderType(foamChemistryReader, icoPoly8ThermoPhysics); makeChemistryReaderType(foamChemistryReader, icoPoly8ThermoPhysics);
makeChemistryReaderType(foamChemistryReader, hConstSolidThermoPhysics);
makeChemistryReaderType(foamChemistryReader, hExponentialSolidThermoPhysics);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -41,6 +41,7 @@ License
#include "powerSeriesReactionRate.H" #include "powerSeriesReactionRate.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
/* * * * * * * * * * * * * * * * * Static data * * * * * * * * * * * * * * * */ /* * * * * * * * * * * * * * * * * Static data * * * * * * * * * * * * * * * */
namespace Foam namespace Foam
@ -178,7 +179,8 @@ void Foam::chemkinReader::addReactionType
{ {
reactions_.append reactions_.append
( (
new IrreversibleReaction<gasThermoPhysics, ReactionRateType> new IrreversibleReaction
<Reaction, gasThermoPhysics, ReactionRateType>
( (
Reaction<gasThermoPhysics> Reaction<gasThermoPhysics>
( (
@ -197,7 +199,8 @@ void Foam::chemkinReader::addReactionType
{ {
reactions_.append reactions_.append
( (
new ReversibleReaction<gasThermoPhysics, ReactionRateType> new ReversibleReaction
<Reaction, gasThermoPhysics, ReactionRateType>
( (
Reaction<gasThermoPhysics> Reaction<gasThermoPhysics>
( (
@ -496,7 +499,7 @@ void Foam::chemkinReader::addReaction
reactions_.append reactions_.append
( (
new NonEquilibriumReversibleReaction new NonEquilibriumReversibleReaction
<gasThermoPhysics, ArrheniusReactionRate> <Reaction, gasThermoPhysics, ArrheniusReactionRate>
( (
Reaction<gasThermoPhysics> Reaction<gasThermoPhysics>
( (
@ -549,7 +552,11 @@ void Foam::chemkinReader::addReaction
reactions_.append reactions_.append
( (
new NonEquilibriumReversibleReaction new NonEquilibriumReversibleReaction
<gasThermoPhysics, thirdBodyArrheniusReactionRate> <
Reaction,
gasThermoPhysics,
thirdBodyArrheniusReactionRate
>
( (
Reaction<gasThermoPhysics> Reaction<gasThermoPhysics>
( (
@ -654,7 +661,7 @@ void Foam::chemkinReader::addReaction
reactions_.append reactions_.append
( (
new NonEquilibriumReversibleReaction new NonEquilibriumReversibleReaction
<gasThermoPhysics, LandauTellerReactionRate> <Reaction, gasThermoPhysics, LandauTellerReactionRate>
( (
Reaction<gasThermoPhysics> Reaction<gasThermoPhysics>
( (

View File

@ -77,7 +77,8 @@ Foam::multiComponentMixture<ThermoType>::multiComponentMixture
: :
basicMultiComponentMixture(thermoDict, specieNames, mesh), basicMultiComponentMixture(thermoDict, specieNames, mesh),
speciesData_(species_.size()), speciesData_(species_.size()),
mixture_("mixture", *thermoData[specieNames[0]]) mixture_("mixture", *thermoData[specieNames[0]]),
mixtureVol_("volMixture", *thermoData[specieNames[0]])
{ {
forAll(species_, i) forAll(species_, i)
{ {
@ -101,7 +102,8 @@ Foam::multiComponentMixture<ThermoType>::multiComponentMixture
: :
basicMultiComponentMixture(thermoDict, thermoDict.lookup("species"), mesh), basicMultiComponentMixture(thermoDict, thermoDict.lookup("species"), mesh),
speciesData_(species_.size()), speciesData_(species_.size()),
mixture_("mixture", constructSpeciesData(thermoDict)) mixture_("mixture", constructSpeciesData(thermoDict)),
mixtureVol_("volMixture", speciesData_[0])
{ {
correctMassFractions(); correctMassFractions();
} }
@ -148,6 +150,65 @@ const ThermoType& Foam::multiComponentMixture<ThermoType>::patchFaceMixture
} }
template<class ThermoType>
const ThermoType& Foam::multiComponentMixture<ThermoType>::cellVolMixture
(
const scalar p,
const scalar T,
const label celli
) const
{
scalar rhoInv = 0.0;
forAll(speciesData_, i)
{
rhoInv += Y_[i][celli]/speciesData_[i].rho(p, T);
}
mixtureVol_ =
Y_[0][celli]/speciesData_[0].rho(p, T)/rhoInv*speciesData_[0];
for (label n=1; n<Y_.size(); n++)
{
mixtureVol_ +=
Y_[n][celli]/speciesData_[n].rho(p, T)/rhoInv*speciesData_[n];
}
return mixtureVol_;
}
template<class ThermoType>
const ThermoType& Foam::multiComponentMixture<ThermoType>::
patchFaceVolMixture
(
const scalar p,
const scalar T,
const label patchi,
const label facei
) const
{
scalar rhoInv = 0.0;
forAll(speciesData_, i)
{
rhoInv +=
Y_[i].boundaryField()[patchi][facei]/speciesData_[i].rho(p, T);
}
mixtureVol_ =
Y_[0].boundaryField()[patchi][facei]/speciesData_[0].rho(p, T)/rhoInv
* speciesData_[0];
for (label n=1; n<Y_.size(); n++)
{
mixtureVol_ +=
Y_[n].boundaryField()[patchi][facei]/speciesData_[n].rho(p,T)
/ rhoInv*speciesData_[n];
}
return mixtureVol_;
}
template<class ThermoType> template<class ThermoType>
void Foam::multiComponentMixture<ThermoType>::read void Foam::multiComponentMixture<ThermoType>::read
( (

View File

@ -60,6 +60,10 @@ class multiComponentMixture
//- Temporary storage for the cell/face mixture thermo data //- Temporary storage for the cell/face mixture thermo data
mutable ThermoType mixture_; mutable ThermoType mixture_;
//- Temporary storage for the volume weighted
// cell/face mixture thermo data
mutable ThermoType mixtureVol_;
// Private Member Functions // Private Member Functions
@ -110,6 +114,21 @@ public:
const label facei const label facei
) const; ) const;
const ThermoType& cellVolMixture
(
const scalar p,
const scalar T,
const label celli
) const;
const ThermoType& patchFaceVolMixture
(
const scalar p,
const scalar T,
const label patchi,
const label facei
) const;
//- Return the raw specie thermodynamic data //- Return the raw specie thermodynamic data
const PtrList<ThermoType>& speciesData() const const PtrList<ThermoType>& speciesData() const
{ {

View File

@ -1,10 +1,11 @@
EXE_INC = \ EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/solidSpecie/lnInclude \
-I$(LIB_SRC)/ODE/lnInclude \ -I$(LIB_SRC)/ODE/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/chemistryModel/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/chemistryModel/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/solidSpecie/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/solidThermo/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/solidThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude -I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude
@ -12,4 +13,5 @@ EXE_INC = \
LIB_LIBS = \ LIB_LIBS = \
-lchemistryModel \ -lchemistryModel \
-lfiniteVolume \ -lfiniteVolume \
-lODE -lODE\
-lreactionThermophysicalModels

View File

@ -24,7 +24,8 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "ODESolidChemistryModel.H" #include "ODESolidChemistryModel.H"
#include "reactingSolidMixture.H" #include "reactingMixture.H"
#include "solidReaction.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -38,24 +39,20 @@ ODESolidChemistryModel
CompType(mesh), CompType(mesh),
ODE(), ODE(),
Ys_(this->solidThermo().composition().Y()), Ys_(this->solidThermo().composition().Y()),
pyrolisisGases_
(
mesh.lookupObject<dictionary>
("thermophysicalProperties").lookup("gaseousSpecies")
),
reactions_ reactions_
( (
dynamic_cast<const reactingSolidMixture<SolidThermo>& > dynamic_cast<const reactingMixture<SolidThermo>& >
( (
this->solidThermo() this->solidThermo()
) )
), ),
pyrolisisGases_(reactions_[0].gasSpecies()),
solidThermo_ solidThermo_
( (
dynamic_cast<const reactingSolidMixture<SolidThermo>& > dynamic_cast<const reactingMixture<SolidThermo>& >
( (
this->solidThermo() this->solidThermo()
).solidData() ).speciesData()
), ),
gasThermo_(pyrolisisGases_.size()), gasThermo_(pyrolisisGases_.size()),
nGases_(pyrolisisGases_.size()), nGases_(pyrolisisGases_.size()),
@ -184,7 +181,7 @@ ODESolidChemistryModel
mesh.lookupObject<dictionary> mesh.lookupObject<dictionary>
( (
"thermophysicalProperties" "thermophysicalProperties"
).subDict(pyrolisisGases_[gasI] + "Coeffs"); ).subDict(pyrolisisGases_[gasI]);
gasThermo_.set gasThermo_.set
( (
@ -193,14 +190,13 @@ ODESolidChemistryModel
); );
} }
Info<< "ODESolidChemistryModel: Number of solids = " << nSolids_ Info<< "solidChemistryModel: Number of solids = " << nSolids_ << endl;
<< " and reactions = " << nReaction_ << endl;
Info<< "Number of gases from pyrolysis = " << nGases_ << endl; Info<< "solidChemistryModel: Number of gases = " << nGases_ << endl;
forAll(reactions_, i) forAll(reactions_, i)
{ {
Info<< indent << "Reaction " << i << nl << reactions_[i] << nl; Info<< indent << reactions_[i] << nl;
} }
} }
@ -235,23 +231,23 @@ ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::omega
forAll(reactions_, i) forAll(reactions_, i)
{ {
const solidReaction& R = reactions_[i]; const Reaction<SolidThermo>& R = reactions_[i];
scalar omegai = omega scalar omegai = omega
( (
R, c, T, p, pf, cf, lRef, pr, cr, rRef R, c, T, p, pf, cf, lRef, pr, cr, rRef
); );
scalar rhoL = 0.0; scalar rhoL = 0.0;
forAll(R.slhs(), s) forAll(R.lhs(), s)
{ {
label si = R.slhs()[s]; label si = R.lhs()[s].index;
om[si] -= omegai; om[si] -= omegai;
rhoL = solidThermo_[si].rho(p, T); rhoL = solidThermo_[si].rho(p, T);
} }
scalar sr = 0.0; scalar sr = 0.0;
forAll(R.srhs(), s) forAll(R.rhs(), s)
{ {
label si = R.srhs()[s]; label si = R.rhs()[s].index;
scalar rhoR = solidThermo_[si].rho(p, T); scalar rhoR = solidThermo_[si].rho(p, T);
sr = rhoR/rhoL; sr = rhoR/rhoL;
om[si] += sr*omegai; om[si] += sr*omegai;
@ -263,7 +259,7 @@ ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::omega
} }
forAll(R.grhs(), g) forAll(R.grhs(), g)
{ {
label gi = R.grhs()[g]; label gi = R.grhs()[g].index;
om[gi + nSolids_] += (1.0 - sr)*omegai; om[gi + nSolids_] += (1.0 - sr)*omegai;
} }
} }
@ -276,7 +272,7 @@ template<class CompType, class SolidThermo, class GasThermo>
Foam::scalar Foam::scalar
Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::omega Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::omega
( (
const solidReaction& R, const Reaction<SolidThermo>& R,
const scalarField& c, const scalarField& c,
const scalar T, const scalar T,
const scalar p, const scalar p,
@ -299,16 +295,17 @@ Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::omega
scalar kf = R.kf(p, T, c1); scalar kf = R.kf(p, T, c1);
const scalar exponent = R.nReact(); //const scalar exponent = R.nReact();
const label Nl = R.slhs().size(); const label Nl = R.lhs().size();
for (label s=0; s<Nl; s++) for (label s=0; s<Nl; s++)
{ {
label si = R.slhs()[s]; label si = R.lhs()[s].index;
const scalar exp = R.lhs()[si].exponent;
kf *= kf *=
pow(c1[si]/Ys0_[si][cellI], exponent) pow(c1[si]/Ys0_[si][cellI], exp)
*(Ys0_[si][cellI]); *(Ys0_[si][cellI]);
} }
@ -390,18 +387,18 @@ void Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::jacobian
for (label ri=0; ri<reactions_.size(); ri++) for (label ri=0; ri<reactions_.size(); ri++)
{ {
const solidReaction& R = reactions_[ri]; const Reaction<SolidThermo>& R = reactions_[ri];
scalar kf0 = R.kf(p, T, c2); scalar kf0 = R.kf(p, T, c2);
forAll(R.slhs(), j) forAll(R.lhs(), j)
{ {
label sj = R.slhs()[j]; label sj = R.lhs()[j].index;
scalar kf = kf0; scalar kf = kf0;
forAll(R.slhs(), i) forAll(R.lhs(), i)
{ {
label si = R.slhs()[i]; label si = R.lhs()[i].index;
scalar exp = R.nReact(); scalar exp = R.lhs()[i].exponent;
if (i == j) if (i == j)
{ {
if (exp < 1.0) if (exp < 1.0)
@ -428,14 +425,14 @@ void Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::jacobian
} }
} }
forAll(R.slhs(), i) forAll(R.lhs(), i)
{ {
label si = R.slhs()[i]; label si = R.lhs()[i].index;
dfdc[si][sj] -= kf; dfdc[si][sj] -= kf;
} }
forAll(R.srhs(), i) forAll(R.rhs(), i)
{ {
label si = R.srhs()[i]; label si = R.rhs()[i].index;
dfdc[si][sj] += kf; dfdc[si][sj] += kf;
} }
} }
@ -551,7 +548,8 @@ ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::nEqns() const
template<class CompType, class SolidThermo, class GasThermo> template<class CompType, class SolidThermo, class GasThermo>
void Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::calculate() void Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::
calculate()
{ {
if (!this->chemistry_) if (!this->chemistry_)
{ {

View File

@ -38,7 +38,7 @@ SourceFiles
#ifndef ODESolidChemistryModel_H #ifndef ODESolidChemistryModel_H
#define ODESolidChemistryModel_H #define ODESolidChemistryModel_H
#include "solidReaction.H" #include "Reaction.H"
#include "ODE.H" #include "ODE.H"
#include "volFieldsFwd.H" #include "volFieldsFwd.H"
#include "DimensionedField.H" #include "DimensionedField.H"
@ -72,12 +72,12 @@ protected:
//- Reference to solid mass fractions //- Reference to solid mass fractions
PtrList<volScalarField>& Ys_; PtrList<volScalarField>& Ys_;
//- Reactions
const PtrList<Reaction<SolidThermo> >& reactions_;
//- List of gas species present in reaction system //- List of gas species present in reaction system
speciesTable pyrolisisGases_; speciesTable pyrolisisGases_;
//- Reactions
const PtrList<solidReaction>& reactions_;
//- Thermodynamic data of solids //- Thermodynamic data of solids
const PtrList<SolidThermo>& solidThermo_; const PtrList<SolidThermo>& solidThermo_;
@ -149,7 +149,7 @@ public:
// Member Functions // Member Functions
//- The reactions //- The reactions
inline const PtrList<solidReaction>& reactions() const; inline const PtrList<Reaction<SolidThermo> >& reactions() const;
//- Thermodynamic data of gases //- Thermodynamic data of gases
inline const PtrList<GasThermo>& gasThermo() const; inline const PtrList<GasThermo>& gasThermo() const;
@ -180,7 +180,7 @@ public:
// species and charateristic times // species and charateristic times
virtual scalar omega virtual scalar omega
( (
const solidReaction& r, const Reaction<SolidThermo>& r,
const scalarField& c, const scalarField& c,
const scalar T, const scalar T,
const scalar p, const scalar p,

View File

@ -45,7 +45,7 @@ Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::RRg()
template<class CompType, class SolidThermo, class GasThermo> template<class CompType, class SolidThermo, class GasThermo>
inline const Foam::PtrList<Foam::solidReaction>& inline const Foam::PtrList<Foam::Reaction<SolidThermo> >&
Foam::ODESolidChemistryModel<CompType, SolidThermo,GasThermo>::reactions() const Foam::ODESolidChemistryModel<CompType, SolidThermo,GasThermo>::reactions() const
{ {
return reactions_; return reactions_;

View File

@ -51,6 +51,7 @@ namespace Foam
hExponentialSolidThermoPhysics, hExponentialSolidThermoPhysics,
gasThermoPhysics gasThermoPhysics
) )
} }

View File

@ -1,4 +1,3 @@
reaction/Reactions/solidReaction/solidReaction.C
reaction/reactions/makeSolidReactions.C reaction/reactions/makeSolidReactions.C
LIB = $(FOAM_LIBBIN)/libsolidSpecie LIB = $(FOAM_LIBBIN)/libsolidSpecie

View File

@ -1,2 +1,5 @@
EXE_INC = \ EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude
LIB_LIBS = \
-lspecie

View File

@ -1,92 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "IrreversibleSolidReaction.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class ReactionRate>
Foam::IrreversibleSolidReaction<ReactionRate>::IrreversibleSolidReaction
(
const solidReaction& reaction,
const ReactionRate& k,
const scalar nReact
)
:
solidReaction(reaction),
k_(k),
nReact_(nReact)
{}
template<class ReactionRate>
Foam::IrreversibleSolidReaction<ReactionRate>::IrreversibleSolidReaction
(
const speciesTable& components,
Istream& is,
const speciesTable& pyrolysisGases
)
:
solidReaction(components, is, pyrolysisGases),
k_(components, is),
nReact_(readScalar(is))
{
is.readEnd("solidArrheniusReactionRate(Istream&)");
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class ReactionRate>
Foam::scalar Foam::IrreversibleSolidReaction<ReactionRate>::kf
(
const scalar p,
const scalar T,
const scalarField& c
) const
{
return k_(p, T, c);
}
template<class ReactionRate>
Foam::scalar Foam::IrreversibleSolidReaction<ReactionRate>::nReact() const
{
return nReact_;
}
template<class ReactionRate>
void Foam::IrreversibleSolidReaction<ReactionRate>::write
(
Ostream& os
) const
{
solidReaction::write(os);
os << token::SPACE << "Reaction order: " << nReact_ << nl << k_;
}
// ************************************************************************* //

View File

@ -26,299 +26,118 @@ License
#include "solidReaction.H" #include "solidReaction.H"
#include "DynamicList.H" #include "DynamicList.H"
/* * * * * * * * * * * * * * * private static data * * * * * * * * * * * * * */
namespace Foam
{
defineTypeNameAndDebug(solidReaction, 0);
defineRunTimeSelectionTable(solidReaction, Istream);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::solidReaction::solidReaction template<class ReactionThermo>
Foam::solidReaction<ReactionThermo>::solidReaction
( (
const speciesTable& componets, const Reaction<ReactionThermo>& reaction,
const speciesTable& pyrolisisGases, const speciesTable& pyrolisisGases,
const List<label>& slhs, const List<specieCoeffs>& glhs,
const List<label>& srhs, const List<specieCoeffs>& grhs
const List<label>& grhs
) )
: :
components_(componets), Reaction<ReactionThermo>(reaction),
pyrolisisGases_(pyrolisisGases), pyrolisisGases_(pyrolisisGases),
slhs_(slhs), glhs_(glhs),
srhs_(srhs),
grhs_(grhs) grhs_(grhs)
{} {}
Foam::solidReaction::solidReaction template<class ReactionThermo>
Foam::solidReaction<ReactionThermo>::solidReaction
( (
const solidReaction& r, const solidReaction<ReactionThermo>& r,
const speciesTable& componets,
const speciesTable& pyrolisisGases const speciesTable& pyrolisisGases
) )
: :
components_(componets), Reaction<ReactionThermo>(r),
pyrolisisGases_(pyrolisisGases), pyrolisisGases_(pyrolisisGases),
slhs_(r.slhs_), glhs_(r.glhs_),
srhs_(r.srhs_),
grhs_(r.grhs_) grhs_(r.grhs_)
{} {}
Foam::solidReaction::solidReaction template<class ReactionThermo>
( Foam::solidReaction<ReactionThermo>::solidReaction
const speciesTable& components,
Istream& is,
const speciesTable& pyrolisisGases
)
:
components_(components),
pyrolisisGases_(pyrolisisGases)
{
setLRhs(is);
}
Foam::label Foam::solidReaction::componentIndex
(
bool& isGas,
Istream& is
)
{
token t(is);
if (t.isWord())
{
word componentName = t.wordToken();
size_t i = componentName.find('=');
if (i != word::npos)
{
string exponentStr = componentName
(
i + 1,
componentName.size() - i - 1
);
componentName = componentName(0, i);
}
if (components_.contains(componentName))
{
isGas = false;
return (components_[componentName]);
}
else if (pyrolisisGases_.contains(componentName))
{
isGas = true;
return (pyrolisisGases_[componentName]);
}
else
{
FatalIOErrorIn
(
"solidReaction::componentIndex(bool&, Istream& is)",
is
)
<< "Cannot find component" << componentName
<< "in tables :" << pyrolisisGases_ << " or "
<< components_
<< exit(FatalIOError);
return -1;
}
}
else
{
FatalIOErrorIn("solidReaction::componentIndex(bool&, Istream& is)", is)
<< "Expected a word but found " << t.info()
<< exit(FatalIOError);
return -1;
}
}
void Foam::solidReaction::setLRhs(Istream& is)
{
DynamicList<label> dlsrhs;
label index = 0;
while (is)
{
bool isGas = false;
index = componentIndex(isGas, is);
if (index != -1)
{
dlsrhs.append(index);
token t(is);
if (t.isPunctuation())
{
if (t == token::ADD)
{
if (isGas)
{
grhs_ = dlsrhs.shrink();
dlsrhs.clear();
//is.putBack(t);
//return;
}
else
{
srhs_ = dlsrhs.shrink();
dlsrhs.clear(); //is.putBack(t);
//return;
}
}
else if (t == token::ASSIGN)
{
if (isGas)
{
Info << "Pyrolysis Gases should appear on lhs of the"
"reaction" << endl;
}
else
{
slhs_ = dlsrhs.shrink();
dlsrhs.clear();
}
}
else if (isGas)
{
grhs_ = dlsrhs.shrink();
is.putBack(t);
return;
}
else
{
srhs_ = dlsrhs.shrink();
is.putBack(t);
return;
}
}
else if (isGas)
{
grhs_ = dlsrhs.shrink();
is.putBack(t);
return;
}
else
{
srhs_ = dlsrhs.shrink();
is.putBack(t);
return;
}
}
else
{
FatalIOErrorIn("solidReaction::lsrhs(Istream& is)", is)
<< "Cannot find component in tables"
<< exit(FatalIOError);
}
}
FatalIOErrorIn("solidReaction::lsrhs(Istream& is)", is)
<< "Cannot continue reading reaction data from stream"
<< exit(FatalIOError);
}
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::solidReaction> Foam::solidReaction::New
( (
const speciesTable& species, const speciesTable& species,
Istream& is, const HashPtrTable<ReactionThermo>& thermoDatabase,
const speciesTable& pyrolisisGases Istream& is
) )
:
Reaction<ReactionThermo>(species, thermoDatabase, is),
pyrolisisGases_(),
glhs_(),
grhs_()
{ {
if (is.eof()) notImplemented
{
FatalIOErrorIn
( (
"solidReaction::New(const speciesTable& species," "template<class ReactionThermo>"
" const HashPtrTable& thermoDatabase, Istream&)", "Foam::solidReaction<ReactionThermo>::solidReaction"
is "("
) << "solidReaction type not specified" << nl << nl " const speciesTable& species,"
<< "Valid solidReaction types are :" << endl " const HashPtrTable<ReactionThermo>& thermoDatabase,"
<< IstreamConstructorTablePtr_->sortedToc() " Istream& is"
<< exit(FatalIOError); ")"
} );
}
const word reactionTypeName(is);
IstreamConstructorTable::iterator cstrIter template<class ReactionThermo>
= IstreamConstructorTablePtr_->find(reactionTypeName); Foam::solidReaction<ReactionThermo>::solidReaction
(
if (cstrIter == IstreamConstructorTablePtr_->end()) const speciesTable& species,
{ const HashPtrTable<ReactionThermo>& thermoDatabase,
FatalIOErrorIn const dictionary& dict
)
:
Reaction<ReactionThermo>(species, thermoDatabase, dict),
pyrolisisGases_(dict.parent().parent().lookup("gaseousSpecies")),
glhs_(),
grhs_()
{
this->setLRhs
( (
"solidReaction::New(const speciesTable& species," IStringStream(dict.lookup("reaction"))(),
" const HashPtrTable& thermoDatabase, Istream&)", pyrolisisGases_,
is glhs_,
) << "Unknown reaction type " grhs_
<< reactionTypeName << nl << nl
<< "Valid reaction types are :" << endl
<< IstreamConstructorTablePtr_->sortedToc()
<< exit(FatalIOError);
}
return autoPtr<solidReaction>
(
cstrIter()(species, is, pyrolisisGases)
); );
} }
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::solidReaction::write(Ostream& os) const template<class ReactionThermo>
const Foam::List<typename Foam::solidReaction<ReactionThermo>::specieCoeffs>&
Foam::solidReaction<ReactionThermo>::glhs() const
{ {
os << type() << nl << " "; return glhs_;
forAll(slhs_, i)
{
os << components_[slhs_[i]];
}
os << " = ";
forAll(srhs_, i)
{
os << components_[srhs_[i]];
}
os << " + ";
forAll(grhs_, i)
{
os << pyrolisisGases_[grhs_[i]];
}
os << endl << " ";
} }
Foam::scalar Foam::solidReaction::kf template<class ReactionThermo>
( const Foam::List<typename Foam::Reaction<ReactionThermo>::specieCoeffs>&
const scalar p, Foam::solidReaction<ReactionThermo>::grhs() const
const scalar T,
const scalarField& c
) const
{ {
return 0.0; return grhs_;
} }
Foam::scalar Foam::solidReaction::nReact() const template<class ReactionThermo>
const Foam::speciesTable& Foam::solidReaction<ReactionThermo>::
gasSpecies() const
{ {
return 1.0; return pyrolisisGases_;
}
template<class ReactionThermo>
void Foam::solidReaction<ReactionThermo>::write(Ostream& os) const
{
Reaction<ReactionThermo>::write(os);
} }

View File

@ -38,9 +38,7 @@ SourceFiles
#define solidReaction_H #define solidReaction_H
#include "speciesTable.H" #include "speciesTable.H"
#include "scalarField.H" #include "Reaction.H"
#include "typeInfo.H"
#include "runTimeSelectionTables.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -48,44 +46,40 @@ namespace Foam
{ {
// Forward declaration of friend functions and operators // Forward declaration of friend functions and operators
template<class ReactionThermo>
class solidReaction; class solidReaction;
inline Ostream& operator<<(Ostream&, const solidReaction&); template<class ReactionThermo>
inline Ostream& operator<<(Ostream&, const solidReaction<ReactionThermo>&);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class solidReaction Declaration Class solidReaction Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class ReactionThermo>
class solidReaction class solidReaction
:
public Reaction<ReactionThermo>
{ {
private: private:
// Private data // Private data
//- List of solid names present in reaction system typedef typename Reaction<ReactionThermo>::specieCoeffs specieCoeffs;
const speciesTable& components_;
//- List of gas species present in reaction system //- List of gas species present in reaction system
speciesTable pyrolisisGases_; speciesTable pyrolisisGases_;
//- Solid components index for the left-hand-side of the reaction //- Gas specie index for the left-hand-side of the reaction
List<label> slhs_; List<specieCoeffs> glhs_;
//- Solid components index for the right-hand-side of the reaction //- Gas specie index for the right-hand-side of the reaction
List<label> srhs_; List<specieCoeffs> grhs_;
//- Specie index for the right-hand-side of the reaction
List<label> grhs_;
// Private Member Functions // Private Member Functions
//- Set rhs and lhs of the reaction
void setLRhs(Istream&);
//- Look for the component index in the reaction
label componentIndex(bool& isGas, Istream& is);
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const solidReaction&); void operator=(const solidReaction&);
@ -94,58 +88,7 @@ private:
public: public:
//- Runtime type information //- Runtime type information
TypeName("Reaction"); TypeName("SolidReaction");
// Declare run-time constructor selection tables
declareRunTimeSelectionTable
(
autoPtr,
solidReaction,
Istream,
(
const speciesTable& components,
Istream& is,
const speciesTable& pyrolysisGases
),
(components, is, pyrolysisGases)
);
// Public classes
//- Class used for the read-construction of PtrLists of reaction
class iNew
{
const speciesTable& components_;
speciesTable pyrolisisGases_;
public:
iNew
(
const speciesTable& components,
Istream& pyrolisisGases
)
:
components_(components),
pyrolisisGases_(pyrolisisGases)
{}
autoPtr<solidReaction> operator()(Istream& is) const
{
return autoPtr<solidReaction>
(
solidReaction::New
(
components_,
is,
pyrolisisGases_
)
);
}
};
// Constructors // Constructors
@ -153,48 +96,59 @@ public:
//- Construct from components //- Construct from components
solidReaction solidReaction
( (
const speciesTable& components, const Reaction<ReactionThermo>& reaction,
const speciesTable& pyrolisisGases, const speciesTable& pyrolisisGases,
const List<label>& slhs, const List<specieCoeffs>& glhs,
const List<label>& srhs, const List<specieCoeffs>& grhs
const List<label>& grhs
); );
//- Construct as copy given new speciesTable //- Construct as copy given new speciesTable
solidReaction solidReaction
( (
const solidReaction&, const solidReaction<ReactionThermo>&,
const speciesTable& components,
const speciesTable& pyrolisisGases const speciesTable& pyrolisisGases
); );
//- Construct from Istream //- Construct from Istream
solidReaction solidReaction
( (
const speciesTable& components, const speciesTable& pyrolisisGases,
Istream& is, const HashPtrTable<ReactionThermo>& thermoDatabase,
const speciesTable& pyrolisisGases Istream& is
); );
//- Construct and return a clone
virtual autoPtr<solidReaction > clone() const //- Construct from dictionary
{ solidReaction
return autoPtr<solidReaction >
( (
new solidReaction(*this) const speciesTable& species,
const HashPtrTable<ReactionThermo>& thermoDatabase,
const dictionary& dict
);
//- Construct and return a clone
virtual autoPtr<Reaction<ReactionThermo> > clone() const
{
return autoPtr<Reaction<ReactionThermo> >
(
new solidReaction<ReactionThermo>(*this)
); );
} }
//- Construct and return a clone with new speciesTable
// Selectors virtual autoPtr<Reaction<ReactionThermo> > clone
//- Return a pointer to a new patchField created on freestore from input
static autoPtr<solidReaction > New
( (
const speciesTable& components, const speciesTable& species
Istream&, ) const
const speciesTable& pyrolisisGases {
return autoPtr<Reaction<ReactionThermo> >
(
new solidReaction<ReactionThermo>(*this, species)
); );
}
//- Destructor //- Destructor
@ -206,23 +160,13 @@ public:
// Access // Access
inline const List<label>& slhs() const;
inline const List<label>& srhs() const;
inline const List<label>& grhs() const;
inline const speciesTable& pyrolisisGases() const; // - Acces to gas components of the reaction
virtual const List<specieCoeffs>& grhs() const;
virtual const List<specieCoeffs>& glhs() const;
// - Access to gas specie list
// solidReaction rate coefficients virtual const speciesTable& gasSpecies() const;
virtual scalar kf
(
const scalar p,
const scalar T,
const scalarField& c
) const;
virtual scalar nReact() const;
//- Write //- Write
@ -231,10 +175,10 @@ public:
// Ostream Operator // Ostream Operator
friend Ostream& operator<< friend Ostream& operator<< <ReactionThermo>
( (
Ostream&, Ostream&,
const solidReaction& const solidReaction<ReactionThermo>&
); );
}; };
@ -249,6 +193,12 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "solidReaction.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -30,38 +30,13 @@ License
namespace Foam namespace Foam
{ {
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const List<label>& solidReaction::slhs() const
{
return slhs_;
}
inline const List<label>& solidReaction::srhs() const
{
return srhs_;
}
inline const List<label>& solidReaction::grhs() const
{
return grhs_;
}
inline const speciesTable& solidReaction::pyrolisisGases() const
{
return pyrolisisGases_;
}
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
template<class ReactionThermo>
inline Ostream& operator<< inline Ostream& operator<<
( (
Ostream& os, Ostream& os,
const solidReaction& r const solidReaction<ReactionThermo>& r
) )
{ {
r.write(os); r.write(os);

View File

@ -75,13 +75,25 @@ public:
Istream& is Istream& is
); );
//- Construct from dictionary
inline solidArrheniusReactionRate
(
const speciesTable& species,
const dictionary& dict
);
//- Destructor
virtual ~solidArrheniusReactionRate()
{}
// Member Functions // Member Functions
//- Return the type name //- Return the type name
static word type() static word type()
{ {
return "SolidArrhenius"; return "Arrhenius";
} }
inline scalar operator() inline scalar operator()
@ -92,6 +104,10 @@ public:
) const; ) const;
//- Write to stream
inline void write(Ostream& os) const;
// Ostream Operator // Ostream Operator
inline friend Ostream& operator<< inline friend Ostream& operator<<

View File

@ -30,6 +30,7 @@ inline Foam::solidArrheniusReactionRate::solidArrheniusReactionRate
const scalar A, const scalar A,
const scalar Ta, const scalar Ta,
const scalar Tcrit const scalar Tcrit
//const scalar nReact
) )
: :
A_(A), A_(A),
@ -50,6 +51,18 @@ inline Foam::solidArrheniusReactionRate::solidArrheniusReactionRate
{} {}
inline Foam::solidArrheniusReactionRate::solidArrheniusReactionRate
(
const speciesTable&,
const dictionary& dict
)
:
A_(readScalar(dict.lookup("A"))),
Ta_(readScalar(dict.lookup("Ta"))),
Tcrit_(readScalar(dict.lookup("Tcrit")))
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline Foam::scalar Foam::solidArrheniusReactionRate::operator() inline Foam::scalar Foam::solidArrheniusReactionRate::operator()
@ -74,6 +87,14 @@ inline Foam::scalar Foam::solidArrheniusReactionRate::operator()
} }
inline void Foam::solidArrheniusReactionRate::write(Ostream& os) const
{
os.writeKeyword("A") << A_ << token::END_STATEMENT << nl;
os.writeKeyword("Ta") << Ta_ << token::END_STATEMENT << nl;
os.writeKeyword("Tcrit") << Tcrit_ << token::END_STATEMENT << nl;
}
inline Foam::Ostream& Foam::operator<< inline Foam::Ostream& Foam::operator<<
( (
Ostream& os, Ostream& os,

View File

@ -33,7 +33,9 @@ Description
#define makeSolidReactionThermo_H #define makeSolidReactionThermo_H
#include "solidReaction.H" #include "solidReaction.H"
#include "IrreversibleSolidReaction.H" #include "IrreversibleReaction.H"
#include "Reaction.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -43,32 +45,46 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#define makeReaction(ReactionType, ReactionRate) \ #define makeSolidReaction(ReactionType, Thermo, ReactionRate) \
\ \
typedef solidReaction Reaction; \ typedef solidReaction<Thermo> solidReaction##Thermo; \
\ \
typedef ReactionType<ReactionRate> \ typedef Reaction<Thermo> Reaction##Thermo; \
ReactionType##ReactionRate; \ \
typedef ReactionType<solidReaction, Thermo, ReactionRate> \
ReactionType##Thermo##ReactionRate; \
\
defineTemplateRunTimeSelectionTable(Reaction##Thermo, Istream); \
defineTemplateRunTimeSelectionTable(Reaction##Thermo, dictionary); \
\
defineTemplateTypeNameAndDebug(solidReaction##Thermo, 0); \
defineTemplateTypeNameAndDebug(Reaction##Thermo, 0); \
\ \
template<> \ template<> \
const word ReactionType##ReactionRate::typeName \ const word ReactionType##Thermo##ReactionRate::typeName \
( \ ( \
ReactionType::typeName_() \ ReactionType::typeName_() \
+ ReactionRate::type() \ + ReactionRate::type() \
+ Reaction::typeName_() \ + solidReaction##Thermo::typeName_() \
); \ ); \
\ \
addToRunTimeSelectionTable \ addToRunTimeSelectionTable \
( \ ( \
Reaction, \ Reaction##Thermo, \
ReactionType##ReactionRate, \ ReactionType##Thermo##ReactionRate, \
Istream \ Istream \
); \
\
addToRunTimeSelectionTable \
( \
Reaction##Thermo, \
ReactionType##Thermo##ReactionRate, \
dictionary \
); );
#define makeSolidIRReactions(Thermo, ReactionRate) \
#define makeIRReactions(ReactionRate) \
\ \
makeReaction(IrreversibleSolidReaction, ReactionRate) makeSolidReaction(IrreversibleReaction, Thermo, ReactionRate)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -25,6 +25,7 @@ License
#include "makeSolidReaction.H" #include "makeSolidReaction.H"
#include "solidArrheniusReactionRate.H" #include "solidArrheniusReactionRate.H"
#include "solidThermoPhysicsTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -33,7 +34,13 @@ namespace Foam
// * * * * * * * * * * * * * Make Solid reactions * * * * * * * * * * * * // // * * * * * * * * * * * * * Make Solid reactions * * * * * * * * * * * * //
makeIRReactions(solidArrheniusReactionRate) makeSolidIRReactions(hConstSolidThermoPhysics, solidArrheniusReactionRate)
makeSolidIRReactions
(
hExponentialSolidThermoPhysics,
solidArrheniusReactionRate
)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -26,7 +26,7 @@ Class
Description Description
Constant properties Transport package. Constant properties Transport package.
Templated into a given thermodynamics package (needed for thermal Templated into a given Thermodynamics package (needed for thermal
conductivity). conductivity).
SourceFiles SourceFiles
@ -44,20 +44,20 @@ SourceFiles
namespace Foam namespace Foam
{ {
template<class thermo> class constAnIsoSolidTransport; template<class Thermo> class constAnIsoSolidTransport;
template<class thermo> template<class Thermo>
inline constAnIsoSolidTransport<thermo> operator* inline constAnIsoSolidTransport<Thermo> operator*
( (
const scalar, const scalar,
const constAnIsoSolidTransport<thermo>& const constAnIsoSolidTransport<Thermo>&
); );
template<class thermo> template<class Thermo>
Ostream& operator<< Ostream& operator<<
( (
Ostream&, Ostream&,
const constAnIsoSolidTransport<thermo>& const constAnIsoSolidTransport<Thermo>&
); );
@ -65,10 +65,10 @@ Ostream& operator<<
Class constAnIsoSolidTransport Declaration Class constAnIsoSolidTransport Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class thermo> template<class Thermo>
class constAnIsoSolidTransport class constAnIsoSolidTransport
: :
public thermo public Thermo
{ {
// Private data // Private data
@ -79,7 +79,7 @@ class constAnIsoSolidTransport
// Private Member Functions // Private Member Functions
//- Construct from components //- Construct from components
inline constAnIsoSolidTransport(const thermo& t, const vector kappa); inline constAnIsoSolidTransport(const Thermo& t, const vector kappa);
public: public:
@ -93,18 +93,36 @@ public:
const constAnIsoSolidTransport& const constAnIsoSolidTransport&
); );
//- Construct from Istream //- Construct from dictionary
//constAnIsoSolidTransport(Istream&);
constAnIsoSolidTransport(const dictionary&); constAnIsoSolidTransport(const dictionary&);
// Selector from dictionary
inline static autoPtr<constAnIsoSolidTransport> New
(
const dictionary& dict
);
// Member functions // Member functions
//- Return the instantiated type name
static word typeName()
{
return "constAnIso<" + Thermo::typeName() + '>';
}
//- Isotropic thermal conductivity [W/mK] //- Isotropic thermal conductivity [W/mK]
inline scalar kappa(const scalar T) const; inline scalar kappa(const scalar p, const scalar T) const;
//- Un-isotropic thermal conductivity [W/mK] //- Un-isotropic thermal conductivity [W/mK]
inline vector Kappa(const scalar T) const; inline vector Kappa(const scalar p, const scalar T) const;
//- Dynamic viscosity [kg/ms]
inline scalar mu(const scalar p, const scalar T) const;
//- Thermal diffusivity of enthalpy [kg/ms]
inline vector alphah(const scalar p, const scalar T) const;
//- Write to Ostream //- Write to Ostream
void write(Ostream& os) const; void write(Ostream& os) const;
@ -121,7 +139,7 @@ public:
// Friend operators // Friend operators
friend constAnIsoSolidTransport operator* <thermo> friend constAnIsoSolidTransport operator* <Thermo>
( (
const scalar, const scalar,
const constAnIsoSolidTransport& const constAnIsoSolidTransport&
@ -130,7 +148,7 @@ public:
// Ostream Operator // Ostream Operator
friend Ostream& operator<< <thermo> friend Ostream& operator<< <Thermo>
( (
Ostream&, Ostream&,
const constAnIsoSolidTransport& const constAnIsoSolidTransport&

View File

@ -25,53 +25,89 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class thermo> template<class Thermo>
inline Foam::constAnIsoSolidTransport<thermo>::constAnIsoSolidTransport inline Foam::constAnIsoSolidTransport<Thermo>::constAnIsoSolidTransport
( (
const thermo& t, const Thermo& t,
const vector kappa const vector kappa
) )
: :
thermo(t), Thermo(t),
kappa_(kappa) kappa_(kappa)
{} {}
template<class thermo> template<class Thermo>
inline Foam::constAnIsoSolidTransport<thermo>::constAnIsoSolidTransport inline Foam::constAnIsoSolidTransport<Thermo>::constAnIsoSolidTransport
( (
const word& name, const word& name,
const constAnIsoSolidTransport& ct const constAnIsoSolidTransport& ct
) )
: :
thermo(name, ct), Thermo(name, ct),
kappa_(ct.kappa_) kappa_(ct.kappa_)
{} {}
template<class Thermo>
inline Foam::autoPtr<Foam::constAnIsoSolidTransport<Thermo> >
Foam::constAnIsoSolidTransport<Thermo>::New
(
const dictionary& dict
)
{
return autoPtr<constAnIsoSolidTransport<Thermo> >
(
new constAnIsoSolidTransport<Thermo>(dict)
);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class thermo> template<class Thermo>
inline Foam::scalar Foam::constAnIsoSolidTransport<thermo>:: inline Foam::scalar Foam::constAnIsoSolidTransport<Thermo>::
kappa(const scalar T) const kappa(const scalar p, const scalar T) const
{ {
return mag(kappa_); return mag(kappa_);
} }
template<class thermo> template<class Thermo>
inline Foam::vector Foam::constAnIsoSolidTransport<thermo>:: inline Foam::vector Foam::constAnIsoSolidTransport<Thermo>::
Kappa(const scalar T) const Kappa(const scalar p, const scalar T) const
{ {
return kappa_; return kappa_;
} }
template<class Thermo>
inline Foam::scalar Foam::constAnIsoSolidTransport<Thermo>::
mu(const scalar p, const scalar T) const
{
notImplemented
(
"Foam::scalar Foam::constAnIsoSolidTransport<Thermo>mu::"
"("
" const scalar p, const scalar T"
") const"
);
return scalar(0);
}
template<class Thermo>
inline Foam::vector Foam::constAnIsoSolidTransport<Thermo>::
alphah(const scalar p, const scalar T) const
{
return kappa_/this->Cpv(p, T);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class thermo> template<class Thermo>
inline Foam::constAnIsoSolidTransport<thermo>& inline Foam::constAnIsoSolidTransport<Thermo>&
Foam::constAnIsoSolidTransport<thermo>::operator= Foam::constAnIsoSolidTransport<Thermo>::operator=
( (
const constAnIsoSolidTransport<thermo>& ct const constAnIsoSolidTransport<Thermo>& ct
) )
{ {
kappa_ = ct.kappa_; kappa_ = ct.kappa_;
@ -80,10 +116,10 @@ Foam::constAnIsoSolidTransport<thermo>::operator=
} }
template<class thermo> template<class Thermo>
inline void Foam::constAnIsoSolidTransport<thermo>::operator+= inline void Foam::constAnIsoSolidTransport<Thermo>::operator+=
( (
const constAnIsoSolidTransport<thermo>& ct const constAnIsoSolidTransport<Thermo>& ct
) )
{ {
scalar molr1 = this->nMoles(); scalar molr1 = this->nMoles();
@ -95,10 +131,10 @@ inline void Foam::constAnIsoSolidTransport<thermo>::operator+=
} }
template<class thermo> template<class Thermo>
inline void Foam::constAnIsoSolidTransport<thermo>::operator-= inline void Foam::constAnIsoSolidTransport<Thermo>::operator-=
( (
const constAnIsoSolidTransport<thermo>& ct const constAnIsoSolidTransport<Thermo>& ct
) )
{ {
scalar molr1 = this->nMoles(); scalar molr1 = this->nMoles();
@ -113,16 +149,16 @@ inline void Foam::constAnIsoSolidTransport<thermo>::operator-=
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
template<class thermo> template<class Thermo>
inline Foam::constAnIsoSolidTransport<thermo> Foam::operator* inline Foam::constAnIsoSolidTransport<Thermo> Foam::operator*
( (
const scalar s, const scalar s,
const constAnIsoSolidTransport<thermo>& ct const constAnIsoSolidTransport<Thermo>& ct
) )
{ {
return constAnIsoSolidTransport<thermo> return constAnIsoSolidTransport<Thermo>
( (
s*static_cast<const thermo&>(ct), s*static_cast<const Thermo&>(ct),
ct.kappa_ ct.kappa_
); );
} }

View File

@ -28,26 +28,26 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class thermo> template<class Thermo>
Foam::constIsoSolidTransport<thermo>::constIsoSolidTransport Foam::constIsoSolidTransport<Thermo>::constIsoSolidTransport
( (
const dictionary& dict const dictionary& dict
) )
: :
thermo(dict), Thermo(dict),
kappa_(readScalar(dict.subDict("transport").lookup("kappa"))) kappa_(readScalar(dict.subDict("transport").lookup("kappa")))
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class thermo> template<class Thermo>
void Foam::constIsoSolidTransport<thermo>::constIsoSolidTransport::write void Foam::constIsoSolidTransport<Thermo>::constIsoSolidTransport::write
( (
Ostream& os Ostream& os
) const ) const
{ {
thermo::write(os); Thermo::write(os);
dictionary dict("transport"); dictionary dict("transport");
dict.add("kappa", kappa_); dict.add("kappa", kappa_);
@ -57,14 +57,14 @@ void Foam::constIsoSolidTransport<thermo>::constIsoSolidTransport::write
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class thermo> template<class Thermo>
Foam::Ostream& Foam::operator<< Foam::Ostream& Foam::operator<<
( (
Ostream& os, Ostream& os,
const constIsoSolidTransport<thermo>& ct const constIsoSolidTransport<Thermo>& ct
) )
{ {
operator<<(os, static_cast<const thermo&>(ct)); operator<<(os, static_cast<const Thermo&>(ct));
os << tab << ct.kappa_; os << tab << ct.kappa_;
os.check os.check

View File

@ -97,6 +97,12 @@ public:
//- Construct from Istream //- Construct from Istream
constIsoSolidTransport(const dictionary& dict); constIsoSolidTransport(const dictionary& dict);
// Selector from dictionary
inline static autoPtr<constIsoSolidTransport> New
(
const dictionary& dict
);
// Member functions // Member functions
@ -107,10 +113,17 @@ public:
} }
//- Isotropic thermal conductivity [W/mK] //- Isotropic thermal conductivity [W/mK]
inline scalar kappa(const scalar T) const; inline scalar kappa(const scalar p, const scalar T) const;
//- Un-isotropic thermal conductivity [W/mK] //- Un-isotropic thermal conductivity [W/mK]
inline vector Kappa(const scalar T) const; inline vector Kappa(const scalar p, const scalar T) const;
//- Dynamic viscosity [kg/ms]
inline scalar mu(const scalar p, const scalar T) const;
//- Thermal diffusivity of enthalpy [kg/ms]
inline scalar alphah(const scalar p, const scalar T) const;
//- Write to Ostream //- Write to Ostream
void write(Ostream& os) const; void write(Ostream& os) const;

View File

@ -49,23 +49,58 @@ inline Foam::constIsoSolidTransport<thermo>::constIsoSolidTransport
{} {}
template<class Thermo>
inline Foam::autoPtr<Foam::constIsoSolidTransport<Thermo> >
Foam::constIsoSolidTransport<Thermo>::New
(
const dictionary& dict
)
{
return autoPtr<constIsoSolidTransport<Thermo> >
(
new constIsoSolidTransport<Thermo>(dict)
);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class thermo> template<class thermo>
inline Foam::scalar Foam::constIsoSolidTransport<thermo>:: inline Foam::scalar Foam::constIsoSolidTransport<thermo>::
kappa(const scalar T) const kappa(const scalar p, const scalar T) const
{ {
return kappa_; return kappa_;
} }
template<class thermo> template<class thermo>
inline Foam::vector Foam::constIsoSolidTransport<thermo>:: inline Foam::vector Foam::constIsoSolidTransport<thermo>::
Kappa(const scalar T) const Kappa(const scalar p, const scalar T) const
{ {
return vector(kappa_, kappa_, kappa_); return vector(kappa_, kappa_, kappa_);
} }
template<class thermo>
inline Foam::scalar Foam::constIsoSolidTransport<thermo>::
mu(const scalar p, const scalar T) const
{
notImplemented
(
"Foam::scalar Foam::constIsoSolidTransport<thermo>mu::"
"("
" const scalar p, const scalar T"
") const"
);
return scalar(0);
}
template<class thermo>
inline Foam::scalar Foam::constIsoSolidTransport<thermo>::
alphah(const scalar p, const scalar T) const
{
return kappa_/this->Cpv(p, T);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class thermo> template<class thermo>

View File

@ -103,10 +103,15 @@ public:
const exponentialSolidTransport& const exponentialSolidTransport&
); );
//- Construct from dictionary //- Construct from dictionary
exponentialSolidTransport(const dictionary&); exponentialSolidTransport(const dictionary&);
// Selector from dictionary
inline static autoPtr<exponentialSolidTransport> New
(
const dictionary& dict
);
// Member functions // Member functions
@ -117,10 +122,16 @@ public:
} }
//- Thermal conductivity [W/mK] //- Thermal conductivity [W/mK]
inline scalar kappa(const scalar T) const; inline scalar kappa(const scalar p, const scalar T) const;
//- Thermal conductivity [W/mK] //- Thermal conductivity [W/mK]
inline vector Kappa(const scalar T) const; inline vector Kappa(const scalar p, const scalar T) const;
//- Dynamic viscosity [kg/ms]
inline scalar mu(const scalar p, const scalar T) const;
//- Thermal diffusivity of enthalpy [kg/ms]
inline scalar alphah(const scalar p, const scalar T) const;
//- Write to Ostream //- Write to Ostream
void write(Ostream& os) const; void write(Ostream& os) const;

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