diff --git a/applications/solvers/lagrangian/sprayFoam/pEqn.H b/applications/solvers/lagrangian/sprayFoam/pEqn.H index 26511b001d..b0c09f9e08 100644 --- a/applications/solvers/lagrangian/sprayFoam/pEqn.H +++ b/applications/solvers/lagrangian/sprayFoam/pEqn.H @@ -53,7 +53,7 @@ else ) ); - fvOptions.makeRelative(fvc::interpolate(psi), phiHbyA); + fvOptions.makeRelative(fvc::interpolate(rho), phiHbyA); while (pimple.correctNonOrthogonal()) { diff --git a/applications/test/ODE/Test-ODE.C b/applications/test/ODE/Test-ODE.C index f3f1658a7d..ae20374259 100644 --- a/applications/test/ODE/Test-ODE.C +++ b/applications/test/ODE/Test-ODE.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -142,7 +142,7 @@ int main(int argc, char *argv[]) scalar dxNext = dxEst; odeSolver->relTol() = relTol; - odeSolver->solve(ode, x, y, dxNext); + odeSolver->solve(x, y, dxNext); Info<< scientific << setw(13) << relTol; Info<< fixed << setw(11) << dxEst; @@ -165,7 +165,7 @@ int main(int argc, char *argv[]) scalar dxEst = 0.5; odeSolver->relTol() = 1e-4; - odeSolver->solve(ode, x, xEnd, y, dxEst); + odeSolver->solve(x, xEnd, y, dxEst); Info<< nl << "Analytical: y(2.0) = " << yEnd << endl; Info << "Numerical: y(2.0) = " << y << ", dxEst = " << dxEst << endl; diff --git a/etc/bashrc b/etc/bashrc index 4fb5d511df..8e6e630471 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -62,7 +62,7 @@ foamInstall=$HOME/$WM_PROJECT foamCompiler=system #- Compiler: -# WM_COMPILER = Gcc | Gcc43 | Gcc44 | Gcc45 | Gcc46 | Clang | Icc (Intel icc) +# WM_COMPILER = Gcc | Gcc45 | Gcc46 | Gcc47 | Clang | Icc (Intel icc) export WM_COMPILER=Gcc unset WM_COMPILER_ARCH WM_COMPILER_LIB_ARCH diff --git a/etc/cshrc b/etc/cshrc index 2700735efd..af3a34d21b 100644 --- a/etc/cshrc +++ b/etc/cshrc @@ -61,7 +61,7 @@ if ( ! $?FOAM_INST_DIR ) setenv FOAM_INST_DIR $foamInstall set foamCompiler=system #- Compiler: -# WM_COMPILER = Gcc | Gcc43 | Gcc44 | Gcc45 | Gcc46 | Clang | Icc (Intel icc) +# WM_COMPILER = Gcc | Gcc45 | Gcc46 | Gcc47 | Clang | Icc (Intel icc) setenv WM_COMPILER Gcc setenv WM_COMPILER_ARCH # defined but empty unsetenv WM_COMPILER_LIB_ARCH diff --git a/src/ODE/Make/files b/src/ODE/Make/files index c7e68837e0..912b36fecb 100644 --- a/src/ODE/Make/files +++ b/src/ODE/Make/files @@ -8,13 +8,14 @@ ODESolvers/Trapezoid/Trapezoid.C ODESolvers/RKF45/RKF45.C ODESolvers/RKCK45/RKCK45.C ODESolvers/RKDP45/RKDP45.C -ODESolvers/Rosenbrock21/Rosenbrock21.C -ODESolvers/Rosenbrock32/Rosenbrock32.C -ODESolvers/Rosenbrock43/Rosenbrock43.C -ODESolvers/rodas32/rodas32.C -ODESolvers/rodas43/rodas43.C +ODESolvers/Rosenbrock12/Rosenbrock12.C +ODESolvers/Rosenbrock23/Rosenbrock23.C +ODESolvers/Rosenbrock34/Rosenbrock34.C +ODESolvers/rodas23/rodas23.C +ODESolvers/rodas34/rodas34.C ODESolvers/SIBS/SIBS.C ODESolvers/SIBS/SIMPR.C ODESolvers/SIBS/polyExtrapolate.C +ODESolvers/seulex/seulex.C LIB = $(FOAM_LIBBIN)/libODE diff --git a/src/ODE/ODESolvers/Euler/Euler.C b/src/ODE/ODESolvers/Euler/Euler.C index 1a6edf576c..1496099ae8 100644 --- a/src/ODE/ODESolvers/Euler/Euler.C +++ b/src/ODE/ODESolvers/Euler/Euler.C @@ -49,7 +49,6 @@ Foam::Euler::Euler(const ODESystem& ode, const dictionary& dict) Foam::scalar Foam::Euler::solve ( - const ODESystem& ode, const scalar x0, const scalarField& y0, const scalarField& dydx0, @@ -75,13 +74,12 @@ Foam::scalar Foam::Euler::solve void Foam::Euler::solve ( - const ODESystem& odes, scalar& x, scalarField& y, scalar& dxTry ) const { - adaptiveSolver::solve(odes, x, y, dxTry); + adaptiveSolver::solve(odes_, x, y, dxTry); } diff --git a/src/ODE/ODESolvers/Euler/Euler.H b/src/ODE/ODESolvers/Euler/Euler.H index 90f67f4b4c..3cefc425be 100644 --- a/src/ODE/ODESolvers/Euler/Euler.H +++ b/src/ODE/ODESolvers/Euler/Euler.H @@ -84,7 +84,6 @@ public: //- Solve a single step dx and return the error scalar solve ( - const ODESystem& ode, const scalar x0, const scalarField& y0, const scalarField& dydx0, @@ -95,7 +94,6 @@ public: //- Solve the ODE system and the update the state void solve ( - const ODESystem& ode, scalar& x, scalarField& y, scalar& dxTry diff --git a/src/ODE/ODESolvers/EulerSI/EulerSI.C b/src/ODE/ODESolvers/EulerSI/EulerSI.C index 1785101758..9b28f733ea 100644 --- a/src/ODE/ODESolvers/EulerSI/EulerSI.C +++ b/src/ODE/ODESolvers/EulerSI/EulerSI.C @@ -54,7 +54,6 @@ Foam::EulerSI::EulerSI(const ODESystem& ode, const dictionary& dict) Foam::scalar Foam::EulerSI::solve ( - const ODESystem& ode, const scalar x0, const scalarField& y0, const scalarField& dydx0, @@ -62,7 +61,7 @@ Foam::scalar Foam::EulerSI::solve scalarField& y ) const { - ode.jacobian(x0, y0, dfdx_, dfdy_); + odes_.jacobian(x0, y0, dfdx_, dfdy_); for (register label i=0; i("absTol", SMALL)), relTol_(n_, dict.lookupOrDefault("relTol", 1e-4)), @@ -52,6 +53,7 @@ Foam::ODESolver::ODESolver const scalarField& relTol ) : + odes_(ode), n_(ode.nEqns()), absTol_(absTol), relTol_(relTol), @@ -82,48 +84,70 @@ Foam::scalar Foam::ODESolver::normalizeError void Foam::ODESolver::solve ( - const ODESystem& ode, + scalar& x, + scalarField& y, + stepState& step +) const +{ + solve(x, y, step.dxTry); +} + + +void Foam::ODESolver::solve +( const scalar xStart, const scalar xEnd, scalarField& y, - scalar& dxEst + scalar& dxTry ) const { + stepState step(dxTry); scalar x = xStart; - bool truncated = false; for (label nStep=0; nStep 0) + step.reject = false; + + // Check if this is a truncated step and set dxTry to integrate to xEnd + if ((x + step.dxTry - xEnd)*(x + step.dxTry - xStart) > 0) { - truncated = true; - dxEst = xEnd - x; + step.last = true; + step.dxTry = xEnd - x; } - // Integrate as far as possible up to dxEst - solve(ode, x, y, dxEst); + // Integrate as far as possible up to step.dxTry + solve(x, y, step); // Check if reached xEnd if ((x - xEnd)*(xEnd - xStart) >= 0) { - if (nStep > 0 && truncated) + if (nStep > 0 && step.last) { - dxEst = dxEst0; + step.dxTry = dxTry0; } + dxTry = step.dxTry; + return; } + + step.first = false; + + // If the step.dxTry was reject set step.prevReject + if (step.reject) + { + step.prevReject = true; + } } FatalErrorIn ( "ODESolver::solve" - "(const ODESystem& ode, const scalar xStart, const scalar xEnd," - "scalarField& y, scalar& dxEst) const" + "(const scalar xStart, const scalar xEnd," + "scalarField& y, scalar& dxTry) const" ) << "Integration steps greater than maximum " << maxSteps_ << exit(FatalError); } diff --git a/src/ODE/ODESolvers/ODESolver/ODESolver.H b/src/ODE/ODESolvers/ODESolver/ODESolver.H index bd767a9063..de4ef399f8 100644 --- a/src/ODE/ODESolvers/ODESolver/ODESolver.H +++ b/src/ODE/ODESolvers/ODESolver/ODESolver.H @@ -55,6 +55,9 @@ protected: // Protected data + //- Reference to ODESystem + const ODESystem& odes_; + //- Size of the ODESystem label n_; @@ -90,6 +93,30 @@ public: //- Runtime type information TypeName("ODESolver"); + class stepState + { + public: + + const bool forward; + scalar dxTry; + scalar dxDid; + bool first; + bool last; + bool reject; + bool prevReject; + + stepState(const scalar dx) + : + forward(dx > 0 ? true : false), + dxTry(dx), + dxDid(0), + first(true), + last(false), + reject(false), + prevReject(false) + {} + }; + // Declare run-time constructor selection table @@ -150,17 +177,31 @@ public: // Update the state and return an estimate for the next step in dxTry virtual void solve ( - const ODESystem& ode, scalar& x, scalarField& y, scalar& dxTry - ) const = 0; + ) const //= 0; + { + stepState step(dxTry); + solve(x, y, step); + dxTry = step.dxTry; + } + + //- Solve the ODE system as far as possible upto dxTry + // adjusting the step as necessary to provide a solution within + // the specified tolerance. + // Update the state and return an estimate for the next step in dxTry + virtual void solve + ( + scalar& x, + scalarField& y, + stepState& step + ) const; //- Solve the ODE system from xStart to xEnd, update the state // and return an estimate for the next step in dxTry virtual void solve ( - const ODESystem& ode, const scalar xStart, const scalar xEnd, scalarField& y, diff --git a/src/ODE/ODESolvers/RKCK45/RKCK45.C b/src/ODE/ODESolvers/RKCK45/RKCK45.C index 2de3cdf99e..30ae91de1a 100644 --- a/src/ODE/ODESolvers/RKCK45/RKCK45.C +++ b/src/ODE/ODESolvers/RKCK45/RKCK45.C @@ -89,7 +89,6 @@ Foam::RKCK45::RKCK45(const ODESystem& ode, const dictionary& dict) Foam::scalar Foam::RKCK45::solve ( - const ODESystem& odes, const scalar x0, const scalarField& y0, const scalarField& dydx0, @@ -102,21 +101,21 @@ Foam::scalar Foam::RKCK45::solve yTemp_[i] = y0[i] + a21*dx*dydx0[i]; } - odes.derivatives(x0 + c2*dx, yTemp_, k2_); + odes_.derivatives(x0 + c2*dx, yTemp_, k2_); forAll(yTemp_, i) { yTemp_[i] = y0[i] + dx*(a31*dydx0[i] + a32*k2_[i]); } - odes.derivatives(x0 + c3*dx, yTemp_, k3_); + odes_.derivatives(x0 + c3*dx, yTemp_, k3_); forAll(yTemp_, i) { yTemp_[i] = y0[i] + dx*(a41*dydx0[i] + a42*k2_[i] + a43*k3_[i]); } - odes.derivatives(x0 + c4*dx, yTemp_, k4_); + odes_.derivatives(x0 + c4*dx, yTemp_, k4_); forAll(yTemp_, i) { @@ -124,7 +123,7 @@ Foam::scalar Foam::RKCK45::solve + dx*(a51*dydx0[i] + a52*k2_[i] + a53*k3_[i] + a54*k4_[i]); } - odes.derivatives(x0 + c5*dx, yTemp_, k5_); + odes_.derivatives(x0 + c5*dx, yTemp_, k5_); forAll(yTemp_, i) { @@ -133,7 +132,7 @@ Foam::scalar Foam::RKCK45::solve *(a61*dydx0[i] + a62*k2_[i] + a63*k3_[i] + a64*k4_[i] + a65*k5_[i]); } - odes.derivatives(x0 + c6*dx, yTemp_, k6_); + odes_.derivatives(x0 + c6*dx, yTemp_, k6_); forAll(y, i) { @@ -154,13 +153,12 @@ Foam::scalar Foam::RKCK45::solve void Foam::RKCK45::solve ( - const ODESystem& odes, scalar& x, scalarField& y, scalar& dxTry ) const { - adaptiveSolver::solve(odes, x, y, dxTry); + adaptiveSolver::solve(odes_, x, y, dxTry); } diff --git a/src/ODE/ODESolvers/RKCK45/RKCK45.H b/src/ODE/ODESolvers/RKCK45/RKCK45.H index a6b551a475..5402c6efbd 100644 --- a/src/ODE/ODESolvers/RKCK45/RKCK45.H +++ b/src/ODE/ODESolvers/RKCK45/RKCK45.H @@ -34,10 +34,7 @@ Description Cash, J.R., Karp, A.H. ACM Transactions on Mathematical Software, vol. 16, 1990, pp. 201–222. - \endverbatim - Based on code from: - \verbatim "Solving Ordinary Differential Equations I: Nonstiff Problems, second edition", Hairer, E., @@ -110,7 +107,6 @@ public: //- Solve a single step dx and return the error scalar solve ( - const ODESystem& ode, const scalar x0, const scalarField& y0, const scalarField& dydx0, @@ -121,7 +117,6 @@ public: //- Solve the ODE system and the update the state void solve ( - const ODESystem& ode, scalar& x, scalarField& y, scalar& dxTry diff --git a/src/ODE/ODESolvers/RKDP45/RKDP45.C b/src/ODE/ODESolvers/RKDP45/RKDP45.C index cf319dca8b..f9a3a78836 100644 --- a/src/ODE/ODESolvers/RKDP45/RKDP45.C +++ b/src/ODE/ODESolvers/RKDP45/RKDP45.C @@ -94,7 +94,6 @@ Foam::RKDP45::RKDP45(const ODESystem& ode, const dictionary& dict) Foam::scalar Foam::RKDP45::solve ( - const ODESystem& odes, const scalar x0, const scalarField& y0, const scalarField& dydx0, @@ -107,21 +106,21 @@ Foam::scalar Foam::RKDP45::solve yTemp_[i] = y0[i] + a21*dx*dydx0[i]; } - odes.derivatives(x0 + c2*dx, yTemp_, k2_); + odes_.derivatives(x0 + c2*dx, yTemp_, k2_); forAll(yTemp_, i) { yTemp_[i] = y0[i] + dx*(a31*dydx0[i] + a32*k2_[i]); } - odes.derivatives(x0 + c3*dx, yTemp_, k3_); + odes_.derivatives(x0 + c3*dx, yTemp_, k3_); forAll(yTemp_, i) { yTemp_[i] = y0[i] + dx*(a41*dydx0[i] + a42*k2_[i] + a43*k3_[i]); } - odes.derivatives(x0 + c4*dx, yTemp_, k4_); + odes_.derivatives(x0 + c4*dx, yTemp_, k4_); forAll(yTemp_, i) { @@ -129,7 +128,7 @@ Foam::scalar Foam::RKDP45::solve + dx*(a51*dydx0[i] + a52*k2_[i] + a53*k3_[i] + a54*k4_[i]); } - odes.derivatives(x0 + c5*dx, yTemp_, k5_); + odes_.derivatives(x0 + c5*dx, yTemp_, k5_); forAll(yTemp_, i) { @@ -138,7 +137,7 @@ Foam::scalar Foam::RKDP45::solve *(a61*dydx0[i] + a62*k2_[i] + a63*k3_[i] + a64*k4_[i] + a65*k5_[i]); } - odes.derivatives(x0 + dx, yTemp_, k6_); + odes_.derivatives(x0 + dx, yTemp_, k6_); forAll(y, i) { @@ -147,7 +146,7 @@ Foam::scalar Foam::RKDP45::solve } // Reuse k2_ for the derivative of the new state - odes.derivatives(x0 + dx, y, k2_); + odes_.derivatives(x0 + dx, y, k2_); forAll(err_, i) { @@ -163,13 +162,12 @@ Foam::scalar Foam::RKDP45::solve void Foam::RKDP45::solve ( - const ODESystem& odes, scalar& x, scalarField& y, scalar& dxTry ) const { - adaptiveSolver::solve(odes, x, y, dxTry); + adaptiveSolver::solve(odes_, x, y, dxTry); } diff --git a/src/ODE/ODESolvers/RKDP45/RKDP45.H b/src/ODE/ODESolvers/RKDP45/RKDP45.H index 95ae212e66..e9ac93592a 100644 --- a/src/ODE/ODESolvers/RKDP45/RKDP45.H +++ b/src/ODE/ODESolvers/RKDP45/RKDP45.H @@ -34,10 +34,7 @@ Description Prince, P. J., Journal of Computational and Applied Mathematics, 6 (1), 1980: pp. 19-26. - \endverbatim - Based on code from: - \verbatim "Solving Ordinary Differential Equations I: Nonstiff Problems, second edition", Hairer, E., @@ -114,7 +111,6 @@ public: //- Solve a single step dx and return the error scalar solve ( - const ODESystem& ode, const scalar x0, const scalarField& y0, const scalarField& dydx0, @@ -125,7 +121,6 @@ public: //- Solve the ODE system and the update the state void solve ( - const ODESystem& ode, scalar& x, scalarField& y, scalar& dxTry diff --git a/src/ODE/ODESolvers/RKF45/RKF45.C b/src/ODE/ODESolvers/RKF45/RKF45.C index 661c618255..92804e0634 100644 --- a/src/ODE/ODESolvers/RKF45/RKF45.C +++ b/src/ODE/ODESolvers/RKF45/RKF45.C @@ -90,7 +90,6 @@ Foam::RKF45::RKF45(const ODESystem& ode, const dictionary& dict) Foam::scalar Foam::RKF45::solve ( - const ODESystem& odes, const scalar x0, const scalarField& y0, const scalarField& dydx0, @@ -103,21 +102,21 @@ Foam::scalar Foam::RKF45::solve yTemp_[i] = y0[i] + a21*dx*dydx0[i]; } - odes.derivatives(x0 + c2*dx, yTemp_, k2_); + odes_.derivatives(x0 + c2*dx, yTemp_, k2_); forAll(yTemp_, i) { yTemp_[i] = y0[i] + dx*(a31*dydx0[i] + a32*k2_[i]); } - odes.derivatives(x0 + c3*dx, yTemp_, k3_); + odes_.derivatives(x0 + c3*dx, yTemp_, k3_); forAll(yTemp_, i) { yTemp_[i] = y0[i] + dx*(a41*dydx0[i] + a42*k2_[i] + a43*k3_[i]); } - odes.derivatives(x0 + c4*dx, yTemp_, k4_); + odes_.derivatives(x0 + c4*dx, yTemp_, k4_); forAll(yTemp_, i) { @@ -125,7 +124,7 @@ Foam::scalar Foam::RKF45::solve + dx*(a51*dydx0[i] + a52*k2_[i] + a53*k3_[i] + a54*k4_[i]); } - odes.derivatives(x0 + c5*dx, yTemp_, k5_); + odes_.derivatives(x0 + c5*dx, yTemp_, k5_); forAll(yTemp_, i) { @@ -134,7 +133,7 @@ Foam::scalar Foam::RKF45::solve *(a61*dydx0[i] + a62*k2_[i] + a63*k3_[i] + a64*k4_[i] + a65*k5_[i]); } - odes.derivatives(x0 + c6*dx, yTemp_, k6_); + odes_.derivatives(x0 + c6*dx, yTemp_, k6_); // Calculate the 5th-order solution forAll(y, i) @@ -159,13 +158,12 @@ Foam::scalar Foam::RKF45::solve void Foam::RKF45::solve ( - const ODESystem& odes, scalar& x, scalarField& y, scalar& dxTry ) const { - adaptiveSolver::solve(odes, x, y, dxTry); + adaptiveSolver::solve(odes_, x, y, dxTry); } diff --git a/src/ODE/ODESolvers/RKF45/RKF45.H b/src/ODE/ODESolvers/RKF45/RKF45.H index df91ed7808..7567adc959 100644 --- a/src/ODE/ODESolvers/RKF45/RKF45.H +++ b/src/ODE/ODESolvers/RKF45/RKF45.H @@ -34,8 +34,6 @@ Description Fehlberg, E., NASA Technical Report 315, 1969. - Based on code from: - \verbatim "Solving Ordinary Differential Equations I: Nonstiff Problems, second edition", Hairer, E., @@ -48,31 +46,6 @@ Description and allows to perform an adapdive step-size control using these two order without the need of re-evaluation. - \f{align}{ - k_1 &= h f(t_k, y_k) \\ - k_2 &= h f(t_k + \frac{1}{4}h, y_k + \frac{1}{4}k_1) \\ - k_3 &= h f(t_k + \frac{3}{8}h, y_k + \frac{3}{32}k_1 + \frac{9}{32}k_2) \\ - k_4 &= h f(t_k + \frac{12}{13}h, y_k + \frac{1932}{2197}k_1 - \frac{7200}{2197}k_2 + \frac{7296}{2197}k_3) - \\ - k_5 &= h f(t_k + h, y_k + \frac{439}{216}k_1 - 8k_2 + \frac{3680}{513}k_3 - - \frac{845}{4104}k_4) \\ - k_6 &= h f(t_k + \frac{1}{2}h, y_k - \frac{8}{27}k_1 + 2k_2 - - \frac{3544}{2565}k_3 + \frac{1859}{4104}k_4 - \frac{11}{40}k_5) \\ - \f} - - Which yields the following update-steps for the 4th and 5th order: - - \f{align}{ - \Delta_4 &= \frac{25}{216}k_1 + \frac{1408}{2565}k_3 + - \frac{2197}{4101}k_4 - \frac{1}{5}k_5 \\ - \Delta_5 &= \frac{16}{135}k_1 + \frac{6656}{12825}k_3 + - \frac{9}{50}k_5 + \frac{2}{55}k_6 - \f} - - The difference between the 5th and 4th order (\f$\epsilon = \left|\Delta_5 - - \Delta_4\right|\f$) can be used to determine if the stepsize \f$h\f$ needs - to be adjusted. - SourceFiles RKF45.C @@ -138,7 +111,6 @@ public: //- Solve a single step dx and return the error scalar solve ( - const ODESystem& ode, const scalar x0, const scalarField& y0, const scalarField& dydx0, @@ -149,7 +121,6 @@ public: //- Solve the ODE system and the update the state void solve ( - const ODESystem& ode, scalar& x, scalarField& y, scalar& dxTry diff --git a/src/ODE/ODESolvers/Rosenbrock21/Rosenbrock21.C b/src/ODE/ODESolvers/Rosenbrock12/Rosenbrock12.C similarity index 77% rename from src/ODE/ODESolvers/Rosenbrock21/Rosenbrock21.C rename to src/ODE/ODESolvers/Rosenbrock12/Rosenbrock12.C index 13371a8e90..f69e6a9cde 100644 --- a/src/ODE/ODESolvers/Rosenbrock21/Rosenbrock21.C +++ b/src/ODE/ODESolvers/Rosenbrock12/Rosenbrock12.C @@ -23,33 +23,33 @@ License \*---------------------------------------------------------------------------*/ -#include "Rosenbrock21.H" +#include "Rosenbrock12.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { - defineTypeNameAndDebug(Rosenbrock21, 0); - addToRunTimeSelectionTable(ODESolver, Rosenbrock21, dictionary); + defineTypeNameAndDebug(Rosenbrock12, 0); + addToRunTimeSelectionTable(ODESolver, Rosenbrock12, dictionary); const scalar - Rosenbrock21::gamma = 1 + 1.0/std::sqrt(2.0), - Rosenbrock21::a21 = 1.0/gamma, - Rosenbrock21::c2 = 1.0, - Rosenbrock21::c21 = -2.0/gamma, - Rosenbrock21::b1 = (3.0/2.0)/gamma, - Rosenbrock21::b2 = (1.0/2.0)/gamma, - Rosenbrock21::e1 = b1 - 1.0/gamma, - Rosenbrock21::e2 = b2, - Rosenbrock21::d1 = gamma, - Rosenbrock21::d2 = -gamma; + Rosenbrock12::gamma = 1 + 1.0/std::sqrt(2.0), + Rosenbrock12::a21 = 1.0/gamma, + Rosenbrock12::c2 = 1.0, + Rosenbrock12::c21 = -2.0/gamma, + Rosenbrock12::b1 = (3.0/2.0)/gamma, + Rosenbrock12::b2 = (1.0/2.0)/gamma, + Rosenbrock12::e1 = b1 - 1.0/gamma, + Rosenbrock12::e2 = b2, + Rosenbrock12::d1 = gamma, + Rosenbrock12::d2 = -gamma; } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::Rosenbrock21::Rosenbrock21(const ODESystem& ode, const dictionary& dict) +Foam::Rosenbrock12::Rosenbrock12(const ODESystem& ode, const dictionary& dict) : ODESolver(ode, dict), adaptiveSolver(ode, dict), @@ -66,9 +66,8 @@ Foam::Rosenbrock21::Rosenbrock21(const ODESystem& ode, const dictionary& dict) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::scalar Foam::Rosenbrock21::solve +Foam::scalar Foam::Rosenbrock12::solve ( - const ODESystem& ode, const scalar x0, const scalarField& y0, const scalarField& dydx0, @@ -76,7 +75,7 @@ Foam::scalar Foam::Rosenbrock21::solve scalarField& y ) const { - ode.jacobian(x0, y0, dfdx_, dfdy_); + odes_.jacobian(x0, y0, dfdx_, dfdy_); for (register label i=0; i. Class - Foam::Rosenbrock21 + Foam::Rosenbrock12 Description L-stable embedded Rosenbrock ODE solver of order (1)2. @@ -39,12 +39,12 @@ Description \endverbatim SourceFiles - Rosenbrock21.C + Rosenbrock12.C \*---------------------------------------------------------------------------*/ -#ifndef Rosenbrock21_H -#define Rosenbrock21_H +#ifndef Rosenbrock12_H +#define Rosenbrock12_H #include "ODESolver.H" #include "adaptiveSolver.H" @@ -55,10 +55,10 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class Rosenbrock21 Declaration + Class Rosenbrock12 Declaration \*---------------------------------------------------------------------------*/ -class Rosenbrock21 +class Rosenbrock12 : public ODESolver, public adaptiveSolver @@ -87,13 +87,13 @@ class Rosenbrock21 public: //- Runtime type information - TypeName("Rosenbrock21"); + TypeName("Rosenbrock12"); // Constructors //- Construct from ODE - Rosenbrock21(const ODESystem& ode, const dictionary& dict); + Rosenbrock12(const ODESystem& ode, const dictionary& dict); // Member Functions @@ -101,7 +101,6 @@ public: //- Solve a single step dx and return the error scalar solve ( - const ODESystem& ode, const scalar x0, const scalarField& y0, const scalarField& dydx0, @@ -112,7 +111,6 @@ public: //- Solve the ODE system and the update the state void solve ( - const ODESystem& ode, scalar& x, scalarField& y, scalar& dxTry diff --git a/src/ODE/ODESolvers/Rosenbrock32/Rosenbrock32.C b/src/ODE/ODESolvers/Rosenbrock23/Rosenbrock23.C similarity index 69% rename from src/ODE/ODESolvers/Rosenbrock32/Rosenbrock32.C rename to src/ODE/ODESolvers/Rosenbrock23/Rosenbrock23.C index e471e3ffe1..035502714e 100644 --- a/src/ODE/ODESolvers/Rosenbrock32/Rosenbrock32.C +++ b/src/ODE/ODESolvers/Rosenbrock23/Rosenbrock23.C @@ -23,45 +23,45 @@ License \*---------------------------------------------------------------------------*/ -#include "Rosenbrock32.H" +#include "Rosenbrock23.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { - defineTypeNameAndDebug(Rosenbrock32, 0); - addToRunTimeSelectionTable(ODESolver, Rosenbrock32, dictionary); + defineTypeNameAndDebug(Rosenbrock23, 0); + addToRunTimeSelectionTable(ODESolver, Rosenbrock23, dictionary); const scalar - Rosenbrock32::a21 = 1, - Rosenbrock32::a31 = 1, - Rosenbrock32::a32 = 0, + Rosenbrock23::a21 = 1, + Rosenbrock23::a31 = 1, + Rosenbrock23::a32 = 0, - Rosenbrock32::c21 = -1.0156171083877702091975600115545, - Rosenbrock32::c31 = 4.0759956452537699824805835358067, - Rosenbrock32::c32 = 9.2076794298330791242156818474003, + Rosenbrock23::c21 = -1.0156171083877702091975600115545, + Rosenbrock23::c31 = 4.0759956452537699824805835358067, + Rosenbrock23::c32 = 9.2076794298330791242156818474003, - Rosenbrock32::b1 = 1, - Rosenbrock32::b2 = 6.1697947043828245592553615689730, - Rosenbrock32::b3 = -0.4277225654321857332623837380651, + Rosenbrock23::b1 = 1, + Rosenbrock23::b2 = 6.1697947043828245592553615689730, + Rosenbrock23::b3 = -0.4277225654321857332623837380651, - Rosenbrock32::e1 = 0.5, - Rosenbrock32::e2 = -2.9079558716805469821718236208017, - Rosenbrock32::e3 = 0.2235406989781156962736090927619, + Rosenbrock23::e1 = 0.5, + Rosenbrock23::e2 = -2.9079558716805469821718236208017, + Rosenbrock23::e3 = 0.2235406989781156962736090927619, - Rosenbrock32::gamma = 0.43586652150845899941601945119356, - Rosenbrock32::c2 = 0.43586652150845899941601945119356, + Rosenbrock23::gamma = 0.43586652150845899941601945119356, + Rosenbrock23::c2 = 0.43586652150845899941601945119356, - Rosenbrock32::d1 = 0.43586652150845899941601945119356, - Rosenbrock32::d2 = 0.24291996454816804366592249683314, - Rosenbrock32::d3 = 2.1851380027664058511513169485832; + Rosenbrock23::d1 = 0.43586652150845899941601945119356, + Rosenbrock23::d2 = 0.24291996454816804366592249683314, + Rosenbrock23::d3 = 2.1851380027664058511513169485832; } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::Rosenbrock32::Rosenbrock32(const ODESystem& ode, const dictionary& dict) +Foam::Rosenbrock23::Rosenbrock23(const ODESystem& ode, const dictionary& dict) : ODESolver(ode, dict), adaptiveSolver(ode, dict), @@ -79,9 +79,8 @@ Foam::Rosenbrock32::Rosenbrock32(const ODESystem& ode, const dictionary& dict) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::scalar Foam::Rosenbrock32::solve +Foam::scalar Foam::Rosenbrock23::solve ( - const ODESystem& ode, const scalar x0, const scalarField& y0, const scalarField& dydx0, @@ -89,7 +88,7 @@ Foam::scalar Foam::Rosenbrock32::solve scalarField& y ) const { - ode.jacobian(x0, y0, dfdx_, dfdy_); + odes_.jacobian(x0, y0, dfdx_, dfdy_); for (register label i=0; i. Class - Foam::Rosenbrock32 + Foam::Rosenbrock23 Description L-stable embedded Rosenbrock ODE solver of order (3)4. @@ -42,12 +42,12 @@ Description \endverbatim SourceFiles - Rosenbrock32.C + Rosenbrock23.C \*---------------------------------------------------------------------------*/ -#ifndef Rosenbrock32_H -#define Rosenbrock32_H +#ifndef Rosenbrock23_H +#define Rosenbrock23_H #include "ODESolver.H" #include "adaptiveSolver.H" @@ -58,10 +58,10 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class Rosenbrock32 Declaration + Class Rosenbrock23 Declaration \*---------------------------------------------------------------------------*/ -class Rosenbrock32 +class Rosenbrock23 : public ODESolver, public adaptiveSolver @@ -91,13 +91,13 @@ class Rosenbrock32 public: //- Runtime type information - TypeName("Rosenbrock32"); + TypeName("Rosenbrock23"); // Constructors //- Construct from ODE - Rosenbrock32(const ODESystem& ode, const dictionary& dict); + Rosenbrock23(const ODESystem& ode, const dictionary& dict); // Member Functions @@ -105,7 +105,6 @@ public: //- Solve a single step dx and return the error scalar solve ( - const ODESystem& ode, const scalar x0, const scalarField& y0, const scalarField& dydx0, @@ -116,7 +115,6 @@ public: //- Solve the ODE system and the update the state void solve ( - const ODESystem& ode, scalar& x, scalarField& y, scalar& dxTry diff --git a/src/ODE/ODESolvers/Rosenbrock43/Rosenbrock43.C b/src/ODE/ODESolvers/Rosenbrock34/Rosenbrock34.C similarity index 60% rename from src/ODE/ODESolvers/Rosenbrock43/Rosenbrock43.C rename to src/ODE/ODESolvers/Rosenbrock34/Rosenbrock34.C index 061390fdbc..65bf3ced87 100644 --- a/src/ODE/ODESolvers/Rosenbrock43/Rosenbrock43.C +++ b/src/ODE/ODESolvers/Rosenbrock34/Rosenbrock34.C @@ -23,89 +23,89 @@ License \*---------------------------------------------------------------------------*/ -#include "Rosenbrock43.H" +#include "Rosenbrock34.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { - defineTypeNameAndDebug(Rosenbrock43, 0); - addToRunTimeSelectionTable(ODESolver, Rosenbrock43, dictionary); + defineTypeNameAndDebug(Rosenbrock34, 0); + addToRunTimeSelectionTable(ODESolver, Rosenbrock34, dictionary); const scalar - // L-Stable constants from Hairer et. al. - Rosenbrock43::a21 = 2, - Rosenbrock43::a31 = 1.867943637803922, - Rosenbrock43::a32 = 0.2344449711399156, - - Rosenbrock43::c21 = -7.137615036412310, - Rosenbrock43::c31 = 2.580708087951457, - Rosenbrock43::c32 = 0.6515950076447975, - Rosenbrock43::c41 = -2.137148994382534, - Rosenbrock43::c42 = -0.3214669691237626, - Rosenbrock43::c43 = -0.6949742501781779, - - Rosenbrock43::b1 = 2.255570073418735, - Rosenbrock43::b2 = 0.2870493262186792, - Rosenbrock43::b3 = 0.435317943184018, - Rosenbrock43::b4 = 1.093502252409163, - - Rosenbrock43::e1 = -0.2815431932141155, - Rosenbrock43::e2 = -0.0727619912493892, - Rosenbrock43::e3 = -0.1082196201495311, - Rosenbrock43::e4 = -1.093502252409163, - - Rosenbrock43::gamma = 0.57282, - Rosenbrock43::c2 = 1.14564, - Rosenbrock43::c3 = 0.65521686381559, - - Rosenbrock43::d1 = 0.57282, - Rosenbrock43::d2 = -1.769193891319233, - Rosenbrock43::d3 = 0.7592633437920482, - Rosenbrock43::d4 = -0.1049021087100450; - // Constants by Shampine // More accurate than the L-Stable coefficients for small step-size // but less stable for large step-size + Rosenbrock34::a21 = 2, + Rosenbrock34::a31 = 48.0/25.0, + Rosenbrock34::a32 = 6.0/25.0, + + Rosenbrock34::c21 = -8, + Rosenbrock34::c31 = 372.0/25.0, + Rosenbrock34::c32 = 12.0/5.0, + + Rosenbrock34::c41 = -112.0/125.0, + Rosenbrock34::c42 = -54.0/125.0, + Rosenbrock34::c43 = -2.0/5.0, + + Rosenbrock34::b1 = 19.0/9.0, + Rosenbrock34::b2 = 1.0/2.0, + Rosenbrock34::b3 = 25.0/108.0, + Rosenbrock34::b4 = 125.0/108.0, + + Rosenbrock34::e1 = 34.0/108.0, + Rosenbrock34::e2 = 7.0/36.0, + Rosenbrock34::e3 = 0, + Rosenbrock34::e4 = 125.0/108.0, + + Rosenbrock34::gamma = 1.0/2.0, + Rosenbrock34::c2 = 1, + Rosenbrock34::c3 = 3.0/5.0, + + Rosenbrock34::d1 = 1.0/2.0, + Rosenbrock34::d2 = -3.0/2.0, + Rosenbrock34::d3 = 605.0/250.0, + Rosenbrock34::d4 = 29.0/250.0; + /* - Rosenbrock43::a21 = 2, - Rosenbrock43::a31 = 48.0/25.0, - Rosenbrock43::a32 = 6.0/25.0, + // L-Stable constants from Hairer et. al. + Rosenbrock34::a21 = 2, + Rosenbrock34::a31 = 1.867943637803922, + Rosenbrock34::a32 = 0.2344449711399156, - Rosenbrock43::c21 = -8, - Rosenbrock43::c31 = 372.0/25.0, - Rosenbrock43::c32 = 12.0/5.0, + Rosenbrock34::c21 = -7.137615036412310, + Rosenbrock34::c31 = 2.580708087951457, + Rosenbrock34::c32 = 0.6515950076447975, + Rosenbrock34::c41 = -2.137148994382534, + Rosenbrock34::c42 = -0.3214669691237626, + Rosenbrock34::c43 = -0.6949742501781779, - Rosenbrock43::c41 = -112.0/125.0, - Rosenbrock43::c42 = -54.0/125.0, - Rosenbrock43::c43 = -2.0/5.0, + Rosenbrock34::b1 = 2.255570073418735, + Rosenbrock34::b2 = 0.2870493262186792, + Rosenbrock34::b3 = 0.435317943184018, + Rosenbrock34::b4 = 1.093502252409163, - Rosenbrock43::b1 = 19.0/9.0, - Rosenbrock43::b2 = 1.0/2.0, - Rosenbrock43::b3 = 25.0/108.0, - Rosenbrock43::b4 = 125.0/108.0, + Rosenbrock34::e1 = -0.2815431932141155, + Rosenbrock34::e2 = -0.0727619912493892, + Rosenbrock34::e3 = -0.1082196201495311, + Rosenbrock34::e4 = -1.093502252409163, - Rosenbrock43::e1 = 34.0/108.0, - Rosenbrock43::e2 = 7.0/36.0, - Rosenbrock43::e3 = 0, - Rosenbrock43::e4 = 125.0/108.0, + Rosenbrock34::gamma = 0.57282, + Rosenbrock34::c2 = 1.14564, + Rosenbrock34::c3 = 0.65521686381559, - Rosenbrock43::gamma = 1.0/2.0, - Rosenbrock43::c2 = 1, - Rosenbrock43::c3 = 3.0/5.0, - - Rosenbrock43::d1 = 1.0/2.0, - Rosenbrock43::d2 = -3.0/2.0, - Rosenbrock43::d3 = 605.0/250.0, - Rosenbrock43::d4 = 29.0/250.0; + Rosenbrock34::d1 = 0.57282, + Rosenbrock34::d2 = -1.769193891319233, + Rosenbrock34::d3 = 0.7592633437920482, + Rosenbrock34::d4 = -0.1049021087100450; */ } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::Rosenbrock43::Rosenbrock43(const ODESystem& ode, const dictionary& dict) +Foam::Rosenbrock34::Rosenbrock34(const ODESystem& ode, const dictionary& dict) : ODESolver(ode, dict), adaptiveSolver(ode, dict), @@ -124,9 +124,8 @@ Foam::Rosenbrock43::Rosenbrock43(const ODESystem& ode, const dictionary& dict) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::scalar Foam::Rosenbrock43::solve +Foam::scalar Foam::Rosenbrock34::solve ( - const ODESystem& ode, const scalar x0, const scalarField& y0, const scalarField& dydx0, @@ -134,7 +133,7 @@ Foam::scalar Foam::Rosenbrock43::solve scalarField& y ) const { - ode.jacobian(x0, y0, dfdx_, dfdy_); + odes_.jacobian(x0, y0, dfdx_, dfdy_); for (register label i=0; i. Class - Foam::Rosenbrock43 + Foam::Rosenbrock34 Description L-stable embedded Rosenbrock ODE solver of order (3)4. - Based on code from: \verbatim "Solving Ordinary Differential Equations II: Stiff and Differential-Algebraic Problems, second edition", @@ -37,7 +36,7 @@ Description Springer-Verlag, Berlin. 1996. \endverbatim - Also provided are the constants from: + The default constants are from: \verbatim "Implementation of Rosenbrock Methods" Shampine, L. F., @@ -46,13 +45,15 @@ Description with which the scheme is more accurate than with the L-Stable coefficients for small step-size but less stable for large step-size. + The L-Stable scheme constants are provided commented-out in Rosenbrock34.C + SourceFiles - Rosenbrock43.C + Rosenbrock34.C \*---------------------------------------------------------------------------*/ -#ifndef Rosenbrock43_H -#define Rosenbrock43_H +#ifndef Rosenbrock34_H +#define Rosenbrock34_H #include "ODESolver.H" #include "adaptiveSolver.H" @@ -63,10 +64,10 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class Rosenbrock43 Declaration + Class Rosenbrock34 Declaration \*---------------------------------------------------------------------------*/ -class Rosenbrock43 +class Rosenbrock34 : public ODESolver, public adaptiveSolver @@ -98,13 +99,13 @@ class Rosenbrock43 public: //- Runtime type information - TypeName("Rosenbrock43"); + TypeName("Rosenbrock34"); // Constructors //- Construct from ODE - Rosenbrock43(const ODESystem& ode, const dictionary& dict); + Rosenbrock34(const ODESystem& ode, const dictionary& dict); // Member Functions @@ -112,7 +113,6 @@ public: //- Solve a single step dx and return the error scalar solve ( - const ODESystem& ode, const scalar x0, const scalarField& y0, const scalarField& dydx0, @@ -123,7 +123,6 @@ public: //- Solve the ODE system and the update the state void solve ( - const ODESystem& ode, scalar& x, scalarField& y, scalar& dxTry diff --git a/src/ODE/ODESolvers/SIBS/SIBS.C b/src/ODE/ODESolvers/SIBS/SIBS.C index 28d4706792..b6b6cf2c1d 100644 --- a/src/ODE/ODESolvers/SIBS/SIBS.C +++ b/src/ODE/ODESolvers/SIBS/SIBS.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -70,13 +70,12 @@ Foam::SIBS::SIBS(const ODESystem& ode, const dictionary& dict) void Foam::SIBS::solve ( - const ODESystem& ode, scalar& x, scalarField& y, scalar& dxTry ) const { - ode.derivatives(x, y, dydx0_); + odes_.derivatives(x, y, dydx0_); scalar h = dxTry; bool exitflag = false; @@ -124,7 +123,7 @@ void Foam::SIBS::solve label k = 0; yTemp_ = y; - ode.jacobian(x, y, dfdx_, dfdy_); + odes_.jacobian(x, y, dfdx_, dfdy_); if (x != xNew_ || h != dxTry) { @@ -151,7 +150,7 @@ void Foam::SIBS::solve << exit(FatalError); } - SIMPR(ode, x, yTemp_, dydx0_, dfdx_, dfdy_, h, nSeq_[k], ySeq_); + SIMPR(x, yTemp_, dydx0_, dfdx_, dfdy_, h, nSeq_[k], ySeq_); scalar xest = sqr(h/nSeq_[k]); polyExtrapolate(k, xest, ySeq_, y, yErr_, x_p_, d_p_); diff --git a/src/ODE/ODESolvers/SIBS/SIBS.H b/src/ODE/ODESolvers/SIBS/SIBS.H index 03664fd53a..0ef0a1d40c 100644 --- a/src/ODE/ODESolvers/SIBS/SIBS.H +++ b/src/ODE/ODESolvers/SIBS/SIBS.H @@ -84,7 +84,6 @@ class SIBS void SIMPR ( - const ODESystem& ode, const scalar xStart, const scalarField& y, const scalarField& dydx, @@ -123,7 +122,6 @@ public: void solve ( - const ODESystem& ode, scalar& x, scalarField& y, scalar& dxTry diff --git a/src/ODE/ODESolvers/SIBS/SIMPR.C b/src/ODE/ODESolvers/SIBS/SIMPR.C index 36402a202d..58a273b03d 100644 --- a/src/ODE/ODESolvers/SIBS/SIMPR.C +++ b/src/ODE/ODESolvers/SIBS/SIMPR.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -29,7 +29,6 @@ License void Foam::SIBS::SIMPR ( - const ODESystem& ode, const scalar xStart, const scalarField& y, const scalarField& dydx, @@ -72,7 +71,7 @@ void Foam::SIBS::SIMPR scalar x = xStart + h; - ode.derivatives(x, ytemp, yEnd); + odes_.derivatives(x, ytemp, yEnd); for (register label nn=2; nn<=nSteps; nn++) { @@ -90,7 +89,7 @@ void Foam::SIBS::SIMPR x += h; - ode.derivatives(x, ytemp, yEnd); + odes_.derivatives(x, ytemp, yEnd); } for (register label i=0; i 1) diff --git a/src/ODE/ODESolvers/adaptiveSolver/adaptiveSolver.H b/src/ODE/ODESolvers/adaptiveSolver/adaptiveSolver.H index d86bb88ce1..0d7dcb035c 100644 --- a/src/ODE/ODESolvers/adaptiveSolver/adaptiveSolver.H +++ b/src/ODE/ODESolvers/adaptiveSolver/adaptiveSolver.H @@ -77,7 +77,6 @@ public: //- Solve a single step dx and return the error virtual scalar solve ( - const ODESystem& ode, const scalar x0, const scalarField& y0, const scalarField& dydx0, diff --git a/src/ODE/ODESolvers/rodas32/rodas32.C b/src/ODE/ODESolvers/rodas23/rodas23.C similarity index 80% rename from src/ODE/ODESolvers/rodas32/rodas32.C rename to src/ODE/ODESolvers/rodas23/rodas23.C index 6221788ea6..e37bc3b00e 100644 --- a/src/ODE/ODESolvers/rodas32/rodas32.C +++ b/src/ODE/ODESolvers/rodas23/rodas23.C @@ -23,35 +23,35 @@ License \*---------------------------------------------------------------------------*/ -#include "rodas32.H" +#include "rodas23.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { - defineTypeNameAndDebug(rodas32, 0); - addToRunTimeSelectionTable(ODESolver, rodas32, dictionary); + defineTypeNameAndDebug(rodas23, 0); + addToRunTimeSelectionTable(ODESolver, rodas23, dictionary); const scalar - rodas32::c3 = 1, - rodas32::d1 = 1.0/2.0, - rodas32::d2 = 3.0/2.0, - rodas32::a31 = 2, - rodas32::a41 = 2, - rodas32::c21 = 4, - rodas32::c31 = 1, - rodas32::c32 = -1, - rodas32::c41 = 1, - rodas32::c42 = -1, - rodas32::c43 = -8.0/3.0, - rodas32::gamma = 1.0/2.0; + rodas23::c3 = 1, + rodas23::d1 = 1.0/2.0, + rodas23::d2 = 3.0/2.0, + rodas23::a31 = 2, + rodas23::a41 = 2, + rodas23::c21 = 4, + rodas23::c31 = 1, + rodas23::c32 = -1, + rodas23::c41 = 1, + rodas23::c42 = -1, + rodas23::c43 = -8.0/3.0, + rodas23::gamma = 1.0/2.0; } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::rodas32::rodas32(const ODESystem& ode, const dictionary& dict) +Foam::rodas23::rodas23(const ODESystem& ode, const dictionary& dict) : ODESolver(ode, dict), adaptiveSolver(ode, dict), @@ -70,9 +70,8 @@ Foam::rodas32::rodas32(const ODESystem& ode, const dictionary& dict) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::scalar Foam::rodas32::solve +Foam::scalar Foam::rodas23::solve ( - const ODESystem& ode, const scalar x0, const scalarField& y0, const scalarField& dydx0, @@ -80,7 +79,7 @@ Foam::scalar Foam::rodas32::solve scalarField& y ) const { - ode.jacobian(x0, y0, dfdx_, dfdy_); + odes_.jacobian(x0, y0, dfdx_, dfdy_); for (register label i=0; i. Class - Foam::rodas32 + Foam::rodas23 Description L-stable, stiffly-accurate embedded Rosenbrock ODE solver of order (2)3. @@ -42,12 +42,12 @@ Description \endverbatim SourceFiles - rodas32.C + rodas23.C \*---------------------------------------------------------------------------*/ -#ifndef rodas32_H -#define rodas32_H +#ifndef rodas23_H +#define rodas23_H #include "ODESolver.H" #include "adaptiveSolver.H" @@ -58,10 +58,10 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class rodas32 Declaration + Class rodas23 Declaration \*---------------------------------------------------------------------------*/ -class rodas32 +class rodas23 : public ODESolver, public adaptiveSolver @@ -91,13 +91,13 @@ class rodas32 public: //- Runtime type information - TypeName("rodas32"); + TypeName("rodas23"); // Constructors //- Construct from ODE - rodas32(const ODESystem& ode, const dictionary& dict); + rodas23(const ODESystem& ode, const dictionary& dict); // Member Functions @@ -105,7 +105,6 @@ public: //- Solve a single step dx and return the error scalar solve ( - const ODESystem& ode, const scalar x0, const scalarField& y0, const scalarField& dydx0, @@ -116,7 +115,6 @@ public: //- Solve the ODE system and the update the state void solve ( - const ODESystem& ode, scalar& x, scalarField& y, scalar& dxTry diff --git a/src/ODE/ODESolvers/rodas43/rodas43.C b/src/ODE/ODESolvers/rodas34/rodas34.C similarity index 67% rename from src/ODE/ODESolvers/rodas43/rodas43.C rename to src/ODE/ODESolvers/rodas34/rodas34.C index 92b78a7ab4..5d3ca9ac35 100644 --- a/src/ODE/ODESolvers/rodas43/rodas43.C +++ b/src/ODE/ODESolvers/rodas34/rodas34.C @@ -23,56 +23,56 @@ License \*---------------------------------------------------------------------------*/ -#include "rodas43.H" +#include "rodas34.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { - defineTypeNameAndDebug(rodas43, 0); - addToRunTimeSelectionTable(ODESolver, rodas43, dictionary); + defineTypeNameAndDebug(rodas34, 0); + addToRunTimeSelectionTable(ODESolver, rodas34, dictionary); const scalar - rodas43::c2 = 0.386, - rodas43::c3 = 0.21, - rodas43::c4 = 0.63, - rodas43::d1 = 0.25, - rodas43::d2 = -0.1043, - rodas43::d3 = 0.1035, - rodas43::d4 = -0.3620000000000023e-01, - rodas43::a21 = 0.1544e1, - rodas43::a31 = 0.9466785280815826, - rodas43::a32 = 0.2557011698983284, - rodas43::a41 = 0.3314825187068521e1, - rodas43::a42 = 0.2896124015972201e1, - rodas43::a43 = 0.9986419139977817, - rodas43::a51 = 0.1221224509226641e1, - rodas43::a52 = 0.6019134481288629e1, - rodas43::a53 = 0.1253708332932087e2, - rodas43::a54 = -0.6878860361058950, - rodas43::c21 = -0.56688e1, - rodas43::c31 = -0.2430093356833875e1, - rodas43::c32 = -0.2063599157091915, - rodas43::c41 = -0.1073529058151375, - rodas43::c42 = -0.9594562251023355e1, - rodas43::c43 = -0.2047028614809616e2, - rodas43::c51 = 0.7496443313967647e1, - rodas43::c52 = -0.1024680431464352e2, - rodas43::c53 = -0.3399990352819905e2, - rodas43::c54 = 0.1170890893206160e2, - rodas43::c61 = 0.8083246795921522e1, - rodas43::c62 = -0.7981132988064893e1, - rodas43::c63 = -0.3152159432874371e2, - rodas43::c64 = 0.1631930543123136e2, - rodas43::c65 = -0.6058818238834054e1, - rodas43::gamma = 0.25; + rodas34::c2 = 0.386, + rodas34::c3 = 0.21, + rodas34::c4 = 0.63, + rodas34::d1 = 0.25, + rodas34::d2 = -0.1043, + rodas34::d3 = 0.1035, + rodas34::d4 = -0.3620000000000023e-01, + rodas34::a21 = 0.1544e1, + rodas34::a31 = 0.9466785280815826, + rodas34::a32 = 0.2557011698983284, + rodas34::a41 = 0.3314825187068521e1, + rodas34::a42 = 0.2896124015972201e1, + rodas34::a43 = 0.9986419139977817, + rodas34::a51 = 0.1221224509226641e1, + rodas34::a52 = 0.6019134481288629e1, + rodas34::a53 = 0.1253708332932087e2, + rodas34::a54 = -0.6878860361058950, + rodas34::c21 = -0.56688e1, + rodas34::c31 = -0.2430093356833875e1, + rodas34::c32 = -0.2063599157091915, + rodas34::c41 = -0.1073529058151375, + rodas34::c42 = -0.9594562251023355e1, + rodas34::c43 = -0.2047028614809616e2, + rodas34::c51 = 0.7496443313967647e1, + rodas34::c52 = -0.1024680431464352e2, + rodas34::c53 = -0.3399990352819905e2, + rodas34::c54 = 0.1170890893206160e2, + rodas34::c61 = 0.8083246795921522e1, + rodas34::c62 = -0.7981132988064893e1, + rodas34::c63 = -0.3152159432874371e2, + rodas34::c64 = 0.1631930543123136e2, + rodas34::c65 = -0.6058818238834054e1, + rodas34::gamma = 0.25; } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::rodas43::rodas43(const ODESystem& ode, const dictionary& dict) +Foam::rodas34::rodas34(const ODESystem& ode, const dictionary& dict) : ODESolver(ode, dict), adaptiveSolver(ode, dict), @@ -93,9 +93,8 @@ Foam::rodas43::rodas43(const ODESystem& ode, const dictionary& dict) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::scalar Foam::rodas43::solve +Foam::scalar Foam::rodas34::solve ( - const ODESystem& ode, const scalar x0, const scalarField& y0, const scalarField& dydx0, @@ -103,7 +102,7 @@ Foam::scalar Foam::rodas43::solve scalarField& y ) const { - ode.jacobian(x0, y0, dfdx_, dfdy_); + odes_.jacobian(x0, y0, dfdx_, dfdy_); for (register label i=0; i. Class - Foam::rodas43 + Foam::rodas34 Description L-stable, stiffly-accurate embedded Rosenbrock ODE solver of order (3)4. @@ -38,12 +38,12 @@ Description \endverbatim SourceFiles - rodas43.C + rodas34.C \*---------------------------------------------------------------------------*/ -#ifndef rodas43_H -#define rodas43_H +#ifndef rodas34_H +#define rodas34_H #include "ODESolver.H" #include "adaptiveSolver.H" @@ -54,10 +54,10 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class rodas43 Declaration + Class rodas34 Declaration \*---------------------------------------------------------------------------*/ -class rodas43 +class rodas34 : public ODESolver, public adaptiveSolver @@ -92,13 +92,13 @@ class rodas43 public: //- Runtime type information - TypeName("rodas43"); + TypeName("rodas34"); // Constructors //- Construct from ODE - rodas43(const ODESystem& ode, const dictionary& dict); + rodas34(const ODESystem& ode, const dictionary& dict); // Member Functions @@ -106,7 +106,6 @@ public: //- Solve a single step dx and return the error scalar solve ( - const ODESystem& ode, const scalar x0, const scalarField& y0, const scalarField& dydx0, @@ -117,7 +116,6 @@ public: //- Solve the ODE system and the update the state void solve ( - const ODESystem& ode, scalar& x, scalarField& y, scalar& dxTry diff --git a/src/ODE/ODESolvers/seulex/seulex.C b/src/ODE/ODESolvers/seulex/seulex.C new file mode 100644 index 0000000000..cc788f9308 --- /dev/null +++ b/src/ODE/ODESolvers/seulex/seulex.C @@ -0,0 +1,463 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "seulex.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(seulex, 0); + + addToRunTimeSelectionTable(ODESolver, seulex, dictionary); + + const scalar + seulex::stepFactor1_ = 0.6, + seulex::stepFactor2_ = 0.93, + seulex::stepFactor3_ = 0.1, + seulex::stepFactor4_ = 4.0, + seulex::stepFactor5_ = 0.5, + seulex::kFactor1_ = 0.7, + seulex::kFactor2_ = 0.9; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::seulex::seulex(const ODESystem& ode, const dictionary& dict) +: + ODESolver(ode, dict), + jacRedo_(min(1.0e-4, min(relTol_))), + nSeq_(iMaxx_), + cpu_(iMaxx_), + coeff_(iMaxx_, iMaxx_), + theta_(2.0*jacRedo_), + table_(kMaxx_, n_), + dfdx_(n_), + dfdy_(n_), + a_(n_), + pivotIndices_(n_), + dxOpt_(iMaxx_), + temp_(iMaxx_), + y0_(n_), + ySequence_(n_), + scale_(n_), + dy_(n_), + yTemp_(n_), + dydx_(n_) +{ + // The CPU time factors for the major parts of the algorithm + const scalar cpuFunc = 1.0, cpuJac = 5.0, cpuLU = 1.0, cpuSolve = 1.0; + + nSeq_[0] = 2; + nSeq_[1] = 3; + + for (int i=2; i 1.0) + { + return false; + } + } + + odes_.derivatives(xnew, yTemp_, dy_); + LUBacksubstitute(a_, pivotIndices_, dy_); + } + + for (label i=0; i0; j--) + { + for (label i=0; i jacRedo_) + { + odes_.jacobian(x, y, dfdx_, dfdy_); + jacUpdated = true; + } + + int k; + scalar dxNew = mag(dx); + bool firstk = true; + + while (firstk || step.reject) + { + dx = step.forward ? dxNew : -dxNew; + firstk = false; + step.reject = false; + + if (mag(dx) <= mag(x)*SMALL) + { + WarningIn("seulex::solve(scalar& x, scalarField& y, stepState&") + << "step size underflow :" << dx << endl; + } + + scalar errOld; + + for (k=0; k<=kTarg_+1; k++) + { + bool success = seul(x, y0_, dx, k, ySequence_, scale_); + + if (!success) + { + step.reject = true; + dxNew = mag(dx)*stepFactor5_; + break; + } + + if (k == 0) + { + y = ySequence_; + } + else + { + forAll(ySequence_, i) + { + table_[k-1][i] = ySequence_[i]; + } + } + + if (k != 0) + { + extrapolate(k, table_, y); + scalar err = 0.0; + forAll(scale_, i) + { + scale_[i] = absTol_[i] + relTol_[i]*mag(y0_[i]); + err += sqr((y[i] - table_[0][i])/scale_[i]); + } + err = sqrt(err/n_); + if (err > 1.0/SMALL || (k > 1 && err >= errOld)) + { + step.reject = true; + dxNew = mag(dx)*stepFactor5_; + break; + } + errOld = min(4*err, 1); + scalar expo = 1.0/(k + 1); + scalar facmin = pow(stepFactor3_, expo); + scalar fac; + if (err == 0.0) + { + fac = 1.0/facmin; + } + else + { + fac = stepFactor2_/pow(err/stepFactor1_, expo); + fac = max(facmin/stepFactor4_, min(1.0/facmin, fac)); + } + dxOpt_[k] = mag(dx*fac); + temp_[k] = cpu_[k]/dxOpt_[k]; + + if ((step.first || step.last) && err <= 1.0) + { + break; + } + + if + ( + k == kTarg_ - 1 + && !step.prevReject + && !step.first && !step.last + ) + { + if (err <= 1.0) + { + break; + } + else if (err > nSeq_[kTarg_]*nSeq_[kTarg_ + 1]*4.0) + { + step.reject = true; + kTarg_ = k; + if (kTarg_>1 && temp_[k-1] < kFactor1_*temp_[k]) + { + kTarg_--; + } + dxNew = dxOpt_[kTarg_]; + break; + } + } + + if (k == kTarg_) + { + if (err <= 1.0) + { + break; + } + else if (err > nSeq_[k + 1]*2.0) + { + step.reject = true; + if (kTarg_>1 && temp_[k-1] < kFactor1_*temp_[k]) + { + kTarg_--; + } + dxNew = dxOpt_[kTarg_]; + break; + } + } + + if (k == kTarg_+1) + { + if (err > 1.0) + { + step.reject = true; + if + ( + kTarg_ > 1 + && temp_[kTarg_-1] < kFactor1_*temp_[kTarg_] + ) + { + kTarg_--; + } + dxNew = dxOpt_[kTarg_]; + } + break; + } + } + } + if (step.reject) + { + step.prevReject = true; + if (!jacUpdated) + { + theta_ = 2.0*jacRedo_; + + if (theta_ > jacRedo_ && !jacUpdated) + { + odes_.jacobian(x, y, dfdx_, dfdy_); + jacUpdated = true; + } + } + } + } + + jacUpdated = false; + + step.dxDid = dx; + x += dx; + + label kopt; + if (k == 1) + { + kopt = 2; + } + else if (k <= kTarg_) + { + kopt=k; + if (temp_[k-1] < kFactor1_*temp_[k]) + { + kopt = k - 1; + } + else if (temp_[k] < kFactor2_*temp_[k - 1]) + { + kopt = min(k + 1, kMaxx_ - 1); + } + } + else + { + kopt = k - 1; + if (k > 2 && temp_[k-2] < kFactor1_*temp_[k - 1]) + { + kopt = k - 2; + } + if (temp_[k] < kFactor2_*temp_[kopt]) + { + kopt = min(k, kMaxx_ - 1); + } + } + + if (step.prevReject) + { + kTarg_ = min(kopt, k); + dxNew = min(mag(dx), dxOpt_[kTarg_]); + step.prevReject = false; + } + else + { + if (kopt <= k) + { + dxNew = dxOpt_[kopt]; + } + else + { + if (k < kTarg_ && temp_[k] < kFactor2_*temp_[k - 1]) + { + dxNew = dxOpt_[k]*cpu_[kopt + 1]/cpu_[k]; + } + else + { + dxNew = dxOpt_[k]*cpu_[kopt]/cpu_[k]; + } + } + kTarg_ = kopt; + } + + step.dxTry = step.forward ? dxNew : -dxNew; +} + + +// ************************************************************************* // diff --git a/src/ODE/ODESolvers/seulex/seulex.H b/src/ODE/ODESolvers/seulex/seulex.H new file mode 100644 index 0000000000..c3cd540198 --- /dev/null +++ b/src/ODE/ODESolvers/seulex/seulex.H @@ -0,0 +1,160 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::seulex + +Description + An extrapolation-algorithm, based on the linearly implicit Euler method + with step size control and order selection. + + The implementation is based on the SEULEX algorithm in + \verbatim + "Solving Ordinary Differential Equations II: Stiff + and Differential-Algebraic Problems, second edition", + Hairer, E., + Nørsett, S., + Wanner, G., + Springer-Verlag, Berlin. 1996. + \endverbatim + +SourceFiles + seulex.C + +\*---------------------------------------------------------------------------*/ + +#ifndef seulex_H +#define seulex_H + +#include "ODESolver.H" +#include "scalarMatrices.H" +#include "labelField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class seulex Declaration +\*---------------------------------------------------------------------------*/ + +class seulex +: + public ODESolver +{ + // Private data + + // Static constants + + static const label kMaxx_ = 12; + static const label iMaxx_ = kMaxx_ + 1; + + static const scalar + stepFactor1_, stepFactor2_, stepFactor3_, + stepFactor4_, stepFactor5_, + kFactor1_, kFactor2_; + + // Evaluated constants + + scalar jacRedo_; + labelField nSeq_; + scalarField cpu_; + scalarSquareMatrix coeff_; + + // Temporary storage + // held to avoid dynamic memory allocation between calls + // and to transfer internal values between functions + + mutable scalar theta_; + mutable label kTarg_; + mutable scalarRectangularMatrix table_; + + mutable scalarField dfdx_; + mutable scalarSquareMatrix dfdy_; + mutable scalarSquareMatrix a_; + mutable labelList pivotIndices_; + + // Fields space for "solve" function + mutable scalarField dxOpt_, temp_; + mutable scalarField y0_, ySequence_, scale_; + + // Fields used in "seul" function + mutable scalarField dy_, yTemp_, dydx_; + + + // Private Member Functions + + //- Computes the j-th line of the extrapolation table + bool seul + ( + const scalar x0, + const scalarField& y0, + const scalar dxTot, + const label k, + scalarField& y, + const scalarField& scale + ) const; + + //- Polynomial extrpolation + void extrapolate + ( + const label k, + scalarRectangularMatrix& table, + scalarField& y + ) const; + + +public: + + //- Runtime type information + TypeName("seulex"); + + + // Constructors + + //- Construct from ODE + seulex(const ODESystem& ode, const dictionary& dict); + + + // Member Functions + + //- Solve the ODE system and the update the state + void solve + ( + scalar& x, + scalarField& y, + stepState& step + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/Time/TimeIO.C b/src/OpenFOAM/db/Time/TimeIO.C index 8aa894def7..84f334f18b 100644 --- a/src/OpenFOAM/db/Time/TimeIO.C +++ b/src/OpenFOAM/db/Time/TimeIO.C @@ -579,8 +579,8 @@ void Foam::Time::readModifiedObjects() if (controlDict_.readIfModified()) { - readDict(); - functionObjects_.read(); + readDict(); + functionObjects_.read(); } bool registryModified = objectRegistry::modified(); diff --git a/src/OpenFOAM/fields/pointPatchFields/basic/basicSymmetry/basicSymmetryPointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/basic/basicSymmetry/basicSymmetryPointPatchField.C index 3a47b78cac..85c718e703 100644 --- a/src/OpenFOAM/fields/pointPatchFields/basic/basicSymmetry/basicSymmetryPointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/basic/basicSymmetry/basicSymmetryPointPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -59,10 +59,10 @@ Foam::basicSymmetryPointPatchField::basicSymmetryPointPatchField const basicSymmetryPointPatchField& ptf, const pointPatch& p, const DimensionedField& iF, - const pointPatchFieldMapper& + const pointPatchFieldMapper& mapper ) : - pointPatchField(p, iF) + pointPatchField(ptf, p, iF, mapper) {} diff --git a/src/OpenFOAM/fields/pointPatchFields/basic/calculated/calculatedPointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/basic/calculated/calculatedPointPatchField.C index a80e1421bb..45f98495db 100644 --- a/src/OpenFOAM/fields/pointPatchFields/basic/calculated/calculatedPointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/basic/calculated/calculatedPointPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -68,10 +68,10 @@ calculatedPointPatchField::calculatedPointPatchField const calculatedPointPatchField& ptf, const pointPatch& p, const DimensionedField& iF, - const pointPatchFieldMapper& + const pointPatchFieldMapper& mapper ) : - pointPatchField(p, iF) + pointPatchField(ptf, p, iF, mapper) {} diff --git a/src/OpenFOAM/fields/pointPatchFields/basic/coupled/coupledPointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/basic/coupled/coupledPointPatchField.C index dfae5f7d28..434b6873f4 100644 --- a/src/OpenFOAM/fields/pointPatchFields/basic/coupled/coupledPointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/basic/coupled/coupledPointPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -61,10 +61,10 @@ coupledPointPatchField::coupledPointPatchField const coupledPointPatchField& ptf, const pointPatch& p, const DimensionedField& iF, - const pointPatchFieldMapper& + const pointPatchFieldMapper& mapper ) : - pointPatchField(p, iF) + pointPatchField(ptf, p, iF, mapper) {} diff --git a/src/OpenFOAM/fields/pointPatchFields/basic/value/valuePointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/basic/value/valuePointPatchField.C index d09bedf76b..6f5c7ef267 100644 --- a/src/OpenFOAM/fields/pointPatchFields/basic/value/valuePointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/basic/value/valuePointPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -108,7 +108,7 @@ Foam::valuePointPatchField::valuePointPatchField const pointPatchFieldMapper& mapper ) : - pointPatchField(p, iF), + pointPatchField(ptf, p, iF, mapper), Field(ptf, mapper) {} diff --git a/src/OpenFOAM/fields/pointPatchFields/basic/zeroGradient/zeroGradientPointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/basic/zeroGradient/zeroGradientPointPatchField.C index a10d879179..754ba28d75 100644 --- a/src/OpenFOAM/fields/pointPatchFields/basic/zeroGradient/zeroGradientPointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/basic/zeroGradient/zeroGradientPointPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -61,10 +61,10 @@ zeroGradientPointPatchField::zeroGradientPointPatchField const zeroGradientPointPatchField& ptf, const pointPatch& p, const DimensionedField& iF, - const pointPatchFieldMapper& + const pointPatchFieldMapper& mapper ) : - pointPatchField(p, iF) + pointPatchField(ptf, p, iF, mapper) {} diff --git a/src/OpenFOAM/fields/pointPatchFields/constraint/empty/emptyPointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/constraint/empty/emptyPointPatchField.C index 8fd4b5bc0b..41f97055ae 100644 --- a/src/OpenFOAM/fields/pointPatchFields/constraint/empty/emptyPointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/constraint/empty/emptyPointPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -77,10 +77,10 @@ emptyPointPatchField::emptyPointPatchField const emptyPointPatchField& ptf, const pointPatch& p, const DimensionedField& iF, - const pointPatchFieldMapper& + const pointPatchFieldMapper& mapper ) : - pointPatchField(p, iF) + pointPatchField(ptf, p, iF, mapper) { if (!isType(this->patch())) { diff --git a/src/OpenFOAM/fields/pointPatchFields/constraint/wedge/wedgePointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/constraint/wedge/wedgePointPatchField.C index eac29f3251..447c7771cd 100644 --- a/src/OpenFOAM/fields/pointPatchFields/constraint/wedge/wedgePointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/constraint/wedge/wedgePointPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -74,10 +74,10 @@ Foam::wedgePointPatchField::wedgePointPatchField const wedgePointPatchField& ptf, const pointPatch& p, const DimensionedField& iF, - const pointPatchFieldMapper& + const pointPatchFieldMapper& mapper ) : - pointPatchField(p, iF) + pointPatchField(ptf, p, iF, mapper) { if (!isType(this->patch())) { diff --git a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C index 3e62d6a202..be4b10dfd8 100644 --- a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -63,6 +63,22 @@ pointPatchField::pointPatchField {} +template +Foam::pointPatchField::pointPatchField +( + const pointPatchField& ptf, + const pointPatch& p, + const DimensionedField& iF, + const pointPatchFieldMapper& +) +: + patch_(p), + internalField_(iF), + updated_(false), + patchType_(ptf.patchType_) +{} + + template pointPatchField::pointPatchField ( diff --git a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H index 439966188b..88e6bfecfe 100644 --- a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H +++ b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H @@ -167,6 +167,15 @@ public: const dictionary& ); + //- Construct by mapping given patchField onto a new patch + pointPatchField + ( + const pointPatchField&, + const pointPatch&, + const DimensionedField&, + const pointPatchFieldMapper& + ); + //- Construct as copy pointPatchField(const pointPatchField&); diff --git a/src/OpenFOAM/primitives/Tensor/tensor/tensor.C b/src/OpenFOAM/primitives/Tensor/tensor/tensor.C index e5c6d35622..992c108ae2 100644 --- a/src/OpenFOAM/primitives/Tensor/tensor/tensor.C +++ b/src/OpenFOAM/primitives/Tensor/tensor/tensor.C @@ -26,69 +26,68 @@ License #include "tensor.H" #include "mathematicalConstants.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ +using namespace Foam::constant::mathematical; // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -template<> -const char* const tensor::typeName = "tensor"; - -template<> -const char* tensor::componentNames[] = +namespace Foam { - "xx", "xy", "xz", - "yx", "yy", "yz", - "zx", "zy", "zz" -}; + template<> + const char* const tensor::typeName = "tensor"; -template<> -const tensor tensor::zero -( - 0, 0, 0, - 0, 0, 0, - 0, 0, 0 -); + template<> + const char* tensor::componentNames[] = + { + "xx", "xy", "xz", + "yx", "yy", "yz", + "zx", "zy", "zz" + }; -template<> -const tensor tensor::one -( - 1, 1, 1, - 1, 1, 1, - 1, 1, 1 -); + template<> + const tensor tensor::zero + ( + 0, 0, 0, + 0, 0, 0, + 0, 0, 0 + ); -template<> -const tensor tensor::max -( - VGREAT, VGREAT, VGREAT, - VGREAT, VGREAT, VGREAT, - VGREAT, VGREAT, VGREAT -); + template<> + const tensor tensor::one + ( + 1, 1, 1, + 1, 1, 1, + 1, 1, 1 + ); -template<> -const tensor tensor::min -( - -VGREAT, -VGREAT, -VGREAT, - -VGREAT, -VGREAT, -VGREAT, - -VGREAT, -VGREAT, -VGREAT -); + template<> + const tensor tensor::max + ( + VGREAT, VGREAT, VGREAT, + VGREAT, VGREAT, VGREAT, + VGREAT, VGREAT, VGREAT + ); -template<> -const tensor tensor::I -( - 1, 0, 0, - 0, 1, 0, - 0, 0, 1 -); + template<> + const tensor tensor::min + ( + -VGREAT, -VGREAT, -VGREAT, + -VGREAT, -VGREAT, -VGREAT, + -VGREAT, -VGREAT, -VGREAT + ); + + template<> + const tensor tensor::I + ( + 1, 0, 0, + 0, 1, 0, + 0, 0, 1 + ); +} // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// Return eigenvalues in ascending order of absolute values -vector eigenValues(const tensor& t) +Foam::vector Foam::eigenValues(const tensor& t) { scalar i = 0; scalar ii = 0; @@ -120,7 +119,7 @@ vector eigenValues(const tensor& t) + t.xy()*t.yx()*t.zz() + t.xx()*t.yz()*t.zy(); // If there is a zero root - if (mag(c) < 1.0e-100) + if (mag(c) < ROOTVSMALL) { scalar disc = sqr(a) - 4*b; @@ -157,14 +156,8 @@ vector eigenValues(const tensor& t) scalar aBy3 = a/3; i = m2SqrtQ*cos(theta/3) - aBy3; - ii = - m2SqrtQ - *cos((theta + constant::mathematical::twoPi)/3) - - aBy3; - iii = - m2SqrtQ - *cos((theta - constant::mathematical::twoPi)/3) - - aBy3; + ii = m2SqrtQ*cos((theta + twoPi)/3) - aBy3; + iii = m2SqrtQ*cos((theta - twoPi)/3) - aBy3; } else { @@ -210,7 +203,7 @@ vector eigenValues(const tensor& t) } -vector eigenVector(const tensor& t, const scalar lambda) +Foam::vector Foam::eigenVector(const tensor& t, const scalar lambda) { if (mag(lambda) < SMALL) { @@ -273,7 +266,7 @@ vector eigenVector(const tensor& t, const scalar lambda) } -tensor eigenVectors(const tensor& t) +Foam::tensor Foam::eigenVectors(const tensor& t) { vector evals(eigenValues(t)); @@ -289,7 +282,7 @@ tensor eigenVectors(const tensor& t) // Return eigenvalues in ascending order of absolute values -vector eigenValues(const symmTensor& t) +Foam::vector Foam::eigenValues(const symmTensor& t) { scalar i = 0; scalar ii = 0; @@ -321,7 +314,7 @@ vector eigenValues(const symmTensor& t) + t.xy()*t.xy()*t.zz() + t.xx()*t.yz()*t.yz(); // If there is a zero root - if (mag(c) < 1.0e-100) + if (mag(c) < ROOTVSMALL) { scalar disc = sqr(a) - 4*b; @@ -358,14 +351,8 @@ vector eigenValues(const symmTensor& t) scalar aBy3 = a/3; i = m2SqrtQ*cos(theta/3) - aBy3; - ii = - m2SqrtQ - *cos((theta + constant::mathematical::twoPi)/3) - - aBy3; - iii = - m2SqrtQ - *cos((theta - constant::mathematical::twoPi)/3) - - aBy3; + ii = m2SqrtQ*cos((theta + twoPi)/3) - aBy3; + iii = m2SqrtQ*cos((theta - twoPi)/3) - aBy3; } else { @@ -411,7 +398,7 @@ vector eigenValues(const symmTensor& t) } -vector eigenVector(const symmTensor& t, const scalar lambda) +Foam::vector Foam::eigenVector(const symmTensor& t, const scalar lambda) { if (mag(lambda) < SMALL) { @@ -474,7 +461,7 @@ vector eigenVector(const symmTensor& t, const scalar lambda) } -tensor eigenVectors(const symmTensor& t) +Foam::tensor Foam::eigenVectors(const symmTensor& t) { vector evals(eigenValues(t)); @@ -489,8 +476,4 @@ tensor eigenVectors(const symmTensor& t) } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/demandDrivenEntry/demandDrivenEntry.C b/src/OpenFOAM/primitives/demandDrivenEntry/demandDrivenEntry.C new file mode 100644 index 0000000000..bac4117c78 --- /dev/null +++ b/src/OpenFOAM/primitives/demandDrivenEntry/demandDrivenEntry.C @@ -0,0 +1,89 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "demandDrivenEntry.H" + +// * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * * // + +template +Foam::demandDrivenEntry::demandDrivenEntry +( + const dictionary& dict, + const Type& value +) +: + dict_(dict), + keyword_("unknown-keyword"), + value_(value), + stored_(true) +{} + + +template +Foam::demandDrivenEntry::demandDrivenEntry +( + const dictionary& dict, + const word& keyword +) +: + dict_(dict), + keyword_(keyword), + value_(pTraits::zero), + stored_(false) +{} + + +template +Foam::demandDrivenEntry::demandDrivenEntry +( + const dictionary& dict, + const word& keyword, + const Type& defaultValue, + const bool readIfPresent +) +: + dict_(dict), + keyword_(keyword), + value_(defaultValue), + stored_(true) +{ + if (readIfPresent) + { + dict_.readIfPresent(keyword, value_); + } +} + + +template +Foam::demandDrivenEntry::demandDrivenEntry(const demandDrivenEntry& dde) +: + dict_(dde.dict_), + keyword_(dde.keyword_), + value_(dde.value_), + stored_(dde.stored_) +{} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/demandDrivenEntry/demandDrivenEntry.H b/src/OpenFOAM/primitives/demandDrivenEntry/demandDrivenEntry.H new file mode 100644 index 0000000000..148dd795e6 --- /dev/null +++ b/src/OpenFOAM/primitives/demandDrivenEntry/demandDrivenEntry.H @@ -0,0 +1,139 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::demandDrivenEntry + +Description + Class for demand-driven dictionary entries + + Holds a reference to a dictionary, which is then queried if the value + is requested and has not already been cached + +SourceFiles + demandDrivenEntry.C + demandDrivenEntryI.H + +\*---------------------------------------------------------------------------*/ + +#ifndef demandDrivenEntry_H +#define demandDrivenEntry_H + +#include "dictionary.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class demandDrivenEntry Declaration +\*---------------------------------------------------------------------------*/ + +template +class demandDrivenEntry +{ +private: + + // Private data + + //- Reference to the dictionary + const dictionary& dict_; + + //- Keyword to look up + const word keyword_; + + //- Value + mutable Type value_; + + //- Flag to say that the value has been stored + mutable bool stored_; + + +public: + + //- Constructors + + //- Construct from dictionary and value - cannot be re-read + demandDrivenEntry + ( + const dictionary& dict, + const Type& value + ); + + + //- Construct from dictionary and keyword + demandDrivenEntry + ( + const dictionary& dict, + const word& keyword + ); + + + //- Construct from dictionary, keyword and default value + demandDrivenEntry + ( + const dictionary& dict, + const word& keyword, + const Type& defaultValue, + const bool readIfPresent = true + ); + + //- Copy constructor + demandDrivenEntry(const demandDrivenEntry& dde); + + + // Public Member Functions + + //- Initialise + inline void initialise() const; + + //- Return the value + inline const Type& value() const; + + //- Set the value + inline void setValue(const Type& value); + + //- Reset the demand-driven entry + inline void reset(); +}; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "demandDrivenEntryI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "demandDrivenEntry.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/demandDrivenEntry/demandDrivenEntryI.H b/src/OpenFOAM/primitives/demandDrivenEntry/demandDrivenEntryI.H new file mode 100644 index 0000000000..c22ec7f6da --- /dev/null +++ b/src/OpenFOAM/primitives/demandDrivenEntry/demandDrivenEntryI.H @@ -0,0 +1,66 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "demandDrivenEntry.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template +inline void Foam::demandDrivenEntry::initialise() const +{ + if (!stored_) + { + dict_.lookup(keyword_) >> value_; + stored_ = true; + } +} + + +template +inline const Type& Foam::demandDrivenEntry::value() const +{ + initialise(); + + return value_; +} + + +template +inline void Foam::demandDrivenEntry::setValue(const Type& value) +{ +// dict_.set(keyword_, value); + value_ = value; + stored_ = true; +} + + +template +inline void Foam::demandDrivenEntry::reset() +{ + stored_ = false; +} + + +// ************************************************************************* // diff --git a/src/combustionModels/PaSR/PaSR.C b/src/combustionModels/PaSR/PaSR.C index dcc3c9e315..2e9d3f011b 100644 --- a/src/combustionModels/PaSR/PaSR.C +++ b/src/combustionModels/PaSR/PaSR.C @@ -42,7 +42,7 @@ Foam::combustionModels::PaSR::PaSR ( IOobject ( - typeName + ":kappa", + "PaSR:kappa", mesh.time().timeName(), mesh, IOobject::NO_READ, @@ -117,7 +117,11 @@ template Foam::tmp Foam::combustionModels::PaSR::dQ() const { - return kappa_*laminar::dQ(); + return + tmp + ( + new volScalarField("PaSR:dQ", kappa_*laminar::dQ()) + ); } @@ -125,7 +129,11 @@ template Foam::tmp Foam::combustionModels::PaSR::Sh() const { - return kappa_*laminar::Sh(); + return + tmp + ( + new volScalarField("PaSR:Sh", kappa_*laminar::Sh()) + ); } diff --git a/src/dynamicMesh/extrudePatchMesh/extrudePatchMesh.C b/src/dynamicMesh/extrudePatchMesh/extrudePatchMesh.C index 5bba2ff062..970e0dac47 100644 --- a/src/dynamicMesh/extrudePatchMesh/extrudePatchMesh.C +++ b/src/dynamicMesh/extrudePatchMesh/extrudePatchMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.C b/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.C index 7efbf7cce2..2c7a064b29 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -51,7 +51,7 @@ void Foam::polyTopoChanger::readModifiers() { WarningIn("polyTopoChanger::readModifiers()") << "Specified IOobject::MUST_READ_IF_MODIFIED but class" - << " does not support automatic rereading." + << " does not support automatic re-reading." << endl; } @@ -80,18 +80,13 @@ void Foam::polyTopoChanger::readModifiers() } // Check state of IOstream - is.check - ( - "polyTopoChanger::polyTopoChanger" - "(const IOobject&, const polyMesh&)" - ); + is.check("polyTopoChanger::readModifiers()"); close(); } } -// Read constructor given IOobject and a polyMesh reference Foam::polyTopoChanger::polyTopoChanger ( const IOobject& io, @@ -106,7 +101,6 @@ Foam::polyTopoChanger::polyTopoChanger } -// Read constructor given IOobject and a polyMesh reference Foam::polyTopoChanger::polyTopoChanger(polyMesh& mesh) : PtrList(), @@ -133,7 +127,6 @@ Foam::polyTopoChanger::polyTopoChanger(polyMesh& mesh) } -// Return a list of modifier types Foam::wordList Foam::polyTopoChanger::types() const { const PtrList& modifiers = *this; @@ -149,7 +142,6 @@ Foam::wordList Foam::polyTopoChanger::types() const } -// Return a list of modifier names Foam::wordList Foam::polyTopoChanger::names() const { const PtrList& modifiers = *this; @@ -165,7 +157,6 @@ Foam::wordList Foam::polyTopoChanger::names() const } -// Is topology change required bool Foam::polyTopoChanger::changeTopology() const { // Go through all mesh modifiers and accumulate the morphing information @@ -211,7 +202,6 @@ bool Foam::polyTopoChanger::changeTopology() const } -// Return topology change request Foam::autoPtr Foam::polyTopoChanger::topoChangeRequest() const { @@ -233,7 +223,6 @@ Foam::polyTopoChanger::topoChangeRequest() const } -// Correct polyTopoChanger after moving points void Foam::polyTopoChanger::modifyMotionPoints(pointField& p) const { const PtrList& topoChanges = *this; @@ -248,7 +237,6 @@ void Foam::polyTopoChanger::modifyMotionPoints(pointField& p) const } -// Force recalculation of locally stored data on topological change void Foam::polyTopoChanger::update(const mapPolyMesh& m) { // Go through all mesh modifiers and accumulate the morphing information @@ -299,7 +287,6 @@ Foam::autoPtr Foam::polyTopoChanger::changeMesh } -// Add mesh modifiers to the morph engine void Foam::polyTopoChanger::addTopologyModifiers ( const List& tm @@ -314,8 +301,10 @@ void Foam::polyTopoChanger::addTopologyModifiers { FatalErrorIn ( - "void polyTopoChanger::addTopologyModifiers(" - "const List& tm)" + "void polyTopoChanger::addTopologyModifiers" + "(" + "const List&" + ")" ) << "Mesh modifier created with different mesh reference." << abort(FatalError); } @@ -344,8 +333,7 @@ Foam::label Foam::polyTopoChanger::findModifierID // Modifier not found if (debug) { - Info<< "label polyTopoChanger::::findModifierID(const word& " - << "modName) const" + WarningIn("label polyTopoChanger::findModifierID(const word&) const") << "Modifier named " << modName << " not found. " << "List of available modifier names: " << names() << endl; } @@ -355,7 +343,6 @@ Foam::label Foam::polyTopoChanger::findModifierID } -// writeData member function required by regIOobject bool Foam::polyTopoChanger::writeData(Ostream& os) const { os << *this; diff --git a/src/fvOptions/sources/derived/MRFSource/MRFSource.C b/src/fvOptions/sources/derived/MRFSource/MRFSource.C index 9f9fcca442..d9b4a2a9b9 100644 --- a/src/fvOptions/sources/derived/MRFSource/MRFSource.C +++ b/src/fvOptions/sources/derived/MRFSource/MRFSource.C @@ -175,6 +175,8 @@ bool Foam::fv::MRFSource::read(const dictionary& dict) coeffs_.readIfPresent("UName", UName_); coeffs_.readIfPresent("rhoName", rhoName_); + initialise(); + return true; } else diff --git a/src/lagrangian/intermediate/clouds/Templates/CollidingCloud/CollidingCloud.C b/src/lagrangian/intermediate/clouds/Templates/CollidingCloud/CollidingCloud.C index 8292b9712b..3ad01176c0 100644 --- a/src/lagrangian/intermediate/clouds/Templates/CollidingCloud/CollidingCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/CollidingCloud/CollidingCloud.C @@ -92,6 +92,7 @@ Foam::CollidingCloud::CollidingCloud ) : CloudType(cloudName, rho, U, mu, g, false), + constProps_(this->particleProperties()), collisionModel_(NULL) { if (this->solution().steadyState()) @@ -246,4 +247,5 @@ void Foam::CollidingCloud::info() << rotationalKineticEnergy << nl; } + // ************************************************************************* // diff --git a/src/lagrangian/intermediate/clouds/Templates/CollidingCloud/CollidingCloud.H b/src/lagrangian/intermediate/clouds/Templates/CollidingCloud/CollidingCloud.H index 3b42061bf4..ceac587e93 100644 --- a/src/lagrangian/intermediate/clouds/Templates/CollidingCloud/CollidingCloud.H +++ b/src/lagrangian/intermediate/clouds/Templates/CollidingCloud/CollidingCloud.H @@ -97,6 +97,10 @@ protected: // Protected data + //- Thermo parcel constant properties + typename parcelType::constantProperties constProps_; + + // References to the cloud sub-models //- Collision model @@ -180,6 +184,11 @@ public: //- Return a reference to the cloud copy inline const CollidingCloud& cloudCopy() const; + //- Return the constant properties + inline const typename parcelType::constantProperties& + constProps() const; + + //- If the collision model controls the wall interaction, // then the wall impact distance should be zero. // Otherwise, it should be allowed to be the value from diff --git a/src/lagrangian/intermediate/clouds/Templates/CollidingCloud/CollidingCloudI.H b/src/lagrangian/intermediate/clouds/Templates/CollidingCloud/CollidingCloudI.H index 1dedd5da9c..f22610f967 100644 --- a/src/lagrangian/intermediate/clouds/Templates/CollidingCloud/CollidingCloudI.H +++ b/src/lagrangian/intermediate/clouds/Templates/CollidingCloud/CollidingCloudI.H @@ -33,6 +33,14 @@ Foam::CollidingCloud::cloudCopy() const } +template +inline const typename CloudType::particleType::constantProperties& +Foam::CollidingCloud::constProps() const +{ + return constProps_; +} + + template inline const Foam::CollisionModel >& Foam::CollidingCloud::collision() const diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C index 7cab777680..dc42e0f9db 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C @@ -308,7 +308,7 @@ Foam::KinematicCloud::KinematicCloud ) ), solution_(mesh_, particleProperties_.subDict("solution")), - constProps_(particleProperties_, solution_.active()), + constProps_(particleProperties_), subModelProperties_ ( particleProperties_.subOrEmptyDict("subModels", solution_.active()) diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C index 0464da7e48..f99ac8bbbd 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C @@ -106,7 +106,7 @@ Foam::ReactingCloud::ReactingCloud CloudType(cloudName, rho, U, g, thermo, false), reactingCloud(), cloudCopyPtr_(NULL), - constProps_(this->particleProperties(), this->solution().active()), + constProps_(this->particleProperties()), compositionModel_(NULL), phaseChangeModel_(NULL), rhoTrans_(thermo.carrier().species().size()) diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C b/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C index 31bc4c3222..963cd985b2 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -85,7 +85,7 @@ Foam::ReactingMultiphaseCloud::ReactingMultiphaseCloud CloudType(cloudName, rho, U, g, thermo, false), reactingMultiphaseCloud(), cloudCopyPtr_(NULL), - constProps_(this->particleProperties(), this->solution().active()), + constProps_(this->particleProperties()), devolatilisationModel_(NULL), surfaceReactionModel_(NULL), dMassDevolatilisation_(0.0), diff --git a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C index e97b6cfc2f..69666fedde 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C @@ -153,7 +153,7 @@ Foam::ThermoCloud::ThermoCloud ), thermoCloud(), cloudCopyPtr_(NULL), - constProps_(this->particleProperties(), this->solution().active()), + constProps_(this->particleProperties()), thermo_(thermo), T_(thermo.thermo().T()), p_(thermo.thermo().p()), diff --git a/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcel.H b/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcel.H index 00cadb13ed..d6c1875158 100644 --- a/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcel.H +++ b/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcel.H @@ -74,6 +74,47 @@ class CollidingParcel : public ParcelType { +public: + + //- Class to hold thermo particle constant properties + class constantProperties + : + public ParcelType::constantProperties + { + + // Private data + + //- Young's modulus [N/m2] + demandDrivenEntry youngsModulus_; + + //- Poisson's ratio + demandDrivenEntry poissonsRatio_; + + + public: + + // Constructors + + //- Null constructor + constantProperties(); + + //- Copy constructor + constantProperties(const constantProperties& cp); + + //- Construct from dictionary + constantProperties(const dictionary& parentDict); + + + // Member functions + + //- Return const access to Young's Modulus + inline scalar youngsModulus() const; + + //- Return const access to Poisson's ratio + inline scalar poissonsRatio() const; + }; + + protected: // Protected data diff --git a/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcelI.H b/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcelI.H index cb8fb964fe..cc5940fcda 100644 --- a/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcelI.H +++ b/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcelI.H @@ -25,6 +25,40 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +template +inline Foam::CollidingParcel::constantProperties:: +constantProperties() +: + ParcelType::constantProperties(), + youngsModulus_(this->dict_, 0.0), + poissonsRatio_(this->dict_, 0.0) +{} + + +template +inline Foam::CollidingParcel::constantProperties::constantProperties +( + const constantProperties& cp +) +: + ParcelType::constantProperties(cp), + youngsModulus_(cp.youngsModulus_), + poissonsRatio_(cp.poissonsRatio_) +{} + + +template +inline Foam::CollidingParcel::constantProperties::constantProperties +( + const dictionary& parentDict +) +: + ParcelType::constantProperties(parentDict), + youngsModulus_(this->dict_, "youngsModulus"), + poissonsRatio_(this->dict_, "poissonsRatio") +{} + + template inline Foam::CollidingParcel::CollidingParcel ( @@ -83,7 +117,25 @@ inline Foam::CollidingParcel::CollidingParcel {} -// * * * * * * * CollidingParcel Member Functions * * * * * * * // +// * * * * * * * * * constantProperties Member Functions * * * * * * * * * * // + +template +inline Foam::scalar +Foam::CollidingParcel::constantProperties::youngsModulus() const +{ + return youngsModulus_.value(); +} + + +template +inline Foam::scalar +Foam::CollidingParcel::constantProperties::poissonsRatio() const +{ + return poissonsRatio_.value(); +} + + +// * * * * * * * * * * CollidingParcel Member Functions * * * * * * * * * * // template inline const Foam::vector& Foam::CollidingParcel::f() const diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H index 61ad57369e..63d1511845 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H @@ -48,6 +48,7 @@ SourceFiles #include "IOstream.H" #include "autoPtr.H" #include "interpolation.H" +#include "demandDrivenEntry.H" // #include "ParticleForceList.H" // TODO @@ -82,29 +83,30 @@ public: //- Class to hold kinematic particle constant properties class constantProperties { - // Private data + protected: + + // Protected data //- Constant properties dictionary const dictionary dict_; + + private: + + // Private data + //- Parcel type id - used for post-processing to flag the type // of parcels issued by this cloud - label parcelTypeId_; + demandDrivenEntry