multiValveEngineState: New functionObject to print and log the piston and valve motion
for the multiValveEngine fvMeshMover. This replaced the hard-coded messages printed by the multiValveEngine class, providing automatic logging of the piston and valve speed and position and easy user extension or replacement to provide additional case-specific diagnostics without having to hack the core multiValveEngine code. A functionObject configuration file is provided so that the simple line can be added to the system/functions file to enable this functionObject.
This commit is contained in:
22
etc/caseDicts/functions/mesh/multiValveEngineState
Normal file
22
etc/caseDicts/functions/mesh/multiValveEngineState
Normal file
@ -0,0 +1,22 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Version: dev
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Description
|
||||
Writes the multi-valve engine motion state
|
||||
providing details of the piston and valve position, speed etc.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
type multiValveEngineState;
|
||||
libs ("libfvMeshMoversMultiValveEngine.so");
|
||||
|
||||
writeControl timeStep;
|
||||
writeInterval 1;
|
||||
|
||||
log true;
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -5,5 +5,6 @@ valve.C
|
||||
valveList.C
|
||||
crankConnectingRodMotion/crankConnectingRodMotion.C
|
||||
pistonPointEdgeData/pistonPointEdgeData.C
|
||||
multiValveEngineState/multiValveEngineState.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libfvMeshMoversMultiValveEngine
|
||||
|
||||
@ -174,27 +174,11 @@ bool Foam::fvMeshMovers::multiValveEngine::update()
|
||||
// Accumulate point motion from each moving object into newPoints field.
|
||||
pointField newPoints(mesh().points());
|
||||
|
||||
Info<< "Piston: " << nl;
|
||||
|
||||
piston_.updatePoints(newPoints);
|
||||
|
||||
Info<< " position from TDC: " << piston_.position() << " m" << nl
|
||||
<< " displacement: " << piston_.displacement() << " m" << nl
|
||||
<< " speed = " << piston_.speed() << " m/s" << nl
|
||||
<< " clearance: " << piston_.clearance() << " m" << endl;
|
||||
|
||||
forAll(valves_, valvei)
|
||||
{
|
||||
valveObject& valve = valves_[valvei];
|
||||
|
||||
Info<< "Valve " << valve.name << nl;
|
||||
|
||||
valve.updatePoints(newPoints);
|
||||
|
||||
Info<< " lift: " << (valve.isOpen() ? valve.lift() : 0.0) << " m "
|
||||
<< (valve.isOpen() ? "(open)" : "(closed)") << nl
|
||||
<< " speed: " << valve.speed() << " m/s" << nl
|
||||
<< " displacement: " << valve.displacement() << " m" << endl;
|
||||
valves_[valvei].updatePoints(newPoints);
|
||||
}
|
||||
|
||||
// Update the mesh according to the newPoints field.
|
||||
|
||||
@ -0,0 +1,179 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2024 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 "multiValveEngineState.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(multiValveEngineState, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
multiValveEngineState,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
const Foam::fvMeshMovers::multiValveEngine&
|
||||
Foam::functionObjects::multiValveEngineState::mve() const
|
||||
{
|
||||
return refCast<const fvMeshMovers::multiValveEngine>(mesh_.mover());
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::multiValveEngineState::multiValveEngineState
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
logFiles(obr_, name)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::multiValveEngineState::~multiValveEngineState()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::multiValveEngineState::read(const dictionary& dict)
|
||||
{
|
||||
fvMeshFunctionObject::read(dict);
|
||||
|
||||
resetName(typeName);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::multiValveEngineState::writeFileHeader
|
||||
(
|
||||
const label i
|
||||
)
|
||||
{
|
||||
writeHeader(file(), "Engine Motion State");
|
||||
writeCommented(file(), "Time");
|
||||
writeTabbed(file(), "piston from TDC");
|
||||
writeTabbed(file(), "piston speed");
|
||||
writeTabbed(file(), "piston displacement");
|
||||
writeTabbed(file(), "piston clearance");
|
||||
|
||||
const fvMeshMovers::multiValveEngine& mve = this->mve();
|
||||
const fvMeshMovers::multiValveEngine::valveList& valves = mve.valves;
|
||||
|
||||
forAll(valves, valvei)
|
||||
{
|
||||
const fvMeshMovers::multiValveEngine::valveObject& valve =
|
||||
valves[valvei];
|
||||
|
||||
writeTabbed(file(), valve.name + " lift");
|
||||
writeTabbed(file(), valve.name + " speed");
|
||||
writeTabbed(file(), valve.name + " displacement");
|
||||
}
|
||||
|
||||
file() << endl;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::multiValveEngineState::execute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::multiValveEngineState::write()
|
||||
{
|
||||
logFiles::write();
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
const fvMeshMovers::multiValveEngine& mve = this->mve();
|
||||
|
||||
const fvMeshMovers::multiValveEngine::pistonObject& piston = mve.piston;
|
||||
|
||||
Log << "Piston: " << nl
|
||||
<< " position from TDC: " << piston.position() << " m" << nl
|
||||
<< " speed = " << piston.speed() << " m/s" << nl
|
||||
<< " displacement: " << piston.displacement() << " m" << nl
|
||||
<< " clearance: " << piston.clearance() << " m" << endl;
|
||||
|
||||
writeTime(file());
|
||||
file()
|
||||
<< tab
|
||||
<< piston.position() << tab
|
||||
<< piston.speed() << tab
|
||||
<< piston.displacement() << tab
|
||||
<< piston.clearance();
|
||||
|
||||
|
||||
const fvMeshMovers::multiValveEngine::valveList& valves = mve.valves;
|
||||
|
||||
forAll(valves, valvei)
|
||||
{
|
||||
const fvMeshMovers::multiValveEngine::valveObject& valve =
|
||||
valves[valvei];
|
||||
|
||||
Log << "Valve " << valve.name << nl
|
||||
<< " lift: " << (valve.isOpen() ? valve.lift() : 0)
|
||||
<< " m "
|
||||
<< (valve.isOpen() ? "(open)" : "(closed)") << nl
|
||||
<< " speed: " << valve.speed() << " m/s" << nl
|
||||
<< " displacement: " << valve.displacement() << " m" << endl;
|
||||
|
||||
file()
|
||||
<< tab
|
||||
<< (valve.isOpen() ? valve.lift() : 0) << tab
|
||||
<< valve.speed() << tab
|
||||
<< valve.displacement();
|
||||
}
|
||||
|
||||
file() << endl;
|
||||
Log << endl;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,151 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2024 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::functionObjects::multiValveEngineState
|
||||
|
||||
Description
|
||||
Writes the multi-valve engine motion state
|
||||
|
||||
providing details of the position and speed of the piston and valves.
|
||||
|
||||
Usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: multiValveEngineState | yes |
|
||||
\endtable
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
multiValveEngineState
|
||||
{
|
||||
type multiValveEngineState;
|
||||
libs ("libfvMeshMoversMultiValveEngine.so");
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
Foam::functionObjects::logFiles
|
||||
Foam::fvMeshMovers::multiValveEngine
|
||||
|
||||
SourceFiles
|
||||
multiValveEngineState.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef multiValveEngineState_H
|
||||
#define multiValveEngineState_H
|
||||
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "logFiles.H"
|
||||
#include "multiValveEngine.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class multiValveEngineState Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class multiValveEngineState
|
||||
:
|
||||
public fvMeshFunctionObject,
|
||||
public logFiles
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
const fvMeshMovers::multiValveEngine& mve() const;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- File header information
|
||||
virtual void writeFileHeader(const label i);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("multiValveEngineState");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
multiValveEngineState
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construction
|
||||
multiValveEngineState(const multiValveEngineState&) = delete;
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~multiValveEngineState();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the multiValveEngineState data
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Return the list of fields required
|
||||
virtual wordList fields() const
|
||||
{
|
||||
return wordList::null();
|
||||
}
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual bool execute();
|
||||
|
||||
//- Write the multiValveEngineState
|
||||
virtual bool write();
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const multiValveEngineState&) = delete;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
19
tutorials/XiFluid/kivaTest/system/functions
Normal file
19
tutorials/XiFluid/kivaTest/system/functions
Normal file
@ -0,0 +1,19 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Version: dev
|
||||
\\/ M anipulation |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
format ascii;
|
||||
class dictionary;
|
||||
location "system";
|
||||
object functions;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#includeFunc multiValveEngineState
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -14,6 +14,7 @@ FoamFile
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#includeFunc multiValveEngineState
|
||||
#includeFunc checkMesh(executeControl=adjustableRunTime, executeInterval=5)
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
Reference in New Issue
Block a user