mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: Fix pyrolysis energy eq in reactingOneDim. Fix moving mesh approach for
solving pyrolysis Eqs.
This commit is contained in:
@ -3,7 +3,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-2014 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -213,25 +213,17 @@ void reactingOneDim::updateFields()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void reactingOneDim::updateMesh(const scalarField& mass0)
|
void reactingOneDim::updateMesh(const scalarField& deltaV)
|
||||||
{
|
{
|
||||||
if (!moveMesh_)
|
Info<< "Initial/final volumes = " << gSum(deltaV) << endl;
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const scalarField newV(mass0/rho_);
|
|
||||||
|
|
||||||
Info<< "Initial/final volumes = " << gSum(regionMesh().V()) << ", "
|
|
||||||
<< gSum(newV) << " [m3]" << endl;
|
|
||||||
|
|
||||||
// move the mesh
|
// move the mesh
|
||||||
const labelList moveMap = moveMesh(regionMesh().V() - newV, minimumDelta_);
|
const labelList moveMap = moveMesh(deltaV, minimumDelta_);
|
||||||
|
|
||||||
// flag any cells that have not moved as non-reacting
|
// flag any cells that have not moved as non-reacting
|
||||||
forAll(moveMap, i)
|
forAll(moveMap, i)
|
||||||
{
|
{
|
||||||
if (moveMap[i] == 0)
|
if (moveMap[i] == 1)
|
||||||
{
|
{
|
||||||
solidChemistry_->setCellReacting(i, false);
|
solidChemistry_->setCellReacting(i, false);
|
||||||
}
|
}
|
||||||
@ -246,28 +238,26 @@ void reactingOneDim::solveContinuity()
|
|||||||
Info<< "reactingOneDim::solveContinuity()" << endl;
|
Info<< "reactingOneDim::solveContinuity()" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
const scalarField mass0 = rho_*regionMesh().V();
|
|
||||||
|
|
||||||
fvScalarMatrix rhoEqn
|
if (!moveMesh_)
|
||||||
(
|
|
||||||
fvm::ddt(rho_)
|
|
||||||
==
|
|
||||||
- solidChemistry_->RRg()
|
|
||||||
);
|
|
||||||
|
|
||||||
if (regionMesh().moving())
|
|
||||||
{
|
{
|
||||||
surfaceScalarField phiRhoMesh
|
fvScalarMatrix rhoEqn
|
||||||
(
|
(
|
||||||
fvc::interpolate(rho_)*regionMesh().phi()
|
fvm::ddt(rho_)
|
||||||
|
==
|
||||||
|
- solidChemistry_->RRg()
|
||||||
);
|
);
|
||||||
|
|
||||||
rhoEqn += fvc::div(phiRhoMesh);
|
rhoEqn.solve();
|
||||||
}
|
}
|
||||||
|
|
||||||
rhoEqn.solve();
|
if (moveMesh_)
|
||||||
|
{
|
||||||
|
const scalarField deltaV =
|
||||||
|
-solidChemistry_->RRg()*regionMesh().V()/rho_;
|
||||||
|
|
||||||
updateMesh(mass0);
|
updateMesh(deltaV);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -298,7 +288,7 @@ void reactingOneDim::solveSpeciesMass()
|
|||||||
fvc::interpolate(Yi*rho_)*regionMesh().phi()
|
fvc::interpolate(Yi*rho_)*regionMesh().phi()
|
||||||
);
|
);
|
||||||
|
|
||||||
YiEqn += fvc::div(phiYiRhoMesh);
|
YiEqn -= fvc::div(phiYiRhoMesh);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,7 +319,6 @@ void reactingOneDim::solveEnergy()
|
|||||||
- fvc::laplacian(kappa(), T())
|
- fvc::laplacian(kappa(), T())
|
||||||
==
|
==
|
||||||
chemistrySh_
|
chemistrySh_
|
||||||
- fvm::Sp(solidChemistry_->RRg(), h_)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (gasHSource_)
|
if (gasHSource_)
|
||||||
@ -351,7 +340,7 @@ void reactingOneDim::solveEnergy()
|
|||||||
fvc::interpolate(rho_*h_)*regionMesh().phi()
|
fvc::interpolate(rho_*h_)*regionMesh().phi()
|
||||||
);
|
);
|
||||||
|
|
||||||
hEqn += fvc::div(phihMesh);
|
hEqn -= fvc::div(phihMesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
hEqn.relax();
|
hEqn.relax();
|
||||||
@ -682,12 +671,6 @@ const surfaceScalarField& reactingOneDim::phiGas() const
|
|||||||
void reactingOneDim::preEvolveRegion()
|
void reactingOneDim::preEvolveRegion()
|
||||||
{
|
{
|
||||||
pyrolysisModel::preEvolveRegion();
|
pyrolysisModel::preEvolveRegion();
|
||||||
|
|
||||||
// Initialise all cells as able to react
|
|
||||||
forAll(h_, cellI)
|
|
||||||
{
|
|
||||||
solidChemistry_->setCellReacting(cellI, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,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-2015 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -201,7 +201,6 @@ bool Foam::regionModels::regionModel::read(const dictionary& dict)
|
|||||||
}
|
}
|
||||||
|
|
||||||
infoOutput_.readIfPresent("infoOutput", dict);
|
infoOutput_.readIfPresent("infoOutput", dict);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -511,8 +510,6 @@ void Foam::regionModels::regionModel::evolve()
|
|||||||
Info<< "\nEvolving " << modelName_ << " for region "
|
Info<< "\nEvolving " << modelName_ << " for region "
|
||||||
<< regionMesh().name() << endl;
|
<< regionMesh().name() << endl;
|
||||||
|
|
||||||
//read();
|
|
||||||
|
|
||||||
preEvolveRegion();
|
preEvolveRegion();
|
||||||
|
|
||||||
evolveRegion();
|
evolveRegion();
|
||||||
|
|||||||
@ -3,7 +3,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-2013 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -75,6 +75,19 @@ void Foam::regionModels::regionModel1D::initialise()
|
|||||||
|
|
||||||
const polyBoundaryMesh& rbm = regionMesh().boundaryMesh();
|
const polyBoundaryMesh& rbm = regionMesh().boundaryMesh();
|
||||||
|
|
||||||
|
forAll(intCoupledPatchIDs_, i)
|
||||||
|
{
|
||||||
|
const label patchI = intCoupledPatchIDs_[i];
|
||||||
|
const polyPatch& ppCoupled = rbm[patchI];
|
||||||
|
localPyrolysisFaceI += ppCoupled.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
boundaryFaceOppositeFace_.setSize(localPyrolysisFaceI);
|
||||||
|
boundaryFaceFaces_.setSize(localPyrolysisFaceI);
|
||||||
|
boundaryFaceCells_.setSize(localPyrolysisFaceI);
|
||||||
|
|
||||||
|
localPyrolysisFaceI = 0;
|
||||||
|
|
||||||
forAll(intCoupledPatchIDs_, i)
|
forAll(intCoupledPatchIDs_, i)
|
||||||
{
|
{
|
||||||
const label patchI = intCoupledPatchIDs_[i];
|
const label patchI = intCoupledPatchIDs_[i];
|
||||||
@ -83,7 +96,6 @@ void Foam::regionModels::regionModel1D::initialise()
|
|||||||
{
|
{
|
||||||
label faceI = ppCoupled.start() + localFaceI;
|
label faceI = ppCoupled.start() + localFaceI;
|
||||||
label cellI = -1;
|
label cellI = -1;
|
||||||
label nFaces = 0;
|
|
||||||
label nCells = 0;
|
label nCells = 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -99,14 +111,14 @@ void Foam::regionModels::regionModel1D::initialise()
|
|||||||
nCells++;
|
nCells++;
|
||||||
cellIDs.append(cellI);
|
cellIDs.append(cellI);
|
||||||
const cell& cFaces = regionMesh().cells()[cellI];
|
const cell& cFaces = regionMesh().cells()[cellI];
|
||||||
faceI = cFaces.opposingFaceLabel(faceI, regionMesh().faces());
|
|
||||||
faceIDs.append(faceI);
|
faceIDs.append(faceI);
|
||||||
nFaces++;
|
label face0 =
|
||||||
|
cFaces.opposingFaceLabel(faceI, regionMesh().faces());
|
||||||
|
faceI = face0;
|
||||||
} while (regionMesh().isInternalFace(faceI));
|
} while (regionMesh().isInternalFace(faceI));
|
||||||
|
|
||||||
boundaryFaceOppositeFace_[localPyrolysisFaceI] = faceI;
|
boundaryFaceOppositeFace_[localPyrolysisFaceI] = faceI;
|
||||||
faceIDs.remove(); //remove boundary face.
|
//faceIDs.remove(); //remove boundary face.
|
||||||
nFaces--;
|
|
||||||
|
|
||||||
boundaryFaceFaces_[localPyrolysisFaceI].transfer(faceIDs);
|
boundaryFaceFaces_[localPyrolysisFaceI].transfer(faceIDs);
|
||||||
boundaryFaceCells_[localPyrolysisFaceI].transfer(cellIDs);
|
boundaryFaceCells_[localPyrolysisFaceI].transfer(cellIDs);
|
||||||
@ -115,10 +127,8 @@ void Foam::regionModels::regionModel1D::initialise()
|
|||||||
nLayers_ = nCells;
|
nLayers_ = nCells;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
faceIDs.clear();
|
||||||
boundaryFaceOppositeFace_.setSize(localPyrolysisFaceI);
|
cellIDs.clear();
|
||||||
boundaryFaceFaces_.setSize(localPyrolysisFaceI);
|
|
||||||
boundaryFaceCells_.setSize(localPyrolysisFaceI);
|
|
||||||
|
|
||||||
surfaceScalarField& nMagSf = nMagSfPtr_();
|
surfaceScalarField& nMagSf = nMagSfPtr_();
|
||||||
|
|
||||||
@ -128,16 +138,22 @@ void Foam::regionModels::regionModel1D::initialise()
|
|||||||
const label patchI = intCoupledPatchIDs_[i];
|
const label patchI = intCoupledPatchIDs_[i];
|
||||||
const polyPatch& ppCoupled = rbm[patchI];
|
const polyPatch& ppCoupled = rbm[patchI];
|
||||||
const vectorField& pNormals = ppCoupled.faceNormals();
|
const vectorField& pNormals = ppCoupled.faceNormals();
|
||||||
|
|
||||||
nMagSf.boundaryField()[patchI] =
|
nMagSf.boundaryField()[patchI] =
|
||||||
regionMesh().Sf().boundaryField()[patchI] & pNormals;
|
regionMesh().Sf().boundaryField()[patchI] & pNormals;
|
||||||
|
|
||||||
forAll(pNormals, localFaceI)
|
forAll(pNormals, localFaceI)
|
||||||
{
|
{
|
||||||
const vector& n = pNormals[localFaceI];
|
const vector n = pNormals[localFaceI];
|
||||||
const labelList& faces = boundaryFaceFaces_[localPyrolysisFaceI++];
|
const labelList& faces = boundaryFaceFaces_[localPyrolysisFaceI++];
|
||||||
forAll (faces, faceI)
|
|
||||||
|
forAll (faces, faceI) //faceI = 0 is on boundary
|
||||||
{
|
{
|
||||||
const label faceID = faces[faceI];
|
if (faceI > 0)
|
||||||
nMagSf[faceID] = regionMesh().Sf()[faceID] & n;
|
{
|
||||||
|
const label faceID = faces[faceI];
|
||||||
|
nMagSf[faceID] = regionMesh().Sf()[faceID] & n;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -150,8 +166,6 @@ bool Foam::regionModels::regionModel1D::read()
|
|||||||
{
|
{
|
||||||
if (regionModel::read())
|
if (regionModel::read())
|
||||||
{
|
{
|
||||||
moveMesh_.readIfPresent("moveMesh", coeffs_);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -199,72 +213,65 @@ Foam::tmp<Foam::labelField> Foam::regionModels::regionModel1D::moveMesh
|
|||||||
forAll(intCoupledPatchIDs_, localPatchI)
|
forAll(intCoupledPatchIDs_, localPatchI)
|
||||||
{
|
{
|
||||||
label patchI = intCoupledPatchIDs_[localPatchI];
|
label patchI = intCoupledPatchIDs_[localPatchI];
|
||||||
const polyPatch pp = bm[patchI];
|
const polyPatch& pp = bm[patchI];
|
||||||
const vectorField& cf = regionMesh().Cf().boundaryField()[patchI];
|
|
||||||
|
|
||||||
forAll(pp, patchFaceI)
|
forAll (pp, patchFaceI)
|
||||||
{
|
{
|
||||||
const labelList& faces = boundaryFaceFaces_[totalFaceId];
|
const labelList& faces = boundaryFaceFaces_[totalFaceId];
|
||||||
const labelList& cells = boundaryFaceCells_[totalFaceId];
|
const labelList& cells = boundaryFaceCells_[totalFaceId];
|
||||||
|
const label oFace = boundaryFaceOppositeFace_[totalFaceId];
|
||||||
|
|
||||||
const vector n = pp.faceNormals()[patchFaceI];
|
const vector n = pp.faceNormals()[patchFaceI];
|
||||||
const vector sf = pp.faceAreas()[patchFaceI];
|
const vector sf = pp.faceAreas()[patchFaceI];
|
||||||
|
|
||||||
List<point> oldCf(faces.size() + 1);
|
List<point> oldCf(faces.size() + 1, vector::zero);
|
||||||
oldCf[0] = cf[patchFaceI];
|
List<bool> frozen(faces.size(), false);
|
||||||
forAll(faces, i)
|
|
||||||
|
forAll (faces, i)
|
||||||
{
|
{
|
||||||
oldCf[i + 1] = regionMesh().faceCentres()[faces[i]];
|
oldCf[i] = regionMesh().faceCentres()[faces[i]];
|
||||||
}
|
}
|
||||||
|
|
||||||
vector newDelta = vector::zero;
|
oldCf[faces.size()] = regionMesh().faceCentres()[oFace];
|
||||||
point nbrCf = oldCf[0];
|
|
||||||
|
|
||||||
forAll(faces, i)
|
forAll (faces, i)
|
||||||
{
|
{
|
||||||
const label faceI = faces[i];
|
|
||||||
const label cellI = cells[i];
|
const label cellI = cells[i];
|
||||||
|
|
||||||
|
if (mag(oldCf[i + 1] - oldCf[i]) < minDelta)
|
||||||
|
{
|
||||||
|
frozen[i] = true;
|
||||||
|
cellMoveMap[cellI] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vectorField newDelta(cells.size() + 1, vector::zero);
|
||||||
|
|
||||||
|
label j = 0;
|
||||||
|
forAllReverse (cells, i)
|
||||||
|
{
|
||||||
|
const label cellI = cells[i];
|
||||||
|
newDelta[j+1] = (deltaV[cellI]/mag(sf))*n + newDelta[j];
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
|
||||||
|
forAll (faces, i)
|
||||||
|
{
|
||||||
|
const label faceI = faces[i];
|
||||||
const face f = regionMesh().faces()[faceI];
|
const face f = regionMesh().faces()[faceI];
|
||||||
|
|
||||||
newDelta += (deltaV[cellI]/mag(sf))*n;
|
|
||||||
|
|
||||||
vector localDelta = vector::zero;
|
|
||||||
forAll(f, pti)
|
forAll(f, pti)
|
||||||
{
|
{
|
||||||
const label pointI = f[pti];
|
const label pointI = f[pti];
|
||||||
|
|
||||||
if
|
if (!frozen[i])
|
||||||
(
|
|
||||||
mag((nbrCf - (oldPoints[pointI] + newDelta)) & n)
|
|
||||||
> minDelta
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
newPoints[pointI] = oldPoints[pointI] + newDelta;
|
newPoints[pointI] =
|
||||||
localDelta = newDelta;
|
oldPoints[pointI] + newDelta[newDelta.size() - 1 - i];
|
||||||
cellMoveMap[cellI] = 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nbrCf = oldCf[i + 1] + localDelta;
|
|
||||||
}
|
|
||||||
// Modify boundary
|
|
||||||
const label bFaceI = boundaryFaceOppositeFace_[totalFaceId];
|
|
||||||
const face f = regionMesh().faces()[bFaceI];
|
|
||||||
const label cellI = cells[cells.size() - 1];
|
|
||||||
newDelta += (deltaV[cellI]/mag(sf))*n;
|
|
||||||
forAll(f, pti)
|
|
||||||
{
|
|
||||||
const label pointI = f[pti];
|
|
||||||
if
|
|
||||||
(
|
|
||||||
mag((nbrCf - (oldPoints[pointI] + newDelta)) & n)
|
|
||||||
> minDelta
|
|
||||||
)
|
|
||||||
{
|
|
||||||
newPoints[pointI] = oldPoints[pointI] + newDelta;
|
|
||||||
cellMoveMap[cellI] = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
totalFaceId ++;
|
totalFaceId ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -307,16 +314,15 @@ Foam::regionModels::regionModel1D::regionModel1D
|
|||||||
boundaryFaceOppositeFace_(regionMesh().nCells()),
|
boundaryFaceOppositeFace_(regionMesh().nCells()),
|
||||||
nLayers_(0),
|
nLayers_(0),
|
||||||
nMagSfPtr_(NULL),
|
nMagSfPtr_(NULL),
|
||||||
moveMesh_(true)
|
moveMesh_(false)
|
||||||
{
|
{
|
||||||
if (active_)
|
if (active_)
|
||||||
{
|
{
|
||||||
constructMeshObjects();
|
constructMeshObjects();
|
||||||
initialise();
|
initialise();
|
||||||
|
|
||||||
if (readFields)
|
if (readFields)
|
||||||
{
|
{
|
||||||
read();
|
moveMesh_.readIfPresent("moveMesh", coeffs_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -343,10 +349,9 @@ Foam::regionModels::regionModel1D::regionModel1D
|
|||||||
{
|
{
|
||||||
constructMeshObjects();
|
constructMeshObjects();
|
||||||
initialise();
|
initialise();
|
||||||
|
|
||||||
if (readFields)
|
if (readFields)
|
||||||
{
|
{
|
||||||
read(dict);
|
moveMesh_.readIfPresent("moveMesh", coeffs_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user