diff --git a/src/functionObjects/field/externalCoupled/externalCoupledMixed/externalCoupledMixedFvPatchField.C b/src/functionObjects/field/externalCoupled/externalCoupledMixed/externalCoupledMixedFvPatchField.C index 84117274b0aad20a8053bc83b49f5e03503b3cc5..3f53770152e8cec89ba0a8f403d9d92edebced38 100644 --- a/src/functionObjects/field/externalCoupled/externalCoupledMixed/externalCoupledMixedFvPatchField.C +++ b/src/functionObjects/field/externalCoupled/externalCoupledMixed/externalCoupledMixedFvPatchField.C @@ -95,14 +95,6 @@ externalCoupledMixedFvPatchField {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -template<class Type> -Foam::externalCoupledMixedFvPatchField<Type>:: -~externalCoupledMixedFvPatchField() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> diff --git a/src/functionObjects/field/externalCoupled/externalCoupledMixed/externalCoupledMixedFvPatchField.H b/src/functionObjects/field/externalCoupled/externalCoupledMixed/externalCoupledMixedFvPatchField.H index 07539e1a311de1449cef3f033edebfa031a7e911..10b6d9b7eaadae0301771cd5cdfb8ecba2420c39 100644 --- a/src/functionObjects/field/externalCoupled/externalCoupledMixed/externalCoupledMixedFvPatchField.H +++ b/src/functionObjects/field/externalCoupled/externalCoupledMixed/externalCoupledMixedFvPatchField.H @@ -146,19 +146,19 @@ public: //- Destructor - virtual ~externalCoupledMixedFvPatchField(); + virtual ~externalCoupledMixedFvPatchField() = default; // Member functions //- Write header - virtual void writeHeader(Ostream&) const; + virtual void writeHeader(Ostream& os) const; //- Write data - virtual void writeData(Ostream&) const; + virtual void writeData(Ostream& os) const; //- Read data - virtual void readData(Istream&); + virtual void readData(Istream& is); }; diff --git a/src/functionObjects/field/externalCoupled/externalCoupledTemperatureMixed/externalCoupledTemperatureMixedFvPatchScalarField.C b/src/functionObjects/field/externalCoupled/externalCoupledTemperatureMixed/externalCoupledTemperatureMixedFvPatchScalarField.C index 8961922b4b7361182634a4795ff32655446f727f..efa4659cab279927e889f44ebb86108b0696c38a 100644 --- a/src/functionObjects/field/externalCoupled/externalCoupledTemperatureMixed/externalCoupledTemperatureMixedFvPatchScalarField.C +++ b/src/functionObjects/field/externalCoupled/externalCoupledTemperatureMixed/externalCoupledTemperatureMixedFvPatchScalarField.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,6 +28,21 @@ License #include "addToRunTimeSelectionTable.H" #include "fvPatchFieldMapper.H" #include "volFields.H" +#include "Enum.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +const Foam::Enum +< + Foam::externalCoupledTemperatureMixedFvPatchScalarField:: + outputTemperatureType +> +Foam::externalCoupledTemperatureMixedFvPatchScalarField::outputTemperatureNames +({ + { outputTemperatureType::FLUID, "fluid" }, + { outputTemperatureType::WALL, "wall" }, +}); + // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // @@ -36,7 +51,14 @@ void Foam::externalCoupledTemperatureMixedFvPatchScalarField::writeHeader Ostream& os ) const { - os << "# Values: magSf T qDot htc" << endl; + if (outputTemperature_ == outputTemperatureType::FLUID) + { + os << "# Values: area Tfluid qDot htc" << endl; + } + else + { + os << "# Values: area Twall qDot htc" << endl; + } } @@ -49,7 +71,8 @@ externalCoupledTemperatureMixedFvPatchScalarField const DimensionedField<scalar, volMesh>& iF ) : - externalCoupledMixedFvPatchField<scalar>(p, iF) + externalCoupledMixedFvPatchField<scalar>(p, iF), + outputTemperature_(outputTemperatureType::WALL) {} @@ -62,7 +85,8 @@ externalCoupledTemperatureMixedFvPatchScalarField const fvPatchFieldMapper& mapper ) : - externalCoupledMixedFvPatchField<scalar>(ptf, p, iF, mapper) + externalCoupledMixedFvPatchField<scalar>(ptf, p, iF, mapper), + outputTemperature_(ptf.outputTemperature_) {} @@ -75,8 +99,23 @@ externalCoupledTemperatureMixedFvPatchScalarField ) : //externalCoupledMixedFvPatchField<scalar>(p, iF, dict) - externalCoupledMixedFvPatchField<scalar>(p, iF) + externalCoupledMixedFvPatchField<scalar>(p, iF), + outputTemperature_(outputTemperatureType::WALL) { + if (dict.found("outputTemperature")) + { + outputTemperature_ = + outputTemperatureNames.get("outputTemperature", dict); + } + else + { + WarningInFunction + << "outputTemperature not specified " + << flatOutput(outputTemperatureNames) << nl + << "using 'wall' as compatibility default" << nl + << endl; + } + if (dict.found("refValue")) { // Initialise same way as mixed @@ -116,7 +155,8 @@ externalCoupledTemperatureMixedFvPatchScalarField const externalCoupledTemperatureMixedFvPatchScalarField& ecmpf ) : - externalCoupledMixedFvPatchField<scalar>(ecmpf) + externalCoupledMixedFvPatchField<scalar>(ecmpf), + outputTemperature_(ecmpf.outputTemperature_) {} @@ -127,14 +167,8 @@ externalCoupledTemperatureMixedFvPatchScalarField const DimensionedField<scalar, volMesh>& iF ) : - externalCoupledMixedFvPatchField<scalar>(ecmpf, iF) -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::externalCoupledTemperatureMixedFvPatchScalarField:: -~externalCoupledTemperatureMixedFvPatchScalarField() + externalCoupledMixedFvPatchField<scalar>(ecmpf, iF), + outputTemperature_(ecmpf.outputTemperature_) {} @@ -148,7 +182,7 @@ void Foam::externalCoupledTemperatureMixedFvPatchScalarField::writeData const label patchi = patch().index(); // Heat flux [W/m2] - scalarField qDot(this->patch().size(), 0.0); + scalarField qDot(this->patch().size(), Zero); typedef compressible::turbulenceModel cmpTurbModelType; @@ -189,10 +223,11 @@ void Foam::externalCoupledTemperatureMixedFvPatchScalarField::writeData << "thermo model to be available" << exit(FatalError); } - // Patch temperature [K] + + // Patch (wall) temperature [K] const scalarField& Tp(*this); - // Near wall cell temperature [K] + // Near wall cell (fluid) temperature [K] const scalarField Tc(patchInternalField()); // Heat transfer coefficient [W/m2/K] @@ -200,13 +235,19 @@ void Foam::externalCoupledTemperatureMixedFvPatchScalarField::writeData const Field<scalar>& magSf(this->patch().magSf()); + const UList<scalar>& Tout = + ( + outputTemperature_ == outputTemperatureType::FLUID + ? Tc + : Tp + ); + forAll(patch(), facei) { os << magSf[facei] << token::SPACE - << Tp[facei] << token::SPACE + << Tout[facei] << token::SPACE << qDot[facei] << token::SPACE - << htc[facei] << token::SPACE - << nl; + << htc[facei] << nl; } } @@ -235,6 +276,20 @@ void Foam::externalCoupledTemperatureMixedFvPatchScalarField::readData } +void Foam::externalCoupledTemperatureMixedFvPatchScalarField::write +( + Ostream& os +) const +{ + externalCoupledMixedFvPatchField::write(os); + os.writeEntry + ( + "outputTemperature", + outputTemperatureNames[outputTemperature_] + ); +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam diff --git a/src/functionObjects/field/externalCoupled/externalCoupledTemperatureMixed/externalCoupledTemperatureMixedFvPatchScalarField.H b/src/functionObjects/field/externalCoupled/externalCoupledTemperatureMixed/externalCoupledTemperatureMixedFvPatchScalarField.H index 340407905712bfa8ce4f4219c43f5a6f8f8631da..3e2475e60eb5120c159e04e0ae174523fc306616 100644 --- a/src/functionObjects/field/externalCoupled/externalCoupledTemperatureMixed/externalCoupledTemperatureMixedFvPatchScalarField.H +++ b/src/functionObjects/field/externalCoupled/externalCoupledTemperatureMixed/externalCoupledTemperatureMixedFvPatchScalarField.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -87,6 +87,14 @@ Description To be used in combination with the functionObjects::externalCoupled functionObject. +Usage + \table + Property | Description | Required | Default + outputTemperature | The output temperature: fluid/wall | yes | + \endtable + +Note the + SeeAlso externalCoupledFunctionObject mixedFvPatchField @@ -101,6 +109,7 @@ SourceFiles #define externalCoupledTemperatureMixedFvPatchScalarField_H #include "externalCoupledMixedFvPatchFields.H" +#include "Enum.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -115,6 +124,24 @@ class externalCoupledTemperatureMixedFvPatchScalarField : public externalCoupledMixedFvPatchField<scalar> { + // Data Types + + //- Location for the ouput temperature + enum outputTemperatureType + { + FLUID, //!< Use fluid (cell) temperature + WALL //!< Use wall (patch) temperature + }; + + //- Names for outputTemperatureType + static const Enum<outputTemperatureType> outputTemperatureNames; + + + // Private Data + + //- Location for the ouput temperature + enum outputTemperatureType outputTemperature_; + public: @@ -189,19 +216,22 @@ public: //- Destructor - virtual ~externalCoupledTemperatureMixedFvPatchScalarField(); + virtual ~externalCoupledTemperatureMixedFvPatchScalarField() = default; // Member functions //- Write header - virtual void writeHeader(Ostream&) const; + virtual void writeHeader(Ostream& os) const; //- Write data - virtual void writeData(Ostream&) const; + virtual void writeData(Ostream& os) const; //- Read data - virtual void readData(Istream&); + virtual void readData(Istream& is); + + //- Write + virtual void write(Ostream& os) const; }; diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/0.orig/T b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/0.orig/T new file mode 100644 index 0000000000000000000000000000000000000000..64f0c2c2930f1ca232cbbbc5a36e70fbe0788d78 --- /dev/null +++ b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/0.orig/T @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1806 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object T; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform 300; + +boundaryField +{ + inlet + { + type fixedValue; + value $internalField; + } + + outlet + { + type inletOutlet; + inletValue $internalField; + value $internalField; + } + + inletWalls + { + type mixed; + refValue uniform 250; + refGradient uniform 0; + valueFraction uniform 1; + value uniform 250; + } + + "(?i).*walls" + { + type zeroGradient; + } +} + +// ************************************************************************* // diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/0.orig/U b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/0.orig/U new file mode 100644 index 0000000000000000000000000000000000000000..c8c7d69afb938631224a0a8c149bf16b50e3eec4 --- /dev/null +++ b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/0.orig/U @@ -0,0 +1,42 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1806 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform (0 0 0); + +boundaryField +{ + inlet + { + type flowRateInletVelocity; + massFlowRate constant 0.01; + rhoInlet 1000; // Guess for rho + } + + outlet + { + type pressureInletOutletVelocity; + value $internalField; + } + + "(?i).*walls" + { + type noSlip; + } +} + +// ************************************************************************* // diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/0.orig/alphat b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/0.orig/alphat new file mode 100644 index 0000000000000000000000000000000000000000..1be1d973130e6410d00af9e838c250758e403ac5 --- /dev/null +++ b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/0.orig/alphat @@ -0,0 +1,43 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1806 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object alphat; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -1 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + inlet + { + type calculated; + value $internalField; + } + + outlet + { + type calculated; + value $internalField; + } + + "(?i).*walls" + { + type compressible::alphatWallFunction; + Prt 0.85; + value $internalField; + } +} + +// ************************************************************************* // diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/0.orig/epsilon b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/0.orig/epsilon new file mode 100644 index 0000000000000000000000000000000000000000..1ba38d1417c853128047fc978c1ad2a0ea3f2044 --- /dev/null +++ b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/0.orig/epsilon @@ -0,0 +1,47 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1806 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object epsilon; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -3 0 0 0 0]; + +internalField uniform 200; + +boundaryField +{ + inlet + { + type turbulentMixingLengthDissipationRateInlet; + mixingLength 0.005; + value $internalField; + } + + outlet + { + type inletOutlet; + inletValue $internalField; + value $internalField; + } + + "(?i).*walls" + { + type epsilonWallFunction; + Cmu 0.09; + kappa 0.41; + E 9.8; + value $internalField; + } +} + +// ************************************************************************* // diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/0.orig/k b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/0.orig/k new file mode 100644 index 0000000000000000000000000000000000000000..8e17c0601eae33c49161998680d884c05a967a12 --- /dev/null +++ b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/0.orig/k @@ -0,0 +1,44 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1806 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object k; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -2 0 0 0 0]; + +internalField uniform 1; + +boundaryField +{ + inlet + { + type turbulentIntensityKineticEnergyInlet; + intensity 0.05; + value $internalField; + } + + outlet + { + type inletOutlet; + inletValue $internalField; + value $internalField; + } + + "(?i).*walls" + { + type kqRWallFunction; + value $internalField; + } +} + +// ************************************************************************* // diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/0.orig/nut b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/0.orig/nut new file mode 100644 index 0000000000000000000000000000000000000000..06e37b057004bb1d771e265bd691311a558b69da --- /dev/null +++ b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/0.orig/nut @@ -0,0 +1,45 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1806 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object nut; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -1 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + inlet + { + type calculated; + value $internalField; + } + + outlet + { + type calculated; + value $internalField; + } + + "(?i).*walls" + { + type nutkWallFunction; + Cmu 0.09; + kappa 0.41; + E 9.8; + value $internalField; + } +} + +// ************************************************************************* // diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/0.orig/p b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/0.orig/p new file mode 100644 index 0000000000000000000000000000000000000000..22879d0e9a4c300435e4e9a22823fcb80f8cd764 --- /dev/null +++ b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/0.orig/p @@ -0,0 +1,40 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1806 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object p; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform 1e5; + +boundaryField +{ + inlet + { + type zeroGradient; + } + + outlet + { + type fixedValue; + value $internalField; + } + + "(?i).*walls" + { + type zeroGradient; + } +} + +// ************************************************************************* // diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/Allclean b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/Allclean new file mode 100755 index 0000000000000000000000000000000000000000..1c48979f034839911f17c2c1bb8428e9e83d8c92 --- /dev/null +++ b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/Allclean @@ -0,0 +1,12 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions + +cleanCase0 + +rm externalCoupled.control 2> /dev/null + +rm -rf comms +### rm -rf VTK + +#------------------------------------------------------------------------------ diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/Allrun b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/Allrun new file mode 100755 index 0000000000000000000000000000000000000000..d726140ec79c940108e59440e2eeef0a027166c5 --- /dev/null +++ b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/Allrun @@ -0,0 +1,81 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions + +./Allrun.pre + +unset coupling parallel testCreate + +isTrue -dict controls -entry coupling && coupling=true +isTrue -dict controls -entry parallel && parallel=true +# isTrue -dict controls -entry testCreate && testCreate=true + +# Remove lock file on interrupt +trap '\rm -f comms/OpenFOAM.lock 2>/dev/null' INT + +# Decompose +if [ "$parallel" = true ] +then + runApplication decomposePar + + # ## Can verify parallel operation of createExternalCoupledPatchGeometry + if [ "$coupling" = true ] && [ "$testCreate" = true ] + then + \rm -f log.createExternalCoupledPatchGeometry + runParallel createExternalCoupledPatchGeometry \ + coupleGroup \ + -commsDir $PWD/comms + fi +fi + + +if [ "$coupling" = true ] +then + + echo "Running with external coupling" + + # Controls +cat << CONTROLS >| externalCoupled.control +//- Overrides for externalCoupled +enabled true; +CONTROLS + + # Run OpenFOAM, with externalCoupled enabled + if [ "$parallel" = true ] + then + runParallel $(getApplication) & + else + runApplication $(getApplication) & + fi + + # Simulated external solver + runApplication ./externalSolver + +else + + echo "Running without external coupling" + + # Controls +cat << CONTROLS >| externalCoupled.control +//- Overrides for externalCoupled +enabled false; +CONTROLS + + # Run OpenFOAM, with externalCoupled disabled + if [ "$parallel" = true ] + then + runParallel $(getApplication) + else + runApplication $(getApplication) + fi + +fi + + +# Reconstruct +if [ "$parallel" = true ] +then + runApplication reconstructPar +fi + +#------------------------------------------------------------------------------ diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/Allrun.pre b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/Allrun.pre new file mode 100755 index 0000000000000000000000000000000000000000..884b4cc6d5ca4f168186ed9ba24847c95eb273d2 --- /dev/null +++ b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/Allrun.pre @@ -0,0 +1,23 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions + +runApplication blockMesh + +# Restore initial fields +restore0Dir + +# Controls +unset coupling testCreate +isTrue -dict controls -entry coupling && coupling=true +isTrue -dict controls -entry testCreate && testCreate=true + +if [ "$coupling" = true ] +then + runApplication changeDictionary + + # Create coupling geometry + runApplication createExternalCoupledPatchGeometry coupleGroup +fi + +#------------------------------------------------------------------------------ diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/constant/thermophysicalProperties b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/constant/thermophysicalProperties new file mode 100644 index 0000000000000000000000000000000000000000..5241bc27606d1f8e124e61ada0d4b9110a0f9331 --- /dev/null +++ b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/constant/thermophysicalProperties @@ -0,0 +1,30 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1806 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object thermophysicalProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +thermoType +{ + type heRhoThermo; + mixture pureMixture; + properties liquid; + energy sensibleInternalEnergy; +} + +mixture +{ + H2O; +} + +// ************************************************************************* // diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/constant/turbulenceProperties b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/constant/turbulenceProperties new file mode 100644 index 0000000000000000000000000000000000000000..853d87b0a8389759e0a807cd09d1dbc1b640f5c9 --- /dev/null +++ b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/constant/turbulenceProperties @@ -0,0 +1,28 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1806 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object turbulenceProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +simulationType RAS; + +RAS +{ + RASModel kEpsilon; + + turbulence on; + + printCoeffs on; +} + +// ************************************************************************* // diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/controls b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/controls new file mode 100644 index 0000000000000000000000000000000000000000..2cfe7cb380d8d7c9a078974fdda06b1087fe7bf8 --- /dev/null +++ b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/controls @@ -0,0 +1,25 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1806 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object controls; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Tutorial controls + +coupling true; + +parallel true; + +testCreate true; + +// ************************************************************************* // diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/externalSolver b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/externalSolver new file mode 100755 index 0000000000000000000000000000000000000000..2b64cfef4a0f19c25b2b7080aadf952ebb42154c --- /dev/null +++ b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/externalSolver @@ -0,0 +1,214 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions + +# Dummy external solver to communicate with OpenFOAM via externalCoupled +# functionObject +# +# Functionality is hard-coded for particular test case +# - it simply return a patch temperature of 500K. +# Since the default temperature on the patch is 250K, this can be used +# to readily detect if the external values are being used. +# +# ----------------------------------------------------------------------------- + +action="$1" + +# Check for unassigned variables +set -u + +commsDir="comms" +patchDir="coupleGroup" +fieldName="T" + +lockFile="${commsDir}/OpenFOAM.lock" +dataFile="${commsDir}/${patchDir}/${fieldName}" +waitSec=5 +timeOut=100 +nSteps=1000 # maximum number of time steps. Note: should be more than + # number of iterations on the OpenFOAM side + +stopAt=600 # external solver signals OpenFOAM to stop + +refValue1=500 +refGrad=0 +valueFraction=1 + +# Remove any old junk +\rm -f $lockFile 2>/dev/null + +log() +{ + echo "External: $@" +} + + +# Create lock file to pass control to OpenFOAM +useMaster() +{ + log "creating lock file '${lockFile}'" + echo "status=openfoam" >| ${lockFile} +} + +# Lock file with special content to stop OpenFOAM master +stopMasterNow() +{ + log "writeNow terminate via lock file '${lockFile}'" + echo "action=writeNow" >| ${lockFile} +} + +# Patch size (inletWalls) +nFaces1=$(getNumberOfPatchFaces inletWalls) || exit $? + + +init() +{ + log "init - creating ${dataFile}.in" + cat /dev/null >| "${dataFile}.in" + + # Local face counter, Local refValue + local nFaces refValue + + # Patch inletWalls + + nFaces="$nFaces1" + refValue="$refValue1" + + log "init - adding $nFaces data elements with refValue $refValue" + + while [ "$nFaces" -gt 0 ] + do + nFaces=$((nFaces - 1)) + # Hard-coded output for patch + echo "$refValue $refGrad $valueFraction" + done >> "${dataFile}.in" + + + # Verify line count? + # log "init ($(wc -l ${dataFile}.in))" + + # Give time for T.in file to flush + sleep 1 + + useMaster +} + + +# Calculate average temperature +# Extract from: +# +# ---- +# # Values: area Twall qDot htc +# 6.25e-06 500 3.53296e+06 20884 +# ---- +avgTemperature() +{ + local file="$1" + local tempType + local avg + + tempType=$(sed -ne '1{s/^.* \(T[^ ]*\).*$/\1/p; q}' "$file") + avg=$(awk 'BEGIN {area=0; sum=0;}END{print sum/area}{if (/^[0-9]/) {area += $1; sum += ($1 * $2);}}' "$file") + + echo "${file##*/} : $tempType avg=$avg" +} + + +loop() +{ + echo "Executing dummy external solver" + + local totalWait=0 + local step=0 + local nFaces refValue + + while [ $step -lt $nSteps ] + do + if [ -f $lockFile ] + then + if grep -q "status=done" ${lockFile} + then + log "found lock file '${lockFile}' with 'status=done' - finished" + break + elif [ -s $lockFile ] + then + log "found lock file '${lockFile}' containing '$(< $lockFile)' - waiting" + else + log "found lock file '${lockFile}' - waiting" + fi + + totalWait=$(expr $totalWait + $waitSec) + if [ $totalWait -gt $timeOut ] + then + log "timeout" + break + else + sleep $waitSec + fi + else + totalWait=0 + step=$(expr $step + 1) + log "step $step" + log "lock not present - taking control" + + log "sleeping for $waitSec secs to simulate external process" + sleep $waitSec + + log "updating ${dataFile}.in from ${dataFile}.out" + + if [ -f "${dataFile}.out" ] + then + + avgTemperature "${dataFile}.out" + + cat /dev/null >| "${dataFile}.in" + + # Hard-coded output for patch + nFaces="$nFaces1" + refValue="$refValue1" + + while [ "$nFaces" -gt 0 ] + do + nFaces=$((nFaces - 1)) + echo "$refValue $refGrad $valueFraction" + done >> "${dataFile}.in" + + else + log "Warning: no such file ${dataFile}.out" + fi + + if [ "${stopAt:-0}" -eq $step ] + then + stopMasterNow + else + useMaster + fi + fi + done +} + + +# Create the comms directory +mkdir -p ${commsDir}/${patchDir} + +case "$action" in + -once | once) + echo "One-shot triggering" + init + ;; + + *) + # Tutorial case uses 'initByExternal' option, + # so we must provide initial values + init + + loop + + log "done" + + # Cleanup. Remove the lock file + \rm -f $lockFile 2>/dev/null + ;; +esac + +#------------------------------------------------------------------------------ diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/system/blockMeshDict b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/system/blockMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..a5b8948b7daeff4a1ccbeb0a7d979f39a48aea66 --- /dev/null +++ b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/system/blockMeshDict @@ -0,0 +1,119 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1806 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +scale 0.001; + +vertices +( + // front-plane: z = +25mm + // inlet region + ( -50 25 25) // pt 0 + ( 0 25 25) // pt 1 + ( -50 75 25) // pt 2 + ( 0 75 25) // pt 3 + // outlet region + ( -500 -75 25) // pt 4 + ( 0 -75 25) // pt 5 + ( -500 -25 25) // pt 6 + ( 0 -25 25) // pt 7 + // bend mid-points + ( 25 0 25) // pt 8 + ( 75 0 25) // pt 9 + // back-plane: z = -25mm + // inlet region + ( -50 25 -25) // pt 0 + 10 + ( 0 25 -25) // pt 1 + 10 + ( -50 75 -25) // pt 2 + 10 + ( 0 75 -25) // pt 3 + 10 + // outlet region + ( -500 -75 -25) // pt 4 + 10 + ( 0 -75 -25) // pt 5 + 10 + ( -500 -25 -25) // pt 7 + 10 + ( 0 -25 -25) // pt 8 + 10 + // bend mid-points + ( 25 0 -25) // pt 8 + 10 + ( 75 0 -25) // pt 9 + 10 +); + +blocks +( + hex (0 1 11 10 2 3 13 12) inlet ( 20 20 20) simpleGrading (1 1 1) + hex (4 5 15 14 6 7 17 16) outlet (200 20 20) simpleGrading (1 1 1) + + hex (1 8 18 11 3 9 19 13) bend1 ( 30 20 20) simpleGrading (1 1 1) + hex (5 9 19 15 7 8 18 17) bend2 ( 30 20 20) simpleGrading (1 1 1) +); + +edges +( + // block 2 + arc 1 8 ( 17.678 17.678 25) + arc 11 18 ( 17.678 17.678 -25) + arc 3 9 ( 53.033 53.033 25) + arc 13 19 ( 53.033 53.033 -25) + // block 3 + arc 7 8 ( 17.678 -17.678 25) + arc 17 18 ( 17.678 -17.678 -25) + arc 5 9 ( 53.033 -53.033 25) + arc 15 19 ( 53.033 -53.033 -25) +); + +boundary +( + inlet + { + type patch; + faces + ( + (0 2 12 10) + ); + } + outlet + { + type patch; + faces + ( + (4 6 16 14) + ); + } + inletWalls + { + type wall; + faces + ( + // block0 + ( 0 1 3 2 ) + ( 11 10 12 13 ) + ( 0 10 11 1 ) + ( 2 3 13 12 ) + ); + } +); + +mergePatchPairs +( +); + + +// The defaultFaces == outside "walls" +defaultPatch +{ + name walls; + type wall; +} + + +// ************************************************************************* // diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/system/changeDictionaryDict b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/system/changeDictionaryDict new file mode 100644 index 0000000000000000000000000000000000000000..36b48ede54b4b1d9e56da6dae305e486ec59b92a --- /dev/null +++ b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/system/changeDictionaryDict @@ -0,0 +1,38 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1806 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object changeDictionaryDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +boundary +{ + inletWalls + { + inGroups (coupleGroup wall); + } +} + +T +{ + boundaryField + { + inletWalls + { + type externalCoupledTemperature; + // outputTemperature fluid; // fluid|wall + } + } +} + + +// ************************************************************************* // diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/system/controlDict b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/system/controlDict new file mode 100644 index 0000000000000000000000000000000000000000..65be40e0617ece0b804c8e1d7237e4d1b63443df --- /dev/null +++ b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/system/controlDict @@ -0,0 +1,65 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1806 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Library defines new boundary conditions +libs ("libOpenFOAM.so" "libfieldFunctionObjects.so"); + +application rhoPimpleFoam; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 0.5; + +deltaT 2e-3; + +writeControl timeStep; + +writeInterval 10; + +purgeWrite 0; + +writeFormat ascii; + +writePrecision 6; + +writeCompression off; + +timeFormat general; + +timePrecision 6; + +graphFormat raw; + +runTimeModifiable true; + +functions +{ + #include "externalCoupled" + + minMax + { + type fieldMinMax; + libs ("libfieldFunctionObjects.so"); + fields (T); + } +} + + +// ************************************************************************* // diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/system/decomposeParDict b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/system/decomposeParDict new file mode 100644 index 0000000000000000000000000000000000000000..66fba51c00f7ecb9d435d379d19c71fae63e91b7 --- /dev/null +++ b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/system/decomposeParDict @@ -0,0 +1,34 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1806 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object decomposeParDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 8; + +method hierarchical; + +simpleCoeffs +{ + n (8 1 1); + delta 0.001; +} + +hierarchicalCoeffs +{ + n (4 2 1); + delta 0.001; + order xyz; +} + +// ************************************************************************* // diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/system/externalCoupled b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/system/externalCoupled new file mode 100644 index 0000000000000000000000000000000000000000..87358f24dbfcd758213ca09871c9b479a3e759aa --- /dev/null +++ b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/system/externalCoupled @@ -0,0 +1,40 @@ +// -*- C++ -*- + +// Control for external coupled simulation +externalCoupled +{ + type externalCoupled; + libs ("libfieldFunctionObjects.so"); + log true; + + executeControl timeStep; + + // Directory to use for communication + commsDir "<case>/comms"; + + // Does external process start first + initByExternal true; + + regions + { + // Region name (wildcards allowed) + ".*" + { + // Patch or patchGroup + coupleGroup + { + // Fields to output in commsDir + writeFields (T); + + // Fields to read from commsDir + readFields (T); + } + } + } + + // Enabled or not? + #sinclude "<case>/externalCoupled.control" +} + + +// ************************************************************************* // diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/system/fvSchemes b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/system/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..b4e6447827cacc1b9d5b96abb647fa0111ae910d --- /dev/null +++ b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/system/fvSchemes @@ -0,0 +1,58 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1806 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; + + limited cellLimited Gauss linear 1; +} + +divSchemes +{ + default none; + + div(phi,U) Gauss linearUpwind limited; + div(phi,e) Gauss linearUpwind limited; + div(phi,epsilon) Gauss linearUpwind limited; + div(phi,k) Gauss linearUpwind limited; + div(phi,K) Gauss linearUpwind limited; + div(phiv,p) Gauss linearUpwind limited; + + div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default corrected; +} + +// ************************************************************************* // diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/system/fvSolution b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/system/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..5d178fd69453caae6b59bbb397f78c13651bd4a1 --- /dev/null +++ b/tutorials/compressible/rhoPimpleFoam/RAS/externalCoupledSquareBendLiq/system/fvSolution @@ -0,0 +1,62 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1806 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + "rho.*" + { + solver nthn; + } + + "p.*" + { + solver GAMG; + smoother GaussSeidel; + + tolerance 1e-7; + relTol 0; + } + + "(U|e|k|epsilon).*" + { + solver PBiCGStab; + preconditioner DILU; + + tolerance 1e-7; + relTol 0; + } +} + +PIMPLE +{ + nCorrectors 3; + nNonOrthogonalCorrectors 0; + pMinFactor 0.1; + pMaxFactor 1.5; + + transonic no; + consistent no; +} + +relaxationFactors +{ + equations + { + ".*" 1; + } +} + +// ************************************************************************* //