Add the OpenFOAM source tree

This commit is contained in:
Henry
2014-12-10 22:40:10 +00:00
parent ee487c860d
commit 446e5777f0
13379 changed files with 3983377 additions and 0 deletions

16
src/engine/Make/files Normal file
View File

@ -0,0 +1,16 @@
engineTime/engineTime.C
ignition/ignition.C
ignition/ignitionIO.C
ignition/ignitionSite.C
ignition/ignitionSiteIO.C
engineValve/engineValve.C
enginePiston/enginePiston.C
engineMesh/engineMesh/engineMesh.C
engineMesh/engineMesh/engineMeshNew.C
engineMesh/staticEngineMesh/staticEngineMesh.C
engineMesh/layeredEngineMesh/layeredEngineMesh.C
engineMesh/fvMotionSolverEngineMesh/fvMotionSolverEngineMesh.C
LIB = $(FOAM_LIBBIN)/libengine

11
src/engine/Make/options Normal file
View File

@ -0,0 +1,11 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/fvMotionSolver/lnInclude
LIB_LIBS = \
-lfiniteVolume \
-lmeshTools \
-ldynamicMesh \
-lfvMotionSolvers

View File

@ -0,0 +1,134 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "engineMesh.H"
#include "dimensionedScalar.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(engineMesh, 0);
defineRunTimeSelectionTable(engineMesh, IOobject);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::engineMesh::engineMesh(const IOobject& io)
:
fvMesh(io),
engineDB_(refCast<const engineTime>(time())),
pistonIndex_(-1),
linerIndex_(-1),
cylinderHeadIndex_(-1),
deckHeight_("deckHeight", dimLength, GREAT),
pistonPosition_("pistonPosition", dimLength, -GREAT)
{
bool foundPiston = false;
bool foundLiner = false;
bool foundCylinderHead = false;
forAll(boundary(), i)
{
if (boundary()[i].name() == "piston")
{
pistonIndex_ = i;
foundPiston = true;
}
else if (boundary()[i].name() == "liner")
{
linerIndex_ = i;
foundLiner = true;
}
else if (boundary()[i].name() == "cylinderHead")
{
cylinderHeadIndex_ = i;
foundCylinderHead = true;
}
}
reduce(foundPiston, orOp<bool>());
reduce(foundLiner, orOp<bool>());
reduce(foundCylinderHead, orOp<bool>());
if (!foundPiston)
{
FatalErrorIn("engineMesh::engineMesh(const IOobject& io)")
<< "cannot find piston patch"
<< exit(FatalError);
}
if (!foundLiner)
{
FatalErrorIn("engineMesh::engineMesh(const IOobject& io)")
<< "cannot find liner patch"
<< exit(FatalError);
}
if (!foundCylinderHead)
{
FatalErrorIn("engineMesh::engineMesh(const IOobject& io)")
<< "cannot find cylinderHead patch"
<< exit(FatalError);
}
{
if (pistonIndex_ != -1)
{
pistonPosition_.value() = -GREAT;
if (boundary()[pistonIndex_].patch().localPoints().size())
{
pistonPosition_.value() =
max(boundary()[pistonIndex_].patch().localPoints()).z();
}
}
reduce(pistonPosition_.value(), maxOp<scalar>());
if (cylinderHeadIndex_ != -1)
{
deckHeight_.value() = GREAT;
if (boundary()[cylinderHeadIndex_].patch().localPoints().size())
{
deckHeight_.value() = min
(
boundary()[cylinderHeadIndex_].patch().localPoints()
).z();
}
}
reduce(deckHeight_.value(), minOp<scalar>());
Info<< "deckHeight: " << deckHeight_.value() << nl
<< "piston position: " << pistonPosition_.value() << endl;
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::engineMesh::~engineMesh()
{}
// ************************************************************************* //

View File

@ -0,0 +1,129 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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/>.
Class
Foam::engineMesh
Description
Foam::engineMesh
SourceFiles
engineMesh.C
\*---------------------------------------------------------------------------*/
#ifndef engineMesh_H
#define engineMesh_H
#include "engineTime.H"
#include "fvMesh.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class engineMesh Declaration
\*---------------------------------------------------------------------------*/
class engineMesh
:
public fvMesh
{
// Private Member Functions
//- Disallow default bitwise copy construct
engineMesh(const engineMesh&);
//- Disallow default bitwise assignment
void operator=(const engineMesh&);
protected:
// Protected data
const engineTime& engineDB_;
label pistonIndex_;
label linerIndex_;
label cylinderHeadIndex_;
dimensionedScalar deckHeight_;
dimensionedScalar pistonPosition_;
public:
//- Runtime type information
TypeName("engineMesh");
// Declare run-time constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
engineMesh,
IOobject,
(const IOobject& io),
(io)
);
// Constructors
//- Construct from objectRegistry, and read/write options
explicit engineMesh(const IOobject& io);
// Selectors
//- Select null constructed
static autoPtr<engineMesh> New(const IOobject& io);
//- Destructor
virtual ~engineMesh();
// Member Functions
// Edit
virtual void move() = 0;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,75 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "engineMesh.H"
#include "Time.H"
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::engineMesh> Foam::engineMesh::New
(
const Foam::IOobject& io
)
{
// get model name, but do not register the dictionary
// otherwise it is registered in the database twice
const word modelType
(
IOdictionary
(
IOobject
(
"engineGeometry",
io.time().constant(),
io.db(),
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
)
).lookup("engineMesh")
);
Info<< "Selecting engineMesh " << modelType << endl;
IOobjectConstructorTable::iterator cstrIter =
IOobjectConstructorTablePtr_->find(modelType);
if (cstrIter == IOobjectConstructorTablePtr_->end())
{
FatalErrorIn
(
"engineMesh::New(const IOobject&)"
) << "Unknown engineMesh type "
<< modelType << nl << nl
<< "Valid engineMesh types are :" << endl
<< IOobjectConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<engineMesh>(cstrIter()(io));
}
// ************************************************************************* //

View File

@ -0,0 +1,140 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 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 "fvMotionSolverEngineMesh.H"
#include "addToRunTimeSelectionTable.H"
#include "fvcMeshPhi.H"
#include "surfaceInterpolate.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(fvMotionSolverEngineMesh, 0);
addToRunTimeSelectionTable(engineMesh, fvMotionSolverEngineMesh, IOobject);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fvMotionSolverEngineMesh::fvMotionSolverEngineMesh(const IOobject& io)
:
engineMesh(io),
pistonLayers_("pistonLayers", dimLength, 0.0),
motionSolver_
(
*this,
IOdictionary
(
IOobject
(
"dynamicMeshDict",
time().constant(),
*this,
IOobject::NO_READ,
IOobject::NO_WRITE
),
engineDB_.engineDict()
)
)
{
engineDB_.engineDict().readIfPresent("pistonLayers", pistonLayers_);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::fvMotionSolverEngineMesh::~fvMotionSolverEngineMesh()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::fvMotionSolverEngineMesh::move()
{
scalar deltaZ = engineDB_.pistonDisplacement().value();
Info<< "deltaZ = " << deltaZ << endl;
// Position of the top of the static mesh layers above the piston
scalar pistonPlusLayers = pistonPosition_.value() + pistonLayers_.value();
scalar pistonSpeed = deltaZ/engineDB_.deltaTValue();
motionSolver_.pointMotionU().boundaryField()[pistonIndex_] == pistonSpeed;
{
scalarField linerPoints
(
boundary()[linerIndex_].patch().localPoints().component(vector::Z)
);
motionSolver_.pointMotionU().boundaryField()[linerIndex_] ==
pistonSpeed*pos(deckHeight_.value() - linerPoints)
*(deckHeight_.value() - linerPoints)
/(deckHeight_.value() - pistonPlusLayers);
}
motionSolver_.solve();
if (engineDB_.foundObject<surfaceScalarField>("phi"))
{
surfaceScalarField& phi =
const_cast<surfaceScalarField&>
(engineDB_.lookupObject<surfaceScalarField>("phi"));
const volScalarField& rho =
engineDB_.lookupObject<volScalarField>("rho");
const volVectorField& U =
engineDB_.lookupObject<volVectorField>("U");
bool absolutePhi = false;
if (moving())
{
phi += fvc::interpolate(rho)*fvc::meshPhi(rho, U);
absolutePhi = true;
}
movePoints(motionSolver_.curPoints());
if (absolutePhi)
{
phi -= fvc::interpolate(rho)*fvc::meshPhi(rho, U);
}
}
else
{
movePoints(motionSolver_.curPoints());
}
pistonPosition_.value() += deltaZ;
Info<< "clearance: " << deckHeight_.value() - pistonPosition_.value() << nl
<< "Piston speed = " << pistonSpeed << " m/s" << endl;
}
// ************************************************************************* //

View File

@ -0,0 +1,105 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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/>.
Class
Foam::fvMotionSolverEngineMesh
Description
Foam::fvMotionSolverEngineMesh
SourceFiles
fvMotionSolverEngineMesh.C
\*---------------------------------------------------------------------------*/
#ifndef fvMotionSolverEngineMesh_H
#define fvMotionSolverEngineMesh_H
#include "engineMesh.H"
#include "velocityComponentLaplacianFvMotionSolver.H"
#include "dimensionedScalar.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class fvMotionSolverEngineMesh Declaration
\*---------------------------------------------------------------------------*/
class fvMotionSolverEngineMesh
:
public engineMesh
{
// Private data
dimensionedScalar pistonLayers_;
//- Mesh-motion solver to solve for the "z" component of the cell-centre
// displacements
velocityComponentLaplacianFvMotionSolver motionSolver_;
// Private Member Functions
//- Disallow default bitwise copy construct
fvMotionSolverEngineMesh(const fvMotionSolverEngineMesh&);
//- Disallow default bitwise assignment
void operator=(const fvMotionSolverEngineMesh&);
public:
//- Runtime type information
TypeName("fvMotionSolver");
// Constructors
//- Construct from IOobject
fvMotionSolverEngineMesh(const IOobject& io);
//- Destructor
~fvMotionSolverEngineMesh();
// Member Functions
// Edit
void move();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,125 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "layeredEngineMesh.H"
#include "addToRunTimeSelectionTable.H"
#include "fvcMeshPhi.H"
#include "surfaceInterpolate.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(layeredEngineMesh, 0);
addToRunTimeSelectionTable(engineMesh, layeredEngineMesh, IOobject);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::layeredEngineMesh::layeredEngineMesh(const IOobject& io)
:
engineMesh(io),
pistonLayers_("pistonLayers", dimLength, 0.0)
{
engineDB_.engineDict().readIfPresent("pistonLayers", pistonLayers_);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::layeredEngineMesh::~layeredEngineMesh()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::layeredEngineMesh::move()
{
scalar deltaZ = engineDB_.pistonDisplacement().value();
Info<< "deltaZ = " << deltaZ << endl;
// Position of the top of the static mesh layers above the piston
scalar pistonPlusLayers = pistonPosition_.value() + pistonLayers_.value();
pointField newPoints(points());
forAll(newPoints, pointi)
{
point& p = newPoints[pointi];
if (p.z() < pistonPlusLayers) // In piston bowl
{
p.z() += deltaZ;
}
else if (p.z() < deckHeight_.value()) // In liner region
{
p.z() +=
deltaZ
*(deckHeight_.value() - p.z())
/(deckHeight_.value() - pistonPlusLayers);
}
}
if (engineDB_.foundObject<surfaceScalarField>("phi"))
{
surfaceScalarField& phi =
const_cast<surfaceScalarField&>
(engineDB_.lookupObject<surfaceScalarField>("phi"));
const volScalarField& rho =
engineDB_.lookupObject<volScalarField>("rho");
const volVectorField& U =
engineDB_.lookupObject<volVectorField>("U");
bool absolutePhi = false;
if (moving())
{
phi += fvc::interpolate(rho)*fvc::meshPhi(rho, U);
absolutePhi = true;
}
movePoints(newPoints);
if (absolutePhi)
{
phi -= fvc::interpolate(rho)*fvc::meshPhi(rho, U);
}
}
else
{
movePoints(newPoints);
}
pistonPosition_.value() += deltaZ;
scalar pistonSpeed = deltaZ/engineDB_.deltaTValue();
Info<< "clearance: " << deckHeight_.value() - pistonPosition_.value() << nl
<< "Piston speed = " << pistonSpeed << " m/s" << endl;
}
// ************************************************************************* //

View File

@ -0,0 +1,100 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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/>.
Class
Foam::layeredEngineMesh
Description
Foam::layeredEngineMesh
SourceFiles
layeredEngineMesh.C
\*---------------------------------------------------------------------------*/
#ifndef layeredEngineMesh_H
#define layeredEngineMesh_H
#include "engineMesh.H"
#include "dimensionedScalar.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class layeredEngineMesh Declaration
\*---------------------------------------------------------------------------*/
class layeredEngineMesh
:
public engineMesh
{
// Private data
dimensionedScalar pistonLayers_;
// Private Member Functions
//- Disallow default bitwise copy construct
layeredEngineMesh(const layeredEngineMesh&);
//- Disallow default bitwise assignment
void operator=(const layeredEngineMesh&);
public:
//- Runtime type information
TypeName("layered");
// Constructors
//- Construct from IOobject
layeredEngineMesh(const IOobject& io);
//- Destructor
~layeredEngineMesh();
// Member Functions
// Edit
void move();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,57 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "staticEngineMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(staticEngineMesh, 0);
addToRunTimeSelectionTable(engineMesh, staticEngineMesh, IOobject);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::staticEngineMesh::staticEngineMesh(const IOobject& io)
:
engineMesh(io)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::staticEngineMesh::~staticEngineMesh()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::staticEngineMesh::move()
{}
// ************************************************************************* //

View File

@ -0,0 +1,94 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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/>.
Class
Foam::staticEngineMesh
Description
Foam::staticEngineMesh
SourceFiles
staticEngineMesh.C
\*---------------------------------------------------------------------------*/
#ifndef staticEngineMesh_H
#define staticEngineMesh_H
#include "engineMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class staticEngineMesh Declaration
\*---------------------------------------------------------------------------*/
class staticEngineMesh
:
public engineMesh
{
// Private Member Functions
//- Disallow default bitwise copy construct
staticEngineMesh(const staticEngineMesh&);
//- Disallow default bitwise assignment
void operator=(const staticEngineMesh&);
public:
//- Runtime type information
TypeName("static");
// Constructors
//- Construct from IOobject
staticEngineMesh(const IOobject& io);
//- Destructor
~staticEngineMesh();
// Member Functions
// Edit
void move();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,90 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 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 "enginePiston.H"
#include "engineTime.H"
#include "polyMesh.H"
#include "interpolateXY.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::enginePiston::enginePiston
(
const polyMesh& mesh,
const word& pistonPatchName,
const autoPtr<coordinateSystem>& pistonCS,
const scalar minLayer,
const scalar maxLayer
)
:
mesh_(mesh),
engineDB_(refCast<const engineTime>(mesh.time())),
patchID_(pistonPatchName, mesh.boundaryMesh()),
csPtr_(pistonCS),
minLayer_(minLayer),
maxLayer_(maxLayer)
{}
// Construct from dictionary
Foam::enginePiston::enginePiston
(
const polyMesh& mesh,
const dictionary& dict
)
:
mesh_(mesh),
engineDB_(refCast<const engineTime>(mesh_.time())),
patchID_(dict.lookup("patch"), mesh.boundaryMesh()),
csPtr_
(
coordinateSystem::New
(
mesh_,
dict.subDict("coordinateSystem")
)
),
minLayer_(readScalar(dict.lookup("minLayer"))),
maxLayer_(readScalar(dict.lookup("maxLayer")))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::enginePiston::writeDict(Ostream& os) const
{
os << nl << token::BEGIN_BLOCK
<< "patch " << patchID_.name() << token::END_STATEMENT << nl
<< "minLayer " << minLayer_ << token::END_STATEMENT << nl
<< "maxLayer " << maxLayer_ << token::END_STATEMENT << nl
<< token::END_BLOCK << endl;
}
// ************************************************************************* //

View File

@ -0,0 +1,158 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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/>.
Class
Foam::enginePiston
Description
Foam::enginePiston
SourceFiles
enginePiston.C
\*---------------------------------------------------------------------------*/
#ifndef enginePiston_H
#define enginePiston_H
#include "polyPatchID.H"
#include "coordinateSystem.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class polyMesh;
class engineTime;
/*---------------------------------------------------------------------------*\
Class enginePiston Declaration
\*---------------------------------------------------------------------------*/
class enginePiston
{
// Private data
//- Reference to engine mesh
const polyMesh& mesh_;
//- Reference to engine database
const engineTime& engineDB_;
//- Piston patch
polyPatchID patchID_;
//- Coordinate system
autoPtr<coordinateSystem> csPtr_;
// Piston layering data
//- Min layer thickness
const scalar minLayer_;
//- Max layer thickness
const scalar maxLayer_;
// Private Member Functions
//- Disallow default bitwise copy construct
enginePiston(const enginePiston&);
//- Disallow default bitwise assignment
void operator=(const enginePiston&);
public:
// Static data members
// Constructors
//- Construct from components
enginePiston
(
const polyMesh& mesh,
const word& pistonPatchName,
const autoPtr<coordinateSystem>& pistonCS,
const scalar minLayer,
const scalar maxLayer
);
//- Construct from dictionary
enginePiston
(
const polyMesh& mesh,
const dictionary& dict
);
// Destructor - default
// Member Functions
//- Return coordinate system
const coordinateSystem& cs() const
{
return csPtr_();
}
//- Return ID of piston patch
const polyPatchID& patchID() const
{
return patchID_;
}
// Piston layering thickness
scalar minLayer() const
{
return minLayer_;
}
scalar maxLayer() const
{
return maxLayer_;
}
//- Write dictionary
void writeDict(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,236 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "engineTime.H"
#include "unitConversion.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::engineTime::timeAdjustment()
{
deltaT_ = degToTime(deltaT_);
endTime_ = degToTime(endTime_);
if
(
writeControl_ == wcRunTime
|| writeControl_ == wcAdjustableRunTime
)
{
writeInterval_ = degToTime(writeInterval_);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
//- Construct from objectRegistry arguments
Foam::engineTime::engineTime
(
const word& name,
const fileName& rootPath,
const fileName& caseName,
const fileName& systemName,
const fileName& constantName,
const fileName& dictName
)
:
Time
(
name,
rootPath,
caseName,
systemName,
constantName
),
dict_
(
IOobject
(
"engineGeometry",
constant(),
*this,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
)
),
rpm_(dict_.lookup("rpm")),
conRodLength_(dimensionedScalar("conRodLength", dimLength, 0)),
bore_(dimensionedScalar("bore", dimLength, 0)),
stroke_(dimensionedScalar("stroke", dimLength, 0)),
clearance_(dimensionedScalar("clearance", dimLength, 0))
{
// geometric parameters are not strictly required for Time
dict_.readIfPresent("conRodLength", conRodLength_);
dict_.readIfPresent("bore", bore_);
dict_.readIfPresent("stroke", stroke_);
dict_.readIfPresent("clearance", clearance_);
timeAdjustment();
startTime_ = degToTime(startTime_);
value() = degToTime(value());
deltaTSave_ = deltaT_;
deltaT0_ = deltaT_;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Read the controlDict and set all the parameters
void Foam::engineTime::readDict()
{
Time::readDict();
timeAdjustment();
}
// Read the controlDict and set all the parameters
bool Foam::engineTime::read()
{
if (Time::read())
{
timeAdjustment();
return true;
}
else
{
return false;
}
}
Foam::scalar Foam::engineTime::degToTime(const scalar theta) const
{
// 6 * rpm => deg/s
return theta/(6.0*rpm_.value());
}
Foam::scalar Foam::engineTime::timeToDeg(const scalar t) const
{
// 6 * rpm => deg/s
return t*(6.0*rpm_.value());
}
Foam::scalar Foam::engineTime::theta() const
{
return timeToDeg(value());
}
// Return current crank-angle translated to a single revolution
// (value between -180 and 180 with 0 = top dead centre)
Foam::scalar Foam::engineTime::thetaRevolution() const
{
scalar t = theta();
while (t > 180.0)
{
t -= 360.0;
}
while (t < -180.0)
{
t += 360.0;
}
return t;
}
Foam::scalar Foam::engineTime::deltaTheta() const
{
return timeToDeg(deltaTValue());
}
Foam::scalar Foam::engineTime::pistonPosition(const scalar theta) const
{
return
(
conRodLength_.value()
+ stroke_.value()/2.0
+ clearance_.value()
)
- (
stroke_.value()*::cos(degToRad(theta))/2.0
+ ::sqrt
(
sqr(conRodLength_.value())
- sqr(stroke_.value()*::sin(degToRad(theta))/2.0)
)
);
}
Foam::dimensionedScalar Foam::engineTime::pistonPosition() const
{
return dimensionedScalar
(
"pistonPosition",
dimLength,
pistonPosition(theta())
);
}
Foam::dimensionedScalar Foam::engineTime::pistonDisplacement() const
{
return dimensionedScalar
(
"pistonDisplacement",
dimLength,
pistonPosition(theta() - deltaTheta()) - pistonPosition().value()
);
}
Foam::dimensionedScalar Foam::engineTime::pistonSpeed() const
{
return dimensionedScalar
(
"pistonSpeed",
dimVelocity,
pistonDisplacement().value()/(deltaTValue() + VSMALL)
);
}
Foam::scalar Foam::engineTime::userTimeToTime(const scalar theta) const
{
return degToTime(theta);
}
Foam::scalar Foam::engineTime::timeToUserTime(const scalar t) const
{
return timeToDeg(t);
}
// ************************************************************************* //

View File

@ -0,0 +1,219 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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/>.
Class
Foam::engineTime
Description
Manage time in terms of engine RPM and crank-angle.
When engineTime is in effect, the userTime is reported in degrees
crank-angle instead of in seconds. The RPM to be used is specified in
\c constant/engineGeometry. If only a time conversion is required,
the geometric engine parameters can be dropped or set to zero.
For example,
\verbatim
rpm rpm [0 0 -1 0 0] 2000;
conRodLength conRodLength [0 1 0 0 0] 0.0;
bore bore [0 1 0 0 0] 0.0;
stroke stroke [0 1 0 0 0] 0.0;
clearance clearance [0 1 0 0 0] 0.0;
\endverbatim
Note
The engineTime can currently only be selected at compile-time.
SourceFiles
engineTime.C
\*---------------------------------------------------------------------------*/
#ifndef engineTime_H
#define engineTime_H
#include "Time.H"
#include "dictionary.H"
#include "dimensionedScalar.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class engineTime Declaration
\*---------------------------------------------------------------------------*/
class engineTime
:
public Time
{
// Private data
IOdictionary dict_;
//- RPM is required
dimensionedScalar rpm_;
//- Optional engine geometry parameters
dimensionedScalar conRodLength_;
dimensionedScalar bore_;
dimensionedScalar stroke_;
dimensionedScalar clearance_;
// Private Member Functions
//- Disallow default bitwise copy construct
engineTime(const engineTime&);
//- Disallow default bitwise assignment
void operator=(const engineTime&);
//- adjust read time values
void timeAdjustment();
public:
// Constructors
//- Construct from objectRegistry arguments
engineTime
(
const word& name,
const fileName& rootPath,
const fileName& caseName,
const fileName& systemName = "system",
const fileName& constantName = "constant",
const fileName& dictName = "engineGeometry"
);
//- Destructor
virtual ~engineTime()
{}
// Member Functions
// Conversion
//- Convert degrees to seconds (for given engine speed in RPM)
scalar degToTime(const scalar theta) const;
//- Convert seconds to degrees (for given engine speed in RPM)
scalar timeToDeg(const scalar t) const;
//- Calculate the piston position from the engine geometry
// and given crank angle.
scalar pistonPosition(const scalar theta) const;
// Access
//- Return the engine geometry dictionary
const dictionary& engineDict() const
{
return dict_;
}
//- Return the engines current operating RPM
const dimensionedScalar& rpm() const
{
return rpm_;
}
//- Return the engines connecting-rod length
const dimensionedScalar& conRodLength() const
{
return conRodLength_;
}
//- Return the engines bore
const dimensionedScalar& bore() const
{
return bore_;
}
//- Return the engines stroke
const dimensionedScalar& stroke() const
{
return stroke_;
}
//- Return the engines clearance-gap
const dimensionedScalar& clearance() const
{
return clearance_;
}
//- Return current crank-angle
scalar theta() const;
//- Return current crank-angle translated to a single revolution
// (value between -180 and 180 with 0 = top dead centre)
scalar thetaRevolution() const;
//- Return crank-angle increment
scalar deltaTheta() const;
//- Return current piston position
dimensionedScalar pistonPosition() const;
//- Return piston displacement for current time step
dimensionedScalar pistonDisplacement() const;
//- Return piston speed for current time step
dimensionedScalar pistonSpeed() const;
// Member functions overriding the virtual functions in time
//- Convert the user-time (CA deg) to real-time (s).
virtual scalar userTimeToTime(const scalar theta) const;
//- Convert the real-time (s) into user-time (CA deg)
virtual scalar timeToUserTime(const scalar t) const;
//- Read the control dictionary and set the write controls etc.
virtual void readDict();
// Edit
//- Read the controlDict and set all the parameters
virtual bool read();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,267 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 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 "engineValve.H"
#include "engineTime.H"
#include "polyMesh.H"
#include "interpolateXY.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::scalar Foam::engineValve::adjustCrankAngle(const scalar theta) const
{
if (theta < liftProfileStart_)
{
scalar adjustedTheta = theta;
while (adjustedTheta < liftProfileStart_)
{
adjustedTheta += liftProfileEnd_ - liftProfileStart_;
}
return adjustedTheta;
}
else if (theta > liftProfileEnd_)
{
scalar adjustedTheta = theta;
while (adjustedTheta > liftProfileEnd_)
{
adjustedTheta -= liftProfileEnd_ - liftProfileStart_;
}
return adjustedTheta;
}
else
{
return theta;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::engineValve::engineValve
(
const word& name,
const polyMesh& mesh,
const autoPtr<coordinateSystem>& valveCS,
const word& bottomPatchName,
const word& poppetPatchName,
const word& stemPatchName,
const word& curtainInPortPatchName,
const word& curtainInCylinderPatchName,
const word& detachInCylinderPatchName,
const word& detachInPortPatchName,
const labelList& detachFaces,
const graph& liftProfile,
const scalar minLift,
const scalar minTopLayer,
const scalar maxTopLayer,
const scalar minBottomLayer,
const scalar maxBottomLayer,
const scalar diameter
)
:
name_(name),
mesh_(mesh),
engineDB_(refCast<const engineTime>(mesh.time())),
csPtr_(valveCS),
bottomPatch_(bottomPatchName, mesh.boundaryMesh()),
poppetPatch_(poppetPatchName, mesh.boundaryMesh()),
stemPatch_(stemPatchName, mesh.boundaryMesh()),
curtainInPortPatch_(curtainInPortPatchName, mesh.boundaryMesh()),
curtainInCylinderPatch_(curtainInCylinderPatchName, mesh.boundaryMesh()),
detachInCylinderPatch_(detachInCylinderPatchName, mesh.boundaryMesh()),
detachInPortPatch_(detachInPortPatchName, mesh.boundaryMesh()),
detachFaces_(detachFaces),
liftProfile_(liftProfile),
liftProfileStart_(min(liftProfile_.x())),
liftProfileEnd_(max(liftProfile_.x())),
minLift_(minLift),
minTopLayer_(minTopLayer),
maxTopLayer_(maxTopLayer),
minBottomLayer_(minBottomLayer),
maxBottomLayer_(maxBottomLayer),
diameter_(diameter)
{}
// Construct from dictionary
Foam::engineValve::engineValve
(
const word& name,
const polyMesh& mesh,
const dictionary& dict
)
:
name_(name),
mesh_(mesh),
engineDB_(refCast<const engineTime>(mesh_.time())),
csPtr_
(
coordinateSystem::New
(
mesh_,
dict.subDict("coordinateSystem")
)
),
bottomPatch_(dict.lookup("bottomPatch"), mesh.boundaryMesh()),
poppetPatch_(dict.lookup("poppetPatch"), mesh.boundaryMesh()),
stemPatch_(dict.lookup("stemPatch"), mesh.boundaryMesh()),
curtainInPortPatch_
(
dict.lookup("curtainInPortPatch"),
mesh.boundaryMesh()
),
curtainInCylinderPatch_
(
dict.lookup("curtainInCylinderPatch"),
mesh.boundaryMesh()
),
detachInCylinderPatch_
(
dict.lookup("detachInCylinderPatch"),
mesh.boundaryMesh()
),
detachInPortPatch_
(
dict.lookup("detachInPortPatch"),
mesh.boundaryMesh()
),
detachFaces_(dict.lookup("detachFaces")),
liftProfile_("theta", "lift", name_, dict.lookup("liftProfile")),
liftProfileStart_(min(liftProfile_.x())),
liftProfileEnd_(max(liftProfile_.x())),
minLift_(readScalar(dict.lookup("minLift"))),
minTopLayer_(readScalar(dict.lookup("minTopLayer"))),
maxTopLayer_(readScalar(dict.lookup("maxTopLayer"))),
minBottomLayer_(readScalar(dict.lookup("minBottomLayer"))),
maxBottomLayer_(readScalar(dict.lookup("maxBottomLayer"))),
diameter_(readScalar(dict.lookup("diameter")))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::scalar Foam::engineValve::lift(const scalar theta) const
{
return interpolateXY
(
adjustCrankAngle(theta),
liftProfile_.x(),
liftProfile_.y()
);
}
bool Foam::engineValve::isOpen() const
{
return lift(engineDB_.theta()) >= minLift_;
}
Foam::scalar Foam::engineValve::curLift() const
{
return max
(
lift(engineDB_.theta()),
minLift_
);
}
Foam::scalar Foam::engineValve::curVelocity() const
{
return
-(
curLift()
- max
(
lift(engineDB_.theta() - engineDB_.deltaTheta()),
minLift_
)
)/(engineDB_.deltaTValue() + VSMALL);
}
Foam::labelList Foam::engineValve::movingPatchIDs() const
{
labelList mpIDs(2);
label nMpIDs = 0;
if (bottomPatch_.active())
{
mpIDs[nMpIDs] = bottomPatch_.index();
nMpIDs++;
}
if (poppetPatch_.active())
{
mpIDs[nMpIDs] = poppetPatch_.index();
nMpIDs++;
}
mpIDs.setSize(nMpIDs);
return mpIDs;
}
void Foam::engineValve::writeDict(Ostream& os) const
{
os << nl << name() << nl << token::BEGIN_BLOCK;
cs().writeDict(os);
os << "bottomPatch " << bottomPatch_.name() << token::END_STATEMENT << nl
<< "poppetPatch " << poppetPatch_.name() << token::END_STATEMENT << nl
<< "stemPatch " << stemPatch_.name() << token::END_STATEMENT << nl
<< "curtainInPortPatch " << curtainInPortPatch_.name()
<< token::END_STATEMENT << nl
<< "curtainInCylinderPatch " << curtainInCylinderPatch_.name()
<< token::END_STATEMENT << nl
<< "detachInCylinderPatch " << detachInCylinderPatch_.name()
<< token::END_STATEMENT << nl
<< "detachInPortPatch " << detachInPortPatch_.name()
<< token::END_STATEMENT << nl
<< "detachFaces " << detachFaces_ << token::END_STATEMENT << nl
<< "liftProfile " << nl << token::BEGIN_BLOCK
<< liftProfile_ << token::END_BLOCK << token::END_STATEMENT << nl
<< "minLift " << minLift_ << token::END_STATEMENT << nl
<< "minTopLayer " << minTopLayer_ << token::END_STATEMENT << nl
<< "maxTopLayer " << maxTopLayer_ << token::END_STATEMENT << nl
<< "minBottomLayer " << minBottomLayer_ << token::END_STATEMENT << nl
<< "maxBottomLayer " << maxBottomLayer_ << token::END_STATEMENT << nl
<< "diameter " << diameter_ << token::END_STATEMENT << nl
<< token::END_BLOCK << endl;
}
// ************************************************************************* //

View File

@ -0,0 +1,323 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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/>.
Class
Foam::engineValve
Description
Foam::engineValve
SourceFiles
engineValve.C
\*---------------------------------------------------------------------------*/
#ifndef engineValve_H
#define engineValve_H
#include "word.H"
#include "coordinateSystem.H"
#include "polyPatchID.H"
#include "graph.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class polyMesh;
class engineTime;
/*---------------------------------------------------------------------------*\
Class engineValve Declaration
\*---------------------------------------------------------------------------*/
class engineValve
{
// Private data
//- Name of valve
word name_;
//- Reference to engine mesh
const polyMesh& mesh_;
//- Reference to engine database
const engineTime& engineDB_;
//- Coordinate system
autoPtr<coordinateSystem> csPtr_;
// Patch and zone names
//- Valve bottom patch
polyPatchID bottomPatch_;
//- Valve poppet patch
polyPatchID poppetPatch_;
//- Valve stem patch
polyPatchID stemPatch_;
//- Valve curtain manifold patch
polyPatchID curtainInPortPatch_;
//- Valve curtain cylinder patch
polyPatchID curtainInCylinderPatch_;
//- Valve detach in cylinder patch
polyPatchID detachInCylinderPatch_;
//- Valve detach in port patch
polyPatchID detachInPortPatch_;
//- Faces to detach
labelList detachFaces_;
// Valve lift data
//- Valve lift profile
graph liftProfile_;
//- Lift curve start angle
scalar liftProfileStart_;
//- Lift curve end angle
scalar liftProfileEnd_;
//- Minimum valve lift. On this lift the valve is considered closed
const scalar minLift_;
// Valve layering data
//- Min top layer thickness
const scalar minTopLayer_;
//- Max top layer thickness
const scalar maxTopLayer_;
//- Min bottom layer thickness
const scalar minBottomLayer_;
//- Max bottom layer thickness
const scalar maxBottomLayer_;
//- Valve diameter
const scalar diameter_;
// Private Member Functions
//- Disallow default bitwise copy construct
engineValve(const engineValve&);
//- Disallow default bitwise assignment
void operator=(const engineValve&);
//- Adjust crank angle to drop within the limits of the lift profile
scalar adjustCrankAngle(const scalar theta) const;
public:
// Static data members
// Constructors
//- Construct from components
engineValve
(
const word& name,
const polyMesh& mesh,
const autoPtr<coordinateSystem>& valveCS,
const word& bottomPatchName,
const word& poppetPatchName,
const word& stemPatchName,
const word& curtainInPortPatchName,
const word& curtainInCylinderPatchName,
const word& detachInCylinderPatchName,
const word& detachInPortPatchName,
const labelList& detachFaces,
const graph& liftProfile,
const scalar minLift,
const scalar minTopLayer,
const scalar maxTopLayer,
const scalar minBottomLayer,
const scalar maxBottomLayer,
const scalar diameter
);
//- Construct from dictionary
engineValve
(
const word& name,
const polyMesh& mesh,
const dictionary& dict
);
// Destructor - default
// Member Functions
//- Return name
const word& name() const
{
return name_;
}
//- Return coordinate system
const coordinateSystem& cs() const
{
return csPtr_();
}
//- Return lift profile
const graph& liftProfile() const
{
return liftProfile_;
}
//- Return valve diameter
scalar diameter() const
{
return diameter_;
}
// Valve patches
//- Return ID of bottom patch
const polyPatchID& bottomPatchID() const
{
return bottomPatch_;
}
//- Return ID of poppet patch
const polyPatchID& poppetPatchID() const
{
return poppetPatch_;
}
//- Return ID of stem patch
const polyPatchID& stemPatchID() const
{
return stemPatch_;
}
//- Return ID of curtain in cylinder patch
const polyPatchID& curtainInCylinderPatchID() const
{
return curtainInCylinderPatch_;
}
//- Return ID of curtain in port patch
const polyPatchID& curtainInPortPatchID() const
{
return curtainInPortPatch_;
}
//- Return ID of detach in cylinder patch
const polyPatchID& detachInCylinderPatchID() const
{
return detachInCylinderPatch_;
}
//- Return ID of detach in port patch
const polyPatchID& detachInPortPatchID() const
{
return detachInPortPatch_;
}
//- Return face labels of detach curtain
const labelList& detachFaces() const
{
return detachFaces_;
}
// Valve layering thickness
scalar minTopLayer() const
{
return minTopLayer_;
}
scalar maxTopLayer() const
{
return maxTopLayer_;
}
scalar minBottomLayer() const
{
return minBottomLayer_;
}
scalar maxBottomLayer() const
{
return maxBottomLayer_;
}
// Valve position and velocity
//- Return valve lift given crank angle in degrees
scalar lift(const scalar theta) const;
//- Is the valve open?
bool isOpen() const;
//- Return current lift
scalar curLift() const;
//- Return valve velocity for current time-step
scalar curVelocity() const;
//- Return list of active patch labels for the valve head
// (stem is excluded)
labelList movingPatchIDs() const;
//- Write dictionary
void writeDict(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,108 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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/>.
Class
Foam::valveBank
Description
A list of valves.
\*---------------------------------------------------------------------------*/
#ifndef valveBank_H
#define valveBank_H
#include "PtrList.H"
#include "engineValve.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class valveBank Declaration
\*---------------------------------------------------------------------------*/
class valveBank
:
public PtrList<engineValve>
{
private:
// Private Member Functions
//- Disallow default bitwise copy construct
valveBank(const valveBank&);
//- Disallow default bitwise assignment
void operator=(const valveBank&);
public:
// Constructors
//- Construct from Istream
valveBank
(
const polyMesh& mesh,
Istream& is
)
{
PtrList<entry> valveEntries(is);
setSize(valveEntries.size());
forAll(valveEntries, valveI)
{
valveI,
set
(
new engineValve
(
valveEntries[valveI].keyword(),
mesh,
valveEntries[valveI].dict()
)
);
}
}
// Destructor - default
// Member Functions
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,26 @@
forAll(ign.sites(), i)
{
const ignitionSite& ignSite = ign.sites()[i];
if (ignSite.igniting())
{
forAll(ignSite.cells(), icelli)
{
label ignCell = ignSite.cells()[icelli];
Info<< "Igniting cell " << ignCell;
Info<< " state :"
<< ' ' << b[ignCell]
<< ' ' << Xi[ignCell]
<< ' ' << Su[ignCell]
<< ' ' << mgb[ignCell]
<< endl;
bEqn.diag()[ignSite.cells()[icelli]] +=
(
ignSite.strength()*ignSite.cellVolumes()[icelli]
*rhou[ignSite.cells()[icelli]]/ignSite.duration()
)/(b[ignSite.cells()[icelli]] + 0.001);
}
}
}

View File

@ -0,0 +1,74 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "ignition.H"
#include "fvMesh.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::ignition::igniting() const
{
if (!ignite())
{
return false;
}
bool igning = false;
forAll(ignSites_, i)
{
if (ignSites_[i].igniting())
{
igning = true;
}
}
return igning;
}
bool Foam::ignition::ignited() const
{
if (!ignite())
{
return false;
}
bool igned = false;
forAll(ignSites_, i)
{
if (ignSites_[i].ignited())
{
igned = true;
}
}
return igned;
}
// ************************************************************************* //

View File

@ -0,0 +1,116 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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/>.
Class
Foam::ignition
Description
Foam::ignition
SourceFiles
ignition.C
ignitionIO.C
\*---------------------------------------------------------------------------*/
#ifndef ignition_H
#define ignition_H
#include "ignitionSite.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class fvMesh;
/*---------------------------------------------------------------------------*\
Class ignition Declaration
\*---------------------------------------------------------------------------*/
class ignition
{
// Private data
const fvMesh& mesh_;
Switch ignite_;
PtrList<ignitionSite> ignSites_;
// Private Member Functions
//- Disallow default bitwise copy construct
ignition(const ignition&);
//- Disallow default bitwise assignment
void operator=(const ignition&);
public:
// Constructors
//- Construct from Istream and database
ignition(const dictionary&, const Time&, const fvMesh&);
//- Construct from Istream and engineTime
ignition(const dictionary&, const engineTime&, const fvMesh&);
// Member Functions
//- Return the set of ignition sites
const PtrList<ignitionSite>& sites()
{
return ignSites_;
}
// Check
bool ignite() const
{
return ignite_;
}
//- Are any of the ignition site currently igniting
bool igniting() const;
//- Has the mixture been ignited?
bool ignited() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,83 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "engineTime.H"
#include "ignition.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::ignition::ignition
(
const dictionary& combustionProperties,
const Time& db,
const fvMesh& mesh
)
:
mesh_(mesh),
ignite_(combustionProperties.lookup("ignite")),
ignSites_
(
combustionProperties.lookup("ignitionSites"),
ignitionSite::iNew(db, mesh)
)
{
if (ignite_)
{
Info<< "\nIgnition on" << endl;
}
else
{
Info<< "\nIgnition switched off" << endl;
}
}
Foam::ignition::ignition
(
const dictionary& combustionProperties,
const engineTime& edb,
const fvMesh& mesh
)
:
mesh_(mesh),
ignite_(combustionProperties.lookup("ignite")),
ignSites_
(
combustionProperties.lookup("ignitionSites"),
ignitionSite::iNew(edb, mesh)
)
{
if (ignite_)
{
Info<< "\nIgnition on" << endl;
}
else
{
Info<< "\nIgnition switched off" << endl;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,135 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "ignitionSite.H"
#include "Time.H"
#include "volFields.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::ignitionSite::findIgnitionCells(const fvMesh& mesh)
{
// Bit tricky: generate C and V before shortcutting if cannot find
// cell locally. mesh.C generation uses parallel communication.
const volVectorField& centres = mesh.C();
const scalarField& vols = mesh.V();
label ignCell = mesh.findCell(location_);
if (ignCell == -1)
{
return;
}
scalar radius = diameter_/2.0;
cells_.setSize(1);
cellVolumes_.setSize(1);
cells_[0] = ignCell;
cellVolumes_[0] = vols[ignCell];
scalar minDist = GREAT;
label nIgnCells = 1;
forAll(centres, celli)
{
scalar dist = mag(centres[celli] - location_);
if (dist < minDist)
{
minDist = dist;
}
if (dist < radius && celli != ignCell)
{
cells_.setSize(nIgnCells+1);
cellVolumes_.setSize(nIgnCells+1);
cells_[nIgnCells] = celli;
cellVolumes_[nIgnCells] = vols[celli];
nIgnCells++;
}
}
if (cells_.size())
{
Pout<< "Found ignition cells:" << endl << cells_ << endl;
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::labelList& Foam::ignitionSite::cells() const
{
if (mesh_.changing() && timeIndex_ != db_.timeIndex())
{
const_cast<ignitionSite&>(*this).findIgnitionCells(mesh_);
}
timeIndex_ = db_.timeIndex();
return cells_;
}
bool Foam::ignitionSite::igniting() const
{
scalar curTime = db_.value();
scalar deltaT = db_.deltaTValue();
return
(
(curTime - deltaT >= time_)
&&
(curTime - deltaT < time_ + max(duration_, deltaT) + SMALL)
);
}
bool Foam::ignitionSite::ignited() const
{
scalar curTime = db_.value();
scalar deltaT = db_.deltaTValue();
return(curTime - deltaT >= time_);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
void Foam::ignitionSite::operator=(const ignitionSite& is)
{
location_ = is.location_;
diameter_ = is.diameter_;
time_ = is.time_;
duration_ = is.duration_;
strength_ = is.strength_;
cells_ = is.cells_;
cellVolumes_ = is.cellVolumes_;
}
// ************************************************************************* //

View File

@ -0,0 +1,187 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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/>.
Class
Foam::ignitionSite
Description
Foam::ignitionSite
SourceFiles
ignitionSiteI.H
ignitionSite.C
ignitionSiteIO.C
\*---------------------------------------------------------------------------*/
#ifndef ignitionSite_H
#define ignitionSite_H
#include "vector.H"
#include "labelList.H"
#include "scalarList.H"
#include "autoPtr.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class Time;
class engineTime;
class fvMesh;
/*---------------------------------------------------------------------------*\
Class ignitionSite Declaration
\*---------------------------------------------------------------------------*/
class ignitionSite
{
// Private data
const Time& db_;
const fvMesh& mesh_;
dictionary ignitionSiteDict_;
vector location_;
scalar diameter_;
scalar time_;
scalar duration_;
scalar strength_;
labelList cells_;
scalarList cellVolumes_;
//- Current time index.
// Used during the update for moving meshes
mutable label timeIndex_;
// Private Member Functions
void findIgnitionCells(const fvMesh&);
public:
// Public classes
//- Class used for the read-construction of
// PtrLists of ignitionSite
class iNew
{
const Time& db_;
const fvMesh& mesh_;
public:
iNew(const Time& db, const fvMesh& mesh)
:
db_(db),
mesh_(mesh)
{}
autoPtr<ignitionSite> operator()(Istream& is) const
{
return autoPtr<ignitionSite>(new ignitionSite(is, db_, mesh_));
}
};
// Constructors
//- Construct from Istream and database
ignitionSite(Istream&, const Time&, const fvMesh&);
//- Construct from Istream and engineTime
ignitionSite(Istream&, const engineTime&, const fvMesh&);
//- Clone
autoPtr<ignitionSite> clone() const
{
return autoPtr<ignitionSite>(new ignitionSite(*this));
}
// Member Functions
// Access
const vector& location() const
{
return location_;
}
scalar diameter() const
{
return diameter_;
}
scalar time() const
{
return time_;
}
scalar duration() const
{
return duration_;
}
scalar strength() const
{
return strength_;
}
//- Return the ignition cells updated if the mesh moved
const labelList& cells() const;
const scalarList& cellVolumes() const
{
return cellVolumes_;
}
// Check
bool igniting() const;
bool ignited() const;
// Member Operators
void operator=(const ignitionSite&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,103 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "ignitionSite.H"
#include "engineTime.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::ignitionSite::ignitionSite
(
Istream& is,
const Time& db,
const fvMesh& mesh
)
:
db_(db),
mesh_(mesh),
ignitionSiteDict_(is),
location_(ignitionSiteDict_.lookup("location")),
diameter_(readScalar(ignitionSiteDict_.lookup("diameter"))),
time_
(
db_.userTimeToTime
(
readScalar(ignitionSiteDict_.lookup("start"))
)
),
duration_
(
db_.userTimeToTime
(
readScalar(ignitionSiteDict_.lookup("duration"))
)
),
strength_(readScalar(ignitionSiteDict_.lookup("strength"))),
timeIndex_(db_.timeIndex())
{
// Check state of Istream
is.check("ignitionSite::ignitionSite(Istream&)");
findIgnitionCells(mesh_);
}
Foam::ignitionSite::ignitionSite
(
Istream& is,
const engineTime& edb,
const fvMesh& mesh
)
:
db_(edb),
mesh_(mesh),
ignitionSiteDict_(is),
location_(ignitionSiteDict_.lookup("location")),
diameter_(readScalar(ignitionSiteDict_.lookup("diameter"))),
time_
(
db_.userTimeToTime
(
edb.degToTime(readScalar(ignitionSiteDict_.lookup("start")))
)
),
duration_
(
db_.userTimeToTime
(
edb.degToTime(readScalar(ignitionSiteDict_.lookup("duration")))
)
),
strength_(readScalar(ignitionSiteDict_.lookup("strength"))),
timeIndex_(db_.timeIndex())
{
// Check state of Istream
is.check("ignitionSite::ignitionSite(Istream&)");
findIgnitionCells(mesh_);
}
// ************************************************************************* //

View File

@ -0,0 +1,93 @@
dimensionedScalar StCorr("StCorr", dimless, 1.0);
if (ign.igniting())
{
// Calculate volume of ignition kernel
dimensionedScalar Vk("Vk", dimVolume, gSum(c*mesh.V().field()));
dimensionedScalar Ak("Ak", dimArea, 0.0);
if (Vk.value() > SMALL)
{
// Calculate kernel area from its volume
// and the dimensionality of the case
switch(mesh.nGeometricD())
{
case 3:
{
// Assume it is part-spherical
scalar sphereFraction
(
readScalar
(
combustionProperties.lookup
(
"ignitionSphereFraction"
)
)
);
Ak = sphereFraction*4.0*constant::mathematical::pi
*pow
(
3.0*Vk
/(sphereFraction*4.0*constant::mathematical::pi),
2.0/3.0
);
}
break;
case 2:
{
// Assume it is part-circular
dimensionedScalar thickness
(
combustionProperties.lookup("ignitionThickness")
);
scalar circleFraction
(
readScalar
(
combustionProperties.lookup
(
"ignitionCircleFraction"
)
)
);
Ak = circleFraction*constant::mathematical::pi*thickness
*sqrt
(
4.0*Vk
/(
circleFraction
*thickness
*constant::mathematical::pi
)
);
}
break;
case 1:
// Assume it is plane or two planes
Ak = dimensionedScalar
(
combustionProperties.lookup("ignitionKernelArea")
);
break;
}
// Calculate kernel area from b field consistent with the
// discretisation of the b equation.
const volScalarField mgb
(
fvc::div(nf, b, "div(phiSt,b)") - b*fvc::div(nf) + dMgb
);
dimensionedScalar AkEst = gSum(mgb*mesh.V().field());
StCorr.value() = max(min((Ak/AkEst).value(), 10.0), 1.0);
Info<< "StCorr = " << StCorr.value() << endl;
}
}

View File

@ -0,0 +1,18 @@
Info<< "Create mesh for time = "
<< runTime.timeName() << nl << endl;
autoPtr<engineMesh> meshPtr
(
engineMesh::New
(
IOobject
(
engineMesh::defaultRegion,
runTime.timeName(),
runTime,
Foam::IOobject::MUST_READ
)
)
);
engineMesh& mesh = meshPtr();

View File

@ -0,0 +1,8 @@
Info<< "Create engine time\n" << endl;
engineTime runTime
(
Time::controlDictName,
args.rootPath(),
args.caseName()
);