diff --git a/applications/solvers/combustion/PDRFoam/Make/options b/applications/solvers/combustion/PDRFoam/Make/options index 4e5b8fb9a077888bdd3802f41232ddfb6d7e4618..a1469d0ef0d73671d5528eacd231844c5e7ceae9 100644 --- a/applications/solvers/combustion/PDRFoam/Make/options +++ b/applications/solvers/combustion/PDRFoam/Make/options @@ -15,8 +15,7 @@ EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \ - -I$(LIB_SRC)/meshTools/lnInclude \ - -I$(LIB_SRC)/triSurface/lnInclude + -I$(LIB_SRC)/meshTools/lnInclude EXE_LIBS = \ -lengine \ diff --git a/applications/solvers/combustion/fireFoam/Allwclean b/applications/solvers/combustion/fireFoam/Allwclean new file mode 100755 index 0000000000000000000000000000000000000000..5c3970936398bfd7c2501ac83a56b8cd4c634043 --- /dev/null +++ b/applications/solvers/combustion/fireFoam/Allwclean @@ -0,0 +1,9 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory +set -x + +wclean libso combustionModels +wclean all sensibleEnthalpyCombustionThermophysicalModels +wclean + +# ----------------------------------------------------------------- end-of-file diff --git a/applications/solvers/combustion/fireFoam/Allwmake b/applications/solvers/combustion/fireFoam/Allwmake new file mode 100755 index 0000000000000000000000000000000000000000..ada80d6666560713a163f5060e14c1484e7cd712 --- /dev/null +++ b/applications/solvers/combustion/fireFoam/Allwmake @@ -0,0 +1,9 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory +set -x + +sensibleEnthalpyCombustionThermophysicalModels/Allwmake +wmake libso combustionModels +wmake + +# ----------------------------------------------------------------- end-of-file diff --git a/applications/solvers/combustion/fireFoam/Make/files b/applications/solvers/combustion/fireFoam/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..826d736bd0f66081e00d868f15363948aa6211a5 --- /dev/null +++ b/applications/solvers/combustion/fireFoam/Make/files @@ -0,0 +1,4 @@ +fireFoam.C + +EXE = $(FOAM_APPBIN)/fireFoam + diff --git a/applications/solvers/combustion/fireFoam/Make/options b/applications/solvers/combustion/fireFoam/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..07d596f7f021fdf6cbb0db688f671890c7985583 --- /dev/null +++ b/applications/solvers/combustion/fireFoam/Make/options @@ -0,0 +1,23 @@ +EXE_INC = \ + -I./combustionModels/lnInclude \ + -I./sensibleEnthalpyCombustionThermophysicalModels/basic/lnInclude \ + -I./sensibleEnthalpyCombustionThermophysicalModels/reactionThermo/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel \ + -I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude + + +EXE_LIBS = \ + -lbasicSensibleEnthalpyThermophysicalModels \ + -lreactionSensibleEnthalpyThermophysicalModels \ + -lcombustionModels \ + -lspecie \ + -lreactionThermophysicalModels \ + -lbasicThermophysicalModels \ + -lfiniteVolume \ + -lcompressibleLESModels \ + -lcompressibleRASModels \ + -lradiation diff --git a/applications/solvers/combustion/fireFoam/UEqn.H b/applications/solvers/combustion/fireFoam/UEqn.H new file mode 100644 index 0000000000000000000000000000000000000000..3b61f2c7b95cfd705eb219d208fcd55f5dc02185 --- /dev/null +++ b/applications/solvers/combustion/fireFoam/UEqn.H @@ -0,0 +1,36 @@ +fvVectorMatrix UEqn +( + fvm::ddt(rho, U) + + fvm::div(phi, U) + + turbulence->divDevRhoReff(U) +); + +UEqn.relax(); + +if (oCorr == nOuterCorr - 1) +{ + solve + ( + UEqn + == + fvc::reconstruct + ( + fvc::interpolate(rho)*(g & mesh.Sf()) + - fvc::snGrad(p)*mesh.magSf() + ), + mesh.solver("UFinal") + ); +} +else +{ + solve + ( + UEqn + == + fvc::reconstruct + ( + fvc::interpolate(rho)*(g & mesh.Sf()) + - fvc::snGrad(p)*mesh.magSf() + ) + ); +} diff --git a/applications/solvers/combustion/fireFoam/combustionModels/Make/files b/applications/solvers/combustion/fireFoam/combustionModels/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..5b1262b70d476c5b469d5fcad4404f3a75f08512 --- /dev/null +++ b/applications/solvers/combustion/fireFoam/combustionModels/Make/files @@ -0,0 +1,9 @@ +combustionModel/combustionModel.C +combustionModel/newCombustionModel.C + +infinitelyFastChemistry/infinitelyFastChemistry.C + +noCombustion/noCombustion.C + +LIB = $(FOAM_LIBBIN)/libcombustionModels + diff --git a/applications/solvers/combustion/fireFoam/combustionModels/Make/options b/applications/solvers/combustion/fireFoam/combustionModels/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..42f59c8e176d991d138c6378b6dd260e163101b0 --- /dev/null +++ b/applications/solvers/combustion/fireFoam/combustionModels/Make/options @@ -0,0 +1,11 @@ +EXE_INC = \ + -I../sensibleEnthalpyCombustionThermophysicalModels/basic/lnInclude \ + -I../sensibleEnthalpyCombustionThermophysicalModels/reactionThermo/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ + -I$(FOAM_SRC)/turbulenceModels/compressible/turbulenceModel \ + -I$(FOAM_SRC)/finiteVolume/lnInclude + +LIB_LIBS = \ + -lfiniteVolume diff --git a/applications/solvers/combustion/fireFoam/combustionModels/combustionModel/combustionModel.C b/applications/solvers/combustion/fireFoam/combustionModels/combustionModel/combustionModel.C new file mode 100644 index 0000000000000000000000000000000000000000..538d43073e63526057913e064e11ea093cd4039a --- /dev/null +++ b/applications/solvers/combustion/fireFoam/combustionModels/combustionModel/combustionModel.C @@ -0,0 +1,109 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "combustionModel.H" +#include "fvm.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(combustionModel, 0); + defineRunTimeSelectionTable(combustionModel, dictionary); +}; + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::combustionModel::combustionModel +( + const dictionary& combustionProperties, + const hsCombustionThermo& thermo, + const compressible::turbulenceModel& turbulence, + const surfaceScalarField& phi, + const volScalarField& rho +) +: + combustionModelCoeffs_ + ( + combustionProperties.subDict + ( + word(combustionProperties.lookup("combustionModel")) + "Coeffs" + ) + ), + thermo_(thermo), + turbulence_(turbulence), + mesh_(phi.mesh()), + phi_(phi), + rho_(rho), + stoicRatio_(thermo.lookup("stoichiometricAirFuelMassRatio")), + s_(thermo.lookup("stoichiometricOxygenFuelMassRatio")), + qFuel_(thermo_.lookup("qFuel")), + composition_(thermo.composition()) +{} + + +// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * // + +Foam::combustionModel::~combustionModel() +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +Foam::tmp<Foam::fvScalarMatrix> +Foam::combustionModel::combustionModel::R(volScalarField& fu) const +{ + const basicMultiComponentMixture& composition = thermo_.composition(); + const volScalarField& ft = composition.Y("ft"); + volScalarField fres = composition.fres(ft, stoicRatio_.value()); + volScalarField wFuelNorm = this->wFuelNorm()*pos(fu - fres); + + return wFuelNorm*fres - fvm::Sp(wFuelNorm, fu); +} + + +Foam::tmp<Foam::volScalarField> Foam::combustionModel::combustionModel::dQ +( + const fvScalarMatrix& Rfu +) const +{ + const basicMultiComponentMixture& composition = thermo_.composition(); + const volScalarField& fu = composition.Y("fu"); + + return (-qFuel_)*(Rfu & fu); +} + + +bool Foam::combustionModel::read(const dictionary& combustionProperties) +{ + combustionModelCoeffs_ = combustionProperties.subDict(type() + "Coeffs"); + + return true; +} + + +// ************************************************************************* // diff --git a/applications/solvers/combustion/fireFoam/combustionModels/combustionModel/combustionModel.H b/applications/solvers/combustion/fireFoam/combustionModels/combustionModel/combustionModel.H new file mode 100644 index 0000000000000000000000000000000000000000..19a3392bbb6ad05c6e00baf4ae9128da5055ef1b --- /dev/null +++ b/applications/solvers/combustion/fireFoam/combustionModels/combustionModel/combustionModel.H @@ -0,0 +1,210 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::combustionModel + +Description + Base class for all non-premixed combustion models. + +SourceFiles + combustionModel.C + +\*---------------------------------------------------------------------------*/ + +#ifndef combustionModel_H +#define combustionModel_H + +#include "IOdictionary.H" +#include "hsCombustionThermo.H" +#include "turbulenceModel.H" +#include "multivariateSurfaceInterpolationScheme.H" +#include "runTimeSelectionTables.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class combustionModel Declaration +\*---------------------------------------------------------------------------*/ + +class combustionModel +{ + +protected: + + // Protected data + + //- Dictionary of coefficients for the particular model + dictionary combustionModelCoeffs_; + + //- Reference to the thermodynamic + const hsCombustionThermo& thermo_; + + //- Reference to the turbulence model + const compressible::turbulenceModel& turbulence_; + + //- Reference to the mesh database + const fvMesh& mesh_; + + //- Reference to mass-flux field + const surfaceScalarField& phi_; + + //- Reference to the density field + const volScalarField& rho_; + + //- Stoichiometric air-fuel mass ratio + dimensionedScalar stoicRatio_; + + //- Stoichiometric oxygen-fuel mass ratio + dimensionedScalar s_; + + //- Heat of combustion (J/Kg) + dimensionedScalar qFuel_; + + +private: + + // Private Member Functions + + //- Disallow copy construct + combustionModel(const combustionModel&); + + //- Disallow default bitwise assignment + void operator=(const combustionModel&); + + const basicMultiComponentMixture& composition_; + + +public: + + //- Runtime type information + TypeName("combustionModel"); + + + // Declare run-time constructor selection table + + declareRunTimeSelectionTable + ( + autoPtr, + combustionModel, + dictionary, + ( + const dictionary& combustionProperties, + const hsCombustionThermo& thermo, + const compressible::turbulenceModel& turbulence, + const surfaceScalarField& phi, + const volScalarField& rho + ), + ( + combustionProperties, + thermo, + turbulence, + phi, + rho + ) + ); + + + // Selectors + + //- Return a reference to the selected combustion model + static autoPtr<combustionModel> New + ( + const dictionary& combustionProperties, + const hsCombustionThermo& thermo, + const compressible::turbulenceModel& turbulence, + const surfaceScalarField& phi, + const volScalarField& rho + ); + + + // Constructors + + //- Construct from components + combustionModel + ( + const dictionary& combustionProperties, + const hsCombustionThermo& thermo, + const compressible::turbulenceModel& turbulence, + const surfaceScalarField& phi, + const volScalarField& rho + ); + + + //- Destructor + virtual ~combustionModel(); + + + // Member Functions + + // Access functions + + //- Access composition + const basicMultiComponentMixture& composition() const + { + return composition_; + } + + //- Access combustion dictionary + const dictionary combustionModelCoeffs() const + { + return combustionModelCoeffs_; + } + + //- Access heat of combustion + const dimensionedScalar qFuel() const + { + return qFuel_; + } + + //- Return normalised consumption rate of (fu - fres) + virtual tmp<volScalarField> wFuelNorm() const = 0; + + //- Fuel consumption rate matrix i.e. source-term for the fuel equation + virtual tmp<fvScalarMatrix> R(volScalarField& fu) const; + + //- Heat-release rate calculated from the given + // fuel consumption rate matrix + virtual tmp<volScalarField> dQ(const fvScalarMatrix& Rfu) const; + + //- Correct combustion rate + virtual void correct() = 0; + + //- Update properties from given dictionary + virtual bool read(const dictionary& combustionProperties) = 0; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/combustion/fireFoam/combustionModels/combustionModel/newCombustionModel.C b/applications/solvers/combustion/fireFoam/combustionModels/combustionModel/newCombustionModel.C new file mode 100644 index 0000000000000000000000000000000000000000..31308b8ccd5875ec6b073e92f5e4a5cea9209dd3 --- /dev/null +++ b/applications/solvers/combustion/fireFoam/combustionModels/combustionModel/newCombustionModel.C @@ -0,0 +1,67 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "combustionModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +Foam::autoPtr<Foam::combustionModel> Foam::combustionModel::New +( + const dictionary& combustionProperties, + const hsCombustionThermo& thermo, + const compressible::turbulenceModel& turbulence, + const surfaceScalarField& phi, + const volScalarField& rho +) +{ + word combustionModelTypeName = combustionProperties.lookup + ( + "combustionModel" + ); + + Info<< "Selecting combustion model " << combustionModelTypeName << endl; + + dictionaryConstructorTable::iterator cstrIter = + dictionaryConstructorTablePtr_->find(combustionModelTypeName); + + if (cstrIter == dictionaryConstructorTablePtr_->end()) + { + FatalErrorIn + ( + "combustionModel::New" + ) << "Unknown combustionModel type " + << combustionModelTypeName << endl << endl + << "Valid combustionModels are : " << endl + << dictionaryConstructorTablePtr_->toc() + << exit(FatalError); + } + + return autoPtr<combustionModel> + (cstrIter()(combustionProperties, thermo, turbulence, phi, rho)); +} + + +// ************************************************************************* // diff --git a/applications/solvers/combustion/fireFoam/combustionModels/infinitelyFastChemistry/infinitelyFastChemistry.C b/applications/solvers/combustion/fireFoam/combustionModels/infinitelyFastChemistry/infinitelyFastChemistry.C new file mode 100644 index 0000000000000000000000000000000000000000..2e040e1eac95e6f20c995279547335b6441e7c0e --- /dev/null +++ b/applications/solvers/combustion/fireFoam/combustionModels/infinitelyFastChemistry/infinitelyFastChemistry.C @@ -0,0 +1,94 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "infinitelyFastChemistry.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace combustionModels +{ + defineTypeNameAndDebug(infinitelyFastChemistry, 0); + addToRunTimeSelectionTable + ( + combustionModel, + infinitelyFastChemistry, + dictionary + ); +}; +}; + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::combustionModels::infinitelyFastChemistry::infinitelyFastChemistry +( + const dictionary& combustionProperties, + const hsCombustionThermo& thermo, + const compressible::turbulenceModel& turbulence, + const surfaceScalarField& phi, + const volScalarField& rho +) +: + combustionModel(combustionProperties, thermo, turbulence, phi, rho), + C_(readScalar(combustionModelCoeffs_.lookup("C"))) +{} + + +// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * // + +Foam::combustionModels::infinitelyFastChemistry::~infinitelyFastChemistry() +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void Foam::combustionModels::infinitelyFastChemistry::correct() +{} + + +Foam::tmp<Foam::volScalarField> +Foam::combustionModels::infinitelyFastChemistry::wFuelNorm() const +{ + return rho_/(mesh_.time().deltaT()*C_); +} + + +bool Foam::combustionModels::infinitelyFastChemistry::read +( + const dictionary& combustionProperties +) +{ + combustionModel::read(combustionProperties); + combustionModelCoeffs_.lookup("C") >> C_ ; + + return true; +} + + +// ************************************************************************* // diff --git a/applications/solvers/combustion/fireFoam/combustionModels/infinitelyFastChemistry/infinitelyFastChemistry.H b/applications/solvers/combustion/fireFoam/combustionModels/infinitelyFastChemistry/infinitelyFastChemistry.H new file mode 100644 index 0000000000000000000000000000000000000000..4c62e5fa03d7f12d090a202a2fef4fbcbe81e45d --- /dev/null +++ b/applications/solvers/combustion/fireFoam/combustionModels/infinitelyFastChemistry/infinitelyFastChemistry.H @@ -0,0 +1,119 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::combustionModels::infinitelyFastChemistry + +Description + Simple infinitely fast chemistry combustion model based on the principle + mixed is burnt. Additional parameter C is used to distribute the heat + release rate.in time + +SourceFiles + infinitelyFastChemistry.C + +\*---------------------------------------------------------------------------*/ + +#ifndef infinitelyFastChemistry_H +#define infinitelyFastChemistry_H + +#include "fvc.H" +#include "combustionModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace combustionModels +{ + +/*---------------------------------------------------------------------------*\ + Class infinitelyFastChemistry Declaration +\*---------------------------------------------------------------------------*/ + +class infinitelyFastChemistry +: + public combustionModel +{ + // Private data + + //- Model constant + scalar C_; + + // Private Member Functions + + //- Disallow copy construct + infinitelyFastChemistry(const infinitelyFastChemistry&); + + //- Disallow default bitwise assignment + void operator=(const infinitelyFastChemistry&); + + +public: + + //- Runtime type information + TypeName("infinitelyFastChemistry"); + + + // Constructors + + //- Construct from components + infinitelyFastChemistry + ( + const dictionary& combustionProperties, + const hsCombustionThermo& thermo, + const compressible::turbulenceModel& turbulence, + const surfaceScalarField& phi, + const volScalarField& rho + ); + + + // Destructor + + virtual ~infinitelyFastChemistry(); + + + // Member Functions + + //- Update properties from given dictionary + virtual bool read(const dictionary& combustionProperties); + + //- Correct combustion rate + virtual void correct(); + + //- Return normalised consumption rate of (fu - fres) + virtual tmp<volScalarField> wFuelNorm() const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace combustionModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/combustion/fireFoam/combustionModels/noCombustion/noCombustion.C b/applications/solvers/combustion/fireFoam/combustionModels/noCombustion/noCombustion.C new file mode 100644 index 0000000000000000000000000000000000000000..dd75660aae354b7d3ddca810ceb4f22355641da1 --- /dev/null +++ b/applications/solvers/combustion/fireFoam/combustionModels/noCombustion/noCombustion.C @@ -0,0 +1,103 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "noCombustion.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace combustionModels +{ + defineTypeNameAndDebug(noCombustion, 0); + addToRunTimeSelectionTable + ( + combustionModel, + noCombustion, + dictionary + ); +}; +}; + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::combustionModels::noCombustion::noCombustion +( + const dictionary& combustionProperties, + const hsCombustionThermo& thermo, + const compressible::turbulenceModel& turbulence, + const surfaceScalarField& phi, + const volScalarField& rho +) +: + combustionModel(combustionProperties, thermo, turbulence, phi, rho) +{} + + +// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * // + +Foam::combustionModels::noCombustion::~noCombustion() +{} + + +void Foam::combustionModels::noCombustion::correct() +{} + + +Foam::tmp<Foam::volScalarField> +Foam::combustionModels::noCombustion::wFuelNorm() const +{ + return tmp<Foam::volScalarField> + ( + new volScalarField + ( + IOobject + ( + "wFuelNorm", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar("wFuelNorm", dimMass/dimTime/pow3(dimLength), 0.0) + ) + ); +} + + +bool Foam::combustionModels::noCombustion::read +( + const dictionary& combustionProperties +) +{ + return combustionModel::read(combustionProperties); +} + + +// ************************************************************************* // diff --git a/applications/solvers/combustion/fireFoam/combustionModels/noCombustion/noCombustion.H b/applications/solvers/combustion/fireFoam/combustionModels/noCombustion/noCombustion.H new file mode 100644 index 0000000000000000000000000000000000000000..e381413cd8f208d77d5c2553bfbccb22a62fe968 --- /dev/null +++ b/applications/solvers/combustion/fireFoam/combustionModels/noCombustion/noCombustion.H @@ -0,0 +1,113 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::combustionModel::noCombustion + +Description + No combustion + +SourceFiles + noCombustion.C + +\*---------------------------------------------------------------------------*/ + +#ifndef noCombustion_H +#define noCombustion_H + +#include "combustionModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace combustionModels +{ + +/*---------------------------------------------------------------------------*\ + Class noCombustion Declaration +\*---------------------------------------------------------------------------*/ + +class noCombustion +: + public combustionModel +{ + // Private data + + + // Private Member Functions + + //- Disallow copy construct + noCombustion(const noCombustion&); + + //- Disallow default bitwise assignment + void operator=(const noCombustion&); + + +public: + + //- Runtime type information + TypeName("noCombustion"); + + + // Constructors + + //- Construct from components + noCombustion + ( + const dictionary& combustionProperties, + const hsCombustionThermo& thermo, + const compressible::turbulenceModel& turbulence, + const surfaceScalarField& phi, + const volScalarField& rho + ); + + + // Destructor + + virtual ~noCombustion(); + + // Member Functions + + //- Update properties from given dictionary + virtual bool read(const dictionary& combustionProperties); + + //- Correct combustion rate + virtual void correct(); + + //- Return normalised consumption rate of (fu - fres) + virtual tmp<volScalarField> wFuelNorm() const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace combustionModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/combustion/fireFoam/createFields.H b/applications/solvers/combustion/fireFoam/createFields.H new file mode 100644 index 0000000000000000000000000000000000000000..a399df8536723747cd9f2a32b379e6c5bc9dd996 --- /dev/null +++ b/applications/solvers/combustion/fireFoam/createFields.H @@ -0,0 +1,130 @@ +Info<< "Reading thermophysical properties\n" << endl; + +autoPtr<hsCombustionThermo> pThermo +( + hsCombustionThermo::New(mesh) +); + +hsCombustionThermo& thermo = pThermo(); + +basicMultiComponentMixture& composition = thermo.composition(); + +volScalarField rho +( + IOobject + ( + "rho", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + thermo.rho() +); + +dimensionedScalar stoicRatio +( + thermo.lookup("stoichiometricAirFuelMassRatio") +); + +volScalarField& p = thermo.p(); +volScalarField& hs = thermo.hs(); + +const volScalarField& psi = thermo.psi(); + +volScalarField& ft = composition.Y("ft"); +volScalarField& fu = composition.Y("fu"); + +Info<< "Reading field U\n" << endl; + +volVectorField U +( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh +); + +#include "compressibleCreatePhi.H" + +Info<< "Creating turbulence model\n" << endl; +autoPtr<compressible::turbulenceModel> turbulence +( + compressible::turbulenceModel::New(rho, U, phi, thermo) +); + +IOdictionary combustionProperties +( + IOobject + ( + "combustionProperties", + runTime.constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) +); + +Info<< "Creating combustion model\n" << endl; +autoPtr<combustionModel::combustionModel> combustion +( + combustionModel::combustionModel::New + ( + combustionProperties, + thermo, + turbulence(), + phi, + rho + ) +); + +volScalarField dQ +( + IOobject + ( + "dQ", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh, + dimensionedScalar("dQ", dimMass/pow3(dimTime)/dimLength, 0.0) +); + + +Info<< "Creating field DpDt\n" << endl; +volScalarField DpDt = + fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p); + + +Info<< "Calculating field g.h\n" << endl; +volScalarField gh("gh", g & mesh.C()); + +surfaceScalarField ghf("gh", g & mesh.Cf()); + +p += rho*gh; + +thermo.correct(); + +dimensionedScalar initialMass = fvc::domainIntegrate(rho); + + +multivariateSurfaceInterpolationScheme<scalar>::fieldTable fields; + +if (composition.contains("ft")) +{ + fields.add(composition.Y("ft")); +} + +if (composition.contains("fu")) +{ + fields.add(composition.Y("fu")); +} + +fields.add(hs); diff --git a/applications/solvers/combustion/fireFoam/fireFoam.C b/applications/solvers/combustion/fireFoam/fireFoam.C new file mode 100644 index 0000000000000000000000000000000000000000..246a186c903546aaa10a17e732beb87d1745bd71 --- /dev/null +++ b/applications/solvers/combustion/fireFoam/fireFoam.C @@ -0,0 +1,103 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + fireFoam + +Description + Transient Solver for Fires and turbulent diffusion flames + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "hsCombustionThermo.H" +#include "turbulenceModel.H" +#include "combustionModel.H" + +#include "radiationModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + #include "createTime.H" + #include "createMesh.H" + #include "readGravitationalAcceleration.H" + #include "initContinuityErrs.H" + #include "createFields.H" + #include "createRadiationModel.H" + #include "readTimeControls.H" + #include "compressibleCourantNo.H" + #include "setInitialDeltaT.H" + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info<< "\nStarting time loop\n" << endl; + + while (runTime.run()) + { + #include "readPISOControls.H" + #include "readTimeControls.H" + #include "compressibleCourantNo.H" + #include "setDeltaT.H" + + runTime++; + Info<< "Time = " << runTime.timeName() << nl << endl; + + #include "rhoEqn.H" + + // --- Pressure-velocity PIMPLE corrector loop + for (int oCorr=0; oCorr<nOuterCorr; oCorr++) + { + #include "UEqn.H" + + #include "ftEqn.H" + #include "fuhsEqn.H" + + // --- PISO loop + for (int corr=0; corr<nCorr; corr++) + { + #include "pEqn.H" + } + } + + turbulence->correct(); + + rho = thermo.rho(); + + runTime.write(); + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + + } + + Info<< "End\n" << endl; + + return 0; +} + +// ************************************************************************* // diff --git a/applications/solvers/combustion/fireFoam/ftEqn.H b/applications/solvers/combustion/fireFoam/ftEqn.H new file mode 100644 index 0000000000000000000000000000000000000000..57406da753360b61b8b352bf5f737a64cb057bf3 --- /dev/null +++ b/applications/solvers/combustion/fireFoam/ftEqn.H @@ -0,0 +1,25 @@ +tmp<fv::convectionScheme<scalar> > mvConvection +( + fv::convectionScheme<scalar>::New + ( + mesh, + fields, + phi, + mesh.divScheme("div(phi,ft_b_h)") + ) +); + +{ + fvScalarMatrix ftEqn + ( + fvm::ddt(rho, ft) + + mvConvection->fvmDiv(phi, ft) + - fvm::laplacian(turbulence->alphaEff(), ft) + ); + + ftEqn.relax(); + ftEqn.solve(); +} + +Info<< "max(ft) = " << max(ft).value() << endl; +Info<< "min(ft) = " << min(ft).value() << endl; diff --git a/applications/solvers/combustion/fireFoam/fuhsEqn.H b/applications/solvers/combustion/fireFoam/fuhsEqn.H new file mode 100644 index 0000000000000000000000000000000000000000..798cee4007e4979d948a7ba4d44af90aba62f5cb --- /dev/null +++ b/applications/solvers/combustion/fireFoam/fuhsEqn.H @@ -0,0 +1,47 @@ +{ + // Solve fuel equation + // ~~~~~~~~~~~~~~~~~~~ + fvScalarMatrix R = combustion->R(fu); + + { + fvScalarMatrix fuEqn + ( + fvm::ddt(rho, fu) + + mvConvection->fvmDiv(phi, fu) + - fvm::laplacian(turbulence->alphaEff(), fu) + == + R + ); + + fuEqn.relax(); + fuEqn.solve(); + } + + Info<< "max(fu) = " << max(fu).value() << endl; + Info<< "min(fu) = " << min(fu).value() << endl; + + + // Solve sensible enthalpy equation + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + radiation->correct(); + dQ = combustion->dQ(R); + + { + fvScalarMatrix hsEqn + ( + fvm::ddt(rho, hs) + + mvConvection->fvmDiv(phi,hs) + - fvm::laplacian(turbulence->alphaEff(), hs) + == + DpDt + + dQ + + radiation->Shs(thermo) + ); + + hsEqn.relax(); + hsEqn.solve(); + } + + thermo.correct(); + combustion->correct(); +} diff --git a/applications/solvers/combustion/fireFoam/pEqn.H b/applications/solvers/combustion/fireFoam/pEqn.H new file mode 100644 index 0000000000000000000000000000000000000000..907398581f2db2bc49275614b726c2ca2aeedabe --- /dev/null +++ b/applications/solvers/combustion/fireFoam/pEqn.H @@ -0,0 +1,64 @@ +bool closedVolume = false; + +rho = thermo.rho(); + +volScalarField rUA = 1.0/UEqn.A(); +surfaceScalarField rhorUAf("(rho*(1|A(U)))", fvc::interpolate(rho*rUA)); +U = rUA*UEqn.H(); + +surfaceScalarField phiU +( + fvc::interpolate(rho) + *( + (fvc::interpolate(U) & mesh.Sf()) + + fvc::ddtPhiCorr(rUA, rho, U, phi) + ) +); + +phi = phiU + rhorUAf*fvc::interpolate(rho)*(g & mesh.Sf()); + +for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) +{ + surfaceScalarField rhorUAf = fvc::interpolate(rho*rUA); + + fvScalarMatrix pEqn + ( + fvm::ddt(psi,p) + + fvc::div(phi) + - fvm::laplacian(rhorUAf, p) + ); + + closedVolume = p.needReference(); + + if (corr == nCorr-1 && nonOrth == nNonOrthCorr) + { + pEqn.solve(mesh.solver(p.name() + "Final")); + } + else + { + pEqn.solve(mesh.solver(p.name())); + } + + if (nonOrth == nNonOrthCorr) + { + phi += pEqn.flux(); + } +} + +DpDt = fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p); + +#include "rhoEqn.H" +#include "compressibleContinuityErrs.H" + +U += rUA*fvc::reconstruct((phi - phiU)/rhorUAf); +U.correctBoundaryConditions(); + +// For closed-volume cases adjust the pressure and density levels +// to obey overall mass continuity +if (closedVolume) +{ + p += + (initialMass - fvc::domainIntegrate(thermo.psi()*p)) + /fvc::domainIntegrate(thermo.psi()); + rho = thermo.rho(); +} diff --git a/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/Allwmake b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/Allwmake new file mode 100755 index 0000000000000000000000000000000000000000..e59cf8471513e0f7a96b7ed8ce2d9129ef4f5578 --- /dev/null +++ b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/Allwmake @@ -0,0 +1,8 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory +set -x + +wmake libso basic +wmake libso reactionThermo + +# ----------------------------------------------------------------- end-of-file diff --git a/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/basic/Make/files b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/basic/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..ca1ec78b98facb2aa0b9bb51250ec6c7a8e70a63 --- /dev/null +++ b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/basic/Make/files @@ -0,0 +1,4 @@ +psiThermo/basicSensiblePsiThermo/basicSensiblePsiThermo.C +psiThermo/basicSensiblePsiThermo/newBasicSensiblePsiThermo.C + +LIB = $(FOAM_LIBBIN)/libbasicSensibleEnthalpyThermophysicalModels diff --git a/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/basic/Make/options b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/basic/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..8bdd75aecbca9cd22deb948dad41b1ae44815702 --- /dev/null +++ b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/basic/Make/options @@ -0,0 +1,7 @@ +EXE_INC = \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude + +LIB_LIBS = \ + -lfiniteVolume diff --git a/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/basic/psiThermo/basicSensiblePsiThermo/basicSensiblePsiThermo.C b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/basic/psiThermo/basicSensiblePsiThermo/basicSensiblePsiThermo.C new file mode 100644 index 0000000000000000000000000000000000000000..5d41d00c93a2a054de86e4f725980262211f6f1e --- /dev/null +++ b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/basic/psiThermo/basicSensiblePsiThermo/basicSensiblePsiThermo.C @@ -0,0 +1,52 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "basicSensiblePsiThermo.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(basicSensiblePsiThermo, 0); + defineRunTimeSelectionTable(basicSensiblePsiThermo, fvMesh); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::basicSensiblePsiThermo::basicSensiblePsiThermo(const fvMesh& mesh) +: + basicThermo(mesh) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::basicSensiblePsiThermo::~basicSensiblePsiThermo() +{} + + +// ************************************************************************* // diff --git a/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/basic/psiThermo/basicSensiblePsiThermo/basicSensiblePsiThermo.H b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/basic/psiThermo/basicSensiblePsiThermo/basicSensiblePsiThermo.H new file mode 100644 index 0000000000000000000000000000000000000000..f2eadec321fb63924e029cba5a70d7ca17f66571 --- /dev/null +++ b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/basic/psiThermo/basicSensiblePsiThermo/basicSensiblePsiThermo.H @@ -0,0 +1,114 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::basicSensiblePsiThermo + +Description + Basic thermodynamic properties based on compressibility + +SourceFiles + basicSensiblePsiThermo.C + newBasicSensiblePsiThermo.C + +\*---------------------------------------------------------------------------*/ + +#ifndef basicSensiblePsiThermo_H +#define basicSensiblePsiThermo_H + +#include "basicThermo.H" +#include "runTimeSelectionTables.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class basicSensiblePsiThermo Declaration +\*---------------------------------------------------------------------------*/ + +class basicSensiblePsiThermo +: + public basicThermo +{ + +protected: + + // Protected member functions + + //- Construct as copy (not implemented) + basicSensiblePsiThermo(const basicSensiblePsiThermo&); + + +public: + + //- Runtime type information + TypeName("basicSensiblePsiThermo"); + + + //- Declare run-time constructor selection table + declareRunTimeSelectionTable + ( + autoPtr, + basicSensiblePsiThermo, + fvMesh, + (const fvMesh& mesh), + (mesh) + ); + + // Constructors + + //- Construct from mesh + basicSensiblePsiThermo(const fvMesh&); + + + //- Selector + static autoPtr<basicSensiblePsiThermo> New(const fvMesh&); + + //- Destructor + virtual ~basicSensiblePsiThermo(); + + + // Member functions + + // Fields derived from thermodynamic state variables + + //- Density [kg/m^3] - uses current value of pressure + virtual tmp<volScalarField> rho() const + { + return p_*psi(); + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/basic/psiThermo/basicSensiblePsiThermo/makeBasicSensiblePsiThermo.H b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/basic/psiThermo/basicSensiblePsiThermo/makeBasicSensiblePsiThermo.H new file mode 100644 index 0000000000000000000000000000000000000000..7d0a078719dfd3ecff7113d34e12b4d8913cfa14 --- /dev/null +++ b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/basic/psiThermo/basicSensiblePsiThermo/makeBasicSensiblePsiThermo.H @@ -0,0 +1,66 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +InClass + Foam::basicSensiblePsiThermo + +Description + Macros for creating 'basic' compresibility-based thermo packages + +\*---------------------------------------------------------------------------*/ + +#ifndef makeBasicSensiblePsiThermo_H +#define makeBasicSensiblePsiThermo_H + +#include "basicSensiblePsiThermo.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#define makeBasicSensiblePsiThermo(Cthermo,Mixture,Transport,Thermo,EqnOfState) \ + \ +typedef Cthermo<Mixture<Transport<specieThermo<Thermo<EqnOfState> > > > > \ + Cthermo##Mixture##Transport##Thermo##EqnOfState; \ + \ +defineTemplateTypeNameAndDebugWithName \ +( \ + Cthermo##Mixture##Transport##Thermo##EqnOfState, \ + #Cthermo \ + "<"#Mixture"<"#Transport"<specieThermo<"#Thermo"<"#EqnOfState">>>>>", \ + 0 \ +); \ + \ +addToRunTimeSelectionTable \ +( \ + basicSensiblePsiThermo, \ + Cthermo##Mixture##Transport##Thermo##EqnOfState, \ + fvMesh \ +) + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/basic/psiThermo/basicSensiblePsiThermo/newBasicSensiblePsiThermo.C b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/basic/psiThermo/basicSensiblePsiThermo/newBasicSensiblePsiThermo.C new file mode 100644 index 0000000000000000000000000000000000000000..14fcbbff6a7b1514c5905286c655ce2721be2a92 --- /dev/null +++ b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/basic/psiThermo/basicSensiblePsiThermo/newBasicSensiblePsiThermo.C @@ -0,0 +1,75 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "basicSensiblePsiThermo.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +Foam::autoPtr<Foam::basicSensiblePsiThermo> Foam::basicSensiblePsiThermo::New +( + const fvMesh& mesh +) +{ + word thermoTypeName; + + // Enclose the creation of the thermophysicalProperties to ensure it is + // deleted before the turbulenceModel is created otherwise the dictionary + // is entered in the database twice + { + IOdictionary thermoDict + ( + IOobject + ( + "thermophysicalProperties", + mesh.time().constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ); + + thermoDict.lookup("thermoType") >> thermoTypeName; + } + + Info<< "Selecting thermodynamics package " << thermoTypeName << endl; + + fvMeshConstructorTable::iterator cstrIter = + fvMeshConstructorTablePtr_->find(thermoTypeName); + + if (cstrIter == fvMeshConstructorTablePtr_->end()) + { + FatalErrorIn("basicSensiblePsiThermo::New(const fvMesh&)") + << "Unknown basicSensiblePsiThermo type " << thermoTypeName << nl << nl + << "Valid basicSensiblePsiThermo types are:" << nl + << fvMeshConstructorTablePtr_->toc() << nl + << exit(FatalError); + } + + return autoPtr<basicSensiblePsiThermo>(cstrIter()(mesh)); +} + + +// ************************************************************************* // diff --git a/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/reactionThermo/Make/files b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/reactionThermo/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..39b2fa53b124a803b24abdc2a4a265ad303dce4a --- /dev/null +++ b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/reactionThermo/Make/files @@ -0,0 +1,5 @@ +combustionThermo/hsCombustionThermo/hsCombustionThermo.C +combustionThermo/hsCombustionThermo/newhsCombustionThermo.C +combustionThermo/hsCombustionThermo/hsCombustionThermos.C + +LIB = $(FOAM_LIBBIN)/libreactionSensibleEnthalpyThermophysicalModels diff --git a/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/reactionThermo/Make/options b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/reactionThermo/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..9551ad0315297711e6f64350cea0392011919456 --- /dev/null +++ b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/reactionThermo/Make/options @@ -0,0 +1,9 @@ +EXE_INC = \ + -I../basic/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude + +LIB_LIBS = \ + -lfiniteVolume diff --git a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitMulticomponentPointSource/pointSourceProperties/pointSourceProperties.C b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/reactionThermo/combustionThermo/hsCombustionThermo/hsCombustionThermo.C similarity index 51% rename from src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitMulticomponentPointSource/pointSourceProperties/pointSourceProperties.C rename to applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/reactionThermo/combustionThermo/hsCombustionThermo/hsCombustionThermo.C index 5d7ad2ac46b509fbafb1b6448d98395be7ab9cf3..2e50a2a64cfd470994d7bff9011dd074191ff90e 100644 --- a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitMulticomponentPointSource/pointSourceProperties/pointSourceProperties.C +++ b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/reactionThermo/combustionThermo/hsCombustionThermo/hsCombustionThermo.C @@ -24,64 +24,44 @@ License \*---------------------------------------------------------------------------*/ -#include "pointSourceProperties.H" +#include "hsCombustionThermo.H" +#include "fvMesh.H" -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -Foam::pointSourceProperties::pointSourceProperties() -: - name_("unknownPointSourceName"), - timeStart_(0.0), - duration_(0.0), - location_(point::zero), - fieldData_() -{} +namespace Foam +{ + defineTypeNameAndDebug(hsCombustionThermo, 0); + defineRunTimeSelectionTable(hsCombustionThermo, fvMesh); +} +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::pointSourceProperties::pointSourceProperties(const dictionary& dict) +Foam::hsCombustionThermo::hsCombustionThermo(const fvMesh& mesh) : - name_(dict.name().name()), - timeStart_(readScalar(dict.lookup("timeStart"))), - duration_(readScalar(dict.lookup("duration"))), - location_(dict.lookup("location")), - fieldData_(dict.lookup("fieldData")) -{} - + basicSensiblePsiThermo(mesh), -Foam::pointSourceProperties::pointSourceProperties -( - const pointSourceProperties& psp -) -: - name_(psp.name_), - timeStart_(psp.timeStart_), - duration_(psp.duration_), - location_(psp.location_), - fieldData_(psp.fieldData_) + hs_ + ( + IOobject + ( + "hs", + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionSet(0, 2, -2, 0, 0), + this->hBoundaryTypes() + ) {} -// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // - -void Foam::pointSourceProperties::operator=(const pointSourceProperties& rhs) -{ - // Check for assignment to self - if (this == &rhs) - { - FatalErrorIn - ( - "pointSourceProperties::operator=(const pointSourceProperties&)" - ) << "Attempted assignment to self" << nl - << abort(FatalError); - } - - // Set updated values - name_ = rhs.name_; - timeStart_ = rhs.timeStart_; - duration_ = rhs.duration_; - location_ = rhs.location_; - fieldData_ = rhs.fieldData_;} +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // +Foam::hsCombustionThermo::~hsCombustionThermo() +{} // ************************************************************************* // diff --git a/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/reactionThermo/combustionThermo/hsCombustionThermo/hsCombustionThermo.H b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/reactionThermo/combustionThermo/hsCombustionThermo/hsCombustionThermo.H new file mode 100644 index 0000000000000000000000000000000000000000..44e4dfe43360a4eab8e8b32d9e3b3a452a7338d6 --- /dev/null +++ b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/reactionThermo/combustionThermo/hsCombustionThermo/hsCombustionThermo.H @@ -0,0 +1,146 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::hsCombustionThermo + +Description + Foam::hsCombustionThermo + +SourceFiles + hsCombustionThermo.C + +\*---------------------------------------------------------------------------*/ + +#ifndef hsCombustionThermo_H +#define hsCombustionThermo_H + +#include "basicSensiblePsiThermo.H" +#include "basicMultiComponentMixture.H" +#include "autoPtr.H" +#include "runTimeSelectionTables.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class hsCombustionThermo Declaration +\*---------------------------------------------------------------------------*/ + +class hsCombustionThermo +: + public basicSensiblePsiThermo +{ + +protected: + + // Protected data + + //- sensible enthalpy field + volScalarField hs_; + + +public: + + //- Runtime type information + TypeName("hsCombustionThermo"); + + + //- Declare run-time constructor selection tables + declareRunTimeSelectionTable + ( + autoPtr, + hsCombustionThermo, + fvMesh, + (const fvMesh& mesh), + (mesh) + ); + + + // Constructors + + //- Construct from dictionary and mesh + hsCombustionThermo(const fvMesh&); + + + // Selectors + + //- Standard selection based on fvMesh + static autoPtr<hsCombustionThermo> New(const fvMesh&); + + //- Select and check that package contains 'thermoType' + static autoPtr<hsCombustionThermo> NewType + ( + const fvMesh&, + const word& thermoType + ); + + + //- Destructor + virtual ~hsCombustionThermo(); + + + // Member functions + + //- Return the composition of the multi-component mixture + virtual basicMultiComponentMixture& composition() = 0; + + //- Return the composition of the multi-component mixture + virtual const basicMultiComponentMixture& composition() const = 0; + + + // Access to thermodynamic state variables + + //- Sensible enthalpy [J/kg] + // Non-const access allowed for transport equations + virtual volScalarField& hs() + { + return hs_; + } + + //- Sensible enthalpy [J/kg] + virtual const volScalarField& hs() const + { + return hs_; + } + + //- Chemical enthalpy [J/kg] + virtual tmp<volScalarField> hc() const = 0; + + //- Update properties + virtual void correct() = 0; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitMulticomponentPointSource/pointSourceProperties/pointSourcePropertiesI.H b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/reactionThermo/combustionThermo/hsCombustionThermo/hsCombustionThermos.C similarity index 52% rename from src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitMulticomponentPointSource/pointSourceProperties/pointSourcePropertiesI.H rename to applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/reactionThermo/combustionThermo/hsCombustionThermo/hsCombustionThermos.C index 60d02c2d5d14f295bee2ad0e2390c121312b52bf..bf3bc4ebfea459b4c55be394b75f1ab414ace6cd 100644 --- a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitMulticomponentPointSource/pointSourceProperties/pointSourcePropertiesI.H +++ b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/reactionThermo/combustionThermo/hsCombustionThermo/hsCombustionThermos.C @@ -24,76 +24,45 @@ License \*---------------------------------------------------------------------------*/ -#include "pointSourceProperties.H" +#include "makeHsCombustionThermo.H" -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -inline const Foam::word& Foam::pointSourceProperties::name() const -{ - return name_; -} - - -inline Foam::scalar Foam::pointSourceProperties::timeStart() const -{ - return timeStart_; -} +#include "hsCombustionThermo.H" +#include "hsPsiMixtureThermo.H" +#include "perfectGas.H" -inline Foam::scalar Foam::pointSourceProperties::timeEnd() const -{ - return timeStart_ + duration_; -} +#include "hConstThermo.H" +#include "janafThermo.H" +#include "specieThermo.H" +#include "sutherlandTransport.H" -inline Foam::scalar Foam::pointSourceProperties::duration() const -{ - return duration_; -} +#include "veryInhomogeneousMixture.H" +#include "multiComponentMixture.H" -inline const Foam::point& Foam::pointSourceProperties::location() const -{ - return location_; -} +#include "thermoPhysicsTypes.H" +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -inline const Foam::List<Foam::pointSourceProperties::fieldNameValuePair>& -Foam::pointSourceProperties::fieldData() const +namespace Foam { - return fieldData_; -} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -inline Foam::word& Foam::pointSourceProperties::name() -{ - return name_; -} +makeHsCombustionThermo +( + hsCombustionThermo, + hsPsiMixtureThermo, + veryInhomogeneousMixture, + sutherlandTransport, + janafThermo, + perfectGas +); -inline Foam::scalar& Foam::pointSourceProperties::timeStart() -{ - return timeStart_; -} - - -inline Foam::scalar& Foam::pointSourceProperties::duration() -{ - return duration_; -} - - -inline Foam::point& Foam::pointSourceProperties::location() -{ - return location_; -} - - -inline Foam::List<Foam::pointSourceProperties::fieldNameValuePair>& -Foam::pointSourceProperties::fieldData() -{ - return fieldData_; -} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +} // End namespace Foam // ************************************************************************* // diff --git a/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/reactionThermo/combustionThermo/hsCombustionThermo/makeHsCombustionThermo.H b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/reactionThermo/combustionThermo/hsCombustionThermo/makeHsCombustionThermo.H new file mode 100644 index 0000000000000000000000000000000000000000..a1507ba35d1459d0c82b8599600c3cb4792f872c --- /dev/null +++ b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/reactionThermo/combustionThermo/hsCombustionThermo/makeHsCombustionThermo.H @@ -0,0 +1,100 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +InClass + Foam::hsCombustionThermo + +Description + +\*---------------------------------------------------------------------------*/ + +#ifndef makeHsCombustionThermo_H +#define makeHsCombustionThermo_H + +#include "addToRunTimeSelectionTable.H" +#include "basicSensiblePsiThermo.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#define makeHsCombustionThermo(CThermo,MixtureThermo,Mixture,Transport,Thermo,EqnOfState) \ + \ +typedef MixtureThermo \ + <Mixture<Transport<specieThermo<Thermo<EqnOfState> > > > > \ + MixtureThermo##Mixture##Transport##Thermo##EqnOfState; \ + \ +defineTemplateTypeNameAndDebugWithName \ +( \ + MixtureThermo##Mixture##Transport##Thermo##EqnOfState, \ + #MixtureThermo \ + "<"#Mixture"<"#Transport"<specieThermo<"#Thermo"<"#EqnOfState">>>>>", \ + 0 \ +); \ + \ +addToRunTimeSelectionTable \ +( \ + basicSensiblePsiThermo, \ + MixtureThermo##Mixture##Transport##Thermo##EqnOfState, \ + fvMesh \ +); \ + \ +addToRunTimeSelectionTable \ +( \ + CThermo, \ + MixtureThermo##Mixture##Transport##Thermo##EqnOfState, \ + fvMesh \ +) + + +#define makeHsCombustionMixtureThermo(CThermo,MixtureThermo,Mixture,ThermoPhys) \ + \ +typedef MixtureThermo<Mixture<ThermoPhys> > \ + MixtureThermo##Mixture##ThermoPhys; \ + \ +defineTemplateTypeNameAndDebugWithName \ +( \ + MixtureThermo##Mixture##ThermoPhys, \ + #MixtureThermo"<"#Mixture"<"#ThermoPhys">>", \ + 0 \ +); \ + \ +addToRunTimeSelectionTable \ +( \ + basicSensiblePsiThermo, \ + MixtureThermo##Mixture##ThermoPhys, \ + fvMesh \ +); \ + \ +addToRunTimeSelectionTable \ +( \ + CThermo, \ + MixtureThermo##Mixture##ThermoPhys, \ + fvMesh \ +); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/reactionThermo/combustionThermo/hsCombustionThermo/newhsCombustionThermo.C b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/reactionThermo/combustionThermo/hsCombustionThermo/newhsCombustionThermo.C new file mode 100644 index 0000000000000000000000000000000000000000..9d39667dd3d66cffaa76e4f991553d18582b9404 --- /dev/null +++ b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/reactionThermo/combustionThermo/hsCombustionThermo/newhsCombustionThermo.C @@ -0,0 +1,151 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "hsCombustionThermo.H" +#include "fvMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +Foam::autoPtr<Foam::hsCombustionThermo> Foam::hsCombustionThermo::New +( + const fvMesh& mesh +) +{ + word hsCombustionThermoTypeName; + + // Enclose the creation of the thermophysicalProperties to ensure it is + // deleted before the turbulenceModel is created otherwise the dictionary + // is entered in the database twice + { + IOdictionary thermoDict + ( + IOobject + ( + "thermophysicalProperties", + mesh.time().constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ); + + thermoDict.lookup("thermoType") >> hsCombustionThermoTypeName; + } + + Info<< "Selecting thermodynamics package " << hsCombustionThermoTypeName + << endl; + + fvMeshConstructorTable::iterator cstrIter = + fvMeshConstructorTablePtr_->find(hsCombustionThermoTypeName); + + if (cstrIter == fvMeshConstructorTablePtr_->end()) + { + FatalErrorIn("hsCombustionThermo::New(const fvMesh&)") + << "Unknown hsCombustionThermo type " + << hsCombustionThermoTypeName << nl << nl + << "Valid hsCombustionThermo types are:" << nl + << fvMeshConstructorTablePtr_->toc() << nl + << exit(FatalError); + } + + return autoPtr<hsCombustionThermo>(cstrIter()(mesh)); +} + + +Foam::autoPtr<Foam::hsCombustionThermo> Foam::hsCombustionThermo::NewType +( + const fvMesh& mesh, + const word& thermoType +) +{ + word hsCombustionThermoTypeName; + + // Enclose the creation of the thermophysicalProperties to ensure it is + // deleted before the turbulenceModel is created otherwise the dictionary + // is entered in the database twice + { + IOdictionary thermoDict + ( + IOobject + ( + "thermophysicalProperties", + mesh.time().constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ); + + thermoDict.lookup("thermoType") >> hsCombustionThermoTypeName; + + if (hsCombustionThermoTypeName.find(thermoType) == string::npos) + { + wordList allModels = fvMeshConstructorTablePtr_->toc(); + DynamicList<word> validModels; + forAll(allModels, i) + { + if (allModels[i].find(thermoType) != string::npos) + { + validModels.append(allModels[i]); + } + } + + FatalErrorIn + ( + "autoPtr<hsCombustionThermo> hsCombustionThermo::NewType" + "(" + "const fvMesh&, " + "const word&" + ")" + ) << "Inconsistent thermo package selected:" << nl << nl + << hsCombustionThermoTypeName << nl << nl << "Please select a " + << "thermo package based on " << thermoType + << ". Valid options include:" << nl << validModels << nl + << exit(FatalError); + } + } + + Info<< "Selecting thermodynamics package " << hsCombustionThermoTypeName + << endl; + + fvMeshConstructorTable::iterator cstrIter = + fvMeshConstructorTablePtr_->find(hsCombustionThermoTypeName); + + if (cstrIter == fvMeshConstructorTablePtr_->end()) + { + FatalErrorIn("hsCombustionThermo::New(const fvMesh&)") + << "Unknown hsCombustionThermo type " + << hsCombustionThermoTypeName << nl << nl + << "Valid hsCombustionThermo types are:" << nl + << fvMeshConstructorTablePtr_->toc() << nl + << exit(FatalError); + } + + return autoPtr<hsCombustionThermo>(cstrIter()(mesh)); +} + + +// ************************************************************************* // diff --git a/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hsPsiMixtureThermo/hsPsiMixtureThermo.C b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hsPsiMixtureThermo/hsPsiMixtureThermo.C new file mode 100644 index 0000000000000000000000000000000000000000..0e6b14e1b0321c89dc6f73e027989b380760550c --- /dev/null +++ b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hsPsiMixtureThermo/hsPsiMixtureThermo.C @@ -0,0 +1,318 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "hsPsiMixtureThermo.H" +#include "fvMesh.H" +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class MixtureType> +Foam::hsPsiMixtureThermo<MixtureType>::hsPsiMixtureThermo(const fvMesh& mesh) +: + hsCombustionThermo(mesh), + MixtureType(*this, mesh) +{ + scalarField& hCells = hs_.internalField(); + const scalarField& TCells = T_.internalField(); + + forAll(hCells, celli) + { + hCells[celli] = this->cellMixture(celli).Hs(TCells[celli]); + } + + forAll(hs_.boundaryField(), patchi) + { + hs_.boundaryField()[patchi] == hs(T_.boundaryField()[patchi], patchi); + } + + hBoundaryCorrection(hs_); + + calculate(); + psi_.oldTime(); // Switch on saving old time +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template<class MixtureType> +Foam::hsPsiMixtureThermo<MixtureType>::~hsPsiMixtureThermo() +{} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template<class MixtureType> +void Foam::hsPsiMixtureThermo<MixtureType>::calculate() +{ + const scalarField& hsCells = hs_.internalField(); + const scalarField& pCells = p_.internalField(); + + scalarField& TCells = T_.internalField(); + scalarField& psiCells = psi_.internalField(); + scalarField& muCells = mu_.internalField(); + scalarField& alphaCells = alpha_.internalField(); + + forAll(TCells, celli) + { + const typename MixtureType::thermoType& mixture_ = + this->cellMixture(celli); + + TCells[celli] = mixture_.THs(hsCells[celli], TCells[celli]); + psiCells[celli] = mixture_.psi(pCells[celli], TCells[celli]); + + muCells[celli] = mixture_.mu(TCells[celli]); + alphaCells[celli] = mixture_.alpha(TCells[celli]); + } + + forAll(T_.boundaryField(), patchi) + { + fvPatchScalarField& pp = p_.boundaryField()[patchi]; + fvPatchScalarField& pT = T_.boundaryField()[patchi]; + fvPatchScalarField& ppsi = psi_.boundaryField()[patchi]; + + fvPatchScalarField& phs = hs_.boundaryField()[patchi]; + + fvPatchScalarField& pmu_ = mu_.boundaryField()[patchi]; + fvPatchScalarField& palpha_ = alpha_.boundaryField()[patchi]; + + if (pT.fixesValue()) + { + forAll(pT, facei) + { + const typename MixtureType::thermoType& mixture_ = + this->patchFaceMixture(patchi, facei); + + phs[facei] = mixture_.Hs(pT[facei]); + + ppsi[facei] = mixture_.psi(pp[facei], pT[facei]); + pmu_[facei] = mixture_.mu(pT[facei]); + palpha_[facei] = mixture_.alpha(pT[facei]); + } + } + else + { + forAll(pT, facei) + { + const typename MixtureType::thermoType& mixture_ = + this->patchFaceMixture(patchi, facei); + + pT[facei] = mixture_.THs(phs[facei], pT[facei]); + + ppsi[facei] = mixture_.psi(pp[facei], pT[facei]); + pmu_[facei] = mixture_.mu(pT[facei]); + palpha_[facei] = mixture_.alpha(pT[facei]); + } + } + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class MixtureType> +void Foam::hsPsiMixtureThermo<MixtureType>::correct() +{ + if (debug) + { + Info<< "entering hMixtureThermo<MixtureType>::correct()" << endl; + } + + // force the saving of the old-time values + psi_.oldTime(); + + calculate(); + + if (debug) + { + Info<< "exiting hMixtureThermo<MixtureType>::correct()" << endl; + } +} + +template<class MixtureType> +Foam::tmp<Foam::volScalarField> +Foam::hsPsiMixtureThermo<MixtureType>::hc() const +{ + const fvMesh& mesh = T_.mesh(); + + tmp<volScalarField> thc + ( + new volScalarField + ( + IOobject + ( + "hc", + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + hs_.dimensions() + ) + ); + + volScalarField& hcf = thc(); + scalarField& hcCells = hcf.internalField(); + + forAll(hcCells, celli) + { + hcCells[celli] = this->cellMixture(celli).Hc(); + } + + forAll(hcf.boundaryField(), patchi) + { + scalarField& hcp = hcf.boundaryField()[patchi]; + + forAll(hcp, facei) + { + hcp[facei] = this->patchFaceMixture(patchi, facei).Hc(); + } + } + + return thc; +} + + +template<class MixtureType> +Foam::tmp<Foam::scalarField> +Foam::hsPsiMixtureThermo<MixtureType>::hs +( + const scalarField& T, + const labelList& cells +) const +{ + tmp<scalarField> th(new scalarField(T.size())); + scalarField& hs = th(); + + forAll(T, celli) + { + hs[celli] = this->cellMixture(cells[celli]).Hs(T[celli]); + } + + return th; +} + + +template<class MixtureType> +Foam::tmp<Foam::scalarField> +Foam::hsPsiMixtureThermo<MixtureType>::hs +( + const scalarField& T, + const label patchi +) const +{ + tmp<scalarField> th(new scalarField(T.size())); + scalarField& hs = th(); + + forAll(T, facei) + { + hs[facei] = this->patchFaceMixture(patchi, facei).Hs(T[facei]); + } + + return th; +} + + +template<class MixtureType> +Foam::tmp<Foam::scalarField> +Foam::hsPsiMixtureThermo<MixtureType>::Cp +( + const scalarField& T, + const label patchi +) const +{ + tmp<scalarField> tCp(new scalarField(T.size())); + + scalarField& cp = tCp(); + + forAll(T, facei) + { + cp[facei] = this->patchFaceMixture(patchi, facei).Cp(T[facei]); + } + + return tCp; +} + + +template<class MixtureType> +Foam::tmp<Foam::volScalarField> +Foam::hsPsiMixtureThermo<MixtureType>::Cp() const +{ + const fvMesh& mesh = T_.mesh(); + + tmp<volScalarField> tCp + ( + new volScalarField + ( + IOobject + ( + "Cp", + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionSet(0, 2, -2, -1, 0) + ) + ); + + volScalarField& cp = tCp(); + + scalarField& cpCells = cp.internalField(); + const scalarField& TCells = T_.internalField(); + + forAll(TCells, celli) + { + cpCells[celli] = this->cellMixture(celli).Cp(TCells[celli]); + } + + forAll(T_.boundaryField(), patchi) + { + cp.boundaryField()[patchi] = Cp(T_.boundaryField()[patchi], patchi); + } + + return tCp; +} + + +template<class MixtureType> +bool Foam::hsPsiMixtureThermo<MixtureType>::read() +{ + if (hsCombustionThermo::read()) + { + MixtureType::read(*this); + return true; + } + else + { + return false; + } +} + + +// ************************************************************************* // diff --git a/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hsPsiMixtureThermo/hsPsiMixtureThermo.H b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hsPsiMixtureThermo/hsPsiMixtureThermo.H new file mode 100644 index 0000000000000000000000000000000000000000..e114b847347d3c3f2c65ebda2298a0053fd09882 --- /dev/null +++ b/applications/solvers/combustion/fireFoam/sensibleEnthalpyCombustionThermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hsPsiMixtureThermo/hsPsiMixtureThermo.H @@ -0,0 +1,147 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::hsPsiMixtureThermo + +Description + Foam::hsPsiMixtureThermo + +SourceFiles + hsPsiMixtureThermo.C + +\*---------------------------------------------------------------------------*/ + +#ifndef hsPsiMixtureThermo_H +#define hsPsiMixtureThermo_H + +#include "hsCombustionThermo.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class hsPsiMixtureThermo Declaration +\*---------------------------------------------------------------------------*/ + +template<class MixtureType> +class hsPsiMixtureThermo +: + public hsCombustionThermo, + public MixtureType +{ + // Private member functions + + void calculate(); + + //- Construct as copy (not implemented) + hsPsiMixtureThermo(const hsPsiMixtureThermo<MixtureType>&); + + +public: + + //- Runtime type information + TypeName("hsPsiMixtureThermo"); + + + // Constructors + + //- Construct from mesh + hsPsiMixtureThermo(const fvMesh&); + + + //- Destructor + virtual ~hsPsiMixtureThermo(); + + + // Member functions + + //- Return the compostion of the multi-component mixture + virtual basicMultiComponentMixture& composition() + { + return *this; + } + + //- Return the compostion of the multi-component mixture + virtual const basicMultiComponentMixture& composition() const + { + return *this; + } + + //- Update properties + virtual void correct(); + + + //- Chemical enthalpy [J/kg] + virtual tmp<volScalarField> hc() const; + + // Fields derived from thermodynamic state variables + + //- Sensible enthalpy for cell-set [J/kg] + virtual tmp<scalarField> hs + ( + const scalarField& T, + const labelList& cells + ) const; + + //- Sensible enthalpy for patch [J/kg] + virtual tmp<scalarField> hs + ( + const scalarField& T, + const label patchi + ) const; + + //- Heat capacity at constant pressure for patch [J/kg/K] + virtual tmp<scalarField> Cp + ( + const scalarField& T, + const label patchi + ) const; + + //- Heat capacity at constant pressure [J/kg/K] + virtual tmp<volScalarField> Cp() const; + + + //- Read thermophysicalProperties dictionary + virtual bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "hsPsiMixtureThermo.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/lagrangian/coalChemistryFoam/coalChemistryFoam.C b/applications/solvers/lagrangian/coalChemistryFoam/coalChemistryFoam.C index f6794e92b2a18db82f8265223e9381a2c66dc847..389a065935004bd9f11154db9447fa86989f59d1 100644 --- a/applications/solvers/lagrangian/coalChemistryFoam/coalChemistryFoam.C +++ b/applications/solvers/lagrangian/coalChemistryFoam/coalChemistryFoam.C @@ -26,8 +26,13 @@ Application coalChemistryFoam Description - Transient solver for compressible, turbulent flow with coal and - limestone parcel injections, and combustion. + Transient solver for: + - compressible, + - turbulent flow, + with + - coal and limestone parcel injections, + - energy source, and + - combustion. \*---------------------------------------------------------------------------*/ @@ -38,7 +43,7 @@ Description #include "CoalCloud.H" #include "psiChemistryModel.H" #include "chemistrySolver.H" -#include "timeActivatedExplicitCellSource.H" +#include "timeActivatedExplicitSource.H" #include "radiationModel.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/solvers/lagrangian/coalChemistryFoam/createFields.H b/applications/solvers/lagrangian/coalChemistryFoam/createFields.H index f79e48c17b87cbd54585fafe87fc2f27034f141e..d0a284a0e17039e394a7d806ba1a5ce84f24a4ee 100644 --- a/applications/solvers/lagrangian/coalChemistryFoam/createFields.H +++ b/applications/solvers/lagrangian/coalChemistryFoam/createFields.H @@ -127,10 +127,11 @@ fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p) ); - Info<< "\nConstructing explicit enthalpy cell source" << endl; - timeActivatedExplicitCellSource enthalpySource + Info<< "\nConstructing explicit enthalpy source" << endl; + scalarTimeActivatedExplicitSourceList enthalpySource ( - "enthalpySource", + "energy", mesh, - h.dimensions()*phi.dimensions()/mesh.V().dimensions() + dimEnergy/dimTime/dimVolume, + "h" ); diff --git a/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/UEqn.H b/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/UEqn.H index b408709aed902619ce7a316b11d0049a1f0e9948..e77fe75dabbcc939eb6c1afae5cd969fe8b9dbd1 100644 --- a/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/UEqn.H +++ b/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/UEqn.H @@ -7,6 +7,7 @@ == rho.dimensionedInternalField()*g + parcels.SU() + + momentumSource.Su() ); pZones.addResistance(UEqn); diff --git a/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/YEqn.H b/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/YEqn.H index 4e9c29815aaa0a96f1a017be68befcff7b154b59..f54be04bb8778fb886f21231f860439e426188d9 100644 --- a/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/YEqn.H +++ b/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/YEqn.H @@ -28,7 +28,7 @@ tmp<fv::convectionScheme<scalar> > mvConvection == parcels.Srho(i) + kappa*chemistry.RR(i)().dimensionedInternalField() - + pointMassSources.Su(i), + + massSource.Su(i), mesh.solver("Yi") ); diff --git a/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/createClouds.H b/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/createClouds.H index 2accb8e1c9a276191c08caf65185bba9b6d44a3a..74a66b63e89da8180b8e4c473bbd1db670ca7eaf 100644 --- a/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/createClouds.H +++ b/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/createClouds.H @@ -1,5 +1,5 @@ Info<< "\nConstructing reacting cloud" << endl; -icoPoly8ThermoReactingCloud parcels +icoPoly8ThermoReactingMultiphaseCloud parcels ( "reactingCloud1", rho, diff --git a/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/createExplicitSources.H b/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/createExplicitSources.H new file mode 100644 index 0000000000000000000000000000000000000000..0f2b52e5361a0e7f5882ac4682e9e0a1f2ef257e --- /dev/null +++ b/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/createExplicitSources.H @@ -0,0 +1,27 @@ +Info<< "Creating mass source\n" << endl; +scalarTimeActivatedExplicitSourceList massSource +( + "mass", + mesh, + dimMass/dimTime/dimVolume, + composition.species() +); + + +Info<< "Creating momentum source\n" << endl; +vectorTimeActivatedExplicitSourceList momentumSource +( + "momentum", + mesh, + dimMass*dimVelocity/dimTime/dimVolume, + "U" +); + +Info<< "Creating energy source\n" << endl; +scalarTimeActivatedExplicitSourceList energySource +( + "energy", + mesh, + dimEnergy/dimTime/dimVolume, + "h" +); diff --git a/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/createMulticomponentPointSources.H b/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/createMulticomponentPointSources.H deleted file mode 100644 index 52de65dc5050296f6aca81542b733afe5252e704..0000000000000000000000000000000000000000 --- a/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/createMulticomponentPointSources.H +++ /dev/null @@ -1,8 +0,0 @@ -Info<< "\nConstructing multi-component mass flow rate point sources" << endl; -timeActivatedExplicitMulticomponentPointSource pointMassSources -( - "pointMassSources", - mesh, - Y, - dimMass/dimVolume/dimTime -); diff --git a/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/hEqn.H b/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/hEqn.H index 6e6b0c763ae85dbde75e0745e8c27b2899598fe3..0715989df7a77d848fae8000cc82f34cc4d53b5b 100644 --- a/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/hEqn.H +++ b/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/hEqn.H @@ -39,6 +39,7 @@ pWork() + parcels.Sh() + radiation->Sh(thermo) + + energySource.Su() ); thermo.correct(); diff --git a/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/pEqn.H b/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/pEqn.H index 32657588b0f594133d47d0b886a88be1a21907ac..9d03624e4320b244f3e11ede5886691da15b002d 100644 --- a/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/pEqn.H +++ b/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/pEqn.H @@ -32,7 +32,7 @@ - fvm::laplacian(rho*rAU, p) == parcels.Srho() - + pointMassSources.Su() + + massSource.SuTot() ); if (corr == nCorr-1 && nonOrth == nNonOrthCorr) diff --git a/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/porousExplicitSourceReactingParcelFoam.C b/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/porousExplicitSourceReactingParcelFoam.C index bf0a16af28b34cc5a1d6f93309df6933d36023ff..b345ffe28a08c484e72213ef802af355c27879de 100644 --- a/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/porousExplicitSourceReactingParcelFoam.C +++ b/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/porousExplicitSourceReactingParcelFoam.C @@ -27,10 +27,11 @@ Application Description Transient PISO solver for compressible, laminar or turbulent flow with - reacting Lagrangian parcels for porous media, including explicit sources + reacting multiphase Lagrangian parcels for porous media, including explicit + sources for mass, momentum and energy The solver includes: - - reacting parcel cloud + - reacting multiphase parcel cloud - porous media - point mass sources - polynomial based, incompressible thermodynamics (f(T)) @@ -43,12 +44,12 @@ Description #include "fvCFD.H" #include "hReactionThermo.H" #include "turbulenceModel.H" -#include "BasicReactingCloud.H" +#include "BasicReactingMultiphaseCloud.H" #include "rhoChemistryModel.H" #include "chemistrySolver.H" #include "radiationModel.H" #include "porousZones.H" -#include "timeActivatedExplicitMulticomponentPointSource.H" +#include "timeActivatedExplicitSource.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -63,7 +64,7 @@ int main(int argc, char *argv[]) #include "createFields.H" #include "createRadiationModel.H" #include "createClouds.H" - #include "createMulticomponentPointSources.H" + #include "createExplicitSources.H" #include "createPorousZones.H" #include "initContinuityErrs.H" #include "readTimeControls.H" diff --git a/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/rhoEqn.H b/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/rhoEqn.H index 5bc5e120a01dee5c2ac7434c3700503b66fe4e8e..50f3beb60381727dc56708445c04e73f2a64cd9d 100644 --- a/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/rhoEqn.H +++ b/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/rhoEqn.H @@ -37,7 +37,7 @@ Description + fvc::div(phi) == parcels.Srho() - + pointMassSources.Su() + + massSource.SuTot() ); rhoEqn.relax(); diff --git a/applications/test/dictionary/Allwmake b/applications/test/dictionary/Allwmake deleted file mode 100755 index fcf297dc892423ab70d3b8238f4a2713b6797ca6..0000000000000000000000000000000000000000 --- a/applications/test/dictionary/Allwmake +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -cd ${0%/*} || exit 1 # run from this directory - -# this will have to do until we have a makefile rule - -if type Coco > /dev/null 2>&1 -then - Coco \ - -frames $WM_THIRD_PARTY_DIR/coco-r \ - calcEntry/calcEntry.atg -else - echo "Coco not installed" -fi - -wmake diff --git a/applications/test/dictionary/Make/files b/applications/test/dictionary/Make/files index 148f5fb1c94c8ff332eed2edec36e2771eb65e02..b9363efb23b13e6012274d16c0a250cdf9d2ca39 100644 --- a/applications/test/dictionary/Make/files +++ b/applications/test/dictionary/Make/files @@ -1,7 +1,3 @@ dictionaryTest.C -calcEntry/calcEntry.C -calcEntry/calcEntryParser.cpp -calcEntry/calcEntryScanner.cpp - EXE = $(FOAM_USER_APPBIN)/dictionaryTest diff --git a/applications/test/dictionary/Make/options b/applications/test/dictionary/Make/options index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..41306609f208806f0c6f42a2426867d3e10d4897 100644 --- a/applications/test/dictionary/Make/options +++ b/applications/test/dictionary/Make/options @@ -0,0 +1 @@ +EXE_INC = diff --git a/applications/test/dictionary/calcEntry/calcEntry.atg b/applications/test/dictionary/calcEntry/calcEntry.atg deleted file mode 100644 index 90c0861143681adc74fd7a4a59fb7ea793c3e1f6..0000000000000000000000000000000000000000 --- a/applications/test/dictionary/calcEntry/calcEntry.atg +++ /dev/null @@ -1,252 +0,0 @@ -/*------------------------------------------------------------------------- - compile with: - Coco \ - -frames $WM_THIRD_PARTY_DIR/coco-r \ - calcEntry.atg --------------------------------------------------------------------------*/ - -#include "dictionary.H" -#include "scalar.H" -#include "error.H" -#include "wchar.H" - - -COMPILER calcEntry -$prefix=calcEntry -$namespace=Foam::functionEntries::calcEntryInternal -$eof=true // grammar handles eof itself - - // Simple four function calculator for OpenFOAM dictionaries - - //! with debug - static const int debug = 0; - - //! The parent dictionary - mutable dictionary* dict_; - - //! Track that parent dictionary was set - bool hasDict_; - - //! The calculation result - scalar val; - - - //! token -> scalar - scalar getScalar() const - { - return coco_string_toDouble(t->val); - } - - //! token -> string - std::string getString() const - { - char* str = coco_string_create_char(t->val); - std::string s(str); - coco_string_delete(str); - return s; - } - - //! attach a dictionary - void dict(const dictionary& dict) - { - dict_ = const_cast<dictionary*>(&dict); - hasDict_ = true; - } - - - //! lookup dictionary entry - scalar getDictLookup() const - { - scalar dictValue = 0; - - if (!hasDict_) - { - FatalErrorIn - ( - "calcEntry::getDictEntry() const" - ) << "No dictionary attached!" - << exit(FatalError); - - return 0; - } - - char* chars = coco_string_create_char - ( - t->val, - 1, - (coco_string_length(t->val) - 1) - ); - word keyword(chars); - coco_string_delete(chars); - - if (debug) - { - Info<<"lookup: " << keyword << nl; - } - - entry* entryPtr = dict_->lookupEntryPtr(keyword, true, false); - if (entryPtr && !entryPtr->isDict()) - { - if (entryPtr->stream().size() != 1) - { - FatalErrorIn - ( - "calcEntry::getDictEntry() const" - ) << "keyword " << keyword << " has " - << entryPtr->stream().size() << " values in dictionary " - << exit(FatalError); - } - entryPtr->stream() >> dictValue; - } - else - { - FatalErrorIn - ( - "calcEntry::getDictEntry() const" - ) << "keyword " << keyword << " is undefined in dictionary " - << exit(FatalError); - } - - - return dictValue; - } - - scalar Result() const - { - return val; - } - - -/*---------------------------------------------------------------------------*/ - -CHARACTERS - letter = 'A'..'Z' + 'a'..'z'. - qualifier = '_' + ':'. - dollar = '$'. - digit = "0123456789". - sign = '+' + '-'. - cr = '\r'. - lf = '\n'. - tab = '\t'. - stringCh = ANY - '"' - '\\' - cr - lf. - printable = '\u0020' .. '\u007e'. - - -// * * * * * * * * * * * * * * * * TOKENS * * * * * * * * * * * * * * * * * // - -TOKENS - -// identifier -ident = - letter { letter | digit | qualifier }. - -// string -string = - '"' { stringCh | '\\' printable } '"'. - -// dictionary lookup identifier -// starts with '$' and otherwise limited to a normal indentifier -variable = - dollar letter { letter | digit | qualifier }. - -// floating point and integer numbers -number = - [sign] ('.' digit { digit } ) | ( digit { digit } [ '.' { digit } ]) - [ ('E' | 'e') [sign] digit { digit } ]. - - -// * * * * * * * * * * * PRAGMAS / COMMENTS / IGNORE * * * * * * * * * * * // - -COMMENTS FROM "/*" TO "*/" NESTED -COMMENTS FROM "//" TO lf - -IGNORE cr + lf + tab - - -// * * * * * * * * * * * * * * * PRODUCTIONS * * * * * * * * * * * * * * * // - -PRODUCTIONS - -calcEntry (. val = 0; - if (debug){Info<<"start val pos:"<< t->pos << nl;} - .) -= - '{' Expr<val> '}' (. - if (debug){ - Info<<"end {} at pos:"<< t->pos - <<" val:"<< t->val - <<" len:"<< coco_string_length(t->val) - <<" la pos:"<< la->pos << nl; - } - // reposition to immediately after the closing '}' - scanner->buffer->SetPos - ( - t->pos + coco_string_length(t->val) - ); - .) - | ( Expr<val> EOF ) -. - - -/*---------------------------------------------------------------------------*/ - -Expr<scalar& val> (. scalar val2 = 0; - if (debug) {Info<<"Expr:"<< val<< " pos:"<< t->pos << nl;} - .) -= - Term<val> - { - "+" Term<val2> (. if (debug) {Info<<"+Term:"<<val2 << " pos:"<< t->pos << nl;} - val += val2; - if (debug) {Info<<"="<< val<< " pos:"<< t->pos << nl;} - .) - | "-" Term<val2> (. if (debug) {Info<<"-Term:"<<val2<< " pos:"<< t->pos << nl;} - val -= val2; - if (debug) {Info<<"="<< val<< " pos:"<< t->pos << nl;} - .) - } -. - - -/*---------------------------------------------------------------------------*/ - -Term<scalar& val> (. scalar val2 = 0; - if (debug) {Info<<"Term:"<< val<< " pos:"<< t->pos << nl;} - .) -= - Factor<val> - { - "*" Factor<val2> (. if (debug) {Info<<"*Factor:"<<val2<< " pos:"<< t->pos << nl;} - val *= val2; - if (debug) {Info<<"="<< val<< " pos:"<< t->pos << nl;} - .) - | "/" Factor<val2> (. if (debug) {Info<<"/Factor:"<<val2<< " pos:"<< t->pos << nl;} - val /= val2; - if (debug) {Info<<"="<< val<< " pos:"<< t->pos << nl;} - .) - } -. - - -/*---------------------------------------------------------------------------*/ -Factor<scalar& val> -= - variable (. val = getDictLookup(); - if (debug) {Info<<"lookup:"<<val<< " pos:"<< t->pos << nl;} - .) - | number (. val = getScalar(); - if (debug) {Info<<"got num:"<<val<< " pos:"<< t->pos << nl;} - .) - | '-' '(' Expr<val> ')' (. val = -val; - if (debug) {Info<<"inv:"<<val<< " pos:"<< t->pos << nl;} - .) - | '(' Expr<val> ')' (. if (debug){Info<<"got Expr:"<<val<< " pos:"<< t->pos << nl;} - .) -. - - -/*---------------------------------------------------------------------------*/ - -END calcEntry. - -// ************************************************************************* // diff --git a/applications/test/dictionary/calcEntry/calcEntryParser.cpp b/applications/test/dictionary/calcEntry/calcEntryParser.cpp deleted file mode 100644 index 1ff95b8ac96b1080dca11b1cb82fe4bc55a6dfab..0000000000000000000000000000000000000000 --- a/applications/test/dictionary/calcEntry/calcEntryParser.cpp +++ /dev/null @@ -1,339 +0,0 @@ - - -#include <wchar.h> -#include "calcEntryParser.h" - - -namespace Foam { -namespace functionEntries { -namespace calcEntryInternal { - - -// ---------------------------------------------------------------------------- -// Parser Implementation -// ---------------------------------------------------------------------------- - -void Parser::SynErr(int n) { - if (errDist >= minErrDist) errors->SynErr(la->line, la->col, n); - errDist = 0; -} - - -void Parser::SemErr(const wchar_t* msg) { - if (errDist >= minErrDist) errors->Error(t->line, t->col, msg); - errDist = 0; -} - - -void Parser::Get() { - for (;;) { - t = la; - la = scanner->Scan(); - if (la->kind <= maxT) { - ++errDist; - break; - } - - if (dummyToken != t) { - dummyToken->kind = t->kind; - dummyToken->pos = t->pos; - dummyToken->col = t->col; - dummyToken->line = t->line; - dummyToken->next = NULL; - coco_string_delete(dummyToken->val); - dummyToken->val = coco_string_create(t->val); - t = dummyToken; - } - la = t; - } -} - - -void Parser::Expect(int n) { - if (la->kind == n) { - Get(); - } - else { - SynErr(n); - } -} - - -void Parser::ExpectWeak(int n, int follow) { - if (la->kind == n) { - Get(); - } - else { - SynErr(n); - while (!StartOf(follow)) { - Get(); - } - } -} - - -bool Parser::WeakSeparator(int n, int syFol, int repFol) { - if (la->kind == n) { - Get(); - return true; - } - else if (StartOf(repFol)) { - return false; - } - else { - SynErr(n); - while (!(StartOf(syFol) || StartOf(repFol) || StartOf(0))) { - Get(); - } - return StartOf(syFol); - } -} - - -void Parser::calcEntry() { - val = 0; - if (debug){Info<<"start val pos:"<< t->pos << nl;} - - if (la->kind == 5) { - Get(); - Expr(val); - Expect(6); - if (debug){ - Info<<"end {} at pos:"<< t->pos - <<" val:"<< t->val - <<" len:"<< coco_string_length(t->val) - <<" la pos:"<< la->pos << nl; - } - // reposition to immediately after the closing '}' - scanner->buffer->SetPos - ( - t->pos + coco_string_length(t->val) - ); - - } else if (StartOf(1)) { - Expr(val); - Expect(0); - } else SynErr(14); -} - -void Parser::Expr(scalar& val) { - scalar val2 = 0; - if (debug) {Info<<"Expr:"<< val<< " pos:"<< t->pos << nl;} - - Term(val); - while (la->kind == 7 || la->kind == 8) { - if (la->kind == 7) { - Get(); - Term(val2); - if (debug) {Info<<"+Term:"<<val2 << " pos:"<< t->pos << nl;} - val += val2; - if (debug) {Info<<"="<< val<< " pos:"<< t->pos << nl;} - - } else { - Get(); - Term(val2); - if (debug) {Info<<"-Term:"<<val2<< " pos:"<< t->pos << nl;} - val -= val2; - if (debug) {Info<<"="<< val<< " pos:"<< t->pos << nl;} - - } - } -} - -void Parser::Term(scalar& val) { - scalar val2 = 0; - if (debug) {Info<<"Term:"<< val<< " pos:"<< t->pos << nl;} - - Factor(val); - while (la->kind == 9 || la->kind == 10) { - if (la->kind == 9) { - Get(); - Factor(val2); - if (debug) {Info<<"*Factor:"<<val2<< " pos:"<< t->pos << nl;} - val *= val2; - if (debug) {Info<<"="<< val<< " pos:"<< t->pos << nl;} - - } else { - Get(); - Factor(val2); - if (debug) {Info<<"/Factor:"<<val2<< " pos:"<< t->pos << nl;} - val /= val2; - if (debug) {Info<<"="<< val<< " pos:"<< t->pos << nl;} - - } - } -} - -void Parser::Factor(scalar& val) { - if (la->kind == 3) { - Get(); - val = getDictLookup(); - if (debug) {Info<<"lookup:"<<val<< " pos:"<< t->pos << nl;} - - } else if (la->kind == 4) { - Get(); - val = getScalar(); - if (debug) {Info<<"got num:"<<val<< " pos:"<< t->pos << nl;} - - } else if (la->kind == 8) { - Get(); - Expect(11); - Expr(val); - Expect(12); - val = -val; - if (debug) {Info<<"inv:"<<val<< " pos:"<< t->pos << nl;} - - } else if (la->kind == 11) { - Get(); - Expr(val); - Expect(12); - if (debug){Info<<"got Expr:"<<val<< " pos:"<< t->pos << nl;} - - } else SynErr(15); -} - - - -void Parser::Parse() { - t = NULL; - if (dummyToken) { // safety: someone might call Parse() twice - delete dummyToken; - } - la = dummyToken = new Token(); - la->val = coco_string_create(L"Dummy Token"); - Get(); - calcEntry(); - // let grammar deal with end-of-file expectations - -} - - -Parser::Parser(Scanner* scan, Errors* err) -: - dummyToken(NULL), - deleteErrorsDestruct_(!err), - errDist(minErrDist), - scanner(scan), - errors(err), - t(NULL), - la(NULL) -{ - - if (!errors) { // add in default error handling - errors = new Errors(); - } -} - - -bool Parser::StartOf(int s) { - const bool T = true; - const bool x = false; - - static bool set[2][15] = { - {T,x,x,x, x,x,x,x, x,x,x,x, x,x,x}, - {x,x,x,T, T,x,x,x, T,x,x,T, x,x,x} - }; - - - - return set[s][la->kind]; -} - - -Parser::~Parser() { - if (deleteErrorsDestruct_) { // delete default error handling - delete errors; - } - delete dummyToken; -} - - -// ---------------------------------------------------------------------------- -// Errors Implementation -// ---------------------------------------------------------------------------- - -Errors::Errors() -: - count(0) -{} - - -Errors::~Errors() -{} - - -void Errors::clear() { - count = 0; -} - - -wchar_t* Errors::strerror(int n) -{ - wchar_t* s; - switch (n) { - case 0: s = coco_string_create(L"EOF expected"); break; - case 1: s = coco_string_create(L"ident expected"); break; - case 2: s = coco_string_create(L"string expected"); break; - case 3: s = coco_string_create(L"variable expected"); break; - case 4: s = coco_string_create(L"number expected"); break; - case 5: s = coco_string_create(L"\"{\" expected"); break; - case 6: s = coco_string_create(L"\"}\" expected"); break; - case 7: s = coco_string_create(L"\"+\" expected"); break; - case 8: s = coco_string_create(L"\"-\" expected"); break; - case 9: s = coco_string_create(L"\"*\" expected"); break; - case 10: s = coco_string_create(L"\"/\" expected"); break; - case 11: s = coco_string_create(L"\"(\" expected"); break; - case 12: s = coco_string_create(L"\")\" expected"); break; - case 13: s = coco_string_create(L"??? expected"); break; - case 14: s = coco_string_create(L"invalid calcEntry"); break; - case 15: s = coco_string_create(L"invalid Factor"); break; - - default: - { - wchar_t format[20]; - coco_swprintf(format, 20, L"error %d", n); - s = coco_string_create(format); - } - break; - } - return s; -} - - -void Errors::Warning(const wchar_t* msg) { - wprintf(L"%ls\n", msg); -} - - -void Errors::Warning(int line, int col, const wchar_t* msg) { - wprintf(L"-- line %d col %d: %ls\n", line, col, msg); -} - - -void Errors::Error(int line, int col, const wchar_t* msg) { - wprintf(L"-- line %d col %d: %ls\n", line, col, msg); - count++; -} - - -void Errors::SynErr(int line, int col, int n) { - wchar_t* msg = this->strerror(n); - this->Error(line, col, msg); - coco_string_delete(msg); -} - - -void Errors::Exception(const wchar_t* msg) { - wprintf(L"%ls", msg); - ::exit(1); -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // namespace -} // namespace -} // namespace - - -// ************************************************************************* // diff --git a/applications/test/dictionary/calcEntry/calcEntryParser.h b/applications/test/dictionary/calcEntry/calcEntryParser.h deleted file mode 100644 index de12a3961ea6eebe69671ac65f5bb1121769b019..0000000000000000000000000000000000000000 --- a/applications/test/dictionary/calcEntry/calcEntryParser.h +++ /dev/null @@ -1,206 +0,0 @@ - - -#ifndef COCO_calcEntryPARSER_H__ -#define COCO_calcEntryPARSER_H__ - -#include "dictionary.H" -#include "scalar.H" -#include "error.H" -#include "wchar.H" - - -#include "calcEntryScanner.h" - -namespace Foam { -namespace functionEntries { -namespace calcEntryInternal { - - -//! Parser error handing -class Errors { -public: - int count; //!< The number of errors detected - - //! Allocate and return a string describing the given error code. - /** It is the responsibility of the caller to free this string, - * eg, with coco_string_delete() - */ - static wchar_t* strerror(int n); - - Errors(); //!< Construct null - start with no errors - virtual ~Errors(); //!< Destructor - virtual void clear(); //!< Clear the error count - - //! Handle a general warning 'msg' - virtual void Warning(const wchar_t* msg); - //! Handle a general warning 'msg' - virtual void Warning(int line, int col, const wchar_t* msg); - //! Handle general error 'msg' (eg, a semantic error) - virtual void Error(int line, int col, const wchar_t* msg); - //! Handle syntax error 'n', uses strerror for the message, calls Error() - virtual void SynErr(int line, int col, int n); - //! Handle a general exception 'msg' - virtual void Exception(const wchar_t* msg); - -}; // Errors - - -//! A Coco/R Parser -class Parser { -private: - enum { - _EOF=0, - _ident=1, - _string=2, - _variable=3, - _number=4, - }; - static const int maxT = 13; - - static const int minErrDist = 2; //!< min. distance before reporting errors - - Token *dummyToken; - bool deleteErrorsDestruct_; //!< delete the 'errors' member in destructor - int errDist; - - void SynErr(int n); //!< Handle syntax error 'n' - void Get(); - void Expect(int n); - bool StartOf(int s); - void ExpectWeak(int n, int follow); - bool WeakSeparator(int n, int syFol, int repFol); - -public: - Scanner *scanner; - Errors *errors; - - Token *t; //!< last recognized token - Token *la; //!< lookahead token - -static const int debug = 0; - - //! The parent dictionary - mutable dictionary* dict_; - - //! Track that parent dictionary was set - bool hasDict_; - - //! The calculation result - scalar val; - - - //! token -> scalar - scalar getScalar() const - { - return coco_string_toDouble(t->val); - } - - //! token -> string - std::string getString() const - { - char* str = coco_string_create_char(t->val); - std::string s(str); - coco_string_delete(str); - return s; - } - - //! attach a dictionary - void dict(const dictionary& dict) - { - dict_ = const_cast<dictionary*>(&dict); - hasDict_ = true; - } - - - //! lookup dictionary entry - scalar getDictLookup() const - { - scalar dictValue = 0; - - if (!hasDict_) - { - FatalErrorIn - ( - "calcEntry::getDictEntry() const" - ) << "No dictionary attached!" - << exit(FatalError); - - return 0; - } - - char* chars = coco_string_create_char - ( - t->val, - 1, - (coco_string_length(t->val) - 1) - ); - word keyword(chars); - coco_string_delete(chars); - - if (debug) - { - Info<<"lookup: " << keyword << nl; - } - - entry* entryPtr = dict_->lookupEntryPtr(keyword, true, false); - if (entryPtr && !entryPtr->isDict()) - { - if (entryPtr->stream().size() != 1) - { - FatalErrorIn - ( - "calcEntry::getDictEntry() const" - ) << "keyword " << keyword << " has " - << entryPtr->stream().size() << " values in dictionary " - << exit(FatalError); - } - entryPtr->stream() >> dictValue; - } - else - { - FatalErrorIn - ( - "calcEntry::getDictEntry() const" - ) << "keyword " << keyword << " is undefined in dictionary " - << exit(FatalError); - } - - - return dictValue; - } - - scalar Result() const - { - return val; - } - - -/*---------------------------------------------------------------------------*/ - - - - //! Construct for the specified scanner - /** - * Use the default error handling, or optionally provide an error - * handler, which will not be deleted upon destruction. - */ - Parser(Scanner* scan, Errors* err = 0); - ~Parser(); //!< Destructor - cleanup errors and dummyToken - void SemErr(const wchar_t* msg); //!< Handle semantic error - - void calcEntry(); - void Expr(scalar& val); - void Term(scalar& val); - void Factor(scalar& val); - - void Parse(); //!< Execute the parse operation - -}; // end Parser - -} // namespace -} // namespace -} // namespace - - -#endif // COCO_calcEntryPARSER_H__ - diff --git a/applications/test/dictionary/calcEntry/calcEntryScanner.cpp b/applications/test/dictionary/calcEntry/calcEntryScanner.cpp deleted file mode 100644 index b070bcf3f35c7c402c7115da70fdefe40bb433b9..0000000000000000000000000000000000000000 --- a/applications/test/dictionary/calcEntry/calcEntryScanner.cpp +++ /dev/null @@ -1,932 +0,0 @@ - - -#include <sstream> - -#include "calcEntryScanner.h" - -// values for the file stream buffering -#define MIN_BUFFER_LENGTH 1024 // 1KB -#define MAX_BUFFER_LENGTH (64*MIN_BUFFER_LENGTH) // 64KB -// value for the heap management -#define HEAP_BLOCK_SIZE (64*1024) // 64KB - - -namespace Foam { -namespace functionEntries { -namespace calcEntryInternal { - - -// * * * * * * * * * * Wide Character String Routines * * * * * * * * * * * // - -// string handling, wide character - -wchar_t* coco_string_create(const wchar_t* str) { - int len = coco_string_length(str); - wchar_t* dest = new wchar_t[len + 1]; - if (len) { - wcsncpy(dest, str, len); - } - dest[len] = 0; - return dest; -} - -wchar_t* coco_string_create(const wchar_t* str, int index, int length) { - int len = coco_string_length(str); - if (len) { - len = length; - } - wchar_t* dest = new wchar_t[len + 1]; - if (len) { - wcsncpy(dest, &(str[index]), len); - } - dest[len] = 0; - return dest; -} - - -wchar_t* coco_string_create_lower(const wchar_t* str) { - if (!str) { return NULL; } - return coco_string_create_lower(str, 0, wcslen(str)); -} - - -wchar_t* coco_string_create_lower(const wchar_t* str, int index, int len) { - if (!str) { return NULL; } - wchar_t* dest = new wchar_t[len + 1]; - - for (int i = 0; i < len; i++) { - const wchar_t ch = str[index + i]; - if ((L'A' <= ch) && (ch <= L'Z')) { - dest[i] = ch - (L'A' - L'a'); - } - else { - dest[i] = ch; - } - } - dest[len] = L'\0'; - return dest; -} - - -wchar_t* coco_string_create_append(const wchar_t* str1, const wchar_t* str2) { - int str1Len = coco_string_length(str1); - int str2Len = coco_string_length(str2); - - wchar_t* dest = new wchar_t[str1Len + str2Len + 1]; - - if (str1Len) { wcscpy(dest, str1); } - if (str2Len) { wcscpy(dest + str1Len, str2); } - - dest[str1Len + str2Len] = 0; - return dest; -} - -wchar_t* coco_string_create_append(const wchar_t* str1, const wchar_t ch) { - int len = coco_string_length(str1); - wchar_t* dest = new wchar_t[len + 2]; - wcsncpy(dest, str1, len); // or use if (len) { wcscpy(dest, str1); } - dest[len] = ch; - dest[len + 1] = 0; - return dest; -} - -void coco_string_delete(wchar_t* &str) { - delete [] str; - str = NULL; -} - -int coco_string_length(const wchar_t* str) { - return str ? wcslen(str) : 0; -} - -bool coco_string_endswith(const wchar_t* str, const wchar_t* endstr) { - int strLen = wcslen(str); - int endLen = wcslen(endstr); - return (endLen <= strLen) && (wcscmp(str + strLen - endLen, endstr) == 0); -} - -int coco_string_indexof(const wchar_t* str, const wchar_t ch) { - const wchar_t* fnd = wcschr(str, ch); - return fnd ? (fnd - str) : -1; -} - -int coco_string_lastindexof(const wchar_t* str, const wchar_t ch) { - const wchar_t* fnd = wcsrchr(str, ch); - return fnd ? (fnd - str) : -1; -} - -void coco_string_merge(wchar_t* &dest, const wchar_t* str) { - if (!str) { return; } - wchar_t* newstr = coco_string_create_append(dest, str); - delete [] dest; - dest = newstr; -} - -bool coco_string_equal(const wchar_t* str1, const wchar_t* str2) { - return wcscmp(str1, str2) == 0; -} - -int coco_string_compareto(const wchar_t* str1, const wchar_t* str2) { - return wcscmp(str1, str2); -} - -int coco_string_hash(const wchar_t* str) { - int h = 0; - if (!str) { return 0; } - while (*str != 0) { - h = (h * 7) ^ *str; - ++str; - } - if (h < 0) { h = -h; } - return h; -} - - -double coco_string_toDouble(const wchar_t* str) -{ - return str ? wcstod(str, NULL) : 0; -} - -float coco_string_toFloat(const wchar_t* str) -{ - return str ? wcstof(str, NULL) : 0; -} - - - -// -// string handling, byte character -// - -wchar_t* coco_string_create(const char* str) { - int len = str ? strlen(str) : 0; - wchar_t* dest = new wchar_t[len + 1]; - for (int i = 0; i < len; ++i) { - dest[i] = wchar_t(str[i]); - } - dest[len] = 0; - return dest; -} - -wchar_t* coco_string_create(const char* str, int index, int length) { - int len = str ? length : 0; - wchar_t* dest = new wchar_t[len + 1]; - for (int i = 0; i < len; ++i) { - dest[i] = wchar_t(str[index + i]); - } - dest[len] = 0; - return dest; -} - - -char* coco_string_create_char(const wchar_t* str) { - int len = coco_string_length(str); - char *dest = new char[len + 1]; - for (int i = 0; i < len; ++i) - { - dest[i] = char(str[i]); - } - dest[len] = 0; - return dest; -} - -char* coco_string_create_char(const wchar_t* str, int index, int length) { - int len = coco_string_length(str); - if (len) { - len = length; - } - char *dest = new char[len + 1]; - for (int i = 0; i < len; ++i) { - dest[i] = char(str[index + i]); - } - dest[len] = 0; - return dest; -} - - -void coco_string_delete(char* &str) { - delete [] str; - str = NULL; -} - - -double coco_string_toDouble(const char* str) -{ - return str ? strtod(str, NULL) : 0; -} - -float coco_string_toFloat(const char* str) -{ - return str ? strtof(str, NULL) : 0; -} - - -// * * * * * * * * * End of Wide Character String Routines * * * * * * * * * // - - -Token::Token() -: - kind(0), - pos(0), - col(0), - line(0), - val(NULL), - next(NULL) -{} - - -// Note: this delete may not be correct if the token was actually -// allocated by the internal heap mechanism -Token::~Token() { - coco_string_delete(val); -} - - -// ---------------------------------------------------------------------------- -// Buffer Implementation -// ---------------------------------------------------------------------------- - -Buffer::Buffer(Buffer* b) -: - buf(b->buf), - bufCapacity(b->bufCapacity), - bufLen(b->bufLen), - bufPos(b->bufPos), - bufStart(b->bufStart), - fileLen(b->fileLen), - cStream(b->cStream), - stdStream(b->stdStream), - isUserStream_(b->isUserStream_) -{ - // avoid accidental deletion on any of these members - b->buf = NULL; - b->cStream = NULL; - b->stdStream = NULL; -} - - -Buffer::Buffer(FILE* istr, bool isUserStream) -: - buf(NULL), - bufCapacity(0), - bufLen(0), - bufPos(0), - bufStart(0), - fileLen(0), - cStream(istr), - stdStream(NULL), - isUserStream_(isUserStream) -{ -// ensure binary read on windows -#if _MSC_VER >= 1300 - _setmode(_fileno(cStream), _O_BINARY); -#endif - - if (CanSeek()) { - fseek(cStream, 0, SEEK_END); - fileLen = ftell(cStream); - fseek(cStream, 0, SEEK_SET); - bufLen = (fileLen < MAX_BUFFER_LENGTH) ? fileLen : MAX_BUFFER_LENGTH; - bufStart = INT_MAX; // nothing in the buffer so far - } - - bufCapacity = (bufLen > 0) ? bufLen : MIN_BUFFER_LENGTH; - buf = new unsigned char[bufCapacity]; - if (fileLen > 0) SetPos(0); // setup buffer to position 0 (start) - else bufPos = 0; // index 0 is already after the file, thus Pos = 0 is invalid - if (bufLen == fileLen && CanSeek()) Close(); -} - - -Buffer::Buffer(std::istream* istr, bool isUserStream) -: - buf(NULL), - bufCapacity(0), - bufLen(0), - bufPos(0), - bufStart(0), - fileLen(0), - cStream(NULL), - stdStream(istr), - isUserStream_(isUserStream) -{ - // ensure binary read on windows -#if _MSC_VER >= 1300 - // TODO -#endif -} - - -Buffer::Buffer(std::string& str) -: - buf(NULL), - bufCapacity(0), - bufLen(0), - bufPos(0), - bufStart(0), - fileLen(0), - cStream(NULL), - stdStream(new std::istringstream(str)), - isUserStream_(false) -{} - - -Buffer::Buffer(const unsigned char* chars, int len) -: - buf(new unsigned char[len]), - bufCapacity(len), - bufLen(len), - bufPos(0), - bufStart(0), - fileLen(len), - cStream(NULL), - stdStream(NULL), - isUserStream_(false) -{ - memcpy(this->buf, chars, len*sizeof(char)); -} - - -Buffer::Buffer(const char* chars, int len) -: - buf(new unsigned char[len]), - bufCapacity(len), - bufLen(len), - bufPos(0), - bufStart(0), - fileLen(len), - cStream(NULL), - stdStream(NULL), - isUserStream_(false) -{ - memcpy(this->buf, chars, len*sizeof(char)); -} - - -Buffer::~Buffer() { - Close(); - if (buf) { - delete [] buf; - buf = NULL; - } -} - - -void Buffer::Close() { - if (!isUserStream_) { - if (cStream) { - fclose(cStream); - cStream = NULL; - } - else if (stdStream) { - delete stdStream; - stdStream = 0; - } - } -} - - -int Buffer::Read() { - if (stdStream) - { - int ch = stdStream->get(); - if (stdStream->eof()) - { - return EoF; - } - return ch; - } - - if (bufPos < bufLen) { - return buf[bufPos++]; - } else if (GetPos() < fileLen) { - SetPos(GetPos()); // shift buffer start to Pos - return buf[bufPos++]; - } else if (cStream && !CanSeek() && (ReadNextStreamChunk() > 0)) { - return buf[bufPos++]; - } else { - return EoF; - } -} - - -int UTF8Buffer::Read() { - int ch; - do { - ch = Buffer::Read(); - // until we find a utf8 start (0xxxxxxx or 11xxxxxx) - } while ((ch >= 128) && ((ch & 0xC0) != 0xC0) && (ch != EoF)); - if (ch < 128 || ch == EoF) { - // nothing to do, first 127 chars are the same in ascii and utf8 - // 0xxxxxxx or end of file character - } else if ((ch & 0xF0) == 0xF0) { - // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - int c1 = ch & 0x07; ch = Buffer::Read(); - int c2 = ch & 0x3F; ch = Buffer::Read(); - int c3 = ch & 0x3F; ch = Buffer::Read(); - int c4 = ch & 0x3F; - ch = (((((c1 << 6) | c2) << 6) | c3) << 6) | c4; - } else if ((ch & 0xE0) == 0xE0) { - // 1110xxxx 10xxxxxx 10xxxxxx - int c1 = ch & 0x0F; ch = Buffer::Read(); - int c2 = ch & 0x3F; ch = Buffer::Read(); - int c3 = ch & 0x3F; - ch = (((c1 << 6) | c2) << 6) | c3; - } else if ((ch & 0xC0) == 0xC0) { - // 110xxxxx 10xxxxxx - int c1 = ch & 0x1F; ch = Buffer::Read(); - int c2 = ch & 0x3F; - ch = (c1 << 6) | c2; - } - return ch; -} - - -int Buffer::Peek() { - int curPos = GetPos(); - int ch = Read(); - SetPos(curPos); - return ch; -} - - -int Buffer::GetPos() const { - if (stdStream) - { - return stdStream->tellg(); - } - - return bufPos + bufStart; -} - - -void Buffer::SetPos(int value) { - if (stdStream) - { - stdStream->seekg(value, std::ios::beg); - return; - } - - if ((value >= fileLen) && cStream && !CanSeek()) { - // Wanted position is after buffer and the stream - // is not seek-able e.g. network or console, - // thus we have to read the stream manually till - // the wanted position is in sight. - while ((value >= fileLen) && (ReadNextStreamChunk() > 0)) - {} - } - - if ((value < 0) || (value > fileLen)) { - wprintf(L"--- buffer out of bounds access, position: %d\n", value); - ::exit(1); - } - - if ((value >= bufStart) && (value < (bufStart + bufLen))) { // already in buffer - bufPos = value - bufStart; - } else if (cStream) { // must be swapped in - fseek(cStream, value, SEEK_SET); - bufLen = fread(buf, sizeof(char), bufCapacity, cStream); - bufStart = value; bufPos = 0; - } else { - bufPos = fileLen - bufStart; // make Pos return fileLen - } -} - - -// Read the next chunk of bytes from the stream, increases the buffer -// if needed and updates the fields fileLen and bufLen. -// Returns the number of bytes read. -int Buffer::ReadNextStreamChunk() { - int freeLen = bufCapacity - bufLen; - if (freeLen == 0) { - // in the case of a growing input stream - // we can neither seek in the stream, nor can we - // foresee the maximum length, thus we must adapt - // the buffer size on demand. - bufCapacity = bufLen * 2; - unsigned char *newBuf = new unsigned char[bufCapacity]; - memcpy(newBuf, buf, bufLen*sizeof(char)); - delete [] buf; - buf = newBuf; - freeLen = bufLen; - } - int read = fread(buf + bufLen, sizeof(char), freeLen, cStream); - if (read > 0) { - fileLen = bufLen = (bufLen + read); - return read; - } - // end of stream reached - return 0; -} - - -bool Buffer::CanSeek() const { - return cStream && (ftell(cStream) != -1); -} - - -// ---------------------------------------------------------------------------- -// Scanner Implementation -// ---------------------------------------------------------------------------- - -Scanner::Scanner(FILE* istr) -: - buffer(new Buffer(istr, true)) -{ - Init(); -} - - -Scanner::Scanner(std::istream& istr) -: - buffer(new Buffer(&istr, true)) -{ - Init(); -} - - -Scanner::Scanner(const wchar_t* fileName) { - char *chFileName = coco_string_create_char(fileName); - FILE* istr; - if ((istr = fopen(chFileName, "rb")) == NULL) { - wprintf(L"--- Cannot open file %ls\n", fileName); - ::exit(1); - } - coco_string_delete(chFileName); - buffer = new Buffer(istr, false); - Init(); -} - - -Scanner::Scanner(const unsigned char* buf, int len) -: - buffer(new Buffer(buf, len)) -{ - Init(); -} - - -Scanner::Scanner(const char* buf, int len) -: - buffer(new Buffer(buf, len)) -{ - Init(); -} - - -Scanner::~Scanner() { - char* cur = reinterpret_cast<char*>(firstHeap); - - while (cur) { - cur = *(reinterpret_cast<char**>(cur + HEAP_BLOCK_SIZE)); - free(firstHeap); - firstHeap = cur; - } - delete [] tval; - delete buffer; -} - - -void Scanner::Init() { - for (int i = 65; i <= 90; ++i) start.set(i, 1); - for (int i = 97; i <= 122; ++i) start.set(i, 1); - for (int i = 36; i <= 36; ++i) start.set(i, 5); - start.set(45, 20); - for (int i = 48; i <= 57; ++i) start.set(i, 9); - start.set(34, 2); - start.set(46, 7); - start.set(123, 14); - start.set(125, 15); - start.set(43, 21); - start.set(42, 16); - start.set(47, 17); - start.set(40, 18); - start.set(41, 19); - start.set(Buffer::EoF, -1); - - - - tvalLength = 128; - tval = new wchar_t[tvalLength]; // text of current token - - // HEAP_BLOCK_SIZE byte heap + pointer to next heap block - heap = malloc(HEAP_BLOCK_SIZE + sizeof(void*)); - firstHeap = heap; - heapEnd = - reinterpret_cast<void**> - (reinterpret_cast<char*>(heap) + HEAP_BLOCK_SIZE); - *heapEnd = 0; - heapTop = heap; - if (sizeof(Token) > HEAP_BLOCK_SIZE) { - wprintf(L"--- Too small HEAP_BLOCK_SIZE\n"); - ::exit(1); - } - - pos = -1; line = 1; col = 0; - oldEols = 0; - NextCh(); - if (ch == 0xEF) { // check optional byte order mark for UTF-8 - NextCh(); int ch1 = ch; - NextCh(); int ch2 = ch; - if (ch1 != 0xBB || ch2 != 0xBF) { - wprintf(L"Illegal byte order mark at start of file"); - ::exit(1); - } - Buffer *oldBuf = buffer; - buffer = new UTF8Buffer(buffer); col = 0; - delete oldBuf; oldBuf = NULL; - NextCh(); - } - - - pt = tokens = CreateToken(); // first token is a dummy -} - - -void Scanner::NextCh() { - if (oldEols > 0) { - ch = EOL; - oldEols--; - } - else { - pos = buffer->GetPos(); - ch = buffer->Read(); col++; - // replace isolated '\r' by '\n' in order to make - // eol handling uniform across Windows, Unix and Mac - if (ch == L'\r' && buffer->Peek() != L'\n') ch = EOL; - if (ch == EOL) { line++; col = 0; } - } - -} - - -void Scanner::AddCh() { - if (tlen >= tvalLength) { - tvalLength *= 2; - wchar_t *newBuf = new wchar_t[tvalLength]; - memcpy(newBuf, tval, tlen*sizeof(wchar_t)); - delete [] tval; - tval = newBuf; - } - if (ch != Buffer::EoF) { - tval[tlen++] = ch; - NextCh(); - } -} - - - -bool Scanner::Comment0() { - int level = 1, pos0 = pos, line0 = line, col0 = col; - NextCh(); - if (ch == L'/') { - NextCh(); - for(;;) { - if (ch == 10) { - level--; - if (level == 0) { oldEols = line - line0; NextCh(); return true; } - NextCh(); - } else if (ch == buffer->EoF) return false; - else NextCh(); - } - } else { - buffer->SetPos(pos0); NextCh(); line = line0; col = col0; - } - return false; -} - -bool Scanner::Comment1() { - int level = 1, pos0 = pos, line0 = line, col0 = col; - NextCh(); - if (ch == L'*') { - NextCh(); - for(;;) { - if (ch == L'*') { - NextCh(); - if (ch == L'/') { - level--; - if (level == 0) { oldEols = line - line0; NextCh(); return true; } - NextCh(); - } - } else if (ch == L'/') { - NextCh(); - if (ch == L'*') { - level++; NextCh(); - } - } else if (ch == buffer->EoF) return false; - else NextCh(); - } - } else { - buffer->SetPos(pos0); NextCh(); line = line0; col = col0; - } - return false; -} - - -void Scanner::CreateHeapBlock() { - char* cur = reinterpret_cast<char*>(firstHeap); - - // release unused blocks - while - ( - (reinterpret_cast<char*>(tokens) < cur) - || (reinterpret_cast<char*>(tokens) > (cur + HEAP_BLOCK_SIZE)) - ) { - cur = *(reinterpret_cast<char**>(cur + HEAP_BLOCK_SIZE)); - free(firstHeap); - firstHeap = cur; - } - - // HEAP_BLOCK_SIZE byte heap + pointer to next heap block - void* newHeap = malloc(HEAP_BLOCK_SIZE + sizeof(void*)); - *heapEnd = newHeap; - heapEnd = - reinterpret_cast<void**> - (reinterpret_cast<char*>(newHeap) + HEAP_BLOCK_SIZE); - *heapEnd = 0; - heap = newHeap; - heapTop = heap; -} - - -Token* Scanner::CreateToken() { - const int reqMem = sizeof(Token); - if - ( - (reinterpret_cast<char*>(heapTop) + reqMem) - >= reinterpret_cast<char*>(heapEnd) - ) { - CreateHeapBlock(); - } - // token 'occupies' heap starting at heapTop - Token* tok = reinterpret_cast<Token*>(heapTop); - // increment past this part of the heap, which is now used - heapTop = - reinterpret_cast<void*> - (reinterpret_cast<char*>(heapTop) + reqMem); - tok->val = NULL; - tok->next = NULL; - return tok; -} - - -void Scanner::AppendVal(Token* tok) { - const int reqMem = (tlen + 1) * sizeof(wchar_t); - if - ( - (reinterpret_cast<char*>(heapTop) + reqMem) - >= reinterpret_cast<char*>(heapEnd) - ) { - if (reqMem > HEAP_BLOCK_SIZE) { - wprintf(L"--- Too long token value\n"); - ::exit(1); - } - CreateHeapBlock(); - } - - // add text value from heap - tok->val = reinterpret_cast<wchar_t*>(heapTop); - - // increment past this part of the heap, which is now used - heapTop = - reinterpret_cast<void*> - (reinterpret_cast<char*>(heapTop) + reqMem); - - // copy the currently parsed tval into the token - wcsncpy(tok->val, tval, tlen); - tok->val[tlen] = L'\0'; -} - - -Token* Scanner::NextToken() { - while (ch == ' ' || - (ch >= 9 && ch <= 10) || ch == 13 - ) NextCh(); - if ((ch == L'/' && Comment0()) || (ch == L'/' && Comment1())) return NextToken(); - t = CreateToken(); - t->pos = pos; t->col = col; t->line = line; - int state = start.state(ch); - tlen = 0; AddCh(); - - switch (state) { - case -1: { t->kind = eofSym; break; } // NextCh already done - case 0: { t->kind = noSym; break; } // NextCh already done - case 1: - case_1: - if ((ch >= L'0' && ch <= L':') || (ch >= L'A' && ch <= L'Z') || ch == L'_' || (ch >= L'a' && ch <= L'z')) {AddCh(); goto case_1;} - else {t->kind = 1; break;} - case 2: - case_2: - if (ch <= 9 || (ch >= 11 && ch <= 12) || (ch >= 14 && ch <= L'!') || (ch >= L'#' && ch <= L'[') || (ch >= L']' && ch <= 65535)) {AddCh(); goto case_2;} - else if (ch == L'"') {AddCh(); goto case_4;} - else if (ch == 92) {AddCh(); goto case_3;} - else {t->kind = noSym; break;} - case 3: - case_3: - if ((ch >= L' ' && ch <= L'~')) {AddCh(); goto case_2;} - else {t->kind = noSym; break;} - case 4: - case_4: - {t->kind = 2; break;} - case 5: - if ((ch >= L'A' && ch <= L'Z') || (ch >= L'a' && ch <= L'z')) {AddCh(); goto case_6;} - else {t->kind = noSym; break;} - case 6: - case_6: - if ((ch >= L'0' && ch <= L':') || (ch >= L'A' && ch <= L'Z') || ch == L'_' || (ch >= L'a' && ch <= L'z')) {AddCh(); goto case_6;} - else {t->kind = 3; break;} - case 7: - case_7: - if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_8;} - else {t->kind = noSym; break;} - case 8: - case_8: - if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_8;} - else {t->kind = 4; break;} - case 9: - case_9: - if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_9;} - else if (ch == L'E' || ch == L'e') {AddCh(); goto case_10;} - else if (ch == L'.') {AddCh(); goto case_13;} - else {t->kind = 4; break;} - case 10: - case_10: - if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_12;} - else if (ch == L'+' || ch == L'-') {AddCh(); goto case_11;} - else {t->kind = noSym; break;} - case 11: - case_11: - if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_12;} - else {t->kind = noSym; break;} - case 12: - case_12: - if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_12;} - else {t->kind = 4; break;} - case 13: - case_13: - if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_13;} - else if (ch == L'E' || ch == L'e') {AddCh(); goto case_10;} - else {t->kind = 4; break;} - case 14: - {t->kind = 5; break;} - case 15: - {t->kind = 6; break;} - case 16: - {t->kind = 9; break;} - case 17: - {t->kind = 10; break;} - case 18: - {t->kind = 11; break;} - case 19: - {t->kind = 12; break;} - case 20: - if (ch == L'.') {AddCh(); goto case_7;} - else {t->kind = 8; break;} - case 21: - if (ch == L'.') {AddCh(); goto case_7;} - else {t->kind = 7; break;} - - } - AppendVal(t); - return t; -} - - -// get the next token (possibly a token already seen during peeking) -Token* Scanner::Scan() { - if (tokens->next == NULL) { - return pt = tokens = NextToken(); - } else { - pt = tokens = tokens->next; - return tokens; - } -} - - -// peek for the next token, ignore pragmas -Token* Scanner::Peek() { - do { - if (pt->next == NULL) { - pt->next = NextToken(); - } - pt = pt->next; - } while (pt->kind > maxT); // skip pragmas - - return pt; -} - - -// make sure that peeking starts at the current scan position -void Scanner::ResetPeek() { - pt = tokens; -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // namespace -} // namespace -} // namespace - - -// ************************************************************************* // diff --git a/applications/test/dictionary/calcEntry/calcEntryScanner.h b/applications/test/dictionary/calcEntry/calcEntryScanner.h deleted file mode 100644 index fdebddeebed9f6792bf2a1922373a86379559282..0000000000000000000000000000000000000000 --- a/applications/test/dictionary/calcEntry/calcEntryScanner.h +++ /dev/null @@ -1,398 +0,0 @@ - - -#ifndef COCO_calcEntrySCANNER_H__ -#define COCO_calcEntrySCANNER_H__ - -#include <climits> -#include <cstdio> -#include <cstdlib> -#include <cstring> -#include <cwchar> -#include <string> -#include <fstream> -#include <iostream> - -// io.h and fcntl are used to ensure binary read from streams on windows -#if _MSC_VER >= 1300 -#include <io.h> -#include <fcntl.h> -#endif - -#if _MSC_VER >= 1400 -#define coco_swprintf swprintf_s -#elif _MSC_VER >= 1300 -#define coco_swprintf _snwprintf -#else -// assume every other compiler knows swprintf -#define coco_swprintf swprintf -#endif - - -#define COCO_WCHAR_MAX 65535 - - -namespace Foam { -namespace functionEntries { -namespace calcEntryInternal { - - - -// * * * * * * * * * * Wide Character String Routines * * * * * * * * * * * // - -// -// string handling, wide character -// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -//! Create by copying str -wchar_t* coco_string_create(const wchar_t* str); - -//! Create a substring of str starting at index and length characters long -wchar_t* coco_string_create(const wchar_t* str, int index, int length); - -//! Create a lowercase string from str -wchar_t* coco_string_create_lower(const wchar_t* str); - -//! Create a lowercase substring from str starting at index and length characters long -wchar_t* coco_string_create_lower(const wchar_t* str, int index, int length); - -//! Create a string by concatenating str1 and str2 -wchar_t* coco_string_create_append(const wchar_t* str1, const wchar_t* str2); - -//! Create a string by concatenating a character to the end of str -wchar_t* coco_string_create_append(const wchar_t* str, const wchar_t ch); - -//! Free storage and nullify the argument -void coco_string_delete(wchar_t* &str); - -//! The length of the str, or 0 if the str is NULL -int coco_string_length(const wchar_t* str); - -//! Return true if the str ends with the endstr -bool coco_string_endswith(const wchar_t* str, const wchar_t* endstr); - -//! Return the index of the first occurrence of ch. -// Return -1 if nothing is found. -int coco_string_indexof(const wchar_t* str, const wchar_t ch); - -//! Return the index of the last occurrence of ch. -// Return -1 if nothing is found. -int coco_string_lastindexof(const wchar_t* str, const wchar_t ch); - -//! Append str to dest -void coco_string_merge(wchar_t* &dest, const wchar_t* str); - -//! Compare strings, return true if they are equal -bool coco_string_equal(const wchar_t* str1, const wchar_t* str2); - -//! Compare strings, return 0 if they are equal -int coco_string_compareto(const wchar_t* str1, const wchar_t* str2); - -//! Simple string hashing function -int coco_string_hash(const wchar_t* str); - -// -// String conversions -// ~~~~~~~~~~~~~~~~~~ - -//! Convert wide string to double -double coco_string_toDouble(const wchar_t* str); - -//! Convert wide string to float -float coco_string_toFloat(const wchar_t* str); - -// -// String handling, byte character -// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -//! Create by copying byte str -wchar_t* coco_string_create(const char* str); - -//! Create a substring of byte str starting at index and length characters long -wchar_t* coco_string_create(const char* str, int index, int length); - -//! Create a byte string by copying str -char* coco_string_create_char(const wchar_t* str); - -//! Create a byte substring of str starting at index and length characters long -char* coco_string_create_char(const wchar_t* str, int index, int length); - -//! Free storage and nullify the argument -void coco_string_delete(char* &str); - - -// -// String conversions, byte character -// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -//! Convert byte string to double -double coco_string_toDouble(const char* str); - -//! Convert byte string to float -float coco_string_toFloat(const char* str); - -// * * * * * * * * * End of Wide Character String Routines * * * * * * * * * // - - -//! Scanner Token -class Token -{ -public: - int kind; //!< token kind - int pos; //!< token position in the source text (starting at 0) - int col; //!< token column (starting at 1) - int line; //!< token line (starting at 1) - wchar_t* val; //!< token value - Token *next; //!< Peek tokens are kept in linked list - - Token(); //!< Construct null - ~Token(); //!< Destructor - cleanup allocated val?? -}; - - -//! Scanner Buffer -// -//! This Buffer supports the following cases: -//! -# seekable stream (file) -//! -# whole stream in buffer -//! -# part of stream in buffer -//! -# non seekable stream (network, console) -class Buffer { -private: - unsigned char *buf; //!< input buffer - int bufCapacity; //!< capacity of buf - int bufLen; //!< length of buffer - int bufPos; //!< current position in buffer - int bufStart; //!< position of first byte in buffer relative to input stream - int fileLen; //!< length of input stream (may change if the stream is no file) - FILE* cStream; //!< input stdio stream (normally seekable) - std::istream* stdStream; //!< STL std stream (seekable) - bool isUserStream_; //!< was the stream opened by the user? - - int ReadNextStreamChunk(); - bool CanSeek() const; //!< true if stream can be seeked otherwise false - -protected: - Buffer(Buffer*); //!< for the UTF8Buffer - -public: - static const int EoF = COCO_WCHAR_MAX + 1; - - //! Attach buffer to a stdio stream. - //! User streams are not closed in the destructor - Buffer(FILE*, bool isUserStream = true); - - //! Attach buffer to an STL std stream - //! User streams are not closed in the destructor - explicit Buffer(std::istream*, bool isUserStream = true); - - //! Copy buffer contents from constant string - //! Handled internally as an istringstream - explicit Buffer(std::string&); - - //! Copy buffer contents from constant character string - Buffer(const unsigned char* chars, int len); - //! Copy buffer contents from constant character string - Buffer(const char* chars, int len); - - //! Close stream (but not user streams) and free buf (if any) - virtual ~Buffer(); - - virtual void Close(); //!< Close stream (but not user streams) - virtual int Read(); //!< Get character from stream or buffer - virtual int Peek(); //!< Peek character from stream or buffer - - virtual int GetPos() const; - virtual void SetPos(int value); -}; - - -//! A Scanner buffer that handles UTF-8 characters -class UTF8Buffer : public Buffer { -public: - UTF8Buffer(Buffer* b) : Buffer(b) {} - virtual int Read(); -}; - - -//------------------------------------------------------------------------------ -// StartStates -//------------------------------------------------------------------------------ -//! maps characters (integers) to start states of tokens -class StartStates { -private: - class Elem { - public: - int key, val; - Elem *next; - Elem(int k, int v) : - key(k), val(v), next(0) - {} - }; - - Elem **tab; - -public: - StartStates() : - tab(new Elem*[128]) - { - memset(tab, 0, 128 * sizeof(Elem*)); - } - - virtual ~StartStates() { - for (int i = 0; i < 128; ++i) { - Elem *e = tab[i]; - while (e) { - Elem *next = e->next; - delete e; - e = next; - } - } - delete [] tab; - } - - void set(int key, int val) { - Elem *e = new Elem(key, val); - int k = unsigned(key) % 128; - e->next = tab[k]; - tab[k] = e; - } - - int state(int key) { - Elem *e = tab[unsigned(key) % 128]; - while (e && e->key != key) e = e->next; - return e ? e->val : 0; - } -}; - - -//------------------------------------------------------------------------------ -// KeywordMap -//------------------------------------------------------------------------------ -//! maps strings to integers (identifiers to keyword kinds) -class KeywordMap { -private: - class Elem { - public: - wchar_t *key; - int val; - Elem *next; - Elem(const wchar_t *k, int v) : - key(coco_string_create(k)), val(v), next(0) - {} - virtual ~Elem() { - coco_string_delete(key); - } - }; - - Elem **tab; - -public: - KeywordMap() : - tab(new Elem*[128]) - { - memset(tab, 0, 128 * sizeof(Elem*)); - } - - virtual ~KeywordMap() { - for (int i = 0; i < 128; ++i) { - Elem *e = tab[i]; - while (e) { - Elem *next = e->next; - delete e; - e = next; - } - } - delete [] tab; - } - - void set(const wchar_t *key, int val) { - Elem *e = new Elem(key, val); - const int k = coco_string_hash(key) % 128; - e->next = tab[k]; - tab[k] = e; - } - - int get(const wchar_t *key, int defaultVal) { - Elem *e = tab[coco_string_hash(key) % 128]; - while (e && !coco_string_equal(e->key, key)) e = e->next; - return e ? e->val : defaultVal; - } -}; - - -//! A Coco/R Scanner -class Scanner { -private: - static const int maxT = 13; - static const int noSym = 13; - - static const int eofSym = 0; //!< end-of-file token id - static const char EOL = '\n'; //!< end-of-line character - - void *firstHeap; //!< the start of the heap management - void *heap; //!< the currently active block - void *heapTop; //!< the top of the heap - void **heapEnd; //!< the end of the last heap block - - StartStates start; //!< A map of start states for particular characters - KeywordMap keywords; //!< A hash of keyword literals to token kind - - Token *t; //!< current token - wchar_t *tval; //!< text of current token - int tvalLength; //!< maximum capacity (length) for tval - int tlen; //!< length of tval - - Token *tokens; //!< list of tokens already peeked (first token is a dummy) - Token *pt; //!< current peek token - - int ch; //!< current input character - - int pos; //!< byte position of current character - int line; //!< line number of current character - int col; //!< column number of current character - int oldEols; //!< the number of EOLs that appeared in a comment - - void CreateHeapBlock(); //!< add a heap block, freeing unused ones - Token* CreateToken(); //!< fit token on the heap - void AppendVal(Token* tok); //!< adjust tok->val to point to the heap and copy tval into it - - void Init(); //!< complete the initialization for the constructors - void NextCh(); //!< get the next input character into ch - void AddCh(); //!< append the character ch to tval - bool Comment0(); - bool Comment1(); - - Token* NextToken(); //!< get the next token - -public: - //! The scanner buffer - Buffer *buffer; - - //! Using an existing open file handle for the scanner - Scanner(FILE*); - - //! Using an existing open STL std stream - explicit Scanner(std::istream&); - - //! Open a file for reading and attach scanner - explicit Scanner(const wchar_t* fileName); - - //! Attach scanner to an existing character buffer - Scanner(const unsigned char* chars, int len); - //! Attach scanner to an existing character buffer - Scanner(const char* chars, int len); - - ~Scanner(); //!< free heap and allocated memory - Token* Scan(); //!< get the next token (possibly a token already seen during peeking) - Token* Peek(); //!< peek for the next token, ignore pragmas - void ResetPeek(); //!< ensure that peeking starts at the current scan position - -}; // end Scanner - -} // namespace -} // namespace -} // namespace - - -#endif // COCO_calcEntrySCANNER_H__ - diff --git a/applications/test/dictionary/testDictCalc b/applications/test/dictionary/testDictCalc index f1d67650e855526718e33e461fa254079990eac9..577cbf112d96c38a3c443cfb190961a4720892d6 100644 --- a/applications/test/dictionary/testDictCalc +++ b/applications/test/dictionary/testDictCalc @@ -10,7 +10,7 @@ FoamFile version 2.0; format ascii; class dictionary; - object testDictTest; + object testDictCalc; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -19,28 +19,13 @@ flowRatePerHour 720; x 10; y 20; z t s v; -// z #test{ // this -// 123 - 456 -// // comments // are -// /* stripped -// * 10 -// * {} -// */ -// + 1 /*100 */ 10 -// }; - -p this calculation #calc{ - 1 + 2 + 10 * 15 + - $x - $y - // $x + $y -} -is done inplace; +p #calc{ 1 + 2 + 10 * 15 + $x - $y }; +// this calculation is in-place, but does not work inside a string: +flowRate "The flow rate " #calc{ $flowRatePerHour / 3600 } "kg/s"; -flowRate #calc{ $flowRatePerHour / 3600}; +// this is also okay +x #calc{ $x * 1E-3 }; -xxx yyy; -foo 30; -bar 15; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/test/dictionary/testDictCalcError b/applications/test/dictionary/testDictCalcError new file mode 100644 index 0000000000000000000000000000000000000000..95b90ce8e8186a01ee01164bd2969f5cbe2d2027 --- /dev/null +++ b/applications/test/dictionary/testDictCalcError @@ -0,0 +1,46 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: Any | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object testDictCalcError; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +flowRatePerHour 720; + +x 10; +y 20; +z t s v; +// z #test{ // this +// 123 - 456 +// // comments // are +// /* stripped +// * 10 +// * {} +// */ +// + 1 /*100 */ 10 +// }; + +p this calculation #calc{ + 1xxx1 + 2 + 10 * 15 + + $x - $y + // $x + $y +} +is done inplace; + + +flowRate #calc{ $flowRatePerHour / 3600}; + +xxx yyy; +foo 30; +bar 15; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/utilities/mesh/advanced/modifyMesh/Make/options b/applications/utilities/mesh/advanced/modifyMesh/Make/options index 39929ff8907077a2153c98fed8f325043d739f3b..70c838b774c8b2609363d066e78b1a19b9306ccd 100644 --- a/applications/utilities/mesh/advanced/modifyMesh/Make/options +++ b/applications/utilities/mesh/advanced/modifyMesh/Make/options @@ -1,9 +1,7 @@ EXE_INC = \ - -I$(LIB_SRC)/triSurface/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude EXE_LIBS = \ - -ltriSurface \ -lmeshTools \ -ldynamicMesh diff --git a/applications/utilities/mesh/advanced/splitCells/Make/options b/applications/utilities/mesh/advanced/splitCells/Make/options index ca424359cf18d2f028b20824a48454c846ddeb5e..7349856cabeb9aeedca94d459c4a1a022c72d996 100644 --- a/applications/utilities/mesh/advanced/splitCells/Make/options +++ b/applications/utilities/mesh/advanced/splitCells/Make/options @@ -1,9 +1,7 @@ EXE_INC = \ -I$(LIB_SRC)/meshTools/lnInclude \ - -I$(LIB_SRC)/triSurface/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude EXE_LIBS = \ -ldynamicMesh \ - -ltriSurface \ -lmeshTools diff --git a/applications/utilities/mesh/conversion/foamToSurface/Make/files b/applications/utilities/mesh/conversion/foamToSurface/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..a5dfd1e846f9acc83c77a19429b1fb7d59cabb76 --- /dev/null +++ b/applications/utilities/mesh/conversion/foamToSurface/Make/files @@ -0,0 +1,3 @@ +foamToSurface.C + +EXE = $(FOAM_APPBIN)/foamToSurface diff --git a/applications/utilities/mesh/conversion/foamToSurface/Make/options b/applications/utilities/mesh/conversion/foamToSurface/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..a504dd8617bfa4ff4d8fc1075d5d68d6db66db89 --- /dev/null +++ b/applications/utilities/mesh/conversion/foamToSurface/Make/options @@ -0,0 +1,5 @@ +EXE_INC = \ + -I$(LIB_SRC)/surfMesh/lnInclude + +EXE_LIBS = \ + -lsurfMesh diff --git a/applications/utilities/mesh/conversion/foamToSurface/foamToSurface.C b/applications/utilities/mesh/conversion/foamToSurface/foamToSurface.C new file mode 100644 index 0000000000000000000000000000000000000000..f9a255c502109cdf2e2415c138e0c18a5fa892e4 --- /dev/null +++ b/applications/utilities/mesh/conversion/foamToSurface/foamToSurface.C @@ -0,0 +1,129 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + foamToSurface + +Description + Reads an OpenFOAM mesh and writes the boundaries in a surface format. + +Usage + - foamToSurface [OPTION] \n + Reads an OpenFOAM mesh and writes the boundaries in a surface format. + + @param -scale \<factor\>\n + Specify an alternative geometry scaling factor. + Eg, use @b 1000 to scale @em [m] to @em [mm]. + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "timeSelector.H" +#include "Time.H" +#include "polyMesh.H" + +#include "MeshedSurfaces.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + argList::noParallel(); + argList::validArgs.append("outputFile.ext"); + timeSelector::addOptions(); + + argList::addOption + ( + "scale", + "scale", + "specify geometry scaling factor" + ); + +# include "setRootCase.H" + + const stringList& params = args.additionalArgs(); + + scalar scaleFactor = 0; + args.optionReadIfPresent<scalar>("scale", scaleFactor); + + fileName exportName(params[0]); + + fileName exportBase = exportName.lessExt(); + word exportExt = exportName.ext(); + + if (!meshedSurface::canWriteType(exportExt, true)) + { + return 1; + } + +# include "createTime.H" + instantList timeDirs = timeSelector::select0(runTime, args); +# include "createPolyMesh.H" + + forAll(timeDirs, timeI) + { + runTime.setTime(timeDirs[timeI], timeI); +# include "getTimeIndex.H" + + polyMesh::readUpdateState state = mesh.readUpdate(); + + if (timeI == 0 || state != polyMesh::UNCHANGED) + { + if (state == polyMesh::UNCHANGED) + { + exportName = exportBase + "." + exportExt; + } + else + { + exportName = + exportBase + '_' + runTime.timeName() + "." + exportExt; + } + + meshedSurface surf(mesh.boundaryMesh()); + surf.scalePoints(scaleFactor); + + Info<< "writing " << exportName; + if (scaleFactor <= 0) + { + Info<< " without scaling" << endl; + } + else + { + Info<< " with scaling " << scaleFactor << endl; + } + surf.write(exportName); + } + + Info<< nl << endl; + } + + Info<< "End\n" << endl; + + return 0; +} + +// ************************************************************************* // diff --git a/applications/utilities/mesh/conversion/foamToSurface/getTimeIndex.H b/applications/utilities/mesh/conversion/foamToSurface/getTimeIndex.H new file mode 100644 index 0000000000000000000000000000000000000000..85a92405dda760fbbfc5931102afe41aa602b2e6 --- /dev/null +++ b/applications/utilities/mesh/conversion/foamToSurface/getTimeIndex.H @@ -0,0 +1,51 @@ +// Read time index from */uniform/time, but treat 0 and constant specially + + word timeName = "0"; + + if + ( + runTime.timeName() != "constant" + && runTime.timeName() != "0" + ) + { + IOobject io + ( + "time", + runTime.timeName(), + "uniform", + runTime, + IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE, + false + ); + + if (io.headerOk()) + { + IOdictionary timeObject + ( + IOobject + ( + "time", + runTime.timeName(), + "uniform", + runTime, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ); + + label index; + timeObject.lookup("index") >> index; + timeName = Foam::name(index); + } + else + { + timeName = runTime.timeName(); + // Info<< "skip ... missing entry " << io.objectPath() << endl; + // continue; + } + } + + Info<< "\nTime [" << timeName << "] = " << runTime.timeName() << nl; + diff --git a/applications/utilities/mesh/conversion/ideasUnvToFoam/Make/options b/applications/utilities/mesh/conversion/ideasUnvToFoam/Make/options index 9f08e8d2a80f6f1fb269c1815170453ae49cf783..02c293ceedb24499f009c1874d6cd6aa18dabd1f 100644 --- a/applications/utilities/mesh/conversion/ideasUnvToFoam/Make/options +++ b/applications/utilities/mesh/conversion/ideasUnvToFoam/Make/options @@ -1,7 +1,7 @@ EXE_INC = \ -I$(LIB_SRC)/meshTools/lnInclude \ - -I$(LIB_SRC)/triSurface/lnInclude + -I$(LIB_SRC)/surfMesh/lnInclude EXE_LIBS = \ -lmeshTools \ - -ltriSurface + -lsurfMesh diff --git a/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C b/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C index ba7ee39c8080a92af0f1f5fda4fad3c7f63f44bf..259ccd2069b02213f3cc48f12dbe04bf4def823e 100644 --- a/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C +++ b/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C @@ -41,7 +41,8 @@ Description #include "cellSet.H" #include "faceSet.H" #include "DynamicList.H" -#include "triSurface.H" + +#include "MeshedSurfaces.H" using namespace Foam; @@ -268,9 +269,11 @@ void readCells break; } - IStringStream lineStr(line); label cellI, feID, physProp, matProp, colour, nNodes; - lineStr >> cellI >> feID >> physProp >> matProp >> colour >> nNodes; + + IStringStream lineStr(line); + lineStr + >> cellI >> feID >> physProp >> matProp >> colour >> nNodes; if (foundFeType.insert(feID)) { @@ -297,7 +300,8 @@ void readCells face cVerts(3); IStringStream lineStr(line); - lineStr >> cVerts[0] >> cVerts[1] >> cVerts[2]; + lineStr + >> cVerts[0] >> cVerts[1] >> cVerts[2]; boundaryFaces.append(cVerts); boundaryFaceIndices.append(cellI); } @@ -308,7 +312,8 @@ void readCells face cVerts(4); IStringStream lineStr(line); - lineStr >> cVerts[0] >> cVerts[1] >> cVerts[2] >> cVerts[3]; + lineStr + >> cVerts[0] >> cVerts[1] >> cVerts[2] >> cVerts[3]; boundaryFaces.append(cVerts); boundaryFaceIndices.append(cellI); } @@ -319,14 +324,15 @@ void readCells labelList cVerts(4); IStringStream lineStr(line); - lineStr >> cVerts[0] >> cVerts[1] >> cVerts[2] >> cVerts[3]; + lineStr + >> cVerts[0] >> cVerts[1] >> cVerts[2] >> cVerts[3]; cellVerts.append(cellShape(tet, cVerts, true)); cellMaterial.append(physProp); if (cellVerts.last().size() != cVerts.size()) { - Pout<< "Line:" << is.lineNumber() + Info<< "Line:" << is.lineNumber() << " element:" << cellI << " type:" << feID << " collapsed from " << cVerts << nl @@ -341,15 +347,16 @@ void readCells labelList cVerts(6); IStringStream lineStr(line); - lineStr >> cVerts[0] >> cVerts[1] >> cVerts[2] >> cVerts[3] - >> cVerts[4] >> cVerts[5]; + lineStr + >> cVerts[0] >> cVerts[1] >> cVerts[2] + >> cVerts[3] >> cVerts[4] >> cVerts[5]; cellVerts.append(cellShape(prism, cVerts, true)); cellMaterial.append(physProp); if (cellVerts.last().size() != cVerts.size()) { - Pout<< "Line:" << is.lineNumber() + Info<< "Line:" << is.lineNumber() << " element:" << cellI << " type:" << feID << " collapsed from " << cVerts << nl @@ -373,7 +380,7 @@ void readCells if (cellVerts.last().size() != cVerts.size()) { - Pout<< "Line:" << is.lineNumber() + Info<< "Line:" << is.lineNumber() << " element:" << cellI << " type:" << feID << " collapsed from " << cVerts << nl @@ -388,7 +395,7 @@ void readCells IOWarningIn("readCells(IFstream&, label&)", is) << "Cell type " << feID << " not supported" << endl; } - is.getLine(line); //Do nothing + is.getLine(line); // Do nothing } } @@ -579,7 +586,11 @@ int main(int argc, char *argv[]) { argList::noParallel(); argList::validArgs.append(".unv file"); - argList::addBoolOption("dump"); + argList::addBoolOption + ( + "dump", + "dump boundary faces as boundaryFaces.obj (for debugging)" + ); # include "setRootCase.H" # include "createTime.H" @@ -858,40 +869,25 @@ int main(int argc, char *argv[]) polyPoints /= lengthScale; - // For debugging: dump boundary faces as triSurface + // For debugging: dump boundary faces as OBJ surface mesh if (args.optionFound("dump")) { - DynamicList<labelledTri> triangles(boundaryFaces.size()); - - forAll(boundaryFaces, i) - { - const face& f = boundaryFaces[i]; - - faceList triFaces(f.nTriangles(polyPoints)); - label nTri = 0; - f.triangles(polyPoints, nTri, triFaces); - - forAll(triFaces, triFaceI) - { - const face& f = triFaces[triFaceI]; - triangles.append(labelledTri(f[0], f[1], f[2], 0)); - } - } - - // Create globally numbered tri surface - triSurface rawSurface(triangles.shrink(), polyPoints); + Info<< "Writing boundary faces to OBJ file boundaryFaces.obj" + << nl << endl; - // Create locally numbered tri surface - triSurface surface + // Create globally numbered surface + meshedSurface rawSurface ( - rawSurface.localFaces(), - rawSurface.localPoints() + xferCopy(polyPoints), + xferCopyTo< faceList >(boundaryFaces) ); - Info<< "Writing boundary faces to STL file boundaryFaces.stl" - << nl << endl; - - surface.write(runTime.path()/"boundaryFaces.stl"); + // Write locally numbered surface + meshedSurface + ( + xferCopy(rawSurface.localPoints()), + xferCopy(rawSurface.localFaces()) + ).write(runTime.path()/"boundaryFaces.obj"); } diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C index fef49a3fe6c65b81f20ec5cb377719a4c02ac535..528551eb51a5ba176d2c42df26a50614f41d0301 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -56,11 +56,6 @@ scalar getMergeDistance(const polyMesh& mesh, const scalar mergeTol) { const boundBox& meshBb = mesh.bounds(); scalar mergeDist = mergeTol * meshBb.mag(); - scalar writeTol = std::pow - ( - scalar(10.0), - -scalar(IOstream::defaultPrecision()) - ); Info<< nl << "Overall mesh bounding box : " << meshBb << nl @@ -68,17 +63,27 @@ scalar getMergeDistance(const polyMesh& mesh, const scalar mergeTol) << "Absolute matching distance : " << mergeDist << nl << endl; - if (mesh.time().writeFormat() == IOstream::ASCII && mergeTol < writeTol) + // check writing tolerance + if (mesh.time().writeFormat() == IOstream::ASCII) { - FatalErrorIn("getMergeDistance(const polyMesh&, const scalar)") - << "Your current settings specify ASCII writing with " - << IOstream::defaultPrecision() << " digits precision." << endl - << "Your merging tolerance (" << mergeTol << ") is finer than this." - << endl - << "Please change your writeFormat to binary" - << " or increase the writePrecision" << endl - << "or adjust the merge tolerance (-mergeTol)." - << exit(FatalError); + const scalar writeTol = std::pow + ( + scalar(10.0), + -scalar(IOstream::defaultPrecision()) + ); + + if (mergeTol < writeTol) + { + FatalErrorIn("getMergeDistance(const polyMesh&, const dictionary&)") + << "Your current settings specify ASCII writing with " + << IOstream::defaultPrecision() << " digits precision." << nl + << "Your merging tolerance (" << mergeTol + << ") is finer than this." << nl + << "Change to binary writeFormat, " + << "or increase the writePrecision" << endl + << "or adjust the merge tolerance (mergeTol)." + << exit(FatalError); + } } return mergeDist; @@ -107,7 +112,7 @@ void writeMesh mesh.time().path()/meshRefiner.timeName() ); } - Info<< "Written mesh in = " + Info<< "Wrote mesh in = " << mesh.time().cpuTimeIncrement() << " s." << endl; } @@ -115,7 +120,11 @@ void writeMesh int main(int argc, char *argv[]) { - argList::addBoolOption("overwrite"); + argList::addBoolOption + ( + "overwrite", + "overwrite existing mesh files" + ); # include "setRootCase.H" # include "createTime.H" runTime.functionObjects().off(); @@ -126,7 +135,6 @@ int main(int argc, char *argv[]) const bool overwrite = args.optionFound("overwrite"); - // Check patches and faceZones are synchronised mesh.boundaryMesh().checkParallelSync(true); meshRefinement::checkCoupledFaceZones(mesh); @@ -173,7 +181,7 @@ int main(int argc, char *argv[]) // layer addition parameters const dictionary& layerDict = meshDict.subDict("addLayersControls"); - + // absolute merge distance const scalar mergeDist = getMergeDistance ( mesh, @@ -181,17 +189,16 @@ int main(int argc, char *argv[]) ); - // Debug // ~~~~~ - const label debug(readLabel(meshDict.lookup("debug"))); + const label debug = meshDict.lookupOrDefault<label>("debug", 0); if (debug > 0) { - meshRefinement::debug = debug; + meshRefinement::debug = debug; autoRefineDriver::debug = debug; - autoSnapDriver::debug = debug; - autoLayerDriver::debug = debug; + autoSnapDriver::debug = debug; + autoLayerDriver::debug = debug; } @@ -272,7 +279,7 @@ int main(int argc, char *argv[]) meshRefiner.write ( - debug&meshRefinement::OBJINTERSECTIONS, + debug & meshRefinement::OBJINTERSECTIONS, mesh.time().path()/meshRefiner.timeName() ); @@ -357,9 +364,9 @@ int main(int argc, char *argv[]) // Now do the real work -refinement -snapping -layers // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Switch wantRefine(meshDict.lookup("castellatedMesh")); - Switch wantSnap(meshDict.lookup("snap")); - Switch wantLayers(meshDict.lookup("addLayers")); + const Switch wantRefine(meshDict.lookup("castellatedMesh")); + const Switch wantSnap(meshDict.lookup("snap")); + const Switch wantLayers(meshDict.lookup("addLayers")); if (wantRefine) { @@ -479,7 +486,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/utilities/mesh/manipulation/autoPatch/Make/options b/applications/utilities/mesh/manipulation/autoPatch/Make/options index d002df80306839e675acfadd6616b913945bd287..7349856cabeb9aeedca94d459c4a1a022c72d996 100644 --- a/applications/utilities/mesh/manipulation/autoPatch/Make/options +++ b/applications/utilities/mesh/manipulation/autoPatch/Make/options @@ -1,10 +1,7 @@ EXE_INC = \ - -I$(LIB_SRC)/triSurface/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude - EXE_LIBS = \ - -ltriSurface \ -ldynamicMesh \ -lmeshTools diff --git a/applications/utilities/mesh/manipulation/objToVTK/Make/options b/applications/utilities/mesh/manipulation/objToVTK/Make/options index 0548bdd022045da6d1853ae6184d7cb0b6713312..79a9626b5500c171eaa6dbeef1681e91f922e9dc 100644 --- a/applications/utilities/mesh/manipulation/objToVTK/Make/options +++ b/applications/utilities/mesh/manipulation/objToVTK/Make/options @@ -1,8 +1 @@ -/* -EXE_INC = \ - -I$(LIB_SRC)/triSurface/lnInclude - -EXE_LIBS = \ - -lmeshTools \ - -ltriSurface -*/ +/* */ diff --git a/applications/utilities/mesh/manipulation/refineMesh/Make/options b/applications/utilities/mesh/manipulation/refineMesh/Make/options index 5c9c1c2b87eac4f2baa89f74c00588c2d761c78f..73f34b0f85f190348d7b3b89bc9b39acd5ce761f 100644 --- a/applications/utilities/mesh/manipulation/refineMesh/Make/options +++ b/applications/utilities/mesh/manipulation/refineMesh/Make/options @@ -1,9 +1,7 @@ EXE_INC = \ -I$(LIB_SRC)/dynamicMesh/lnInclude \ - -I$(LIB_SRC)/triSurface/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude - EXE_LIBS = \ -ldynamicMesh \ -lmeshTools diff --git a/applications/utilities/miscellaneous/foamDebugSwitches/Make/options b/applications/utilities/miscellaneous/foamDebugSwitches/Make/options index e473b84bb97d6b6674fe75f865e16df486bf5bb3..7207b539275a309d53ea95e21565461d52cc6bfc 100644 --- a/applications/utilities/miscellaneous/foamDebugSwitches/Make/options +++ b/applications/utilities/miscellaneous/foamDebugSwitches/Make/options @@ -18,6 +18,7 @@ EXE_LIBS = \ -lengine \ -lerrorEstimation \ -lfieldFunctionObjects \ + -lfileFormats \ -lfiniteVolume \ -lforces \ -lfvMotionSolvers \ diff --git a/applications/utilities/postProcessing/sampling/probeLocations/Make/options b/applications/utilities/postProcessing/sampling/probeLocations/Make/options index 44392ffc4437ed4013fba29bf3a948028cfadb61..ec8bc31179aeb190cbcd64e34098392e1c704f4e 100644 --- a/applications/utilities/postProcessing/sampling/probeLocations/Make/options +++ b/applications/utilities/postProcessing/sampling/probeLocations/Make/options @@ -2,7 +2,6 @@ EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/sampling/lnInclude \ - -I$(LIB_SRC)/triSurface/lnInclude \ -I$(LIB_SRC)/lagrangian/basic/lnInclude EXE_LIBS = \ @@ -10,5 +9,4 @@ EXE_LIBS = \ -lgenericPatchFields \ -lmeshTools \ -lsampling \ - -ltriSurface \ -llagrangian diff --git a/applications/utilities/postProcessing/sampling/sample/Make/options b/applications/utilities/postProcessing/sampling/sample/Make/options index 4877a53003324da70a11fdc9d0c4211de08c905d..88c6039b4e048acf84a463e29ff47746419c9d85 100644 --- a/applications/utilities/postProcessing/sampling/sample/Make/options +++ b/applications/utilities/postProcessing/sampling/sample/Make/options @@ -3,7 +3,6 @@ EXE_INC = \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/sampling/lnInclude \ -I$(LIB_SRC)/surfMesh/lnInclude \ - -I$(LIB_SRC)/triSurface/lnInclude \ -I$(LIB_SRC)/lagrangian/basic/lnInclude EXE_LIBS = \ @@ -12,5 +11,4 @@ EXE_LIBS = \ -lmeshTools \ -lsampling \ -lsurfMesh \ - -ltriSurface \ -llagrangian diff --git a/applications/utilities/surface/surfaceAutoPatch/Make/options b/applications/utilities/surface/surfaceAutoPatch/Make/options index e4751082e14ff667621dfbf92ccf70545c128a26..9f08e8d2a80f6f1fb269c1815170453ae49cf783 100644 --- a/applications/utilities/surface/surfaceAutoPatch/Make/options +++ b/applications/utilities/surface/surfaceAutoPatch/Make/options @@ -1,5 +1,4 @@ EXE_INC = \ - /* -I$(LIB_SRC)/cfdTools/general/lnInclude */ \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/triSurface/lnInclude diff --git a/applications/utilities/surface/surfaceFeatureConvert/Make/options b/applications/utilities/surface/surfaceFeatureConvert/Make/options index f87dafaa5d10360d6d884f491ab17401eb6dcb22..e71834f99e7bda1e25a37bf5073892ce318fab8a 100644 --- a/applications/utilities/surface/surfaceFeatureConvert/Make/options +++ b/applications/utilities/surface/surfaceFeatureConvert/Make/options @@ -1,9 +1,7 @@ EXE_INC = \ -I$(LIB_SRC)/meshTools/lnInclude \ - -I$(LIB_SRC)/edgeMesh/lnInclude \ - -I$(LIB_SRC)/triSurface/lnInclude + -I$(LIB_SRC)/edgeMesh/lnInclude EXE_LIBS = \ -lmeshTools \ - -ledgeMesh \ - -ltriSurface + -ledgeMesh diff --git a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C index f38bf13cc5803e622a01085040b23155da4fd2b2..71eda554fafce464bffff9a7b43e875d3f71852c 100644 --- a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C +++ b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C @@ -79,11 +79,7 @@ void deleteBox { const point eMid = surf.edges()[edgeI].centre(surf.localPoints()); - if - ( - (removeInside && bb.contains(eMid)) - || (!removeInside && !bb.contains(eMid)) - ) + if (removeInside ? bb.contains(eMid) : !bb.contains(eMid)) { edgeStat[edgeI] = surfaceFeatures::NONE; } @@ -133,7 +129,6 @@ int main(int argc, char *argv[]) - // Either construct features from surface&featureangle or read set. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/applications/utilities/surface/surfaceFind/Make/options b/applications/utilities/surface/surfaceFind/Make/options index 4c41bc1a492720796cc6fec3cc42dbcc3ea89276..946b16a9ad7a1cb602df9752d7c7b5c62e375c2c 100644 --- a/applications/utilities/surface/surfaceFind/Make/options +++ b/applications/utilities/surface/surfaceFind/Make/options @@ -1,6 +1,6 @@ EXE_INC = \ - -I$(LIB_SRC)/triSurface/lnInclude + -I$(LIB_SRC)/surfMesh/lnInclude EXE_LIBS = \ -lmeshTools \ - -ltriSurface + -lsurfMesh diff --git a/applications/utilities/surface/surfaceFind/surfaceFind.C b/applications/utilities/surface/surfaceFind/surfaceFind.C index dcaccc04c298c4e7f4315e93c5b051ce63894ff9..8e36fc25ecaab5ce7a55b224ee2486ab93776c3a 100644 --- a/applications/utilities/surface/surfaceFind/surfaceFind.C +++ b/applications/utilities/surface/surfaceFind/surfaceFind.C @@ -23,18 +23,16 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Description - Finds nearest triangle and vertex. + Finds nearest face and vertex. \*---------------------------------------------------------------------------*/ -#include "triSurface.H" #include "argList.H" #include "OFstream.H" -#ifndef namespaceFoam -#define namespaceFoam - using namespace Foam; -#endif +#include "MeshedSurfaces.H" + +using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -44,9 +42,9 @@ int main(int argc, char *argv[]) { argList::noParallel(); argList::validArgs.clear(); - argList::addOption("x", "X"); - argList::addOption("y", "Y"); - argList::addOption("z", "Z"); + argList::addOption("x", "X", "The point x-coordinate (if non-zero)"); + argList::addOption("y", "Y", "The point y-coordinate (if non-zero)"); + argList::addOption("z", "Z", "The point y-coordinate (if non-zero)"); argList::validArgs.append("surface file"); @@ -54,15 +52,15 @@ int main(int argc, char *argv[]) point samplePt ( - args.optionRead<scalar>("x"), - args.optionRead<scalar>("y"), - args.optionRead<scalar>("z") + args.optionLookupOrDefault<scalar>("x", 0), + args.optionLookupOrDefault<scalar>("y", 0), + args.optionLookupOrDefault<scalar>("z", 0) ); Info<< "Looking for nearest face/vertex to " << samplePt << endl; - Info<< "Reading surf1 ..." << endl; - triSurface surf1(args.additionalArgs()[0]); + Info<< "Reading surf ..." << endl; + meshedSurface surf1(args.additionalArgs()[0]); // // Nearest vertex @@ -83,11 +81,11 @@ int main(int argc, char *argv[]) } } - Info<< "Nearest vertex:" << endl - << " index :" << minIndex << " (in localPoints)" << endl + Info<< "Nearest vertex:" << nl + << " index :" << minIndex << " (in localPoints)" << nl << " index :" << surf1.meshPoints()[minIndex] - << " (in points)" << endl - << " coordinates:" << localPoints[minIndex] << endl + << " (in points)" << nl + << " coordinates:" << localPoints[minIndex] << nl << endl; // @@ -101,8 +99,7 @@ int main(int argc, char *argv[]) forAll(surf1, faceI) { - const labelledTri& f = surf1[faceI]; - const point centre = f.centre(points); + const point centre = surf1[faceI].centre(points); const scalar dist = mag(centre - samplePt); if (dist < minDist) @@ -112,16 +109,19 @@ int main(int argc, char *argv[]) } } - const labelledTri& f = surf1[minIndex]; + const face& f = surf1[minIndex]; - Info<< "Face with nearest centre:" << endl - << " index :" << minIndex << endl - << " centre :" << f.centre(points) << endl - << " face :" << f << endl - << " vertex coords:" << points[f[0]] << " " - << points[f[1]] << " " << points[f[2]] << endl - << endl; + Info<< "Face with nearest centre:" << nl + << " index :" << minIndex << nl + << " centre :" << f.centre(points) << nl + << " face :" << f << nl + << " vertex coords:\n"; + forAll(f, fp) + { + Info<< " " << points[f[fp]] << "\n"; + } + Info<< endl; Info<< "End\n" << endl; diff --git a/applications/utilities/surface/surfaceSmooth/Make/options b/applications/utilities/surface/surfaceSmooth/Make/options index 4c41bc1a492720796cc6fec3cc42dbcc3ea89276..946b16a9ad7a1cb602df9752d7c7b5c62e375c2c 100644 --- a/applications/utilities/surface/surfaceSmooth/Make/options +++ b/applications/utilities/surface/surfaceSmooth/Make/options @@ -1,6 +1,6 @@ EXE_INC = \ - -I$(LIB_SRC)/triSurface/lnInclude + -I$(LIB_SRC)/surfMesh/lnInclude EXE_LIBS = \ -lmeshTools \ - -ltriSurface + -lsurfMesh diff --git a/applications/utilities/surface/surfaceSmooth/surfaceSmooth.C b/applications/utilities/surface/surfaceSmooth/surfaceSmooth.C index bce23c9846897dd0f98b7314e7277a27b9ed6b2a..e68f6ab20b2f6d5fb0a281312944d2ced07d1daf 100644 --- a/applications/utilities/surface/surfaceSmooth/surfaceSmooth.C +++ b/applications/utilities/surface/surfaceSmooth/surfaceSmooth.C @@ -23,15 +23,16 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Description - Example of simple laplacian smoother + Example of a simple laplacian smoother \*---------------------------------------------------------------------------*/ -#include "triSurface.H" #include "argList.H" #include "OFstream.H" #include "boundBox.H" +#include "MeshedSurfaces.H" + using namespace Foam; @@ -61,23 +62,20 @@ int main(int argc, char *argv[]) label iters(readLabel(IStringStream(args.additionalArgs()[2])())); fileName outFileName(args.additionalArgs()[3]); - Info<< "Relax:" << relax << endl; - Info<< "Iters:" << iters << endl; - + Info<< "Relax:" << relax << nl + << "Iters:" << iters << nl + << "Reading surface from " << surfFileName << " ..." << endl; - Info<< "Reading surface from " << surfFileName << " ..." << endl; + meshedSurface surf1(surfFileName); - triSurface surf1(surfFileName); - - Info<< "Triangles : " << surf1.size() << endl; - Info<< "Vertices : " << surf1.nPoints() << endl; - Info<< "Bounding Box : " << boundBox(surf1.localPoints()) << endl; + Info<< "Faces : " << surf1.size() << nl + << "Vertices : " << surf1.nPoints() << nl + << "Bounding Box : " << boundBox(surf1.localPoints()) << endl; pointField newPoints(surf1.localPoints()); const labelListList& pointEdges = surf1.pointEdges(); - for (label iter = 0; iter < iters; iter++) { forAll(pointEdges, vertI) @@ -100,16 +98,14 @@ int main(int argc, char *argv[]) } } - triSurface surf2 - ( - surf1.localFaces(), - surf1.patches(), - newPoints - ); - Info<< "Writing surface to " << outFileName << " ..." << endl; - surf2.write(outFileName); + meshedSurface + ( + xferMove(newPoints), + xferCopy(surf1.localFaces()), + xferCopy(surf1.surfZones()) + ).write(outFileName); Info<< "End\n" << endl; diff --git a/applications/utilities/surface/surfaceSubset/surfaceSubset.C b/applications/utilities/surface/surfaceSubset/surfaceSubset.C index dd8a6ede00422d203d8dc5fdc19ae3207d759ceb..6cc8ee4678438534a81367192ebfe3d04b48d42b 100644 --- a/applications/utilities/surface/surfaceSubset/surfaceSubset.C +++ b/applications/utilities/surface/surfaceSubset/surfaceSubset.C @@ -100,10 +100,8 @@ int main(int argc, char *argv[]) meshSubsetDict.lookup("addFaceNeighbours") ); - Switch invertSelection - ( - meshSubsetDict.lookup("invertSelection") - ); + const bool invertSelection = + meshSubsetDict.lookupOrDefault<bool>("invertSelection", false); // Mark the cells for the subset @@ -246,7 +244,7 @@ int main(int argc, char *argv[]) // bb of surface treeBoundBox bb(selectSurf.localPoints()); - // Radnom number generator + // Random number generator Random rndGen(354543); // search engine @@ -269,14 +267,11 @@ int main(int argc, char *argv[]) indexedOctree<treeDataTriSurface>::volumeType t = selectTree.getVolumeType(fc); - if (t == indexedOctree<treeDataTriSurface>::INSIDE && !outside) - { - facesToSubset[faceI] = true; - } - else if + if ( - t == indexedOctree<treeDataTriSurface>::OUTSIDE - && outside + outside + ? (t == indexedOctree<treeDataTriSurface>::OUTSIDE) + : (t == indexedOctree<treeDataTriSurface>::INSIDE) ) { facesToSubset[faceI] = true; @@ -346,20 +341,11 @@ int main(int argc, char *argv[]) if (invertSelection) { Info<< "Inverting selection." << endl; - boolList newFacesToSubset(facesToSubset.size()); forAll(facesToSubset, i) { - if (facesToSubset[i]) - { - newFacesToSubset[i] = false; - } - else - { - newFacesToSubset[i] = true; - } + facesToSubset[i] = facesToSubset[i] ? false : true; } - facesToSubset.transfer(newFacesToSubset); } diff --git a/applications/utilities/surface/surfaceSubset/surfaceSubsetDict b/applications/utilities/surface/surfaceSubset/surfaceSubsetDict index 3a8db2cffd60d1c9c2785966ece5171885b51554..f956a24789a05df748677a39fdac889ef1a603ad 100644 --- a/applications/utilities/surface/surfaceSubset/surfaceSubsetDict +++ b/applications/utilities/surface/surfaceSubset/surfaceSubsetDict @@ -36,7 +36,7 @@ zone surface { name "sphere.stl"; - outside yes; + outside yes; } // Extend selection with edge neighbours diff --git a/applications/utilities/surface/surfaceTransformPoints/Make/options b/applications/utilities/surface/surfaceTransformPoints/Make/options index 4c41bc1a492720796cc6fec3cc42dbcc3ea89276..a504dd8617bfa4ff4d8fc1075d5d68d6db66db89 100644 --- a/applications/utilities/surface/surfaceTransformPoints/Make/options +++ b/applications/utilities/surface/surfaceTransformPoints/Make/options @@ -1,6 +1,5 @@ EXE_INC = \ - -I$(LIB_SRC)/triSurface/lnInclude + -I$(LIB_SRC)/surfMesh/lnInclude EXE_LIBS = \ - -lmeshTools \ - -ltriSurface + -lsurfMesh diff --git a/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C b/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C index 8bb87d3ee9d14819f5f8a6d73886a53be10d1e02..387471521ed37b2e7d0968715aa251c920b97525 100644 --- a/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C +++ b/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C @@ -35,7 +35,6 @@ Description \*---------------------------------------------------------------------------*/ -#include "triSurface.H" #include "argList.H" #include "OFstream.H" #include "IFstream.H" @@ -45,6 +44,8 @@ Description #include "quaternion.H" #include "mathematicalConstants.H" +#include "MeshedSurfaces.H" + using namespace Foam; using namespace Foam::constant::mathematical; @@ -114,7 +115,7 @@ int main(int argc, char *argv[]) << exit(FatalError); } - triSurface surf1(surfFileName); + meshedSurface surf1(surfFileName); pointField points(surf1.points()); @@ -193,9 +194,8 @@ int main(int argc, char *argv[]) points.replace(vector::Z, scaleVector.z()*points.component(vector::Z)); } - triSurface surf2(surf1, surf1.patches(), points); - - surf2.write(outFileName); + surf1.movePoints(points); + surf1.write(outFileName); Info<< "End\n" << endl; diff --git a/bin/engridFoam b/bin/engridFoam index 37e61b05691b7709878d8c647bcb0634e17334a4..b017d23cb658921d01b0702afe9ec83f8c877792 100755 --- a/bin/engridFoam +++ b/bin/engridFoam @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -34,7 +34,7 @@ usage() { while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat<<USAGE -usage: ${0##*/} [OPTION] +Usage: ${0##*/} [OPTION] options: -help diff --git a/bin/finddep b/bin/finddep index 0d16d4e335291982c28a8dcc986536ece4dd2844..93eea85889a4829131540073aa8a406acfc3a915 100755 --- a/bin/finddep +++ b/bin/finddep @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -34,7 +34,7 @@ usage() { while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat<<USAGE -usage: ${0##*/} <file1> ... <fileN> +Usage: ${0##*/} <file1> ... <fileN> * find all .dep files referring to any of <file1> ... <fileN> diff --git a/bin/foamCleanPath b/bin/foamCleanPath index 225aa0e9430f3fbcf874ca965999cc098e2878ad..fcb5b7068c4ed0d50a2bf2a6810ff65c5f477aa8 100755 --- a/bin/foamCleanPath +++ b/bin/foamCleanPath @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -41,7 +41,7 @@ #------------------------------------------------------------------------------ usage() { cat <<USAGE 1>&2 -usage: ${0##*/} [-strip] path [wildcard] .. [wildcard] +Usage: ${0##*/} [-strip] path [wildcard] .. [wildcard] Prints its argument (which should be a ':' separated list) cleansed from - duplicate elements diff --git a/bin/foamClearPolyMesh b/bin/foamClearPolyMesh index ce3e563d31f504257dad6567a946028e5dde7a11..40689539abc6823c75538283989845630640953a 100755 --- a/bin/foamClearPolyMesh +++ b/bin/foamClearPolyMesh @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -35,10 +35,14 @@ usage() { while [ "$#" -ge 1 ]; do echo "$1" 1>&2; shift; done cat <<USAGE 1>&2 -usage: ${0##*/} [-case dir] [-region name] +Usage: ${0##*/} [OPTION] +options: + -case <dir> specify alternative case directory, default is the cwd + -region <name> specify alternative mesh region + -help print the usage - Remove the contents of the constant/polyMesh directory - as per the Foam::polyMesh::removeFiles() method. +Remove the contents of the constant/polyMesh directory as per the +Foam::polyMesh::removeFiles() method. USAGE exit 1 diff --git a/bin/foamEtcFile b/bin/foamEtcFile index e3faab4121d1108195689c0d548240302a5510b4..851ef739b4000063645db2ce99c5131208daba5c 100755 --- a/bin/foamEtcFile +++ b/bin/foamEtcFile @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -40,7 +40,7 @@ usage() { while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat<<USAGE -usage: ${0##*/} [OPTION] fileName +Usage: ${0##*/} [OPTION] fileName ${0##*/} -list options: diff --git a/bin/foamExec b/bin/foamExec index 998bbd06439c3c59387f6ac9525dadf966774956..bbc12a53f6148af7bb7d0b2e5c4a47a1e8a07874 100755 --- a/bin/foamExec +++ b/bin/foamExec @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -41,7 +41,7 @@ usage() { while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat<<USAGE -usage: ${0##*/} [OPTION] <application> ... +Usage: ${0##*/} [OPTION] <application> ... options: -v ver specify OpenFOAM version diff --git a/bin/foamJob b/bin/foamJob index 289d430d83f29ef3c372e02d9595bf7ade6646f5..ca51fb6074ae9ea494ba67d9bdde34bd61533d33 100755 --- a/bin/foamJob +++ b/bin/foamJob @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -33,14 +33,13 @@ usage() { while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat<<USAGE -usage: ${0##*/} [OPTION] <application> ... - +Usage: ${0##*/} [OPTION] <application> ... options: - -case dir specify case directory - -s also sends output to screen - -p parallel run of processors - -v ver specify OpenFOAM version - -help this usage + -case <dir> specify alternative case directory, default is the cwd + -s also sends output to screen + -p parallel run of processors + -v <ver> specify OpenFOAM version + -help print the usage * run an OpenFOAM job in background. Redirects the output to 'log' in the case directory diff --git a/bin/foamNew b/bin/foamNew index d1b31693b9f40e55166691202608eaa7d01b4a5c..fde1aa1979aab6445f1b65f71d51d3415fb70d27 100755 --- a/bin/foamNew +++ b/bin/foamNew @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -33,7 +33,7 @@ usage() { while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat<<USAGE -usage: ${0##*/} <type> {args} +Usage: ${0##*/} <type> {args} * create a new standard OpenFOAM source or template file diff --git a/bin/foamUpdateCaseFileHeader b/bin/foamUpdateCaseFileHeader index cfe611ac811732c2034d4cf1b6a9470b4767ea11..f72035b13403663e179234eb94f38c163881b765 100755 --- a/bin/foamUpdateCaseFileHeader +++ b/bin/foamUpdateCaseFileHeader @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------ # License @@ -38,7 +38,7 @@ foamVersion=$WM_PROJECT_VERSION usage() { cat<<USAGE -usage: ${0##*/} [OPTION] <file1> ... <fileN> +Usage: ${0##*/} [OPTION] <file1> ... <fileN> options: -v VER specifies the version to be written in the header diff --git a/bin/foamUpgradeTurbulenceProperties b/bin/foamUpgradeTurbulenceProperties index 846d8d6cda580f7443517f3e4cde1d7c57b35ea4..517aada23a6eaaa5da27c742f16d5f346f52e260 100755 --- a/bin/foamUpgradeTurbulenceProperties +++ b/bin/foamUpgradeTurbulenceProperties @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------ # License @@ -39,7 +39,7 @@ usage() { cat<<USAGE -usage: ${0##*/} <turbulenceProperties> +Usage: ${0##*/} <turbulenceProperties> Where <turbulenceProperties> is the full path to the turbulenceProperties dictionary diff --git a/bin/paraFoam b/bin/paraFoam index 79bf6506d442845c8350f1f3e12228fe9f11e9b7..623030e16772342a1dc5b607c6facc11c68962bf 100755 --- a/bin/paraFoam +++ b/bin/paraFoam @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -30,18 +30,21 @@ # start paraview with the OpenFOAM libraries # # Note -# combining -block and -region options yields undefined behaviour +# combining -block or -builtin options with the -region option yields +# undefined behaviour #------------------------------------------------------------------------------ usage() { while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat<<USAGE -usage: ${0##*/} [OPTION] +Usage: ${0##*/} [OPTION] options: - -case dir specify alternative case directory - -region name specify mesh region name - -block use blockMesh reader (and .blockMesh file) - -touch only create the .OpenFOAM file + -block use blockMesh reader (uses .blockMesh extension) + -builtin use VTK builtin OpenFOAM reader (uses .foam extension) + -case <dir> specify alternative case directory, default is the cwd + -region <name> specify alternative mesh region + -touch only create the file (eg, .blockMesh, .OpenFOAM, etc) + -help print the usage * start paraview $ParaView_VERSION with the OpenFOAM libraries @@ -52,7 +55,7 @@ USAGE unset regionName touchOnly # reader extension -reader=OpenFOAM +extension=OpenFOAM # parse options while [ "$#" -gt 0 ] @@ -62,7 +65,11 @@ do usage ;; -block | -blockMesh) - reader=blockMesh + extension=blockMesh + shift + ;; + -builtin) + extension=foam shift ;; -case) @@ -87,12 +94,12 @@ done # get a sensible caseName from the directory name caseName=${PWD##*/} -caseFile="$caseName.$reader" +caseFile="$caseName.$extension" fvControls="system" if [ -n "$regionName" ] then - caseFile="$caseName{$regionName}.$reader" + caseFile="$caseName{$regionName}.$extension" fvControls="$fvControls/$regionName" fi @@ -113,7 +120,7 @@ esac # # check existence of essential files # -case $reader in +case $extension in blockMesh) for check in system/controlDict constant/polyMesh/blockMeshDict do @@ -121,7 +128,7 @@ blockMesh) done ;; -OpenFOAM) +builtin | OpenFOAM) for check in system/controlDict $fvControls/fvSchemes $fvControls/fvSolution do [ -s "$parentDir/$check" ] || usage "file does not exist: '$parentDir/$check'" diff --git a/bin/rmdepall b/bin/rmdepall index 5850692d22141219a32002b902e6bd2ff1d7ba20..f70b76adff3cdd49aa153d41dabe85a0fb9388d4 100755 --- a/bin/rmdepall +++ b/bin/rmdepall @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -32,7 +32,7 @@ usage() { while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat<<USAGE 1>&2 -usage: ${0##*/} [file] +Usage: ${0##*/} [file] Remove all .dep files or remove .dep files referring to <file> diff --git a/bin/templates/foamScript b/bin/templates/foamScript index e8a160860c298189fb416e8ccdd8cacdedadd5ca..a7fe5865128e9ba1ebed027c7eb87bfa7eeabd58 100644 --- a/bin/templates/foamScript +++ b/bin/templates/foamScript @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------ # License diff --git a/bin/templates/source/_Template.C b/bin/templates/source/_Template.C index a45d3ff6ac42f26f8238619393703ef088a0cc4a..5431e02d99916998734c3add309877396830a341 100644 --- a/bin/templates/source/_Template.C +++ b/bin/templates/source/_Template.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/bin/templates/source/_Template.H b/bin/templates/source/_Template.H index b86edcbde916e0eafd4b6b9b7d426215ae9bd391..1c04fa543d536a9c2223f3e7620df7a7a78fb9b6 100644 --- a/bin/templates/source/_Template.H +++ b/bin/templates/source/_Template.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/bin/templates/source/_TemplateApp.C b/bin/templates/source/_TemplateApp.C index 42f2df0db8ea3c8a43b3b9afd151aad9af9218ed..50cd2827abbc4e6de59b67cc1ec062dd86eb2f23 100644 --- a/bin/templates/source/_TemplateApp.C +++ b/bin/templates/source/_TemplateApp.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/bin/templates/source/_TemplateI.H b/bin/templates/source/_TemplateI.H index 10e8e4fec8ff30bc0e113d06c5081a217cfb6944..cfc30ed48ab3db4f0f75bf38e0b4ffb937700196 100644 --- a/bin/templates/source/_TemplateI.H +++ b/bin/templates/source/_TemplateI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/bin/templates/source/_TemplateIO.C b/bin/templates/source/_TemplateIO.C index c6d595100a2460dcfca112cf0c214ecb7faed950..8282a55f495aba38c8554742521af9b598bf2286 100644 --- a/bin/templates/source/_TemplateIO.C +++ b/bin/templates/source/_TemplateIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/bin/templates/source/foamNewSource b/bin/templates/source/foamNewSource index ec1ad7b2e1bbc37c8bfdb9714918da4b783b667d..8924b09448226eee99be2b3df38cfba366d859b5 100755 --- a/bin/templates/source/foamNewSource +++ b/bin/templates/source/foamNewSource @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -36,7 +36,7 @@ Template="$WM_PROJECT_DIR/bin/templates/source/_Template" usage() { while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat<<USAGE -usage: $Script <type> <class name> +Usage: $Script <type> <class name> * create a new standard OpenFOAM source file diff --git a/bin/templates/sourceTemplate/_TemplateTemplate.C b/bin/templates/sourceTemplate/_TemplateTemplate.C index c73d5043a125f5f29afbdd95015be50ac93e2552..21ce4f1b368f8e586d1098be3236473559747209 100644 --- a/bin/templates/sourceTemplate/_TemplateTemplate.C +++ b/bin/templates/sourceTemplate/_TemplateTemplate.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/bin/templates/sourceTemplate/_TemplateTemplate.H b/bin/templates/sourceTemplate/_TemplateTemplate.H index 6e24ddda2a6badd20ad9c4ebbcaf54c45147dcee..6ee6474936160eaf9af4215abcdf2993448db16c 100644 --- a/bin/templates/sourceTemplate/_TemplateTemplate.H +++ b/bin/templates/sourceTemplate/_TemplateTemplate.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/bin/templates/sourceTemplate/_TemplateTemplateI.H b/bin/templates/sourceTemplate/_TemplateTemplateI.H index 10e8e4fec8ff30bc0e113d06c5081a217cfb6944..cfc30ed48ab3db4f0f75bf38e0b4ffb937700196 100644 --- a/bin/templates/sourceTemplate/_TemplateTemplateI.H +++ b/bin/templates/sourceTemplate/_TemplateTemplateI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/bin/templates/sourceTemplate/_TemplateTemplateIO.C b/bin/templates/sourceTemplate/_TemplateTemplateIO.C index 9453630b686216647ab7035df15bb36dcc0144fa..d874b9117000af05c8cd0be7b5a7c4d94f5b18a8 100644 --- a/bin/templates/sourceTemplate/_TemplateTemplateIO.C +++ b/bin/templates/sourceTemplate/_TemplateTemplateIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/bin/templates/sourceTemplate/foamNewTemplate b/bin/templates/sourceTemplate/foamNewTemplate index edf4fd3bce7ea59b753081d0ad0e42678f4af257..8045a5cac67b2d25c9681f297b31896d8cc20a43 100755 --- a/bin/templates/sourceTemplate/foamNewTemplate +++ b/bin/templates/sourceTemplate/foamNewTemplate @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -37,7 +37,7 @@ usage() { while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat<<USAGE -usage: $Script <type> <Class name> <Template arguments...> +Usage: $Script <type> <Class name> <Template arguments...> * create a new standard OpenFOAM source file diff --git a/bin/tools/org-batch b/bin/tools/org-batch index 809552b54f7370333f92c2a779dfed254bbc731d..02682ee6f9c7e43555f2e44b4d0246652f44c905 100755 --- a/bin/tools/org-batch +++ b/bin/tools/org-batch @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -36,7 +36,7 @@ usage() { while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat<<USAGE -usage: ${0##*/} [OPTIONS] file1 [.. fileN] +Usage: ${0##*/} [OPTIONS] file1 [.. fileN] options: -html create html (default) -latex create LaTeX diff --git a/etc/apps/paraview3/bashrc b/etc/apps/paraview3/bashrc index bbeb6c0ebdad592e39ca3d8b4bbc413b50f2bd71..60b40255d2f18f41a10f9ebd122ec2235c177d84 100644 --- a/etc/apps/paraview3/bashrc +++ b/etc/apps/paraview3/bashrc @@ -2,7 +2,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------ # License @@ -46,9 +46,12 @@ do fi done -# set MAJOR and VERSION variables if not already set -[ -z "$ParaView_MAJOR" ] && export ParaView_MAJOR=paraview-3.6 + +# set VERSION and MAJOR (version) variables if not already set +# the major version is "<digits>.<digits>" [ -z "$ParaView_VERSION" ] && export ParaView_VERSION=3.6.1 +[ -z "$ParaView_MAJOR" ] && export ParaView_MAJOR=3.6 + export ParaView_INST_DIR=$WM_THIRD_PARTY_DIR/paraview-$ParaView_VERSION export ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER @@ -59,9 +62,9 @@ if [ -r $ParaView_PYTHON_DIR ] then if [ "$PYTHONPATH" ] then - export PYTHONPATH=$PYTHONPATH:$ParaView_PYTHON_DIR:$ParaView_DIR/lib/$ParaView_MAJOR + export PYTHONPATH=$PYTHONPATH:$ParaView_PYTHON_DIR:$ParaView_DIR/lib/paraview-$ParaView_MAJOR else - export PYTHONPATH=$ParaView_PYTHON_DIR:$ParaView_DIR/lib/$ParaView_MAJOR + export PYTHONPATH=$ParaView_PYTHON_DIR:$ParaView_DIR/lib/paraview-$ParaView_MAJOR fi fi diff --git a/etc/apps/paraview3/cshrc b/etc/apps/paraview3/cshrc index fdd1e819cf4eca530cf694c839f94a686637a034..d22f25012dd6c54e400683dc4b6f48aa066a444d 100644 --- a/etc/apps/paraview3/cshrc +++ b/etc/apps/paraview3/cshrc @@ -2,7 +2,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------ # License @@ -44,8 +44,10 @@ foreach cmake ( cmake-2.6.4 cmake-2.6.2 cmake-2.4.6 ) endif end -if ( ! $?ParaView_MAJOR ) setenv ParaView_MAJOR paraview-3.6 +# set VERSION and MAJOR (version) variables if not already set +# the major version is "<digits>.<digits>" if ( ! $?ParaView_VERSION ) setenv ParaView_VERSION 3.6.1 +if ( ! $?ParaView_MAJOR ) setenv ParaView_MAJOR 3.6 setenv ParaView_INST_DIR $WM_THIRD_PARTY_DIR/paraview-$ParaView_VERSION setenv ParaView_DIR $ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER @@ -54,9 +56,9 @@ setenv ParaView_DIR $ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER set paraviewPython=$ParaView_DIR/Utilities/VTKPythonWrapping if ( -r $paraviewPython ) then if ($?PYTHONPATH) then - setenv PYTHONPATH ${PYTHONPATH}:${paraviewPython}:$ParaView_DIR/lib/${ParaView_MAJOR} + setenv PYTHONPATH ${PYTHONPATH}:${paraviewPython}:$ParaView_DIR/lib/paraview-${ParaView_MAJOR} else - setenv PYTHONPATH ${paraviewPython}:$ParaView_DIR/lib/${ParaView_MAJOR} + setenv PYTHONPATH ${paraviewPython}:$ParaView_DIR/lib/paraview-${ParaView_MAJOR} endif endif diff --git a/etc/settings.csh b/etc/settings.csh index 6628473269fae2c5e969698e89584c46661c4acc..d285e07ca29d5b6603f0188b0c8e13de5b19b9e6 100644 --- a/etc/settings.csh +++ b/etc/settings.csh @@ -87,11 +87,11 @@ switch ("$compilerInstall") case OpenFOAM: switch ("$WM_COMPILER") case Gcc: - setenv WM_COMPILER_DIR $WM_THIRD_PARTY_DIR/gcc-4.4.2/platforms/$WM_ARCH$WM_COMPILER_ARCH - _foamAddLib $WM_THIRD_PARTY_DIR/mpfr-2.4.1/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib - _foamAddLib $WM_THIRD_PARTY_DIR/gmp-4.2.4/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib + setenv WM_COMPILER_DIR $WM_THIRD_PARTY_DIR/gcc-4.4.3/platforms/$WM_ARCH$WM_COMPILER_ARCH + _foamAddLib $WM_THIRD_PARTY_DIR/mpfr-2.4.2/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib + _foamAddLib $WM_THIRD_PARTY_DIR/gmp-5.0.1/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib breaksw - case Gcc44: + case Gcc442: setenv WM_COMPILER_DIR $WM_THIRD_PARTY_DIR/gcc-4.4.2/platforms/$WM_ARCH$WM_COMPILER_ARCH _foamAddLib $WM_THIRD_PARTY_DIR/mpfr-2.4.1/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib _foamAddLib $WM_THIRD_PARTY_DIR/gmp-4.2.4/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib @@ -132,7 +132,7 @@ unset MPI_ARCH_PATH switch ("$WM_MPLIB") case OPENMPI: - set mpi_version=openmpi-1.4 + set mpi_version=openmpi-1.4.1 setenv MPI_HOME $WM_THIRD_PARTY_DIR/$mpi_version setenv MPI_ARCH_PATH $MPI_HOME/platforms/$WM_OPTIONS diff --git a/etc/settings.sh b/etc/settings.sh index 8b3cebe42e9c1965a8bcf6f4ec1adba91391de6f..bb0d48df0e4160bc0311bd5433efa15a883b8eeb 100644 --- a/etc/settings.sh +++ b/etc/settings.sh @@ -111,6 +111,11 @@ case "${compilerInstall:-OpenFOAM}" in OpenFOAM) case "$WM_COMPILER" in Gcc) + export WM_COMPILER_DIR=$WM_THIRD_PARTY_DIR/gcc-4.4.3/platforms/$WM_ARCH$WM_COMPILER_ARCH + _foamAddLib $WM_THIRD_PARTY_DIR/mpfr-2.4.2/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib + _foamAddLib $WM_THIRD_PARTY_DIR/gmp-5.0.1/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib + ;; + Gcc442) export WM_COMPILER_DIR=$WM_THIRD_PARTY_DIR/gcc-4.4.2/platforms/$WM_ARCH$WM_COMPILER_ARCH _foamAddLib $WM_THIRD_PARTY_DIR/mpfr-2.4.1/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib _foamAddLib $WM_THIRD_PARTY_DIR/gmp-4.2.4/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib @@ -163,7 +168,7 @@ unset MPI_ARCH_PATH case "$WM_MPLIB" in OPENMPI) - mpi_version=openmpi-1.4 + mpi_version=openmpi-1.4.1 export MPI_HOME=$WM_THIRD_PARTY_DIR/$mpi_version export MPI_ARCH_PATH=$MPI_HOME/platforms/$WM_OPTIONS diff --git a/src/Allwmake b/src/Allwmake index a91f131e55a3c559d30749c4bca7ac4bf2e55a87..f24f2f370d518127542e64f15adbb35b8311c7f7 100755 --- a/src/Allwmake +++ b/src/Allwmake @@ -22,6 +22,7 @@ wmake libso OpenFOAM wmake libso lagrangian/basic +wmake libso fileFormats wmake libso edgeMesh wmake libso surfMesh wmake libso triSurface diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 9c18e7255554a2f30fdde1980d8b2b24cff66dbe..d8634de6dfdc75f0852cab846fd032ff45c8da8b 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -142,6 +142,12 @@ $(functionEntries)/includeIfPresentEntry/includeIfPresentEntry.C $(functionEntries)/inputModeEntry/inputModeEntry.C $(functionEntries)/removeEntry/removeEntry.C +calcEntry = $(functionEntries)/calcEntry +$(calcEntry)/calcEntryParser.atg +$(calcEntry)/calcEntryInternal.C +$(calcEntry)/calcEntry.C + + IOdictionary = db/IOobjects/IOdictionary $(IOdictionary)/IOdictionary.C $(IOdictionary)/IOdictionaryIO.C diff --git a/src/OpenFOAM/Make/options b/src/OpenFOAM/Make/options index 4eba86ae56d914aed88f7c06eb8d50c24b6f492b..b1cc1a2d10a16d24ecee7fd9ac347019fa4ed786 100644 --- a/src/OpenFOAM/Make/options +++ b/src/OpenFOAM/Make/options @@ -1,4 +1,4 @@ -EXE_INC = +EXE_INC = -I$(OBJECTS_DIR) LIB_LIBS = \ $(FOAM_LIBBIN)/libOSspecific.o \ diff --git a/applications/test/dictionary/calcEntry/calcEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntry.C similarity index 87% rename from applications/test/dictionary/calcEntry/calcEntry.C rename to src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntry.C index 98108123083a6d58dc8f2a5d6f664b783ec77225..0f0bfbbdc84bf333bc1ca3a5f92db1c8401003d4 100644 --- a/applications/test/dictionary/calcEntry/calcEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntry.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -68,17 +68,23 @@ bool Foam::functionEntries::calcEntry::execute myErrorHandler("calcEntryInternal::Parser"); calcEntryInternal::Scanner scanner(iss); + + // set the starting line + scanner.Line(is.lineNumber()); + calcEntryInternal::Parser parser(&scanner, &myErrorHandler); // Attach dictionary context parser.dict(parentDict); - // Attach scalar functions - // parser.functions(parentDict); - parser.Parse(); - // make a small input list to contain the answer + // mostly have an extra newline in the lookahead token + // so subtract 1 to keep things vaguely in sync + // (this is still far from perfect) + is.lineNumber() = scanner.Line() - 1; + + // a small input list to contain the answer tokenList tokens(2); tokens[0] = parser.Result(); tokens[1] = token::END_STATEMENT; diff --git a/applications/test/dictionary/calcEntry/calcEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntry.H similarity index 97% rename from applications/test/dictionary/calcEntry/calcEntry.H rename to src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntry.H index 027c4b510b74258ade09325a34b4d70601e47c02..d7014743cf7bb9371f50cf106954ce4ff392d351 100644 --- a/applications/test/dictionary/calcEntry/calcEntry.H +++ b/src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntry.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -77,7 +77,6 @@ public: primitiveEntry& entry, Istream& is ); - }; diff --git a/src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntryInternal.C b/src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntryInternal.C new file mode 100644 index 0000000000000000000000000000000000000000..086238d9a3b5665f23bdae47d6ec7672c946d41c --- /dev/null +++ b/src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntryInternal.C @@ -0,0 +1,129 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "calcEntryInternal.H" +#include "addToGlobalFunctionSelectionTable.H" +#include "unitConversion.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionEntries +{ +namespace calcEntryInternal +{ + +defineGlobalFunctionSelectionTable(dispatch,ParamList); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#define globalConstant0(Name, Constant)\ +scalar Name##_0(const UList<scalar>& param) \ +{ \ + return Constant; \ +} \ +addNamedToGlobalFunctionSelectionTable(dispatch,ParamList,Name##_0,&Name##_0) + + +#define globalFunction0(Name, Function)\ +scalar Name##_0(const UList<scalar>& param) \ +{ \ + return Function(); \ +} \ +addNamedToGlobalFunctionSelectionTable(dispatch,ParamList,Name##_0,&Name##_0) + + +#define globalFunction1(Name, Function)\ +scalar Name##_1(const UList<scalar>& param) \ +{ \ + return Function(param[0]); \ +} \ +addNamedToGlobalFunctionSelectionTable(dispatch,ParamList,Name##_1,&Name##_1) + + +#define globalFunction2(Name, Function)\ +scalar Name##_2(const UList<scalar>& param) \ +{ \ + return Function(param[0], param[1]); \ +} \ +addNamedToGlobalFunctionSelectionTable(dispatch,ParamList,Name##_2,&Name##_2) + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +globalConstant0(pi, constant::mathematical::pi); + +globalFunction1(degToRad, degToRad); +globalFunction1(radToDeg, radToDeg); +globalFunction1(asin, Foam::asin); +globalFunction1(acos, Foam::acos); +globalFunction1(atan, Foam::atan); +globalFunction1(sin, Foam::sin); +globalFunction1(cos, Foam::cos); +globalFunction1(tan, Foam::tan); +globalFunction1(log, Foam::log); +globalFunction1(log10, Foam::log10); +globalFunction1(mag, Foam::mag); + +globalFunction2(atan2, Foam::atan2); +globalFunction2(pow, Foam::pow); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +scalar dispatch(const word& name, const UList<scalar>& param) +{ + // create lookup name with parameter count + const word lookupName = name + '_' + Foam::name(param.size()); + + dispatchParamListMemberFunctionTable::iterator mfIter = + dispatchParamListMemberFunctionTablePtr_->find(lookupName); + + if (mfIter == dispatchParamListMemberFunctionTablePtr_->end()) + { + FatalErrorIn + ( + "calcEntryInternal::scalarFunctions::dispatch" + "(const word&, const UList<scalar>&) : " + ) << "Unknown function " << name << nl << nl + << "Valid types are :" << endl + << dispatchParamListMemberFunctionTablePtr_->sortedToc() + << exit(FatalError); + } + + return mfIter()(param); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace calcEntryInternal +} // End namespace functionEntries +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntryInternal.H b/src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntryInternal.H new file mode 100644 index 0000000000000000000000000000000000000000..2dd3a0305682064df767e60ac6929f4e31844110 --- /dev/null +++ b/src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntryInternal.H @@ -0,0 +1,81 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Namespace + Foam::functionEntries::calcEntryInternal + +Description + Contains global functions and classes for the calcEntry. + +SourceFiles + calcEntryInternal.C + +\*---------------------------------------------------------------------------*/ + +#ifndef calcEntryInternal_H +#define calcEntryInternal_H + +#include "error.H" +#include "scalar.H" +#include "DynamicList.H" +#include "globalFunctionSelectionTables.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionEntries +{ +namespace calcEntryInternal +{ + + // Global Function Selectors + + declareGlobalFunctionSelectionTable + ( + scalar, + dispatch, + ParamList, + ( + const UList<scalar>& param + ), + (param) + ); + + + //- Dispatch calculation to the named function + scalar dispatch(const word&, const UList<scalar>&); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace calcEntryInternal +} // End namespace functionEntries +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntryParser.atg b/src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntryParser.atg new file mode 100644 index 0000000000000000000000000000000000000000..755f539d98398a20060c0625de835882096cb3ae --- /dev/null +++ b/src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntryParser.atg @@ -0,0 +1,258 @@ +/*---------------------------------------------------------------------------*\ + Attributed Grammar for Coco/R (-*- C++ -*- version) + compile with: + coco-cpp calcEntryParser.atg +\*---------------------------------------------------------------------------*/ +[copy] +/*---------------------------------*- C++ -*---------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +@file calcEntryParser.atg + +Description + An attributed Coco/R grammar to parse simple arithmetic expressions + + Includes support for dictionary $variables and some scalar functions + (eg, sin, pow, ...) + +SourceFiles + generated + +\*---------------------------------------------------------------------------*/ +[/copy] +#include "dictionary.H" +#include "wchar.H" +#include "calcEntryInternal.H" + + +COMPILER calcEntry + // grammar pragmas: + $prefix=calcEntry + $namespace=Foam::functionEntries::calcEntryInternal + $define=EXPLICIT_EOF // grammar handles eof itself + $define=STREAMS_ONLY // only use STL streams + $define=NO_UTF8 // disable UTF8 on input + +private: + //- The parent dictionary + dictionary* dict_; + + //- The calculation result + scalar val; + + //- lookup dictionary entry + scalar getDictLookup(const word&) const; + +public: + + //- attach a dictionary + void dict(const dictionary& dict) + { + dict_ = const_cast<dictionary*>(&dict); + } + + //- Return the calculated result + scalar Result() const + { + return val; + } + + +/*---------------------------------------------------------------------------*/ + +[initialize] // add to Parser constructor + dict_ = 0; + val = 0; +[/initialize] + +/*---------------------------------------------------------------------------*/ +[code] +Foam::scalar Parser::getDictLookup(const word& keyword) const +{ + if (!dict_) + { + FatalErrorIn + ( + "calcEntry::getDictEntry(const word&) const" + ) << "No dictionary attached!" + << exit(FatalError); + + return 0; + } + + scalar dictValue = 0; + + entry* entryPtr = dict_->lookupEntryPtr(keyword, true, false); + if (entryPtr && !entryPtr->isDict()) + { + if (entryPtr->stream().size() != 1) + { + FatalErrorIn + ( + "calcEntry::getDictEntry(const word&) const" + ) << "keyword " << keyword << " has " + << entryPtr->stream().size() << " values in dictionary " + << exit(FatalError); + } + entryPtr->stream() >> dictValue; + } + else + { + FatalErrorIn + ( + "calcEntry::getDictEntry(const word&) const" + ) << "keyword " << keyword << " is undefined in dictionary " + << exit(FatalError); + } + + return dictValue; +} +[/code] + +/*---------------------------------------------------------------------------*/ + +CHARACTERS + letter = 'A'..'Z' + 'a'..'z' + '_'. + digit = "0123456789". + alphanum = letter + digit. + sign = '+' + '-'. + cr = '\r'. + lf = '\n'. + tab = '\t'. + stringCh = ANY - '"' - '\\' - cr - lf. + printable = '\u0020' .. '\u007e'. + + +// * * * * * * * * * * * * * * * * TOKENS * * * * * * * * * * * * * * * * * // + +TOKENS + +// identifier +ident = + letter { alphanum }. + +// string +string = + '"' { stringCh | '\\' printable } '"'. + +// dictionary lookup identifier +// starts with '$' and otherwise limited to a normal identifier +variable = + '$' letter { alphanum }. + +// floating point and integer numbers +number = + [sign] ('.' digit { digit } ) | ( digit { digit } [ '.' { digit } ]) + [ ('E' | 'e') [sign] digit { digit } ]. + + +// * * * * * * * * * * * PRAGMAS / COMMENTS / IGNORE * * * * * * * * * * * // + +COMMENTS FROM "/*" TO "*/" NESTED +COMMENTS FROM "//" TO lf + +IGNORE cr + lf + tab + + +// * * * * * * * * * * * * * * * PRODUCTIONS * * * * * * * * * * * * * * * // + +PRODUCTIONS + +calcEntry (. val = 0; .) += + '{' Expr<val> '}' (. // reposition to immediately after the closing '}' + scanner->buffer->SetPos(t->pos + 1); + .) + | ( Expr<val> EOF ) +. + + +/*---------------------------------------------------------------------------*/ + +Expr<scalar& val> (. scalar val2 = 0; .) += + Term<val> + { + '+' Term<val2> (. val += val2; .) + | '-' Term<val2> (. val -= val2; .) + } +. + + +/*---------------------------------------------------------------------------*/ + +Term<scalar& val> (. scalar val2 = 0; .) += + Factor<val> + { + '*' Factor<val2> (. val *= val2; .) + | '/' Factor<val2> (. val /= val2; .) + } +. + + +/*---------------------------------------------------------------------------*/ + +// Note the treatment of the leading signs is fairly generous +// eg, "10 + - 10" is treated like "10 + -10" +// +Factor<scalar& val> (. bool negative = false; .) += + ['+' | '-' (. negative = true; .) + ] + ( + Func<val> | '(' Expr<val> ')' + | variable (. + // skip leading '$' for the keyword + val = getDictLookup(t->toString(1, t->length()-1)); + .) + | number (. val = coco_string_toDouble(t->val); .) + ) (. if (negative) { val = -val; } .) +. + + +/*---------------------------------------------------------------------------*/ + +// functions like sin(x) or pow(x, y) etc. +Func<scalar& val> += + ident (. + word funcName(t->toString()); + DynamicList<scalar> stack(4); + .) + '(' + [ (. scalar x; .) + Expr<x> (. stack.append(x); .) + { ',' Expr<x> (. stack.append(x); .) + } + ] + ')' (. val = dispatch(funcName, stack); .) +. + + +/*---------------------------------------------------------------------------*/ + +END calcEntry. + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/error/CocoParserErrors.H b/src/OpenFOAM/db/error/CocoParserErrors.H index 21f574592dbec36011d24f18eb8b6aad1e33555d..97d503204f1b38ccf5abfaffb4990a5eb4af4621 100644 --- a/src/OpenFOAM/db/error/CocoParserErrors.H +++ b/src/OpenFOAM/db/error/CocoParserErrors.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -45,7 +45,7 @@ namespace Foam Class CocoParserErrors Declaration \*---------------------------------------------------------------------------*/ -template<class BaseClass> +template<class BaseClass, class StringClass=std::wstring> class CocoParserErrors : public BaseClass @@ -90,14 +90,14 @@ public: // Error Handling //- Handle a general warning 'msg' - virtual void Warning(const wchar_t* msg) + virtual void Warning(const StringClass& msg) { WarningIn(name_) << msg << endl; } //- Handle a general warning 'msg' - virtual void Warning(int line, int col, const wchar_t* msg) + virtual void Warning(int line, int col, const StringClass& msg) { WarningIn(name_) <<"line " << line << " col " << col << ": " @@ -105,7 +105,7 @@ public: } //- Handle general error 'msg' (eg, a semantic error) - virtual void Error(int line, int col, const wchar_t* msg) + virtual void Error(int line, int col, const StringClass& msg) { FatalErrorIn(name_) << "line " << line << " col " << col <<": " << msg << endl @@ -113,7 +113,7 @@ public: } //- Handle general error 'msg' (eg, a semantic error) - virtual void Error(const wchar_t* msg) + virtual void Error(const StringClass& msg) { FatalErrorIn(name_) << msg << endl @@ -121,7 +121,7 @@ public: } //- Handle a general exception 'msg' - virtual void Exception(const wchar_t* msg) + virtual void Exception(const StringClass& msg) { this->Error(msg); } diff --git a/src/OpenFOAM/db/runTimeSelection/addToRunTimeSelectionTable.H b/src/OpenFOAM/db/runTimeSelection/construction/addToRunTimeSelectionTable.H similarity index 100% rename from src/OpenFOAM/db/runTimeSelection/addToRunTimeSelectionTable.H rename to src/OpenFOAM/db/runTimeSelection/construction/addToRunTimeSelectionTable.H diff --git a/src/OpenFOAM/db/runTimeSelection/runTimeSelectionTables.H b/src/OpenFOAM/db/runTimeSelection/construction/runTimeSelectionTables.H similarity index 100% rename from src/OpenFOAM/db/runTimeSelection/runTimeSelectionTables.H rename to src/OpenFOAM/db/runTimeSelection/construction/runTimeSelectionTables.H diff --git a/src/OpenFOAM/db/runTimeSelection/globalFunctions/addToGlobalFunctionSelectionTable.H b/src/OpenFOAM/db/runTimeSelection/globalFunctions/addToGlobalFunctionSelectionTable.H new file mode 100644 index 0000000000000000000000000000000000000000..d6eadfdd74c0e2541d3b79130e9b840bb057a931 --- /dev/null +++ b/src/OpenFOAM/db/runTimeSelection/globalFunctions/addToGlobalFunctionSelectionTable.H @@ -0,0 +1,53 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +@file Foam::addToGlobalFunctionSelectionTable + +Description + Macros for easy insertion into global function selection tables + +\*---------------------------------------------------------------------------*/ + +#ifndef addToGlobalFunctionSelectionTable_H +#define addToGlobalFunctionSelectionTable_H + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +// add to hash-table of functions with 'lookup' as the key +#define addNamedToGlobalFunctionSelectionTable\ +(memberFunction,argNames,lookup,functionPtr) \ + \ + /* Add to the table, find by lookup name */ \ + add##memberFunction##argNames##GlobalMemberFunctionToTable \ + add_##lookup##_##memberFunction##argNames##GlobalMemberFunctionTo##Table_\ + (#lookup, functionPtr) + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/runTimeSelection/globalFunctions/globalFunctionSelectionTables.H b/src/OpenFOAM/db/runTimeSelection/globalFunctions/globalFunctionSelectionTables.H new file mode 100644 index 0000000000000000000000000000000000000000..4a7dfb4ac4b5c8f27a5625ae40830eac9d5c2937 --- /dev/null +++ b/src/OpenFOAM/db/runTimeSelection/globalFunctions/globalFunctionSelectionTables.H @@ -0,0 +1,145 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +@file Foam::globalFunctionSelectionTables + +Description + Macros to enable the easy declaration of global function selection tables. + +\*---------------------------------------------------------------------------*/ + +#ifndef globalMemberFunctionSelectionTables_H +#define globalMemberFunctionSelectionTables_H + +#include "memberFunctionSelectionTables.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +// external use: +// ~~~~~~~~~~~~~ +// declare a run-time selection: +#define declareGlobalFunctionSelectionTable\ +(returnType,memberFunction,argNames,argList,parList) \ + \ + /* Construct from argList function pointer type */ \ + typedef returnType (*memberFunction##argNames##MemberFunctionPtr)argList; \ + \ + /* Construct from argList function table type */ \ + typedef HashTable \ + <memberFunction##argNames##MemberFunctionPtr, word, string::hash> \ + memberFunction##argNames##MemberFunctionTable; \ + \ + /* Construct from argList function pointer table pointer */ \ + extern memberFunction##argNames##MemberFunctionTable* \ + memberFunction##argNames##MemberFunctionTablePtr_; \ + \ + /* Table memberFunction called from the table add function */ \ + void construct##memberFunction##argNames##MemberFunctionTables(); \ + \ + /* Table destructor called from the table add function destructor */ \ + void destroy##memberFunction##argNames##MemberFunctionTables(); \ + \ + /* Class to add constructor from argList to table */ \ + class add##memberFunction##argNames##GlobalMemberFunctionToTable \ + { \ + public: \ + \ + add##memberFunction##argNames##GlobalMemberFunctionToTable \ + ( \ + const word& lookup, \ + memberFunction##argNames##MemberFunctionPtr function \ + ) \ + { \ + construct##memberFunction##argNames##MemberFunctionTables(); \ + memberFunction##argNames##MemberFunctionTablePtr_->insert \ + ( \ + lookup, \ + function \ + ); \ + } \ + \ + ~add##memberFunction##argNames##GlobalMemberFunctionToTable() \ + { \ + destroy##memberFunction##argNames##MemberFunctionTables(); \ + } \ + } + +// internal use: +// constructor/destructor aid +#define defineGlobalFunctionSelectionTableConstructDestruct\ +(memberFunction,argNames) \ + \ + /* Table constructor called from the table add function */ \ + void construct##memberFunction##argNames##MemberFunctionTables()\ + { \ + static bool constructed = false; \ + if (!constructed) \ + { \ + constructed = true; \ + memberFunction##argNames##MemberFunctionTablePtr_ \ + = new memberFunction##argNames##MemberFunctionTable; \ + } \ + } \ + \ + /* Table destructor called from the table add function destructor */ \ + void destroy##memberFunction##argNames##MemberFunctionTables()\ + { \ + if (memberFunction##argNames##MemberFunctionTablePtr_) \ + { \ + delete memberFunction##argNames##MemberFunctionTablePtr_; \ + memberFunction##argNames##MemberFunctionTablePtr_ = NULL; \ + } \ + } + + +// internal use: +// create pointer to hash-table of functions +#define defineGlobalFunctionSelectionTablePtr\ +(memberFunction,argNames) \ + \ + /* Define the memberFunction table */ \ + memberFunction##argNames##MemberFunctionTable* \ + memberFunction##argNames##MemberFunctionTablePtr_ = NULL + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// external use: +// ~~~~~~~~~~~~~ +// define run-time selection table +#define defineGlobalFunctionSelectionTable\ +(memberFunction,argNames) \ + \ + defineGlobalFunctionSelectionTablePtr \ + (memberFunction,argNames); \ + defineGlobalFunctionSelectionTableConstructDestruct \ + (memberFunction,argNames) + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/memberFunctionSelection/addToMemberFunctionSelectionTable.H b/src/OpenFOAM/db/runTimeSelection/memberFunctions/addToMemberFunctionSelectionTable.H similarity index 100% rename from src/OpenFOAM/db/memberFunctionSelection/addToMemberFunctionSelectionTable.H rename to src/OpenFOAM/db/runTimeSelection/memberFunctions/addToMemberFunctionSelectionTable.H diff --git a/src/OpenFOAM/db/memberFunctionSelection/memberFunctionSelectionTables.H b/src/OpenFOAM/db/runTimeSelection/memberFunctions/memberFunctionSelectionTables.H similarity index 100% rename from src/OpenFOAM/db/memberFunctionSelection/memberFunctionSelectionTables.H rename to src/OpenFOAM/db/runTimeSelection/memberFunctions/memberFunctionSelectionTables.H diff --git a/src/OpenFOAM/db/runTimeSelection/staticMemberFunctions/addToStaticMemberFunctionSelectionTable.H b/src/OpenFOAM/db/runTimeSelection/staticMemberFunctions/addToStaticMemberFunctionSelectionTable.H new file mode 100644 index 0000000000000000000000000000000000000000..572f93ae23e426310ba74a711604c63b7351bed9 --- /dev/null +++ b/src/OpenFOAM/db/runTimeSelection/staticMemberFunctions/addToStaticMemberFunctionSelectionTable.H @@ -0,0 +1,53 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +@file Foam::addToStaticMemberFunctionSelectionTable + +Description + Macros for easy insertion into member function selection tables + +\*---------------------------------------------------------------------------*/ + +#ifndef addToStaticMemberFunctionSelectionTable_H +#define addToStaticMemberFunctionSelectionTable_H + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +// add to hash-table of functions with 'lookup' as the key +#define addNamedToStaticMemberFunctionSelectionTable\ +(baseType,thisType,memberFunction,argNames,lookup,functionPtr) \ + \ + /* Add the thisType memberFunction to the table, find by lookup name */ \ + baseType::add##memberFunction##argNames##StaticMemberFunctionToTable<thisType> \ + add_##lookup##_##thisType##memberFunction##argNames##StaticMemberFunctionTo##baseType##Table_\ + (#lookup, functionPtr) + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/runTimeSelection/staticMemberFunctions/staticMemberFunctionSelectionTables.H b/src/OpenFOAM/db/runTimeSelection/staticMemberFunctions/staticMemberFunctionSelectionTables.H new file mode 100644 index 0000000000000000000000000000000000000000..3febd71e8a0684a0680ecbfe1a0cc9802afe606b --- /dev/null +++ b/src/OpenFOAM/db/runTimeSelection/staticMemberFunctions/staticMemberFunctionSelectionTables.H @@ -0,0 +1,147 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +@file Foam::staticMemberFunctionSelectionTables + +Description + Macros to enable the easy declaration of member function selection tables. + +\*---------------------------------------------------------------------------*/ + +#ifndef staticMemberFunctionSelectionTables_H +#define staticMemberFunctionSelectionTables_H + +#include "memberFunctionSelectionTables.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +// external use: +// ~~~~~~~~~~~~~ +// declare a run-time selection: +#define declareStaticMemberFunctionSelectionTable\ +(returnType,baseType,memberFunction,argNames,argList,parList) \ + \ + /* Construct from argList function pointer type */ \ + typedef returnType (*memberFunction##argNames##MemberFunctionPtr)argList; \ + \ + /* Construct from argList function table type */ \ + typedef HashTable \ + <memberFunction##argNames##MemberFunctionPtr, word, string::hash> \ + memberFunction##argNames##MemberFunctionTable; \ + \ + /* Construct from argList function pointer table pointer */ \ + static memberFunction##argNames##MemberFunctionTable* \ + memberFunction##argNames##MemberFunctionTablePtr_; \ + \ + /* Table memberFunction called from the table add function */ \ + static void construct##memberFunction##argNames##MemberFunctionTables(); \ + \ + /* Table destructor called from the table add function destructor */ \ + static void destroy##memberFunction##argNames##MemberFunctionTables(); \ + \ + /* Class to add constructor from argList to table */ \ + template<class baseType##Type> \ + class add##memberFunction##argNames##StaticMemberFunctionToTable \ + { \ + public: \ + \ + add##memberFunction##argNames##StaticMemberFunctionToTable \ + ( \ + const word& lookup, \ + memberFunction##argNames##MemberFunctionPtr function \ + ) \ + { \ + construct##memberFunction##argNames##MemberFunctionTables(); \ + memberFunction##argNames##MemberFunctionTablePtr_->insert \ + ( \ + lookup, \ + function \ + ); \ + } \ + \ + ~add##memberFunction##argNames##StaticMemberFunctionToTable() \ + { \ + destroy##memberFunction##argNames##MemberFunctionTables(); \ + } \ + } + + +// internal use: +// constructor/destructor aid +#define defineStaticMemberFunctionSelectionTableConstructDestruct\ +(baseType,memberFunction,argNames) \ + \ + /* Table constructor called from the table add function constructor */ \ + void baseType::construct##memberFunction##argNames##MemberFunctionTables()\ + { \ + static bool constructed = false; \ + if (!constructed) \ + { \ + constructed = true; \ + baseType::memberFunction##argNames##MemberFunctionTablePtr_ \ + = new baseType::memberFunction##argNames##MemberFunctionTable;\ + } \ + }; \ + \ + /* Table destructor called from the table add function destructor */ \ + void baseType::destroy##memberFunction##argNames##MemberFunctionTables() \ + { \ + if (baseType::memberFunction##argNames##MemberFunctionTablePtr_) \ + { \ + delete baseType::memberFunction##argNames##MemberFunctionTablePtr_;\ + baseType::memberFunction##argNames##MemberFunctionTablePtr_ = NULL;\ + } \ + } + + +// internal use: +// create pointer to hash-table of functions +#define defineStaticMemberFunctionSelectionTablePtr\ +(baseType,memberFunction,argNames) \ + \ + /* Define the memberFunction table */ \ + baseType::memberFunction##argNames##MemberFunctionTable* \ + baseType::memberFunction##argNames##MemberFunctionTablePtr_ = NULL + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// external use: +// ~~~~~~~~~~~~~ +// define run-time selection table +#define defineStaticMemberFunctionSelectionTable\ +(baseType,memberFunction,argNames) \ + \ + defineStaticMemberFunctionSelectionTablePtr \ + (baseType,memberFunction,argNames); \ + defineStaticMemberFunctionSelectionTableConstructDestruct \ + (baseType,memberFunction,argNames) \ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/memory/autoPtr/autoPtr.H b/src/OpenFOAM/memory/autoPtr/autoPtr.H index c90898d0555fa57275c3a7e7b8234a9d7d8a7c85..8d29cda66061db0d31e56142a0afa6fffd87e2ee 100644 --- a/src/OpenFOAM/memory/autoPtr/autoPtr.H +++ b/src/OpenFOAM/memory/autoPtr/autoPtr.H @@ -77,52 +77,53 @@ public: // Member Functions - // Check + // Check - //- Return true if the autoPtr is empty (ie, no pointer set). - inline bool empty() const; + //- Return true if the autoPtr is empty (ie, no pointer set). + inline bool empty() const; - //- Return true if the autoPtr valid (ie, the pointer is set). - inline bool valid() const; + //- Return true if the autoPtr valid (ie, the pointer is set). + inline bool valid() const; - // Edit + // Edit - //- Return object pointer for reuse - inline T* ptr(); + //- Return object pointer for reuse + inline T* ptr(); - //- Set pointer to that given. - // If object pointer already set issue a FatalError. - inline void set(T*); + //- Set pointer to that given. + // If object pointer already set issue a FatalError. + inline void set(T*); - //- If object pointer already set, delete object and set to given pointer - inline void reset(T* = 0); + //- If object pointer already set, delete object and set to given + // pointer + inline void reset(T* = 0); - //- Delete object and set pointer to NULL, if the pointer is valid. - inline void clear(); + //- Delete object and set pointer to NULL, if the pointer is valid. + inline void clear(); - // Member operators + // Member operators - //- Return reference to the object data - inline T& operator()(); + //- Return reference to the object data + inline T& operator()(); - //- Return const reference to the object data - inline const T& operator()() const; + //- Return const reference to the object data + inline const T& operator()() const; - // inline T& operator*(); - // inline const T& operator*() const; + // inline T& operator*(); + // inline const T& operator*() const; - inline operator const T&() const; + inline operator const T&() const; - //- Return object pointer - inline T* operator->(); + //- Return object pointer + inline T* operator->(); - //- Return const object pointer - inline const T* operator->() const; + //- Return const object pointer + inline const T* operator->() const; - //- Take over object pointer from parameter - inline void operator=(const autoPtr<T>&); + //- Take over object pointer from parameter + inline void operator=(const autoPtr<T>&); }; diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C index e97cada0f3170be84e3e4a51598fcf0114a582fa..f5afcad87280540775e19f7b0688a309bb8c2a98 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C @@ -703,6 +703,7 @@ void Foam::globalMeshData::calcPointBoundaryFaces } } + void Foam::globalMeshData::calcGlobalPointBoundaryFaces() const { if (debug) @@ -1743,14 +1744,6 @@ Foam::autoPtr<Foam::globalIndex> Foam::globalMeshData::mergePoints label myUniquePoints = meshPoints.size() - nCoupledSlave; - //Pout<< "Points :" << nl - // << " patch : " << meshPoints.size() << nl - // << " of which coupled : " << nCoupledMaster+nCoupledSlave << nl - // << " of which master : " << nCoupledMaster << nl - // << " of which slave : " << nCoupledSlave << nl - // << endl; - - // 2. Create global indexing for unique points. autoPtr<globalIndex> globalPointsPtr(new globalIndex(myUniquePoints)); diff --git a/src/OpenFOAM/meshes/primitiveShapes/plane/plane.C b/src/OpenFOAM/meshes/primitiveShapes/plane/plane.C index 6f711cc603eb9d613e2d5dcf645ea8f50f4761dc..4b4f4d4965be074f3222a7b04c0e0f507a8ea733 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/plane/plane.C +++ b/src/OpenFOAM/meshes/primitiveShapes/plane/plane.C @@ -137,7 +137,7 @@ Foam::plane::plane(const vector& normalVector) } else { - FatalErrorIn("plane::plane(const point&, const vector&)") + FatalErrorIn("plane::plane(const vector&)") << "plane normal has zero length" << abort(FatalError); } diff --git a/src/OpenFOAM/primitives/chars/wchar/wchar.H b/src/OpenFOAM/primitives/chars/wchar/wchar.H index c731a3dc8149154b127fe51d60c700b41f3f70ca..d4df7a61eaac704c77d8a39cc3e5ef465148f474 100644 --- a/src/OpenFOAM/primitives/chars/wchar/wchar.H +++ b/src/OpenFOAM/primitives/chars/wchar/wchar.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -31,12 +31,17 @@ Description SourceFiles wcharIO.C +SeeAlso + http://en.wikipedia.org/wiki/UTF-8 + http://en.wikibooks.org/wiki/Unicode/Character_reference + \*---------------------------------------------------------------------------*/ #ifndef wchar_H #define wchar_H #include <cwchar> +#include <string> // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -48,12 +53,15 @@ class Ostream; // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // -//- Output via a normal char +//- Output wide character (Unicode) as UTF-8 Ostream& operator<<(Ostream&, const wchar_t); -//- Output string via normal char +//- Output wide character (Unicode) string as UTF-8 Ostream& operator<<(Ostream&, const wchar_t*); +//- Output wide character (Unicode) string as UTF-8 +Ostream& operator<<(Ostream&, const std::wstring&); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/chars/wchar/wcharIO.C b/src/OpenFOAM/primitives/chars/wchar/wcharIO.C index 47a5ed056024b78a174ed6e35281fad1057106ec..37f81321efd0e5fa6112bfb8cf33b3a59713efd6 100644 --- a/src/OpenFOAM/primitives/chars/wchar/wcharIO.C +++ b/src/OpenFOAM/primitives/chars/wchar/wcharIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -22,11 +22,6 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Description - Reads a char from an input stream, for a given version - number and File format. If an ascii File is being read, then the line - numbers are counted and an erroneous read is reported. - \*---------------------------------------------------------------------------*/ #include "error.H" @@ -38,23 +33,100 @@ Description Foam::Ostream& Foam::operator<<(Ostream& os, const wchar_t wc) { - os.write(char(wc)); + if (!(wc & ~0x0000007F)) + { + // 0x00000000 - 0x0000007F: (1-byte output) + // 0xxxxxxx + os.write(char(wc)); + } + else if (!(wc & ~0x000007FF)) + { + // 0x00000080 - 0x000007FF: (2-byte output) + // 110bbbaa 10aaaaaa + os.write(char(0xC0 | ((wc >> 6) & 0x1F))); + os.write(char(0x80 | ((wc) & 0x3F))); + } + else if (!(wc & ~0x0000FFFF)) + { + // 0x00000800 - 0x0000FFFF: (3-byte output) + // 1110bbbb 10bbbbaa 10aaaaaa + os.write(char(0xE0 | ((wc >> 12) & 0x0F))); + os.write(char(0x80 | ((wc >> 6) & 0x3F))); + os.write(char(0x80 | ((wc) & 0x3F))); + } + else if (!(wc & ~0x001FFFFF)) + { + // 0x00010000 - 0x001FFFFF: (4-byte output) + // 11110ccc 10ccbbbb 10bbbbaa 10aaaaaa + os.write(char(0xF0 | ((wc >> 18) & 0x07))); + os.write(char(0x80 | ((wc >> 12) & 0x3F))); + os.write(char(0x80 | ((wc >> 6) & 0x3F))); + os.write(char(0x80 | ((wc) & 0x3F))); + } + else if (!(wc & ~0x03FFFFFF)) + { + // 0x00200000 - 0x03FFFFFF: (5-byte output) + // 111110dd 10cccccc 10ccbbbb 10bbbbaa 10aaaaaa + os.write(char(0xF8 | ((wc >> 24) & 0x03))); + os.write(char(0x80 | ((wc >> 18) & 0x3F))); + os.write(char(0x80 | ((wc >> 12) & 0x3F))); + os.write(char(0x80 | ((wc >> 6) & 0x3F))); + os.write(char(0x80 | ((wc) & 0x3F))); + } + else if (!(wc & ~0x7FFFFFFF)) + { + // 0x04000000 - 0x7FFFFFFF: (6-byte output) + // 1111110d 10dddddd 10cccccc 10ccbbbb 10bbbbaa 10aaaaaa + os.write(char(0xFC | ((wc >> 30) & 0x01))); + os.write(char(0x80 | ((wc >> 24) & 0x3F))); + os.write(char(0x80 | ((wc >> 18) & 0x3F))); + os.write(char(0x80 | ((wc >> 12) & 0x3F))); + os.write(char(0x80 | ((wc >> 6) & 0x3F))); + os.write(char(0x80 | ((wc) & 0x3F))); + } + else + { + // according to man page utf8(7) + // the Unicode standard specifies no characters above 0x0010FFFF, + // so Unicode characters can only be up to four bytes long in UTF-8. + + // report anything unknown/invalid as replacement character U+FFFD + os.write(char(0xEF)); + os.write(char(0xBF)); + os.write(char(0xBD)); + } os.check("Ostream& operator<<(Ostream&, const wchar_t)"); return os; } -Foam::Ostream& Foam::operator<<(Ostream& os, const wchar_t* ws) +Foam::Ostream& Foam::operator<<(Ostream& os, const wchar_t* wstr) { - if (ws) + if (wstr) { - for (const wchar_t* p = ws; *p; ++p) + for (const wchar_t* iter = wstr; *iter; ++iter) { - os.write(char(*p)); + os << *iter; } } - os.check("Ostream& operator<<(Ostream&, const wchar_t*)"); + + return os; +} + + +Foam::Ostream& Foam::operator<<(Ostream& os, const std::wstring& wstr) +{ + for + ( + std::wstring::const_iterator iter = wstr.begin(); + iter != wstr.end(); + ++iter + ) + { + os << *iter; + } + return os; } diff --git a/src/OpenFOAM/primitives/strings/string/stringI.H b/src/OpenFOAM/primitives/strings/string/stringI.H index c609351b9cf5dad482ac8817e68496e90061b9bd..1893351aadf752ce15a18dfdc1a10c54dadde773 100644 --- a/src/OpenFOAM/primitives/strings/string/stringI.H +++ b/src/OpenFOAM/primitives/strings/string/stringI.H @@ -64,7 +64,7 @@ inline Foam::string::string(const char c) template<class String> inline bool Foam::string::valid(const string& str) { - for (const_iterator iter = str.begin(); iter != str.end(); iter++) + for (const_iterator iter = str.begin(); iter != str.end(); ++iter) { if (!String::valid(*iter)) { @@ -113,7 +113,7 @@ template<class String> inline bool Foam::string::meta(const string& str, const char quote) { int escaped = 0; - for (const_iterator iter = str.begin(); iter != str.end(); iter++) + for (const_iterator iter = str.begin(); iter != str.end(); ++iter) { if (quote && *iter == quote) { @@ -145,7 +145,7 @@ Foam::string::quotemeta(const string& str, const char quote) sQuoted.reserve(2*str.length()); int escaped = 0; - for (const_iterator iter = str.begin(); iter != str.end(); iter++) + for (const_iterator iter = str.begin(); iter != str.end(); ++iter) { if (*iter == quote) { diff --git a/src/dynamicMesh/motionSmoother/motionSmoother.C b/src/dynamicMesh/motionSmoother/motionSmoother.C index c477369ab729c0b66710ffbdba8da5b2e58cfc0b..f4f9e9bb6f04b0859b8f8a51304614d0ad402321 100644 --- a/src/dynamicMesh/motionSmoother/motionSmoother.C +++ b/src/dynamicMesh/motionSmoother/motionSmoother.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -34,14 +34,9 @@ License #include "meshTools.H" #include "OFstream.H" -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -defineTypeNameAndDebug(motionSmoother, 0); - -} +defineTypeNameAndDebug(Foam::motionSmoother, 0); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -738,7 +733,7 @@ Foam::tmp<Foam::scalarField> Foam::motionSmoother::movePoints // Correct for 2-D motion if (twoDCorrector_.required()) { - Info<< "Correct-ing 2-D mesh motion"; + Info<< "Correcting 2-D mesh motion"; if (mesh_.globalData().parallel()) { diff --git a/src/edgeMesh/Make/options b/src/edgeMesh/Make/options index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..7e207d0dbeaca258e5a72af8b4eb7bacefc0dee8 100644 --- a/src/edgeMesh/Make/options +++ b/src/edgeMesh/Make/options @@ -0,0 +1,5 @@ +EXE_INC = \ + -I$(LIB_SRC)/fileFormats/lnInclude + +LIB_LIBS = \ + -lfileFormats diff --git a/src/edgeMesh/edgeFormats/nas/NASedgeFormat.C b/src/edgeMesh/edgeFormats/nas/NASedgeFormat.C index 4b178d1dbd31b3186973d3ebf24cfb65a362173e..fec0c883a35030e558f2e32b1650c9639dcf94db 100644 --- a/src/edgeMesh/edgeFormats/nas/NASedgeFormat.C +++ b/src/edgeMesh/edgeFormats/nas/NASedgeFormat.C @@ -29,34 +29,6 @@ License #include "IStringStream.H" #include "PackedBoolList.H" -// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // - -// Do weird things to extract a floating point number -Foam::scalar Foam::fileFormats::NASedgeFormat::parseNASCoord -( - const string& s -) -{ - size_t expSign = s.find_last_of("+-"); - - if (expSign != string::npos && expSign > 0 && !isspace(s[expSign-1])) - { - scalar mantissa = readScalar(IStringStream(s.substr(0, expSign))()); - scalar exponent = readScalar(IStringStream(s.substr(expSign+1))()); - - if (s[expSign] == '-') - { - exponent = -exponent; - } - return mantissa * pow(10, exponent); - } - else - { - return readScalar(IStringStream(s)()); - } -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::fileFormats::NASedgeFormat::NASedgeFormat diff --git a/src/edgeMesh/edgeFormats/nas/NASedgeFormat.H b/src/edgeMesh/edgeFormats/nas/NASedgeFormat.H index 600b880cb790cdc23cf6c64a97ecdc5e4fc931c6..3ccd4397af10bf726183fb65d053e82a1f5f8bb5 100644 --- a/src/edgeMesh/edgeFormats/nas/NASedgeFormat.H +++ b/src/edgeMesh/edgeFormats/nas/NASedgeFormat.H @@ -37,6 +37,7 @@ SourceFiles #define NASedgeFormat_H #include "edgeMesh.H" +#include "NASCore.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -51,7 +52,8 @@ namespace fileFormats class NASedgeFormat : - public edgeMesh + public edgeMesh, + public NASCore { // Private Member Functions @@ -61,13 +63,6 @@ class NASedgeFormat //- Disallow default bitwise assignment void operator=(const NASedgeFormat&); -protected: - - // Protected Member Functions - - //- Do weird things to extract number - static scalar parseNASCoord(const string&); - public: // Constructors diff --git a/src/edgeMesh/edgeFormats/starcd/STARCDedgeFormat.C b/src/edgeMesh/edgeFormats/starcd/STARCDedgeFormat.C index 67599ccfd22de488718033b6d4456a7debc44efa..67ce539dca3f569f289fe1acfd30d9ee37d6ae38 100644 --- a/src/edgeMesh/edgeFormats/starcd/STARCDedgeFormat.C +++ b/src/edgeMesh/edgeFormats/starcd/STARCDedgeFormat.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -59,132 +59,6 @@ inline void Foam::fileFormats::STARCDedgeFormat::writeLines // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -bool Foam::fileFormats::STARCDedgeFormat::readHeader -( - IFstream& is, - const word& signature -) -{ - if (!is.good()) - { - FatalErrorIn - ( - "fileFormats::STARCDedgeFormat::readHeader(...)" - ) - << "cannot read " << signature << " " << is.name() - << abort(FatalError); - } - - word header; - label majorVersion; - - string line; - - is.getLine(line); - IStringStream(line)() >> header; - - is.getLine(line); - IStringStream(line)() >> majorVersion; - - // add other checks ... - if (header != signature) - { - Info<< "header mismatch " << signature << " " << is.name() - << endl; - } - - return true; -} - - -void Foam::fileFormats::STARCDedgeFormat::writeHeader -( - Ostream& os, - const char* filetype -) -{ - os << "PROSTAR_" << filetype << nl - << 4000 - << " " << 0 - << " " << 0 - << " " << 0 - << " " << 0 - << " " << 0 - << " " << 0 - << " " << 0 - << endl; -} - - -bool Foam::fileFormats::STARCDedgeFormat::readPoints -( - IFstream& is, - pointField& points, - labelList& ids -) -{ - // - // read .vrt file - // ~~~~~~~~~~~~~~ - - if (!is.good()) - { - FatalErrorIn - ( - "fileFormats::STARCDedgeFormat::readPoints(...)" - ) - << "Cannot read file " << is.name() - << exit(FatalError); - } - - readHeader(is, "PROSTAR_VERTEX"); - - DynamicList<point> dynPoints; - DynamicList<label> dynPointId; // STAR-CD index of points - - label lineLabel; - while ((is >> lineLabel).good()) - { - scalar x, y, z; - - is >> x >> y >> z; - - dynPoints.append(point(x, y, z)); - dynPointId.append(lineLabel); - } - - points.transfer(dynPoints); - ids.transfer(dynPointId); - - return true; -} - - -void Foam::fileFormats::STARCDedgeFormat::writePoints -( - Ostream& os, - const pointField& pointLst -) -{ - writeHeader(os, "VERTEX"); - - // Set the precision of the points data to 10 - os.precision(10); - - // force decimal point for Fortran input - os.setf(std::ios::showpoint); - - forAll(pointLst, ptI) - { - os << ptI + 1 << " " - << pointLst[ptI].x() << " " - << pointLst[ptI].y() << " " - << pointLst[ptI].z() << nl; - } - os.flush(); -} - - void Foam::fileFormats::STARCDedgeFormat::writeCase ( Ostream& os, diff --git a/src/edgeMesh/edgeFormats/starcd/STARCDedgeFormat.H b/src/edgeMesh/edgeFormats/starcd/STARCDedgeFormat.H index 4f54011d89a76a8e0a3c5cfaabf35b4db4f0f136..04806547ff65bb3c2bbc4ebaa536d660e02920ec 100644 --- a/src/edgeMesh/edgeFormats/starcd/STARCDedgeFormat.H +++ b/src/edgeMesh/edgeFormats/starcd/STARCDedgeFormat.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -43,6 +43,8 @@ SourceFiles #define STARCDedgeFormat_H #include "edgeMesh.H" +#include "STARCDCore.H" + #include "IFstream.H" #include "Ostream.H" #include "OFstream.H" @@ -60,7 +62,8 @@ namespace fileFormats class STARCDedgeFormat : - public edgeMesh + public edgeMesh, + public STARCDCore { // Private Data @@ -90,21 +93,12 @@ protected: // Protected Member Functions - static bool readHeader(IFstream&, const word&); - - static void writeHeader(Ostream&, const char* filetype); - - static bool readPoints(IFstream&, pointField&, labelList& ids); - - static void writePoints(Ostream&, const pointField&); - - static void writeCase - ( - Ostream&, - const pointField&, - const label nEdges - ); - + static void writeCase + ( + Ostream&, + const pointField&, + const label nEdges + ); public: diff --git a/src/fileFormats/Make/files b/src/fileFormats/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..a3acab834d80262bd1fd231f695e5091831c03f6 --- /dev/null +++ b/src/fileFormats/Make/files @@ -0,0 +1,4 @@ +nas/NASCore.C +starcd/STARCDCore.C + +LIB = $(FOAM_LIBBIN)/libfileFormats diff --git a/src/fileFormats/Make/options b/src/fileFormats/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/surfMesh/surfaceFormats/nas/NASsurfaceFormatCore.C b/src/fileFormats/nas/NASCore.C similarity index 87% rename from src/surfMesh/surfaceFormats/nas/NASsurfaceFormatCore.C rename to src/fileFormats/nas/NASCore.C index 97b6a9ae4057eca52bf6823c0ee4d29c4be97817..9af082eef1e15bf3bf83f96dacaa861da970ff49 100644 --- a/src/surfMesh/surfaceFormats/nas/NASsurfaceFormatCore.C +++ b/src/fileFormats/nas/NASCore.C @@ -24,13 +24,18 @@ License \*---------------------------------------------------------------------------*/ -#include "NASsurfaceFormatCore.H" +#include "NASCore.H" #include "IStringStream.H" -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Do weird things to extract a floating point number -Foam::scalar Foam::fileFormats::NASsurfaceFormatCore::parseNASCoord +Foam::fileFormats::NASCore::NASCore() +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +Foam::scalar Foam::fileFormats::NASCore::parseNASCoord ( const string& s ) diff --git a/src/surfMesh/surfaceFormats/nas/NASsurfaceFormatCore.H b/src/fileFormats/nas/NASCore.H similarity index 81% rename from src/surfMesh/surfaceFormats/nas/NASsurfaceFormatCore.H rename to src/fileFormats/nas/NASCore.H index 2c7b32d781450a50123d01d5a971fe9eee438723..129531e6aa7779087b05cf4fa5a80bc55f402f87 100644 --- a/src/surfMesh/surfaceFormats/nas/NASsurfaceFormatCore.H +++ b/src/fileFormats/nas/NASCore.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,21 +23,21 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - Foam::fileFormats::NASsurfaceFormatCore + Foam::fileFormats::NASCore Description - Internal class used by the NASsurfaceFormat + Core routines used when reading/writing NASTRAN files. SourceFiles - NASsurfaceFormatCore.C + NASCore.C \*---------------------------------------------------------------------------*/ -#ifndef NASsurfaceFormatCore_H -#define NASsurfaceFormatCore_H +#ifndef NASCore_H +#define NASCore_H -#include "Ostream.H" -#include "OFstream.H" +#include "scalar.H" +#include "string.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -47,17 +47,23 @@ namespace fileFormats { /*---------------------------------------------------------------------------*\ - Class NASsurfaceFormatCore Declaration + Class fileFormats::NASCore Declaration \*---------------------------------------------------------------------------*/ -class NASsurfaceFormatCore +class NASCore { -protected: +public: - // Protected Member Functions + // Public Member Functions //- Do weird things to extract number static scalar parseNASCoord(const string&); + + + // Constructors + + //- Construct null + NASCore(); }; diff --git a/src/fileFormats/starcd/STARCDCore.C b/src/fileFormats/starcd/STARCDCore.C new file mode 100644 index 0000000000000000000000000000000000000000..e8206c29d8894bc82afa0a58f977807f32341207 --- /dev/null +++ b/src/fileFormats/starcd/STARCDCore.C @@ -0,0 +1,173 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2006-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "STARCDCore.H" +#include "ListOps.H" +#include "clock.H" +#include "PackedBoolList.H" +#include "IStringStream.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::fileFormats::STARCDCore::STARCDCore() +{} + + +// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * // + +bool Foam::fileFormats::STARCDCore::readHeader +( + IFstream& is, + const word& signature +) +{ + if (!is.good()) + { + FatalErrorIn + ( + "fileFormats::STARCDCore::readHeader(...)" + ) + << "cannot read " << signature << " " << is.name() + << abort(FatalError); + } + + word header; + label majorVersion; + + string line; + + is.getLine(line); + IStringStream(line)() >> header; + + is.getLine(line); + IStringStream(line)() >> majorVersion; + + // add other checks ... + if (header != signature) + { + Info<< "header mismatch " << signature << " " << is.name() + << endl; + } + + return true; +} + + +void Foam::fileFormats::STARCDCore::writeHeader +( + Ostream& os, + const word& filetype +) +{ + os << "PROSTAR_" << filetype << nl + << 4000 + << " " << 0 + << " " << 0 + << " " << 0 + << " " << 0 + << " " << 0 + << " " << 0 + << " " << 0 + << endl; +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::fileFormats::STARCDCore::readPoints +( + IFstream& is, + pointField& points, + labelList& ids +) +{ + if (!is.good()) + { + FatalErrorIn + ( + "fileFormats::STARCDedgeFormat::readPoints(...)" + ) + << "Cannot read file " << is.name() + << exit(FatalError); + } + + readHeader(is, "PROSTAR_VERTEX"); + + + // reuse memory if possible + DynamicList<point> dynPoints(points.xfer()); + DynamicList<label> dynPointId(ids.xfer()); // STAR-CD index of points + + dynPoints.clear(); + dynPointId.clear(); + + label lineLabel; + while ((is >> lineLabel).good()) + { + scalar x, y, z; + + is >> x >> y >> z; + + dynPoints.append(point(x, y, z)); + dynPointId.append(lineLabel); + } + + points.transfer(dynPoints); + ids.transfer(dynPointId); + + return true; +} + + +void Foam::fileFormats::STARCDCore::writePoints +( + Ostream& os, + const pointField& pointLst +) +{ + writeHeader(os, "VERTEX"); + + // Set the precision of the points data to 10 + os.precision(10); + + // force decimal point for Fortran input + os.setf(std::ios::showpoint); + + forAll(pointLst, ptI) + { + os + << ptI + 1 << " " + << pointLst[ptI].x() << " " + << pointLst[ptI].y() << " " + << pointLst[ptI].z() << nl; + } + os.flush(); +} + + + + +// ************************************************************************* // diff --git a/src/fileFormats/starcd/STARCDCore.H b/src/fileFormats/starcd/STARCDCore.H new file mode 100644 index 0000000000000000000000000000000000000000..7057d842cbba8106f5da312ef3f6d6f54792698d --- /dev/null +++ b/src/fileFormats/starcd/STARCDCore.H @@ -0,0 +1,131 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2006-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::fileFormats::STARCDCore + +Description + Core routines used when reading/writing pro-STAR vrt/cel/bnd files. + +SourceFiles + STARCDCore.C + +\*---------------------------------------------------------------------------*/ + +#ifndef STARCDCore_H +#define STARCDCore_H + +#include "IFstream.H" +#include "pointField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +namespace fileFormats +{ + +/*---------------------------------------------------------------------------*\ + Class fileFormats::STARCDCore Declaration +\*---------------------------------------------------------------------------*/ + +class STARCDCore +{ +protected: + + // Protected Member Functions + + //- Read header + static bool readHeader(IFstream&, const word& fileSignature); + + //- Write header for fileType (CELL|VERTEX|BOUNDARY) + static void writeHeader(Ostream&, const word& fileType); + + +protected: + + enum cellType + { + starcdFluidType = 1, + starcdSolidType = 2, + starcdBaffleType = 3, + starcdShellType = 4, + starcdLineType = 5, + starcdPointType = 6 + }; + + enum shapeType + { + starcdPoint = 1, + starcdLine = 2, + starcdShell = 3, + starcdHex = 11, + starcdPrism = 12, + starcdTet = 13, + starcdPyr = 14, + starcdPoly = 255 + }; + + +public: + + // Public Member Functions + + //- Read points from a (.vrt) file + // The file format is as follows: + // @verbatim + // Line 1: + // PROSTAR_VERTEX newline + // + // Line 2: + // {version} 0 0 0 0 0 0 0 newline + // + // Body: + // {vertexId} {x} {y} {z} newline + // @endverbatim + static bool readPoints(IFstream&, pointField&, labelList& ids); + + //- Write header and points to (.vrt) file + static void writePoints(Ostream&, const pointField&); + + + // Constructors + + //- Construct null + STARCDCore(); + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace fileFormats +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 94c83312d35b49b48f4019411eab97c1ba1dfcee..e12c715250b1588d64f65bd95ee9ab4787bfbf95 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -341,10 +341,5 @@ $(SRF)/derivedFvPatchFields/SRFVelocityFvPatchVectorField/SRFVelocityFvPatchVect fieldSources = $(general)/fieldSources $(fieldSources)/pressureGradientExplicitSource/pressureGradientExplicitSource.C $(fieldSources)/timeActivatedExplicitSource/timeActivatedExplicitSource.C -$(fieldSources)/timeActivatedExplicitCellSource/timeActivatedExplicitCellSource.C - -$(fieldSources)/timeActivatedExplicitMulticomponentPointSource/timeActivatedExplicitMulticomponentPointSource.C -$(fieldSources)/timeActivatedExplicitMulticomponentPointSource/pointSourceProperties/pointSourceProperties.C -$(fieldSources)/timeActivatedExplicitMulticomponentPointSource/pointSourceProperties/pointSourcePropertiesIO.C LIB = $(FOAM_LIBBIN)/libfiniteVolume diff --git a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitCellSource/timeActivatedExplicitCellSource.C b/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitCellSource/timeActivatedExplicitCellSource.C deleted file mode 100644 index 624adadf67f938b02c247c34dcaca254becba9bc..0000000000000000000000000000000000000000 --- a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitCellSource/timeActivatedExplicitCellSource.C +++ /dev/null @@ -1,175 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. - \\/ 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 2 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, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -\*---------------------------------------------------------------------------*/ - -#include "timeActivatedExplicitCellSource.H" -#include "volFields.H" - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -void Foam::timeActivatedExplicitCellSource::updateCellSet() -{ - cellSelector_->applyToSet(topoSetSource::NEW, selectedCellSet_); - - Info<< " " << name_ << ": selected " - << returnReduce(selectedCellSet_.size(), sumOp<label>()) - << " cells" << nl << endl; - - V_ = scalarField(selectedCellSet_.size(), 1.0); - if (volumeType_ == vtAbsolute) - { - label i = 0; - forAllConstIter(cellSet, selectedCellSet_, iter) - { - V_[i++] = mesh_.V()[iter.key()]; - } - } -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::timeActivatedExplicitCellSource::timeActivatedExplicitCellSource -( - const word& name, - const fvMesh& mesh, - const dimensionSet& dims -) -: - timeActivatedExplicitSource(name, mesh, dims), - onValue_(readScalar(lookup("onValue"))), - offValue_(readScalar(lookup("offValue"))), - V_(0), - cellSource_(lookup("cellSource")), - cellSelector_ - ( - topoSetSource::New - ( - cellSource_, - mesh, - subDict(cellSource_ + "Coeffs") - ) - ), - selectedCellSet_ - ( - mesh, - name + "SourceCellSet", - mesh.nCells()/10 + 1 // Reasonable size estimate. - ) -{ - // Create the cell set - updateCellSet(); -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -Foam::scalar Foam::timeActivatedExplicitCellSource::onValue() const -{ - return onValue_; -} - - -Foam::scalar Foam::timeActivatedExplicitCellSource::offValue() const -{ - return offValue_; -} - - -Foam::tmp<Foam::DimensionedField<Foam::scalar, Foam::volMesh> > -Foam::timeActivatedExplicitCellSource::Su() -{ - tmp<DimensionedField<scalar, volMesh> > tSource - ( - new DimensionedField<scalar, volMesh> - ( - IOobject - ( - name_ + "Su", - runTime_.timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh_, - dimensionedScalar("zero", dimensions_, 0.0) - ) - ); - - scalar value = offValue_; - if - ( - active_ - && (runTime_.time().value() >= timeStart_) - && (runTime_.time().value() <= timeStart_ + duration_) - ) - { - // Update the cell set if the mesh is changing - if (mesh_.changing()) - { - updateCellSet(); - } - - value = onValue_; - } - - DimensionedField<scalar, volMesh>& sourceField = tSource(); - - label i = 0; - forAllConstIter(cellSet, selectedCellSet_, iter) - { - sourceField[iter.key()] = value/V_[i++]; - } - - return tSource; -} - - -bool Foam::timeActivatedExplicitCellSource::read() -{ - if (timeActivatedExplicitSource::read()) - { - lookup("onValue") >> onValue_; - lookup("offValue") >> offValue_; - lookup("cellSource") >> cellSource_; - cellSelector_ = - topoSetSource::New - ( - cellSource_, - mesh_, - subDict(cellSource_ + "Coeffs") - ); - updateCellSet(); - - return true; - } - else - { - return false; - } -} - - -// ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitCellSource/timeActivatedExplicitCellSource.H b/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitCellSource/timeActivatedExplicitCellSource.H deleted file mode 100644 index 96dfb3a5e822609beccce827aa97d5e88f98afdf..0000000000000000000000000000000000000000 --- a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitCellSource/timeActivatedExplicitCellSource.H +++ /dev/null @@ -1,143 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. - \\/ 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 2 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, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Class - Foam::timeActivatedExplicitSourceNew - -Description - Creates a cell set source that is activated at a given time, and remains - active for a specified duration. The source value is either in specific - (XX/m3) or absolute (XX) units. - -SourceFiles - timeActivatedExplicitCellSource.C - -\*---------------------------------------------------------------------------*/ - -#ifndef timeActivatedExplicitCellSource_H -#define timeActivatedExplicitCellSource_H - -#include "timeActivatedExplicitSource.H" -#include "topoSetSource.H" -#include "cellSet.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class timeActivatedExplicitCellSource Declaration -\*---------------------------------------------------------------------------*/ - -class timeActivatedExplicitCellSource -: - public timeActivatedExplicitSource -{ -private: - - // Private member functions - - //- Update the cell set that the source is acting on - void updateCellSet(); - - - // Private Member Functions - - //- Disallow default bitwise copy construct - timeActivatedExplicitCellSource(const timeActivatedExplicitCellSource&); - - //- Disallow default bitwise assignment - void operator=(const timeActivatedExplicitCellSource&); - - -protected: - - // Protected data - - // Source properties - - //- Value when "on" - scalar onValue_; - - //- Value when "off" - scalar offValue_; - - - // Cell set - - //- Cell volumes - scalarList V_; - - //- Name of cell source (XXXToCell) - word cellSource_; - - //- Method by which the cells will be selected - autoPtr<topoSetSource> cellSelector_; - - //- Set of selected cells - cellSet selectedCellSet_; - - -public: - - // Constructors - - //- Construct from explicit source name and mesh - timeActivatedExplicitCellSource - ( - const word&, - const fvMesh&, - const dimensionSet& - ); - - - // Member Functions - - // Access - - //- Return the "on" value - virtual scalar onValue() const; - - //- Return the "off" value - virtual scalar offValue() const; - - //- Return a tmp field of the source - virtual tmp<DimensionedField<scalar, volMesh> > Su(); - - - //- Read properties dictionary - virtual bool read(); -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitMulticomponentPointSource/pointSourceProperties/pointSourceProperties.H b/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitMulticomponentPointSource/pointSourceProperties/pointSourceProperties.H deleted file mode 100644 index c83e3fc6662634ff92882909fdbc54721bfa2f58..0000000000000000000000000000000000000000 --- a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitMulticomponentPointSource/pointSourceProperties/pointSourceProperties.H +++ /dev/null @@ -1,158 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. - \\/ 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 2 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, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Class - Foam::pointSourceProperties - -Description - Helper class to describe point source properties - -SourceFiles - pointSourceProperties.C - -\*---------------------------------------------------------------------------*/ - -#ifndef pointSourceProperties_H -#define pointSourceProperties_H - -#include "IOdictionary.H" -#include "fvMesh.H" -#include "Time.H" -#include "Tuple2.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class pointSourceProperties Declaration -\*---------------------------------------------------------------------------*/ - -class pointSourceProperties -{ -protected: - - // Protected data - - typedef Tuple2<word, scalar> fieldNameValuePair; - - //- Source name - word name_; - - //- Time start - scalar timeStart_; - - //- Duration - scalar duration_; - - //- Point location - point location_; - - //- List of source field name vs value pairs - List<fieldNameValuePair> fieldData_; - - -public: - - // Constructors - - //- Construct null - pointSourceProperties(); - - //- Construct from dictionary - pointSourceProperties(const dictionary& dict); - - //- Construct from Istream - pointSourceProperties(Istream& is); - - //- Copy constructor - pointSourceProperties(const pointSourceProperties&); - - - // Member Functions - - // Access - - //- Return const access to the source name - inline const word& name() const; - - //- Return const access to the time start - inline scalar timeStart() const; - - //- Return const access to the time end - inline scalar timeEnd() const; - - //- Return const access to the duration - inline scalar duration() const; - - //- Return const access to the point location - inline const point& location() const; - - //- Return const access to the source field name vs value pairs - inline const List<fieldNameValuePair>& fieldData() const; - - - // Edit - - //- Return access to the source name - inline word& name(); - - //- Return access to the time start - inline scalar& timeStart(); - - //- Return access to the duration - inline scalar& duration(); - - //- Return access to the point location - inline point& location(); - - //- Return access to the source field name vs value pairs - inline List<fieldNameValuePair>& fieldData(); - - - // Member Operators - - void operator=(const pointSourceProperties&); - - // IOstream operators - - friend Istream& operator>>(Istream&, pointSourceProperties&); - friend Ostream& operator<<(Ostream&, const pointSourceProperties&); -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#include "pointSourcePropertiesI.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitMulticomponentPointSource/pointSourceProperties/pointSourcePropertiesIO.C b/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitMulticomponentPointSource/pointSourceProperties/pointSourcePropertiesIO.C deleted file mode 100644 index 5b0ca2e63efa8751afa1425704cb5d3f72d31d25..0000000000000000000000000000000000000000 --- a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitMulticomponentPointSource/pointSourceProperties/pointSourcePropertiesIO.C +++ /dev/null @@ -1,88 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. - \\/ 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 2 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, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -\*---------------------------------------------------------------------------*/ - -#include "pointSourceProperties.H" -#include "dictionaryEntry.H" - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::pointSourceProperties::pointSourceProperties(Istream& is) -: - name_("unknownPointSourceName"), - timeStart_(0.0), - duration_(0.0), - location_(point::zero), - fieldData_() -{ - is.check("pointSourceProperties(Istream&)"); - - const dictionaryEntry entry(dictionary::null, is); - - name_ = entry.keyword(); - entry.lookup("timeStart") >> timeStart_; - entry.lookup("duration") >> duration_; - entry.lookup("location") >> location_; - entry.lookup("fieldData") >> fieldData_; -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -Foam::Istream& Foam::operator>>(Istream& is, pointSourceProperties& psp) -{ - is.check("Istream& operator>>(Istream&, pointSourceProperties&)"); - - const dictionaryEntry entry(dictionary::null, is); - - psp.name_ = entry.keyword(); - entry.lookup("timeStart") >> psp.timeStart_; - entry.lookup("duration") >> psp.duration_; - entry.lookup("location") >> psp.location_; - entry.lookup("fieldData") >> psp.fieldData_; - - return is; -} - - -Foam::Ostream& Foam::operator<<(Ostream& os, const pointSourceProperties& psp) -{ - os.check("Ostream& operator<<(Ostream&, const pointSourceProperties&)"); - - os << psp.name_ << nl << token::BEGIN_BLOCK << nl; - os.writeKeyword("timeStart") << psp.timeStart_ << token::END_STATEMENT << nl; - os.writeKeyword("duration") << psp.duration_ << token::END_STATEMENT << nl; - os.writeKeyword("location") << psp.location_ << token::END_STATEMENT << nl; - os.writeKeyword("fieldData") << psp.fieldData_ << token::END_STATEMENT << nl; - os << token::END_BLOCK << nl; - - os.check("Ostream& operator<<(Ostream&, const pointSourceProperties&)"); - - return os; -} - - - -// ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitMulticomponentPointSource/timeActivatedExplicitMulticomponentPointSource.C b/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitMulticomponentPointSource/timeActivatedExplicitMulticomponentPointSource.C deleted file mode 100644 index 38ee3466ee7554c9f5a643c8a6ae4ad0988d6b64..0000000000000000000000000000000000000000 --- a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitMulticomponentPointSource/timeActivatedExplicitMulticomponentPointSource.C +++ /dev/null @@ -1,292 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. - \\/ 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 2 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, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -\*---------------------------------------------------------------------------*/ - -#include "timeActivatedExplicitMulticomponentPointSource.H" -#include "volFields.H" - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -Foam::label -Foam::timeActivatedExplicitMulticomponentPointSource::carrierFieldId -( - const word& fieldName -) -{ - forAll(carrierFields_, fieldI) - { - if (carrierFields_[fieldI].name() == fieldName) - { - return fieldI; - } - } - - return -1; -} - - -void Foam::timeActivatedExplicitMulticomponentPointSource::updateAddressing() -{ - forAll(pointSources_, sourceI) - { - const pointSourceProperties& psp = pointSources_[sourceI]; - bool foundCell = false; - label cid = mesh_.findCell(psp.location()); - if (cid >= 0) - { - foundCell = mesh_.pointInCell(psp.location(), cid); - } - reduce(foundCell, orOp<bool>()); - if (!foundCell) - { - label cid = mesh_.findNearestCell(psp.location()); - if (cid >= 0) - { - foundCell = mesh_.pointInCell(psp.location(), cid); - } - } - reduce(foundCell, orOp<bool>()); - - if (!foundCell) - { - FatalErrorIn - ( - "timeActivatedExplicitMulticomponentPointSource::" - "updateAddressing()" - ) << "Unable to find location " << psp.location() << " in mesh " - << "for source " << psp.name() << nl - << exit(FatalError); - } - else - { - cellOwners_[sourceI] = cid; - } - - fieldIds_[sourceI].setSize(psp.fieldData().size()); - forAll(psp.fieldData(), fieldI) - { - const word& fieldName = psp.fieldData()[fieldI].first(); - label cfid = carrierFieldId(fieldName); - if (cfid < 0) - { - FatalErrorIn - ( - "timeActivatedExplicitMulticomponentPointSource::" - "updateAddressing()" - ) << "Unable to find field " << fieldName << " in carrier " - << "fields for source " << psp.name() << nl - << exit(FatalError); - } - else - { - fieldIds_[sourceI][fieldI] = cfid; - } - } - } -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::timeActivatedExplicitMulticomponentPointSource:: -timeActivatedExplicitMulticomponentPointSource -( - const word& name, - const fvMesh& mesh, - const PtrList<volScalarField>& carrierFields, - const dimensionSet& dims -) -: - IOdictionary - ( - IOobject - ( - name + "Properties", - mesh.time().constant(), - mesh, - IOobject::MUST_READ, - IOobject::NO_WRITE - ) - ), - name_(name), - mesh_(mesh), - runTime_(mesh.time()), - dimensions_(dims), - carrierFields_(carrierFields), - active_(lookup("active")), - pointSources_(lookup("pointSources")), - cellOwners_(pointSources_.size()), - fieldIds_(pointSources_.size()) -{ - // Initialise the field addressing - updateAddressing(); -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -Foam::tmp<Foam::DimensionedField<Foam::scalar, Foam::volMesh> > -Foam::timeActivatedExplicitMulticomponentPointSource::Su -( - const label fieldI -) -{ - if (mesh_.changing()) - { - updateAddressing(); - } - - tmp<DimensionedField<scalar, volMesh> > tSource - ( - new DimensionedField<scalar, volMesh> - ( - IOobject - ( - name_ + carrierFields_[fieldI].name() + "Su", - runTime_.timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh_, - dimensionedScalar("zero", dimensions_, 0.0) - ) - ); - - if (active_) - { - DimensionedField<scalar, volMesh>& sourceField = tSource(); - - const scalarField& V = mesh_.V(); - const scalar dt = runTime_.deltaTValue(); - - forAll(pointSources_, sourceI) - { - const pointSourceProperties& psp = pointSources_[sourceI]; - - forAll(fieldIds_[sourceI], i) - { - if - ( - fieldIds_[sourceI][i] == fieldI - && (runTime_.time().value() >= psp.timeStart()) - && (runTime_.time().value() <= psp.timeEnd()) - ) - { - const label cid = cellOwners_[sourceI]; - if (cid >= 0) - { - sourceField[cid] += - dt*psp.fieldData()[i].second()/V[cid]; - } - } - } - } - } - - return tSource; -} - - -Foam::tmp<Foam::DimensionedField<Foam::scalar, Foam::volMesh> > -Foam::timeActivatedExplicitMulticomponentPointSource::Su() -{ - if (mesh_.changing()) - { - updateAddressing(); - } - - tmp<DimensionedField<scalar, volMesh> > tSource - ( - new DimensionedField<scalar, volMesh> - ( - IOobject - ( - name_ + "TotalSu", - runTime_.timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh_, - dimensionedScalar("zero", dimensions_, 0.0) - ) - ); - - if (active_) - { - DimensionedField<scalar, volMesh>& sourceField = tSource(); - - const scalarField& V = mesh_.V(); - const scalar dt = runTime_.deltaTValue(); - - forAll(pointSources_, sourceI) - { - const pointSourceProperties& psp = pointSources_[sourceI]; - - forAll(fieldIds_[sourceI], i) - { - if - ( - (runTime_.time().value() >= psp.timeStart()) - && (runTime_.time().value() <= psp.timeEnd()) - ) - { - const label cid = cellOwners_[sourceI]; - if (cid >= 0) - { - sourceField[cid] += - dt*psp.fieldData()[i].second()/V[cid]; - } - } - } - } - } - - return tSource; -} - - -bool Foam::timeActivatedExplicitMulticomponentPointSource::read() -{ - if (regIOobject::read()) - { - lookup("active") >> active_; - lookup("pointSources") >> pointSources_; - - cellOwners_.setSize(pointSources_.size()); - - updateAddressing(); - - return true; - } - else - { - return false; - } -} - - -// ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitMulticomponentPointSource/timeActivatedExplicitMulticomponentPointSource.H b/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitMulticomponentPointSource/timeActivatedExplicitMulticomponentPointSource.H deleted file mode 100644 index 0247f263896954720494026cdbef057db8f4b66c..0000000000000000000000000000000000000000 --- a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitMulticomponentPointSource/timeActivatedExplicitMulticomponentPointSource.H +++ /dev/null @@ -1,185 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. - \\/ 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 2 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, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Class - Foam::timeActivatedExplicitMulticomponentPointSourceNew - -Description - Provides a mechanism to introduce point sources to a set of carrier fields. - Carrier fields are supplied on consruction, and interrogated to provide the - field indices of the sources. - - Source values are assumed to be in <quantity>/s, and divided through by the - cell volumes before being returned, e.g. for a kg/s source - - Properties are described in a <name>Properties dictionary - - active true; // are sources active (true/false) - - pointSources - ( - source1 // source name - { - timeStart 0.0; - duration 1.0; - location (0 0 0); - fieldData - ( - (H2O 0.1) // kg/s - (O2 0.05) // kg/s - ); - } - source2 // source name - { - timeStart 0.5; - duration 2.0; - location (1 1 1); - fieldData - ( - (NO 0.1) // kg/s - (CO2 0.05) // kg/s - (H2 0.001) // kg/s - ); - } - ); - - -SourceFiles - timeActivatedExplicitMulticomponentPointSourceNew.C - -\*---------------------------------------------------------------------------*/ - -#ifndef timeActivatedExplicitMulticomponentPointSource_H -#define timeActivatedExplicitMulticomponentPointSource_H - -#include "IOdictionary.H" -#include "fvMesh.H" -#include "Time.H" -#include "pointSourceProperties.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class timeActivatedExplicitMulitcomponentPointSource Declaration -\*---------------------------------------------------------------------------*/ - -class timeActivatedExplicitMulticomponentPointSource -: - public IOdictionary -{ -protected: - - // Protected data - - //- Name of the source - word name_; - - //- Reference to the mesh - const fvMesh& mesh_; - - //- Reference to time database - const Time& runTime_; - - //- Source dimensions - const dimensionSet& dimensions_; - - //- Reference to the multicomponent carrier fields - const PtrList<volScalarField>& carrierFields_; - - //- Active flag - Switch active_; - - //- List of point source properties - List<pointSourceProperties> pointSources_; - - //- List of cell owners for point source locations - List<label> cellOwners_; - - //- List of field ids for each source - List<labelList> fieldIds_; - - - // Protected Member Functions - - //- Return the id of field given its name - label carrierFieldId(const word& fieldName); - - //- Update the addressing between source and carrier fields - void updateAddressing(); - - //- Disallow default bitwise copy construct - timeActivatedExplicitMulticomponentPointSource - ( - const timeActivatedExplicitMulticomponentPointSource& - ); - - //- Disallow default bitwise assignment - void operator=(const timeActivatedExplicitMulticomponentPointSource&); - - -public: - - // Constructors - - //- Construct from components - timeActivatedExplicitMulticomponentPointSource - ( - const word&, - const fvMesh&, - const PtrList<volScalarField>&, - const dimensionSet& - ); - - - // Member Functions - - // Access - - //- Return a tmp field of the source for field fieldI - virtual tmp<DimensionedField<scalar, volMesh> > Su - ( - const label fieldI - ); - - //- Return a tmp field of the total source - virtual tmp<DimensionedField<scalar, volMesh> > Su(); - - - //- Read properties dictionary - virtual bool read(); -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/TimeActivatedExplicitSource.C b/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/TimeActivatedExplicitSource.C new file mode 100644 index 0000000000000000000000000000000000000000..1552b8f8ab1fdbed3a489b127dc409370ad2995c --- /dev/null +++ b/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/TimeActivatedExplicitSource.C @@ -0,0 +1,360 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "TimeActivatedExplicitSource.H" +#include "fvMesh.H" +#include "volFields.H" + +// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * // + +template<class Type> +const Foam::wordList Foam::TimeActivatedExplicitSource<Type>:: +selectionModeTypeNames_ +( + IStringStream("(points cellSet)")() +); + + +template<class Type> +const Foam::wordList Foam::TimeActivatedExplicitSource<Type>:: +volumeModeTypeNames_ +( + IStringStream("(absolute specific)")() +); + + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +template<class Type> +typename Foam::TimeActivatedExplicitSource<Type>::selectionModeType +Foam::TimeActivatedExplicitSource<Type>::wordToSelectionModeType +( + const word& smtName +) const +{ + forAll(selectionModeTypeNames_, i) + { + if (smtName == selectionModeTypeNames_[i]) + { + return selectionModeType(i); + } + } + + FatalErrorIn + ( + "TimeActivatedExplicitSource<Type>::selectionModeType" + "TimeActivatedExplicitSource<Type>::wordToSelectionModeType" + "(" + "const word&" + ")" + ) << "Unknown selectionMode type " << smtName + << ". Valid selectionMode types are:" << nl << selectionModeTypeNames_ + << exit(FatalError); + + return selectionModeType(0); +} + + +template<class Type> +typename Foam::TimeActivatedExplicitSource<Type>::volumeModeType +Foam::TimeActivatedExplicitSource<Type>::wordToVolumeModeType +( + const word& vmtName +) const +{ + forAll(volumeModeTypeNames_, i) + { + if (vmtName == volumeModeTypeNames_[i]) + { + return volumeModeType(i); + } + } + + FatalErrorIn + ( + "TimeActivatedExplicitSource<Type>::volumeModeType" + "TimeActivatedExplicitSource<Type>::wordToVolumeModeType(const word&)" + ) << "Unknown volumeMode type " << vmtName + << ". Valid volumeMode types are:" << nl << volumeModeTypeNames_ + << exit(FatalError); + + return volumeModeType(0); +} + + +template<class Type> +Foam::word Foam::TimeActivatedExplicitSource<Type>::selectionModeTypeToWord +( + const selectionModeType& smtType +) const +{ + if (smtType > selectionModeTypeNames_.size()) + { + return "UNKNOWN"; + } + else + { + return selectionModeTypeNames_[smtType]; + } +} + + +template<class Type> +Foam::word Foam::TimeActivatedExplicitSource<Type>::volumeModeTypeToWord +( + const volumeModeType& vmtType +) const +{ + if (vmtType > volumeModeTypeNames_.size()) + { + return "UNKNOWN"; + } + else + { + return volumeModeTypeNames_[vmtType]; + } +} + + +template<class Type> +void Foam::TimeActivatedExplicitSource<Type>::setSelection +( + const dictionary& dict +) +{ + switch (selectionMode_) + { + case smPoints: + { + dict.lookup("points") >> points_; + break; + } + case smCellSet: + { + dict.lookup("cellSet") >> cellSetName_; + break; + } + default: + { + FatalErrorIn + ( + "TimeActivatedExplicitSource::setSelection(const dictionary&)" + ) << "Unknown selectionMode " + << selectionModeTypeNames_[selectionMode_] + << ". Valid selectionMode types are" << selectionModeTypeNames_ + << exit(FatalError); + } + } +} + + +template<class Type> +void Foam::TimeActivatedExplicitSource<Type>::setFieldData +( + const dictionary& dict, + const wordList& fieldNames +) +{ + dict.lookup("fieldData") >> fieldData_; + labelList localFieldIds(fieldData_.size(), -1); + forAll(fieldNames, i) + { + forAll(fieldData_, j) + { + const word& fdName = fieldData_[j].first(); + if (fdName == fieldNames[i]) + { + fieldIds_[i] = j; + localFieldIds[j] = i; + break; + } + } + } + forAll(localFieldIds, i) + { + if (localFieldIds[i] < 0) + { + FatalErrorIn + ( + "TimeActivatedExplicitSource<Type>::setFieldData" + "(" + "const dictionary&, " + "const wordList&" + ")" + ) << "Field " << fieldData_[i].first() << " not found in " + << "field list. Available fields are: " << nl << fieldNames + << exit(FatalError); + } + } +} + + +template<class Type> +void Foam::TimeActivatedExplicitSource<Type>::setCellSet() +{ + Info<< incrIndent << indent << "Source: " << name_ << endl; + switch (selectionMode_) + { + case smPoints: + { + Info<< indent << "- selecting cells using points" << endl; + + labelHashSet cellOwners; + forAll(points_, i) + { + label cellI = mesh_.findCell(points_[i]); + if (cellI >= 0) + { + cellOwners.insert(cellI); + } + + label globalCellI = returnReduce(cellI, maxOp<label>()); + if (globalCellI < 0) + { + WarningIn("TimeActivatedExplicitSource<Type>::setCellIds()") + << "Unable to find owner cell for point " << points_[i] + << endl; + } + } + + cellsPtr_.reset(new cellSet(mesh_, "points", cellOwners)); + + break; + } + case smCellSet: + { + Info<< indent << "- selecting cells using cellSet " + << cellSetName_ << endl; + cellsPtr_.reset(new cellSet(mesh_, cellSetName_)); + + break; + } + default: + { + FatalErrorIn("TimeActivatedExplicitSource<Type>::setCellIds()") + << "Unknown selectionMode " + << selectionModeTypeNames_[selectionMode_] + << ". Valid selectionMode types are" << selectionModeTypeNames_ + << exit(FatalError); + } + } + + const cellSet& cSet = cellsPtr_(); + + // Set volume normalisation + V_ = scalarField(cSet.size(), 1.0); + if (volumeMode_ == vmAbsolute) + { + label i = 0; + forAllConstIter(cellSet, cSet, iter) + { + V_[i++] = mesh_.V()[iter.key()]; + } + } + + Info<< indent << "- selected " << returnReduce(cSet.size(), sumOp<label>()) + << " cell(s)" << nl << decrIndent << endl; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class Type> +Foam::TimeActivatedExplicitSource<Type>::TimeActivatedExplicitSource +( + const word& name, + const dictionary& dict, + const fvMesh& mesh, + const wordList& fieldNames +) +: + name_(name), + mesh_(mesh), + active_(dict.lookup("active")), + timeStart_(readScalar(dict.lookup("timeStart"))), + duration_(readScalar(dict.lookup("duration"))), + volumeMode_(wordToVolumeModeType(dict.lookup("volumeMode"))), + selectionMode_(wordToSelectionModeType(dict.lookup("selectionMode"))), + points_(), + cellSetName_("none"), + V_(), + cellsPtr_(), + fieldData_(), + fieldIds_(fieldNames.size(), -1) +{ + setSelection(dict); + + if (fieldNames.size() == 1) + { + fieldData_.setSize(1); + fieldData_[0].first() = fieldNames[0]; + dict.lookup("fieldData") >> fieldData_[0].second(); + fieldIds_[0] = 0; + } + else + { + setFieldData(dict, fieldNames); + } + + setCellSet(); +} + + +template<class Type> +void Foam::TimeActivatedExplicitSource<Type>::addToField +( + DimensionedField<Type, volMesh>& Su, + const label fieldI +) +{ + const label fid = fieldIds_[fieldI]; + + if + ( + active_ + && (fid >= 0) + && (mesh_.time().value() >= timeStart_) + && (mesh_.time().value() <= timeEnd()) + ) + { + // Update the cell set if the mesh is changing + if (mesh_.changing()) + { + setCellSet(); + } + + const cellSet& cSet = cellsPtr_(); + + label i = 0; + forAllConstIter(cellSet, cSet, iter) + { + Su[iter.key()] = fieldData_[fid].second()/V_[i++]; + } + } +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/TimeActivatedExplicitSource.H b/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/TimeActivatedExplicitSource.H new file mode 100644 index 0000000000000000000000000000000000000000..9b1bfa6974537073b969fc7a2686ab57ed085cc6 --- /dev/null +++ b/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/TimeActivatedExplicitSource.H @@ -0,0 +1,392 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::TimeActivatedExplicitSource + +Description + Time activated explicit source. + + Sources described by: + + { + active true; // on/off switch + timeStart 0.2; // start time + duration 2.0; // duration + selectionMode points; // cellSet + volumeMode absolute; // specific + + fieldData // field data - usage for multiple fields + ( + (H2O 0.005) + ); + + fieldData 0.005; // field data - usage for single field + + points // list of points when selectionMode = points + ( + (2.75 0.5 0) + ); + + cellSet c0; // cellSet name when selectionMode = cekllSet + } + +SourceFiles + TimeActivatedExplicitSource.C + +\*---------------------------------------------------------------------------*/ + +#ifndef TimeActivatedExplicitSource_H +#define TimeActivatedExplicitSource_H + +#include "Tuple2.H" +#include "cellSet.H" +#include "volFieldsFwd.H" +#include "DimensionedField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes + +class fvMesh; + +template<class Type> +class TimeActivatedExplicitSource; + +// Forward declaration of friend functions + +template<class Type> +Ostream& operator<< +( + Ostream&, + const TimeActivatedExplicitSource<Type>& +); + +/*---------------------------------------------------------------------------*\ + Class TimeActivatedExplicitSource Declaration +\*---------------------------------------------------------------------------*/ + +template<class Type> +class TimeActivatedExplicitSource +{ +public: + + // Public data + + //- Enumeration for selection mode types + enum selectionModeType + { + smPoints, + smCellSet + }; + + //- Word list of selection mode type names + static const wordList selectionModeTypeNames_; + + //- Enumeration for volume types + enum volumeModeType + { + vmAbsolute, + vmSpecific + }; + + //- Word list of volume mode type names + static const wordList volumeModeTypeNames_; + + +protected: + + // Protected data + + typedef Tuple2<word, Type> fieldNameValuePair; + + //- Source name + word name_; + + //- Reference to the mesh database + const fvMesh& mesh_; + + //- Source active flag + bool active_; + + //- Time start + scalar timeStart_; + + //- Duration + scalar duration_; + + //- Volume mode + volumeModeType volumeMode_; + + //- Cell selection mode + selectionModeType selectionMode_; + + //- List of points for "points" selectionMode + List<point> points_; + + //- Name of cell set for "cellSet" selectionMode + word cellSetName_; + + //- Field of cell volumes according to cell set cells + scalarList V_; + + //- Cell set + autoPtr<cellSet> cellsPtr_; + + //- List of source field name vs value pairs + List<fieldNameValuePair> fieldData_; + + //- Map of fields ids from supplied fields to local field source ids + labelList fieldIds_; + + + // Protected functions + + //- Helper function to convert from a word to a selectionModeType + selectionModeType wordToSelectionModeType(const word& smtName) const; + + //- Helper function to convert from a word to a volumeModeType + volumeModeType wordToVolumeModeType(const word& vtName) const; + + //- Helper function to convert from a selectionModeType to a word + word selectionModeTypeToWord(const selectionModeType& smtType) const; + + //- Helper function to convert from a volumeModeType to a word + word volumeModeTypeToWord(const volumeModeType& vtType) const; + + //- Set the cellSet or points selection + void setSelection(const dictionary& dict); + + //- Set the local field data + void setFieldData(const dictionary& dict, const wordList& fieldNames); + + //- Set the cell set based on the user input selection mode + void setCellSet(); + + +public: + + // Constructors + + //- Construct from components + TimeActivatedExplicitSource + ( + const word& name, + const dictionary& dict, + const fvMesh& mesh, + const wordList& fieldNames + ); + + //- Return clone + autoPtr<TimeActivatedExplicitSource> clone() const + { + notImplemented + ( + "autoPtr<TimeActivatedExplicitSource> clone() const" + ); + return autoPtr<TimeActivatedExplicitSource>(NULL); + } + + //- Return pointer to new TimeActivatedExplicitSource object created + // on the freestore from an Istream + class iNew + { + //- Reference to the mesh database + const fvMesh& mesh_; + + //- List of field names + const wordList& fieldNames_; + + + public: + + iNew + ( + const fvMesh& mesh, + const wordList& fieldNames + ) + : + mesh_(mesh), + fieldNames_(fieldNames) + {} + + autoPtr<TimeActivatedExplicitSource> operator()(Istream& is) const + { + const word name(is); + const dictionary dict(is); + + return autoPtr<TimeActivatedExplicitSource> + ( + new TimeActivatedExplicitSource + ( + name, + dict, + mesh_, + fieldNames_ + ) + ); + } + }; + + + // Member Functions + + // Access + + //- Return const access to the source name + inline const word& name() const; + + //- Return const access to the mesh database + inline const fvMesh& mesh() const; + + //- Return const access to the source active flag + inline bool active() const; + + //- Return const access to the time start + inline scalar timeStart() const; + + //- Return const access to the duration + inline scalar duration() const; + + //- Return const access to the time end + inline scalar timeEnd() const; + + //- Return const access to the volume mode + inline const volumeModeType& volumeMode() const; + + //- Return const access to the cell selection mode + inline const selectionModeType& selectionMode() const; + + //- Return const access to the list of points for "points" + // selectionMode + inline const List<point>& points() const; + + //- Return const access to the name of cell set for "cellSet" + // selectionMode + inline const word& cellSetName() const; + + //- Return const access to the field of cell volumes according to + // cell set cells + inline const scalarList& V() const; + + //- Return const access to the cell set + inline const cellSet& cells() const; + + //- Return const access to the source field name vs value pairs + inline const List<fieldNameValuePair>& fieldData() const; + + //- Return const access to the the map of fields ids from supplied + // fields to local field source ids + inline const labelList& fieldIds() const; + + + // Edit + + //- Return access to the source name + inline word& name(); + + //- Return access to the source active flag + inline bool& active(); + + //- Return access to the time start + inline scalar& timeStart(); + + //- Return access to the duration + inline scalar& duration(); + + //- Return access to the volume mode + inline volumeModeType& volumeMode(); + + //- Return access to the cell selection mode + inline selectionModeType& selectionMode(); + + //- Return access to the list of points for "points" selectionMode + inline List<point>& points(); + + //- Return access to the name of cell set for "cellSet" + // selectionMode + inline word& cellSetName(); + + //- Return access to the field of cell volumes according to + // cell set cells + inline scalarList& V(); + + //- Return access to the cell set + inline cellSet& cells(); + + //- Return access to the source field name vs value pairs + inline List<fieldNameValuePair>& fieldData(); + + //- Return access to the the map of fields ids from supplied + // fields to local field source ids + inline labelList& fieldIds(); + + + // Evaluation + + //- Add the source contribution to field Su + void addToField + ( + DimensionedField<Type, volMesh>& Su, + const label fieldI + ); + + + // I-O + + //- Write the source properties + void writeData(Ostream&) const; + + //- Ostream operator + friend Ostream& operator<< <Type> + ( + Ostream& os, + const TimeActivatedExplicitSource& source + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "TimeActivatedExplicitSource.C" +# include "TimeActivatedExplicitSourceIO.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "TimeActivatedExplicitSourceI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/TimeActivatedExplicitSourceI.H b/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/TimeActivatedExplicitSourceI.H new file mode 100644 index 0000000000000000000000000000000000000000..a641d486b7276131150984b5ba54748dcc56f364 --- /dev/null +++ b/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/TimeActivatedExplicitSourceI.H @@ -0,0 +1,227 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "TimeActivatedExplicitSource.H" + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type> +inline const Foam::word& Foam::TimeActivatedExplicitSource<Type>::name() const +{ + return name_; +} + + +template<class Type> +inline const Foam::fvMesh& Foam::TimeActivatedExplicitSource<Type>::mesh() const +{ + return mesh_; +} + + +template<class Type> +inline bool Foam::TimeActivatedExplicitSource<Type>::active() const +{ + return active_; +} + + +template<class Type> +inline Foam::scalar Foam::TimeActivatedExplicitSource<Type>::timeStart() const +{ + return timeStart_; +} + + +template<class Type> +inline Foam::scalar Foam::TimeActivatedExplicitSource<Type>::duration() const +{ + return duration_; +} + + +template<class Type> +inline Foam::scalar Foam::TimeActivatedExplicitSource<Type>::timeEnd() const +{ + return timeStart_ + duration_; +} + + +template<class Type> +inline const typename Foam::TimeActivatedExplicitSource<Type>::volumeModeType& +Foam::TimeActivatedExplicitSource<Type>::volumeMode() const +{ + return volumeMode_; +} + + +template<class Type> +inline const typename Foam::TimeActivatedExplicitSource<Type>:: +selectionModeType& +Foam::TimeActivatedExplicitSource<Type>::selectionMode() const +{ + return selectionMode_; +} + + +template<class Type> +inline const Foam::List<Foam::point>& +Foam::TimeActivatedExplicitSource<Type>::points() const +{ + return points_; +} + + +template<class Type> +inline const Foam::word& +Foam::TimeActivatedExplicitSource<Type>::cellSetName() const +{ + return cellSetName_; +} + + +template<class Type> +inline const Foam::scalarList& +Foam::TimeActivatedExplicitSource<Type>::V() const +{ + return V_; +} + + +template<class Type> +inline const Foam::cellSet& +Foam::TimeActivatedExplicitSource<Type>::cells() const +{ + return cellsPtr_(); +} + + +template<class Type> +inline const Foam::List<typename Foam::TimeActivatedExplicitSource<Type>:: +fieldNameValuePair>& +Foam::TimeActivatedExplicitSource<Type>::fieldData() const +{ + return fieldData_; +} + + +template<class Type> +inline const Foam::labelList& +Foam::TimeActivatedExplicitSource<Type>::fieldIds() const +{ + return fieldIds_; +} + + +template<class Type> +inline Foam::word& Foam::TimeActivatedExplicitSource<Type>::name() +{ + return name_; +} + + +template<class Type> +inline bool& Foam::TimeActivatedExplicitSource<Type>::active() +{ + return active_; +} + + +template<class Type> +inline Foam::scalar& Foam::TimeActivatedExplicitSource<Type>::timeStart() +{ + return timeStart_; +} + + +template<class Type> +inline Foam::scalar& Foam::TimeActivatedExplicitSource<Type>::duration() +{ + return duration_; +} + + +template<class Type> +inline typename Foam::TimeActivatedExplicitSource<Type>::volumeModeType& +Foam::TimeActivatedExplicitSource<Type>::volumeMode() +{ + return volumeMode_; +} + + +template<class Type> +inline typename Foam::TimeActivatedExplicitSource<Type>::selectionModeType& +Foam::TimeActivatedExplicitSource<Type>::selectionMode() +{ + return selectionMode_; +} + + +template<class Type> +inline Foam::List<Foam::point>& +Foam::TimeActivatedExplicitSource<Type>::points() +{ + return points_; +} + + +template<class Type> +inline Foam::word& Foam::TimeActivatedExplicitSource<Type>::cellSetName() +{ + return cellSetName_; +} + + +template<class Type> +inline Foam::scalarList& Foam::TimeActivatedExplicitSource<Type>::V() +{ + return V_; +} + + +template<class Type> +inline Foam::cellSet& Foam::TimeActivatedExplicitSource<Type>::cells() +{ + return cellsPtr_(); +} + + +template<class Type> +inline Foam::List<typename Foam::TimeActivatedExplicitSource<Type>::fieldNameValuePair>& +Foam::TimeActivatedExplicitSource<Type>::fieldData() +{ + return fieldData_; +} + + +template<class Type> +inline Foam::labelList& Foam::TimeActivatedExplicitSource<Type>::fieldIds() +{ + return fieldIds_; +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/TimeActivatedExplicitSourceIO.C b/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/TimeActivatedExplicitSourceIO.C new file mode 100644 index 0000000000000000000000000000000000000000..f9ae9120e899306b10de40ea0ae18d52818f5b49 --- /dev/null +++ b/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/TimeActivatedExplicitSourceIO.C @@ -0,0 +1,102 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "TimeActivatedExplicitSource.H" + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type> +void Foam::TimeActivatedExplicitSource<Type>::writeData(Ostream& os) const +{ + os << indent << name_ << nl + << indent << token::BEGIN_BLOCK << incrIndent << nl; + + os.writeKeyword("active") << active_ << token::END_STATEMENT << nl; + os.writeKeyword("timeStart") << timeStart_ << token::END_STATEMENT << nl; + os.writeKeyword("duration") << duration_ << token::END_STATEMENT << nl; + os.writeKeyword("selectionMode") << selectionModeTypeToWord(selectionMode_) + << token::END_STATEMENT << nl; + os.writeKeyword("volumeMode") << volumeModeTypeToWord(volumeMode_) + << token::END_STATEMENT << nl; + + if (fieldIds_.size() == 1) + { + os.writeKeyword("fieldData") << fieldData_[0].second() + << token::END_STATEMENT << nl; + } + else + { + os.writeKeyword("fieldData") << fieldData_ << nl; + } + + switch (selectionMode_) + { + case smPoints: + { + os.writeKeyword("points") << nl << indent << points_ + << token::END_STATEMENT << nl; + break; + } + case smCellSet: + { + os.writeKeyword("cellSet") << cellSetName_ + << token::END_STATEMENT << nl; + break; + } + default: + { + FatalErrorIn + ( + "TimeActivatedExplicitSource<Type>::writeData" + "(" + "Ostream&, " + "bool" + ") const" + ) << "Unknown selectionMode " + << selectionModeTypeToWord(selectionMode_) + << abort(FatalError); + } + } + + os << decrIndent << indent << token::END_BLOCK << endl; +} + + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +template<class Type> +Foam::Ostream& Foam::operator<< +( + Ostream& os, + const TimeActivatedExplicitSource<Type>& source +) +{ + source.writeData(os); + return os; +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/TimeActivatedExplicitSourceList.C b/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/TimeActivatedExplicitSourceList.C new file mode 100644 index 0000000000000000000000000000000000000000..64ff584d28065f7b868e11a12c5c70ab01010093 --- /dev/null +++ b/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/TimeActivatedExplicitSourceList.C @@ -0,0 +1,223 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "TimeActivatedExplicitSourceList.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class Type> +Foam::TimeActivatedExplicitSourceList<Type>::TimeActivatedExplicitSourceList +( + const word& name, + const fvMesh& mesh, + const dimensionSet& dimensions, + const wordList& fieldNames +) +: + IOPtrList<TimeActivatedExplicitSource<Type> > + ( + IOobject + ( + name + "SourceProperties", + mesh.time().constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ), + typename TimeActivatedExplicitSource<Type>::iNew(mesh, fieldNames) + ), + name_(name), + mesh_(mesh), + dimensions_(dimensions), + fieldNames_(fieldNames) +{} + + +template<class Type> +Foam::TimeActivatedExplicitSourceList<Type>::TimeActivatedExplicitSourceList +( + const word& name, + const fvMesh& mesh, + const dimensionSet& dimensions, + const word& fieldName +) +: + IOPtrList<TimeActivatedExplicitSource<Type> > + ( + IOobject + ( + name + "SourceProperties", + mesh.time().constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ), + typename TimeActivatedExplicitSource<Type>::iNew + ( + mesh, + IStringStream('(' + fieldName + ')')() + ) + ), + name_(name), + mesh_(mesh), + dimensions_(dimensions), + fieldNames_(1, fieldName) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type> +Foam::tmp<Foam::DimensionedField<Type, Foam::volMesh> > +Foam::TimeActivatedExplicitSourceList<Type>::Su(const label fieldI) +{ + tmp<DimensionedField<Type, volMesh> > tSu + ( + new DimensionedField<Type, volMesh> + ( + IOobject + ( + name_ + "Source_" + fieldNames_[fieldI], + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensioned<Type>("zero", dimensions_, pTraits<Type>::zero) + ) + ); + + DimensionedField<Type, volMesh>& Su = tSu(); + + forAll(*this, i) + { + this->operator[](i).addToField(Su, fieldI); + } + + return tSu; +} + + +template<class Type> +Foam::tmp<Foam::DimensionedField<Type, Foam::volMesh> > +Foam::TimeActivatedExplicitSourceList<Type>::SuTot() +{ + tmp<DimensionedField<Type, volMesh> > tSuTot + ( + new DimensionedField<Type, volMesh> + ( + IOobject + ( + name_ + "TotalSource", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensioned<Type>("zero", dimensions_, pTraits<Type>::zero) + ) + ); + + DimensionedField<Type, volMesh>& SuTot = tSuTot(); + + forAll(fieldNames_, fieldI) + { + forAll(*this, sourceI) + { + this->operator[](sourceI).addToField(SuTot, fieldI); + } + } + + return tSuTot; +} + + +template<class Type> +bool Foam::TimeActivatedExplicitSourceList<Type>::readData(Istream& is) +{ + this->clear(); + + IOPtrList<TimeActivatedExplicitSource<Type> > newSources + ( + IOobject + ( + name_ + "TimeActivatedExplicitSource", + mesh_.time().constant(), + mesh_, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ), + typename TimeActivatedExplicitSource<Type>::iNew(mesh_, fieldNames_) + ); + + transfer(newSources); + + return is.good(); +} + + +template<class Type> +bool Foam::TimeActivatedExplicitSourceList<Type>::writeData(Ostream& os) const +{ + // Write size of list + os << nl << this->size(); + + // Write beginning of contents + os << nl << token::BEGIN_LIST; + + // Write list contents + forAll(*this, i) + { + os << nl; + this->operator[](i).writeData(os); + } + + // Write end of contents + os << token::END_LIST << token::END_STATEMENT << nl; + + // Check state of IOstream + return os.good(); +} + + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +template<class Type> +Foam::Ostream& Foam::operator<< +( + Ostream& os, + const TimeActivatedExplicitSourceList<Type>& sources +) +{ + sources.writeData(os); + return os; +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/TimeActivatedExplicitSourceList.H b/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/TimeActivatedExplicitSourceList.H new file mode 100644 index 0000000000000000000000000000000000000000..502dfb01eea6384fa05b658b2ff6f818947715bd --- /dev/null +++ b/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/TimeActivatedExplicitSourceList.H @@ -0,0 +1,172 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::TimeActivatedExplicitSourceList + +Description + List of time activeted explict sources + +SourceFiles + TimeActivatedExplicitSourceList.C + +\*---------------------------------------------------------------------------*/ + +#ifndef TimeActivatedExplicitSourceList_H +#define TimeActivatedExplicitSourceList_H + +#include "IOPtrList.H" +#include "TimeActivatedExplicitSource.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class fvMesh; + +template<class Type> +class TimeActivatedExplicitSource; + +template<class Type> +class TimeActivatedExplicitSourceList; + +// Forward declaration of friend functions + +template<class Type> +Ostream& operator<< +( + Ostream&, + const TimeActivatedExplicitSourceList<Type>& +); + +/*---------------------------------------------------------------------------*\ + Class TimeActivatedExplicitSourceList Declaration +\*---------------------------------------------------------------------------*/ + +template<class Type> +class TimeActivatedExplicitSourceList +: + public IOPtrList<TimeActivatedExplicitSource<Type> > +{ +private: + + // Private data + + //- Name of source properties list + word name_; + + //- Reference to the mesh database + const fvMesh& mesh_; + + //- Dimensions of source properties + dimensionSet dimensions_; + + //- List of field names the source is working on + wordList fieldNames_; + + + // Private member functions + + //- Disallow default bitwise copy construct + TimeActivatedExplicitSourceList + ( + const TimeActivatedExplicitSourceList<Type>& + ); + + //- Disallow default bitwise assignment + void operator=(const TimeActivatedExplicitSourceList<Type>&); + + +public: + + // Constructors + + //- Construct from components with list of field names + TimeActivatedExplicitSourceList + ( + const word& name, + const fvMesh& mesh, + const dimensionSet& dimensions, + const wordList& fieldNames + ); + + //- Construct from components with single field name + TimeActivatedExplicitSourceList + ( + const word& name, + const fvMesh& mesh, + const dimensionSet& dimensions, + const word& fieldName + ); + + + // Member Functions + + // Evaluation + + //- Return the source for field, fieldI + tmp<DimensionedField<Type, volMesh> > Su + ( + const label fieldI = 0 + ); + + //- Return the total source for all fields + tmp<DimensionedField<Type, volMesh> > SuTot(); + + + + // I-O + + //- Read data from Istream + bool readData(Istream& is); + + //- Write data to Istream + bool writeData(Ostream& os) const; + + //- Ostream operator + friend Ostream& operator<< <Type> + ( + Ostream& os, + const TimeActivatedExplicitSourceList& sources + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "TimeActivatedExplicitSourceList.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/timeActivatedExplicitSource.C b/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/timeActivatedExplicitSource.C index c59b74a770eba9dc0aba0fbca48068d46a22e6ba..4af51fe56da29c45068ff19e9f3b42701359e1af 100644 --- a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/timeActivatedExplicitSource.C +++ b/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/timeActivatedExplicitSource.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,131 +25,21 @@ License \*---------------------------------------------------------------------------*/ #include "timeActivatedExplicitSource.H" -#include "volFields.H" -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -template<> -const char* Foam::NamedEnum -< - Foam::timeActivatedExplicitSource::volumeType, - 2 ->::names[] = +namespace Foam { - "specific", - "absolute" -}; - -const Foam::NamedEnum<Foam::timeActivatedExplicitSource::volumeType, 2> -Foam::timeActivatedExplicitSource::volumeTypeNames_; - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::timeActivatedExplicitSource::timeActivatedExplicitSource -( - const word& name, - const fvMesh& mesh, - const dimensionSet& dims -) -: - IOdictionary + defineTemplateTypeNameAndDebug ( - IOobject - ( - name + "Properties", - mesh.time().constant(), - mesh, - IOobject::MUST_READ, - IOobject::NO_WRITE - ) - ), - mesh_(mesh), - runTime_(mesh.time()), - name_(name), - active_(lookup("active")), - dimensions_(dims), - volumeType_(volumeTypeNames_.read(lookup("volumeType"))), - timeStart_(readScalar(lookup("timeStart"))), - duration_(readScalar(lookup("duration"))) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -const Foam::fvMesh& Foam::timeActivatedExplicitSource::mesh() const -{ - return mesh_; -} - - -const Foam::Time& Foam::timeActivatedExplicitSource::runTime() const -{ - return runTime_; -} - - -const Foam::word& Foam::timeActivatedExplicitSource::name() const -{ - return name_; -} - - -const Foam::Switch& Foam::timeActivatedExplicitSource::active() const -{ - return active_; -} - - -const Foam::dimensionSet& Foam::timeActivatedExplicitSource::dimensions() const -{ - return dimensions_; -} - - -const Foam::timeActivatedExplicitSource::volumeType& -Foam::timeActivatedExplicitSource::volume() const -{ - return volumeType_; -} - - -Foam::scalar Foam::timeActivatedExplicitSource::timeStart() const -{ - return timeStart_; -} - - -Foam::scalar Foam::timeActivatedExplicitSource::duration() const -{ - return duration_; -} - - -bool Foam::timeActivatedExplicitSource::read() -{ - if (regIOobject::read()) - { - lookup("active") >> active_; - if (active_) - { - volumeType_ = volumeTypeNames_.read(lookup("volumeType")); - lookup("timeStart") >> duration_; - lookup("duration") >> duration_; - return true; - } - else - { - return false; - } - } - else - { - return false; - } + IOPtrList<scalarTimeActivatedExplicitSource>, + 0 + ); + defineTemplateTypeNameAndDebug + ( + IOPtrList<vectorTimeActivatedExplicitSource>, + 0 + ); } - - - // ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/timeActivatedExplicitSource.H b/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/timeActivatedExplicitSource.H index 77695be74c7e323de7b97b084fa44d832f8d96b5..5c0b038b06cb65a86193ee18727162226ed4f140 100644 --- a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/timeActivatedExplicitSource.H +++ b/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/timeActivatedExplicitSource.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -22,150 +22,43 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Class +Typedef Foam::timeActivatedExplicitSource -Description - Base class for field sources. Provides: - - name - - references to mesh and time databases - - dimensions - - volume type - - startTime - - duration - - read (from <sourceName>Properties dictionary) - -SourceFiles - timeActivatedExplicitSource.C - \*---------------------------------------------------------------------------*/ #ifndef timeActivatedExplicitSource_H #define timeActivatedExplicitSource_H -#include "IOdictionary.H" -#include "autoPtr.H" -#include "fvMesh.H" -#include "Time.H" -#include "NamedEnum.H" +#include "TimeActivatedExplicitSource.H" +#include "TimeActivatedExplicitSourceList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { - -/*---------------------------------------------------------------------------*\ - Class timeActivatedExplicitSource Declaration -\*---------------------------------------------------------------------------*/ - -class timeActivatedExplicitSource -: - public IOdictionary -{ -public: - - enum volumeType - { - vtSpecific, - vtAbsolute - }; - - static const NamedEnum<volumeType, 2> volumeTypeNames_; - - -private: - - // Private Member Functions - - //- Disallow default bitwise copy construct - timeActivatedExplicitSource(const timeActivatedExplicitSource&); - - //- Disallow default bitwise assignment - void operator=(const timeActivatedExplicitSource&); - - -protected: - - // Protected data - - //- Reference to the mesh - const fvMesh& mesh_; - - //- Reference to time database - const Time& runTime_; - - - // Source properties - - //- Name of the source - word name_; - - //- Active flag - Switch active_; - - //- Dimensions - const dimensionSet dimensions_; - - //- Volume type - volumeType volumeType_; - - //- Time start [s] - scalar timeStart_; - - //- Duration [s] - scalar duration_; - - -public: - - // Constructors - - //- Construct from explicit source name and mesh - timeActivatedExplicitSource - ( - const word&, - const fvMesh&, - const dimensionSet& - ); - - - // Member Functions - - // Access - - //- Return the reference to the mesh - virtual const fvMesh& mesh() const; - - //- Return the reference to the time database - virtual const Time& runTime() const; - - //- Return the source name - virtual const word& name() const; - - //- Return the active flag - virtual const Switch& active() const; - - //- Return the dimensions - virtual const dimensionSet& dimensions() const; - - //- Return the volume type - virtual const volumeType& volume() const; - - //- Return the start time - virtual scalar timeStart() const; - - //- Return the duration - virtual scalar duration() const; - - - //- Read properties dictionary - virtual bool read(); -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam + typedef TimeActivatedExplicitSource<scalar> + scalarTimeActivatedExplicitSource; + typedef TimeActivatedExplicitSource<vector> + vectorTimeActivatedExplicitSource; + typedef TimeActivatedExplicitSource<sphericalTensor> + sphericalTensorTimeActivatedExplicitSource; + typedef TimeActivatedExplicitSource<symmTensor> + symmTensorTimeActivatedExplicitSource; + typedef TimeActivatedExplicitSource<tensor> + tensorTimeActivatedExplicitSource; + + typedef TimeActivatedExplicitSourceList<scalar> + scalarTimeActivatedExplicitSourceList; + typedef TimeActivatedExplicitSourceList<vector> + vectorTimeActivatedExplicitSourceList; + typedef TimeActivatedExplicitSourceList<sphericalTensor> + sphericalTensorTimeActivatedExplicitSourceList; + typedef TimeActivatedExplicitSourceList<symmTensor> + symmTensorTimeActivatedExplicitSourceList; + typedef TimeActivatedExplicitSourceList<tensor> + tensorTimeActivatedExplicitSourceList; +} // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/lagrangian/intermediate/Make/files b/src/lagrangian/intermediate/Make/files index 6695181469cb5c784a4356690084accb18d78508..2ee3d31c3fa7d2c257fd14e51eb3cf5f595ebbc3 100644 --- a/src/lagrangian/intermediate/Make/files +++ b/src/lagrangian/intermediate/Make/files @@ -45,10 +45,32 @@ $(REACTINGMPPARCEL)/makeBasicReactingMultiphaseParcelSubmodels.C /* bolt-on models */ -submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.C -submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.C +RADIATION=submodels/addOns/radiation +$(RADIATION)/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.C +$(RADIATION)/scatter/cloudScatter/cloudScatter.C + submodels/Kinematic/PatchInteractionModel/LocalInteraction/patchInteractionData.C +KINEMATICINJECTION=submodels/Kinematic/InjectionModel +$(KINEMATICINJECTION)/KinematicLookupTableInjection/kinematicParcelInjectionData.C +$(KINEMATICINJECTION)/KinematicLookupTableInjection/kinematicParcelInjectionDataIO.C +$(KINEMATICINJECTION)/KinematicLookupTableInjection/kinematicParcelInjectionDataIOList.C + +THERMOINJECTION=submodels/Thermodynamic/InjectionModel +$(THERMOINJECTION)/ThermoLookupTableInjection/thermoParcelInjectionData.C +$(THERMOINJECTION)/ThermoLookupTableInjection/thermoParcelInjectionDataIO.C +$(THERMOINJECTION)/ThermoLookupTableInjection/thermoParcelInjectionDataIOList.C + +REACTINGINJECTION=submodels/Reacting/InjectionModel +$(REACTINGINJECTION)/ReactingLookupTableInjection/reactingParcelInjectionData.C +$(REACTINGINJECTION)/ReactingLookupTableInjection/reactingParcelInjectionDataIO.C +$(REACTINGINJECTION)/ReactingLookupTableInjection/reactingParcelInjectionDataIOList.C + +REACTINGMPINJECTION=submodels/ReactingMultiphase/InjectionModel +$(REACTINGMPINJECTION)/ReactingMultiphaseLookupTableInjection/reactingMultiphaseParcelInjectionData.C +$(REACTINGMPINJECTION)/ReactingMultiphaseLookupTableInjection/reactingMultiphaseParcelInjectionDataIO.C +$(REACTINGMPINJECTION)/ReactingMultiphaseLookupTableInjection/reactingMultiphaseParcelInjectionDataIOList.C + /* data entries */ submodels/IO/DataEntry/makeDataEntries.C diff --git a/src/lagrangian/intermediate/parcels/include/makeReactingMultiphaseParcelInjectionModels.H b/src/lagrangian/intermediate/parcels/include/makeReactingMultiphaseParcelInjectionModels.H index e93dce23757777bd0975f7d2c337225d3034b820..00f178d1d9965d3fb577f0fba5fca454c11966e5 100644 --- a/src/lagrangian/intermediate/parcels/include/makeReactingMultiphaseParcelInjectionModels.H +++ b/src/lagrangian/intermediate/parcels/include/makeReactingMultiphaseParcelInjectionModels.H @@ -38,6 +38,7 @@ License #include "ManualInjection.H" #include "NoInjection.H" #include "PatchInjection.H" +#include "ReactingMultiphaseLookupTableInjection.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -108,6 +109,13 @@ License ParcelType, \ ThermoType \ ); \ + makeInjectionModelThermoType \ + ( \ + ReactingMultiphaseLookupTableInjection, \ + KinematicCloud, \ + ParcelType, \ + ThermoType \ + ); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/lagrangian/intermediate/submodels/IO/DataEntry/Table/Table.C b/src/lagrangian/intermediate/submodels/IO/DataEntry/Table/Table.C index ed009f8f3347eb6d97e4c82349711131836b41b2..6c8fe19f82ef0c4d0a3e7a2313b3fcf3021b1e66 100644 --- a/src/lagrangian/intermediate/submodels/IO/DataEntry/Table/Table.C +++ b/src/lagrangian/intermediate/submodels/IO/DataEntry/Table/Table.C @@ -94,46 +94,56 @@ Type Foam::Table<Type>::integrate(const scalar x1, const scalar x2) const Type sum = pTraits<Type>::zero; // Return zero if out of bounds - if ((x1 > table_[table_.size()-1].first()) || (x2 < table_[0].first())) + if ((x1 > table_.last().first()) || (x2 < table_[0].first())) { return sum; } - // Find start index + // Find next index greater than x1 label id1 = 0; while ((table_[id1].first() < x1) && (id1 < table_.size())) { id1++; } - // Find end index + // Find next index less than x2 label id2 = table_.size() - 1; while ((table_[id2].first() > x2) && (id2 >= 1)) { id2--; } - // Integrate table body - for (label i=id1; i<id2; i++) + if ((id1 - id2) == 1) { - sum += - (table_[i].second() + table_[i+1].second()) - * (table_[i+1].first() - table_[i].first()); + // x1 and x2 lie within 1 interval + sum = 0.5*(value(x1) + value(x2))*(x2 - x1); } - sum *= 0.5; - - // Add table ends (partial segments) - if (id1 > 0) - { - sum += 0.5 - * (value(x1) + table_[id1].second()) - * (table_[id1].first() - x1); - } - if (id2 < table_.size() - 1) + else { - sum += 0.5 - * (table_[id2].second() + value(x2)) - * (x2 - table_[id2].first()); + // x1 and x2 cross multiple intervals + + // Integrate table body + for (label i=id1; i<id2; i++) + { + sum += + (table_[i].second() + table_[i+1].second()) + * (table_[i+1].first() - table_[i].first()); + } + sum *= 0.5; + + // Add table ends (partial segments) + if (id1 > 0) + { + sum += 0.5 + * (value(x1) + table_[id1].second()) + * (table_[id1].first() - x1); + } + if (id2 < table_.size() - 1) + { + sum += 0.5 + * (table_[id2].second() + value(x2)) + * (x2 - table_[id2].first()); + } } return sum; diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/KinematicLookupTableInjection.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/KinematicLookupTableInjection.C index 5fd976e0160d5ba25a548b86730e38b007085d3b..31587079e6725159e995b955731db1989d411e4a 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/KinematicLookupTableInjection.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/KinematicLookupTableInjection.C @@ -27,11 +27,6 @@ License #include "KinematicLookupTableInjection.H" #include "scalarIOList.H" -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -template<class CloudType> -Foam::label Foam::KinematicLookupTableInjection<CloudType>::INPUT_FILE_COLS = 9; - // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // template<class CloudType> @@ -62,9 +57,9 @@ Foam::scalar Foam::KinematicLookupTableInjection<CloudType>::volumeToInject scalar volume = 0.0; if ((time0 >= 0.0) && (time0 < duration_)) { - forAll(mDot_, injectorI) + forAll(injectors_, i) { - volume += mDot_[injectorI]/rho_[injectorI]*(time1 - time0); + volume += injectors_[i].mDot()/injectors_[i].rho()*(time1 - time0); } } @@ -88,14 +83,7 @@ Foam::KinematicLookupTableInjection<CloudType>::KinematicLookupTableInjection ( readScalar(this->coeffDict().lookup("parcelsPerSecond")) ), - x_(0), - U_(0), - d_(0), - rho_(0), - mDot_(0), - injectorCells_(0) -{ - scalarListIOList injectorData + injectors_ ( IOobject ( @@ -105,55 +93,21 @@ Foam::KinematicLookupTableInjection<CloudType>::KinematicLookupTableInjection IOobject::MUST_READ, IOobject::NO_WRITE ) - ); - - x_.setSize(injectorData.size()); - U_.setSize(injectorData.size()); - d_.setSize(injectorData.size()); - rho_.setSize(injectorData.size()); - mDot_.setSize(injectorData.size()); - - // Populate lists - forAll(injectorData, injectorI) - { - if (injectorData[injectorI].size() != INPUT_FILE_COLS) - { - FatalErrorIn - ( - "KinematicLookupTableInjection" - "(" - "const dictionary&," - "CloudType& owner" - ")" - ) << "Incorrect number of entries in injector specification " - << "- found " << injectorData[injectorI].size() - << ", expected " << INPUT_FILE_COLS << ":" << nl - << " x0 x1 x2 u0 u1 u2 d rho mDot " << nl - << exit(FatalError); - } - x_[injectorI].component(0) = injectorData[injectorI][0]; - x_[injectorI].component(1) = injectorData[injectorI][1]; - x_[injectorI].component(2) = injectorData[injectorI][2]; - U_[injectorI].component(0) = injectorData[injectorI][3]; - U_[injectorI].component(1) = injectorData[injectorI][4]; - U_[injectorI].component(2) = injectorData[injectorI][5]; - d_[injectorI] = injectorData[injectorI][6]; - rho_[injectorI] = injectorData[injectorI][7]; - mDot_[injectorI] = injectorData[injectorI][8]; - } - + ), + injectorCells_(0) +{ // Set/cache the injector cells - injectorCells_.setSize(injectorData.size()); - forAll(x_, injectorI) + injectorCells_.setSize(injectors_.size()); + forAll(injectors_, i) { - this->findCellAtPosition(injectorCells_[injectorI], x_[injectorI]); + this->findCellAtPosition(injectorCells_[i], injectors_[i].x()); } // Determine volume of particles to inject this->volumeTotal_ = 0.0; - forAll(mDot_, injectorI) + forAll(injectors_, i) { - this->volumeTotal_ += mDot_[injectorI]/rho_[injectorI]; + this->volumeTotal_ += injectors_[i].mDot()/injectors_[i].rho(); } this->volumeTotal_ *= duration_; } @@ -194,7 +148,7 @@ void Foam::KinematicLookupTableInjection<CloudType>::setPositionAndCell { label injectorI = parcelI*injectorCells_.size()/nParcels; - position = x_[injectorI]; + position = injectors_[injectorI].x(); cellOwner = injectorCells_[injectorI]; } @@ -211,13 +165,13 @@ void Foam::KinematicLookupTableInjection<CloudType>::setProperties label injectorI = parcelI*injectorCells_.size()/nParcels; // set particle velocity - parcel.U() = U_[injectorI]; + parcel.U() = injectors_[injectorI].U(); // set particle diameter - parcel.d() = d_[injectorI]; + parcel.d() = injectors_[injectorI].d(); // set particle density - parcel.rho() = rho_[injectorI]; + parcel.rho() = injectors_[injectorI].rho(); } diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/KinematicLookupTableInjection.H b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/KinematicLookupTableInjection.H index e076f0ea5821c417eb3be8aa0859f5d2e016d59a..b7dffffe9973cb147bdae43c45bf7cefab0adf33 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/KinematicLookupTableInjection.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/KinematicLookupTableInjection.H @@ -30,7 +30,10 @@ Description an injection site. ( - (x y z u v w d rho mDot) + (x y z) (u v w) d rho mDot // injector 1 + (x y z) (u v w) d rho mDot // injector 2 + ... + (x y z) (u v w) d rho mDot // injector N ); where: @@ -49,7 +52,7 @@ SourceFiles #define KinematicLookupTableInjection_H #include "InjectionModel.H" -#include "pdf.H" +#include "kinematicParcelInjectionDataIOList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -76,27 +79,12 @@ class KinematicLookupTableInjection //- Number of parcels per injector - common to all injection sources const label nParcelsPerSecond_; - //- List of parcel position per injector / [m] - List<point> x_; - - //- List of parcel velocity per injector / [m] - List<vector> U_; - - //- List of parcel diameter per injector / [m] - List<scalar> d_; - - //- List of parcel fluid density pre injector / [kg/m3] - List<scalar> rho_; - - //- List of parcel injection mass flow per injector / [kg/s] - List<scalar> mDot_; + //- List of injectors + kinematicParcelInjectionDataIOList injectors_; //- List of injector cells per injector List<label> injectorCells_; - //- Number of columns expected in input file - static label INPUT_FILE_COLS; - protected: diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/kinematicParcelInjectionData.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/kinematicParcelInjectionData.C new file mode 100644 index 0000000000000000000000000000000000000000..ef2deb1b6a98d7e9dd555e4ee7c4ad87f7f17e29 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/kinematicParcelInjectionData.C @@ -0,0 +1,66 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "kinematicParcelInjectionData.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(kinematicParcelInjectionData, 0); +} + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::kinematicParcelInjectionData::kinematicParcelInjectionData() +: + x_(point::zero), + U_(vector::zero), + d_(0.0), + rho_(0.0), + mDot_(0.0) +{} + + +Foam::kinematicParcelInjectionData::kinematicParcelInjectionData +( + const dictionary& dict +) +: + x_(dict.lookup("x")), + U_(dict.lookup("U")), + d_(readScalar(dict.lookup("d"))), + rho_(readScalar(dict.lookup("rho"))), + mDot_(readScalar(dict.lookup("mDot"))) +{} + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::kinematicParcelInjectionData::~kinematicParcelInjectionData() +{} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/kinematicParcelInjectionData.H b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/kinematicParcelInjectionData.H new file mode 100644 index 0000000000000000000000000000000000000000..3a77de1b9d093f1e8ef4d73d3c4afefb1df6c8af --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/kinematicParcelInjectionData.H @@ -0,0 +1,216 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::kinematicParcelInjectionData + +Description + Container class to provide injection data for kinematic parcels + +SourceFiles + kinematicParcelInjectionData.C + +\*---------------------------------------------------------------------------*/ + +#ifndef kinematicParcelInjectionData_H +#define kinematicParcelInjectionData_H + +#include "dictionary.H" +#include "vector.H" +#include "point.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class kinematicParcelInjectionData; + +// Forward declaration of friend functions + +Ostream& operator<< +( + Ostream&, + const kinematicParcelInjectionData& +); + +Istream& operator>> +( + Istream&, + kinematicParcelInjectionData& +); + +/*---------------------------------------------------------------------------*\ + Class kinematicParcelInjectionData Declaration +\*---------------------------------------------------------------------------*/ + +class kinematicParcelInjectionData +{ +protected: + + // Parcel properties + + //- Position [m] + point x_; + + //- Velocity [m/s] + vector U_; + + //- Diameter [m] + scalar d_; + + //- Density [kg/m3] + scalar rho_; + + //- Mass flow rate [kg/s] + scalar mDot_; + + +public: + + //- Runtime type information + TypeName("kinematicParcelInjectionData"); + + // Constructors + + //- Null constructor + kinematicParcelInjectionData(); + + //- Construct from dictionary + kinematicParcelInjectionData(const dictionary& dict); + + //- Construct from Istream + kinematicParcelInjectionData(Istream& is); + + + //-Destructor + virtual ~kinematicParcelInjectionData(); + + + // Access + + //- Return const access to the position + inline const point& x() const; + + //- Return const access to the velocity + inline const vector& U() const; + + //- Return const access to the diameter + inline scalar d() const; + + //- Return const access to the density + inline scalar rho() const; + + //- Return const access to the mass flow rate + inline scalar mDot() const; + + + // Edit + + //- Return access to the position + inline point& x(); + + //- Return access to the velocity + inline vector& U(); + + //- Return access to the diameter + inline scalar& d(); + + //- Return access to the density + inline scalar& rho(); + + //- Return access to the mass flow rate + inline scalar& mDot(); + + + // I-O + + // Friend Operators + + friend bool operator== + ( + const kinematicParcelInjectionData& a, + const kinematicParcelInjectionData& b + ) + { + notImplemented + ( + "operator==" + "(" + "const kinematicParcelInjectionData&, " + "const kinematicParcelInjectionData&" + ")" + ); + + return false; + } + + friend bool operator!= + ( + const kinematicParcelInjectionData& a, + const kinematicParcelInjectionData& b + ) + { + notImplemented + ( + "operator==" + "(" + "const kinematicParcelInjectionData&, " + "const kinematicParcelInjectionData&" + ")" + ); + + return false; + } + + //- Ostream operator + friend Ostream& operator<< + ( + Ostream& os, + const kinematicParcelInjectionData& data + ); + + //- Istream operator + friend Istream& operator>> + ( + Istream& is, + kinematicParcelInjectionData& data + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "kinematicParcelInjectionDataI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/kinematicParcelInjectionDataI.H b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/kinematicParcelInjectionDataI.H new file mode 100644 index 0000000000000000000000000000000000000000..cf0c97d5222db52fafb2c9d1f229803c352ec248 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/kinematicParcelInjectionDataI.H @@ -0,0 +1,91 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "kinematicParcelInjectionData.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +inline const Foam::point& Foam::kinematicParcelInjectionData::x() const +{ + return x_; +} + + +inline const Foam::vector& Foam::kinematicParcelInjectionData::U() const +{ + return U_; +} + + +inline Foam::scalar Foam::kinematicParcelInjectionData::d() const +{ + return d_; +} + + +inline Foam::scalar Foam::kinematicParcelInjectionData::rho() const +{ + return rho_; +} + + +inline Foam::scalar Foam::kinematicParcelInjectionData::mDot() const +{ + return mDot_; +} + + +inline Foam::point& Foam::kinematicParcelInjectionData::x() +{ + return x_; +} + + +inline Foam::vector& Foam::kinematicParcelInjectionData::U() +{ + return U_; +} + + +inline Foam::scalar& Foam::kinematicParcelInjectionData::d() +{ + return d_; +} + + +inline Foam::scalar& Foam::kinematicParcelInjectionData::rho() +{ + return rho_; +} + + +inline Foam::scalar& Foam::kinematicParcelInjectionData::mDot() +{ + return mDot_; +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/kinematicParcelInjectionDataIO.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/kinematicParcelInjectionDataIO.C new file mode 100644 index 0000000000000000000000000000000000000000..1dae7bd7baf89d6211d800ea0c96379f4579eb07 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/kinematicParcelInjectionDataIO.C @@ -0,0 +1,89 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "kinematicParcelInjectionData.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +Foam::kinematicParcelInjectionData::kinematicParcelInjectionData(Istream& is) +{ + is.check("reading (Px Py Pz)"); + is >> x_; + + is.check("reading (Ux Uy Uz)"); + is >> U_; + + is.check("reading d"); + is >> d_; + + is.check("reading rho"); + is >> rho_; + + is.check("reading mDot"); + is >> mDot_; + + is.check("kinematicParcelInjectionData(Istream& is)"); +} + + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +Foam::Ostream& Foam::operator<< +( + Ostream& os, + const kinematicParcelInjectionData& data +) +{ + os << data.x_ << data.U_ << data.d_ << data.rho_ << data.mDot_; + + return os; +} + + +Foam::Istream& Foam::operator>>(Istream& is, kinematicParcelInjectionData& data) +{ + is.check("reading (Px Py Pz)"); + is >> data.x_; + + is.check("reading (Ux Uy Uz)"); + is >> data.U_; + + is.check("reading d"); + is >> data.d_; + + is.check("reading rho"); + is >> data.rho_; + + is.check("reading mDot"); + is >> data.mDot_; + + is.check("operator(Istream&, kinematicParcelInjectionData&)"); + + return is; +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/kinematicParcelInjectionDataIOList.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/kinematicParcelInjectionDataIOList.C new file mode 100644 index 0000000000000000000000000000000000000000..74259df210c61cd4d472462cd605c20ea3e0fce3 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/kinematicParcelInjectionDataIOList.C @@ -0,0 +1,37 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "kinematicParcelInjectionDataIOList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + defineTemplateTypeNameAndDebug(IOList<kinematicParcelInjectionData>, 0); +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/kinematicParcelInjectionDataIOList.H b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/kinematicParcelInjectionDataIOList.H new file mode 100644 index 0000000000000000000000000000000000000000..8ef31c4f13d45c642216754559a4bdf09484984f --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/kinematicParcelInjectionDataIOList.H @@ -0,0 +1,52 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + +Description + +SourceFiles + kinematicParcelInjectionDataIOList.C + +\*---------------------------------------------------------------------------*/ + +#ifndef kinematicParcelInjectionDataIOList_H +#define kinematicParcelInjectionDataIOList_H + +#include "IOList.H" +#include "kinematicParcelInjectionData.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef IOList<kinematicParcelInjectionData> + kinematicParcelInjectionDataIOList; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Reacting/InjectionModel/ReactingLookupTableInjection/ReactingLookupTableInjection.C b/src/lagrangian/intermediate/submodels/Reacting/InjectionModel/ReactingLookupTableInjection/ReactingLookupTableInjection.C index 2de0366b31230928c3cec60622aee9f8cf1b6699..5497d67bd61cd27a6d1d9dc51a3f84ea0ec65b4a 100644 --- a/src/lagrangian/intermediate/submodels/Reacting/InjectionModel/ReactingLookupTableInjection/ReactingLookupTableInjection.C +++ b/src/lagrangian/intermediate/submodels/Reacting/InjectionModel/ReactingLookupTableInjection/ReactingLookupTableInjection.C @@ -25,12 +25,6 @@ License \*---------------------------------------------------------------------------*/ #include "ReactingLookupTableInjection.H" -#include "scalarIOList.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -template<class CloudType> -Foam::label Foam::ReactingLookupTableInjection<CloudType>::INPUT_FILE_COLS = 12; // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // @@ -62,9 +56,9 @@ Foam::scalar Foam::ReactingLookupTableInjection<CloudType>::volumeToInject scalar volume = 0.0; if ((time0 >= 0.0) && (time0 < duration_)) { - forAll(mDot_, injectorI) + forAll(injectors_, i) { - volume += mDot_[injectorI]/rho_[injectorI]*(time1 - time0); + volume += injectors_[i].mDot()/injectors_[i].rho()*(time1 - time0); } } @@ -88,17 +82,7 @@ Foam::ReactingLookupTableInjection<CloudType>::ReactingLookupTableInjection ( readScalar(this->coeffDict().lookup("parcelsPerSecond")) ), - x_(0), - U_(0), - d_(0), - rho_(0), - mDot_(0), - T_(0), - cp_(0), - Y_(0), - injectorCells_(0) -{ - scalarListIOList injectorData + injectors_ ( IOobject ( @@ -108,75 +92,21 @@ Foam::ReactingLookupTableInjection<CloudType>::ReactingLookupTableInjection IOobject::MUST_READ, IOobject::NO_WRITE ) - ); - - x_.setSize(injectorData.size()); - U_.setSize(injectorData.size()); - d_.setSize(injectorData.size()); - rho_.setSize(injectorData.size()); - mDot_.setSize(injectorData.size()); - T_.setSize(injectorData.size()); - cp_.setSize(injectorData.size()); - Y_.setSize(injectorData.size()); - - // Populate lists - forAll(injectorData, injectorI) - { - if (injectorData[injectorI].size() != INPUT_FILE_COLS) - { - FatalErrorIn - ( - "ReactingLookupTableInjection" - "(" - "const dictionary&," - "CloudType& owner" - ")" - ) << "Incorrect number of entries in injector specification " - << "- found " << injectorData[injectorI].size() - << ", expected a minimum of " << INPUT_FILE_COLS << ":" << nl - << " x0 x1 x2 u0 u1 u2 d rho mDot T cp Y0..YN" - << nl << exit(FatalError); - } - x_[injectorI].component(0) = injectorData[injectorI][0]; - x_[injectorI].component(1) = injectorData[injectorI][1]; - x_[injectorI].component(2) = injectorData[injectorI][2]; - U_[injectorI].component(0) = injectorData[injectorI][3]; - U_[injectorI].component(1) = injectorData[injectorI][4]; - U_[injectorI].component(2) = injectorData[injectorI][5]; - d_[injectorI] = injectorData[injectorI][6]; - rho_[injectorI] = injectorData[injectorI][7]; - mDot_[injectorI] = injectorData[injectorI][8]; - T_[injectorI] = injectorData[injectorI][9]; - cp_[injectorI] = injectorData[injectorI][10]; - - Y_[injectorI].setSize - ( - injectorData[injectorI].size() - INPUT_FILE_COLS + 1 - ); - label Yi = 0; - for - ( - label i = INPUT_FILE_COLS-1; - i < injectorData[injectorI].size(); - i++ - ) - { - Y_[injectorI][Yi++] = injectorData[injectorI][i]; - } - } - + ), + injectorCells_(0) +{ // Set/cache the injector cells - injectorCells_.setSize(injectorData.size()); - forAll(x_, injectorI) + injectorCells_.setSize(injectors_.size()); + forAll(injectors_, i) { - this->findCellAtPosition(injectorCells_[injectorI], x_[injectorI]); + this->findCellAtPosition(injectorCells_[i], injectors_[i].x()); } // Determine volume of particles to inject this->volumeTotal_ = 0.0; - forAll(mDot_, injectorI) + forAll(injectors_, i) { - this->volumeTotal_ += mDot_[injectorI]/rho_[injectorI]; + this->volumeTotal_ += injectors_[i].mDot()/injectors_[i].rho(); } this->volumeTotal_ *= duration_; } @@ -217,7 +147,7 @@ void Foam::ReactingLookupTableInjection<CloudType>::setPositionAndCell { label injectorI = parcelI*injectorCells_.size()/nParcels; - position = x_[injectorI]; + position = injectors_[injectorI].x(); cellOwner = injectorCells_[injectorI]; } @@ -234,22 +164,22 @@ void Foam::ReactingLookupTableInjection<CloudType>::setProperties label injectorI = parcelI*injectorCells_.size()/nParcels; // set particle velocity - parcel.U() = U_[injectorI]; + parcel.U() = injectors_[injectorI].U(); // set particle diameter - parcel.d() = d_[injectorI]; + parcel.d() = injectors_[injectorI].d(); // set particle density - parcel.rho() = rho_[injectorI]; + parcel.rho() = injectors_[injectorI].rho(); // set particle temperature - parcel.T() = T_[injectorI]; + parcel.T() = injectors_[injectorI].T(); // set particle specific heat capacity - parcel.cp() = cp_[injectorI]; + parcel.cp() = injectors_[injectorI].cp(); // set particle component mass fractions - parcel.Y() = Y_[injectorI]; + parcel.Y() = injectors_[injectorI].Y(); } diff --git a/src/lagrangian/intermediate/submodels/Reacting/InjectionModel/ReactingLookupTableInjection/ReactingLookupTableInjection.H b/src/lagrangian/intermediate/submodels/Reacting/InjectionModel/ReactingLookupTableInjection/ReactingLookupTableInjection.H index f8b6546d5ba203a9dad0b28a2463bc1a1137f790..51882ee37840fa77f12ff6917e1b34717213dd6a 100644 --- a/src/lagrangian/intermediate/submodels/Reacting/InjectionModel/ReactingLookupTableInjection/ReactingLookupTableInjection.H +++ b/src/lagrangian/intermediate/submodels/Reacting/InjectionModel/ReactingLookupTableInjection/ReactingLookupTableInjection.H @@ -30,7 +30,10 @@ Description an injection site. ( - (x y z u v w d rho mDot T cp Y0..YN) + (x y z) (u v w) d rho mDot T cp (Y0..YN) // injector 1 + (x y z) (u v w) d rho mDot T cp (Y0..YN) // injector 2 + ... + (x y z) (u v w) d rho mDot T cp (Y0..YN) // injector N ); where: @@ -41,6 +44,7 @@ Description mDot = mass flow rate [kg/m3] T = temperature [K] cp = specific heat capacity [J/kg/K] + Y = list of mass fractions SourceFiles ReactingLookupTableInjection.C @@ -51,7 +55,7 @@ SourceFiles #define ReactingLookupTableInjection_H #include "InjectionModel.H" -#include "pdf.H" +#include "reactingParcelInjectionDataIOList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -78,36 +82,12 @@ class ReactingLookupTableInjection //- Number of parcels per injector - common to all injection sources const label nParcelsPerSecond_; - //- List of parcel position per injector / [m] - List<point> x_; - - //- List of parcel velocity per injector / [m] - List<vector> U_; - - //- List of parcel diameter per injector / [m] - List<scalar> d_; - - //- List of parcel fluid density pre injector / [kg/m3] - List<scalar> rho_; - - //- List of parcel injection mass flow per injector / [kg/s] - List<scalar> mDot_; - - //- List of parcel temperature flow per injector / [K] - List<scalar> T_; - - //- List of parcel specific heat capacity per injector / [J/kg/K] - List<scalar> cp_; - - //- List of parcel specie mass fractions per injector / [] - List<scalarList> Y_; + //- List of injectors + reactingParcelInjectionDataIOList injectors_; //- List of injector cells per injector List<label> injectorCells_; - //- Number of columns expected in input file - static label INPUT_FILE_COLS; - protected: diff --git a/src/lagrangian/intermediate/submodels/Reacting/InjectionModel/ReactingLookupTableInjection/reactingParcelInjectionData.C b/src/lagrangian/intermediate/submodels/Reacting/InjectionModel/ReactingLookupTableInjection/reactingParcelInjectionData.C new file mode 100644 index 0000000000000000000000000000000000000000..f5ddfe5d59ca1fb9881e2f8b99ba9d1bc85814ae --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Reacting/InjectionModel/ReactingLookupTableInjection/reactingParcelInjectionData.C @@ -0,0 +1,60 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "reactingParcelInjectionData.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(reactingParcelInjectionData, 0); +} + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::reactingParcelInjectionData::reactingParcelInjectionData() +: + thermoParcelInjectionData(), + Y_() +{} + + +Foam::reactingParcelInjectionData::reactingParcelInjectionData +( + const dictionary& dict +) +: + thermoParcelInjectionData(dict), + Y_(dict.lookup("Y")) +{} + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::reactingParcelInjectionData::~reactingParcelInjectionData() +{} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Reacting/InjectionModel/ReactingLookupTableInjection/reactingParcelInjectionData.H b/src/lagrangian/intermediate/submodels/Reacting/InjectionModel/ReactingLookupTableInjection/reactingParcelInjectionData.H new file mode 100644 index 0000000000000000000000000000000000000000..aa038e8fd223bc1dea6aa30bae655591f33dcecc --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Reacting/InjectionModel/ReactingLookupTableInjection/reactingParcelInjectionData.H @@ -0,0 +1,181 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::reactingParcelInjectionData + +Description + Container class to provide injection data for reacting parcels + +SourceFiles + reactingParcelInjectionData.C + +\*---------------------------------------------------------------------------*/ + +#ifndef reactingParcelInjectionData_H +#define reactingParcelInjectionData_H + +#include "thermoParcelInjectionData.H" +#include "scalarList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class reactingParcelInjectionData; + +// Forward declaration of friend functions + +Ostream& operator<< +( + Ostream&, + const reactingParcelInjectionData& +); + +Istream& operator>> +( + Istream&, + reactingParcelInjectionData& +); + +/*---------------------------------------------------------------------------*\ + Class reactingParcelInjectionData Declaration +\*---------------------------------------------------------------------------*/ + +class reactingParcelInjectionData +: + public thermoParcelInjectionData +{ +protected: + + // Parcel properties + + //- List of mass fractions + scalarList Y_; + + +public: + + //- Runtime type information + TypeName("reactingParcelInjectionData"); + + // Constructors + + //- Null constructor + reactingParcelInjectionData(); + + //- Construct from dictionary + reactingParcelInjectionData(const dictionary& dict); + + //- Construct from Istream + reactingParcelInjectionData(Istream& is); + + + //-Destructor + virtual ~reactingParcelInjectionData(); + + + // Access + + //- Return const access to the list of mass fractions + inline const scalarList& Y() const; + + + // Edit + + //- Return access to the mass fractions + inline scalarList& Y(); + + + // I-O + + // Friend Operators + + friend bool operator== + ( + const reactingParcelInjectionData& a, + const reactingParcelInjectionData& b + ) + { + notImplemented + ( + "operator==" + "(" + "const reactingParcelInjectionData&, " + "const reactingParcelInjectionData&" + ")" + ); + + return false; + } + + friend bool operator!= + ( + const reactingParcelInjectionData& a, + const reactingParcelInjectionData& b + ) + { + notImplemented + ( + "operator==" + "(" + "const reactingParcelInjectionData&, " + "const reactingParcelInjectionData&" + ")" + ); + + return false; + } + + //- Ostream operator + friend Ostream& operator<< + ( + Ostream& os, + const reactingParcelInjectionData& data + ); + + //- Istream operator + friend Istream& operator>> + ( + Istream& is, + reactingParcelInjectionData& data + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "reactingParcelInjectionDataI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Reacting/InjectionModel/ReactingLookupTableInjection/reactingParcelInjectionDataI.H b/src/lagrangian/intermediate/submodels/Reacting/InjectionModel/ReactingLookupTableInjection/reactingParcelInjectionDataI.H new file mode 100644 index 0000000000000000000000000000000000000000..6dcf2e76a0177b2b52e960112a222462a06c4fb3 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Reacting/InjectionModel/ReactingLookupTableInjection/reactingParcelInjectionDataI.H @@ -0,0 +1,43 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "reactingParcelInjectionData.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +inline const Foam::scalarList& Foam::reactingParcelInjectionData::Y() const +{ + return Y_; +} + + +inline Foam::scalarList& Foam::reactingParcelInjectionData::Y() +{ + return Y_; +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Reacting/InjectionModel/ReactingLookupTableInjection/reactingParcelInjectionDataIO.C b/src/lagrangian/intermediate/submodels/Reacting/InjectionModel/ReactingLookupTableInjection/reactingParcelInjectionDataIO.C new file mode 100644 index 0000000000000000000000000000000000000000..e4e5427c307d75fbe7de940a39bbd4f7ffb42fa3 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Reacting/InjectionModel/ReactingLookupTableInjection/reactingParcelInjectionDataIO.C @@ -0,0 +1,71 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "reactingParcelInjectionData.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +Foam::reactingParcelInjectionData::reactingParcelInjectionData(Istream& is) +: + thermoParcelInjectionData(is) +{ + is.check("reading Y's"); + is >> Y_; + + is.check("reactingParcelInjectionData(Istream& is)"); +} + + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +Foam::Ostream& Foam::operator<< +( + Ostream& os, + const reactingParcelInjectionData& data +) +{ + os << static_cast<const thermoParcelInjectionData&>(data); + + os << data.Y_; + + return os; +} + + +Foam::Istream& Foam::operator>>(Istream& is, reactingParcelInjectionData& data) +{ + is >> static_cast<thermoParcelInjectionData&>(data); + + is.check("reading Y's"); + is >> data.Y_; + + is.check("operator(Istream&, reactingParcelInjectionData&)"); + + return is; +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Reacting/InjectionModel/ReactingLookupTableInjection/reactingParcelInjectionDataIOList.C b/src/lagrangian/intermediate/submodels/Reacting/InjectionModel/ReactingLookupTableInjection/reactingParcelInjectionDataIOList.C new file mode 100644 index 0000000000000000000000000000000000000000..1325d13bc6d080de04c56e68b4697e1385a66db0 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Reacting/InjectionModel/ReactingLookupTableInjection/reactingParcelInjectionDataIOList.C @@ -0,0 +1,37 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "reactingParcelInjectionDataIOList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + defineTemplateTypeNameAndDebug(IOList<reactingParcelInjectionData>, 0); +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Reacting/InjectionModel/ReactingLookupTableInjection/reactingParcelInjectionDataIOList.H b/src/lagrangian/intermediate/submodels/Reacting/InjectionModel/ReactingLookupTableInjection/reactingParcelInjectionDataIOList.H new file mode 100644 index 0000000000000000000000000000000000000000..530e25757f308727fd3978a3f64e0c0009bddb54 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Reacting/InjectionModel/ReactingLookupTableInjection/reactingParcelInjectionDataIOList.H @@ -0,0 +1,52 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + +Description + +SourceFiles + reactingParcelInjectionDataIOList.C + +\*---------------------------------------------------------------------------*/ + +#ifndef reactingParcelInjectionDataIOList_H +#define reactingParcelInjectionDataIOList_H + +#include "IOList.H" +#include "reactingParcelInjectionData.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef IOList<reactingParcelInjectionData> + reactingParcelInjectionDataIOList; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/ReactingMultiphase/InjectionModel/ReactingMultiphaseLookupTableInjection/ReactingMultiphaseLookupTableInjection.C b/src/lagrangian/intermediate/submodels/ReactingMultiphase/InjectionModel/ReactingMultiphaseLookupTableInjection/ReactingMultiphaseLookupTableInjection.C new file mode 100644 index 0000000000000000000000000000000000000000..377b13307785b759057d867fd311cae7d2d914f3 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/ReactingMultiphase/InjectionModel/ReactingMultiphaseLookupTableInjection/ReactingMultiphaseLookupTableInjection.C @@ -0,0 +1,218 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "ReactingMultiphaseLookupTableInjection.H" + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +template<class CloudType> +Foam::label +Foam::ReactingMultiphaseLookupTableInjection<CloudType>::parcelsToInject +( + const scalar time0, + const scalar time1 +) const +{ + if ((time0 >= 0.0) && (time0 < duration_)) + { + return round(injectorCells_.size()*(time1 - time0)*nParcelsPerSecond_); + } + else + { + return 0; + } +} + + +template<class CloudType> +Foam::scalar +Foam::ReactingMultiphaseLookupTableInjection<CloudType>::volumeToInject +( + const scalar time0, + const scalar time1 +) const +{ + scalar volume = 0.0; + if ((time0 >= 0.0) && (time0 < duration_)) + { + forAll(injectors_, i) + { + volume += injectors_[i].mDot()/injectors_[i].rho()*(time1 - time0); + } + } + + return volume; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class CloudType> +Foam::ReactingMultiphaseLookupTableInjection<CloudType>:: +ReactingMultiphaseLookupTableInjection +( + const dictionary& dict, + CloudType& owner +) +: + InjectionModel<CloudType>(dict, owner, typeName), + inputFileName_(this->coeffDict().lookup("inputFile")), + duration_(readScalar(this->coeffDict().lookup("duration"))), + nParcelsPerSecond_ + ( + readScalar(this->coeffDict().lookup("parcelsPerSecond")) + ), + injectors_ + ( + IOobject + ( + inputFileName_, + owner.db().time().constant(), + owner.db(), + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ), + injectorCells_(0) +{ + // Set/cache the injector cells + injectorCells_.setSize(injectors_.size()); + forAll(injectors_, i) + { + this->findCellAtPosition(injectorCells_[i], injectors_[i].x()); + } + + // Determine volume of particles to inject + this->volumeTotal_ = 0.0; + forAll(injectors_, i) + { + this->volumeTotal_ += injectors_[i].mDot()/injectors_[i].rho(); + } + this->volumeTotal_ *= duration_; +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template<class CloudType> +Foam::ReactingMultiphaseLookupTableInjection<CloudType>:: +~ReactingMultiphaseLookupTableInjection() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class CloudType> +bool Foam::ReactingMultiphaseLookupTableInjection<CloudType>::active() const +{ + return true; +} + + +template<class CloudType> +Foam::scalar +Foam::ReactingMultiphaseLookupTableInjection<CloudType>::timeEnd() const +{ + return this->SOI_ + duration_; +} + + +template<class CloudType> +void Foam::ReactingMultiphaseLookupTableInjection<CloudType>::setPositionAndCell +( + const label parcelI, + const label nParcels, + const scalar time, + vector& position, + label& cellOwner +) +{ + label injectorI = parcelI*injectorCells_.size()/nParcels; + + position = injectors_[injectorI].x(); + cellOwner = injectorCells_[injectorI]; +} + + +template<class CloudType> +void Foam::ReactingMultiphaseLookupTableInjection<CloudType>::setProperties +( + const label parcelI, + const label nParcels, + const scalar, + typename CloudType::parcelType& parcel +) +{ + label injectorI = parcelI*injectorCells_.size()/nParcels; + + // set particle velocity + parcel.U() = injectors_[injectorI].U(); + + // set particle diameter + parcel.d() = injectors_[injectorI].d(); + + // set particle density + parcel.rho() = injectors_[injectorI].rho(); + + // set particle temperature + parcel.T() = injectors_[injectorI].T(); + + // set particle specific heat capacity + parcel.cp() = injectors_[injectorI].cp(); + + // set particle component mass fractions + parcel.Y() = injectors_[injectorI].Y(); + + // set particle gaseous component mass fractions + parcel.YGas() = injectors_[injectorI].YGas(); + + // set particle liquid component mass fractions + parcel.YLiquid() = injectors_[injectorI].YLiquid(); + + // set particle solid component mass fractions + parcel.YSolid() = injectors_[injectorI].YSolid(); +} + + +template<class CloudType> +bool +Foam::ReactingMultiphaseLookupTableInjection<CloudType>::fullyDescribed() const +{ + return true; +} + + +template<class CloudType> +bool Foam::ReactingMultiphaseLookupTableInjection<CloudType>::validInjection +( + const label +) +{ + return true; +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/ReactingMultiphase/InjectionModel/ReactingMultiphaseLookupTableInjection/ReactingMultiphaseLookupTableInjection.H b/src/lagrangian/intermediate/submodels/ReactingMultiphase/InjectionModel/ReactingMultiphaseLookupTableInjection/ReactingMultiphaseLookupTableInjection.H new file mode 100644 index 0000000000000000000000000000000000000000..f7599b2fa78d8df3e0ccf755e1f3377d076a32b5 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/ReactingMultiphase/InjectionModel/ReactingMultiphaseLookupTableInjection/ReactingMultiphaseLookupTableInjection.H @@ -0,0 +1,187 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::ReactingMultiphaseLookupTableInjection + +Description + Particle injection sources read from look-up table. Each row corresponds to + an injection site. + + ( + (x y z) (u v w) d rho mDot T cp (Y0..Y2) (Yg0..YgN) (Yl0..YlN) (Ys0..YsN) + (x y z) (u v w) d rho mDot T cp (Y0..Y2) (Yg0..YgN) (Yl0..YlN) (Ys0..YsN) + ... + (x y z) (u v w) d rho mDot T cp (Y0..Y2) (Yg0..YgN) (Yl0..YlN) (Ys0..YsN) + ); + + where: + x, y, z = global cartesian co-ordinates [m] + u, v, w = global cartesian velocity components [m/s] + d = diameter [m] + rho = density [kg/m3] + mDot = mass flow rate [kg/m3] + T = temperature [K] + cp = specific heat capacity [J/kg/K] + Y(3) = total mass fraction of gas (Y0), liquid (Y1), solid (Y3) + Yg(Ngas) = mass fractions of gaseous components + Yl(Nliq) = mass fractions of liquid components + Ys(Nsld) = mass fractions of solid components + +SourceFiles + ReactingMultiphaseLookupTableInjection.C + +\*---------------------------------------------------------------------------*/ + +#ifndef ReactingMultiphaseLookupTableInjection_H +#define ReactingMultiphaseLookupTableInjection_H + +#include "InjectionModel.H" +#include "reactingMultiphaseParcelInjectionDataIOList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class ReactingMultiphaseLookupTableInjection Declaration +\*---------------------------------------------------------------------------*/ + +template<class CloudType> +class ReactingMultiphaseLookupTableInjection +: + public InjectionModel<CloudType> +{ + // Private data + + //- Name of file containing injector/parcel data + const word inputFileName_; + + //- Injection duration - common to all injection sources + const scalar duration_; + + //- Number of parcels per injector - common to all injection sources + const label nParcelsPerSecond_; + + //- List of injectors + reactingMultiphaseParcelInjectionDataIOList injectors_; + + //- List of injector cells per injector + List<label> injectorCells_; + + +protected: + + // Protected member functions + + //- Number of parcels to introduce over the time step relative to SOI + label parcelsToInject + ( + const scalar time0, + const scalar time1 + ) const; + + //- Volume of parcels to introduce over the time step relative to SOI + scalar volumeToInject + ( + const scalar time0, + const scalar time1 + ) const; + + +public: + + //- Runtime type information + TypeName("ReactingMultiphaseLookupTableInjection"); + + + // Constructors + + //- Construct from dictionary + ReactingMultiphaseLookupTableInjection + ( + const dictionary& dict, + CloudType& owner + ); + + + //- Destructor + virtual ~ReactingMultiphaseLookupTableInjection(); + + + // Member Functions + + //- Flag to indicate whether model activates injection model + bool active() const; + + //- Return the end-of-injection time + scalar timeEnd() const; + + + // Injection geometry + + //- Set the injection position and owner cell + virtual void setPositionAndCell + ( + const label parcelI, + const label nParcels, + const scalar time, + vector& position, + label& cellOwner + ); + + //- Set the parcel properties + virtual void setProperties + ( + const label parcelI, + const label nParcels, + const scalar time, + typename CloudType::parcelType& parcel + ); + + //- Flag to identify whether model fully describes the parcel + virtual bool fullyDescribed() const; + + //- Return flag to identify whether or not injection of parcelI is + // permitted + virtual bool validInjection(const label parcelI); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "ReactingMultiphaseLookupTableInjection.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/ReactingMultiphase/InjectionModel/ReactingMultiphaseLookupTableInjection/reactingMultiphaseParcelInjectionData.C b/src/lagrangian/intermediate/submodels/ReactingMultiphase/InjectionModel/ReactingMultiphaseLookupTableInjection/reactingMultiphaseParcelInjectionData.C new file mode 100644 index 0000000000000000000000000000000000000000..28013467a2f2e8df5197ca05d2df157453feb480 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/ReactingMultiphase/InjectionModel/ReactingMultiphaseLookupTableInjection/reactingMultiphaseParcelInjectionData.C @@ -0,0 +1,67 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "reactingMultiphaseParcelInjectionData.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(reactingMultiphaseParcelInjectionData, 0); +} + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::reactingMultiphaseParcelInjectionData:: +reactingMultiphaseParcelInjectionData() +: + reactingParcelInjectionData(), + YGas_(), + YLiquid_(), + YSolid_() +{} + + +Foam::reactingMultiphaseParcelInjectionData:: +reactingMultiphaseParcelInjectionData +( + const dictionary& dict +) +: + reactingParcelInjectionData(dict), + YGas_(dict.lookup("YGas")), + YLiquid_(dict.lookup("YLiquid")), + YSolid_(dict.lookup("YSolid")) +{} + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::reactingMultiphaseParcelInjectionData:: +~reactingMultiphaseParcelInjectionData() +{} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/ReactingMultiphase/InjectionModel/ReactingMultiphaseLookupTableInjection/reactingMultiphaseParcelInjectionData.H b/src/lagrangian/intermediate/submodels/ReactingMultiphase/InjectionModel/ReactingMultiphaseLookupTableInjection/reactingMultiphaseParcelInjectionData.H new file mode 100644 index 0000000000000000000000000000000000000000..c6a705052e70881a590c3f120701eac342527c7d --- /dev/null +++ b/src/lagrangian/intermediate/submodels/ReactingMultiphase/InjectionModel/ReactingMultiphaseLookupTableInjection/reactingMultiphaseParcelInjectionData.H @@ -0,0 +1,198 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::reactingMultiphaseParcelInjectionData + +Description + Container class to provide injection data for reacting multiphase parcels + +SourceFiles + reactingMultiphaseParcelInjectionData.C + +\*---------------------------------------------------------------------------*/ + +#ifndef reactingMultiphaseParcelInjectionData_H +#define reactingMultiphaseParcelInjectionData_H + +#include "reactingParcelInjectionData.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class reactingMultiphaseParcelInjectionData; + +// Forward declaration of friend functions + +Ostream& operator<< +( + Ostream&, + const reactingMultiphaseParcelInjectionData& +); + +Istream& operator>> +( + Istream&, + reactingMultiphaseParcelInjectionData& +); + +/*---------------------------------------------------------------------------*\ + Class reactingMultiphaseParcelInjectionData Declaration +\*---------------------------------------------------------------------------*/ + +class reactingMultiphaseParcelInjectionData +: + public reactingParcelInjectionData +{ +protected: + + // Parcel properties + + //- List of gaseous mass fractions + scalarList YGas_; + + //- List of liquid mass fractions + scalarList YLiquid_; + + //- List of solid mass fractions + scalarList YSolid_; + + +public: + + //- Runtime type information + TypeName("reactingMultiphaseParcelInjectionData"); + + // Constructors + + //- Null constructor + reactingMultiphaseParcelInjectionData(); + + //- Construct from dictionary + reactingMultiphaseParcelInjectionData(const dictionary& dict); + + //- Construct from Istream + reactingMultiphaseParcelInjectionData(Istream& is); + + + //-Destructor + virtual ~reactingMultiphaseParcelInjectionData(); + + + // Access + + //- Return const access to the list of gaseous mass fractions + inline const scalarList& YGas() const; + + //- Return const access to the list of liquid mass fractions + inline const scalarList& YLiquid() const; + + //- Return const access to the list of solid mass fractions + inline const scalarList& YSolid() const; + + + // Edit + + //- Return access to the gaseous mass fractions + inline scalarList& YGas(); + + //- Return access to the liquid mass fractions + inline scalarList& YLiquid(); + + //- Return access to the solid mass fractions + inline scalarList& YSolid(); + + + // I-O + + // Friend Operators + + friend bool operator== + ( + const reactingMultiphaseParcelInjectionData& a, + const reactingMultiphaseParcelInjectionData& b + ) + { + notImplemented + ( + "operator==" + "(" + "const reactingMultiphaseParcelInjectionData&, " + "const reactingMultiphaseParcelInjectionData&" + ")" + ); + + return false; + } + + friend bool operator!= + ( + const reactingMultiphaseParcelInjectionData& a, + const reactingMultiphaseParcelInjectionData& b + ) + { + notImplemented + ( + "operator==" + "(" + "const reactingMultiphaseParcelInjectionData&, " + "const reactingMultiphaseParcelInjectionData&" + ")" + ); + + return false; + } + + //- Ostream operator + friend Ostream& operator<< + ( + Ostream& os, + const reactingMultiphaseParcelInjectionData& data + ); + + //- Istream operator + friend Istream& operator>> + ( + Istream& is, + reactingMultiphaseParcelInjectionData& data + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "reactingMultiphaseParcelInjectionDataI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/ReactingMultiphase/InjectionModel/ReactingMultiphaseLookupTableInjection/reactingMultiphaseParcelInjectionDataI.H b/src/lagrangian/intermediate/submodels/ReactingMultiphase/InjectionModel/ReactingMultiphaseLookupTableInjection/reactingMultiphaseParcelInjectionDataI.H new file mode 100644 index 0000000000000000000000000000000000000000..79cc4164fd25d95a793fde50db92f7832622030a --- /dev/null +++ b/src/lagrangian/intermediate/submodels/ReactingMultiphase/InjectionModel/ReactingMultiphaseLookupTableInjection/reactingMultiphaseParcelInjectionDataI.H @@ -0,0 +1,70 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "reactingMultiphaseParcelInjectionData.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +inline const Foam::scalarList& +Foam::reactingMultiphaseParcelInjectionData::YGas() const +{ + return YGas_; +} + + +inline const Foam::scalarList& +Foam::reactingMultiphaseParcelInjectionData::YLiquid() const +{ + return YLiquid_; +} + + +inline const Foam::scalarList& +Foam::reactingMultiphaseParcelInjectionData::YSolid() const +{ + return YSolid_; +} + + +inline Foam::scalarList& Foam::reactingMultiphaseParcelInjectionData::YGas() +{ + return YGas_; +} + + +inline Foam::scalarList& Foam::reactingMultiphaseParcelInjectionData::YLiquid() +{ + return YLiquid_; +} + + +inline Foam::scalarList& Foam::reactingMultiphaseParcelInjectionData::YSolid() +{ + return YSolid_; +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/ReactingMultiphase/InjectionModel/ReactingMultiphaseLookupTableInjection/reactingMultiphaseParcelInjectionDataIO.C b/src/lagrangian/intermediate/submodels/ReactingMultiphase/InjectionModel/ReactingMultiphaseLookupTableInjection/reactingMultiphaseParcelInjectionDataIO.C new file mode 100644 index 0000000000000000000000000000000000000000..5c6ec6fbd0b581513d39d9137085e23677ee4913 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/ReactingMultiphase/InjectionModel/ReactingMultiphaseLookupTableInjection/reactingMultiphaseParcelInjectionDataIO.C @@ -0,0 +1,88 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "reactingMultiphaseParcelInjectionData.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +Foam::reactingMultiphaseParcelInjectionData:: +reactingMultiphaseParcelInjectionData(Istream& is) +: + reactingParcelInjectionData(is) +{ + is.check("reading YGas's"); + is >> YGas_; + + is.check("reading YLiquid's"); + is >> YLiquid_; + + is.check("reading YSolid's"); + is >> YSolid_; + + is.check("reactingMultiphaseParcelInjectionData(Istream& is)"); +} + + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +Foam::Ostream& Foam::operator<< +( + Ostream& os, + const reactingMultiphaseParcelInjectionData& data +) +{ + os << static_cast<const reactingParcelInjectionData&>(data); + + os << data.YGas_ << data.YLiquid_ << data.YSolid_; + + return os; +} + + +Foam::Istream& Foam::operator>> +( + Istream& is, + reactingMultiphaseParcelInjectionData& data +) +{ + is >> static_cast<reactingParcelInjectionData&>(data); + + is.check("reading YGas's"); + is >> data.YGas_; + + is.check("reading YLiquid's"); + is >> data.YLiquid_; + + is.check("reading YSolid's"); + is >> data.YSolid_; + + is.check("operator(Istream&, reactingMultiphaseParcelInjectionData&)"); + + return is; +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/ReactingMultiphase/InjectionModel/ReactingMultiphaseLookupTableInjection/reactingMultiphaseParcelInjectionDataIOList.C b/src/lagrangian/intermediate/submodels/ReactingMultiphase/InjectionModel/ReactingMultiphaseLookupTableInjection/reactingMultiphaseParcelInjectionDataIOList.C new file mode 100644 index 0000000000000000000000000000000000000000..821cdfb3c74a8052c00c7e41f95cadc3d41f82d6 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/ReactingMultiphase/InjectionModel/ReactingMultiphaseLookupTableInjection/reactingMultiphaseParcelInjectionDataIOList.C @@ -0,0 +1,37 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "reactingMultiphaseParcelInjectionDataIOList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + defineTemplateTypeNameAndDebug(IOList<reactingMultiphaseParcelInjectionData>, 0); +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/ReactingMultiphase/InjectionModel/ReactingMultiphaseLookupTableInjection/reactingMultiphaseParcelInjectionDataIOList.H b/src/lagrangian/intermediate/submodels/ReactingMultiphase/InjectionModel/ReactingMultiphaseLookupTableInjection/reactingMultiphaseParcelInjectionDataIOList.H new file mode 100644 index 0000000000000000000000000000000000000000..140b5a0b28409f64d36dd45b280c5dfe69db4548 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/ReactingMultiphase/InjectionModel/ReactingMultiphaseLookupTableInjection/reactingMultiphaseParcelInjectionDataIOList.H @@ -0,0 +1,52 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + +Description + +SourceFiles + reactingMultiphaseParcelInjectionDataIOList.C + +\*---------------------------------------------------------------------------*/ + +#ifndef reactingMultiphaseParcelInjectionDataIOList_H +#define reactingMultiphaseParcelInjectionDataIOList_H + +#include "IOList.H" +#include "reactingMultiphaseParcelInjectionData.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef IOList<reactingMultiphaseParcelInjectionData> + reactingMultiphaseParcelInjectionDataIOList; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Thermodynamic/InjectionModel/ThermoLookupTableInjection/ThermoLookupTableInjection.C b/src/lagrangian/intermediate/submodels/Thermodynamic/InjectionModel/ThermoLookupTableInjection/ThermoLookupTableInjection.C index ad7e13b6d20417d9364345d3da04628588241777..92478200242186d83a928abbaa37f3b734244990 100644 --- a/src/lagrangian/intermediate/submodels/Thermodynamic/InjectionModel/ThermoLookupTableInjection/ThermoLookupTableInjection.C +++ b/src/lagrangian/intermediate/submodels/Thermodynamic/InjectionModel/ThermoLookupTableInjection/ThermoLookupTableInjection.C @@ -27,11 +27,6 @@ License #include "ThermoLookupTableInjection.H" #include "scalarIOList.H" -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -template<class CloudType> -Foam::label Foam::ThermoLookupTableInjection<CloudType>::INPUT_FILE_COLS = 11; - // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // template<class CloudType> @@ -62,9 +57,9 @@ Foam::scalar Foam::ThermoLookupTableInjection<CloudType>::volumeToInject scalar volume = 0.0; if ((time0 >= 0.0) && (time0 < duration_)) { - forAll(mDot_, injectorI) + forAll(injectors_, i) { - volume += mDot_[injectorI]/rho_[injectorI]*(time1 - time0); + volume += injectors_[i].mDot()/injectors_[i].rho()*(time1 - time0); } } @@ -88,16 +83,7 @@ Foam::ThermoLookupTableInjection<CloudType>::ThermoLookupTableInjection ( readScalar(this->coeffDict().lookup("parcelsPerSecond")) ), - x_(0), - U_(0), - d_(0), - rho_(0), - mDot_(0), - T_(0), - cp_(0), - injectorCells_(0) -{ - scalarListIOList injectorData + injectors_ ( IOobject ( @@ -107,59 +93,21 @@ Foam::ThermoLookupTableInjection<CloudType>::ThermoLookupTableInjection IOobject::MUST_READ, IOobject::NO_WRITE ) - ); - - x_.setSize(injectorData.size()); - U_.setSize(injectorData.size()); - d_.setSize(injectorData.size()); - rho_.setSize(injectorData.size()); - mDot_.setSize(injectorData.size()); - T_.setSize(injectorData.size()); - cp_.setSize(injectorData.size()); - - // Populate lists - forAll(injectorData, injectorI) - { - if (injectorData[injectorI].size() != INPUT_FILE_COLS) - { - FatalErrorIn - ( - "ThermoLookupTableInjection" - "(" - "const dictionary&," - "CloudType& owner" - ")" - ) << "Incorrect number of entries in injector specification " - << "- found " << injectorData[injectorI].size() - << ", expected " << INPUT_FILE_COLS << ":" << nl - << " x0 x1 x2 u0 u1 u2 d rho mDot T cp" - << nl << exit(FatalError); - } - x_[injectorI].component(0) = injectorData[injectorI][0]; - x_[injectorI].component(1) = injectorData[injectorI][1]; - x_[injectorI].component(2) = injectorData[injectorI][2]; - U_[injectorI].component(0) = injectorData[injectorI][3]; - U_[injectorI].component(1) = injectorData[injectorI][4]; - U_[injectorI].component(2) = injectorData[injectorI][5]; - d_[injectorI] = injectorData[injectorI][6]; - rho_[injectorI] = injectorData[injectorI][7]; - mDot_[injectorI] = injectorData[injectorI][8]; - T_[injectorI] = injectorData[injectorI][9]; - cp_[injectorI] = injectorData[injectorI][10]; - } - + ), + injectorCells_(0) +{ // Set/cache the injector cells - injectorCells_.setSize(injectorData.size()); - forAll(x_, injectorI) + injectorCells_.setSize(injectors_.size()); + forAll(injectors_, i) { - this->findCellAtPosition(injectorCells_[injectorI], x_[injectorI]); + this->findCellAtPosition(injectorCells_[injectorI], injectors_[i].x()); } // Determine volume of particles to inject this->volumeTotal_ = 0.0; - forAll(mDot_, injectorI) + forAll(injectors_, i) { - this->volumeTotal_ += mDot_[injectorI]/rho_[injectorI]; + this->volumeTotal_ += injectors_[i].mDot()/injectors_[i].rho(); } this->volumeTotal_ *= duration_; } @@ -200,7 +148,7 @@ void Foam::ThermoLookupTableInjection<CloudType>::setPositionAndCell { label injectorI = parcelI*injectorCells_.size()/nParcels; - position = x_[injectorI]; + position = injectors_[injectorI].x(); cellOwner = injectorCells_[injectorI]; } @@ -217,19 +165,19 @@ void Foam::ThermoLookupTableInjection<CloudType>::setProperties label injectorI = parcelI*injectorCells_.size()/nParcels; // set particle velocity - parcel.U() = U_[injectorI]; + parcel.U() = injectors_[injectorI].U(); // set particle diameter - parcel.d() = d_[injectorI]; + parcel.d() = injectors_[injectorI].d(); // set particle density - parcel.rho() = rho_[injectorI]; + parcel.rho() = injectors_[injectorI].rho(); // set particle temperature - parcel.T() = T_[injectorI]; + parcel.T() = injectors_[injectorI].T(); // set particle specific heat capacity - parcel.cp() = cp_[injectorI]; + parcel.cp() = injectors_[injectorI].cp(); } diff --git a/src/lagrangian/intermediate/submodels/Thermodynamic/InjectionModel/ThermoLookupTableInjection/ThermoLookupTableInjection.H b/src/lagrangian/intermediate/submodels/Thermodynamic/InjectionModel/ThermoLookupTableInjection/ThermoLookupTableInjection.H index 5c53b0337e2dbfa885cd175846cfd2fb364bcff5..0a8d88f271a6eb7676fb7fad358e516afebf4755 100644 --- a/src/lagrangian/intermediate/submodels/Thermodynamic/InjectionModel/ThermoLookupTableInjection/ThermoLookupTableInjection.H +++ b/src/lagrangian/intermediate/submodels/Thermodynamic/InjectionModel/ThermoLookupTableInjection/ThermoLookupTableInjection.H @@ -30,7 +30,10 @@ Description an injection site. ( - (x y z u v w d rho mDot T cp) + (x y z) (u v w) d rho mDot T cp // injector 1 + (x y z) (u v w) d rho mDot T cp // injector 2 + ... + (x y z) (u v w) d rho mDot T cp // injector N ); where: @@ -51,7 +54,7 @@ SourceFiles #define ThermoLookupTableInjection_H #include "InjectionModel.H" -#include "pdf.H" +#include "kinematicParcelInjectionDataIOList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -78,33 +81,12 @@ class ThermoLookupTableInjection //- Number of parcels per injector - common to all injection sources const label nParcelsPerSecond_; - //- List of parcel position per injector / [m] - List<point> x_; - - //- List of parcel velocity per injector / [m] - List<vector> U_; - - //- List of parcel diameter per injector / [m] - List<scalar> d_; - - //- List of parcel fluid density pre injector / [kg/m3] - List<scalar> rho_; - - //- List of parcel injection mass flow per injector / [kg/s] - List<scalar> mDot_; - - //- List of parcel temperature flow per injector / [K] - List<scalar> T_; - - //- List of parcel specific heat capacity per injector / [J/kg/K] - List<scalar> cp_; + //- List of injectors + kinematicParcelInjectionDataIOList injectors_; //- List of injector cells per injector List<label> injectorCells_; - //- Number of columns expected in input file - static label INPUT_FILE_COLS; - protected: diff --git a/src/lagrangian/intermediate/submodels/Thermodynamic/InjectionModel/ThermoLookupTableInjection/thermoParcelInjectionData.C b/src/lagrangian/intermediate/submodels/Thermodynamic/InjectionModel/ThermoLookupTableInjection/thermoParcelInjectionData.C new file mode 100644 index 0000000000000000000000000000000000000000..d4188563e91bce3c3d63fe9681df92ae793b1315 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Thermodynamic/InjectionModel/ThermoLookupTableInjection/thermoParcelInjectionData.C @@ -0,0 +1,62 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "thermoParcelInjectionData.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(thermoParcelInjectionData, 0); +} + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::thermoParcelInjectionData::thermoParcelInjectionData() +: + kinematicParcelInjectionData(), + T_(0.0), + cp_(0.0) +{} + + +Foam::thermoParcelInjectionData::thermoParcelInjectionData +( + const dictionary& dict +) +: + kinematicParcelInjectionData(dict), + T_(readScalar(dict.lookup("T"))), + cp_(readScalar(dict.lookup("cp"))) +{} + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::thermoParcelInjectionData::~thermoParcelInjectionData() +{} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Thermodynamic/InjectionModel/ThermoLookupTableInjection/thermoParcelInjectionData.H b/src/lagrangian/intermediate/submodels/Thermodynamic/InjectionModel/ThermoLookupTableInjection/thermoParcelInjectionData.H new file mode 100644 index 0000000000000000000000000000000000000000..5bd75838903241256b02bc5978409673b9757887 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Thermodynamic/InjectionModel/ThermoLookupTableInjection/thermoParcelInjectionData.H @@ -0,0 +1,189 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::thermoParcelInjectionData + +Description + Container class to provide injection data for thermodynamic parcels + +SourceFiles + thermoParcelInjectionData.C + +\*---------------------------------------------------------------------------*/ + +#ifndef thermoParcelInjectionData_H +#define thermoParcelInjectionData_H + +#include "kinematicParcelInjectionData.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class thermoParcelInjectionData; + +// Forward declaration of friend functions + +Ostream& operator<< +( + Ostream&, + const thermoParcelInjectionData& +); + +Istream& operator>> +( + Istream&, + thermoParcelInjectionData& +); + +/*---------------------------------------------------------------------------*\ + Class thermoParcelInjectionData Declaration +\*---------------------------------------------------------------------------*/ + +class thermoParcelInjectionData +: + public kinematicParcelInjectionData +{ +protected: + + // Parcel properties + + //- Temperature [K] + scalar T_; + + //- Specific heat capacity [J/kg/K] + scalar cp_; + + +public: + + //- Runtime type information + TypeName("thermoParcelInjectionData"); + + // Constructors + + //- Null constructor + thermoParcelInjectionData(); + + //- Construct from dictionary + thermoParcelInjectionData(const dictionary& dict); + + //- Construct from Istream + thermoParcelInjectionData(Istream& is); + + + //-Destructor + virtual ~thermoParcelInjectionData(); + + + // Access + + //- Return const access to the temperature + inline scalar T() const; + + //- Return const access to the specific heat capacity + inline scalar cp() const; + + + // Edit + + //- Return access to the temperature + inline scalar& T(); + + //- Return access to the specific heat capacity + inline scalar& cp(); + + + // I-O + + // Friend Operators + + friend bool operator== + ( + const thermoParcelInjectionData& a, + const thermoParcelInjectionData& b + ) + { + notImplemented + ( + "operator==" + "(" + "const thermoParcelInjectionData&, " + "const thermoParcelInjectionData&" + ")" + ); + + return false; + } + + friend bool operator!= + ( + const thermoParcelInjectionData& a, + const thermoParcelInjectionData& b + ) + { + notImplemented + ( + "operator==" + "(" + "const thermoParcelInjectionData&, " + "const thermoParcelInjectionData&" + ")" + ); + + return false; + } + + //- Ostream operator + friend Ostream& operator<< + ( + Ostream& os, + const thermoParcelInjectionData& data + ); + + //- Istream operator + friend Istream& operator>> + ( + Istream& is, + thermoParcelInjectionData& data + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "thermoParcelInjectionDataI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Thermodynamic/InjectionModel/ThermoLookupTableInjection/thermoParcelInjectionDataI.H b/src/lagrangian/intermediate/submodels/Thermodynamic/InjectionModel/ThermoLookupTableInjection/thermoParcelInjectionDataI.H new file mode 100644 index 0000000000000000000000000000000000000000..293c5487bf2c7b4aea621942bc8c3429ab3d1a6b --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Thermodynamic/InjectionModel/ThermoLookupTableInjection/thermoParcelInjectionDataI.H @@ -0,0 +1,55 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "thermoParcelInjectionData.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +inline Foam::scalar Foam::thermoParcelInjectionData::T() const +{ + return T_; +} + + +inline Foam::scalar Foam::thermoParcelInjectionData::cp() const +{ + return cp_; +} + + +inline Foam::scalar& Foam::thermoParcelInjectionData::T() +{ + return T_; +} + + +inline Foam::scalar& Foam::thermoParcelInjectionData::cp() +{ + return cp_; +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Thermodynamic/InjectionModel/ThermoLookupTableInjection/thermoParcelInjectionDataIO.C b/src/lagrangian/intermediate/submodels/Thermodynamic/InjectionModel/ThermoLookupTableInjection/thermoParcelInjectionDataIO.C new file mode 100644 index 0000000000000000000000000000000000000000..3546f171ade5297e9e572df580376fb76da93a55 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Thermodynamic/InjectionModel/ThermoLookupTableInjection/thermoParcelInjectionDataIO.C @@ -0,0 +1,77 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "thermoParcelInjectionData.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +Foam::thermoParcelInjectionData::thermoParcelInjectionData(Istream& is) +: + kinematicParcelInjectionData(is) +{ + is.check("reading T"); + is >> T_; + + is.check("reading cp"); + is >> cp_; + + is.check("thermoParcelInjectionData(Istream& is)"); +} + + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +Foam::Ostream& Foam::operator<< +( + Ostream& os, + const thermoParcelInjectionData& data +) +{ + os << static_cast<const kinematicParcelInjectionData&>(data); + + os << data.T_ << data.cp_; + + return os; +} + + +Foam::Istream& Foam::operator>>(Istream& is, thermoParcelInjectionData& data) +{ + is >> static_cast<kinematicParcelInjectionData&>(data); + + is.check("reading T"); + is >> data.T_; + + is.check("reading cp"); + is >> data.cp_; + + is.check("operator(Istream&, thermoParcelInjectionData&)"); + + return is; +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Thermodynamic/InjectionModel/ThermoLookupTableInjection/thermoParcelInjectionDataIOList.C b/src/lagrangian/intermediate/submodels/Thermodynamic/InjectionModel/ThermoLookupTableInjection/thermoParcelInjectionDataIOList.C new file mode 100644 index 0000000000000000000000000000000000000000..c24f92cc4aacd4caaf111ae377ca2b8a99e6c70e --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Thermodynamic/InjectionModel/ThermoLookupTableInjection/thermoParcelInjectionDataIOList.C @@ -0,0 +1,37 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "thermoParcelInjectionDataIOList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + defineTemplateTypeNameAndDebug(IOList<thermoParcelInjectionData>, 0); +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Thermodynamic/InjectionModel/ThermoLookupTableInjection/thermoParcelInjectionDataIOList.H b/src/lagrangian/intermediate/submodels/Thermodynamic/InjectionModel/ThermoLookupTableInjection/thermoParcelInjectionDataIOList.H new file mode 100644 index 0000000000000000000000000000000000000000..e20ea8144003843f2307cc6b8c5d851e875479c5 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Thermodynamic/InjectionModel/ThermoLookupTableInjection/thermoParcelInjectionDataIOList.H @@ -0,0 +1,52 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + +Description + +SourceFiles + thermoParcelInjectionDataIOList.C + +\*---------------------------------------------------------------------------*/ + +#ifndef thermoParcelInjectionDataIOList_H +#define thermoParcelInjectionDataIOList_H + +#include "IOList.H" +#include "thermoParcelInjectionData.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef IOList<thermoParcelInjectionData> + thermoParcelInjectionDataIOList; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoHexMeshDriver.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoHexMeshDriver.C index 76e589c039d18d2b7c47907ac9d24c21bdaca37f..03284173dadb61e3a35a24b258f4fa759a9a5e23 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoHexMeshDriver.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoHexMeshDriver.C @@ -459,16 +459,16 @@ void Foam::autoHexMeshDriver::writeMesh(const string& msg) const mesh_.time().path()/meshRefiner.timeName() ); } - Info<< "Written mesh in = " + Info<< "Wrote mesh in = " << mesh_.time().cpuTimeIncrement() << " s." << endl; } void Foam::autoHexMeshDriver::doMesh() { - Switch wantRefine(dict_.lookup("doRefine")); - Switch wantSnap(dict_.lookup("doSnap")); - Switch wantLayers(dict_.lookup("doLayers")); + const Switch wantRefine(dict_.lookup("doRefine")); + const Switch wantSnap(dict_.lookup("doSnap")); + const Switch wantLayers(dict_.lookup("doLayers")); Info<< "Do refinement : " << wantRefine << nl << "Do snapping : " << wantSnap << nl diff --git a/src/meshTools/Make/files b/src/meshTools/Make/files index ada844b5a5d274f209d64431dfc32e888cb92434..30e68c56a7165018c052d67084be3db7d68aa8ee 100644 --- a/src/meshTools/Make/files +++ b/src/meshTools/Make/files @@ -9,16 +9,17 @@ cellDist/wallPoint/wallPoint.C cellFeatures/cellFeatures.C -coordinateSystems/coordinateSystem.C -coordinateSystems/coordinateSystemNew.C -coordinateSystems/coordinateSystems.C -coordinateSystems/cylindricalCS.C -coordinateSystems/sphericalCS.C -coordinateSystems/parabolicCylindricalCS.C -coordinateSystems/toroidalCS.C -coordinateSystems/coordinateRotation/coordinateRotation.C -coordinateSystems/coordinateRotation/EulerCoordinateRotation.C -coordinateSystems/coordinateRotation/STARCDCoordinateRotation.C +csys = coordinateSystems +$(csys)/coordinateSystem.C +$(csys)/coordinateSystemNew.C +$(csys)/coordinateSystems.C +$(csys)/cylindricalCS.C +$(csys)/sphericalCS.C +$(csys)/parabolicCylindricalCS.C +$(csys)/toroidalCS.C +$(csys)/coordinateRotation/coordinateRotation.C +$(csys)/coordinateRotation/EulerCoordinateRotation.C +$(csys)/coordinateRotation/STARCDCoordinateRotation.C edgeFaceCirculator/edgeFaceCirculator.C diff --git a/src/meshTools/indexedOctree/indexedOctree.H b/src/meshTools/indexedOctree/indexedOctree.H index 6c2bfa3c6e6f1408f6b80dfa6375ab60ba511522..b653dc3e793bb4feca9d522195446e56d7952afe 100644 --- a/src/meshTools/indexedOctree/indexedOctree.H +++ b/src/meshTools/indexedOctree/indexedOctree.H @@ -85,8 +85,7 @@ public: }; - // Tree node. Has up pointer and down pointers. - + //- Tree node. Has up pointer and down pointers. class node { public: diff --git a/src/meshTools/sets/topoSets/cellSet.H b/src/meshTools/sets/topoSets/cellSet.H index 607813ab9cf76e6f5d9e5d5146e9566a9c8725b8..8d01947847519e4cd34d2399f3573871183a0ae5 100644 --- a/src/meshTools/sets/topoSets/cellSet.H +++ b/src/meshTools/sets/topoSets/cellSet.H @@ -51,13 +51,12 @@ class cellSet : public topoSet { - - // Private Member Functions //- Disallow default bitwise copy construct cellSet(const cellSet&); + public: //- Runtime type information @@ -66,7 +65,6 @@ public: // Constructors - //- Construct from IOobject. No checking. cellSet(const IOobject& obj); @@ -161,7 +159,6 @@ public: const primitiveMesh&, const label maxLen ) const; - }; diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C index a9d95a7396899718a7aac37947a0cacea57d63a3..59ae40b2b54264cdecd5621b3e40489d46606dad 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C @@ -49,7 +49,7 @@ sixDoFRigidBodyDisplacementPointPatchVectorField : fixedValuePointPatchField<vector>(p, iF), motion_(), - p0_(p.localPoints()), + initialPoints_(p.localPoints()), rhoInf_(1.0) {} @@ -71,13 +71,13 @@ sixDoFRigidBodyDisplacementPointPatchVectorField updateCoeffs(); } - if (dict.found("p0")) + if (dict.found("initialPoints")) { - p0_ = vectorField("p0", dict , p.size()); + initialPoints_ = vectorField("initialPoints", dict , p.size()); } else { - p0_ = p.localPoints(); + initialPoints_ = p.localPoints(); } } @@ -93,7 +93,7 @@ sixDoFRigidBodyDisplacementPointPatchVectorField : fixedValuePointPatchField<vector>(ptf, p, iF, mapper), motion_(ptf.motion_), - p0_(ptf.p0_, mapper), + initialPoints_(ptf.initialPoints_, mapper), rhoInf_(ptf.rhoInf_) {} @@ -107,7 +107,7 @@ sixDoFRigidBodyDisplacementPointPatchVectorField : fixedValuePointPatchField<vector>(ptf, iF), motion_(ptf.motion_), - p0_(ptf.p0_), + initialPoints_(ptf.initialPoints_), rhoInf_(ptf.rhoInf_) {} @@ -121,7 +121,7 @@ void sixDoFRigidBodyDisplacementPointPatchVectorField::autoMap { fixedValuePointPatchField<vector>::autoMap(m); - p0_.autoMap(m); + initialPoints_.autoMap(m); } @@ -136,7 +136,7 @@ void sixDoFRigidBodyDisplacementPointPatchVectorField::rmap fixedValuePointPatchField<vector>::rmap(sDoFptf, addr); - p0_.rmap(sDoFptf.p0_, addr); + initialPoints_.rmap(sDoFptf.initialPoints_, addr); } @@ -186,7 +186,10 @@ void sixDoFRigidBodyDisplacementPointPatchVectorField::updateCoeffs() t.deltaTValue() ); - Field<vector>::operator=(motion_.currentPosition(p0_) - p0_); + Field<vector>::operator= + ( + motion_.currentPosition(initialPoints_) - initialPoints_ + ); fixedValuePointPatchField<vector>::updateCoeffs(); } @@ -198,7 +201,7 @@ void sixDoFRigidBodyDisplacementPointPatchVectorField::write(Ostream& os) const motion_.write(os); os.writeKeyword("rhoInf") << rhoInf_ << token::END_STATEMENT << nl; - p0_.writeEntry("p0", os); + initialPoints_.writeEntry("initialPoints", os); writeEntry("value", os); } diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.H b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.H index 4cfa63becc1cf2d51507479f391b9b0b4efd2ce2..fee0c157f771cf61213705c3d141b73556a4224f 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.H +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.H @@ -57,8 +57,8 @@ class sixDoFRigidBodyDisplacementPointPatchVectorField //- Six dof motion object sixDoFRigidBodyMotion motion_; - //- Reference positions of points on the patch - pointField p0_; + //- Initial positions of points on the patch + pointField initialPoints_; //- Reference density required by the forces object for // incompressible calculations diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.C b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.C index 2e9abddf5f65c526529d0d43cab3b54b6507771c..c6a738678c51009e072b4aa3a5d8abbdd55fbb69 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.C +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.C @@ -15,7 +15,7 @@ License 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 + FITNESS FOR A PARTICLUAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License @@ -139,11 +139,13 @@ void Foam::sixDoFRigidBodyMotion::applyConstraints(scalar deltaT) << ") exceeded." << nl << exit(FatalError); } - else if (report_) + + Info<< "sixDoFRigidBodyMotion constraints converged in " + << iteration << " iterations" << endl; + + if (report_) { - Info<< "sixDoFRigidBodyMotion constraints converged in " - << iteration << " iterations" - << nl << "Constraint force: " << cFA << nl + Info<< "Constraint force: " << cFA << nl << "Constraint moment: " << cMA << endl; } @@ -169,7 +171,8 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion() constraints_(), constraintNames_(), maxConstraintIterations_(0), - refCentreOfMass_(vector::zero), + initialCentreOfMass_(vector::zero), + initialQ_(I), momentOfInertia_(diagTensor::one*VSMALL), mass_(VSMALL), report_(false) @@ -185,7 +188,8 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion const vector& pi, const vector& tau, scalar mass, - const point& refCentreOfMass, + const point& initialCentreOfMass, + const tensor& initialQ, const diagTensor& momentOfInertia, bool report ) @@ -204,7 +208,8 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion constraints_(), constraintNames_(), maxConstraintIterations_(0), - refCentreOfMass_(refCentreOfMass), + initialCentreOfMass_(initialCentreOfMass), + initialQ_(initialQ), momentOfInertia_(momentOfInertia), mass_(mass), report_(report) @@ -219,7 +224,14 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion(const dictionary& dict) constraints_(), constraintNames_(), maxConstraintIterations_(0), - refCentreOfMass_(dict.lookupOrDefault("refCentreOfMass", centreOfMass())), + initialCentreOfMass_ + ( + dict.lookupOrDefault("initialCentreOfMass", centreOfMass()) + ), + initialQ_ + ( + dict.lookupOrDefault("initialOrientation", Q()) + ), momentOfInertia_(dict.lookup("momentOfInertia")), mass_(readScalar(dict.lookup("mass"))), report_(dict.lookupOrDefault<Switch>("report", false)) @@ -241,7 +253,8 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion constraints_(sDoFRBM.constraints()), constraintNames_(sDoFRBM.constraintNames()), maxConstraintIterations_(sDoFRBM.maxConstraintIterations()), - refCentreOfMass_(sDoFRBM.refCentreOfMass()), + initialCentreOfMass_(sDoFRBM.initialCentreOfMass()), + initialQ_(sDoFRBM.initialQ()), momentOfInertia_(sDoFRBM.momentOfInertia()), mass_(sDoFRBM.mass()), report_(sDoFRBM.report()) @@ -433,7 +446,7 @@ void Foam::sixDoFRigidBodyMotion::updateForce Foam::point Foam::sixDoFRigidBodyMotion::predictedPosition ( - const point& pt, + const point& pInitial, const vector& deltaForce, const vector& deltaMoment, scalar deltaT @@ -449,13 +462,17 @@ Foam::point Foam::sixDoFRigidBodyMotion::predictedPosition rotate(QTemp, piTemp, deltaT); - return (centreOfMassTemp + (QTemp & (pt - refCentreOfMass_))); + return + ( + centreOfMassTemp + + (QTemp & initialQ_.T() & (pInitial - initialCentreOfMass_)) + ); } Foam::vector Foam::sixDoFRigidBodyMotion::predictedOrientation ( - const vector& v, + const vector& vInitial, const vector& deltaMoment, scalar deltaT ) const @@ -466,7 +483,7 @@ Foam::vector Foam::sixDoFRigidBodyMotion::predictedOrientation rotate(QTemp, piTemp, deltaT); - return (QTemp & v); + return (QTemp & initialQ_.T() & vInitial); } diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.H b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.H index 70107dc19cc650b8664248954d63f806ee3c661e..20cbdae929345fc93cdeca7269ca9865b4f01748 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.H +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.H @@ -104,10 +104,14 @@ class sixDoFRigidBodyMotion // constraints label maxConstraintIterations_; - //- Centre of mass of reference state - point refCentreOfMass_; + //- Centre of mass of initial state + point initialCentreOfMass_; + + //- Orientation of initial state + tensor initialQ_; //- Moment of inertia of the body in reference configuration + // (Q = I) diagTensor momentOfInertia_; //- Mass of the body @@ -166,8 +170,11 @@ class sixDoFRigidBodyMotion // constraint iterations inline label maxConstraintIterations() const; - //- Return access to the centre of mass - inline const point& refCentreOfMass() const; + //- Return access to the initial centre of mass + inline const point& initialCentreOfMass() const; + + //- Return access to the initial orientation + inline const tensor& initialQ() const; //- Return access to the orientation inline const tensor& Q() const; @@ -188,7 +195,10 @@ class sixDoFRigidBodyMotion // Edit //- Return access to the centre of mass - inline point& refCentreOfMass(); + inline point& initialCentreOfMass(); + + //- Return access to the centre of mass + inline tensor& initialQ(); //- Return non-const access to the orientation inline tensor& Q(); @@ -223,7 +233,8 @@ public: const vector& pi, const vector& tau, scalar mass, - const point& refCentreOfMass, + const point& initialCentreOfMass, + const tensor& initialQ, const diagTensor& momentOfInertia, bool report = false ); @@ -274,40 +285,43 @@ public: scalar deltaT ); - //- Transform the given reference state pointField by the - // current motion state - inline tmp<pointField> currentPosition(const pointField& refPts) const; - - //- Transform the given reference state point by the current + //- Transform the given initial state pointField by the current // motion state - inline point currentPosition(const point& refPt) const; + inline tmp<pointField> currentPosition + ( + const pointField& pInitial + ) const; - //- Transform the given reference state direction by the current + //- Transform the given initial state point by the current motion + // state + inline point currentPosition(const point& pInitial) const; + + //- Transform the given initial state direction by the current // motion state - inline vector currentOrientation(const vector& refDir) const; + inline vector currentOrientation(const vector& vInitial) const; //- Access the orientation tensor, Q. // globalVector = Q & bodyLocalVector // bodyLocalVector = Q.T() & globalVector - inline const tensor& currentOrientation() const; + inline const tensor& orientation() const; - //- Predict the position of the supplied point after deltaT - // given the current motion state and the additional supplied - // force and moment + //- Predict the position of the supplied initial state point + // after deltaT given the current motion state and the + // additional supplied force and moment point predictedPosition ( - const point& pt, + const point& pInitial, const vector& deltaForce, const vector& deltaMoment, scalar deltaT ) const; - //- Predict the orientation of the supplied vector after deltaT - // given the current motion state and the additional supplied - // moment + //- Predict the orientation of the supplied initial state + // vector after deltaT given the current motion state and the + // additional supplied moment vector predictedOrientation ( - const vector& v, + const vector& vInitial, const vector& deltaMoment, scalar deltaT ) const; diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedAxis/fixedAxis.C b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedAxis/fixedAxis.C index 699849929ab0046de5b15fe92400354fbf5a2fed..5d9d4800d93eb445106e755bb63b79b8ac5ad8d8 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedAxis/fixedAxis.C +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedAxis/fixedAxis.C @@ -97,7 +97,7 @@ bool Foam::sixDoFRigidBodyMotionConstraints::fixedAxis::constrain { rotationAxis /= magRotationAxis; - const tensor& Q = motion.currentOrientation(); + const tensor& Q = motion.orientation(); // Transform rotationAxis to body local system rotationAxis = Q.T() & rotationAxis; diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedOrientation/fixedOrientation.C b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedOrientation/fixedOrientation.C index eb634772c446bfed3b9ab6e427252a3e3f7fabc8..14f8fdadaaf39e00a2a43609d08ceb9807ff72bb 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedOrientation/fixedOrientation.C +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedOrientation/fixedOrientation.C @@ -52,8 +52,7 @@ Foam::sixDoFRigidBodyMotionConstraints::fixedOrientation::fixedOrientation const dictionary& sDoFRBMCDict ) : - sixDoFRigidBodyMotionConstraint(sDoFRBMCDict), - fixedOrientation_() + sixDoFRigidBodyMotionConstraint(sDoFRBMCDict) { read(sDoFRBMCDict); } @@ -99,10 +98,6 @@ bool Foam::sixDoFRigidBodyMotionConstraints::fixedOrientation::constrain deltaT ); - axis = (fixedOrientation_ & axis); - - refDir = (fixedOrientation_ & refDir); - // Removing any axis component from predictedDir predictedDir -= (axis & predictedDir)*axis; @@ -177,23 +172,6 @@ bool Foam::sixDoFRigidBodyMotionConstraints::fixedOrientation::read { sixDoFRigidBodyMotionConstraint::read(sDoFRBMCDict); - fixedOrientation_ = - sDoFRBMCCoeffs_.lookupOrDefault<tensor>("fixedOrientation", I); - - if (mag(mag(fixedOrientation_) - sqrt(3.0)) > 1e-9) - { - FatalErrorIn - ( - "Foam::sixDoFRigidBodyMotionConstraints::fixedOrientation::read" - "(" - "const dictionary& sDoFRBMCDict" - ")" - ) - << "fixedOrientation " << fixedOrientation_ - << " is not a rotation tensor." - << exit(FatalError); - } - return true; } @@ -203,8 +181,6 @@ void Foam::sixDoFRigidBodyMotionConstraints::fixedOrientation::write Ostream& os ) const { - os.writeKeyword("fixedOrientation") - << fixedOrientation_ << token::END_STATEMENT << nl; } // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedOrientation/fixedOrientation.H b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedOrientation/fixedOrientation.H index 8975f6086247f1ec49a640c7ad5c2cd2f5ff0a3f..6aaa50aa6f549266ed7c2f14c0f80e47820c1168 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedOrientation/fixedOrientation.H +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedOrientation/fixedOrientation.H @@ -59,12 +59,6 @@ class fixedOrientation public sixDoFRigidBodyMotionConstraint { - // Private data - - //- Reference orientation where there is no moment - tensor fixedOrientation_; - - public: //- Runtime type information diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionI.H b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionI.H index 4dea5d4688ad6de50129ac63a6a0449bb301e6d2..2335dcf8eb8b900832ab0073494993852bf69d54 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionI.H +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionI.H @@ -133,9 +133,17 @@ inline Foam::label Foam::sixDoFRigidBodyMotion::maxConstraintIterations() const } -inline const Foam::point& Foam::sixDoFRigidBodyMotion::refCentreOfMass() const +inline const Foam::point& +Foam::sixDoFRigidBodyMotion::initialCentreOfMass() const { - return refCentreOfMass_; + return initialCentreOfMass_; +} + + +inline const Foam::tensor& +Foam::sixDoFRigidBodyMotion::initialQ() const +{ + return initialQ_; } @@ -169,9 +177,15 @@ inline const Foam::vector& Foam::sixDoFRigidBodyMotion::tau() const } -inline Foam::point& Foam::sixDoFRigidBodyMotion::refCentreOfMass() +inline Foam::point& Foam::sixDoFRigidBodyMotion::initialCentreOfMass() +{ + return initialCentreOfMass_; +} + + +inline Foam::tensor& Foam::sixDoFRigidBodyMotion::initialQ() { - return refCentreOfMass_; + return initialQ_; } @@ -208,32 +222,40 @@ inline Foam::vector& Foam::sixDoFRigidBodyMotion::tau() // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // inline Foam::tmp<Foam::pointField> -Foam::sixDoFRigidBodyMotion::currentPosition(const pointField& refPts) const +Foam::sixDoFRigidBodyMotion::currentPosition(const pointField& pInitial) const { - return (centreOfMass() + (Q() & (refPts - refCentreOfMass_))); + return + ( + centreOfMass() + + (Q() & initialQ_.T() & (pInitial - initialCentreOfMass_))) + ; } inline Foam::point Foam::sixDoFRigidBodyMotion::currentPosition ( - const point& refPt + const point& pInitial ) const { - return (centreOfMass() + (Q() & (refPt - refCentreOfMass_))); + return + ( + centreOfMass() + + (Q() & initialQ_.T() & (pInitial - initialCentreOfMass_)) + ); } inline Foam::vector Foam::sixDoFRigidBodyMotion::currentOrientation ( - const vector& refDir + const vector& vInitial ) const { - return (Q() & refDir); + return (Q() & initialQ_.T() & vInitial); } inline const Foam::tensor& -Foam::sixDoFRigidBodyMotion::currentOrientation() const +Foam::sixDoFRigidBodyMotion::orientation() const { return Q(); } diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionIO.C b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionIO.C index ab76faa033d35c4476459cfb5816e58e5ad85715..68865c69cbab2aa6284a163b1dd9388d13d7a000 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionIO.C +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionIO.C @@ -33,8 +33,10 @@ void Foam::sixDoFRigidBodyMotion::write(Ostream& os) const { motionState_.write(os); - os.writeKeyword("refCentreOfMass") - << refCentreOfMass_ << token::END_STATEMENT << nl; + os.writeKeyword("initialCentreOfMass") + << initialCentreOfMass_ << token::END_STATEMENT << nl; + os.writeKeyword("initialOrientation") + << initialQ_ << token::END_STATEMENT << nl; os.writeKeyword("momentOfInertia") << momentOfInertia_ << token::END_STATEMENT << nl; os.writeKeyword("mass") @@ -112,7 +114,8 @@ void Foam::sixDoFRigidBodyMotion::write(Ostream& os) const Foam::Istream& Foam::operator>>(Istream& is, sixDoFRigidBodyMotion& sDoFRBM) { is >> sDoFRBM.motionState_ - >> sDoFRBM.refCentreOfMass_ + >> sDoFRBM.initialCentreOfMass_ + >> sDoFRBM.initialQ_ >> sDoFRBM.momentOfInertia_ >> sDoFRBM.mass_; @@ -134,7 +137,8 @@ Foam::Ostream& Foam::operator<< ) { os << sDoFRBM.motionState() - << token::SPACE << sDoFRBM.refCentreOfMass() + << token::SPACE << sDoFRBM.initialCentreOfMass() + << token::SPACE << sDoFRBM.initialQ() << token::SPACE << sDoFRBM.momentOfInertia() << token::SPACE << sDoFRBM.mass(); diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/linearAxialAngularSpring/linearAxialAngularSpring.C b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/linearAxialAngularSpring/linearAxialAngularSpring.C index 16c72280d6e65d303145af1851f3992941696d3e..67f7206e59336528a039da867f8ca3b36e6da1f0 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/linearAxialAngularSpring/linearAxialAngularSpring.C +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/linearAxialAngularSpring/linearAxialAngularSpring.C @@ -86,7 +86,7 @@ Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring::restrain vector oldDir = refQ_ & refDir; - vector newDir = motion.currentOrientation(refDir); + vector newDir = motion.orientation() & refDir; if (mag(oldDir & axis_) > 0.95 || mag(newDir & axis_) > 0.95) { @@ -96,7 +96,7 @@ Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring::restrain vector oldDir = refQ_ & refDir; - vector newDir = motion.currentOrientation(refDir); + vector newDir = motion.orientation() & refDir; } // Removing any axis component from oldDir and newDir and normalising diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/sphericalAngularSpring/sphericalAngularSpring.C b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/sphericalAngularSpring/sphericalAngularSpring.C index c3f4292e7b119f4eff613c754c566a834069c994..43a5e795b62728a14318d34d4a65097018f0b60a 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/sphericalAngularSpring/sphericalAngularSpring.C +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/sphericalAngularSpring/sphericalAngularSpring.C @@ -92,7 +92,7 @@ Foam::sixDoFRigidBodyMotionRestraints::sphericalAngularSpring::restrain refDir[(cmpt + 1) % 3] = 1; - vector newDir = motion.currentOrientation(refDir); + vector newDir = motion.orientation() & refDir; axis = (refQ_ & axis); diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/tabulatedAxialAngularSpring/tabulatedAxialAngularSpring.C b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/tabulatedAxialAngularSpring/tabulatedAxialAngularSpring.C index d5c4a50d667402243303416176935641c369864f..1a173c24455674d03e678b0576de6f0f49ae2f54 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/tabulatedAxialAngularSpring/tabulatedAxialAngularSpring.C +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/tabulatedAxialAngularSpring/tabulatedAxialAngularSpring.C @@ -88,7 +88,7 @@ Foam::sixDoFRigidBodyMotionRestraints::tabulatedAxialAngularSpring::restrain vector oldDir = refQ_ & refDir; - vector newDir = motion.currentOrientation(refDir); + vector newDir = motion.orientation() & refDir; if (mag(oldDir & axis_) > 0.95 || mag(newDir & axis_) > 0.95) { @@ -98,7 +98,7 @@ Foam::sixDoFRigidBodyMotionRestraints::tabulatedAxialAngularSpring::restrain vector oldDir = refQ_ & refDir; - vector newDir = motion.currentOrientation(refDir); + vector newDir = motion.orientation() & refDir; } // Removing any axis component from oldDir and newDir and normalising diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionState.C b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionState.C index cd52b1d142a27179e7721e2e33bf6dcc1c88968e..efdb0c5c223784804db90737afa894c9db85f070 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionState.C +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionState.C @@ -64,11 +64,11 @@ Foam::sixDoFRigidBodyMotionState::sixDoFRigidBodyMotionState ) : centreOfMass_(dict.lookup("centreOfMass")), - Q_(dict.lookupOrDefault("Q", tensor(I))), - v_(dict.lookupOrDefault("v", vector::zero)), - a_(dict.lookupOrDefault("a", vector::zero)), - pi_(dict.lookupOrDefault("pi", vector::zero)), - tau_(dict.lookupOrDefault("tau", vector::zero)) + Q_(dict.lookupOrDefault("orientation", tensor(I))), + v_(dict.lookupOrDefault("velocity", vector::zero)), + a_(dict.lookupOrDefault("acceleration", vector::zero)), + pi_(dict.lookupOrDefault("angularMomentum", vector::zero)), + tau_(dict.lookupOrDefault("torque", vector::zero)) {} diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionStateIO.C b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionStateIO.C index 650a3599910271cef51858af3855c94c576cc34c..fb70e1a28c2411e600de011187a22c4080962689 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionStateIO.C +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionStateIO.C @@ -33,15 +33,15 @@ void Foam::sixDoFRigidBodyMotionState::write(Ostream& os) const { os.writeKeyword("centreOfMass") << centreOfMass_ << token::END_STATEMENT << nl; - os.writeKeyword("Q") + os.writeKeyword("orientation") << Q_ << token::END_STATEMENT << nl; - os.writeKeyword("v") + os.writeKeyword("velocity") << v_ << token::END_STATEMENT << nl; - os.writeKeyword("a") + os.writeKeyword("acceleration") << a_ << token::END_STATEMENT << nl; - os.writeKeyword("pi") + os.writeKeyword("angularMomentum") << pi_ << token::END_STATEMENT << nl; - os.writeKeyword("tau") + os.writeKeyword("torque") << tau_ << token::END_STATEMENT << nl; } diff --git a/src/surfMesh/Make/files b/src/surfMesh/Make/files index 55b12af52e9310cf497cd3c9359452f083d4daee..a62f9c27f956f4c72f650d680ef0f113332f636c 100644 --- a/src/surfMesh/Make/files +++ b/src/surfMesh/Make/files @@ -24,7 +24,6 @@ $(surfaceFormats)/ac3d/AC3DsurfaceFormatCore.C $(surfaceFormats)/ac3d/AC3DsurfaceFormatRunTime.C $(surfaceFormats)/ftr/FTRsurfaceFormatRunTime.C $(surfaceFormats)/gts/GTSsurfaceFormatRunTime.C -$(surfaceFormats)/nas/NASsurfaceFormatCore.C $(surfaceFormats)/nas/NASsurfaceFormatRunTime.C $(surfaceFormats)/obj/OBJsurfaceFormatRunTime.C $(surfaceFormats)/off/OFFsurfaceFormatRunTime.C diff --git a/src/surfMesh/Make/options b/src/surfMesh/Make/options index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..7e207d0dbeaca258e5a72af8b4eb7bacefc0dee8 100644 --- a/src/surfMesh/Make/options +++ b/src/surfMesh/Make/options @@ -0,0 +1,5 @@ +EXE_INC = \ + -I$(LIB_SRC)/fileFormats/lnInclude + +LIB_LIBS = \ + -lfileFormats diff --git a/src/surfMesh/surfaceFormats/nas/NASsurfaceFormat.H b/src/surfMesh/surfaceFormats/nas/NASsurfaceFormat.H index bf57a568a5e74b5fd0bd9943819388840bfeaea0..3708c213bcffe8eeebc1ec843f2b2d4b76877057 100644 --- a/src/surfMesh/surfaceFormats/nas/NASsurfaceFormat.H +++ b/src/surfMesh/surfaceFormats/nas/NASsurfaceFormat.H @@ -47,7 +47,7 @@ SourceFiles #include "MeshedSurface.H" #include "MeshedSurfaceProxy.H" #include "UnsortedMeshedSurface.H" -#include "NASsurfaceFormatCore.H" +#include "NASCore.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -64,7 +64,7 @@ template<class Face> class NASsurfaceFormat : public MeshedSurface<Face>, - public NASsurfaceFormatCore + public NASCore { // Private Member Functions diff --git a/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormatCore.C b/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormatCore.C index 931088ea339e3b4c3793fbb2cb7fefbdc955be72..f85025ec4a6339931ce0f42259c4ce01d8679bf2 100644 --- a/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormatCore.C +++ b/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormatCore.C @@ -31,63 +31,6 @@ License // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -bool Foam::fileFormats::STARCDsurfaceFormatCore::readHeader -( - IFstream& is, - const word& signature -) -{ - if (!is.good()) - { - FatalErrorIn - ( - "fileFormats::STARCDsurfaceFormatCore::readHeader(...)" - ) - << "cannot read " << signature << " " << is.name() - << abort(FatalError); - } - - word header; - label majorVersion; - - string line; - - is.getLine(line); - IStringStream(line)() >> header; - - is.getLine(line); - IStringStream(line)() >> majorVersion; - - // add other checks ... - if (header != signature) - { - Info<< "header mismatch " << signature << " " << is.name() - << endl; - } - - return true; -} - - -void Foam::fileFormats::STARCDsurfaceFormatCore::writeHeader -( - Ostream& os, - const char* filetype -) -{ - os << "PROSTAR_" << filetype << nl - << 4000 - << " " << 0 - << " " << 0 - << " " << 0 - << " " << 0 - << " " << 0 - << " " << 0 - << " " << 0 - << endl; -} - - // parse things like this: // CTNAME 1 someName // don't bother with the older comma-delimited format @@ -102,12 +45,12 @@ Foam::fileFormats::STARCDsurfaceFormatCore::readInpCellTable regExp ctnameRE ( - " *CTNA[^ ]*" // keyword - min 4 chars - "[[:space:]]+" // space delimited - "([0-9]+)" // 1: <digits> - "[[:space:]]+" // space delimited + " *CTNA[^ ]*" // keyword - min 4 chars + "[[:space:]]+" // space delimited + "([0-9]+)" // 1: <digits> + "[[:space:]]+" // space delimited "([^,[:space:]].*)", // 2: <name> - true // ignore case + true // ignore case ); string line; @@ -132,78 +75,6 @@ Foam::fileFormats::STARCDsurfaceFormatCore::readInpCellTable } -bool Foam::fileFormats::STARCDsurfaceFormatCore::readPoints -( - IFstream& is, - pointField& points, - labelList& ids -) -{ - // - // read .vrt file - // ~~~~~~~~~~~~~~ - - if (!is.good()) - { - FatalErrorIn - ( - "fileFormats::STARCDsurfaceFormatCore::readPoints(...)" - ) - << "Cannot read file " << is.name() - << exit(FatalError); - } - - readHeader(is, "PROSTAR_VERTEX"); - - DynamicList<point> dynPoints; - // STAR-CD index of points - DynamicList<label> dynPointId; - - label lineLabel; - while ((is >> lineLabel).good()) - { - scalar x, y, z; - - is >> x >> y >> z; - - dynPoints.append(point(x, y, z)); - dynPointId.append(lineLabel); - } - - points.transfer(dynPoints); - ids.transfer(dynPointId); - - return true; -} - - - -void Foam::fileFormats::STARCDsurfaceFormatCore::writePoints -( - Ostream& os, - const pointField& pointLst -) -{ - writeHeader(os, "VERTEX"); - - // Set the precision of the points data to 10 - os.precision(10); - - // force decimal point for Fortran input - os.setf(std::ios::showpoint); - - forAll(pointLst, ptI) - { - os - << ptI + 1 << " " - << pointLst[ptI].x() << " " - << pointLst[ptI].y() << " " - << pointLst[ptI].z() << nl; - } - os.flush(); -} - - void Foam::fileFormats::STARCDsurfaceFormatCore::writeCase ( Ostream& os, @@ -238,4 +109,3 @@ void Foam::fileFormats::STARCDsurfaceFormatCore::writeCase // ************************************************************************* // - diff --git a/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormatCore.H b/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormatCore.H index 0376d6248edc2f97548f8c48bd484634aedac76d..d99867d18030c21dc9339de504918d2d8efb8bc4 100644 --- a/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormatCore.H +++ b/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormatCore.H @@ -40,6 +40,7 @@ SourceFiles #include "Ostream.H" #include "OFstream.H" #include "MeshedSurface.H" +#include "STARCDCore.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -53,21 +54,15 @@ namespace fileFormats \*---------------------------------------------------------------------------*/ class STARCDsurfaceFormatCore +: + public STARCDCore { protected: // Protected Member Functions - static bool readHeader(IFstream&, const word&); - - static void writeHeader(Ostream&, const char* filetype); - static Map<word> readInpCellTable(IFstream&); - static bool readPoints(IFstream&, pointField&, labelList& ids); - - static void writePoints(Ostream&, const pointField&); - static void writeCase ( Ostream&, diff --git a/src/thermophysicalModels/basic/basicThermo/basicThermo.C b/src/thermophysicalModels/basic/basicThermo/basicThermo.C index 3de20158ad0c345b33e5dd237166c761e0af03e9..f03bcc8289bba92a065410fb8bc23c5374d7b725 100644 --- a/src/thermophysicalModels/basic/basicThermo/basicThermo.C +++ b/src/thermophysicalModels/basic/basicThermo/basicThermo.C @@ -143,7 +143,6 @@ void Foam::basicThermo::eBoundaryCorrection(volScalarField& e) } } - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::basicThermo::basicThermo(const fvMesh& mesh) @@ -300,6 +299,50 @@ Foam::tmp<Foam::scalarField> Foam::basicThermo::h } +Foam::volScalarField& Foam::basicThermo::hs() +{ + notImplemented("basicThermo::hs()"); + return const_cast<volScalarField&>(volScalarField::null()); +} + + +const Foam::volScalarField& Foam::basicThermo::hs() const +{ + notImplemented("basicThermo::hs() const"); + return volScalarField::null(); +} + + +Foam::tmp<Foam::scalarField> Foam::basicThermo::hs +( + const scalarField& T, + const labelList& cells +) const +{ + notImplemented + ( + "basicThermo::hs" + "(const scalarField& T, const labelList& cells) const" + ); + return tmp<scalarField>(NULL); +} + + +Foam::tmp<Foam::scalarField> Foam::basicThermo::hs +( + const scalarField& T, + const label patchi +) const +{ + notImplemented + ( + "basicThermo::hs" + "(const scalarField& T, const label patchi) const" + ); + return tmp<scalarField>(NULL); +} + + Foam::volScalarField& Foam::basicThermo::e() { notImplemented("basicThermo::e()"); diff --git a/src/thermophysicalModels/basic/basicThermo/basicThermo.H b/src/thermophysicalModels/basic/basicThermo/basicThermo.H index 1b5425852530ca30ec9cb6328adb12b777d473ab..1c907edcf9ea3eb915d5a0102010c85abf619fb6 100644 --- a/src/thermophysicalModels/basic/basicThermo/basicThermo.H +++ b/src/thermophysicalModels/basic/basicThermo/basicThermo.H @@ -141,7 +141,7 @@ public: //- Compressibility [s^2/m^2] virtual const volScalarField& psi() const; - //- Enthalpy [J/kg] + //- Total enthalpy [J/kg] // Non-const access allowed for transport equations virtual volScalarField& h(); @@ -162,6 +162,27 @@ public: const label patchi ) const; + //- Sensible enthalpy [J/kg] + // Non-const access allowed for transport equations + virtual volScalarField& hs(); + + //- Enthalpy [J/kg] + virtual const volScalarField& hs() const; + + //- Enthalpy for cell-set [J/kg] + virtual tmp<scalarField> hs + ( + const scalarField& T, + const labelList& cells + ) const; + + //- Enthalpy for patch [J/kg] + virtual tmp<scalarField> hs + ( + const scalarField& T, + const label patchi + ) const; + //- Internal energy [J/kg] // Non-const access allowed for transport equations virtual volScalarField& e(); diff --git a/src/thermophysicalModels/basic/derivedFvPatchFields/fixedEnthalpy/fixedEnthalpyFvPatchScalarField.C b/src/thermophysicalModels/basic/derivedFvPatchFields/fixedEnthalpy/fixedEnthalpyFvPatchScalarField.C index 19e345abe0b321bcfd619c1068a28417539a4b16..4679801fd334e4fba208e7b83562c330dfef2e67 100644 --- a/src/thermophysicalModels/basic/derivedFvPatchFields/fixedEnthalpy/fixedEnthalpyFvPatchScalarField.C +++ b/src/thermophysicalModels/basic/derivedFvPatchFields/fixedEnthalpy/fixedEnthalpyFvPatchScalarField.C @@ -30,14 +30,9 @@ License #include "volFields.H" #include "basicThermo.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -fixedEnthalpyFvPatchScalarField::fixedEnthalpyFvPatchScalarField +Foam::fixedEnthalpyFvPatchScalarField::fixedEnthalpyFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF @@ -47,7 +42,7 @@ fixedEnthalpyFvPatchScalarField::fixedEnthalpyFvPatchScalarField {} -fixedEnthalpyFvPatchScalarField::fixedEnthalpyFvPatchScalarField +Foam::fixedEnthalpyFvPatchScalarField::fixedEnthalpyFvPatchScalarField ( const fixedEnthalpyFvPatchScalarField& ptf, const fvPatch& p, @@ -59,7 +54,7 @@ fixedEnthalpyFvPatchScalarField::fixedEnthalpyFvPatchScalarField {} -fixedEnthalpyFvPatchScalarField::fixedEnthalpyFvPatchScalarField +Foam::fixedEnthalpyFvPatchScalarField::fixedEnthalpyFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, @@ -70,7 +65,7 @@ fixedEnthalpyFvPatchScalarField::fixedEnthalpyFvPatchScalarField {} -fixedEnthalpyFvPatchScalarField::fixedEnthalpyFvPatchScalarField +Foam::fixedEnthalpyFvPatchScalarField::fixedEnthalpyFvPatchScalarField ( const fixedEnthalpyFvPatchScalarField& tppsf ) @@ -79,7 +74,7 @@ fixedEnthalpyFvPatchScalarField::fixedEnthalpyFvPatchScalarField {} -fixedEnthalpyFvPatchScalarField::fixedEnthalpyFvPatchScalarField +Foam::fixedEnthalpyFvPatchScalarField::fixedEnthalpyFvPatchScalarField ( const fixedEnthalpyFvPatchScalarField& tppsf, const DimensionedField<scalar, volMesh>& iF @@ -91,7 +86,7 @@ fixedEnthalpyFvPatchScalarField::fixedEnthalpyFvPatchScalarField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void fixedEnthalpyFvPatchScalarField::updateCoeffs() +void Foam::fixedEnthalpyFvPatchScalarField::updateCoeffs() { if (updated()) { @@ -109,7 +104,14 @@ void fixedEnthalpyFvPatchScalarField::updateCoeffs() const_cast<fvPatchScalarField&>(thermo.T().boundaryField()[patchi]); Tw.evaluate(); - operator==(thermo.h(Tw, patchi)); + if (dimensionedInternalField().name() == "h") + { + operator==(thermo.h(Tw, patchi)); + } + else + { + operator==(thermo.hs(Tw, patchi)); + } fixedValueFvPatchScalarField::updateCoeffs(); } @@ -117,10 +119,14 @@ void fixedEnthalpyFvPatchScalarField::updateCoeffs() // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -makePatchTypeField(fvPatchScalarField, fixedEnthalpyFvPatchScalarField); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + fixedEnthalpyFvPatchScalarField + ); +} -} // End namespace Foam // ************************************************************************* // diff --git a/src/thermophysicalModels/basic/derivedFvPatchFields/fixedEnthalpy/fixedEnthalpyFvPatchScalarField.H b/src/thermophysicalModels/basic/derivedFvPatchFields/fixedEnthalpy/fixedEnthalpyFvPatchScalarField.H index 725ca85df22258892d208a8112f9c5c4244df041..654b5c1af6e2b049a35324cf54e5309bccd6c6ca 100644 --- a/src/thermophysicalModels/basic/derivedFvPatchFields/fixedEnthalpy/fixedEnthalpyFvPatchScalarField.H +++ b/src/thermophysicalModels/basic/derivedFvPatchFields/fixedEnthalpy/fixedEnthalpyFvPatchScalarField.H @@ -44,7 +44,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class fixedEnthalpyFvPatchScalarField Declaration + Class fixedEnthalpyFvPatchScalarField Declaration \*---------------------------------------------------------------------------*/ class fixedEnthalpyFvPatchScalarField diff --git a/src/thermophysicalModels/basic/derivedFvPatchFields/gradientEnthalpy/gradientEnthalpyFvPatchScalarField.C b/src/thermophysicalModels/basic/derivedFvPatchFields/gradientEnthalpy/gradientEnthalpyFvPatchScalarField.C index ed3a4a6ca34ca13267aaafb4bd1273cae5966c2f..cb9b74020f5dfd19281b241eb24e5662fe9ba7d3 100644 --- a/src/thermophysicalModels/basic/derivedFvPatchFields/gradientEnthalpy/gradientEnthalpyFvPatchScalarField.C +++ b/src/thermophysicalModels/basic/derivedFvPatchFields/gradientEnthalpy/gradientEnthalpyFvPatchScalarField.C @@ -30,14 +30,9 @@ License #include "volFields.H" #include "basicThermo.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -gradientEnthalpyFvPatchScalarField::gradientEnthalpyFvPatchScalarField +Foam::gradientEnthalpyFvPatchScalarField::gradientEnthalpyFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF @@ -47,7 +42,7 @@ gradientEnthalpyFvPatchScalarField::gradientEnthalpyFvPatchScalarField {} -gradientEnthalpyFvPatchScalarField::gradientEnthalpyFvPatchScalarField +Foam::gradientEnthalpyFvPatchScalarField::gradientEnthalpyFvPatchScalarField ( const gradientEnthalpyFvPatchScalarField& ptf, const fvPatch& p, @@ -59,7 +54,7 @@ gradientEnthalpyFvPatchScalarField::gradientEnthalpyFvPatchScalarField {} -gradientEnthalpyFvPatchScalarField::gradientEnthalpyFvPatchScalarField +Foam::gradientEnthalpyFvPatchScalarField::gradientEnthalpyFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, @@ -70,7 +65,7 @@ gradientEnthalpyFvPatchScalarField::gradientEnthalpyFvPatchScalarField {} -gradientEnthalpyFvPatchScalarField::gradientEnthalpyFvPatchScalarField +Foam::gradientEnthalpyFvPatchScalarField::gradientEnthalpyFvPatchScalarField ( const gradientEnthalpyFvPatchScalarField& tppsf ) @@ -79,7 +74,7 @@ gradientEnthalpyFvPatchScalarField::gradientEnthalpyFvPatchScalarField {} -gradientEnthalpyFvPatchScalarField::gradientEnthalpyFvPatchScalarField +Foam::gradientEnthalpyFvPatchScalarField::gradientEnthalpyFvPatchScalarField ( const gradientEnthalpyFvPatchScalarField& tppsf, const DimensionedField<scalar, volMesh>& iF @@ -91,7 +86,7 @@ gradientEnthalpyFvPatchScalarField::gradientEnthalpyFvPatchScalarField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void gradientEnthalpyFvPatchScalarField::updateCoeffs() +void Foam::gradientEnthalpyFvPatchScalarField::updateCoeffs() { if (updated()) { @@ -110,12 +105,24 @@ void gradientEnthalpyFvPatchScalarField::updateCoeffs() Tw.evaluate(); - gradient() = thermo.Cp(Tw, patchi)*Tw.snGrad() - + patch().deltaCoeffs()* + if (dimensionedInternalField().name() == "h") + { + gradient() = thermo.Cp(Tw, patchi)*Tw.snGrad() + + patch().deltaCoeffs()* ( thermo.h(Tw, patchi) - thermo.h(Tw, patch().faceCells()) ); + } + else + { + gradient() = thermo.Cp(Tw, patchi)*Tw.snGrad() + + patch().deltaCoeffs()* + ( + thermo.hs(Tw, patchi) + - thermo.hs(Tw, patch().faceCells()) + ); + } fixedGradientFvPatchScalarField::updateCoeffs(); } @@ -123,10 +130,14 @@ void gradientEnthalpyFvPatchScalarField::updateCoeffs() // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -makePatchTypeField(fvPatchScalarField, gradientEnthalpyFvPatchScalarField); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + gradientEnthalpyFvPatchScalarField + ); +} -} // End namespace Foam // ************************************************************************* // diff --git a/src/thermophysicalModels/basic/derivedFvPatchFields/mixedEnthalpy/mixedEnthalpyFvPatchScalarField.C b/src/thermophysicalModels/basic/derivedFvPatchFields/mixedEnthalpy/mixedEnthalpyFvPatchScalarField.C index 3d64c9a0d221c9ce4f39fde82853ef321f5fbd93..cfe404d38e845fb44f89deff045fc46a17a17092 100644 --- a/src/thermophysicalModels/basic/derivedFvPatchFields/mixedEnthalpy/mixedEnthalpyFvPatchScalarField.C +++ b/src/thermophysicalModels/basic/derivedFvPatchFields/mixedEnthalpy/mixedEnthalpyFvPatchScalarField.C @@ -30,14 +30,9 @@ License #include "volFields.H" #include "basicThermo.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -mixedEnthalpyFvPatchScalarField::mixedEnthalpyFvPatchScalarField +Foam::mixedEnthalpyFvPatchScalarField::mixedEnthalpyFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF @@ -51,7 +46,7 @@ mixedEnthalpyFvPatchScalarField::mixedEnthalpyFvPatchScalarField } -mixedEnthalpyFvPatchScalarField::mixedEnthalpyFvPatchScalarField +Foam::mixedEnthalpyFvPatchScalarField::mixedEnthalpyFvPatchScalarField ( const mixedEnthalpyFvPatchScalarField& ptf, const fvPatch& p, @@ -63,7 +58,7 @@ mixedEnthalpyFvPatchScalarField::mixedEnthalpyFvPatchScalarField {} -mixedEnthalpyFvPatchScalarField::mixedEnthalpyFvPatchScalarField +Foam::mixedEnthalpyFvPatchScalarField::mixedEnthalpyFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, @@ -74,7 +69,7 @@ mixedEnthalpyFvPatchScalarField::mixedEnthalpyFvPatchScalarField {} -mixedEnthalpyFvPatchScalarField::mixedEnthalpyFvPatchScalarField +Foam::mixedEnthalpyFvPatchScalarField::mixedEnthalpyFvPatchScalarField ( const mixedEnthalpyFvPatchScalarField& tppsf ) @@ -83,7 +78,7 @@ mixedEnthalpyFvPatchScalarField::mixedEnthalpyFvPatchScalarField {} -mixedEnthalpyFvPatchScalarField::mixedEnthalpyFvPatchScalarField +Foam::mixedEnthalpyFvPatchScalarField::mixedEnthalpyFvPatchScalarField ( const mixedEnthalpyFvPatchScalarField& tppsf, const DimensionedField<scalar, volMesh>& iF @@ -95,7 +90,7 @@ mixedEnthalpyFvPatchScalarField::mixedEnthalpyFvPatchScalarField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void mixedEnthalpyFvPatchScalarField::updateCoeffs() +void Foam::mixedEnthalpyFvPatchScalarField::updateCoeffs() { if (updated()) { @@ -117,13 +112,27 @@ void mixedEnthalpyFvPatchScalarField::updateCoeffs() Tw.evaluate(); valueFraction() = Tw.valueFraction(); - refValue() = thermo.h(Tw.refValue(), patchi); - refGrad() = thermo.Cp(Tw, patchi)*Tw.refGrad() - + patch().deltaCoeffs()* - ( + + if (dimensionedInternalField().name() == "h") + { + refValue() = thermo.h(Tw.refValue(), patchi); + refGrad() = thermo.Cp(Tw, patchi)*Tw.refGrad() + + patch().deltaCoeffs()* + ( thermo.h(Tw, patchi) - thermo.h(Tw, patch().faceCells()) - ); + ); + } + else + { + refValue() = thermo.hs(Tw.refValue(), patchi); + refGrad() = thermo.Cp(Tw, patchi)*Tw.refGrad() + + patch().deltaCoeffs()* + ( + thermo.hs(Tw, patchi) + - thermo.hs(Tw, patch().faceCells()) + ); + } mixedFvPatchScalarField::updateCoeffs(); } @@ -131,10 +140,14 @@ void mixedEnthalpyFvPatchScalarField::updateCoeffs() // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -makePatchTypeField(fvPatchScalarField, mixedEnthalpyFvPatchScalarField); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + mixedEnthalpyFvPatchScalarField + ); +} -} // End namespace Foam // ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/radiationModel/radiationModel/radiationModel.C b/src/thermophysicalModels/radiation/radiationModel/radiationModel/radiationModel.C index be93dc011eddef10cb16c01d0348a0253cf6f224..d1f844f5925405ec492fb22fef09744d5290bc08 100644 --- a/src/thermophysicalModels/radiation/radiationModel/radiationModel/radiationModel.C +++ b/src/thermophysicalModels/radiation/radiationModel/radiationModel/radiationModel.C @@ -156,4 +156,22 @@ Foam::tmp<Foam::fvScalarMatrix> Foam::radiation::radiationModel::Sh } +Foam::tmp<Foam::fvScalarMatrix> Foam::radiation::radiationModel::Shs +( + basicThermo& thermo +) const +{ + volScalarField& hs = thermo.hs(); + const volScalarField cp = thermo.Cp(); + const volScalarField T3 = pow3(T_); + + return + ( + Ru() + - fvm::Sp(4.0*Rp()*T3/cp, hs) + - Rp()*T3*(T_ - 4.0*hs/cp) + ); +} + + // ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/radiationModel/radiationModel/radiationModel.H b/src/thermophysicalModels/radiation/radiationModel/radiationModel/radiationModel.H index aae443461e1955fd61c7781d94d0cf0bddf8f9d2..3e1a8019cf4da2c26957b93b70c60e30f96424a4 100644 --- a/src/thermophysicalModels/radiation/radiationModel/radiationModel/radiationModel.H +++ b/src/thermophysicalModels/radiation/radiationModel/radiationModel/radiationModel.H @@ -163,7 +163,7 @@ public: virtual void calculate() = 0; //- Read radiationProperties dictionary - virtual bool read(); + virtual bool read() = 0; // Access @@ -176,6 +176,9 @@ public: //- Enthalpy source term virtual tmp<fvScalarMatrix> Sh(basicThermo& thermo) const; + + //- Sensible enthalpy source term + virtual tmp<fvScalarMatrix> Shs(basicThermo& thermo) const; }; @@ -189,4 +192,3 @@ public: #endif // ************************************************************************* // - diff --git a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinLexer.L b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinLexer.L index ec6ea77ec115f94914876ee34c15997a6ea3b6d9..5c704720ae49f824d890a0869ca388653f586824 100644 --- a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinLexer.L +++ b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinLexer.L @@ -309,8 +309,8 @@ List<specieElement> currentSpecieComposition(5); scalar currentLowT = 0; scalar currentHighT = 0; scalar currentCommonT = 0; -gasThermoPhysics::coeffArray highCpCoeffs; -gasThermoPhysics::coeffArray lowCpCoeffs; +gasThermoPhysics::coeffArray highCpCoeffs = {0, 0, 0, 0, 0, 0, 0}; +gasThermoPhysics::coeffArray lowCpCoeffs = {0, 0, 0, 0, 0, 0, 0}; gasReaction::specieCoeffs currentSpecieCoeff; diff --git a/src/thermophysicalModels/reactionThermo/combustionThermo/hCombustionThermo/hCombustionThermo.H b/src/thermophysicalModels/reactionThermo/combustionThermo/hCombustionThermo/hCombustionThermo.H index b4b66b55bdb3dcefc0ad5143773cb400e03d2f78..d6b1ff7069cbf4c26b5b8284d3ca406480afe409 100644 --- a/src/thermophysicalModels/reactionThermo/combustionThermo/hCombustionThermo/hCombustionThermo.H +++ b/src/thermophysicalModels/reactionThermo/combustionThermo/hCombustionThermo/hCombustionThermo.H @@ -128,9 +128,6 @@ public: } - //- Sensible enthalpy [J/kg] - virtual tmp<volScalarField> hs() const = 0; - //- Chemical enthalpy [J/kg] virtual tmp<volScalarField> hc() const = 0; diff --git a/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hPsiMixtureThermo/hPsiMixtureThermo.C b/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hPsiMixtureThermo/hPsiMixtureThermo.C index 5a788049a62d2a649e1761ca4ae1df31f9d80047..d354b3a98600b0a06c841e9c7c2c693b89063e10 100644 --- a/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hPsiMixtureThermo/hPsiMixtureThermo.C +++ b/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hPsiMixtureThermo/hPsiMixtureThermo.C @@ -155,53 +155,6 @@ void Foam::hPsiMixtureThermo<MixtureType>::correct() } -template<class MixtureType> -Foam::tmp<Foam::volScalarField> -Foam::hPsiMixtureThermo<MixtureType>::hs() const -{ - const fvMesh& mesh = T_.mesh(); - - tmp<volScalarField> ths - ( - new volScalarField - ( - IOobject - ( - "hs", - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh, - h_.dimensions() - ) - ); - - volScalarField& hsf = ths(); - scalarField& hsCells = hsf.internalField(); - const scalarField& TCells = T_.internalField(); - - forAll(TCells, celli) - { - hsCells[celli] = this->cellMixture(celli).Hs(TCells[celli]); - } - - forAll(T_.boundaryField(), patchi) - { - scalarField& hsp = hsf.boundaryField()[patchi]; - const scalarField& Tp = T_.boundaryField()[patchi]; - - forAll(Tp, facei) - { - hsp[facei] = this->patchFaceMixture(patchi, facei).Hs(Tp[facei]); - } - } - - return ths; -} - - template<class MixtureType> Foam::tmp<Foam::volScalarField> Foam::hPsiMixtureThermo<MixtureType>::hc() const diff --git a/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hPsiMixtureThermo/hPsiMixtureThermo.H b/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hPsiMixtureThermo/hPsiMixtureThermo.H index 64503284478016985773a5cef53b5de87af8d299..a30a0c1465af946f99145ff9a3d80bf177ecfb94 100644 --- a/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hPsiMixtureThermo/hPsiMixtureThermo.H +++ b/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hPsiMixtureThermo/hPsiMixtureThermo.H @@ -94,9 +94,6 @@ public: //- Update properties virtual void correct(); - //- Sensible enthalpy [J/kg] - virtual tmp<volScalarField> hs() const; - //- Chemical enthalpy [J/kg] virtual tmp<volScalarField> hc() const; diff --git a/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hhuMixtureThermo/hhuMixtureThermo.C b/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hhuMixtureThermo/hhuMixtureThermo.C index 0af469ecf910cff475c9f37738e85fd6f84fb389..6d7245c044051c6751ae7afc9b7eb7a8b4403ab4 100644 --- a/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hhuMixtureThermo/hhuMixtureThermo.C +++ b/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hhuMixtureThermo/hhuMixtureThermo.C @@ -174,54 +174,6 @@ void Foam::hhuMixtureThermo<MixtureType>::correct() } -template<class MixtureType> -Foam::tmp<Foam::volScalarField> -Foam::hhuMixtureThermo<MixtureType>::hs() const -{ - const fvMesh& mesh = T_.mesh(); - - tmp<volScalarField> ths - ( - new volScalarField - ( - IOobject - ( - "hs", - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh, - h_.dimensions() - ) - ); - - volScalarField& hsf = ths(); - - scalarField& hsCells = hsf.internalField(); - const scalarField& TCells = T_.internalField(); - - forAll(TCells, celli) - { - hsCells[celli] = this->cellMixture(celli).Hs(TCells[celli]); - } - - forAll(T_.boundaryField(), patchi) - { - scalarField& hsp = hsf.boundaryField()[patchi]; - const scalarField& Tp = T_.boundaryField()[patchi]; - - forAll(Tp, facei) - { - hsp[facei] = this->patchFaceMixture(patchi, facei).Hs(Tp[facei]); - } - } - - return ths; -} - - template<class MixtureType> Foam::tmp<Foam::volScalarField> Foam::hhuMixtureThermo<MixtureType>::hc() const diff --git a/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hhuMixtureThermo/hhuMixtureThermo.H b/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hhuMixtureThermo/hhuMixtureThermo.H index 5e9834e86c086b036855efa7f9ba3ae66a1a0e33..c55e0a9216a4616a6ce97ac3ba9810e28387e808 100644 --- a/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hhuMixtureThermo/hhuMixtureThermo.H +++ b/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hhuMixtureThermo/hhuMixtureThermo.H @@ -36,8 +36,6 @@ SourceFiles #ifndef hhuMixtureThermo_H #define hhuMixtureThermo_H -//#include "hPsiMixtureThermo.H" - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -94,9 +92,6 @@ public: //- Update properties virtual void correct(); - //- Sensible enthalpy [J/kg] - virtual tmp<volScalarField> hs() const; - //- Chemical enthalpy [J/kg] virtual tmp<volScalarField> hc() const; diff --git a/src/thermophysicalModels/reactionThermo/mixtures/basicMultiComponentMixture/basicMultiComponentMixture.H b/src/thermophysicalModels/reactionThermo/mixtures/basicMultiComponentMixture/basicMultiComponentMixture.H index 4a83754c0ff910f9edfb615ab12f350198fa602e..f590e16d6952c15cb04988ac0df047f390e6d4fa 100644 --- a/src/thermophysicalModels/reactionThermo/mixtures/basicMultiComponentMixture/basicMultiComponentMixture.H +++ b/src/thermophysicalModels/reactionThermo/mixtures/basicMultiComponentMixture/basicMultiComponentMixture.H @@ -26,7 +26,8 @@ Class Foam::basicMultiComponentMixture Description - combustion mixture + Multi-component mixture. Provides a list of mass fraction fields and helper + functions to query mixture composition. SourceFiles basicMultiComponentMixture.C diff --git a/src/thermophysicalModels/reactionThermo/reactionThermo/hReactionThermo/hReactionThermo.H b/src/thermophysicalModels/reactionThermo/reactionThermo/hReactionThermo/hReactionThermo.H index 3d5c37614c3c16e3ec5fd7786bc667da322bb900..f2319efa4ff2839a5af01d6b7cde0a9cb5311ecd 100644 --- a/src/thermophysicalModels/reactionThermo/reactionThermo/hReactionThermo/hReactionThermo.H +++ b/src/thermophysicalModels/reactionThermo/reactionThermo/hReactionThermo/hReactionThermo.H @@ -128,9 +128,6 @@ public: } - //- Sensible enthalpy [J/kg] - virtual tmp<volScalarField> hs() const = 0; - //- Chemical enthalpy [J/kg] virtual tmp<volScalarField> hc() const = 0; diff --git a/src/thermophysicalModels/reactionThermo/reactionThermo/mixtureThermos/hRhoMixtureThermo/hRhoMixtureThermo.C b/src/thermophysicalModels/reactionThermo/reactionThermo/mixtureThermos/hRhoMixtureThermo/hRhoMixtureThermo.C index 9cbf9202dee94885edbc428ad5d4f51a10d2a111..e12fadf8a1e86c91f3eba988e76dee9f26932097 100644 --- a/src/thermophysicalModels/reactionThermo/reactionThermo/mixtureThermos/hRhoMixtureThermo/hRhoMixtureThermo.C +++ b/src/thermophysicalModels/reactionThermo/reactionThermo/mixtureThermos/hRhoMixtureThermo/hRhoMixtureThermo.C @@ -154,53 +154,6 @@ void Foam::hRhoMixtureThermo<MixtureType>::correct() } -template<class MixtureType> -Foam::tmp<Foam::volScalarField> -Foam::hRhoMixtureThermo<MixtureType>::hs() const -{ - const fvMesh& mesh = T_.mesh(); - - tmp<volScalarField> ths - ( - new volScalarField - ( - IOobject - ( - "hs", - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh, - h_.dimensions() - ) - ); - - volScalarField& hsf = ths(); - scalarField& hsCells = hsf.internalField(); - const scalarField& TCells = T_.internalField(); - - forAll(TCells, celli) - { - hsCells[celli] = this->cellMixture(celli).Hs(TCells[celli]); - } - - forAll(T_.boundaryField(), patchi) - { - scalarField& hsp = hsf.boundaryField()[patchi]; - const scalarField& Tp = T_.boundaryField()[patchi]; - - forAll(Tp, facei) - { - hsp[facei] = this->patchFaceMixture(patchi, facei).Hs(Tp[facei]); - } - } - - return ths; -} - - template<class MixtureType> Foam::tmp<Foam::volScalarField> Foam::hRhoMixtureThermo<MixtureType>::hc() const diff --git a/src/thermophysicalModels/reactionThermo/reactionThermo/mixtureThermos/hRhoMixtureThermo/hRhoMixtureThermo.H b/src/thermophysicalModels/reactionThermo/reactionThermo/mixtureThermos/hRhoMixtureThermo/hRhoMixtureThermo.H index 570f696bac41be646b72fdf814b648c1811b285f..28e95270d91c63fee986c1bf258ffe355f9ffe6e 100644 --- a/src/thermophysicalModels/reactionThermo/reactionThermo/mixtureThermos/hRhoMixtureThermo/hRhoMixtureThermo.H +++ b/src/thermophysicalModels/reactionThermo/reactionThermo/mixtureThermos/hRhoMixtureThermo/hRhoMixtureThermo.H @@ -94,9 +94,6 @@ public: //- Update properties virtual void correct(); - //- Sensible enthalpy [J/kg] - virtual tmp<volScalarField> hs() const; - //- Chemical enthalpy [J/kg] virtual tmp<volScalarField> hc() const; diff --git a/src/thermophysicalModels/specie/thermo/specieThermo/specieThermo.H b/src/thermophysicalModels/specie/thermo/specieThermo/specieThermo.H index 560f8f4145f7e9faed0f176f3a8946a1ae752e9c..7ec9d97959625189c1ee0713004415dbd0508bd6 100644 --- a/src/thermophysicalModels/specie/thermo/specieThermo/specieThermo.H +++ b/src/thermophysicalModels/specie/thermo/specieThermo/specieThermo.H @@ -242,6 +242,9 @@ public: //- Temperature from Enthalpy given an initial temperature T0 inline scalar TH(const scalar H, const scalar T0) const; + //- Temperature from sensible Enthalpy given an initial T0 + inline scalar THs(const scalar Hs, const scalar T0) const; + //- Temperature from internal energy given an initial temperature T0 inline scalar TE(const scalar E, const scalar T0) const; diff --git a/src/thermophysicalModels/specie/thermo/specieThermo/specieThermoI.H b/src/thermophysicalModels/specie/thermo/specieThermo/specieThermoI.H index 215ea7b2032eff381cd5512f7f239bb6e82484dc..788f6b9055464eb9ba99a5af6db330b549e98621 100644 --- a/src/thermophysicalModels/specie/thermo/specieThermo/specieThermoI.H +++ b/src/thermophysicalModels/specie/thermo/specieThermo/specieThermoI.H @@ -281,6 +281,17 @@ inline Foam::scalar Foam::specieThermo<thermo>::TH } +template<class thermo> +inline Foam::scalar Foam::specieThermo<thermo>::THs +( + const scalar hs, + const scalar T0 +) const +{ + return T(hs, T0, &specieThermo<thermo>::Hs, &specieThermo<thermo>::Cp); +} + + template<class thermo> inline Foam::scalar Foam::specieThermo<thermo>::TE ( diff --git a/src/triSurface/Make/options b/src/triSurface/Make/options index 41306609f208806f0c6f42a2426867d3e10d4897..7e207d0dbeaca258e5a72af8b4eb7bacefc0dee8 100644 --- a/src/triSurface/Make/options +++ b/src/triSurface/Make/options @@ -1 +1,5 @@ -EXE_INC = +EXE_INC = \ + -I$(LIB_SRC)/fileFormats/lnInclude + +LIB_LIBS = \ + -lfileFormats diff --git a/src/turbulenceModels/compressible/RAS/LaunderSharmaKE/LaunderSharmaKE.C b/src/turbulenceModels/compressible/RAS/LaunderSharmaKE/LaunderSharmaKE.C index 18f8d49995241dda50bf28a0bde304a2335b2e9f..f1dc4e9203767f045707e99ffb66103d7e5e47e4 100644 --- a/src/turbulenceModels/compressible/RAS/LaunderSharmaKE/LaunderSharmaKE.C +++ b/src/turbulenceModels/compressible/RAS/LaunderSharmaKE/LaunderSharmaKE.C @@ -168,10 +168,10 @@ LaunderSharmaKE::LaunderSharmaKE "mut", runTime_.timeName(), mesh_, - IOobject::MUST_READ, + IOobject::NO_READ, IOobject::AUTO_WRITE ), - rho_*Cmu_*fMu()*sqr(k_)/(epsilon_ + epsilonSmall_) + autoCreateLowReMut("mut", mesh_) ), alphat_ @@ -187,6 +187,9 @@ LaunderSharmaKE::LaunderSharmaKE autoCreateAlphat("alphat", mesh_) ) { + mut_ = rho_*Cmu_*fMu()*sqr(k_)/(epsilon_ + epsilonSmall_); + mut_.correctBoundaryConditions(); + alphat_ = mut_/Prt_; alphat_.correctBoundaryConditions(); diff --git a/src/turbulenceModels/compressible/RAS/Make/files b/src/turbulenceModels/compressible/RAS/Make/files index def806534ab52e722648072d881ea925b7fcb51b..4301cde42596cba22b42bcd182566a2e6bb0ad62 100644 --- a/src/turbulenceModels/compressible/RAS/Make/files +++ b/src/turbulenceModels/compressible/RAS/Make/files @@ -23,6 +23,7 @@ $(mutWallFunctions)/mutkWallFunction/mutkWallFunctionFvPatchScalarField.C $(mutWallFunctions)/mutURoughWallFunction/mutURoughWallFunctionFvPatchScalarField.C $(mutWallFunctions)/mutUSpaldingWallFunction/mutUSpaldingWallFunctionFvPatchScalarField.C $(mutWallFunctions)/mutUWallFunction/mutUWallFunctionFvPatchScalarField.C +$(mutWallFunctions)/mutLowReWallFunction/mutLowReWallFunctionFvPatchScalarField.C epsilonWallFunctions = $(wallFunctions)/epsilonWallFunctions $(epsilonWallFunctions)/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C diff --git a/src/turbulenceModels/compressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.C b/src/turbulenceModels/compressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.C index 842d9125ea27d823cfcfa644dd0a4f0c0f775d22..d2e291d915de4c2c31a6b3e4ac84797827dacb13 100644 --- a/src/turbulenceModels/compressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.C +++ b/src/turbulenceModels/compressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.C @@ -29,6 +29,7 @@ License #include "calculatedFvPatchField.H" #include "alphatWallFunctionFvPatchScalarField.H" #include "mutkWallFunctionFvPatchScalarField.H" +#include "mutLowReWallFunctionFvPatchScalarField.H" #include "epsilonWallFunctionFvPatchScalarField.H" #include "kqRWallFunctionFvPatchField.H" #include "omegaWallFunctionFvPatchScalarField.H" @@ -182,6 +183,76 @@ tmp<volScalarField> autoCreateMut } +tmp<volScalarField> autoCreateLowReMut +( + const word& fieldName, + const fvMesh& mesh +) +{ + IOobject mutHeader + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ); + + if (mutHeader.headerOk()) + { + return tmp<volScalarField>(new volScalarField(mutHeader, mesh)); + } + else + { + Info<< "--> Creating " << fieldName + << " to employ run-time selectable wall functions" << endl; + + const fvBoundaryMesh& bm = mesh.boundary(); + + wordList mutBoundaryTypes(bm.size()); + + forAll(bm, patchI) + { + if (isA<wallFvPatch>(bm[patchI])) + { + mutBoundaryTypes[patchI] = + RASModels::mutLowReWallFunctionFvPatchScalarField::typeName; + } + else + { + mutBoundaryTypes[patchI] = + calculatedFvPatchField<scalar>::typeName; + } + } + + tmp<volScalarField> mut + ( + new volScalarField + ( + IOobject + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + mesh, + dimensionedScalar("zero", dimDensity*dimArea/dimTime, 0.0), + mutBoundaryTypes + ) + ); + + Info<< " Writing new " << fieldName << endl; + mut().write(); + + return mut; + } +} + + tmp<volScalarField> autoCreateEpsilon ( const word& fieldName, diff --git a/src/turbulenceModels/compressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.H b/src/turbulenceModels/compressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.H index d36be7583cc2f069f00a7b95aaccc14b48a20a4e..31e38aa4152767481aad7a53351e479c7080c51b 100644 --- a/src/turbulenceModels/compressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.H +++ b/src/turbulenceModels/compressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.H @@ -53,6 +53,13 @@ namespace compressible const fvMesh& mesh ); + //- mut for Low-Reynolds number models + tmp<volScalarField> autoCreateLowReMut + ( + const word& fieldName, + const fvMesh& mesh + ); + //- alphat tmp<volScalarField> autoCreateAlphat ( diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutLowReWallFunction/mutLowReWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutLowReWallFunction/mutLowReWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000000000000000000000000000000000..81ffb961c0928b1d2eb1d6f66a4d240faba2c8db --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutLowReWallFunction/mutLowReWallFunctionFvPatchScalarField.C @@ -0,0 +1,118 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "mutLowReWallFunctionFvPatchScalarField.H" +#include "RASModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +tmp<scalarField> mutLowReWallFunctionFvPatchScalarField::calcMut() const +{ + return tmp<scalarField>(new scalarField(patch().size(), 0.0)); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +mutLowReWallFunctionFvPatchScalarField::mutLowReWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF +) +: + mutkWallFunctionFvPatchScalarField(p, iF) +{} + + +mutLowReWallFunctionFvPatchScalarField::mutLowReWallFunctionFvPatchScalarField +( + const mutLowReWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + mutkWallFunctionFvPatchScalarField(ptf, p, iF, mapper) +{} + + +mutLowReWallFunctionFvPatchScalarField::mutLowReWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const dictionary& dict +) +: + mutkWallFunctionFvPatchScalarField(p, iF, dict) +{} + + +mutLowReWallFunctionFvPatchScalarField::mutLowReWallFunctionFvPatchScalarField +( + const mutLowReWallFunctionFvPatchScalarField& mlrwfpsf +) +: + mutkWallFunctionFvPatchScalarField(mlrwfpsf) +{} + + +mutLowReWallFunctionFvPatchScalarField::mutLowReWallFunctionFvPatchScalarField +( + const mutLowReWallFunctionFvPatchScalarField& mlrwfpsf, + const DimensionedField<scalar, volMesh>& iF +) +: + mutkWallFunctionFvPatchScalarField(mlrwfpsf, iF) +{} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + mutLowReWallFunctionFvPatchScalarField +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutLowReWallFunction/mutLowReWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutLowReWallFunction/mutLowReWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000000000000000000000000000000000..8c86470cc68ae9811622166010e9d3cd6d4a253a --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutLowReWallFunction/mutLowReWallFunctionFvPatchScalarField.H @@ -0,0 +1,149 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible::RASModels::mutLowReWallFunctionFvPatchScalarField + +Description + Boundary condition for turbulent (kinematic) viscosity when for use with + low Reynolds number models. + + Sets mut to zero, and provides an access to calculate y+. + +SourceFiles + mutLowReWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef compressibleMutLowReWallFunctionFvPatchScalarField_H +#define compressibleMutLowReWallFunctionFvPatchScalarField_H + +#include "mutkWallFunctionFvPatchScalarField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class mutLowReWallFunctionFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class mutLowReWallFunctionFvPatchScalarField +: + public mutkWallFunctionFvPatchScalarField +{ +protected: + + // Private member functions + + //- Calculate the turbulence viscosity + virtual tmp<scalarField> calcMut() const; + + +public: + + //- Runtime type information + TypeName("mutLowReWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + mutLowReWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + mutLowReWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const dictionary& + ); + + //- Construct by mapping given + // mutLowReWallFunctionFvPatchScalarField + // onto a new patch + mutLowReWallFunctionFvPatchScalarField + ( + const mutLowReWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + mutLowReWallFunctionFvPatchScalarField + ( + const mutLowReWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp<fvPatchScalarField> clone() const + { + return tmp<fvPatchScalarField> + ( + new mutLowReWallFunctionFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + mutLowReWallFunctionFvPatchScalarField + ( + const mutLowReWallFunctionFvPatchScalarField&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp<fvPatchScalarField> clone + ( + const DimensionedField<scalar, volMesh>& iF + ) const + { + return tmp<fvPatchScalarField> + ( + new mutLowReWallFunctionFvPatchScalarField(*this, iF) + ); + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutkWallFunction/mutkWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutkWallFunction/mutkWallFunctionFvPatchScalarField.H index 91b930a344c6fd42f4658d8f115675a8662469a9..8854670a0120e6db412efb571ab3deab323a1354 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutkWallFunction/mutkWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutkWallFunction/mutkWallFunctionFvPatchScalarField.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef compressibleMutWallFunctionFvPatchScalarField_H -#define compressibleMutWallFunctionFvPatchScalarField_H +#ifndef compressibleMutkWallFunctionFvPatchScalarField_H +#define compressibleMutkWallFunctionFvPatchScalarField_H #include "fixedValueFvPatchFields.H" diff --git a/src/turbulenceModels/incompressible/RAS/LamBremhorstKE/LamBremhorstKE.C b/src/turbulenceModels/incompressible/RAS/LamBremhorstKE/LamBremhorstKE.C index 321a7b5ff91df01571d207d804f8f2ed165bfde7..1edcb224b556829a6a0aa2a1a8ce383ed251b662 100644 --- a/src/turbulenceModels/incompressible/RAS/LamBremhorstKE/LamBremhorstKE.C +++ b/src/turbulenceModels/incompressible/RAS/LamBremhorstKE/LamBremhorstKE.C @@ -127,8 +127,22 @@ LamBremhorstKE::LamBremhorstKE *(scalar(1) + 20.5/(Rt_ + SMALL)) ), - nut_(Cmu_*fMu_*sqr(k_)/(epsilon_ + epsilonSmall_)) + nut_ + ( + IOobject + ( + "nut", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateLowReNut("nut", mesh_) + ) { + nut_ = Cmu_*fMu_*sqr(k_)/(epsilon_ + epsilonSmall_); + nut_.correctBoundaryConditions(); + printCoeffs(); } diff --git a/src/turbulenceModels/incompressible/RAS/LaunderSharmaKE/LaunderSharmaKE.C b/src/turbulenceModels/incompressible/RAS/LaunderSharmaKE/LaunderSharmaKE.C index ad2ebe0821eb994026b69df4fded8daf31fa70d5..3bbdcb6a4734a47eee3a0543d5ed6d741d653e12 100644 --- a/src/turbulenceModels/incompressible/RAS/LaunderSharmaKE/LaunderSharmaKE.C +++ b/src/turbulenceModels/incompressible/RAS/LaunderSharmaKE/LaunderSharmaKE.C @@ -133,8 +133,22 @@ LaunderSharmaKE::LaunderSharmaKE mesh_ ), - nut_(Cmu_*fMu()*sqr(k_)/(epsilonTilda_ + epsilonSmall_)) + nut_ + ( + IOobject + ( + "nut", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateLowReNut("nut", mesh_) + ) { + nut_ = Cmu_*fMu()*sqr(k_)/(epsilonTilda_ + epsilonSmall_); + nut_.correctBoundaryConditions(); + printCoeffs(); } diff --git a/src/turbulenceModels/incompressible/RAS/LienCubicKELowRe/LienCubicKELowRe.C b/src/turbulenceModels/incompressible/RAS/LienCubicKELowRe/LienCubicKELowRe.C index 2fdb30e8cf9fbfe68c7e602ee8ad566988b53234..2146553f0f6b758230156e68243fdb28af9b598c 100644 --- a/src/turbulenceModels/incompressible/RAS/LienCubicKELowRe/LienCubicKELowRe.C +++ b/src/turbulenceModels/incompressible/RAS/LienCubicKELowRe/LienCubicKELowRe.C @@ -28,6 +28,8 @@ License #include "wallFvPatch.H" #include "addToRunTimeSelectionTable.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -233,20 +235,16 @@ LienCubicKELowRe::LienCubicKELowRe nut_ ( - Cmu_ - *( - scalar(1) - exp(-Am_*yStar_)) - /(scalar(1) - exp(-Aepsilon_*yStar_) + SMALL - ) - *sqr(k_)/(epsilon_ + epsilonSmall_) - // cubic term C5, implicit part - + max + IOobject ( - C5viscosity_, - dimensionedScalar("0", C5viscosity_.dimensions(), 0.0) - ) + "nut", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateLowReNut("nut", mesh_) ), - // turbulent viscosity, with implicit part of C5 nonlinearStress_ ( @@ -282,6 +280,21 @@ LienCubicKELowRe::LienCubicKELowRe ) ) { + nut_ = Cmu_ + *( + scalar(1) - exp(-Am_*yStar_)) + /(scalar(1) - exp(-Aepsilon_*yStar_) + SMALL + ) + *sqr(k_)/(epsilon_ + epsilonSmall_) + // cubic term C5, implicit part + + max + ( + C5viscosity_, + dimensionedScalar("0", C5viscosity_.dimensions(), 0.0) + ); + + nut_.correctBoundaryConditions(); + printCoeffs(); } diff --git a/src/turbulenceModels/incompressible/RAS/LienLeschzinerLowRe/LienLeschzinerLowRe.C b/src/turbulenceModels/incompressible/RAS/LienLeschzinerLowRe/LienLeschzinerLowRe.C index b7a82d6d1bdd788b3ce5bb598e677eae27560f10..6e47e1d926f77bd2e5a794decc8a6c4c16ddfd65 100644 --- a/src/turbulenceModels/incompressible/RAS/LienLeschzinerLowRe/LienLeschzinerLowRe.C +++ b/src/turbulenceModels/incompressible/RAS/LienLeschzinerLowRe/LienLeschzinerLowRe.C @@ -28,6 +28,8 @@ License #include "wallFvPatch.H" #include "addToRunTimeSelectionTable.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -167,11 +169,22 @@ LienLeschzinerLowRe::LienLeschzinerLowRe nut_ ( - Cmu_*(scalar(1) - exp(-Am_*yStar_)) - /(scalar(1) - exp(-Aepsilon_*yStar_) + SMALL)*sqr(k_) - /(epsilon_ + epsilonSmall_) + IOobject + ( + "epsilon", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateLowReNut("nut", mesh_) ) { + nut_ = Cmu_*(scalar(1) - exp(-Am_*yStar_)) + /(scalar(1) - exp(-Aepsilon_*yStar_) + SMALL)*sqr(k_) + /(epsilon_ + epsilonSmall_); + nut_.correctBoundaryConditions(); + printCoeffs(); } diff --git a/src/turbulenceModels/incompressible/RAS/Make/files b/src/turbulenceModels/incompressible/RAS/Make/files index 394e7391a75965341d8875f8288313646ff8af7a..7ddd1d4e3b24fa0d6156d5f6fed061beebf8ace1 100644 --- a/src/turbulenceModels/incompressible/RAS/Make/files +++ b/src/turbulenceModels/incompressible/RAS/Make/files @@ -27,6 +27,7 @@ $(nutWallFunctions)/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarFiel $(nutWallFunctions)/nutUSpaldingWallFunction/nutUSpaldingWallFunctionFvPatchScalarField.C $(nutWallFunctions)/nutUWallFunction/nutUWallFunctionFvPatchScalarField.C $(nutWallFunctions)/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.C +$(nutWallFunctions)/nutLowReWallFunction/nutLowReWallFunctionFvPatchScalarField.C epsilonWallFunctions = $(wallFunctions)/epsilonWallFunctions $(epsilonWallFunctions)/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C diff --git a/src/turbulenceModels/incompressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.C b/src/turbulenceModels/incompressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.C index b2bcedff458b7d5311dc6966ba923d18d475cc3a..3de77712fdcfa64f1aa6e8a90b37167e2e902583 100644 --- a/src/turbulenceModels/incompressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.C +++ b/src/turbulenceModels/incompressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.C @@ -28,6 +28,7 @@ License #include "calculatedFvPatchField.H" #include "nutkWallFunctionFvPatchScalarField.H" +#include "nutLowReWallFunctionFvPatchScalarField.H" #include "epsilonWallFunctionFvPatchScalarField.H" #include "kqRWallFunctionFvPatchField.H" #include "omegaWallFunctionFvPatchScalarField.H" @@ -111,6 +112,76 @@ tmp<volScalarField> autoCreateNut } +tmp<volScalarField> autoCreateLowReNut +( + const word& fieldName, + const fvMesh& mesh +) +{ + IOobject nutHeader + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ); + + if (nutHeader.headerOk()) + { + return tmp<volScalarField>(new volScalarField(nutHeader, mesh)); + } + else + { + Info<< "--> Creating " << fieldName + << " to employ run-time selectable wall functions" << endl; + + const fvBoundaryMesh& bm = mesh.boundary(); + + wordList nutBoundaryTypes(bm.size()); + + forAll(bm, patchI) + { + if (isA<wallFvPatch>(bm[patchI])) + { + nutBoundaryTypes[patchI] = + RASModels::nutLowReWallFunctionFvPatchScalarField::typeName; + } + else + { + nutBoundaryTypes[patchI] = + calculatedFvPatchField<scalar>::typeName; + } + } + + tmp<volScalarField> nut + ( + new volScalarField + ( + IOobject + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + mesh, + dimensionedScalar("zero", dimArea/dimTime, 0.0), + nutBoundaryTypes + ) + ); + + Info<< " Writing new " << fieldName << endl; + nut().write(); + + return nut; + } +} + + tmp<volScalarField> autoCreateEpsilon ( const word& fieldName, diff --git a/src/turbulenceModels/incompressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.H b/src/turbulenceModels/incompressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.H index 615834f9e804b54b291db21de1dae1269e0d7ada..e3d2c738851b3cb153c3b5e55382815134479955 100644 --- a/src/turbulenceModels/incompressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.H +++ b/src/turbulenceModels/incompressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.H @@ -53,6 +53,13 @@ namespace incompressible const fvMesh& mesh ); + //- nut for Low-Reynolds number models + tmp<volScalarField> autoCreateLowReNut + ( + const word& fieldName, + const fvMesh& mesh + ); + //- epsilon tmp<volScalarField> autoCreateEpsilon ( diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutLowReWallFunction/nutLowReWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutLowReWallFunction/nutLowReWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000000000000000000000000000000000..eb5d4091686d1fb1b8671642084389bff139bf6a --- /dev/null +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutLowReWallFunction/nutLowReWallFunctionFvPatchScalarField.C @@ -0,0 +1,114 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "nutLowReWallFunctionFvPatchScalarField.H" +#include "RASModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +tmp<scalarField> nutLowReWallFunctionFvPatchScalarField::calcNut() const +{ + return tmp<scalarField>(new scalarField(patch().size(), 0.0)); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +nutLowReWallFunctionFvPatchScalarField::nutLowReWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF +) +: + nutkWallFunctionFvPatchScalarField(p, iF) +{} + + +nutLowReWallFunctionFvPatchScalarField::nutLowReWallFunctionFvPatchScalarField +( + const nutLowReWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + nutkWallFunctionFvPatchScalarField(ptf, p, iF, mapper) +{} + + +nutLowReWallFunctionFvPatchScalarField::nutLowReWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const dictionary& dict +) +: + nutkWallFunctionFvPatchScalarField(p, iF, dict) +{} + + +nutLowReWallFunctionFvPatchScalarField::nutLowReWallFunctionFvPatchScalarField +( + const nutLowReWallFunctionFvPatchScalarField& nlrwfpsf +) +: + nutkWallFunctionFvPatchScalarField(nlrwfpsf) +{} + + +nutLowReWallFunctionFvPatchScalarField::nutLowReWallFunctionFvPatchScalarField +( + const nutLowReWallFunctionFvPatchScalarField& nlrwfpsf, + const DimensionedField<scalar, volMesh>& iF +) +: + nutkWallFunctionFvPatchScalarField(nlrwfpsf, iF) +{} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField(fvPatchScalarField, nutLowReWallFunctionFvPatchScalarField); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace incompressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutLowReWallFunction/nutLowReWallFunctionFvPatchScalarField.H b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutLowReWallFunction/nutLowReWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000000000000000000000000000000000..2427f686c689ca81add97613f80bf918912d04c9 --- /dev/null +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutLowReWallFunction/nutLowReWallFunctionFvPatchScalarField.H @@ -0,0 +1,149 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::incompressible::RASModels::nutLowReWallFunctionFvPatchScalarField + +Description + Boundary condition for turbulent (kinematic) viscosity when for use with + low Reynolds number models. + + Sets nut to zero, and provides an access function to calculate y+. + +SourceFiles + nutLowReWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef nutLowReWallFunctionFvPatchScalarField_H +#define nutLowReWallFunctionFvPatchScalarField_H + +#include "nutkWallFunctionFvPatchScalarField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class nutLowReWallFunctionFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class nutLowReWallFunctionFvPatchScalarField +: + public nutkWallFunctionFvPatchScalarField +{ +protected: + + // Protected member functions + + //- Calculate the turbulence viscosity + virtual tmp<scalarField> calcNut() const; + + +public: + + //- Runtime type information + TypeName("nutLowReWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + nutLowReWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + nutLowReWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const dictionary& + ); + + //- Construct by mapping given + // nutLowReWallFunctionFvPatchScalarField + // onto a new patch + nutLowReWallFunctionFvPatchScalarField + ( + const nutLowReWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + nutLowReWallFunctionFvPatchScalarField + ( + const nutLowReWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp<fvPatchScalarField> clone() const + { + return tmp<fvPatchScalarField> + ( + new nutLowReWallFunctionFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + nutLowReWallFunctionFvPatchScalarField + ( + const nutLowReWallFunctionFvPatchScalarField&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp<fvPatchScalarField> clone + ( + const DimensionedField<scalar, volMesh>& iF + ) const + { + return tmp<fvPatchScalarField> + ( + new nutLowReWallFunctionFvPatchScalarField(*this, iF) + ); + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace incompressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/G b/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/G new file mode 100644 index 0000000000000000000000000000000000000000..fd0982491c620462f6851cb538d2be2efe95d6c9 --- /dev/null +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/G @@ -0,0 +1,32 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object G; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 0 -3 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + ".*" + { + type MarshakRadiation; + T T; + emissivity 1; + value uniform 0; + } +} + +// ************************************************************************* // diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/IDefault b/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/IDefault new file mode 100644 index 0000000000000000000000000000000000000000..61b02dea13d844c93a773502a5c9288b99978b97 --- /dev/null +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/IDefault @@ -0,0 +1,32 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object IDefault; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 0 -3 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + ".*" + { + type greyDiffusiveRadiation; + T T; + emissivity 1.0 + value uniform 0; + } +} + +// ************************************************************************* // diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/T b/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/T new file mode 100755 index 0000000000000000000000000000000000000000..1c7d1ebb4d55cb4cfb065e9a471cc237c216ecb0 --- /dev/null +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/T @@ -0,0 +1,52 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object T; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform 300; + +boundaryField +{ + outlet + { + type inletOutlet; + inletValue uniform 300; + value uniform 300; + } + sides + { + type inletOutlet; + inletValue uniform 300; + value uniform 300; + } + base + { + type zeroGradient; + } + inlet + { + type fixedValue; + value uniform 300; + } + frontBack + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/U b/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/U new file mode 100755 index 0000000000000000000000000000000000000000..48e4aab470ddcae4baead5ef0e43b75acc0903d9 --- /dev/null +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/U @@ -0,0 +1,55 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + location "0"; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform (0 0 0); + +boundaryField +{ + outlet + { + + type inletOutlet; + inletValue uniform (0 0 0); + value uniform (0 0 0); + + } + sides + { + type pressureInletOutletVelocity; + outletValue uniform (0 0 0); + value uniform (0 0 0); + } + base + { + type fixedValue; + value uniform (0 0 0); + } + inlet + { + type fixedValue; + value uniform (0 0.05 0); + } + frontBack + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/alphaSgs b/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/alphaSgs new file mode 100755 index 0000000000000000000000000000000000000000..c840a07a08e78775f21a5ff3ea0cc2cc6b821f97 --- /dev/null +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/alphaSgs @@ -0,0 +1,47 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object alphaSgs; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -1 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + outlet + { + type zeroGradient; + } + sides + { + type zeroGradient; + } + base + { + type zeroGradient; + } + inlet + { + type zeroGradient; + } + frontBack + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/b b/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/b new file mode 100755 index 0000000000000000000000000000000000000000..0fbbd652fef5c361395a5502ae033ccb19005d7d --- /dev/null +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/b @@ -0,0 +1,47 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object b; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + outlet + { + type zeroGradient; + } + sides + { + type zeroGradient; + } + base + { + type zeroGradient; + } + inlet + { + type zeroGradient; + } + frontBack + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/ft b/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/ft new file mode 100755 index 0000000000000000000000000000000000000000..44b0a149551af8622f9968807576310b0de84173 --- /dev/null +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/ft @@ -0,0 +1,52 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object ft; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + outlet + { + type inletOutlet; + inletValue uniform 0; + value uniform 0; + } + sides + { + type inletOutlet; + inletValue uniform 0; + value uniform 0; + } + base + { + type zeroGradient; + } + inlet + { + type fixedValue; + value uniform 1.0; + } + frontBack + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/fu b/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/fu new file mode 100755 index 0000000000000000000000000000000000000000..e3b3011de317a317c710f4fc6b42d666046f8c91 --- /dev/null +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/fu @@ -0,0 +1,52 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object fu; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + outlet + { + type inletOutlet; + inletValue uniform 0; + value uniform 0; + } + sides + { + type inletOutlet; + inletValue uniform 0; + value uniform 0; + } + base + { + type zeroGradient; + } + inlet + { + type fixedValue; + value uniform 1.0; + } + frontBack + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/k b/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/k new file mode 100755 index 0000000000000000000000000000000000000000..80db42f64f8d054dd7a85b2de03ce68589e01a0f --- /dev/null +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/k @@ -0,0 +1,53 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object k; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -2 0 0 0 0]; + +internalField uniform 1e-4; + +boundaryField +{ + outlet + { + type inletOutlet; + inletValue uniform 1e-4; + value uniform 1e-4; + } + sides + { + type inletOutlet; + inletValue uniform 1e-4; + value uniform 1e-4; + } + base + { + type fixedValue; + value uniform 1e-4; + } + inlet + { + type fixedValue; + value uniform 1e-4; + } + frontBack + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/muSgs b/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/muSgs new file mode 100755 index 0000000000000000000000000000000000000000..f8b645f718b5ca5fe7094bb6e9b642641f632528 --- /dev/null +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/muSgs @@ -0,0 +1,47 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object muSgs; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -1 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + outlet + { + type zeroGradient; + } + sides + { + type zeroGradient; + } + base + { + type zeroGradient; + } + inlet + { + type zeroGradient; + } + frontBack + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/p b/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/p new file mode 100755 index 0000000000000000000000000000000000000000..d25a0c7e11d1bf93f25afe42aa3f1bcdeaab1f6b --- /dev/null +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/p @@ -0,0 +1,55 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object p; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform 101325; + +boundaryField +{ + outlet + { + type buoyantPressure; + value uniform 101325; + } + + sides + { + type uniformDensityHydrostaticPressure; + rho 1.2; + pRefValue 101325; + pRefPoint (0 0 0); + value $internalField; + } + base + { + type buoyantPressure; + value $internalField; + } + inlet + { + type buoyantPressure; + value $internalField; + } + frontBack + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire2D/Allrun b/tutorials/combustion/fireFoam/les/smallPoolFire2D/Allrun new file mode 100755 index 0000000000000000000000000000000000000000..4d995124bb70bd6509a91a1cf07f4b2cb15c0bff --- /dev/null +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/Allrun @@ -0,0 +1,13 @@ +#!/bin/sh + +# Source tutorial run functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions + +runApplication blockMesh +runApplication setSet -batch makeFaceSet.setSet +runApplication createPatch -overwrite + +# Run +runApplication fireFoam + +# ----------------------------------------------------------------------------- diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/LESProperties b/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/LESProperties new file mode 100644 index 0000000000000000000000000000000000000000..17f30efd1fb7fd5e67a17052137394e3de003448 --- /dev/null +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/LESProperties @@ -0,0 +1,84 @@ +/*---------------------------------------------------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.openfoam.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ + +FoamFile +{ + version 2.0; + format binary; + class dictionary; + location "constant"; + object LESProperties; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +LESModel oneEqEddy; + +delta cubeRootVol; + +turbulence on; + +printCoeffs on; + + +cubeRootVolCoeffs +{ + deltaCoeff 1; +} + +PrandtlCoeffs +{ + delta cubeRootVol; + cubeRootVolCoeffs + { + deltaCoeff 1; + } + smoothCoeffs + { + delta cubeRootVol; + cubeRootVolCoeffs + { + deltaCoeff 1; + } + maxDeltaRatio 1.1; + } + Cdelta 0.158; +} + +vanDriestCoeffs +{ + delta cubeRootVol; + cubeRootVolCoeffs + { + deltaCoeff 1; + } + smoothCoeffs + { + delta cubeRootVol; + cubeRootVolCoeffs + { + deltaCoeff 1; + } + maxDeltaRatio 1.1; + } + Aplus 26; + Cdelta 0.158; +} + +smoothCoeffs +{ + delta cubeRootVol; + cubeRootVolCoeffs + { + deltaCoeff 1; + } + maxDeltaRatio 1.1; +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/SpeciesTable b/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/SpeciesTable new file mode 100644 index 0000000000000000000000000000000000000000..98d27237ea171a717c84e0497a66cbad00a75484 --- /dev/null +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/SpeciesTable @@ -0,0 +1,491 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object SpeciesTable; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +fields +1 +( + +{ + name ft; + min 0; + max 1; + N 100; +} + +) +; +output +5 +( + +{ + name CH4; +} + + +{ + name CO2; +} + + +{ + name H2O; +} + + +{ + name CO; +} + + +{ + name soot; +} + +) +; +values +6 +( + +101 +( +0.001 +0.011 +0.021 +0.031 +0.041 +0.051 +0.061 +0.071 +0.081 +0.091 +0.101 +0.111 +0.121 +0.131 +0.141 +0.151 +0.161 +0.171 +0.181 +0.191 +0.201 +0.211 +0.221 +0.231 +0.241 +0.251 +0.261 +0.271 +0.281 +0.291 +0.301 +0.311 +0.321 +0.331 +0.341 +0.351 +0.361 +0.371 +0.381 +0.391 +0.401 +0.411 +0.421 +0.431 +0.441 +0.451 +0.461 +0.471 +0.481 +0.491 +0.501 +0.511 +0.521 +0.531 +0.541 +0.551 +0.561 +0.571 +0.581 +0.591 +0.601 +0.611 +0.621 +0.631 +0.641 +0.651 +0.661 +0.671 +0.681 +0.691 +0.701 +0.711 +0.721 +0.731 +0.741 +0.751 +0.761 +0.771 +0.781 +0.791 +0.801 +0.811 +0.821 +0.831 +0.841 +0.851 +0.861 +0.871 +0.881 +0.891 +0.901 +0.911 +0.921 +0.931 +0.941 +0.951 +0.961 +0.971 +0.981 +0.991 +0.999 +) + + +101 +( +0 +0 +0 +0 +0 +0 +0.0105883 +0.0285208 +0.0461843 +0.0635849 +0.0807284 +0.0976204 +0.114266 +0.130672 +0.146842 +0.162782 +0.178496 +0.193989 +0.209266 +0.224332 +0.23919 +0.253845 +0.268301 +0.282563 +0.296633 +0.310517 +0.324216 +0.337736 +0.35108 +0.364251 +0.377252 +0.390087 +0.402759 +0.415271 +0.427625 +0.439826 +0.451876 +0.463777 +0.475532 +0.487144 +0.498616 +0.50995 +0.521148 +0.532214 +0.543149 +0.553955 +0.564635 +0.575191 +0.585626 +0.595941 +0.606138 +0.61622 +0.626187 +0.636044 +0.64579 +0.655428 +0.66496 +0.674387 +0.683712 +0.692935 +0.702059 +0.711085 +0.720014 +0.728849 +0.73759 +0.74624 +0.754799 +0.763269 +0.771652 +0.779948 +0.788159 +0.796287 +0.804332 +0.812297 +0.820181 +0.827987 +0.835715 +0.843367 +0.850943 +0.858445 +0.865875 +0.873232 +0.880518 +0.887735 +0.894882 +0.901961 +0.908974 +0.91592 +0.922802 +0.929619 +0.936373 +0.943064 +0.949694 +0.956263 +0.962772 +0.969222 +0.975614 +0.981948 +0.988226 +0.994448 +0.999385 +) + + +101 +( +0.00200328 +0.0213922 +0.0396804 +0.0569589 +0.0733092 +0.088804 +0.0940165 +0.0923125 +0.0906341 +0.0889806 +0.0873516 +0.0857465 +0.0841647 +0.0826058 +0.0810693 +0.0795547 +0.0780615 +0.0765893 +0.0751376 +0.073706 +0.0722942 +0.0709016 +0.0695279 +0.0681728 +0.0668357 +0.0655165 +0.0642147 +0.06293 +0.0616621 +0.0604105 +0.0591751 +0.0579555 +0.0567514 +0.0555625 +0.0543885 +0.0532292 +0.0520842 +0.0509534 +0.0498363 +0.0487329 +0.0476428 +0.0465658 +0.0455017 +0.0444503 +0.0434112 +0.0423844 +0.0413695 +0.0403664 +0.0393749 +0.0383948 +0.0374258 +0.0364678 +0.0355206 +0.0345841 +0.033658 +0.0327421 +0.0318364 +0.0309406 +0.0300546 +0.0291781 +0.0283112 +0.0274535 +0.026605 +0.0257655 +0.0249349 +0.024113 +0.0232997 +0.0224948 +0.0216983 +0.0209099 +0.0201297 +0.0193573 +0.0185928 +0.0178361 +0.0170869 +0.0163452 +0.0156108 +0.0148837 +0.0141638 +0.0134509 +0.0127449 +0.0120458 +0.0113535 +0.0106678 +0.00998859 +0.00931588 +0.00864953 +0.00798947 +0.00733558 +0.0066878 +0.00604604 +0.00541021 +0.00478022 +0.00415601 +0.00353749 +0.00292458 +0.00231721 +0.00171531 +0.00111879 +0.000527591 +5.8413e-05 +) + + +101 +( +0.00400655 +0.0427844 +0.0793607 +0.113918 +0.146618 +0.177608 +0.188033 +0.184625 +0.181268 +0.177961 +0.174703 +0.171493 +0.168329 +0.165212 +0.162139 +0.159109 +0.156123 +0.153179 +0.150275 +0.147412 +0.144588 +0.141803 +0.139056 +0.136346 +0.133671 +0.131033 +0.128429 +0.12586 +0.123324 +0.120821 +0.11835 +0.115911 +0.113503 +0.111125 +0.108777 +0.106458 +0.104168 +0.101907 +0.0996727 +0.0974658 +0.0952856 +0.0931317 +0.0910035 +0.0889006 +0.0868225 +0.0847688 +0.082739 +0.0807328 +0.0787498 +0.0767895 +0.0748516 +0.0729356 +0.0710413 +0.0691682 +0.067316 +0.0654843 +0.0636728 +0.0618812 +0.0601091 +0.0583563 +0.0566223 +0.054907 +0.05321 +0.051531 +0.0498697 +0.0482259 +0.0465993 +0.0449896 +0.0433965 +0.0418198 +0.0402593 +0.0387147 +0.0371857 +0.0356721 +0.0341737 +0.0326903 +0.0312216 +0.0297674 +0.0283276 +0.0269018 +0.0254899 +0.0240917 +0.022707 +0.0213355 +0.0199772 +0.0186318 +0.0172991 +0.0159789 +0.0146712 +0.0133756 +0.0120921 +0.0108204 +0.00956045 +0.00831202 +0.00707498 +0.00584917 +0.00463443 +0.00343062 +0.00223758 +0.00105518 +0.000116826 +) + +101{0} +101{0} +) +; diff --git a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/enthalpySourceProperties b/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/combustionProperties similarity index 73% rename from tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/enthalpySourceProperties rename to tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/combustionProperties index 4db0ca8f4058d6bdb1c5b43899ae88fe4f178fb8..9619d659c77bdf65ae6bf5dd1f49a9b446f25ad8 100644 --- a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/enthalpySourceProperties +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/combustionProperties @@ -11,28 +11,19 @@ FoamFile format ascii; class dictionary; location "constant"; - object enthalpySourceProperties; + object combustionProperties; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -active yes; +combustionModel infinitelyFastChemistry; -cellSource sphereToCell; - -volumeType absolute; - -timeStart 0.15; - -duration 0.1; - -onValue 10000; - -offValue 0; +infinitelyFastChemistryCoeffs +{ + C 10.0; +} -sphereToCellCoeffs +noCombustionCoeffs { - centre ( 0.125 0.375 0.05 ); - radius 0.005; } diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/g b/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/g new file mode 100644 index 0000000000000000000000000000000000000000..2845e492e925860efc7e2c85e2ab0069aee643fd --- /dev/null +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/g @@ -0,0 +1,21 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class uniformDimensionedVectorField; + location "constant"; + object g; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -2 0 0 0 0]; +value (0 -9.8 0); + +// ************************************************************************* // diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/polyMesh/blockMeshDict b/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/polyMesh/blockMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..0f18c0d733830bc2768ff312ea9078a0c821ce14 --- /dev/null +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/polyMesh/blockMeshDict @@ -0,0 +1,67 @@ +/*---------------------------------------------------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +convertToMeters 1; + +vertices +( + (-0.5 0 -0.01) + ( 0.5 0 -0.01) + ( 0.5 1 -0.01) + (-0.5 1 -0.01) + (-0.5 0 0.01) + ( 0.5 0 0.01) + ( 0.5 1 0.01) + (-0.5 1 0.01) + +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (150 150 1) simpleGrading (1 1 1) +); + +edges +( +); + +patches +( + patch base + ( + (0 1 5 4) + ) + patch outlet + ( + (3 2 6 7) + ) + patch sides + ( + (1 5 6 2) + (0 4 7 3) + ) + empty frontAndBack + ( + (0 1 2 3) + (4 5 6 7) + ) +); + +mergePatchPairs +( +); + +// ************************************************************************* // diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/polyMesh/boundary b/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/polyMesh/boundary new file mode 100644 index 0000000000000000000000000000000000000000..ce658ffe2525b139025eff2cb449728439bbadf9 --- /dev/null +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/polyMesh/boundary @@ -0,0 +1,52 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class polyBoundaryMesh; + location "constant/polyMesh"; + object boundary; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +5 +( + base + { + type patch; + nFaces 134; + startFace 44700; + } + outlet + { + type patch; + nFaces 150; + startFace 44834; + } + sides + { + type patch; + nFaces 300; + startFace 44984; + } + frontAndBack + { + type empty; + nFaces 45000; + startFace 45284; + } + inlet + { + type patch; + nFaces 16; + startFace 90284; + } +) + +// ************************************************************************* // diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/radiationProperties b/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/radiationProperties new file mode 100644 index 0000000000000000000000000000000000000000..5cf96fad766a735835295727ca5a507edd3b4d49 --- /dev/null +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/radiationProperties @@ -0,0 +1,149 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object radiationProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +radiation on; + +radiationModel fvDOM; + +noRadiation +{ +} + +P1Coeffs +{ +} + +fvDOMCoeffs +{ + nPhi 4; // azimuthal angles in PI/2 on X-Y.(from Y to X) + nTheta 0; // polar angles in PI (from Z to X-Y plane) + convergence 1e-3; // convergence criteria for radiation iteration + maxIter 1; // maximum number of iterations +} + +// Number of flow iterations per radiation iteration +solverFreq 10; + +absorptionEmissionModel greyMeanAbsorptionEmission; + +constantAbsorptionEmissionCoeffs +{ + a a [ 0 -1 0 0 0 0 0 ] 0.01; + e e [ 0 -1 0 0 0 0 0 ] 0; + E E [ 1 -1 -3 0 0 0 0 ] 0; +} + +greyMeanAbsorptionEmissionCoeffs +{ + lookUpTableFileName "SpeciesTable"; + + EhrrCoeff 0.0; + + CO2 + { + Tcommon 300; //Common Temp + invTemp true; //Is the polynomio using inverse temperature. + Tlow 200; //Low Temp + Thigh 2500; //High Temp + + loTcoeffs //coefss for T < Tcommon + ( + 0 // a0 + + 0 // a1*T + + 0 // a2*T^(+/-)2 + + 0 // a3*T^(+/-)3 + + 0 // a4*T^(+/-)4 + + 0 // a5*T^(+/-)5 + + ); + hiTcoeffs //coefss for T > Tcommon + ( + 18.741 + -121.31e3 + 273.5e6 + -194.05e9 + 56.31e12 + -5.8169e15 + ); + + } + + H2O + { + Tcommon 300; + invTemp true; + Tlow 200; + Thigh 2500; + + loTcoeffs + ( + 0 + 0 + 0 + 0 + 0 + 0 + ); + hiTcoeffs + ( + -0.23093 + -1.12390e3 + 9.4153e6 + -2.99885e9 + 0.51382e12 + -1.868e10 + ); + } + + CH4 + { + Tcommon 300; + Tlow 200; + Thigh 2500; + invTemp false; + + loTcoeffs + ( + 0 + 0 + 0 + 0 + 0 + 0 + ); + hiTcoeffs + ( + 6.6334 + -0.0035686 + 1.6682e-8 + 2.5611e-10 + -2.6558e-14 + 0 + ); + } + +} + +scatterModel constantScatter; + +constantScatterCoeffs +{ + sigma sigma [ 0 -1 0 0 0 0 0 ] 0; + C C [ 0 0 0 0 0 0 0 ] 0; +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/thermophysicalProperties b/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/thermophysicalProperties new file mode 100644 index 0000000000000000000000000000000000000000..2e4a2e74af5eccb9b5c187a22a7ac761db6e1355 --- /dev/null +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/thermophysicalProperties @@ -0,0 +1,55 @@ +/*---------------------------------------------------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.openfoam.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ + +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object thermophysicalProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +thermoType hsPsiMixtureThermo<veryInhomogeneousMixture<sutherlandTransport<specieThermo<janafThermo<perfectGas>>>>>; + +stoichiometricAirFuelMassRatio stoichiometricAirFuelMassRatio [0 0 0 0 0 0 0] 17.1271; +stoichiometricOxygenFuelMassRatio stoichiometricOxygenFuelMassRatio [0 0 0 0 0 0 0] 4.0; +qFuel qFuel [0 2 -2 0 0 0 0] 5.00264e+07; + +fuel fuel 1 16.0428 + 200 6000 1000 + 1.63543 0.0100844 -3.36924e-06 5.34973e-10 -3.15528e-14 -10005.6 9.9937 + 5.14988 -0.013671 4.91801e-05 -4.84744e-08 1.66694e-11 -10246.6 -4.64132 + 1.67212e-06 170.672; + +oxidant oxidant 1 28.8504 + 200 6000 1000 + 3.10131 0.00124137 -4.18816e-07 6.64158e-11 -3.91274e-15 -985.266 5.35597 + 3.58378 -0.000727005 1.67057e-06 -1.09203e-10 -4.31765e-13 -1050.53 3.11239 + 1.67212e-06 170.672; + +reactants reactants 1 27.6004 + 200 6000 1000 + 2.95825 0.00210441 -7.06762e-07 1.12145e-10 -6.61028e-15 -1865.61 5.80859 + 3.73662 -0.00199028 6.30727e-06 -4.82941e-09 1.23723e-12 -1948.03 2.35566 + 1.67212e-06 170.672; + +burntProducts burntProducts 1 27.6334 + 200 6000 1000 + 3.0602 0.00182422 -5.93878e-07 8.93807e-11 -4.97595e-15 -10998.7 5.32209 + 3.54628 0.000378279 2.02797e-07 9.31602e-10 -6.84016e-13 -11102.1 2.90098 + 1.67212e-06 170.672; + +products products 1 27.6004 + 200 6000 1000 + 3.05615 0.0018477 -6.01767e-07 9.06474e-11 -5.05149e-15 -10995.9 5.33537 + 3.55084 0.000338343 3.42018e-07 7.91162e-10 -6.34688e-13 -11099.7 2.87954 + 1.67212e-06 170.672; + + +// ************************************************************************* // diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/turbulenceProperties b/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/turbulenceProperties new file mode 100644 index 0000000000000000000000000000000000000000..d44ea0a37125e0c4a34ba83ae4a6c556f39236d4 --- /dev/null +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/turbulenceProperties @@ -0,0 +1,23 @@ +/*---------------------------------------------------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.openfoam.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ + +FoamFile +{ + version 2.0; + format binary; + class dictionary; + location "constant"; + object turbulenceProperties; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +simulationType LESModel; + + +// ************************************************************************* // diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire2D/makeFaceSet.setSet b/tutorials/combustion/fireFoam/les/smallPoolFire2D/makeFaceSet.setSet new file mode 100644 index 0000000000000000000000000000000000000000..78681a7505850cc0519ce586eb04590d655ab63e --- /dev/null +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/makeFaceSet.setSet @@ -0,0 +1 @@ +faceSet f0 new boxToFace (-0.0529 -0.001 -0.1)(0.0529 0.002 0.1) diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire2D/system/controlDict b/tutorials/combustion/fireFoam/les/smallPoolFire2D/system/controlDict new file mode 100644 index 0000000000000000000000000000000000000000..aa179ea0851a6c7aa5a9f38829869a9358f55234 --- /dev/null +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/system/controlDict @@ -0,0 +1,55 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.openfoam.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application fireFoam; + +startFrom startTime; + +startTime 0.0; + +stopAt endTime; + +endTime 3.0; + +deltaT 0.001; + +writeControl adjustableRunTime; + +writeInterval 0.1; + +purgeWrite 0; + +writeFormat ascii; + +writePrecision 6; + +writeCompression uncompressed; + +timeFormat general; + +timePrecision 6; + +graphFormat raw; + +runTimeModifiable yes; + +adjustTimeStep yes; + +maxCo 0.25; + +maxDeltaT 0.1; + +// ************************************************************************* // diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire2D/system/createPatchDict b/tutorials/combustion/fireFoam/les/smallPoolFire2D/system/createPatchDict new file mode 100644 index 0000000000000000000000000000000000000000..1db65e4d32e9f44abb11309efbfdd2554a47cd5c --- /dev/null +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/system/createPatchDict @@ -0,0 +1,80 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object createPatchDict; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// This application/dictionary controls: +// - optional: create new patches from boundary faces (either given as +// a set of patches or as a faceSet) +// - always: order faces on coupled patches such that they are opposite. This +// is done for all coupled faces, not just for any patches created. +// - optional: synchronise points on coupled patches. + +// 1. Create cyclic: +// - specify where the faces should come from +// - specify the type of cyclic. If a rotational specify the rotationAxis +// and centre to make matching easier +// - pointSync true to guarantee points to line up. + +// 2. Correct incorrect cyclic: +// This will usually fail upon loading: +// "face 0 area does not match neighbour 2 by 0.0100005%" +// " -- possible face ordering problem." +// - change patch type from 'cyclic' to 'patch' in the polyMesh/boundary file. +// - loosen match tolerance to get case to load +// - regenerate cyclic as above + + +// Tolerance used in matching faces. Absolute tolerance is span of +// face times this factor. To load incorrectly matches meshes set this +// to a higher value. +matchTolerance 1E-3; + +// Do a synchronisation of coupled points after creation of any patches. +pointSync true; + +// Patches to create. +patchInfo +( + { + // Name of new patch + name inlet; + + // Type of new patch + dictionary + { + type patch; + + // Optional: explicitly set transformation tensor. + // Used when matching and synchronising points. + //transform translational; + //separationVector (-2289 0 0); + transform rotational; + rotationAxis (1 0 0); + rotationCentre (0 0 0); + } + + // How to construct: either from 'patches' or 'set' + constructFrom set; + + // If constructFrom = patches : names of patches. Wildcards allowed. + patches ("periodic.*"); + + // If constructFrom = set : name of faceSet + set f0; + } +); + +// ************************************************************************* // diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire2D/system/fvSchemes b/tutorials/combustion/fireFoam/les/smallPoolFire2D/system/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..8b24cb3469fc56cae3a762677be34b696decc0b5 --- /dev/null +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/system/fvSchemes @@ -0,0 +1,76 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.openfoam.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default none; + div(phi,U) Gauss limitedLinear 1; + div(phi,k) Gauss limitedLinear 1; + flux(phi,ft) Gauss limitedLinear01 1; + div(phi,ft_b_h) Gauss multivariateSelection + { + fu limitedLinear01 1; + ft limitedLinear01 1; + hs limitedLinear 1; + }; + div((muEff*dev2(grad(U).T()))) Gauss linear; + div(phiU,p) Gauss linear; + div(Ji,Ii_h) Gauss upwind; +} + +laplacianSchemes +{ + default none; + laplacian(muEff,U) Gauss linear corrected; + laplacian(DkEff,k) Gauss linear corrected; + laplacian(DBEff,B) Gauss linear corrected; + laplacian(alphaEff,hs) Gauss linear uncorrected; + laplacian(alphaEff,fu) Gauss linear uncorrected; + laplacian(alphaEff,ft) Gauss linear uncorrected; + laplacian((((rho*(1|A(U)))*rho)*gh)) Gauss linear uncorrected; + laplacian(interpolate((rho*(1|A(U)))),p) Gauss linear uncorrected; + laplacian(gammaRad,G) Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default corrected; +} + +fluxRequired +{ + default no; + p; +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire2D/system/fvSolution b/tutorials/combustion/fireFoam/les/smallPoolFire2D/system/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..ac4b5ee3ed9fb59fec01e8353c90274f565a9e29 --- /dev/null +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/system/fvSolution @@ -0,0 +1,138 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.openfoam.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSolution; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + rho + { + solver PCG; + preconditioner DIC; + tolerance 0; + relTol 0; + }; + + p + { + solver GAMG; + tolerance 1e-7; + relTol 0.01; + smoother GaussSeidel; + cacheAgglomeration true; + nCellsInCoarsestLevel 10; + agglomerator faceAreaPair; + mergeLevels 1; + }; + + pFinal + { + solver GAMG; + tolerance 1e-7; + relTol 0; + smoother GaussSeidel; + cacheAgglomeration true; + nCellsInCoarsestLevel 10; + agglomerator faceAreaPair; + mergeLevels 1; + }; + + + ft + { + solver smoothSolver; + smoother GaussSeidel; + tolerance 1e-7; + relTol 0; + nSweeps 1; + }; + + fu + { + solver smoothSolver; + smoother GaussSeidel; + tolerance 1e-7; + relTol 0; + nSweeps 1; + }; + + + U + { + solver smoothSolver; + smoother GaussSeidel; + tolerance 1e-7; + relTol 0.1; + nSweeps 1; + }; + + UFinal + { + solver smoothSolver; + smoother GaussSeidel; + tolerance 1e-7; + relTol 0; + nSweeps 1; + }; + + k + { + solver smoothSolver; + smoother GaussSeidel; + tolerance 1e-7; + relTol 0; + nSweeps 1; + }; + + hs + { + solver PBiCG; + preconditioner DILU; + tolerance 1e-7; + relTol 0; + }; + + Ii + { + solver GAMG; + tolerance 1e-4; + relTol 0; + smoother DILU; + cacheAgglomeration true; + nCellsInCoarsestLevel 10; + agglomerator faceAreaPair; + mergeLevels 1; + } + + G + { + solver PCG; + preconditioner DIC; + tolerance 1e-06; + relTol 0; + } + +} + +PISO +{ + momentumPredictor yes; + nOuterCorrectors 1; + nCorrectors 2; + nNonOrthogonalCorrectors 0; +} + +// ************************************************************************* // diff --git a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/Allrun b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/Allrun new file mode 100755 index 0000000000000000000000000000000000000000..945c8974dfc7003e127eeb307d1fa26a1e1f379d --- /dev/null +++ b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/Allrun @@ -0,0 +1,14 @@ +#!/bin/sh + +# Source tutorial run functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions + +application=`getApplication` + +# create mesh +runApplication blockMesh + +# create ignition cells cellSet +runApplication cellSet + +runApplication $application diff --git a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/energySourceProperties b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/energySourceProperties new file mode 100644 index 0000000000000000000000000000000000000000..b2f981a9200a917d8c700d55b4e01f030c50822b --- /dev/null +++ b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/energySourceProperties @@ -0,0 +1,31 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object energySourcesProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +( + source1 + { + active true; + timeStart 0.15; + duration 0.1; + selectionMode cellSet; + volumeMode absolute; + fieldData 10000; + cellSet ignitionCells; + } +); + +// ************************************************************************* // diff --git a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/system/cellSetDict b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/system/cellSetDict new file mode 100644 index 0000000000000000000000000000000000000000..bd2802d8bd1e987d85e9d4544c43da6b6a38886b --- /dev/null +++ b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/system/cellSetDict @@ -0,0 +1,32 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object cellSetDict; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +name ignitionCells; + +action new; + +topoSetSources +( + sphereToCell + { + centre ( 0.125 0.375 0.05 ); + radius 0.005; + } +); + + +// ************************************************************************* // diff --git a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/pointMassSourcesProperties b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/energySourceProperties similarity index 77% rename from tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/pointMassSourcesProperties rename to tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/energySourceProperties index 68218d9f6335e019113634d0dc361173c11fc015..a4828b7dd6354f5e7b080517ed63660366d29dc8 100644 --- a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/pointMassSourcesProperties +++ b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/energySourceProperties @@ -11,22 +11,22 @@ FoamFile format ascii; class dictionary; location "constant"; - object pointMassSourcesProperties; + object energySourcesProperties; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -active true; - -pointSources ( source1 { - timeStart 0.2; - duration 2.0; - location (2.75 0.5 0); - fieldData + active true; + timeStart 0.2; + duration 2.0; + selectionMode points; + volumeMode absolute; + fieldData 10; + points ( - (H2O 0.01) + (2.75 0.5 0) ); } ); diff --git a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/massSourceProperties b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/massSourceProperties new file mode 100644 index 0000000000000000000000000000000000000000..62b51b949588134647f9d0097b9ed0ad5eac22ca --- /dev/null +++ b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/massSourceProperties @@ -0,0 +1,38 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object massSourcesProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +( + source1 + { + active true; + timeStart 0.2; + duration 2.0; + selectionMode points; + volumeMode absolute; + fieldData + ( + (H2O 1e-4) // kg/s + ); + points + ( + (2.75 0.5 0) + ); + } +); + + +// ************************************************************************* // diff --git a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/momentumSourceProperties b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/momentumSourceProperties new file mode 100644 index 0000000000000000000000000000000000000000..46546bc66014f00ffafce925f563529ecf783e78 --- /dev/null +++ b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/momentumSourceProperties @@ -0,0 +1,35 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object momentumSourcesProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +( + source1 + { + active true; + timeStart 0.2; + duration 2.0; + selectionMode points; + volumeMode absolute; + fieldData (0 0.005 0); + points + ( + (2.75 0.5 0) + ); + } +); + + +// ************************************************************************* // diff --git a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/parcelInjectionProperties b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/parcelInjectionProperties index 4b87511c200888dd04b9f79d0d5c6adb8a4edcd7..6a440d2bda09ef650d64cacf63d6a3d174dcdb31 100644 --- a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/parcelInjectionProperties +++ b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/parcelInjectionProperties @@ -14,12 +14,12 @@ FoamFile object scalarListList; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// x y z u v w d rho mDot T cp Y0..YN +// (x y z) (u v w) d rho mDot T cp (Y0..Y2) (Yg0..YgN) (Yl0..YlN) (Ys0..YsN) ( - (0.1 0.32 0.0 0.5 0.25 0.0 0.001 1000 0.2 300 4200 1.0) - (0.1 0.44 0.0 0.5 0.10 0.0 0.001 1000 0.2 300 4200 1.0) - (0.1 0.56 0.0 0.5 -0.10 0.0 0.001 1000 0.2 300 4200 1.0) - (0.1 0.68 0.0 0.5 -0.25 0.0 0.001 1000 0.2 300 4200 1.0) + (0.1 0.32 0.0) (0.5 0.25 0.0) 0.001 1000 0.2 300 4200 (0 1 0) () (1) () + (0.1 0.44 0.0) (0.5 0.10 0.0) 0.001 1000 0.2 300 4200 (0 1 0) () (1) () + (0.1 0.56 0.0) (0.5 -0.10 0.0) 0.001 1000 0.2 300 4200 (0 1 0) () (1) () + (0.1 0.68 0.0) (0.5 -0.25 0.0) 0.001 1000 0.2 300 4200 (0 1 0) () (1) () ); diff --git a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/reactingCloud1Positions b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/reactingCloud1Positions index 4936063330be067d061e1a6130f4847859305b20..380a953bfb4e70c50e1fc93e8e62f8634c91a55e 100644 --- a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/reactingCloud1Positions +++ b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/reactingCloud1Positions @@ -15,30 +15,9 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ( -(0.002 0.002 0.00005) -(0.004 0.002 0.00005) -(0.006 0.002 0.00005) -(0.008 0.002 0.00005) -(0.010 0.002 0.00005) -(0.002 0.004 0.00005) -(0.004 0.004 0.00005) -(0.006 0.004 0.00005) -(0.008 0.004 0.00005) -(0.010 0.004 0.00005) -(0.002 0.006 0.00005) -(0.004 0.006 0.00005) -(0.006 0.006 0.00005) -(0.008 0.006 0.00005) -(0.010 0.006 0.00005) -(0.002 0.008 0.00005) -(0.004 0.008 0.00005) -(0.006 0.008 0.00005) -(0.008 0.008 0.00005) -(0.010 0.008 0.00005) -(0.002 0.010 0.00005) -(0.004 0.010 0.00005) -(0.006 0.010 0.00005) -(0.008 0.010 0.00005) -(0.010 0.010 0.00005) +(0.1 0.32 0.0) +(0.1 0.44 0.0) +(0.1 0.56 0.0) +(0.1 0.68 0.0) ) // ************************************************************************* // diff --git a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/reactingCloud1Properties b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/reactingCloud1Properties index f6fcd38bb30780fe551be5adb939b94d6d8f2429..7541150b7aec08a6ef42cd9243ee2a02e0dfbf0a 100644 --- a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/reactingCloud1Properties +++ b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/reactingCloud1Properties @@ -17,7 +17,8 @@ FoamFile active true; -InjectionModel ReactingLookupTableInjection; +InjectionModel ReactingMultiphaseLookupTableInjection; +//InjectionModel ManualInjection; DragModel SphereDrag; @@ -27,12 +28,16 @@ PatchInteractionModel LocalInteraction; HeatTransferModel RanzMarshall; -CompositionModel SinglePhaseMixture; +CompositionModel SingleMixtureFraction; PhaseChangeModel LiquidEvaporation; PostProcessingModel PatchPostProcessing; +DevolatilisationModel none; + +SurfaceReactionModel none; + radiation off; coupled true; @@ -55,6 +60,8 @@ constantProperties Pr Pr [ 0 0 0 0 0 ] 0.7; Tvap Tvap [ 0 0 0 1 0 ] 273; Tbp Tvap [ 0 0 0 1 0 ] 373; + LDevol LDevol [ 0 0 0 0 0 ] 0; + hRetentionCoeff hRetentionCoeff [ 0 0 0 0 0 ] 1; constantVolume false; } @@ -83,9 +90,9 @@ particleForces ManualInjectionCoeffs { - massTotal massTotal [ 1 0 0 0 0 ] 1e-2; + massTotal massTotal [ 1 0 0 0 0 ] 1e-3; parcelBasisType mass; - SOI 0; + SOI 0.5; positionsFile "reactingCloud1Positions"; U0 ( 0 0 0 ); parcelPDF @@ -99,7 +106,7 @@ ManualInjectionCoeffs } } -ReactingLookupTableInjectionCoeffs +ReactingMultiphaseLookupTableInjectionCoeffs { massTotal massTotal [ 1 0 0 0 0 ] 1e-2; parcelBasisType mass; @@ -109,7 +116,6 @@ ReactingLookupTableInjectionCoeffs parcelsPerSecond 250; } - StandardWallInteractionCoeffs { type rebound; @@ -135,15 +141,24 @@ RanzMarshallCoeffs BirdCorrection true; } -SinglePhaseMixtureCoeffs +SingleMixtureFractionCoeffs { phases ( + gas + { + } liquid { - H2O 1; + H2O 1; + } + solid + { } ); + YGasTot0 0; + YLiquidTot0 1; + YSolidTot0 0; } LiquidEvaporationCoeffs diff --git a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/parcelInBox/constant/reactingCloud1Properties b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/parcelInBox/constant/reactingCloud1Properties index e488fffacc5b095a9e340153f493aaa9ec21f256..c320e60ae1bf85aea2ec52009276c0399044187c 100644 --- a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/parcelInBox/constant/reactingCloud1Properties +++ b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/parcelInBox/constant/reactingCloud1Properties @@ -27,10 +27,14 @@ PatchInteractionModel StandardWallInteraction; HeatTransferModel RanzMarshall; -CompositionModel SinglePhaseMixture; +CompositionModel SingleMixtureFraction; PhaseChangeModel LiquidEvaporation; +DevolatilisationModel none; + +SurfaceReactionModel none; + PostProcessingModel none; radiation off; @@ -55,6 +59,8 @@ constantProperties Tvap Tvap [ 0 0 0 1 0 ] 284; Tbp Tbp [ 0 0 0 1 0 ] 373; Pr Pr [ 0 0 0 0 0 ] 0.7; + LDevol LDevol [ 0 0 0 0 0 ] 0; + hRetentionCoeff hRetentionCoeff [ 0 0 0 0 0 ] 1; constantVolume false; } @@ -110,15 +116,24 @@ RanzMarshallCoeffs BirdCorrection off; } -SinglePhaseMixtureCoeffs +SingleMixtureFractionCoeffs { phases ( + gas + { + } liquid { - H2O 1; + H2O 1; + } + solid + { } ); + YGasTot0 0; + YLiquidTot0 1; + YSolidTot0 0; } LiquidEvaporationCoeffs diff --git a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/verticalChannel/0/U b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/verticalChannel/0/U index b2ed1ea6d74f3d52badf34a348c389941adbacb2..39d9711c4080366f8db54efaeefbe1c0551951d0 100644 --- a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/verticalChannel/0/U +++ b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/verticalChannel/0/U @@ -33,13 +33,13 @@ boundaryField { type flowRateInletVelocity; flowRate 0.00379; - value uniform (-0 10.82857143 -0); + value uniform (0 10.82857143 0); } inletSides { type flowRateInletVelocity; flowRate 0.00832; - value uniform (-0 11.88571429 -0); + value uniform (0 11.88571429 0); } outlet { diff --git a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/verticalChannel/constant/reactingCloud1Properties b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/verticalChannel/constant/reactingCloud1Properties index ddb7eaf3a9beccf5275e6fa3db5eac511096588d..1dbbf94c3f9a4aace6dabf2db13a0c5bdb4363ec 100644 --- a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/verticalChannel/constant/reactingCloud1Properties +++ b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/verticalChannel/constant/reactingCloud1Properties @@ -27,10 +27,14 @@ PatchInteractionModel StandardWallInteraction; HeatTransferModel RanzMarshall; -CompositionModel SinglePhaseMixture; +CompositionModel SingleMixtureFraction; PhaseChangeModel LiquidEvaporation; +DevolatilisationModel none; + +SurfaceReactionModel none; + PostProcessingModel PatchPostProcessing; radiation off; @@ -55,6 +59,8 @@ constantProperties Tvap Tvap [ 0 0 0 1 0 ] 273; Tbp Tbp [ 0 0 0 1 0 ] 373; Pr Pr [ 0 0 0 0 0 ] 0.7; + LDevol LDevol [ 0 0 0 0 0 ] 0; + hRetentionCoeff hRetentionCoeff [ 0 0 0 0 0 ] 1; constantVolume false; } @@ -132,15 +138,24 @@ RanzMarshallCoeffs BirdCorrection off; } -SinglePhaseMixtureCoeffs +SingleMixtureFractionCoeffs { phases ( + gas + { + } liquid { - H2O 1; + H2O 1; + } + solid + { } ); + YGasTot0 0; + YLiquidTot0 1; + YSolidTot0 0; } LiquidEvaporationCoeffs diff --git a/wmake/rules/General/coco b/wmake/rules/General/coco new file mode 100644 index 0000000000000000000000000000000000000000..7f7bd2ff29b58e6d8b869fa567b2aa00cf2b1bd4 --- /dev/null +++ b/wmake/rules/General/coco @@ -0,0 +1,13 @@ +# handie Coco/R attributed grammars + +.SUFFIXES: .atg + +atgtoo = \ + $(WM_THIRD_PARTY_DIR)/coco-cpp/platforms/$(WM_ARCH)$(WM_COMPILER)/bin/coco-cpp \ + -single \ + -frames $(WM_THIRD_PARTY_DIR)/coco-cpp/platforms/share/coco-cpp \ + $$SOURCE -o $(OBJECTS_DIR) && \ + $(CC) $(c++FLAGS) -c $*.cpp -o $@ + +.atg.dep: + $(MAKE_DEP) diff --git a/wmake/rules/General/standard b/wmake/rules/General/standard index 809f9353a2d6f179ebc3329b5c8ce67142b01af2..3188ac4413f749392e8e11bd094bd767fc5cf7b7 100644 --- a/wmake/rules/General/standard +++ b/wmake/rules/General/standard @@ -4,6 +4,7 @@ include $(GENERAL_RULES)/sourceToDep include $(GENERAL_RULES)/flex include $(GENERAL_RULES)/flex++ +include $(GENERAL_RULES)/coco ## include $(GENERAL_RULES)/byacc ## include $(GENERAL_RULES)/btyacc++ include $(GENERAL_RULES)/bison diff --git a/wmake/src/Makefile b/wmake/src/Makefile index a74c250f8815ba0020d9cef77f587551c725e2ad..cac2a639a5238b358d2abb78977435f8148ae417 100644 --- a/wmake/src/Makefile +++ b/wmake/src/Makefile @@ -2,7 +2,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------ # License @@ -60,16 +60,17 @@ include $(RULES)/$(WM_LINK_LANGUAGE) # targets #------------------------------------------------------------------------------ -all: $(BIN)/dirToString $(BIN)/wmkdep +all: $(BIN)/dirToString $(BIN)/wmkdep $(BIN)/wmkdepend clean: - rm -f $(BIN)/dirToString $(BIN)/wmkdep 2>/dev/null + rm -f $(BIN)/dirToString $(BIN)/wmkdep $(BIN)/wmkdepend 2>/dev/null $(BIN)/dirToString: dirToString.c @mkdir -p $(BIN) $(cc) $(cFLAGS) dirToString.c -o $(BIN)/dirToString + $(BIN)/wmkdep: wmkdep.l @mkdir -p $(BIN) flex wmkdep.l @@ -77,4 +78,13 @@ $(BIN)/wmkdep: wmkdep.l @rm -f lex.yy.c 2>/dev/null +# for bootstrapping - use generated files directly (instead of from .atg file) +$(BIN)/wmkdepend: wmkdepend.cpp \ + wmkdependParser.cpp wmkdependScanner.cpp \ + wmkdependParser.h wmkdependScanner.h + @mkdir -p $(BIN) + $(CC) $(c++FLAGS) \ + wmkdepend.cpp wmkdependParser.cpp wmkdependScanner.cpp \ + -o $(BIN)/wmkdepend + #------------------------------------------------------------------------------ diff --git a/wmake/src/wmkdepend.cpp b/wmake/src/wmkdepend.cpp new file mode 100644 index 0000000000000000000000000000000000000000..159fb3849b9046fbf4716922492b084bb736ac27 --- /dev/null +++ b/wmake/src/wmkdepend.cpp @@ -0,0 +1,164 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + wmkdepend + +Description + A fast dependency list generator that emulates the behaviour and + output of cpp -M. However, the output contains no duplications and + is ~40% faster than cpp. + + The algorithm uses flex to scan for includes and searches the files + found. Each file is entered into a hash table so that files are scanned + only once. This is why this program is faster than cpp. + +Usage + wmkdep [ -Idirectory ... -Idirectory ] filename + +\*---------------------------------------------------------------------------*/ + +#include <cstdio> +#include <stdlib.h> +#include <cstring> + +#include "wmkdependParser.h" + +// Note: since we use the Coco/R default error messages, we must use +// wide streams for stderr. + +void printUsage(const char* message = NULL) +{ + if (message) + { + fwprintf(stderr, L"\nError: %s\n\n", message); + } + + fwprintf + ( + stderr, + L"Usage: wmkdepend [ -Idirectory ... -Idirectory ] filename\n" + ); +} + + +int main(int argc, char* argv[]) +{ + if (argc == 1) + { + printUsage("Error: input file not supplied"); + ::exit(1); + } + + for (int i=1; i < argc; i++) + { + if (strncmp(argv[i], "-I", 2) == 0 && strlen(argv[i]) > 2) + { + std::string dirName(argv[i] + 2); + + // add trailing slash if required + if (dirName.rfind('/') != dirName.size()-1) + { + dirName += '/'; + } + + wmake::Parser::includeDirs.push_back(dirName); + } + } + + std::string sourceFile(argv[argc-1]); + + fwprintf + ( + stderr, + L"Making dependency list for source file %s\n", + sourceFile.c_str() + ); + + std::string::size_type basePos = sourceFile.rfind('/'); + if (basePos == std::string::npos) + { + basePos = 0; + } + else + { + basePos++; + } + + std::string::size_type dotPos = sourceFile.rfind('.'); + if + ( + dotPos == std::string::npos + || dotPos == sourceFile.size()-1 + || dotPos <= basePos + ) + { + fwprintf + ( + stderr, + L"Cannot find extension in source file name %s\n", + sourceFile.c_str() + ); + ::exit(1); + } + + std::string depFile = sourceFile.substr(0, dotPos); + depFile += ".dep"; + + const std::string sourceExt = sourceFile.substr(dotPos); + if (sourceExt == ".java") + { + // import directories to ignore + wmake::Parser::ignoreDir("java.*"); + wmake::Parser::ignoreDir("org.*"); + wmake::Parser::ignoreDir("com.*"); + wmake::Parser::ignoreDir("sunw.*"); + wmake::Parser::ignoreDir("sun.*"); + wmake::Parser::ignoreDir("launcher.*"); + + std::cout + << "$(CLASSES_DIR)/" + << sourceFile.substr(basePos, dotPos - basePos) << ".class: " + << depFile << "\n"; + } + else + { + std::cout + << "$(OBJECTS_DIR)/" + << sourceFile.substr(basePos, dotPos - basePos) << ".o: " + << depFile << "\n"; + } + + + wmake::Parser::sourceFile = sourceFile; + wmake::Parser::depFile = depFile; + + wmake::Parser::includeFile(sourceFile); + + return 0; +} + + + +/*****************************************************************************/ diff --git a/wmake/src/wmkdependParser.atg b/wmake/src/wmkdependParser.atg new file mode 100644 index 0000000000000000000000000000000000000000..2da6ebd31333d55539958a446f00affb782332e0 --- /dev/null +++ b/wmake/src/wmkdependParser.atg @@ -0,0 +1,497 @@ +/*---------------------------------------------------------------------------*\ + Attributed Grammar for Coco/R (-*- C++ -*- version) + compile with: + coco-cpp wmkdependParser.atg +\*---------------------------------------------------------------------------*/ +[copy] +/*---------------------------------*- C++ -*---------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +@file wmkdependParser.atg + +Description + An attributed Coco/R grammar to parse C/C++, Fortran and Java files + for include and import statements. + +SourceFiles + generated + +\*---------------------------------------------------------------------------*/ +[/copy] +#include <iostream> +#include <string> +#include <list> + +//! @brief A simple HashTable implementation +/** + * @note This hash table is only vaguely STL-like. In accordance with + * its present purpose, this hash table only supports a constIterator + * and no deletions. For simplicity, the constIterator increment is + * simply via a next() method. Instead of comparing to an end value, + * the constIterator valid() method is used. + * For example, + * @code + * for + * ( + * HashTable<foo>::constIterator iter = myHash.begin(); + * iter.valid(); + * iter.next() + * ) + * { + * std::cerr<< "key: " << iter.key() << "\n"; + * } + * @endcode + * + */ +class StringHashSet +{ + //! An entry within the HashTable + struct hashedEntry + { + const std::string key_; //<! The lookup key + hashedEntry *next_; //<! Pointer to next hashedEntry in sub-list + + hashedEntry(const std::string& key, hashedEntry *next=0) + : + key_(key), next_(next) + {} + }; + + const int size_; //<! fixed HashTable size + hashedEntry** table_; + +public: + + //! Construct with a default size + StringHashSet(int size = 500) + : + size_(size), + table_(new hashedEntry*[size_]) + { + memset(table_, 0, size_ * sizeof(hashedEntry*)); + } + + //! Destructor + ~StringHashSet() + { + for (int hashIdx = 0; hashIdx < size_; ++hashIdx) + { + hashedEntry* ep = table_[hashIdx]; + while (ep) + { + hashedEntry* del = ep; + ep = ep->next_; + delete del; + } + } + delete[] table_; + table_ = 0; + } + + //! Return hash index for lookup name in hash table + bool hashKeyIndex(const std::string& name) const + { + int hashIdx = 0; + + // calculate hash index + for + ( + std::string::const_iterator iter = name.begin(); + iter != name.end(); + ++iter + ) + { + hashIdx = hashIdx << 1 ^ *iter; + } + + if (hashIdx < 0) + { + hashIdx = -hashIdx; + } + + return hashIdx % size_; + } + + + //! Return true if name is found in hash table + bool found(const std::string& name) const + { + const int hashIdx = hashKeyIndex(name); + + for (hashedEntry* ep = table_[hashIdx]; ep; ep = ep->next_) + { + if (name == ep->key_) + { + // found + return true; + } + } + + // entry not found + return false; + } + + + //! Return true if name is found in hash table, insert if not found + bool foundOrInsert(const std::string& name) + { + const int hashIdx = hashKeyIndex(name); + + for (hashedEntry* ep = table_[hashIdx]; ep; ep = ep->next_) + { + if (name == ep->key_) + { + // found - return true + return true; + } + } + + // not found - insert it + table_[hashIdx] = new hashedEntry(name, table_[hashIdx]); + + // entry not found (but was added) - return false + return false; + } + +}; + + +/*---------------------------------------------------------------------------*/ + +COMPILER wmkdepend + // grammar pragmas: + $namespace=wmake + $prefix=wmkdepend + $define=FORCE_UTF8 + +/*---------------------------------------------------------------------------*/ +private: + + //! Hash of files already visited + static StringHashSet visitedFiles_; + + //! Hash of (java) directories already visited + static StringHashSet visitedDirs_; + + //! Replace all '.' with '/' + static void dotToSlash(std::string& name); + + //! Import (java) directories + static void importDir(const std::string& dirName); + + //! Import (java) file + static void importFile(const std::string& name); + +public: + //! Include directories to search + static std::list<std::string> includeDirs; + + //! The name of the top-level source file + static std::string sourceFile; + + //! The name of the top-level dep file + static std::string depFile; + + //! Add directory to list of visited dirs, thus effectively ignoring it + static void ignoreDir(const std::string& name); + + //! Include file + static void includeFile(const std::string& name); + +/*---------------------------------------------------------------------------*/ +[code] +#include <sys/types.h> +#include <dirent.h> + +StringHashSet Parser::visitedFiles_; +StringHashSet Parser::visitedDirs_; + +std::list<std::string> Parser::includeDirs; +std::string Parser::sourceFile; +std::string Parser::depFile; + + +void Parser::dotToSlash(std::string& name) +{ + std::string::size_type start = 0; + + while ((start = name.find('.', start)) != std::string::npos) + { + name.replace(start, 1, 1, '/'); + start++; + } +} + + +void Parser::ignoreDir(const std::string& name) +{ + visitedDirs_.foundOrInsert(name); +} + + +void Parser::includeFile(const std::string& name) +{ + if (visitedFiles_.foundOrInsert(name)) + { + return; + } + + // use stdio and buffering within Coco/R -- (faster) + FILE *fh = fopen(name.c_str(), "r"); + if (fh) + { + std::cout << depFile << ": " << name << "\n"; + } + else + { + for + ( + std::list<std::string>::const_iterator iter = includeDirs.begin(); + iter != includeDirs.end(); + ++iter + ) + { + const std::string pathName = *iter + name; + + fh = fopen(pathName.c_str(), "r"); + if (fh) + { + std::cout << depFile << ": " << pathName << "\n"; + break; + } + } + } + + if (fh) + { + Scanner scanner(fh); + Parser parser(&scanner); + + parser.Parse(); + fclose(fh); + } + else + { + fwprintf + ( + stderr, + L"could not open file %s for source file %s\n", + name.c_str(), sourceFile.c_str() + ); + } +} + + +void Parser::importFile(const std::string& name) +{ + // check if a globbed form was already visited + std::string::size_type dotPos = name.find('.'); + if (dotPos != std::string::npos) + { + std::string dirGlob = name.substr(0, dotPos); + dirGlob += ".*"; + + if (visitedDirs_.found(dirGlob)) + { + return; + } + } + + std::string javaFileName = name; + + dotToSlash(javaFileName); + javaFileName += ".java"; + + includeFile(javaFileName); +} + + +void Parser::importDir(const std::string& name) +{ + if (visitedDirs_.foundOrInsert(name)) + { + return; + } + + std::string dirName = name; + dotToSlash(dirName); + + DIR *source = opendir(dirName.c_str()); + + if (source) + { + struct dirent *list; + + // Read and parse all the entries in the directory + while ((list = readdir(source)) != NULL) + { + const char* ext = strstr(list->d_name, ".java"); + + // avoid matching on something like '.java~' + if (ext && strlen(ext) == 5) + { + std::string pathName = dirName + list->d_name; + includeFile(pathName); + } + } + + closedir(source); + } + else + { + fwprintf + ( + stderr, + L"could not open directory %s\n", + dirName.c_str() + ); + return; + } +} + +[/code] + + +/*---------------------------------------------------------------------------*/ + +CHARACTERS + letter = 'A'..'Z' + 'a'..'z' + '_'. + digit = "0123456789". + cr = '\r'. + lf = '\n'. + tab = '\t'. + stringCh = ANY - '"' - '\\' - cr - lf. + printable = '\u0020' .. '\u007e'. + java_letter = letter + '$'. + +// * * * * * * * * * * * * * * * * TOKENS * * * * * * * * * * * * * * * * * // + +TOKENS + +// string +string = + '"' { stringCh | '\\' printable } '"'. + +// single-quoted string (eg, Fortran) +sqstring = + '\'' { stringCh | '\\' printable } '\''. + +// for java import +package_name = + java_letter { java_letter | digit } + { '.' java_letter { java_letter | digit } } . + +// for java import +package_dir = + java_letter { java_letter | digit } + { '.' java_letter { java_letter | digit } } ".*" . + + +// * * * * * * * * * * * PRAGMAS / COMMENTS / IGNORE * * * * * * * * * * * // + +COMMENTS FROM "/*" TO "*/" NESTED +COMMENTS FROM "//" TO lf + +IGNORE tab + +// * * * * * * * * * * * * * * * PRODUCTIONS * * * * * * * * * * * * * * * // + +PRODUCTIONS + +wmkdepend += +{ + // C/C++-style includes + '#' + [ + "include" + [ + string (. + if (isUTF8()) + { + includeFile(t->toStringUTF8(1, t->length()-2)); + } + else + { + includeFile(t->toString(1, t->length()-2)); + } + .) + ] + ] + [ ANY { ANY } ] '\n' // skip trailing junk + + // Fortran-style includes + | "include" + [ + sqstring (. + if (isUTF8()) + { + includeFile(t->toStringUTF8(1, t->length()-2)); + } + else + { + includeFile(t->toString(1, t->length()-2)); + } + .) + ] + [ ANY { ANY } ] '\n' // skip trailing junk + + // Java imports + | "import" + ( + package_dir (. + if (isUTF8()) + { + importDir(t->toStringUTF8()); + } + else + { + importDir(t->toString()); + } + .) + | package_name (. + if (isUTF8()) + { + importFile(t->toStringUTF8()); + } + else + { + importFile(t->toString()); + } + .) + ) + ';' + [ ANY { ANY } ] '\n' // skip trailing junk + + | [ ANY { ANY } ] '\n' // skip any other lines + +} +. + + +/*---------------------------------------------------------------------------*/ + +END wmkdepend. + +// ************************************************************************* // diff --git a/wmake/src/wmkdependParser.cpp b/wmake/src/wmkdependParser.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b6d5e4e71a11114a14ee50bcc579ea249a807684 --- /dev/null +++ b/wmake/src/wmkdependParser.cpp @@ -0,0 +1,575 @@ +/*---------------------------------*- C++ -*---------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +@file wmkdependParser.atg + +Description + An attributed Coco/R grammar to parse C/C++, Fortran and Java files + for include and import statements. + +SourceFiles + generated + +\*---------------------------------------------------------------------------*/ +// This file was generated with Coco/R C++ (7 Feb 2010) +// http://www.ssw.uni-linz.ac.at/coco/ +// with these defines: +// - FORCE_UTF8 + + +#include <cstdio> +#include <cstdlib> +#include <cstring> +#include <cwchar> +#include <sstream> + +#include "wmkdependParser.h" + +namespace wmake { + + +#include <sys/types.h> +#include <dirent.h> + +StringHashSet Parser::visitedFiles_; +StringHashSet Parser::visitedDirs_; + +std::list<std::string> Parser::includeDirs; +std::string Parser::sourceFile; +std::string Parser::depFile; + + +void Parser::dotToSlash(std::string& name) +{ + std::string::size_type start = 0; + + while ((start = name.find('.', start)) != std::string::npos) + { + name.replace(start, 1, 1, '/'); + start++; + } +} + + +void Parser::ignoreDir(const std::string& name) +{ + visitedDirs_.foundOrInsert(name); +} + + +void Parser::includeFile(const std::string& name) +{ + if (visitedFiles_.foundOrInsert(name)) + { + return; + } + + // use stdio and buffering within Coco/R -- (faster) + FILE *fh = fopen(name.c_str(), "r"); + if (fh) + { + std::cout << depFile << ": " << name << "\n"; + } + else + { + for + ( + std::list<std::string>::const_iterator iter = includeDirs.begin(); + iter != includeDirs.end(); + ++iter + ) + { + const std::string pathName = *iter + name; + + fh = fopen(pathName.c_str(), "r"); + if (fh) + { + std::cout << depFile << ": " << pathName << "\n"; + break; + } + } + } + + if (fh) + { + Scanner scanner(fh); + Parser parser(&scanner); + + parser.Parse(); + fclose(fh); + } + else + { + fwprintf + ( + stderr, + L"could not open file %s for source file %s\n", + name.c_str(), sourceFile.c_str() + ); + } +} + + +void Parser::importFile(const std::string& name) +{ + // check if a globbed form was already visited + std::string::size_type dotPos = name.find('.'); + if (dotPos != std::string::npos) + { + std::string dirGlob = name.substr(0, dotPos); + dirGlob += ".*"; + + if (visitedDirs_.found(dirGlob)) + { + return; + } + } + + std::string javaFileName = name; + + dotToSlash(javaFileName); + javaFileName += ".java"; + + includeFile(javaFileName); +} + + +void Parser::importDir(const std::string& name) +{ + if (visitedDirs_.foundOrInsert(name)) + { + return; + } + + std::string dirName = name; + dotToSlash(dirName); + + DIR *source = opendir(dirName.c_str()); + + if (source) + { + struct dirent *list; + + // Read and parse all the entries in the directory + while ((list = readdir(source)) != NULL) + { + const char* ext = strstr(list->d_name, ".java"); + + // avoid matching on something like '.java~' + if (ext && strlen(ext) == 5) + { + std::string pathName = dirName + list->d_name; + includeFile(pathName); + } + } + + closedir(source); + } + else + { + fwprintf + ( + stderr, + L"could not open directory %s\n", + dirName.c_str() + ); + return; + } +} + + + + +//! @cond fileScope +// + +// +// Create by copying str - only used locally +inline static wchar_t* coco_string_create(const wchar_t* str) +{ + const int len = wcslen(str); + wchar_t* dst = new wchar_t[len + 1]; + wcsncpy(dst, str, len); + dst[len] = 0; + return dst; +} + + +// Free storage and nullify the argument +inline static void coco_string_delete(wchar_t* &str) +{ + delete[] str; + str = NULL; +} +// +//! @endcond fileScope + + +// ---------------------------------------------------------------------------- +// Parser Implementation +// ---------------------------------------------------------------------------- + +void Parser::SynErr(int n) +{ + if (errDist >= minErrDist) errors->SynErr(la->line, la->col, n); + errDist = 0; +} + + +void Parser::SemErr(const std::wstring& msg) +{ + if (errDist >= minErrDist) errors->Error(t->line, t->col, msg); + errDist = 0; +} + + +bool Parser::isUTF8() const +{ + return scanner && scanner->buffer && scanner->buffer->isUTF8(); +} + + +void Parser::Get() +{ + for (;;) + { + t = la; + la = scanner->Scan(); + if (la->kind <= maxT) + { + ++errDist; + break; + } + if (dummyToken != t) + { + dummyToken->kind = t->kind; + dummyToken->pos = t->pos; + dummyToken->col = t->col; + dummyToken->line = t->line; + dummyToken->next = NULL; + coco_string_delete(dummyToken->val); + dummyToken->val = coco_string_create(t->val); + t = dummyToken; + } + la = t; + } +} + + +void Parser::Expect(int n) +{ + if (la->kind == n) + { + Get(); + } + else + { + SynErr(n); + } +} + + +void Parser::ExpectWeak(int n, int follow) +{ + if (la->kind == n) + { + Get(); + } + else + { + SynErr(n); + while (!StartOf(follow)) + { + Get(); + } + } +} + + +bool Parser::WeakSeparator(int n, int syFol, int repFol) +{ + if (la->kind == n) + { + Get(); + return true; + } + else if (StartOf(repFol)) + { + return false; + } + else + { + SynErr(n); + while (!(StartOf(syFol) || StartOf(repFol) || StartOf(0))) + { + Get(); + } + return StartOf(syFol); + } +} + + +void Parser::wmkdepend() +{ + while (StartOf(1)) { + if (la->kind == 5) { + Get(); + if (la->kind == 6) { + Get(); + if (la->kind == 1) { + Get(); + if (isUTF8()) + { + includeFile(t->toStringUTF8(1, t->length()-2)); + } + else + { + includeFile(t->toString(1, t->length()-2)); + } + + } + } + if (StartOf(2)) { + Get(); + while (StartOf(3)) { + Get(); + } + } + Expect(7); + } else if (la->kind == 6) { + Get(); + if (la->kind == 2) { + Get(); + if (isUTF8()) + { + includeFile(t->toStringUTF8(1, t->length()-2)); + } + else + { + includeFile(t->toString(1, t->length()-2)); + } + + } + if (StartOf(4)) { + Get(); + while (StartOf(3)) { + Get(); + } + } + Expect(7); + } else if (la->kind == 8) { + Get(); + if (la->kind == 4) { + Get(); + if (isUTF8()) + { + importDir(t->toStringUTF8()); + } + else + { + importDir(t->toString()); + } + + } else if (la->kind == 3) { + Get(); + if (isUTF8()) + { + importFile(t->toStringUTF8()); + } + else + { + importFile(t->toString()); + } + + } else SynErr(11); + Expect(9); + if (StartOf(3)) { + Get(); + while (StartOf(3)) { + Get(); + } + } + Expect(7); + } else { + if (StartOf(5)) { + Get(); + while (StartOf(3)) { + Get(); + } + } + Expect(7); + } + } +} + + + +void Parser::Parse() +{ + t = NULL; + // might call Parse() twice + if (dummyToken) { + coco_string_delete(dummyToken->val); + delete dummyToken; + } + dummyToken = new Token(coco_string_create(L"Dummy Token")); + la = dummyToken; + Get(); + wmkdepend(); + Expect(0); // expect end-of-file automatically added +} + + +Parser::Parser(Scanner* scan, Errors* err) +: + dummyToken(NULL), + deleteErrorsDestruct_(!err), + errDist(minErrDist), + scanner(scan), + errors(err), + t(NULL), + la(NULL) +{ + if (!errors) // add in default error handling + { + errors = new Errors(); + } + // user-defined initializations: +} + + +bool Parser::StartOf(int s) +{ + const bool T = true; + const bool x = false; + + static const bool set[6][12] = + { + {T,x,x,x, x,x,x,x, x,x,x,x}, + {x,T,T,T, T,T,T,T, T,T,T,x}, + {x,x,T,T, T,T,x,x, T,T,T,x}, + {x,T,T,T, T,T,T,x, T,T,T,x}, + {x,T,x,T, T,T,T,x, T,T,T,x}, + {x,T,T,T, T,x,x,x, x,T,T,x} + }; + + return set[s][la->kind]; +} + + +Parser::~Parser() +{ + if (deleteErrorsDestruct_) { delete errors; } // delete default error handling + if (dummyToken) { + coco_string_delete(dummyToken->val); + delete dummyToken; + } + // user-defined destruction: +} + + +// ---------------------------------------------------------------------------- +// Errors Implementation +// ---------------------------------------------------------------------------- + +Errors::Errors() +: + count(0) +{} + + +Errors::~Errors() +{} + + +void Errors::clear() +{ + count = 0; +} + + +std::wstring Errors::strerror(int n) +{ + switch (n) { + case 0: return L"EOF expected"; break; + case 1: return L"string expected"; break; + case 2: return L"sqstring expected"; break; + case 3: return L"package_name expected"; break; + case 4: return L"package_dir expected"; break; + case 5: return L"\"#\" expected"; break; + case 6: return L"\"include\" expected"; break; + case 7: return L"\"\\n\" expected"; break; + case 8: return L"\"import\" expected"; break; + case 9: return L"\";\" expected"; break; + case 10: return L"??? expected"; break; + case 11: return L"invalid wmkdepend"; break; + default: + { + // std::wostringstream buf; (this typedef might be missing) + std::basic_ostringstream<wchar_t> buf; + buf << "error " << n; + return buf.str(); + } + break; + } +} + + +void Errors::Warning(const std::wstring& msg) +{ + fwprintf(stderr, L"%ls\n", msg.c_str()); +} + + +void Errors::Warning(int line, int col, const std::wstring& msg) +{ + fwprintf(stderr, L"-- line %d col %d: %ls\n", line, col, msg.c_str()); +} + + +void Errors::Error(int line, int col, const std::wstring& msg) +{ + fwprintf(stderr, L"-- line %d col %d: %ls\n", line, col, msg.c_str()); + count++; +} + + +void Errors::SynErr(int line, int col, int n) +{ + this->Error(line, col, this->strerror(n)); +} + + +void Errors::Exception(const std::wstring& msg) +{ + fwprintf(stderr, L"%ls", msg.c_str()); + ::exit(1); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace + +// ************************************************************************* // diff --git a/wmake/src/wmkdependParser.h b/wmake/src/wmkdependParser.h new file mode 100644 index 0000000000000000000000000000000000000000..8c7703adbd6a2eece7c06394cdff879d21e89cb1 --- /dev/null +++ b/wmake/src/wmkdependParser.h @@ -0,0 +1,310 @@ +/*---------------------------------*- C++ -*---------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +@file wmkdependParser.atg + +Description + An attributed Coco/R grammar to parse C/C++, Fortran and Java files + for include and import statements. + +SourceFiles + generated + +\*---------------------------------------------------------------------------*/ +// This file was generated with Coco/R C++ (7 Feb 2010) +// http://www.ssw.uni-linz.ac.at/coco/ +// with these defines: +// - FORCE_UTF8 + + +#ifndef COCO_wmkdependPARSER_H__ +#define COCO_wmkdependPARSER_H__ + +#include <iostream> +#include <string> +#include <list> + +//! @brief A simple HashTable implementation +/** + * @note This hash table is only vaguely STL-like. In accordance with + * its present purpose, this hash table only supports a constIterator + * and no deletions. For simplicity, the constIterator increment is + * simply via a next() method. Instead of comparing to an end value, + * the constIterator valid() method is used. + * For example, + * @code + * for + * ( + * HashTable<foo>::constIterator iter = myHash.begin(); + * iter.valid(); + * iter.next() + * ) + * { + * std::cerr<< "key: " << iter.key() << "\n"; + * } + * @endcode + * + */ +class StringHashSet +{ + //! An entry within the HashTable + struct hashedEntry + { + const std::string key_; //<! The lookup key + hashedEntry *next_; //<! Pointer to next hashedEntry in sub-list + + hashedEntry(const std::string& key, hashedEntry *next=0) + : + key_(key), next_(next) + {} + }; + + const int size_; //<! fixed HashTable size + hashedEntry** table_; + +public: + + //! Construct with a default size + StringHashSet(int size = 500) + : + size_(size), + table_(new hashedEntry*[size_]) + { + memset(table_, 0, size_ * sizeof(hashedEntry*)); + } + + //! Destructor + ~StringHashSet() + { + for (int hashIdx = 0; hashIdx < size_; ++hashIdx) + { + hashedEntry* ep = table_[hashIdx]; + while (ep) + { + hashedEntry* del = ep; + ep = ep->next_; + delete del; + } + } + delete[] table_; + table_ = 0; + } + + //! Return hash index for lookup name in hash table + bool hashKeyIndex(const std::string& name) const + { + int hashIdx = 0; + + // calculate hash index + for + ( + std::string::const_iterator iter = name.begin(); + iter != name.end(); + ++iter + ) + { + hashIdx = hashIdx << 1 ^ *iter; + } + + if (hashIdx < 0) + { + hashIdx = -hashIdx; + } + + return hashIdx % size_; + } + + + //! Return true if name is found in hash table + bool found(const std::string& name) const + { + const int hashIdx = hashKeyIndex(name); + + for (hashedEntry* ep = table_[hashIdx]; ep; ep = ep->next_) + { + if (name == ep->key_) + { + // found + return true; + } + } + + // entry not found + return false; + } + + + //! Return true if name is found in hash table, insert if not found + bool foundOrInsert(const std::string& name) + { + const int hashIdx = hashKeyIndex(name); + + for (hashedEntry* ep = table_[hashIdx]; ep; ep = ep->next_) + { + if (name == ep->key_) + { + // found - return true + return true; + } + } + + // not found - insert it + table_[hashIdx] = new hashedEntry(name, table_[hashIdx]); + + // entry not found (but was added) - return false + return false; + } + +}; + + +/*---------------------------------------------------------------------------*/ + + + +#include "wmkdependScanner.h" + +namespace wmake { + + +/*---------------------------------------------------------------------------*\ + Class Errors Declaration +\*---------------------------------------------------------------------------*/ +//! Parser error handing +class Errors +{ +public: + int count; //!< The number of errors detected + + //! Return a string describing the given error code. + static std::wstring strerror(int n); + + Errors(); //!< Construct null - start with no errors + virtual ~Errors(); //!< Destructor + virtual void clear(); //!< Clear the error count + + //! Handle a general warning 'msg' + virtual void Warning(const std::wstring& msg); + //! Handle a general warning 'msg' + virtual void Warning(int line, int col, const std::wstring& msg); + //! Handle general error 'msg' (eg, a semantic error) + virtual void Error(int line, int col, const std::wstring& msg); + //! Handle syntax error 'n', uses strerror for the message, calls Error() + virtual void SynErr(int line, int col, int n); + //! Handle a general exception 'msg' + virtual void Exception(const std::wstring& msg); + +}; // Errors + + + +/*---------------------------------------------------------------------------*\ + Class Parser Declaration +\*---------------------------------------------------------------------------*/ +//! A Coco/R Parser +class Parser +{ + enum { + _EOF=0, + _string=1, + _sqstring=2, + _package_name=3, + _package_dir=4, + maxT = 10 //<! max term (w/o pragmas) + }; + static const int minErrDist = 2; //!< min. distance before reporting errors + + Token *dummyToken; + bool deleteErrorsDestruct_; //!< delete the 'errors' member in destructor + int errDist; + + void SynErr(int n); //!< Handle syntax error 'n' + void Get(); + void Expect(int n); + bool StartOf(int s); + void ExpectWeak(int n, int follow); + bool WeakSeparator(int n, int syFol, int repFol); + +public: + Scanner *scanner; + Errors *errors; + + Token *t; //!< last recognized token + Token *la; //!< lookahead token + +private: + + //! Hash of files already visited + static StringHashSet visitedFiles_; + + //! Hash of (java) directories already visited + static StringHashSet visitedDirs_; + + //! Replace all '.' with '/' + static void dotToSlash(std::string& name); + + //! Import (java) directories + static void importDir(const std::string& dirName); + + //! Import (java) file + static void importFile(const std::string& name); + +public: + //! Include directories to search + static std::list<std::string> includeDirs; + + //! The name of the top-level source file + static std::string sourceFile; + + //! The name of the top-level dep file + static std::string depFile; + + //! Add directory to list of visited dirs, thus effectively ignoring it + static void ignoreDir(const std::string& name); + + //! Include file + static void includeFile(const std::string& name); + +/*---------------------------------------------------------------------------*/ + + //! Construct for the specified scanner + /*! + * Use the default error handling, or optionally provide an error + * handler, which will not be deleted upon destruction. + */ + Parser(Scanner* scan, Errors* err = 0); + ~Parser(); + void Parse(); //!< Execute the parse operation + void SemErr(const std::wstring& msg); //!< Handle semantic error + bool isUTF8() const; //!< Return true if scanner buffer is UTF8 + + void wmkdepend(); + +}; // end Parser + +} // End namespace + +#endif // COCO_wmkdependPARSER_H__ + +// ************************************************************************* // diff --git a/wmake/src/wmkdependScanner.cpp b/wmake/src/wmkdependScanner.cpp new file mode 100644 index 0000000000000000000000000000000000000000..72f082f7886bbb2c3a256240763222f4700ecfaf --- /dev/null +++ b/wmake/src/wmkdependScanner.cpp @@ -0,0 +1,1022 @@ +/*---------------------------------*- C++ -*---------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +@file wmkdependParser.atg + +Description + An attributed Coco/R grammar to parse C/C++, Fortran and Java files + for include and import statements. + +SourceFiles + generated + +\*---------------------------------------------------------------------------*/ +// This file was generated with Coco/R C++ (7 Feb 2010) +// http://www.ssw.uni-linz.ac.at/coco/ +// with these defines: +// - FORCE_UTF8 + + +#include <sstream> + +// io.h and fcntl are used to ensure binary read from streams on windows +#ifdef _WIN32 +# include <io.h> +# include <fcntl.h> +#endif + +#include <climits> + +#include "wmkdependScanner.h" + +// values for the file stream buffering +#define MIN_BUFFER_LENGTH 1024 // 1KB +#define MAX_BUFFER_LENGTH (64*MIN_BUFFER_LENGTH) // 64KB +// value for the heap management +#define HEAP_BLOCK_SIZE (64*1024) // 64KB + + +namespace wmake { + +// * * * * * * * * * * * Miscellaneous String Routines * * * * * * * * * * * // + +// +// string handling, byte character +// + +std::string coco_stdString(const wchar_t* str) +{ + return str ? coco_stdString(str, 0, wcslen(str)) : std::string(); +} + + +std::string coco_stdString(const wchar_t* str, unsigned length) +{ + return coco_stdString(str, 0, length); +} + + +std::string coco_stdString(const wchar_t* str, unsigned index, unsigned length) +{ + const unsigned len = (str && *str) ? length : 0; + std::string dst; + dst.reserve(len); + + for (unsigned i = 0; i < len; ++i) + { + dst += char(str[index+i] & 0xFF); + } + + return dst; +} + + +std::string coco_stdStringUTF8(const wchar_t* str) +{ + return str ? coco_stdStringUTF8(str, 0, wcslen(str)) : std::string(); +} + + +std::string coco_stdStringUTF8(const wchar_t* str, unsigned length) +{ + return coco_stdStringUTF8(str, 0, length); +} + + +std::string coco_stdStringUTF8(const wchar_t* str, unsigned index, unsigned length) +{ + const unsigned len = (str && *str) ? length : 0; + std::string dst; + dst.reserve(len); + + for (unsigned i = 0; i < len; ++i) + { + wchar_t wc = str[index+i]; + + if (!(wc & ~0x0000007F)) + { + // 0x00000000 - 0x0000007F [min. 8bit storage, 1-byte encoding) + // 0aaaaaaa + dst += char(wc); + } + else if (!(wc & ~0x000007FF)) + { + // 0x00000080 - 0x000007FF [min. 16bit storage, 2-byte encoding] + // 110bbbaa 10aaaaaa + dst += char(0xC0 | ((wc >> 6) & 0x1F)); + dst += char(0x80 | ((wc) & 0x3F)); + } + else if (!(wc & ~0x0000FFFF)) + { + // 0x00000800 - 0x0000FFFF [min. 16bit storage, 3-byte encoding] + // 1110bbbb 10bbbbaa 10aaaaaa + dst += char(0xE0 | ((wc >> 12) & 0x0F)); + dst += char(0x80 | ((wc >> 6) & 0x3F)); + dst += char(0x80 | ((wc) & 0x3F)); + } + else if (!(wc & ~0x001FFFFF)) + { + // 0x00010000 - 0x001FFFFF [min. 24bit storage, 4-byte encoding] + // 11110ccc 10ccbbbb 10bbbbaa 10aaaaaa + dst += char(0xF0 | ((wc >> 18) & 0x07)); + dst += char(0x80 | ((wc >> 12) & 0x3F)); + dst += char(0x80 | ((wc >> 6) & 0x3F)); + dst += char(0x80 | ((wc) & 0x3F)); + } +// +// Not (yet) used - wchar_t storage is limited to 16bit on windows +// This also corresponds to the unicode BMP (Basic Multilingual Plane) +// +// else if (!(wc & ~0x03FFFFFF)) +// { +// // 0x00200000 - 0x03FFFFFF [min. 32bit storage, 5-byte encoding] +// // 111110dd 10cccccc 10ccbbbb 10bbbbaa 10aaaaaa +// dst += char(0xF8 | ((wc >> 24) & 0x03)); +// dst += char(0x80 | ((wc >> 18) & 0x3F)); +// dst += char(0x80 | ((wc >> 12) & 0x3F)); +// dst += char(0x80 | ((wc >> 6) & 0x3F)); +// dst += char(0x80 | ((wc) & 0x3F)); +// } +// else if (!(wc & ~0x7FFFFFFF)) +// { +// // 0x04000000 - 0x7FFFFFFF [min. 32bit storage, 6-byte encoding] +// // 1111110d 10dddddd 10cccccc 10ccbbbb 10bbbbaa 10aaaaaa +// dst += char(0xFC | ((wc >> 30) & 0x01)); +// dst += char(0x80 | ((wc >> 24) & 0x3F)); +// dst += char(0x80 | ((wc >> 18) & 0x3F)); +// dst += char(0x80 | ((wc >> 12) & 0x3F)); +// dst += char(0x80 | ((wc >> 6) & 0x3F)); +// dst += char(0x80 | ((wc) & 0x3F)); +// } +// + else + { + // report anything unknown/invalid as replacement character U+FFFD + dst += char(0xEF); + dst += char(0xBF); + dst += char(0xBD); + } + } + + return dst; +} + + +// * * * * * * * * * * * * End of String Routines * * * * * * * * * * * * * // + + +Token::Token(wchar_t* value) +: + kind(0), + pos(0), + col(0), + line(0), + val(value), + next(NULL) +{} + + +Token::~Token() +{} + + +int Token::length() const +{ + return val ? wcslen(val) : 0; +} + + +// ---------------------------------------------------------------------------- +// Buffer Implementation +// ---------------------------------------------------------------------------- + +Buffer::Buffer(Buffer* b) +: + buf(b->buf), + bufCapacity(b->bufCapacity), + bufLen(b->bufLen), + bufPos(b->bufPos), + bufStart(b->bufStart), + fileLen(b->fileLen), + cStream(b->cStream), + stdStream(b->stdStream), + isUserStream_(b->isUserStream_) +{ + // avoid accidental deletion on any of these members + b->buf = NULL; + b->cStream = NULL; + b->stdStream = NULL; +} + + +Buffer::Buffer(const char* chars, int len) +: + buf(new unsigned char[len]), + bufCapacity(len), + bufLen(len), + bufPos(0), + bufStart(0), + fileLen(len), + cStream(NULL), + stdStream(NULL), + isUserStream_(false) +{ + memcpy(this->buf, chars, len*sizeof(char)); +} + + +Buffer::Buffer(const unsigned char* chars, int len) +: + buf(new unsigned char[len]), + bufCapacity(len), + bufLen(len), + bufPos(0), + bufStart(0), + fileLen(len), + cStream(NULL), + stdStream(NULL), + isUserStream_(false) +{ + memcpy(this->buf, chars, len*sizeof(char)); +} + + +Buffer::Buffer(FILE* ifh, bool isUserStream) +: + buf(NULL), + bufCapacity(0), + bufLen(0), + bufPos(0), + bufStart(0), + fileLen(0), + cStream(ifh), + stdStream(NULL), + isUserStream_(isUserStream) +{ +// ensure binary read on windows +#ifdef _WIN32 + _setmode(_fileno(cStream), _O_BINARY); +#endif + + if (CanSeek()) + { + fseek(cStream, 0, SEEK_END); + fileLen = ftell(cStream); + fseek(cStream, 0, SEEK_SET); + bufLen = (fileLen < MAX_BUFFER_LENGTH) ? fileLen : MAX_BUFFER_LENGTH; + bufStart = INT_MAX; // nothing in the buffer so far + } + + bufCapacity = (bufLen > 0) ? bufLen : MIN_BUFFER_LENGTH; + buf = new unsigned char[bufCapacity]; + if (fileLen > 0) SetPos(0); // setup buffer to position 0 (start) + else bufPos = 0; // index 0 is already after the file, thus Pos = 0 is invalid + if (bufLen == fileLen && CanSeek()) Close(); +} + + +Buffer::Buffer(std::istream* istr, bool isUserStream) +: + buf(NULL), + bufCapacity(0), + bufLen(0), + bufPos(0), + bufStart(0), + fileLen(0), + cStream(NULL), + stdStream(istr), + isUserStream_(isUserStream) +{ +#if _WIN32 + // TODO: ensure binary read on windows? +#endif +} + + +Buffer::~Buffer() +{ + Close(); + if (buf) + { + delete[] buf; + buf = NULL; + } +} + + +void Buffer::Close() +{ + if (!isUserStream_) + { + if (cStream) + { + fclose(cStream); + cStream = NULL; + } + if (stdStream) + { + delete stdStream; + stdStream = 0; + } + } +} + + +int Buffer::Read() +{ + if (stdStream) + { + int ch = stdStream->get(); + if (stdStream->eof()) + { + return EoF; + } + return ch; + } + + if (bufPos < bufLen) { + return buf[bufPos++]; + } + else if (GetPos() < fileLen) { + SetPos(GetPos()); // shift buffer start to Pos + return buf[bufPos++]; + } + else if (cStream && !CanSeek() && (ReadNextStreamChunk() > 0)) { + return buf[bufPos++]; + } + + return EoF; +} + +bool Buffer::isUTF8() const +{ + return false; +} + +int UTF8Buffer::Read() +{ + int ch; + do { + ch = Buffer::Read(); + // until we find a utf8 start (0xxxxxxx or 11xxxxxx) + } while (ch != EoF && ch >= 128 && ((ch & 0xC0) != 0xC0)); + if (ch < 128 || ch == EoF) { + // nothing to do, first 127 chars are identical in ASCII and UTF8 + // 0xxxxxxx or end of file character + } + else if ((ch & 0xF0) == 0xF0) { + // 0x00010000 - 0x001FFFFF [min. 24bit storage, 4-byte encoding] + // 11110ccc 10ccbbbb 10bbbbaa 10aaaaaa + // CAUTION: this should probably be disallowed since it overflows + // wchar_t on windows and overflows the max (0xFFFF) used here + int c1 = ch & 0x07; ch = Buffer::Read(); + int c2 = ch & 0x3F; ch = Buffer::Read(); + int c3 = ch & 0x3F; ch = Buffer::Read(); + int c4 = ch & 0x3F; + ch = (((((c1 << 6) | c2) << 6) | c3) << 6) | c4; + } + else if ((ch & 0xE0) == 0xE0) { + // 0x00000800 - 0x0000FFFF [min. 16bit storage, 3-byte encoding] + // 1110bbbb 10bbbbaa 10aaaaaa + int c1 = ch & 0x0F; ch = Buffer::Read(); + int c2 = ch & 0x3F; ch = Buffer::Read(); + int c3 = ch & 0x3F; + ch = (((c1 << 6) | c2) << 6) | c3; + } + else if ((ch & 0xC0) == 0xC0) { + // 0x00000080 - 0x000007FF [min. 16bit storage, 2-byte encoding] + // 110bbbaa 10aaaaaa + int c1 = ch & 0x1F; ch = Buffer::Read(); + int c2 = ch & 0x3F; + ch = (c1 << 6) | c2; + } + return ch; +} + + +bool UTF8Buffer::isUTF8() const +{ + return true; +} + + +int Buffer::Peek() +{ + int curPos = GetPos(); + int ch = Read(); + SetPos(curPos); + return ch; +} + + +int Buffer::GetPos() const +{ + if (stdStream) + { + return stdStream->tellg(); + } + + return bufPos + bufStart; +} + + +void Buffer::SetPos(int value) +{ + if (stdStream) + { + stdStream->seekg(value, std::ios::beg); + return; + } + + if ((value >= fileLen) && cStream && !CanSeek()) + { + // Wanted position is after buffer and the stream + // is not seek-able e.g. network or console, + // thus we have to read the stream manually till + // the wanted position is in sight. + while ((value >= fileLen) && (ReadNextStreamChunk() > 0)) + {} + } + + if ((value < 0) || (value > fileLen)) + { + fwprintf(stderr, L"--- buffer out of bounds access, position: %d\n", value); + ::exit(1); + } + + if ((value >= bufStart) && (value < (bufStart + bufLen))) // already in buffer + { + bufPos = value - bufStart; + } + else if (cStream) // must be swapped in + { + fseek(cStream, value, SEEK_SET); + bufLen = fread(buf, sizeof(char), bufCapacity, cStream); + bufStart = value; bufPos = 0; + } + else + { + bufPos = fileLen - bufStart; // make Pos return fileLen + } +} + + +// +// Read the next chunk of bytes from the stream, increases the buffer +// if needed and updates the fields fileLen and bufLen. +// Returns the number of bytes read. +// +int Buffer::ReadNextStreamChunk() +{ + int freeLen = bufCapacity - bufLen; + if (freeLen == 0) + { + // in the case of a growing input stream + // we can neither seek in the stream, nor can we + // foresee the maximum length, thus we must adapt + // the buffer size on demand. + bufCapacity = bufLen * 2; + unsigned char *newBuf = new unsigned char[bufCapacity]; + memcpy(newBuf, buf, bufLen*sizeof(char)); + delete[] buf; + buf = newBuf; + freeLen = bufLen; + } + int read = fread(buf + bufLen, sizeof(char), freeLen, cStream); + if (read > 0) + { + fileLen = bufLen = (bufLen + read); + return read; + } + // end of stream reached + return 0; +} + + +bool Buffer::CanSeek() const +{ + return cStream && (ftell(cStream) != -1); +} + +// ---------------------------------------------------------------------------- +// Scanner Implementation +// ---------------------------------------------------------------------------- + +Scanner::Scanner(const char* buf, int len) +: + buffer(new Buffer(buf, len)) +{ + Init(); +} + + +Scanner::Scanner(const unsigned char* buf, int len) +: + buffer(new Buffer(buf, len)) +{ + Init(); +} + + +Scanner::Scanner(FILE* ifh) +: + buffer(new Buffer(ifh, true)) +{ + Init(); +} + + +#ifdef _WIN32 +Scanner::Scanner(const std::wstring& fileName) +{ + FILE* ifh; + + if ((ifh = _wfopen(fileName.c_str(), L"rb")) == NULL) + { + fwprintf(stderr, L"--- Cannot open file %ls\n", fileName.c_str()); + ::exit(1); + } + buffer = new Buffer(ifh, false); + Init(); +} +#endif + + +Scanner::Scanner(const std::string& fileName) +{ + FILE* ifh; + if ((ifh = fopen(fileName.c_str(), "rb")) == NULL) + { + fwprintf(stderr, L"--- Cannot open file %s\n", fileName.c_str()); + ::exit(1); + } + buffer = new Buffer(ifh, false); + Init(); +} + + +Scanner::Scanner(std::istream& istr) +: + buffer(new Buffer(&istr, true)) +{ + Init(); +} + + +Scanner::~Scanner() +{ + char* cur = reinterpret_cast<char*>(firstHeap); + +#ifdef COCO_DEBUG_HEAP + fwprintf(stderr, L"~Scanner:\n"); +#endif + + while (cur) + { + cur = *(reinterpret_cast<char**>(cur + HEAP_BLOCK_SIZE)); + free(firstHeap); +#ifdef COCO_DEBUG_HEAP + fwprintf + ( + stderr, L" free %p -> %p\n", + firstHeap, + reinterpret_cast<char*>(firstHeap) + HEAP_BLOCK_SIZE + ); +#endif + firstHeap = cur; + } + delete[] tval; + delete buffer; +} + + +void Scanner::Init() +{ + for (int i = 36; i <= 36; ++i) start.set(i, 7); + for (int i = 65; i <= 90; ++i) start.set(i, 7); + for (int i = 95; i <= 95; ++i) start.set(i, 7); + for (int i = 97; i <= 122; ++i) start.set(i, 7); + start.set(34, 1); + start.set(39, 4); + start.set(35, 11); + start.set(10, 12); + start.set(59, 13); + start.set(Buffer::EoF, -1); + + keywords.set(L"include", 6); + keywords.set(L"import", 8); + + tvalLength = 128; + tval = new wchar_t[tvalLength]; // text of current token + tlen = 0; + tval[tlen] = 0; + + // HEAP_BLOCK_SIZE byte heap + pointer to next heap block + heap = malloc(HEAP_BLOCK_SIZE + sizeof(void*)); + firstHeap = heap; + heapEnd = + reinterpret_cast<void**> + (reinterpret_cast<char*>(heap) + HEAP_BLOCK_SIZE); + *heapEnd = 0; + heapTop = heap; + if (sizeof(Token) > HEAP_BLOCK_SIZE) + { + fwprintf(stderr, L"--- Too small HEAP_BLOCK_SIZE\n"); + ::exit(1); + } +#ifdef COCO_DEBUG_HEAP + fwprintf + ( + stderr, L"Scanner::init: firstHeap %p -> %p\n", + firstHeap, + reinterpret_cast<char*>(firstHeap) + HEAP_BLOCK_SIZE + ); +#endif + + pos = -1; line = 1; col = 0; + oldEols = 0; + NextCh(); + if (ch == 0xEF) // check optional byte order mark for UTF-8 + { // Windows-specific magic + NextCh(); int ch1 = ch; + NextCh(); int ch2 = ch; + if (ch1 != 0xBB || ch2 != 0xBF) + { + fwprintf(stderr, L"Illegal byte order mark at start of file"); + ::exit(1); + } + Buffer *oldBuf = buffer; + buffer = new UTF8Buffer(oldBuf); col = 0; + delete oldBuf; oldBuf = NULL; + NextCh(); + } + else + { + // FORCE_UTF8 was defined + // use UTF8Buffer without relying on a byte order mark. + Buffer *oldBuf = buffer; + buffer = new UTF8Buffer(oldBuf); col = 0; + delete oldBuf; oldBuf = NULL; + } + + pt = tokens = CreateToken(); // first token is a dummy +} + + +void Scanner::NextCh() +{ + if (oldEols > 0) + { + ch = EOL; + oldEols--; + } + else + { + pos = buffer->GetPos(); + ch = buffer->Read(); col++; + // replace isolated '\r' by '\n' in order to make + // eol handling uniform across Windows, Unix and Mac + if (ch == '\r' && buffer->Peek() != '\n') ch = EOL; + if (ch == EOL) { line++; col = 0; } + } +} + + +void Scanner::AddCh() +{ + if (tlen >= tvalLength) + { + tvalLength *= 2; + wchar_t *newBuf = new wchar_t[tvalLength]; + memcpy(newBuf, tval, tlen*sizeof(wchar_t)); + delete[] tval; + tval = newBuf; + } + if (ch != Buffer::EoF) + { + tval[tlen++] = ch; + NextCh(); + } +} + + + +bool Scanner::Comment0() { + int level = 1, pos0 = pos, line0 = line, col0 = col; + NextCh(); + if (ch == '/') { + NextCh(); + while (true) { + if (ch == 10) { + level--; + if (level == 0) { oldEols = line - line0; NextCh(); return true; } + NextCh(); + } else if (ch == buffer->EoF) return false; + else NextCh(); + } + } else { + buffer->SetPos(pos0); NextCh(); line = line0; col = col0; + } + return false; +} + +bool Scanner::Comment1() { + int level = 1, pos0 = pos, line0 = line, col0 = col; + NextCh(); + if (ch == '*') { + NextCh(); + while (true) { + if (ch == '*') { + NextCh(); + if (ch == '/') { + level--; + if (level == 0) { oldEols = line - line0; NextCh(); return true; } + NextCh(); + } + } else if (ch == '/') { + NextCh(); + if (ch == '*') { + level++; NextCh(); + } + } else if (ch == buffer->EoF) return false; + else NextCh(); + } + } else { + buffer->SetPos(pos0); NextCh(); line = line0; col = col0; + } + return false; +} + +void Scanner::CreateHeapBlock() +{ + char* cur = reinterpret_cast<char*>(firstHeap); + +#ifdef COCO_DEBUG_HEAP + fwprintf(stderr, L"CreateHeapBlock: tokens %p\n", tokens); +#endif + + // release unused blocks + while + ( + (reinterpret_cast<char*>(tokens) < cur) + || (reinterpret_cast<char*>(tokens) > (cur + HEAP_BLOCK_SIZE)) + ) + { + cur = *(reinterpret_cast<char**>(cur + HEAP_BLOCK_SIZE)); +#ifdef COCO_DEBUG_HEAP + fwprintf + ( + stderr, L" free %p -> %p\n", + firstHeap, + reinterpret_cast<char*>(firstHeap) + HEAP_BLOCK_SIZE + ); +#endif + free(firstHeap); + firstHeap = cur; + } + + // HEAP_BLOCK_SIZE byte heap + pointer to next heap block + void* newHeap = malloc(HEAP_BLOCK_SIZE + sizeof(void*)); + *heapEnd = newHeap; + heapEnd = + reinterpret_cast<void**> + (reinterpret_cast<char*>(newHeap) + HEAP_BLOCK_SIZE); + *heapEnd = 0; + heap = newHeap; + heapTop = heap; +#ifdef COCO_DEBUG_HEAP + fwprintf + ( + stderr, L" malloc %p -> %p\n", + newHeap, + reinterpret_cast<char*>(newHeap) + HEAP_BLOCK_SIZE + ); +#endif +} + + +Token* Scanner::CreateToken() +{ + const int reqMem = sizeof(Token); + if + ( + (reinterpret_cast<char*>(heapTop) + reqMem) + >= reinterpret_cast<char*>(heapEnd) + ) + { + CreateHeapBlock(); + } + // token 'occupies' heap starting at heapTop + Token* tok = reinterpret_cast<Token*>(heapTop); + // increment past this part of the heap, which is now used + heapTop = + reinterpret_cast<void*> + (reinterpret_cast<char*>(heapTop) + reqMem); + tok->val = NULL; + tok->next = NULL; + return tok; +} + + +void Scanner::AppendVal(Token* tok) +{ + const int reqMem = (tlen + 1) * sizeof(wchar_t); + if + ( + (reinterpret_cast<char*>(heapTop) + reqMem) + >= reinterpret_cast<char*>(heapEnd) + ) + { + if (reqMem > HEAP_BLOCK_SIZE) + { + fwprintf(stderr, L"--- Too long token value\n"); + ::exit(1); + } + CreateHeapBlock(); + } + + // add text value from heap + tok->val = reinterpret_cast<wchar_t*>(heapTop); + + // increment past this part of the heap, which is now used + heapTop = + reinterpret_cast<void*> + (reinterpret_cast<char*>(heapTop) + reqMem); + + // copy the currently parsed tval into the token + wcsncpy(tok->val, tval, tlen); + tok->val[tlen] = '\0'; +} + + +Token* Scanner::NextToken() +{ + while + ( + ch == ' ' + || ch == 9 + ) NextCh(); + if ((ch == '/' && Comment0()) || (ch == '/' && Comment1())) return NextToken(); + int recKind = noSym; + int recEnd = pos; + t = CreateToken(); + t->pos = pos; t->col = col; t->line = line; + int state = start.state(ch); + tlen = 0; AddCh(); + + switch (state) + { + case -1: { t->kind = eofSym; break; } // NextCh already done + case 0: { + case_0: + if (recKind != noSym) { + tlen = recEnd - t->pos; + SetScannerBehindT(); + } + t->kind = recKind; break; + } // NextCh already done + case 1: + case_1: + if (ch <= 9 || (ch >= 11 && ch <= 12) || (ch >= 14 && ch <= '!') || (ch >= '#' && ch <= '[') || (ch >= ']' && ch <= 65535)) {AddCh(); goto case_1;} + else if (ch == '"') {AddCh(); goto case_3;} + else if (ch == 92) {AddCh(); goto case_2;} + else {goto case_0;} + case 2: + case_2: + if ((ch >= ' ' && ch <= '~')) {AddCh(); goto case_1;} + else {goto case_0;} + case 3: + case_3: + {t->kind = 1; break;} + case 4: + case_4: + if (ch <= 9 || (ch >= 11 && ch <= 12) || (ch >= 14 && ch <= '!') || (ch >= '#' && ch <= '&') || (ch >= '(' && ch <= '[') || (ch >= ']' && ch <= 65535)) {AddCh(); goto case_4;} + else if (ch == 39) {AddCh(); goto case_8;} + else if (ch == 92) {AddCh(); goto case_5;} + else {goto case_0;} + case 5: + case_5: + if ((ch >= ' ' && ch <= '~')) {AddCh(); goto case_4;} + else {goto case_0;} + case 6: + case_6: + {t->kind = 4; break;} + case 7: + case_7: + recEnd = pos; recKind = 3; + if (ch == '$' || (ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') || ch == '_' || (ch >= 'a' && ch <= 'z')) {AddCh(); goto case_7;} + else if (ch == '.') {AddCh(); goto case_9;} + else {t->kind = 3; std::wstring literal(tval, tlen); t->kind = keywords.get(literal, t->kind); break;} + case 8: + case_8: + recEnd = pos; recKind = 2; + if (ch <= 9 || (ch >= 11 && ch <= 12) || (ch >= 14 && ch <= '!') || (ch >= '#' && ch <= '&') || (ch >= '(' && ch <= '[') || (ch >= ']' && ch <= 65535)) {AddCh(); goto case_4;} + else if (ch == 39) {AddCh(); goto case_8;} + else if (ch == 92) {AddCh(); goto case_5;} + else {t->kind = 2; break;} + case 9: + case_9: + if (ch == '$' || (ch >= 'A' && ch <= 'Z') || ch == '_' || (ch >= 'a' && ch <= 'z')) {AddCh(); goto case_10;} + else if (ch == '*') {AddCh(); goto case_6;} + else {goto case_0;} + case 10: + case_10: + recEnd = pos; recKind = 3; + if (ch == '$' || (ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') || ch == '_' || (ch >= 'a' && ch <= 'z')) {AddCh(); goto case_10;} + else if (ch == '.') {AddCh(); goto case_9;} + else {t->kind = 3; std::wstring literal(tval, tlen); t->kind = keywords.get(literal, t->kind); break;} + case 11: + {t->kind = 5; break;} + case 12: + {t->kind = 7; break;} + case 13: + {t->kind = 9; break;} + } + AppendVal(t); + return t; +} + + +void Scanner::SetScannerBehindT() +{ + buffer->SetPos(t->pos); + NextCh(); + line = t->line; col = t->col; + for (int i = 0; i < tlen; i++) NextCh(); +} + + +// get the next token (possibly a token already seen during peeking) +Token* Scanner::Scan() +{ + if (tokens->next == NULL) { + pt = tokens = NextToken(); + } + else { + pt = tokens = tokens->next; + } + return tokens; +} + + +// peek for the next token, ignore pragmas +Token* Scanner::Peek() +{ + do + { + if (pt->next == NULL) + { + pt->next = NextToken(); + } + pt = pt->next; + } while (pt->kind > maxT); // skip pragmas + + return pt; +} + + +// make sure that peeking starts at the current scan position +void Scanner::ResetPeek() +{ + pt = tokens; +} + + +int Scanner::Line() const +{ + return line; +} + + +void Scanner::Line(int lineNo) +{ + line = lineNo; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace + +// ************************************************************************* // diff --git a/wmake/src/wmkdependScanner.h b/wmake/src/wmkdependScanner.h new file mode 100644 index 0000000000000000000000000000000000000000..a72bf4b9684c2b8cd847484213e681981c09acab --- /dev/null +++ b/wmake/src/wmkdependScanner.h @@ -0,0 +1,477 @@ +/*---------------------------------*- C++ -*---------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +@file wmkdependParser.atg + +Description + An attributed Coco/R grammar to parse C/C++, Fortran and Java files + for include and import statements. + +SourceFiles + generated + +\*---------------------------------------------------------------------------*/ +// This file was generated with Coco/R C++ (7 Feb 2010) +// http://www.ssw.uni-linz.ac.at/coco/ +// with these defines: +// - FORCE_UTF8 + + +#ifndef COCO_wmkdependSCANNER_H__ +#define COCO_wmkdependSCANNER_H__ + +#include <cstdio> +#include <cstdlib> +#include <cstring> +#include <cwchar> +#include <string> +#include <fstream> +#include <iostream> + +namespace wmake { + +// * * * * * * * * * * * Miscellaneous String Routines * * * * * * * * * * * // + +//! Simple lower-case string transformation +template<class StringT> +inline void coco_string_toLower(StringT& str) +{ + for + ( + typename StringT::iterator iter = str.begin(); + iter != str.end(); + ++iter + ) + { + if (*iter >= 'A' && *iter <= 'Z') + { + *iter += ('a' - 'A'); // lower-case + } + } +} + + +//! Simple string hashing function +template<class StringT> +inline int coco_string_hash(const StringT& str) +{ + int h = 0; + for + ( + typename StringT::const_iterator iter = str.begin(); + iter != str.end(); + ++iter + ) + { + h = (h * 7) ^ *iter; + } + return h < 0 ? -h : h; +} + + +// +// String conversions +// ~~~~~~~~~~~~~~~~~~ + +//! Convert wide string to double +inline double coco_string_toDouble(const wchar_t* str) +{ + return str ? wcstod(str, NULL) : 0; +} + + +//! Convert wide string to long +inline long coco_string_toLong(const wchar_t* str) +{ + return str ? wcstol(str, NULL, 10) : 0; +} + + +//! A byte string (restricted to 8bit values) by copying str +std::string coco_stdString(const wchar_t* str); + +//! A byte string (restricted to 8bit values) by copying str, +//! up to length characters long +std::string coco_stdString(const wchar_t* str, unsigned length); + +//! A byte substring (restricted to 8bit values) of str, +//! starting at index and length characters long +std::string coco_stdString(const wchar_t* str, unsigned index, unsigned length); + +//! A UTF8 byte string by copying str +std::string coco_stdStringUTF8(const wchar_t* str); + +//! A UTF8 byte string by copying str, up to length characters long +std::string coco_stdStringUTF8(const wchar_t* str, unsigned length); + +//! A UTF8 byte substring, starting at index and length characters long +std::string coco_stdStringUTF8(const wchar_t* str, unsigned index, unsigned length); + +// * * * * * * * * * * * * End of String Routines * * * * * * * * * * * * * // + + + +/*---------------------------------------------------------------------------*\ + Class Token Declaration +\*---------------------------------------------------------------------------*/ +/*! + * @brief Scanner Token + * + * @note since each Token is allocated by the internal heap mechanism, + * the destructor does not clean up the val member. + */ +class Token +{ +public: + int kind; //!< token kind + int pos; //!< token position in the source text (starting at 0) + int col; //!< token column (starting at 1) + int line; //!< token line (starting at 1) + wchar_t* val; //!< token value (normally allocated from the internal heap) + Token *next; //!< Peek tokens are kept in linked list + + int length() const; //!< The length of val, or 0 if val is NULL + + //! Construct null Token, optionally with pointer to a string value + Token(wchar_t* value = 0); + ~Token(); //!< Destructor - does not cleanup val member + + //! Token val as byte string (restricted to 8bit values) + inline std::string toString() const + { + return coco_stdString(val); + } + + //! Token val as byte string (restricted to 8bit values), up to length characters long + inline std::string toString(unsigned length) const + { + return coco_stdString(val, length); + } + + //! Token val as byte string (restricted to 8bit values), starting at index and length characters long + inline std::string toString(unsigned index, unsigned length) const + { + return coco_stdString(val, index, length); + } + + //! Token val as UTF8 byte string + inline std::string toStringUTF8() const + { + return coco_stdStringUTF8(val); + } + + //! Token val as UTF8 byte string, up to length characters long + inline std::string toStringUTF8(unsigned length) const + { + return coco_stdStringUTF8(val, length); + } + + //! Token val as UTF8 byte substring, starting at index and length characters long + inline std::string toStringUTF8(unsigned index, unsigned length) const + { + return coco_stdStringUTF8(this->val, index, length); + } + +}; + + +/*---------------------------------------------------------------------------*\ + Class Buffer Declaration +\*---------------------------------------------------------------------------*/ +/*! + * @brief Scanner Buffer Token + * + * This Buffer supports the following cases: + * -# seekable stream (file) + * -# whole stream in buffer + * -# part of stream in buffer + * -# non seekable stream (network, console) + */ +class Buffer +{ + unsigned char *buf; //!< input buffer + int bufCapacity; //!< capacity of buf + int bufLen; //!< length of buffer + int bufPos; //!< current position in buffer + int bufStart; //!< position of first byte in buffer relative to input stream + int fileLen; //!< length of input stream (may change if the stream is no file) + FILE* cStream; //!< input stdio stream (normally seekable) + std::istream* stdStream; //!< STL std stream (seekable) + bool isUserStream_; //!< was the stream opened by the user? + + int ReadNextStreamChunk(); + bool CanSeek() const; //!< true if stream can be seeked otherwise false + +protected: + Buffer(Buffer*); //!< for the UTF8Buffer + +public: + //! max unicode characters is 0xFFFF (16bit storage) + static const int MaxChar = 65535; + static const int EoF = MaxChar + 1; + + //! Copy buffer contents from constant character string + Buffer(const char* chars, int len); + + //! Copy buffer contents from constant character string + Buffer(const unsigned char* chars, int len); + + //! @brief Attach buffer to a stdio stream. + //! User streams are not closed in the destructor + Buffer(FILE*, bool isUserStream = true); + + //! @brief Attach buffer to an STL standard stream + //! User streams are not closed in the destructor + explicit Buffer(std::istream*, bool isUserStream = true); + + //! Close stream (but not user streams) and free buf (if any) + virtual ~Buffer(); + + virtual void Close(); //!< Close stream (but not user streams) + virtual int Read(); //!< Get character from stream or buffer + virtual int Peek(); //!< Peek character from stream or buffer + + virtual int GetPos() const; + virtual void SetPos(int value); + virtual bool isUTF8() const; //!< Return false - buffer is not UTF8 +}; + + +/*---------------------------------------------------------------------------*\ + Class UTF8Buffer Declaration +\*---------------------------------------------------------------------------*/ +//! A Scanner Buffer variant that decodes UTF-8 characters into 16bit unicode +class UTF8Buffer : public Buffer +{ +public: + UTF8Buffer(Buffer* b) : Buffer(b) {} + virtual int Read(); + virtual bool isUTF8() const; //!< Return true - buffer is UTF8 +}; + + +/*---------------------------------------------------------------------------*\ + Class StartStates Declaration +\*---------------------------------------------------------------------------*/ +//! maps characters (integers) to start states of tokens as a HashTable +class StartStates +{ + //! HashTable entry + struct Entry + { + int key; //<! The lookup key + int val; //<! The data + Entry *next; //<! Pointer next Entry in sub-list + + Entry(int k, int v, Entry *n=0) + : + key(k), val(v), next(n) + {} + }; + + static const int size_ = 128; //<! fixed HashTable size + Entry **table_; + +public: + StartStates() + : + table_(new Entry*[size_]) + { + memset(table_, 0, size_*sizeof(Entry*)); + } + + virtual ~StartStates() + { + for (int i = 0; i < size_; ++i) + { + Entry *e = table_[i]; + while (e) + { + Entry *next = e->next; + delete e; + e = next; + } + } + delete[] table_; + } + + void set(int key, int val) + { + const int hashIndex = unsigned(key) % size_; + table_[hashIndex] = new Entry(key, val, table_[hashIndex]); + } + + int state(int key) + { + Entry *e = table_[unsigned(key) % size_]; + while (e && e->key != key) e = e->next; + return e ? e->val : 0; + } +}; + + +/*---------------------------------------------------------------------------*\ + Class KeywordMap Declaration +\*---------------------------------------------------------------------------*/ +//! maps strings to integers (identifiers to keyword kinds) as a HashTable +class KeywordMap +{ + //! HashTable entry + struct Entry + { + const std::wstring key; //<! The lookup key + int val; //<! The data + Entry *next; //<! Pointer next Entry in sub-list + + Entry(const std::wstring& k, int v, Entry *n=0) + : + key(k), val(v), next(n) + {} + }; + + static const int size_ = 128; //<! fixed HashTable size + Entry **table_; + +public: + KeywordMap() + : + table_(new Entry*[size_]) + { + memset(table_, 0, size_*sizeof(Entry*)); + } + + virtual ~KeywordMap() + { + for (int i = 0; i < size_; ++i) + { + Entry *e = table_[i]; + while (e) + { + Entry *next = e->next; + delete e; + e = next; + } + } + delete[] table_; + } + + void set(const std::wstring& key, int val) + { + const int hashIndex = coco_string_hash(key) % size_; + table_[hashIndex] = new Entry(key, val, table_[hashIndex]); + } + + int get(const std::wstring& key, int defaultVal) + { + Entry *e = table_[coco_string_hash(key) % size_]; + while (e && e->key != key) e = e->next; + return e ? e->val : defaultVal; + } +}; + + +/*---------------------------------------------------------------------------*\ + Class Scanner Declaration +\*---------------------------------------------------------------------------*/ +//! A Coco/R Scanner +class Scanner +{ + static const int maxT = 10; + static const int noSym = 10; + static const int eofSym = 0; //!< end-of-file token id + static const char EOL = '\n'; //!< end-of-line character + + void *firstHeap; //!< the start of the heap management + void *heap; //!< the currently active block + void *heapTop; //!< the top of the heap + void **heapEnd; //!< the end of the last heap block + + StartStates start; //!< A map of start states for particular characters + KeywordMap keywords; //!< A hash of keyword literals to token kind + + Token *t; //!< current token + wchar_t *tval; //!< text of current token + int tvalLength; //!< maximum capacity (length) for tval + int tlen; //!< length of tval + + Token *tokens; //!< list of tokens already peeked (first token is a dummy) + Token *pt; //!< current peek token + + int ch; //!< current input character + int pos; //!< byte position of current character + int line; //!< line number of current character + int col; //!< column number of current character + int oldEols; //!< the number of EOLs that appeared in a comment + + void CreateHeapBlock(); //!< add a heap block, freeing unused ones + Token* CreateToken(); //!< fit token on the heap + void AppendVal(Token* tok); //!< adjust tok->val to point to the heap and copy tval into it + void SetScannerBehindT(); + + void Init(); //!< complete the initialization for the constructors + void NextCh(); //!< get the next input character into ch + void AddCh(); //!< append the character ch to tval + bool Comment0(); + bool Comment1(); + Token* NextToken(); //!< get the next token + +public: + //! The scanner buffer + Buffer *buffer; + + //! Attach scanner to an existing character buffer + Scanner(const char* chars, int len); + + //! Attach scanner to an existing character buffer + Scanner(const unsigned char* chars, int len); + + //! Attach scanner to an existing open file handle + Scanner(FILE*); + +#ifdef _WIN32 + //! Open a file for reading and attach scanner - Windows only + explicit Scanner(const std::wstring& fileName); +#endif + + //! Open a file for reading and attach scanner + explicit Scanner(const std::string& fileName); + + //! Attach scanner to an existing open STL standard stream + explicit Scanner(std::istream&); + + ~Scanner(); //!< free heap and allocated memory + Token* Scan(); //!< get the next token (possibly a token already seen during peeking) + Token* Peek(); //!< peek for the next token, ignore pragmas + void ResetPeek(); //!< ensure that peeking starts at the current scan position + + int Line() const; //!< Return the current line + void Line(int lineNo); //!< Define the starting line for reporting errors + +}; // end Scanner + +} // End namespace + +#endif // COCO_wmkdependSCANNER_H__ + +// ************************************************************************* //