diff --git a/solvers_post/BetaIntegrator/BetaIntegrator.H b/solvers_post/BetaIntegrator/BetaIntegrator.H index a0ee5e2..ba585ea 100644 --- a/solvers_post/BetaIntegrator/BetaIntegrator.H +++ b/solvers_post/BetaIntegrator/BetaIntegrator.H @@ -69,15 +69,15 @@ class BetaIntegrator { // Private data + //- Quadrature points + const scalarField &etaSpace_; + //- Beta pdf numerators scalarField pdfNum_; //- Beta pdf denominator scalar pdfDen_; - //- Quadrature points - const scalarField &etaSpace_; - //- Description of data_ BetaFunction bf_; diff --git a/solvers_post/LagrangianCMCFoam/LagrangianCMCFoam.C b/solvers_post/LagrangianCMCFoam/LagrangianCMCFoam.C index ec7230d..e30ba6a 100644 --- a/solvers_post/LagrangianCMCFoam/LagrangianCMCFoam.C +++ b/solvers_post/LagrangianCMCFoam/LagrangianCMCFoam.C @@ -51,7 +51,13 @@ Contact #include "LinearMesh.H" -#include "../FlameStructure/FlameStructure.H" +#include "FlameStructure.H" + +#include "AMC.H" + +#include "BetaFunction.H" +#include "BetaGrid.H" +#include "BetaIntegrator.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/solvers_post/LagrangianCMCFoam/Make/files b/solvers_post/LagrangianCMCFoam/Make/files index fb1569c..5a947ad 100644 --- a/solvers_post/LagrangianCMCFoam/Make/files +++ b/solvers_post/LagrangianCMCFoam/Make/files @@ -1,5 +1,20 @@ ../FlameStructure/FlameStructure.C ../FlameStructure/FlameStructureIO.C + +../AMC/AMC.C + +../LinearInterpolator1D/LinearInterpolator1D.C +../LinearInterpolator1D/LinearInterpolator1DIO.C + +../BetaFunction/BetaFunction.C +../BetaFunction/BetaFunctionIO.C + +../BetaGrid/BetaGrid.C +../BetaGrid/BetaGridIO.C + +../BetaIntegrator/BetaIntegrator.C +../BetaIntegrator/BetaIntegratorIO.C + LagrangianCMCFoam.C EXE = $(FOAM_USER_APPBIN)/LagrangianCMCFoam diff --git a/solvers_post/LagrangianCMCFoam/Make/options b/solvers_post/LagrangianCMCFoam/Make/options index 561364d..a020bbe 100644 --- a/solvers_post/LagrangianCMCFoam/Make/options +++ b/solvers_post/LagrangianCMCFoam/Make/options @@ -1,6 +1,12 @@ DEV_PATH=../../libs EXE_INC = \ + -I../FlameStructure \ + -I../LinearInterpolator1D \ + -I../AMC \ + -I../BetaFunction \ + -I../BetaGrid \ + -I../BetaIntegrator \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/sampling/lnInclude \ diff --git a/solvers_post/LagrangianCMCFoam/readCMCProperties.H b/solvers_post/LagrangianCMCFoam/readCMCProperties.H index 7c3e54b..f7e29fe 100644 --- a/solvers_post/LagrangianCMCFoam/readCMCProperties.H +++ b/solvers_post/LagrangianCMCFoam/readCMCProperties.H @@ -95,6 +95,9 @@ scalarField pdf(etamax+1,0.0); scalarField f(etamax+1, 0.0); Info<<"Set eta space grid"<. + +\*---------------------------------------------------------------------------*/ + +#include "LinearInterpolator1D.H" + +#include "error.H" +#include "Switch.H" + + +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +bool Foam::LinearInterpolator1D::_checkSorted(const scalarField& grid) +{ + Switch sorted = true; + + for (label i = 1; i < srcGrid_.size(); i++) + { + if (grid[i-1] >= grid[i]) + { + sorted = false; + break; + } + } + + return sorted; +} + + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::LinearInterpolator1D::LinearInterpolator1D() +{} + + +Foam::LinearInterpolator1D::LinearInterpolator1D(const scalarField& srcGrid, const scalarField& dstGrid) +: + srcGrid_(srcGrid), + dstGrid_(dstGrid), + idxHigh_(dstGrid.size()), + coef_(dstGrid.size()) +{ + // Check dstGrid and srcGrid are intervals + if (!(dstGrid_.first() < dstGrid_.last() && srcGrid_.first() < srcGrid_.last())) + { + FatalErrorInFunction + << "Invalid grids" + << abort(FatalError); + } + + // Check dstGrid lies within srcGrid + if (dstGrid_.first() < srcGrid_.first() || srcGrid_.last() < dstGrid_.last()) + { + FatalErrorInFunction + << "Extrapolation attempted" + << abort(FatalError); + } + + // Check srcGrid and dstGrid are sorted + if (!(_checkSorted(dstGrid_) && _checkSorted(srcGrid_))) + { + FatalErrorInFunction + << "Unsorted grids" + << abort(FatalError); + } + + forAll (dstGrid_, j) + { + for (label i = 1; i < srcGrid_.size(); i++) + { + if (srcGrid_[i] >= dstGrid_[j]) + { + idxHigh_[j] = i; + coef_[j] = (srcGrid_[i] - dstGrid_[j]) / (srcGrid_[i] - srcGrid_[i-1]); + break; + } + } + } +} + + +Foam::LinearInterpolator1D::LinearInterpolator1D(const LinearInterpolator1D&) +{} + + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::LinearInterpolator1D::~LinearInterpolator1D() +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + + +void Foam::LinearInterpolator1D::interpolate(const scalarField& src, scalarField& dst) +{ + forAll (dst, i) + { + dst[i] = coef_[i]*src[idxHigh_[i]-1] + (1.0-coef_[i])*src[idxHigh_[i]]; + } + + return; +} + + +// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * // + +void Foam::LinearInterpolator1D::operator=(const LinearInterpolator1D& rhs) +{ + // Check for assignment to self + if (this == &rhs) + { + FatalErrorInFunction + << "Attempted assignment to self" + << abort(FatalError); + } +} + +// * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * // + + +// ************************************************************************* // diff --git a/solvers_post/LinearInterpolator1D/LinearInterpolator1D.H b/solvers_post/LinearInterpolator1D/LinearInterpolator1D.H new file mode 100644 index 0000000..dd9ddc1 --- /dev/null +++ b/solvers_post/LinearInterpolator1D/LinearInterpolator1D.H @@ -0,0 +1,150 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::LinearInterpolator1D + +Description + +SourceFiles + LinearInterpolator1DI.H + LinearInterpolator1D.C + LinearInterpolator1DIO.C + +\*---------------------------------------------------------------------------*/ + +#ifndef LinearInterpolator1D_H +#define LinearInterpolator1D_H + +#include "scalarField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class Istream; +class Ostream; + +// Forward declaration of friend functions and operators +class LinearInterpolator1D; +Istream& operator>>(Istream&, LinearInterpolator1D&); +Ostream& operator<<(Ostream&, const LinearInterpolator1D&); + + +/*---------------------------------------------------------------------------*\ + Class LinearInterpolator1D Declaration +\*---------------------------------------------------------------------------*/ + +class LinearInterpolator1D +{ + // Private data + + //- Source grids + scalarField srcGrid_; + + //- Destination grids + scalarField dstGrid_; + + //- Source grid to refer for each dst grid + labelList idxHigh_; + + //- Coefficients for dst grid points + scalarField coef_; + + + // Private Member Functions + + //- Check grid sorted + bool _checkSorted(const scalarField& grid); + + //- Disallow default bitwise copy construct + LinearInterpolator1D(const LinearInterpolator1D&); + + //- Disallow default bitwise assignment + void operator=(const LinearInterpolator1D&); + + +public: + + + // Constructors + + //- Construct null + LinearInterpolator1D(); + + //- Construct from components + LinearInterpolator1D(const scalarField& srcGrid, const scalarField& dstGrid); + + //- Construct from Istream + LinearInterpolator1D(Istream&); + + + + //- Destructor + ~LinearInterpolator1D(); + + + // Member Functions + + // Access + + // Check + + // Edit + + // Write + + //- Evaluate interpolation + void interpolate(const scalarField& src, scalarField& dst); + + + // Member Operators + + + + // Friend Functions + + // Friend Operators + + // IOstream Operators + + friend Istream& operator>>(Istream&, LinearInterpolator1D&); + friend Ostream& operator<<(Ostream&, const LinearInterpolator1D&); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "LinearInterpolator1DI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/solvers_post/LinearInterpolator1D/LinearInterpolator1DI.H b/solvers_post/LinearInterpolator1D/LinearInterpolator1DI.H new file mode 100644 index 0000000..eca8d9e --- /dev/null +++ b/solvers_post/LinearInterpolator1D/LinearInterpolator1DI.H @@ -0,0 +1,58 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +// ************************************************************************* // diff --git a/solvers_post/LinearInterpolator1D/LinearInterpolator1DIO.C b/solvers_post/LinearInterpolator1D/LinearInterpolator1DIO.C new file mode 100644 index 0000000..081c8a5 --- /dev/null +++ b/solvers_post/LinearInterpolator1D/LinearInterpolator1DIO.C @@ -0,0 +1,65 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "LinearInterpolator1D.H" +#include "IOstreams.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::LinearInterpolator1D::LinearInterpolator1D(Istream& is) +{ + // Check state of Istream + is.check("Foam::LinearInterpolator1D::LinearInterpolator1D(Foam::Istream&)"); +} + + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +Foam::Istream& Foam::operator>>(Istream& is, LinearInterpolator1D&) +{ + // Check state of Istream + is.check + ( + "Foam::Istream& Foam::operator>>(Foam::Istream&, Foam::LinearInterpolator1D&)" + ); + + return is; +} + + +Foam::Ostream& Foam::operator<<(Ostream& os, const LinearInterpolator1D&) +{ + // Check state of Ostream + os.check + ( + "Foam::Ostream& Foam::operator<<(Foam::Ostream&, " + "const Foam::LinearInterpolator1D&)" + ); + + return os; +} + + +// ************************************************************************* //