diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/CrankNicolsonDdtScheme/CrankNicolsonDdtScheme.C b/src/finiteVolume/finiteVolume/ddtSchemes/CrankNicolsonDdtScheme/CrankNicolsonDdtScheme.C index 341cf88b09d72a1bd25d90e9445c6f88e3cd5856..bfbc7cf9deee64658e28dbdd522150c2cfba9814 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/CrankNicolsonDdtScheme/CrankNicolsonDdtScheme.C +++ b/src/finiteVolume/finiteVolume/ddtSchemes/CrankNicolsonDdtScheme/CrankNicolsonDdtScheme.C @@ -27,6 +27,7 @@ License #include "surfaceInterpolate.H" #include "fvcDiv.H" #include "fvMatrices.H" +#include "Constant.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -277,7 +278,70 @@ const FieldField<fvPatchField, Type>& ff } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class Type> +CrankNicolsonDdtScheme<Type>::CrankNicolsonDdtScheme(const fvMesh& mesh) +: + ddtScheme<Type>(mesh), + ocCoeff_(new Function1Types::Constant<scalar>("ocCoeff", 1)) +{ + // Ensure the old-old-time cell volumes are available + // for moving meshes + if (mesh.moving()) + { + mesh.V00(); + } +} + + +template<class Type> +CrankNicolsonDdtScheme<Type>::CrankNicolsonDdtScheme +( + const fvMesh& mesh, + Istream& is +) +: + ddtScheme<Type>(mesh, is) +{ + token firstToken(is); + + if (firstToken.isNumber()) + { + const scalar ocCoeff = firstToken.scalarToken(); + if (ocCoeff < 0 || ocCoeff > 1) + { + FatalIOErrorInFunction + ( + is + ) << "Off-centreing coefficient = " << ocCoeff + << " should be >= 0 and <= 1" + << exit(FatalIOError); + } + + ocCoeff_ = new Function1Types::Constant<scalar> + ( + "ocCoeff", + ocCoeff + ); + } + else + { + is.putBack(firstToken); + dictionary dict(is); + ocCoeff_ = Function1<scalar>::New("ocCoeff", dict); + } + + // Ensure the old-old-time cell volumes are available + // for moving meshes + if (mesh.moving()) + { + mesh.V00(); + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> tmp<GeometricField<Type, fvPatchField, volMesh>> diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/CrankNicolsonDdtScheme/CrankNicolsonDdtScheme.H b/src/finiteVolume/finiteVolume/ddtSchemes/CrankNicolsonDdtScheme/CrankNicolsonDdtScheme.H index 4b002fd45b3d5ef5311d247d6100908d5b1a6b22..fb3380138ab2c58fb37cef983c4a5421040bffe6 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/CrankNicolsonDdtScheme/CrankNicolsonDdtScheme.H +++ b/src/finiteVolume/finiteVolume/ddtSchemes/CrankNicolsonDdtScheme/CrankNicolsonDdtScheme.H @@ -91,7 +91,7 @@ SourceFiles #define CrankNicolsonDdtScheme_H #include "ddtScheme.H" -#include "Constant.H" +#include "Function1.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -153,7 +153,8 @@ class CrankNicolsonDdtScheme }; - //- Off-centering coefficient, 1 -> CN, less than one blends with EI + //- Off-centering coefficient function + // 1 -> CN, less than one blends with EI autoPtr<Function1<scalar>> ocCoeff_; @@ -210,59 +211,10 @@ public: // Constructors //- Construct from mesh - CrankNicolsonDdtScheme(const fvMesh& mesh) - : - ddtScheme<Type>(mesh), - ocCoeff_(new Function1Types::Constant<scalar>("ocCoeff", 1)) - { - // Ensure the old-old-time cell volumes are available - // for moving meshes - if (mesh.moving()) - { - mesh.V00(); - } - } + CrankNicolsonDdtScheme(const fvMesh& mesh); //- Construct from mesh and Istream - CrankNicolsonDdtScheme(const fvMesh& mesh, Istream& is) - : - ddtScheme<Type>(mesh, is) - { - token firstToken(is); - - if (firstToken.isNumber()) - { - const scalar ocCoeff = firstToken.scalarToken(); - if (ocCoeff < 0 || ocCoeff > 1) - { - FatalIOErrorInFunction - ( - is - ) << "Off-centreing coefficient = " << ocCoeff - << " should be >= 0 and <= 1" - << exit(FatalIOError); - } - - ocCoeff_ = new Function1Types::Constant<scalar> - ( - "ocCoeff", - ocCoeff - ); - } - else - { - is.putBack(firstToken); - dictionary dict(is); - ocCoeff_ = Function1<scalar>::New("ocCoeff", dict); - } - - // Ensure the old-old-time cell volumes are available - // for moving meshes - if (mesh.moving()) - { - mesh.V00(); - } - } + CrankNicolsonDdtScheme(const fvMesh& mesh, Istream& is); // Member Functions @@ -273,7 +225,7 @@ public: return fv::ddtScheme<Type>::mesh(); } - //- Return the off-centreing coefficient + //- Return the current off-centreing coefficient scalar ocCoeff() const { return ocCoeff_->value(mesh().time().value());