diff --git a/applications/solvers/acoustic/acousticFoam/Make/files b/applications/solvers/acoustic/acousticFoam/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..897caa0f26ed3000526aaf95beda9cb98f49a60c --- /dev/null +++ b/applications/solvers/acoustic/acousticFoam/Make/files @@ -0,0 +1,3 @@ +acousticFoam.C + +EXE = $(FOAM_APPBIN)/acousticFoam diff --git a/applications/solvers/acoustic/acousticFoam/Make/options b/applications/solvers/acoustic/acousticFoam/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..c12930f5c0acd64ce13f06758abdd6f8c84f28b2 --- /dev/null +++ b/applications/solvers/acoustic/acousticFoam/Make/options @@ -0,0 +1,14 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/fvOption/lnInclude \ + -I$(LIB_SRC)/regionFaModels/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/sampling/lnInclude \ + -I$(LIB_SRC)/transportModels/compressible/lnInclude + +EXE_LIBS = \ + -lfiniteVolume \ + -lfvOptions \ + -lmeshTools \ + -lsampling \ + -lregionFaModels diff --git a/applications/solvers/acoustic/acousticFoam/acousticFoam.C b/applications/solvers/acoustic/acousticFoam/acousticFoam.C new file mode 100644 index 0000000000000000000000000000000000000000..ab12a827f2ca7ffb03714df1cc1721e78c9b929b --- /dev/null +++ b/applications/solvers/acoustic/acousticFoam/acousticFoam.C @@ -0,0 +1,99 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +Application + acousticFoam + +Group + grpAcousticSolvers + +Description + Acoustic solver solving the acoustic pressure wave equation. + + \f[ + \ddt2{pa} - c^2 \laplacian{pa} = 0 + \f] + + where + \vartable + c | Sound speed + pa | Acoustic pressure + \endvartable + +SourceFiles + acousticFoam.C + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "fvOptions.H" +#include "pimpleControl.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + argList::addNote + ( + "Acoustic solver solving the acoustic pressure wave equation." + ); + + #include "postProcess.H" + + #include "addCheckCaseOptions.H" + #include "setRootCaseLists.H" + #include "createTime.H" + #include "createMesh.H" + #include "createControl.H" + #include "createRegionControls.H" + + #include "readTransportProperties.H" + #include "createFields.H" + + Info<< "\nStarting time loop\n" << endl; + + while (runTime.run()) + { + ++runTime; + + Info<< "Time = " << runTime.timeName() << nl << endl; + + while (pimple.correct()) + { + #include "paEqn.H" + } + + runTime.write(); + + runTime.printExecutionTime(Info); + } + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/solvers/acoustic/acousticFoam/createFields.H b/applications/solvers/acoustic/acousticFoam/createFields.H new file mode 100644 index 0000000000000000000000000000000000000000..3a1eaa069fe54953c3f423138e2c43148cd66b27 --- /dev/null +++ b/applications/solvers/acoustic/acousticFoam/createFields.H @@ -0,0 +1,15 @@ + +Info << "\nReading pa" << endl; + +volScalarField pa +( + IOobject + ( + "pa", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh +); diff --git a/applications/solvers/acoustic/acousticFoam/createRegionControls.H b/applications/solvers/acoustic/acousticFoam/createRegionControls.H new file mode 100644 index 0000000000000000000000000000000000000000..a1888eead75bcc65858f77448160b4342cd417a4 --- /dev/null +++ b/applications/solvers/acoustic/acousticFoam/createRegionControls.H @@ -0,0 +1,8 @@ +fvSolution solutionDict(runTime); + +const dictionary& pimpleDict = solutionDict.subDict("PIMPLE"); + +bool solvePrimaryRegion +( + pimpleDict.getOrDefault("solvePrimaryRegion", true) +); diff --git a/applications/solvers/acoustic/acousticFoam/paEqn.H b/applications/solvers/acoustic/acousticFoam/paEqn.H new file mode 100644 index 0000000000000000000000000000000000000000..d80eb80929a9364205e4642906a3518e47df712d --- /dev/null +++ b/applications/solvers/acoustic/acousticFoam/paEqn.H @@ -0,0 +1,15 @@ + +fvScalarMatrix paEqn +( + fvm::d2dt2(pa) - sqr(c0)*fvc::laplacian(pa) +); + +if (solvePrimaryRegion) +{ + paEqn.relax(); + paEqn.solve(); +} +else +{ + pa.correctBoundaryConditions(); +} diff --git a/applications/solvers/acoustic/acousticFoam/readTransportProperties.H b/applications/solvers/acoustic/acousticFoam/readTransportProperties.H new file mode 100644 index 0000000000000000000000000000000000000000..5ff526af53ffa722ddd738ce3078c31c8e1db33b --- /dev/null +++ b/applications/solvers/acoustic/acousticFoam/readTransportProperties.H @@ -0,0 +1,23 @@ +Info<< "\nReading transportProperties" << endl; + +IOdictionary transportProperties +( + IOobject + ( + "transportProperties", + runTime.constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) +); + +dimensionedScalar c0("c0", dimVelocity, transportProperties); + +dimensionedScalar rho("rho", dimDensity, transportProperties); + +scalar MaxCo = + max(mesh.surfaceInterpolation::deltaCoeffs()*c0).value() + *runTime.deltaT().value(); + +Info<< "Max acoustic Courant Number = " << MaxCo << endl; diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/Make/options b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/Make/options index 14bbcc2cee2fb54dc58a4a5bc0afe646aa098b5b..241a4ff1a640043ff0d49ee17e6327c60bc835de 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/Make/options +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/Make/options @@ -14,7 +14,9 @@ EXE_INC = \ -I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude \ -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \ -I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \ - -I$(LIB_SRC)/regionModels/regionModel/lnInclude + -I$(LIB_SRC)/sampling/lnInclude \ + -I$(LIB_SRC)/regionModels/regionModel/lnInclude \ + -I$(LIB_SRC)/regionFaModels/lnInclude EXE_LIBS = \ -lfiniteVolume \ @@ -28,4 +30,8 @@ EXE_LIBS = \ -lturbulenceModels \ -lcompressibleTurbulenceModels \ -lradiationModels \ - -lregionModels + -lfvOptions \ + -lfaOptions \ + -lregionModels \ + -lsampling \ + -lregionFaModels diff --git a/src/Allwmake b/src/Allwmake index 15a09cdc0a5b4a66af812d90c780f8fe1ace96b6..a2109cae24d40c5231193c55bd517a433e84942f 100755 --- a/src/Allwmake +++ b/src/Allwmake @@ -49,6 +49,7 @@ wmake $targetType fileFormats wmake $targetType surfMesh wmake $targetType meshTools +wmake $targetType finiteArea wmake $targetType finiteVolume wmake $targetType mesh/blockMesh @@ -85,7 +86,9 @@ regionModels/Allwmake $targetType $* lagrangian/Allwmake $targetType $* wmake $targetType fvOptions +wmake $targetType faOptions wmake $targetType fvMotionSolver +wmake $targetType regionFaModels wmake $targetType overset @@ -97,7 +100,6 @@ wmake $targetType waveModels wmake $targetType engine -wmake $targetType finiteArea wmake $targetType genericPatchFields conversion/Allwmake $targetType $* diff --git a/src/OpenFOAM/algorithms/subCycle/subCycle.H b/src/OpenFOAM/algorithms/subCycle/subCycle.H index 6de416d94b0ca38eea4ce3780ee01a3d871d0364..5024c7d8d6d040963362a0cd66a1dedd96b4d94f 100644 --- a/src/OpenFOAM/algorithms/subCycle/subCycle.H +++ b/src/OpenFOAM/algorithms/subCycle/subCycle.H @@ -59,7 +59,12 @@ class subCycleField GeometricField& gf0_; //- Copy of the "real" old-time value of the field - GeometricField gf_0_; + tmp<GeometricField> gf_0_; + + GeometricField& gf00_; + + //- Copy of the "real" old-old-time value of the field + tmp<GeometricField> gf_00_; public: @@ -71,19 +76,28 @@ public: : gf_(gf), gf0_(gf.oldTime()), - gf_0_(gf0_.name() + "_", gf0_) - {} + gf00_(gf.oldTime().oldTime()) + { + { + gf_0_ = GeometricField::New(gf0_.name() + "_", gf0_); + gf_00_ = GeometricField::New(gf00_.name() + "_", gf00_); + } + } //- Destructor ~subCycleField() { - // Reset the old-time field - gf0_ = gf_0_; + if (gf_0_.valid()) + { + // Reset the old-time field + gf0_ = gf_0_; + + gf00_ = gf_00_; // Correct the time index of the field to correspond to the global time - gf_.timeIndex() = gf_.time().timeIndex(); - gf0_.timeIndex() = gf_.time().timeIndex(); + gf_.timeIndex() = gf_.time().timeIndex(); + } } @@ -96,7 +110,8 @@ public: void updateTimeIndex() { gf_.timeIndex() = gf_.time().timeIndex() + 1; - gf0_.timeIndex() = gf_.time().timeIndex() + 1; + gf0_.timeIndex() = gf0_.time().timeIndex() + 1; + gf00_.timeIndex() = gf00_.time().timeIndex() + 1; } }; diff --git a/src/OpenFOAM/db/Time/subCycleTime.C b/src/OpenFOAM/db/Time/subCycleTime.C index fc21130645d0311de1572032e2c819900ca6a39c..32dee009156041154d2f14d0f755be286c0f780e 100644 --- a/src/OpenFOAM/db/Time/subCycleTime.C +++ b/src/OpenFOAM/db/Time/subCycleTime.C @@ -36,7 +36,10 @@ Foam::subCycleTime::subCycleTime(Time& runTime, const label nCycles) total_(nCycles) { // Could avoid 0 or 1 nCycles here on construction - time_.subCycle(nCycles); + if (nCycles > 1) + { + time_.subCycle(nCycles); + } } @@ -64,7 +67,10 @@ bool Foam::subCycleTime::end() const void Foam::subCycleTime::endSubCycle() { - time_.endSubCycle(); + if (total_ > 1) + { + time_.endSubCycle(); + } // If called manually, ensure status() will return false @@ -89,8 +95,12 @@ bool Foam::subCycleTime::loop() Foam::subCycleTime& Foam::subCycleTime::operator++() { - ++time_; - ++index_; + if (total_ > 1) + { + time_++; + } + + index_++; // Register index change with Time, in case someone wants this information time_.subCycleIndex(index_); diff --git a/src/faOptions/Make/files b/src/faOptions/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..cd8c59745df5cbd23f79099fe327b62161876a73 --- /dev/null +++ b/src/faOptions/Make/files @@ -0,0 +1,16 @@ +faOption/faOption.C +faOption/faOptionIO.C +faOption/faOptionList.C +faOption/faOptions.C + +faceSetOption/faceSetOption.C + +/* Sources */ +derivedSources=sources/derived + +$(derivedSources)/externalHeatFluxSource/externalHeatFluxSource.C +$(derivedSources)/jouleHeatingSource/jouleHeatingSource.C +$(derivedSources)/contactHeatFluxSource/contactHeatFluxSource.C +$(derivedSources)/externalFileSource/externalFileSource.C + +LIB = $(FOAM_LIBBIN)/libfaOptions diff --git a/src/faOptions/Make/options b/src/faOptions/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..46c960d614b9ba1846f15d329bf92412ceff9ea7 --- /dev/null +++ b/src/faOptions/Make/options @@ -0,0 +1,22 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteArea/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/solidThermo/lnInclude \ + -I$(LIB_SRC)/transportModels \ + -I$(LIB_SRC)/transportModels/compressible/lnInclude \ + -I$(LIB_SRC)/transportModels/incompressible/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ + -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \ + -I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \ + -I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude + +LIB_LIBS = \ + -lfiniteArea \ + -lfiniteVolume \ + -lsampling \ + -lmeshTools \ + -lturbulenceModels \ + -lincompressibleTurbulenceModels \ + -lcompressibleTurbulenceModels diff --git a/src/faOptions/faOption/faOption.C b/src/faOptions/faOption/faOption.C new file mode 100644 index 0000000000000000000000000000000000000000..708f73885113285098a924d9105967a6391ff50e --- /dev/null +++ b/src/faOptions/faOption/faOption.C @@ -0,0 +1,291 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "faOption.H" +#include "areaFields.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + namespace fa + { + defineTypeNameAndDebug(option, 0); + defineRunTimeSelectionTable(option, dictionary); + } +} + + +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +void Foam::fa::option::constructMeshObjects() +{ + regionMeshPtr_.reset(new faMesh(mesh_)); + + vsmPtr_.reset(new volSurfaceMapping(regionMeshPtr_())); +} + + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::fa::option::option +( + const word& name, + const word& modelType, + const dictionary& dict, + const fvPatch& patch +) +: + name_(name), + modelType_(modelType), + mesh_(patch.boundaryMesh().mesh()), + patch_(patch), + dict_(dict), + coeffs_(dict.optionalSubDict(modelType + "Coeffs")), + active_(dict.getOrDefault<Switch>("active", true)), + fieldNames_(), + applied_(), + regionName_(dict.get<word>("region")), + regionMeshPtr_(nullptr), + vsmPtr_(nullptr) +{ + constructMeshObjects(); + + Info<< incrIndent << indent << "Source: " << name_ << endl << decrIndent; +} + + +// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * // + +Foam::autoPtr<Foam::fa::option> Foam::fa::option::New +( + const word& name, + const dictionary& coeffs, + const fvPatch& patch +) +{ + const word modelType(coeffs.get<word>("type")); + + Info<< indent + << "Selecting finite area options type " << modelType << endl; + + const_cast<Time&>(patch.boundaryMesh().mesh().time()).libs().open + ( + coeffs, + "libs", + dictionaryConstructorTablePtr_ + ); + + auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); + + if (!cstrIter.found()) + { + FatalErrorInFunction + << "Unknown faOption model type " + << modelType << nl << nl + << "Valid faOption types are:" << nl + << dictionaryConstructorTablePtr_->sortedToc() + << exit(FatalError); + } + + return autoPtr<option>(cstrIter()(name, modelType, coeffs, patch)); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::fa::option::isActive() +{ + return active_; +} + + +Foam::label Foam::fa::option::applyToField(const word& fieldName) const +{ + return fieldNames_.find(fieldName); +} + + +void Foam::fa::option::checkApplied() const +{ + forAll(applied_, i) + { + if (!applied_[i]) + { + WarningInFunction + << "Source " << name_ << " defined for field " + << fieldNames_[i] << " but never used" << endl; + } + } +} + + +void Foam::fa::option::addSup +( + const areaScalarField& h, + faMatrix<scalar>& eqn, + const label fieldi +) +{} + + +void Foam::fa::option::addSup +( + const areaScalarField& h, + faMatrix<vector>& eqn, + const label fieldi +) +{} + + +void Foam::fa::option::addSup +( + const areaScalarField& h, + faMatrix<sphericalTensor>& eqn, + const label fieldi +) +{} + + +void Foam::fa::option::addSup +( + const areaScalarField& h, + faMatrix<symmTensor>& eqn, + const label fieldi +) +{} + + +void Foam::fa::option::addSup +( + const areaScalarField& h, + faMatrix<tensor>& eqn, + const label fieldi +) +{} + + +void Foam::fa::option::addSup +( + const areaScalarField& h, + const areaScalarField& rho, + faMatrix<scalar>& eqn, + const label fieldi +) +{} + + +void Foam::fa::option::addSup +( + const areaScalarField& h, + const areaScalarField& rho, + faMatrix<vector>& eqn, + const label fieldi +) +{} + + +void Foam::fa::option::addSup +( + const areaScalarField& h, + const areaScalarField& rho, + faMatrix<sphericalTensor>& eqn, + const label fieldi +) +{} + + +void Foam::fa::option::addSup +( + const areaScalarField& h, + const areaScalarField& rho, + faMatrix<symmTensor>& eqn, + const label fieldi +) +{} + + +void Foam::fa::option::addSup +( + const areaScalarField& h, + const areaScalarField& rho, + faMatrix<tensor>& eqn, + const label fieldi +) +{} + + +void Foam::fa::option::constrain(faMatrix<scalar>& eqn, const label fieldi) +{} + + +void Foam::fa::option::constrain(faMatrix<vector>& eqn, const label fieldi) +{} + + +void Foam::fa::option::constrain +( + faMatrix<sphericalTensor>& eqn, + const label fieldi +) +{} + + +void Foam::fa::option::constrain +( + faMatrix<symmTensor>& eqn, + const label fieldi +) +{} + + +void Foam::fa::option::constrain(faMatrix<tensor>& eqn, const label fieldi) +{} + + +void Foam::fa::option::correct(areaScalarField& field) +{} + + +void Foam::fa::option::correct(areaVectorField& field) +{} + + +void Foam::fa::option::correct(areaSphericalTensorField& field) +{} + + +void Foam::fa::option::correct(areaSymmTensorField& field) +{} + + +void Foam::fa::option::correct(areaTensorField& field) +{} + + +// ************************************************************************* // diff --git a/src/faOptions/faOption/faOption.H b/src/faOptions/faOption/faOption.H new file mode 100644 index 0000000000000000000000000000000000000000..253c26e2b1536ab21fb5e0340378cbfb899aaeb7 --- /dev/null +++ b/src/faOptions/faOption/faOption.H @@ -0,0 +1,441 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +Class + Foam::fa::option + +Description + Base abstract class for handling finite area options (i.e. \c faOption). + +Usage + Minimal example by using \c constant/faOptions: + \verbatim + <userDefinedName1> + { + // Mandatory entries (unmodifiable) + type <faOptionName>; + + // Mandatory entries (runtime modifiable) + region <regionName>; + + // Optional entries (unmodifiable/runtime modifiable) + <faOption>Coeffs + { + // subdictionary entries + } + + // Optional entries (runtime modifiable) + active true; + log true; + } + \endverbatim + + where the entries mean: + \table + Property | Description | Type | Reqd | Dflt + type | Name of operand faOption | word | yes | - + region | Name of operand region | word | yes | - + \<faOption\>Coeffs | Dictionary containing settings of <!-- + --> the selected faOption settings | dictionary | no | - + active | Flag to (de)activate faOption | bool | no | true + log | Flag to log faOption-related info | bool | no | true + \endtable + +Note + - Source/sink options are to be added to the right-hand side of equations. + +SourceFiles + faOption.C + faOptionIO.C + +\*---------------------------------------------------------------------------*/ + +#ifndef faOption_H +#define faOption_H + +#include "faMatrices.H" +#include "areaFields.H" +#include "dictionary.H" +#include "Switch.H" +#include "runTimeSelectionTables.H" +#include "fvMesh.H" +#include "volSurfaceMapping.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace fa +{ + +/*---------------------------------------------------------------------------*\ + Class option Declaration +\*---------------------------------------------------------------------------*/ + +class option +{ + // Private Member Functions + + //- Construct region mesh and fields + void constructMeshObjects(); + + +protected: + + // Protected Data + + //- Source name + const word name_; + + //- Model type + const word modelType_; + + //- Reference to the mesh database + const fvMesh& mesh_; + + //- Reference to the patch + const fvPatch& patch_; + + //- Top level source dictionary + dictionary dict_; + + //- Dictionary containing source coefficients + dictionary coeffs_; + + //- Source active flag + Switch active_; + + //- Field names to apply source to - populated by derived models + wordList fieldNames_; + + //- Applied flag list - corresponds to each fieldNames_ entry + List<bool> applied_; + + //- Region name + word regionName_; + + //- Pointer to the region mesh database + autoPtr<faMesh> regionMeshPtr_; + + //-Volume-to surface mapping + autoPtr<volSurfaceMapping> vsmPtr_; + + +public: + + //- Runtime type information + TypeName("option"); + + + // Declare run-time constructor selection table + + declareRunTimeSelectionTable + ( + autoPtr, + option, + dictionary, + ( + const word& name, + const word& modelType, + const dictionary& dict, + const fvPatch& patch + ), + (name, modelType, dict, patch) + ); + + + // Constructors + + //- Construct from components + option + ( + const word& name, + const word& modelType, + const dictionary& dict, + const fvPatch& patch + ); + + //- Return clone + autoPtr<option> clone() const + { + NotImplemented; + return nullptr; + } + + //- Return pointer to new faOption object created + //- on the freestore from an Istream + class iNew + { + + //- Reference to the patch + const fvPatch& patch_; + + //- Name + const word& name_; + + public: + + iNew + ( + const fvPatch& patch, + const word& name + ) + : + patch_(patch), + name_(name) + {} + + autoPtr<option> operator()(Istream& is) const + { + const dictionary dict(is); + + return autoPtr<option> + ( + option::New(name_, dict, patch_) + ); + } + }; + + + // Selectors + + //- Return a reference to the selected faOption model + static autoPtr<option> New + ( + const word& name, + const dictionary& dict, + const fvPatch& patch + ); + + + //- Destructor + virtual ~option() = default; + + + // Member Functions + + // Access + + //- Return const access to the source name + inline const word& name() const; + + //- Return const access to the mesh database + inline const fvMesh& mesh() const; + + //- Return const access to fvPatch + inline const fvPatch& patch() const; + + //- Return dictionary + inline const dictionary& coeffs() const; + + //- Return const access to the source active flag + inline bool active() const; + + //- Set the applied flag to true for field index fieldi + inline void setApplied(const label fieldi); + + //- Return the region mesh database + inline const faMesh& regionMesh() const; + + //- Return volSurfaceMapping + inline const volSurfaceMapping& vsm() const; + + //- Region name + inline const word& regionName() const; + + + // Edit + + //- Return access to the source active flag + inline Switch& active(); + + + // Checks + + //- Is the source active? + virtual bool isActive(); + + //- Return index of field name if found in fieldNames list + virtual label applyToField(const word& fieldName) const; + + //- Check that the source has been applied + virtual void checkApplied() const; + + + // Evaluation + + // Explicit and implicit sources + + virtual void addSup + ( + const areaScalarField& h, + faMatrix<scalar>& eqn, + const label fieldi + ); + + virtual void addSup + ( + const areaScalarField& h, + faMatrix<vector>& eqn, + const label fieldi + ); + + virtual void addSup + ( + const areaScalarField& h, + faMatrix<symmTensor>& eqn, + const label fieldi + ); + + virtual void addSup + ( + const areaScalarField& h, + faMatrix<sphericalTensor>& eqn, + const label fieldi + ); + + virtual void addSup + ( + const areaScalarField& h, + faMatrix<tensor>& eqn, + const label fieldi + ); + + + // Explicit and implicit sources for compressible equations + + virtual void addSup + ( + const areaScalarField& h, + const areaScalarField& rho, + faMatrix<scalar>& eqn, + const label fieldi + ); + + virtual void addSup + ( + const areaScalarField& h, + const areaScalarField& rho, + faMatrix<vector>& eqn, + const label fieldi + ); + + virtual void addSup + ( + const areaScalarField& h, + const areaScalarField& rho, + faMatrix<symmTensor>& eqn, + const label fieldi + ); + + virtual void addSup + ( + const areaScalarField& h, + const areaScalarField& rho, + faMatrix<sphericalTensor>& eqn, + const label fieldi + ); + + virtual void addSup + ( + const areaScalarField& h, + const areaScalarField& rho, + faMatrix<tensor>& eqn, + const label fieldi + ); + + + // Constraints + + virtual void constrain + ( + faMatrix<scalar>& eqn, + const label fieldi + ); + + virtual void constrain + ( + faMatrix<vector>& eqn, + const label fieldi + ); + + virtual void constrain + ( + faMatrix<sphericalTensor>& eqn, + const label fieldi + ); + + virtual void constrain + ( + faMatrix<symmTensor>& eqn, + const label fieldi + ); + + virtual void constrain + ( + faMatrix<tensor>& eqn, + const label fieldi + ); + + + // Correction + + virtual void correct(areaScalarField& field); + virtual void correct(areaVectorField& field); + virtual void correct(areaSphericalTensorField& field); + virtual void correct(areaSymmTensorField& field); + virtual void correct(areaTensorField& field); + + + // IO + + //- Write the source header information + virtual void writeHeader(Ostream&) const; + + //- Write the source footer information + virtual void writeFooter(Ostream&) const; + + //- Write the source properties + virtual void writeData(Ostream&) const; + + //- Read source dictionary + virtual bool read(const dictionary& dict); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace fa +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "faOptionI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/faOptions/faOption/faOptionI.H b/src/faOptions/faOption/faOptionI.H new file mode 100644 index 0000000000000000000000000000000000000000..a541123f2752e01909762b7faed3d1420c7cdd2e --- /dev/null +++ b/src/faOptions/faOption/faOptionI.H @@ -0,0 +1,108 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------ +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +inline const Foam::word& Foam::fa::option::name() const +{ + return name_; +} + + +inline const Foam::fvMesh& Foam::fa::option::mesh() const +{ + return mesh_; +} + + +inline const Foam::fvPatch& Foam::fa::option::patch() const +{ + return patch_; +} + + +inline const Foam::dictionary& Foam::fa::option::coeffs() const +{ + return coeffs_; +} + + +inline bool Foam::fa::option::active() const +{ + return active_; +} + + +inline void Foam::fa::option::setApplied(const label fieldi) +{ + applied_[fieldi] = true; +} + + +inline Foam::Switch& Foam::fa::option::active() +{ + return active_; +} + + +inline const Foam::word& Foam::fa::option::regionName() const +{ + return regionName_; +} + + +inline const Foam::faMesh& Foam::fa::option::regionMesh() const +{ + if (regionMeshPtr_.valid()) + { + return regionMeshPtr_(); + } + else + { + FatalErrorInFunction + << "Region mesh not available" << abort(FatalError); + } + return *(new faMesh(mesh_)); +} + + +inline const Foam::volSurfaceMapping& Foam::fa::option::vsm() const +{ + if (vsmPtr_.valid()) + { + return vsmPtr_(); + } + else + { + FatalErrorInFunction + << "vsmPtr not available" << abort(FatalError); + } + return *(new volSurfaceMapping(regionMeshPtr_())); +} + + +// ************************************************************************* // diff --git a/src/faOptions/faOption/faOptionIO.C b/src/faOptions/faOption/faOptionIO.C new file mode 100644 index 0000000000000000000000000000000000000000..1cb2ab70f205d49c932b747fc47bf79d1d9118b4 --- /dev/null +++ b/src/faOptions/faOption/faOptionIO.C @@ -0,0 +1,64 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------ +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "faOption.H" + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::fa::option::writeHeader(Ostream& os) const +{ + os.beginBlock(name_); +} + + +void Foam::fa::option::writeFooter(Ostream& os) const +{ + os.endBlock(); +} + + +void Foam::fa::option::writeData(Ostream& os) const +{ + os.writeEntry("type", type()); + os.writeEntry("active", active_); + + os << nl; + coeffs_.writeEntry(word(type() + "Coeffs"), os); +} + + +bool Foam::fa::option::read(const dictionary& dict) +{ + dict.readIfPresent("active", active_); + + coeffs_ = dict.optionalSubDict(modelType_ + "Coeffs"); + + return true; +} + + +// ************************************************************************* // diff --git a/src/faOptions/faOption/faOptionList.C b/src/faOptions/faOption/faOptionList.C new file mode 100644 index 0000000000000000000000000000000000000000..80de3cf682efd2dbed3808cd6dd4c3699f4041a4 --- /dev/null +++ b/src/faOptions/faOption/faOptionList.C @@ -0,0 +1,178 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------ +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "faOptionList.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace fa +{ + defineTypeNameAndDebug(optionList, 0); +} +} + + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +const Foam::dictionary& Foam::fa::optionList::optionsDict +( + const dictionary& dict +) const +{ + if (dict.found("options")) + { + return dict.subDict("options"); + } + else + { + return dict; + } +} + + +bool Foam::fa::optionList::readOptions(const dictionary& dict) +{ + checkTimeIndex_ = mesh_.time().timeIndex() + 2; + + bool allOk = true; + forAll(*this, i) + { + option& bs = this->operator[](i); + bool ok = bs.read(dict.subDict(bs.name())); + allOk = (allOk && ok); + } + return allOk; +} + + +void Foam::fa::optionList::checkApplied() const +{ + if (mesh_.time().timeIndex() == checkTimeIndex_) + { + forAll(*this, i) + { + const option& bs = this->operator[](i); + bs.checkApplied(); + } + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::fa::optionList::optionList +( + const fvPatch& p, + const dictionary& dict +) +: + PtrList<option>(), + mesh_(p.boundaryMesh().mesh()), + patch_(p), + checkTimeIndex_(mesh_.time().startTimeIndex() + 2) +{ + reset(optionsDict(dict)); +} + + +Foam::fa::optionList::optionList(const fvPatch& p) +: + PtrList<option>(), + mesh_(p.boundaryMesh().mesh()), + patch_(p), + checkTimeIndex_(mesh_.time().startTimeIndex() + 2) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::fa::optionList::reset(const dictionary& dict) +{ + // Count number of active faOptions + label count = 0; + for (const entry& dEntry : dict) + { + if (dEntry.isDict()) + { + ++count; + } + } + + this->resize(count); + + count = 0; + for (const entry& dEntry : dict) + { + if (dEntry.isDict()) + { + const word& name = dEntry.keyword(); + const dictionary& sourceDict = dEntry.dict(); + + this->set + ( + count++, + option::New(name, sourceDict, patch_) + ); + } + } +} + + +bool Foam::fa::optionList::read(const dictionary& dict) +{ + return readOptions(optionsDict(dict)); +} + + +bool Foam::fa::optionList::writeData(Ostream& os) const +{ + // Write list contents + forAll(*this, i) + { + os << nl; + this->operator[](i).writeHeader(os); + this->operator[](i).writeData(os); + this->operator[](i).writeFooter(os); + } + + // Check state of IOstream + return os.good(); +} + + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +Foam::Ostream& Foam::operator<<(Ostream& os, const fa::optionList& options) +{ + options.writeData(os); + return os; +} + + +// ************************************************************************* // diff --git a/src/faOptions/faOption/faOptionList.H b/src/faOptions/faOption/faOptionList.H new file mode 100644 index 0000000000000000000000000000000000000000..290dc794a6596c960307fee872f9109fec70bad2 --- /dev/null +++ b/src/faOptions/faOption/faOptionList.H @@ -0,0 +1,250 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------ +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 <http://www.gnu.org/licenses/>. + +Class + Foam::fa::optionList + +Description + List of finite volume options + +SourceFile + optionList.C + +\*---------------------------------------------------------------------------*/ + +#ifndef faOptionList_H +#define faOptionList_H + +#include "faOption.H" +#include "PtrList.H" +#include "GeometricField.H" +#include "geometricOneField.H" +#include "faPatchField.H" +#include "fvMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of friend functions and operators +namespace fa +{ + class optionList; +} + +Ostream& operator<<(Ostream& os, const fa::optionList& options); + +namespace fa +{ + +/*---------------------------------------------------------------------------*\ + Class optionList Declaration +\*---------------------------------------------------------------------------*/ + +class optionList +: + public PtrList<option> +{ +protected: + + // Protected Data + + //- Reference to the mesh database + const fvMesh& mesh_; + + //- Reference to the patch + const fvPatch& patch_; + + //- Time index to check that all defined sources have been applied + label checkTimeIndex_; + + + // Protected Member Functions + + //- Return the "options" sub-dictionary if present otherwise return dict + const dictionary& optionsDict(const dictionary& dict) const; + + //- Read options dictionary + bool readOptions(const dictionary& dict); + + //- Check that all sources have been applied + void checkApplied() const; + + //- Return source for equation with specified name and dimensions + template<class Type> + tmp<faMatrix<Type>> source + ( + GeometricField<Type, faPatchField, areaMesh>& field, + const areaScalarField& h, + const word& fieldName, + const dimensionSet& ds + ); + + //- No copy construct + optionList(const optionList&) = delete; + + //- No copy assignment + void operator=(const optionList&) = delete; + + +public: + + //- Runtime type information + TypeName("optionList"); + + + // Constructors + + //- Construct null + optionList(const fvPatch& p); + + //- Construct from mesh and dictionary + optionList(const fvPatch&, const dictionary& ); + + + //- Destructor + virtual ~optionList() + {} + + + // Member Functions + + //- Reset the source list + void reset(const dictionary& dict); + + + // Sources + + //- Return source for equation + template<class Type> + tmp<faMatrix<Type>> operator() + ( + const areaScalarField& h, + GeometricField<Type, faPatchField, areaMesh>& field + ); + + //- Return source for equation with specified name + template<class Type> + tmp<faMatrix<Type>> operator() + ( + const areaScalarField& h, + GeometricField<Type, faPatchField, areaMesh>& field, + const word& fieldName + ); + + //- Return source for equation + template<class Type> + tmp<faMatrix<Type>> operator() + ( + const areaScalarField& h, + const areaScalarField& rho, + GeometricField<Type, faPatchField, areaMesh>& field + ); + + //- Return source for equation with specified name + template<class Type> + tmp<faMatrix<Type>> operator() + ( + const areaScalarField& h, + const areaScalarField& rho, + GeometricField<Type, faPatchField, areaMesh>& field, + const word& fieldName + ); + + + //- Return source for equation with specified name and dimensios + template<class Type> + tmp<faMatrix<Type>> operator() + ( + const areaScalarField& rho, + GeometricField<Type, faPatchField, areaMesh>& field, + const dimensionSet& ds + ); + + + //- Return source for equation with second time derivative + template<class Type> + tmp<faMatrix<Type>> d2dt2 + ( + GeometricField<Type, faPatchField, areaMesh>& field + ); + + //- Return source for equation with second time derivative + template<class Type> + tmp<faMatrix<Type>> d2dt2 + ( + GeometricField<Type, faPatchField, areaMesh>& field, + const word& fieldName + ); + + + // Constraints + + //- Apply constraints to equation + template<class Type> + void constrain(faMatrix<Type>& eqn); + + + // Correction + + //- Apply correction to field + template<class Type> + void correct(GeometricField<Type, faPatchField, areaMesh>& field); + + + // IO + + //- Read dictionary + virtual bool read(const dictionary& dict); + + //- Write data to Ostream + virtual bool writeData(Ostream& os) const; + + //- Ostream operator + friend Ostream& operator<< + ( + Ostream& os, + const optionList& options + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace fa +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "faOptionListTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/faOptions/faOption/faOptionListTemplates.C b/src/faOptions/faOption/faOptionListTemplates.C new file mode 100644 index 0000000000000000000000000000000000000000..1a954bcce453918c6aad227c2aba433930bd5001 --- /dev/null +++ b/src/faOptions/faOption/faOptionListTemplates.C @@ -0,0 +1,290 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------ +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "profiling.H" + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type> +Foam::tmp<Foam::faMatrix<Type>> Foam::fa::optionList::source +( + GeometricField<Type, faPatchField, areaMesh>& field, + const areaScalarField& h, + const word& fieldName, + const dimensionSet& ds +) +{ + checkApplied(); + + tmp<faMatrix<Type>> tmtx(new faMatrix<Type>(field, ds)); + faMatrix<Type>& mtx = tmtx.ref(); + + forAll(*this, i) + { + option& source = this->operator[](i); + + label fieldi = source.applyToField(fieldName); + + if (fieldi != -1) + { + addProfiling(faopt, "faOption()." + source.name()); + + source.setApplied(fieldi); + + if (source.isActive()) + { + if (debug) + { + Info<< "Applying source " << source.name() << " to field " + << fieldName << endl; + } + + source.addSup(h, mtx, fieldi); + } + } + } + + return tmtx; +} + + +template<class Type> +Foam::tmp<Foam::faMatrix<Type>> Foam::fa::optionList::operator() +( + const areaScalarField& h, + GeometricField<Type, faPatchField, areaMesh>& field +) +{ + return this->operator()(h, field, field.name()); +} + + +template<class Type> +Foam::tmp<Foam::faMatrix<Type>> Foam::fa::optionList::operator() +( + const areaScalarField& h, + GeometricField<Type, faPatchField, areaMesh>& field, + const word& fieldName +) +{ + return source(field, h, fieldName, field.dimensions()/dimTime*dimArea); +} + + +template<class Type> +Foam::tmp<Foam::faMatrix<Type>> Foam::fa::optionList::operator() +( + const areaScalarField& h, + const areaScalarField& rho, + GeometricField<Type, faPatchField, areaMesh>& field +) +{ + return this->operator()(h, rho, field, field.name()); +} + + +template<class Type> +Foam::tmp<Foam::faMatrix<Type>> Foam::fa::optionList::operator() +( + const areaScalarField& h, + const areaScalarField& rho, + GeometricField<Type, faPatchField, areaMesh>& field, + const word& fieldName +) +{ + checkApplied(); + + const dimensionSet ds + ( + rho.dimensions()*field.dimensions()/dimTime*dimArea + ); + + tmp<faMatrix<Type>> tmtx(new faMatrix<Type>(field, ds)); + faMatrix<Type>& mtx = tmtx.ref(); + + forAll(*this, i) + { + option& source = this->operator[](i); + + label fieldi = source.applyToField(fieldName); + + if (fieldi != -1) + { + addProfiling(faopt, "faOption()." + source.name()); + + source.setApplied(fieldi); + + if (source.isActive()) + { + if (debug) + { + Info<< "Applying source " << source.name() << " to field " + << fieldName << endl; + } + + source.addSup(h, rho, mtx, fieldi); + } + } + } + + return tmtx; +} + + +template<class Type> +Foam::tmp<Foam::faMatrix<Type>> Foam::fa::optionList::operator() +( + const areaScalarField& rho, + GeometricField<Type, faPatchField, areaMesh>& field, + const dimensionSet& ds +) +{ + checkApplied(); + + const dimensionSet dsMat(ds*dimArea); + + tmp<faMatrix<Type>> tmtx(new faMatrix<Type>(field, dsMat)); + faMatrix<Type>& mtx = tmtx.ref(); + + forAll(*this, i) + { + option& source = this->operator[](i); + + label fieldi = source.applyToField(field.name()); + + if (fieldi != -1) + { + addProfiling(faopt, "faOption()." + source.name()); + + source.setApplied(fieldi); + + if (source.isActive()) + { + if (debug) + { + Info<< "Applying source " << source.name() << " to field " + << field.name() << endl; + } + + source.addSup(rho, mtx, fieldi); + } + } + } + + return tmtx; +} + + +template<class Type> +Foam::tmp<Foam::faMatrix<Type>> Foam::fa::optionList::d2dt2 +( + GeometricField<Type, faPatchField, areaMesh>& field +) +{ + return this->d2dt2(field, field.name()); +} + + +template<class Type> +Foam::tmp<Foam::faMatrix<Type>> Foam::fa::optionList::d2dt2 +( + GeometricField<Type, faPatchField, areaMesh>& field, + const word& fieldName +) +{ + return source(field, fieldName, field.dimensions()/sqr(dimTime)*dimArea); +} + + +template<class Type> +void Foam::fa::optionList::constrain(faMatrix<Type>& eqn) +{ + checkApplied(); + + forAll(*this, i) + { + option& source = this->operator[](i); + + label fieldi = source.applyToField(eqn.psi().name()); + + if (fieldi != -1) + { + addProfiling(faopt, "faOption::constrain." + eqn.psi().name()); + + source.setApplied(fieldi); + + if (source.isActive()) + { + if (debug) + { + Info<< "Applying constraint " << source.name() + << " to field " << eqn.psi().name() << endl; + } + + source.constrain(eqn, fieldi); + } + } + } +} + + +template<class Type> +void Foam::fa::optionList::correct +( + GeometricField<Type, faPatchField, areaMesh>& field +) +{ + const word& fieldName = field.name(); + + forAll(*this, i) + { + option& source = this->operator[](i); + + label fieldi = source.applyToField(fieldName); + + if (fieldi != -1) + { + addProfiling(faopt, "faOption::correct." + source.name()); + + source.setApplied(fieldi); + + if (source.isActive()) + { + if (debug) + { + Info<< "Correcting source " << source.name() + << " for field " << fieldName << endl; + } + + source.correct(field); + } + } + } +} + + +// ************************************************************************* // diff --git a/src/faOptions/faOption/faOptions.C b/src/faOptions/faOption/faOptions.C new file mode 100644 index 0000000000000000000000000000000000000000..ef6e465813d2d59824e8b9e16c0787da600497bb --- /dev/null +++ b/src/faOptions/faOption/faOptions.C @@ -0,0 +1,144 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------ +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "faOptions.H" +#include "faMesh.H" +#include "Time.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + namespace fa + { + defineTypeNameAndDebug(options, 0); + } +} + + +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +Foam::IOobject Foam::fa::options::createIOobject +( + const fvMesh& mesh +) const +{ + IOobject io + ( + typeName, + mesh.time().constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ); + + if (io.typeHeaderOk<IOdictionary>(true)) + { + Info<< "Creating finite area options from " + << io.instance()/io.name() << nl + << endl; + + io.readOpt() = IOobject::MUST_READ_IF_MODIFIED; + return io; + } + else + { + // Check if the faOptions file is in system + io.instance() = mesh.time().system(); + + if (io.typeHeaderOk<IOdictionary>(true)) + { + Info<< "Creating finite area options from " + << io.instance()/io.name() << nl + << endl; + + io.readOpt() = IOobject::MUST_READ_IF_MODIFIED; + return io; + } + else + { + io.readOpt() = IOobject::NO_READ; + return io; + } + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::fa::options::options +( + const fvPatch& p +) +: + IOdictionary(createIOobject(p.boundaryMesh().mesh())), + optionList(p, *this) +{} + + +Foam::fa::options& Foam::fa::options::New(const fvPatch& p) +{ + const fvMesh& mesh = p.boundaryMesh().mesh(); + + if (mesh.thisDb().foundObject<options>(typeName)) + { + return const_cast<options&> + ( + mesh.lookupObject<options>(typeName) + ); + } + else + { + if (debug) + { + InfoInFunction + << "Constructing " << typeName + << " for region " << mesh.name() << endl; + } + + options* objectPtr = new options(p); + regIOobject::store(objectPtr); + return *objectPtr; + } +} + + +bool Foam::fa::options::read() +{ + if (IOdictionary::regIOobject::read()) + { + optionList::read(*this); + return true; + } + else + { + return false; + } +} + + +// ************************************************************************* // diff --git a/src/faOptions/faOption/faOptions.H b/src/faOptions/faOption/faOptions.H new file mode 100644 index 0000000000000000000000000000000000000000..a80969885cc96c0a18f00eed579b868dc6041927 --- /dev/null +++ b/src/faOptions/faOption/faOptions.H @@ -0,0 +1,112 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------ +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 <http://www.gnu.org/licenses/>. + +Class + Foam::fa::options + +Description + Finite-area options + +SourceFiles + faOptions.C + +\*---------------------------------------------------------------------------*/ + +#ifndef fa_options_H +#define fa_options_H + +#include "faOptionList.H" +#include "IOdictionary.H" +#include "autoPtr.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace fa +{ + +/*---------------------------------------------------------------------------*\ + Class options Declaration +\*---------------------------------------------------------------------------*/ + +class options +: + public IOdictionary, + public optionList +{ + // Private Member Functions + + //- Create IO object if dictionary is present + IOobject createIOobject(const fvMesh& mesh) const; + + //- No copy construct + options(const options&) = delete; + + //- No copy assignment + void operator=(const options&) = delete; + + +public: + + // Declare name of the class and its debug switch + ClassName("faOptions"); + + + // Constructors + + //- Construct from components with list of field names + options(const fvPatch& p); + + //- Construct faOptions and register to database if not present + //- otherwise lookup and return + static options& New(const fvPatch& p); + + + //- Destructor + virtual ~options() + {} + + + // Member Functions + + //- Inherit read from optionList + using optionList::read; + + //- Read dictionary + virtual bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace fa +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/faOptions/faOption/makeFaOption.H b/src/faOptions/faOption/makeFaOption.H new file mode 100644 index 0000000000000000000000000000000000000000..64a12e469195bae5cf5f1d77523da5345ff42fa4 --- /dev/null +++ b/src/faOptions/faOption/makeFaOption.H @@ -0,0 +1,54 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------ +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#ifndef makeFaOption_H +#define makeFaOption_H + +#include "faOption.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#define makeFaOption(Option, Type) \ + \ + defineTemplateTypeNameAndDebugWithName \ + ( \ + Foam::fa::Option<Foam::Type>, \ + #Type#Option, \ + 0 \ + ); \ + \ + Foam::fa::option::adddictionaryConstructorToTable \ + <Foam::fa::Option<Foam::Type>> \ + add##Option##Type##dictionary##ConstructorTooptionTable_ + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/faOptions/faceSetOption/faceSetOption.C b/src/faOptions/faceSetOption/faceSetOption.C new file mode 100644 index 0000000000000000000000000000000000000000..24e176e56da0fc8c7bc15396e46137342d9a7b28 --- /dev/null +++ b/src/faOptions/faceSetOption/faceSetOption.C @@ -0,0 +1,246 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "faceSetOption.H" +#include "areaFields.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + namespace fa + { + defineTypeNameAndDebug(faceSetOption, 0); + } +} + + +const Foam::Enum +< + Foam::fa::faceSetOption::selectionModeType +> +Foam::fa::faceSetOption::selectionModeTypeNames_ +({ + { selectionModeType::smAll, "all" }, + { selectionModeType::smVolFaceZone, "volFaceZone" } +}); + + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +void Foam::fa::faceSetOption::setSelection(const dictionary& dict) +{ + switch (selectionMode_) + { + case smAll: + { + break; + } + case smVolFaceZone: + { + dict.readEntry("faceZone", faceSetName_); + break; + } + default: + { + FatalErrorInFunction + << "Unknown selectionMode " + << selectionModeTypeNames_[selectionMode_] + << ". Valid selectionMode types : " + << selectionModeTypeNames_ + << exit(FatalError); + } + } +} + + +void Foam::fa::faceSetOption::setArea() +{ + // Set area information + + scalar sumArea = 0.0; + for (const label facei : faces_) + { + sumArea += regionMesh().S()[facei]; + } + reduce(sumArea, sumOp<scalar>()); + + const scalar AOld = A_; + A_ = sumArea; + + // Convert both areas to representation using current writeprecision + word AOldName(Time::timeName(AOld, IOstream::defaultPrecision())); + word AName(Time::timeName(A_, IOstream::defaultPrecision())); + + if (AName != AOldName) + { + Info<< indent + << "- selected " << returnReduce(faces_.size(), sumOp<label>()) + << " face(s) with area " << A_ << endl; + } +} + + +void Foam::fa::faceSetOption::setFaceSet() +{ + switch (selectionMode_) + { + case smVolFaceZone: + { + Info<< indent + << "- selecting faces using volume-mesh faceZone " + << faceSetName_ << endl; + + label zoneID = mesh_.faceZones().findZoneID(faceSetName_); + if (zoneID == -1) + { + FatalErrorInFunction + << "Cannot find faceZone " << faceSetName_ << endl + << "Valid faceZones are " << mesh_.faceZones().names() + << exit(FatalError); + } + + const faceZone& addr = mesh_.faceZones()[zoneID]; + + const bitSet isZoneFace(mesh_.nFaces(), addr); + + // Do we loop over faMesh faces or over faceZone faces? + const labelUList& faceLabels = regionMesh().faceLabels(); + + label n = 0; + for (const label facei : faceLabels) + { + if (isZoneFace[facei]) + { + n++; + } + } + faces_.setSize(n); + n = 0; + for (const label facei : faceLabels) + { + if (isZoneFace[facei]) + { + faces_[n++] = facei; + } + } + break; + } + + case smAll: + { + Info<< indent << "- selecting all faces" << endl; + faces_ = identity(regionMesh().nFaces()); + + break; + } + default: + { + FatalErrorInFunction + << "Unknown selectionMode " + << selectionModeTypeNames_[selectionMode_] + << ". Valid selectionMode types are " + << selectionModeTypeNames_ + << exit(FatalError); + } + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::fa::faceSetOption::faceSetOption +( + const word& name, + const word& modelType, + const dictionary& dict, + const fvPatch& patch +) +: + option(name, modelType, dict, patch), + timeStart_(-1.0), + duration_(0.0), + selectionMode_(selectionModeTypeNames_.get("selectionMode", coeffs_)), + faceSetName_("none"), + A_(0.0) +{ + if (isActive()) + { + Info<< incrIndent; + read(dict); + setSelection(coeffs_); + setFaceSet(); + setArea(); + Info<< decrIndent; + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::fa::faceSetOption::isActive() +{ + if (option::isActive() && inTimeLimits(mesh_.time().value())) + { + // Update the face set if the mesh is changing + if (mesh_.changing()) + { + if (mesh_.topoChanging()) + { + setArea(); + // Force printing of new set area + A_ = -GREAT; + } + + // Report new area (if changed) + setArea(); + } + + return true; + } + + return false; +} + + +bool Foam::fa::faceSetOption::read(const dictionary& dict) +{ + if (option::read(dict)) + { + if (coeffs_.readIfPresent("timeStart", timeStart_)) + { + coeffs_.readEntry("duration", duration_); + } + + return true; + } + + return false; +} + + +// ************************************************************************* // diff --git a/src/faOptions/faceSetOption/faceSetOption.H b/src/faOptions/faceSetOption/faceSetOption.H new file mode 100644 index 0000000000000000000000000000000000000000..edbf26ed53b90f7b6b9a29da625338ca722dd07c --- /dev/null +++ b/src/faOptions/faceSetOption/faceSetOption.H @@ -0,0 +1,241 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +Class + Foam::fa::faceSetOption + +Description + Intermediate abstract class for handling + face-set options for the derived faOptions. + +Usage + Minimal example by using \c constant/faOptions: + \verbatim + <userDefinedName1> + { + // Mandatory/Optional (inherited) entries + ... + + // Mandatory entries (unmodifiable) + selectionMode all; + + // Optional entries (runtime modifiable) + timeStart 1.0; + + // Conditional mandatory entries (runtime modifiable) + + // when timeStart entry is present + duration 1.4; + + // when selectionMode=volFaceZone + faceZone <faceZoneName>; + } + \endverbatim + + where the entries mean: + \table + Property | Description | Type | Reqd | Dflt + selectionMode | Mode of face selection - see below | word | yes | - + timeStart | Start time of faOption | scalar | no | -1 + duration | Duration of faOption execution <!-- + --> starting from timeStart | scalar | cndtnl | 0 + faceZone | Name of operand faceZone | word | cndtnl | - + \endtable + + Options for the \c selectionMode entry: + \verbatim + all | Use all faces in the computational domain + faceZone | Use a given faceZone + \endverbatim + + The inherited entries are elaborated in: + - \link faOption.H \endlink + +Note + - Source/sink options are to be added to the right-hand side of equations. + +SourceFiles + faceSetOption.C + +\*---------------------------------------------------------------------------*/ + +#ifndef faceSetOption_H +#define faceSetOption_H + +#include "faOption.H" +#include "faceSet.H" +#include "faMesh.H" +#include "Time.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace fa +{ + +/*---------------------------------------------------------------------------*\ + Class faceSetOption Declaration +\*---------------------------------------------------------------------------*/ + +class faceSetOption +: + public option +{ +public: + + // Public Enumeration + + //- Enumeration for selection mode types + enum selectionModeType + { + smAll, + smVolFaceZone + }; + + //- List of selection mode type names + static const Enum<selectionModeType> selectionModeTypeNames_; + + +protected: + + // Protected Data + + //- Time start + scalar timeStart_; + + //- Duration + scalar duration_; + + //- Face selection mode + selectionModeType selectionMode_; + + //- Name of zone for "faceZone" selectionMode + word faceSetName_; + + //- Set of faces to apply source to + labelList faces_; + + //- Sum of face area + scalar A_; + + + // Protected Functions + + //- Set the face selection + void setSelection(const dictionary& dict); + + //- Set the face set based on the user input selection mode + void setFaceSet(); + + //- Recalculate the area + void setArea(); + + +public: + + //- Runtime type information + TypeName("faceSetOption"); + + + // Constructors + + //- Construct from components + faceSetOption + ( + const word& name, + const word& modelType, + const dictionary& dict, + const fvPatch& patch + ); + + + //- Destructor + virtual ~faceSetOption() = default; + + + // Member Functions + + // Access + + //- Return const access to the time start + inline scalar timeStart() const; + + //- Return const access to the duration + inline scalar duration() const; + + //- Return true if within time limits + inline bool inTimeLimits(const scalar time) const; + + //- Return const access to the face selection mode + inline const selectionModeType& selectionMode() const; + + //- Return const access to the name of face set for "faceZone" + //- selectionMode + inline const word& faceSetName() const; + + //- Return const access to the total face area + inline scalar A() const; + + //- Return const access to the face set + inline const labelList& faces() const; + + + // Edit + + //- Return access to the time start + inline scalar& timeStart(); + + //- Return access to the duration + inline scalar& duration(); + + + // Checks + + //- Is the source active? + virtual bool isActive(); + + + // IO + + //- Read source dictionary + virtual bool read(const dictionary& dict); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace fa +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "faceSetOptionI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/faOptions/faceSetOption/faceSetOptionI.H b/src/faOptions/faceSetOption/faceSetOptionI.H new file mode 100644 index 0000000000000000000000000000000000000000..d63ee885604f56986a9c937bbfdc0736d16bdc29 --- /dev/null +++ b/src/faOptions/faceSetOption/faceSetOptionI.H @@ -0,0 +1,93 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +inline Foam::scalar Foam::fa::faceSetOption::timeStart() const +{ + return timeStart_; +} + + +inline Foam::scalar Foam::fa::faceSetOption::duration() const +{ + return duration_; +} + + +inline bool Foam::fa::faceSetOption::inTimeLimits(const scalar time) const +{ + return + ( + (timeStart_ < 0) + || + ( + (mesh_.time().value() >= timeStart_) + && (mesh_.time().value() <= (timeStart_ + duration_)) + ) + ); +} + + +inline const Foam::fa::faceSetOption::selectionModeType& +Foam::fa::faceSetOption::selectionMode() const +{ + return selectionMode_; +} + + +inline const Foam::word& Foam::fa::faceSetOption::faceSetName() const +{ + return faceSetName_; +} + + +inline Foam::scalar Foam::fa::faceSetOption::A() const +{ + return A_; +} + + +inline const Foam::labelList& Foam::fa::faceSetOption::faces() const +{ + return faces_; +} + + +inline Foam::scalar& Foam::fa::faceSetOption::timeStart() +{ + return timeStart_; +} + + +inline Foam::scalar& Foam::fa::faceSetOption::duration() +{ + return duration_; +} + + +// ************************************************************************* // diff --git a/src/faOptions/sources/derived/contactHeatFluxSource/contactHeatFluxSource.C b/src/faOptions/sources/derived/contactHeatFluxSource/contactHeatFluxSource.C new file mode 100644 index 0000000000000000000000000000000000000000..e9a4133d7a9f1b67f40f3742e1880e14e474b5e9 --- /dev/null +++ b/src/faOptions/sources/derived/contactHeatFluxSource/contactHeatFluxSource.C @@ -0,0 +1,204 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "contactHeatFluxSource.H" +#include "faMatrices.H" +#include "addToRunTimeSelectionTable.H" +#include "volFields.H" +#include "famSup.H" +#include "zeroGradientFaPatchFields.H" + +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + +namespace Foam +{ +namespace fa +{ + defineTypeNameAndDebug(contactHeatFluxSource, 0); + addToRunTimeSelectionTable(option, contactHeatFluxSource, dictionary); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::fa::contactHeatFluxSource::contactHeatFluxSource +( + const word& sourceName, + const word& modelType, + const dictionary& dict, + const fvPatch& patch +) +: + faceSetOption(sourceName, modelType, dict, patch), + temperatureCoupledBase(patch, dict), + TName_(dict.getOrDefault<word>("T", "T")), + TprimaryName_(dict.get<word>("Tprimary")), + Tp_(mesh().lookupObject<volScalarField>(TprimaryName_)), + Tw1_ + ( + IOobject + ( + "Tw1_" + sourceName, + mesh().time().timeName(), + mesh(), + IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE + ), + regionMesh(), + dimensionedScalar(dimTemperature, Zero), + zeroGradientFaPatchScalarField::typeName + ), + thicknessLayers_(Zero), + kappaLayers_(Zero), + contactRes_(0), + curTimeIndex_(-1) +{ + fieldNames_.setSize(1, TName_); + + applied_.setSize(fieldNames_.size(), false); + + read(dict); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::tmp<Foam::areaScalarField> Foam::fa::contactHeatFluxSource::htc() const +{ + IOobject io + ( + "thtc", + mesh().time().timeName(), + mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ); + + tmp<areaScalarField> thtc + ( + new areaScalarField + ( + io, + regionMesh(), + dimensionedScalar(dimPower/dimArea/dimTemperature, Zero) + ) + ); + + areaScalarField& htc = thtc.ref(); + + const volScalarField::Boundary& vfb = Tp_.boundaryField(); + + htc.primitiveFieldRef() = + temperatureCoupledBase::kappa + ( + vsm().mapInternalToSurface<scalar>(vfb)() + )*patch().deltaCoeffs(); + + if (contactRes_ != 0) + { + tmp<areaScalarField> tcontact + ( + new areaScalarField + ( + io, + regionMesh(), + dimensionedScalar + ( + "contact", + dimPower/dimArea/dimTemperature, + contactRes_ + ) + ) + ); + areaScalarField& contact = tcontact.ref(); + htc.primitiveFieldRef() += contact.primitiveField(); + } + + return thtc; +} + + +void Foam::fa::contactHeatFluxSource::addSup +( + const areaScalarField& h, + const areaScalarField& rhoCph, + faMatrix<scalar>& eqn, + const label fieldi +) +{ + if (isActive()) + { + DebugInfo<< name() << ": applying source to " << eqn.psi().name() + << endl; + + if (curTimeIndex_ != mesh().time().timeIndex()) + { + const volScalarField::Boundary& vfb = Tp_.boundaryField(); + + Tw1_.primitiveFieldRef() = + this->vsm().mapInternalToSurface<scalar>(vfb); + + tmp<areaScalarField> htcw = htc(); + + eqn += -fam::Sp(htcw(), eqn.psi()) + htcw()*Tw1_; + + curTimeIndex_ = mesh().time().timeIndex(); + } + } +} + + +bool Foam::fa::contactHeatFluxSource::read(const dictionary& dict) +{ + if (option::read(dict)) + { + coeffs_.readIfPresent("T", TName_); + + if (dict.readIfPresent("thicknessLayers", thicknessLayers_)) + { + dict.readEntry("kappaLayers", kappaLayers_); + + if (thicknessLayers_.size() > 0) + { + // Calculate effective thermal resistance by harmonic averaging + forAll(thicknessLayers_, iLayer) + { + contactRes_ += thicknessLayers_[iLayer]/kappaLayers_[iLayer]; + } + contactRes_ = scalar(1)/contactRes_; + } + } + + return true; + } + + return false; +} + + +// ************************************************************************* // diff --git a/src/faOptions/sources/derived/contactHeatFluxSource/contactHeatFluxSource.H b/src/faOptions/sources/derived/contactHeatFluxSource/contactHeatFluxSource.H new file mode 100644 index 0000000000000000000000000000000000000000..699c5214c0c52407e96d3d9ebbbc1b1c0c9c9c24 --- /dev/null +++ b/src/faOptions/sources/derived/contactHeatFluxSource/contactHeatFluxSource.H @@ -0,0 +1,196 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +Class + Foam::fa::contactHeatFluxSource + +Group + grpFaOptionsSources + +Description + Applies contact heat flux between specified \c faMesh + and \c fvMesh within a specified region for compressible flows. + +Usage + Minimal example by using \c constant/faOptions: + \verbatim + contactHeatFluxSource1 + { + // Mandatory entries (unmodifiable) + type contactHeatFluxSource; + Tprimary <TprimaryFieldName>; + + // Optional entries (runtime modifiable) + T <Tname>; + thicknessLayers (<layer1> <layer2> ... <layerN>); + + // Conditional optional entries (runtime modifiable) + + // when the entry "thicknessLayers" is present + kappaLayers (<layer1> <layer2> ... <layerN>); + + // Mandatory/Optional (inherited) entries + ... + } + \endverbatim + + where the entries mean: + \table + Property | Description | Type | Reqd | Dflt + type | Type name: contactHeatFluxSource | word | yes | - + Tprimary | Name of primary temperature field | word | yes | - + T | Name of operand temperature field | word | no | T + thicknessLayers | List of thicknesses of layers | scalarList | no | - + kappaLayers | List of conductivities of layers | scalarList | cndtnl | - + \endtable + + The inherited entries are elaborated in: + - \link faOption.H \endlink + - \link faceSetOption.H \endlink + - \link temperatureCoupledBase.H \endlink + +SourceFiles + contactHeatFluxSource.C + +\*---------------------------------------------------------------------------*/ + +#ifndef fa_contactHeatFluxSource_H +#define fa_contactHeatFluxSource_H + +#include "faOption.H" +#include "Function1.H" +#include "areaFields.H" +#include "faceSetOption.H" +#include "temperatureCoupledBase.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace fa +{ + +/*---------------------------------------------------------------------------*\ + Class contactHeatFluxSource Declaration +\*---------------------------------------------------------------------------*/ + +class contactHeatFluxSource +: + public faceSetOption, + public temperatureCoupledBase +{ + // Private Data + + //- Name of temperature field + word TName_; + + //- Name of primary temperature field + word TprimaryName_; + + //- Primary region temperature + const volScalarField& Tp_; + + //- Temperature - wall [K] + areaScalarField Tw1_; + + //- Thickness of layers + scalarList thicknessLayers_; + + //- Conductivity of layers + scalarList kappaLayers_; + + //- Total contact resistance + scalar contactRes_; + + //- Current time index (used for updating) + label curTimeIndex_; + + + // Private Member Functions + + //- Return htc from the primary region + tmp<areaScalarField> htc() const; + + +public: + + //- Runtime type information + TypeName("contactHeatFluxSource"); + + + // Constructors + + //- Construct from explicit source name and mesh + contactHeatFluxSource + ( + const word& sourceName, + const word& modelType, + const dictionary& dict, + const fvPatch& patch + ); + + //- No copy construct + contactHeatFluxSource(const contactHeatFluxSource&) = delete; + + //- No copy assignment + void operator=(const contactHeatFluxSource&) = delete; + + + //- Destructor + virtual ~contactHeatFluxSource() = default; + + + // Member Functions + + // Evaluation + + //- Add explicit contribution to compressible momentum equation + virtual void addSup + ( + const areaScalarField& h, + const areaScalarField& rho, + faMatrix<scalar>& eqn, + const label fieldi + ); + + + // IO + + //- Read source dictionary + virtual bool read(const dictionary& dict); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace fa +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +#endif + +// ************************************************************************* // diff --git a/src/faOptions/sources/derived/externalFileSource/externalFileSource.C b/src/faOptions/sources/derived/externalFileSource/externalFileSource.C new file mode 100644 index 0000000000000000000000000000000000000000..f5a95479d23288d4df5861a6b943fcbbd405d045 --- /dev/null +++ b/src/faOptions/sources/derived/externalFileSource/externalFileSource.C @@ -0,0 +1,130 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "externalFileSource.H" +#include "faMatrices.H" +#include "faCFD.H" +#include "zeroGradientFaPatchFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + +namespace Foam +{ +namespace fa +{ + defineTypeNameAndDebug(externalFileSource, 0); + addToRunTimeSelectionTable(option, externalFileSource, dictionary); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::fa::externalFileSource::externalFileSource +( + const word& sourceName, + const word& modelType, + const dictionary& dict, + const fvPatch& p +) +: + faceSetOption(sourceName, modelType, dict, p), + fieldName_(dict.get<word>("fieldName")), + tableName_(dict.get<word>("tableName")), + pExt_ + ( + IOobject + ( + "pExt", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + regionMesh(), + dimensionedScalar("pExt", dimPressure, Zero), + zeroGradientFaPatchScalarField::typeName + ), + value_ + ( + new PatchFunction1Types::MappedFile<scalar> + ( + p.patch(), + "uniformValue", + dict, + tableName_, // field table name + true // face values + ) + ), + curTimeIndex_(-1) +{ + fieldNames_.setSize(1, fieldName_); + + applied_.setSize(fieldNames_.size(), false); + + read(dict); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::fa::externalFileSource::addSup +( + const areaScalarField& solidMass, + faMatrix<scalar>& eqn, + const label fieldi +) +{ + const scalar t = mesh().time().value(); + + if (isActive() && t > timeStart() && t < (timeStart() + duration())) + { + DebugInfo<< name() << ": applying source to " << eqn.psi().name()<<endl; + + if (curTimeIndex_ != mesh().time().timeIndex()) + { + pExt_.field() = value_->value(t); + eqn += pExt_/solidMass; + curTimeIndex_ = mesh().time().timeIndex(); + } + } +} + + +bool Foam::fa::externalFileSource::read(const dictionary& dict) +{ + if (option::read(dict)) + { + return true; + } + + return false; +} + + +// ************************************************************************* // diff --git a/src/faOptions/sources/derived/externalFileSource/externalFileSource.H b/src/faOptions/sources/derived/externalFileSource/externalFileSource.H new file mode 100644 index 0000000000000000000000000000000000000000..6d6c0ec2dadfd0feed004bf0a6808d07a1709959 --- /dev/null +++ b/src/faOptions/sources/derived/externalFileSource/externalFileSource.H @@ -0,0 +1,169 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +Class + Foam::fa::externalFileSource + +Group + grpFaOptionsSources + +Description + Applies sources on a specified field within a specified region + by using an external table file for compressible flows. + +Usage + Minimal example by using \c constant/faOptions: + \verbatim + externalFileSource1 + { + // Mandatory entries (unmodifiable) + type externalFileSource; + fieldName <fieldName>; + tableName <tableFileName.dat>; + + // Mandatory/Optional (inherited) entries + ... + } + \endverbatim + + where the entries mean: + \table + Property | Description | Type | Reqd | Dflt + type | Type name: externalFileSource | word | yes | - + fieldName | Name of operand field | word | yes | - + tableName | Name of operand table file | word | yes | - + \endtable + + The inherited entries are elaborated in: + - \link faOption.H \endlink + - \link faceSetOption.H \endlink + +See also + - Foam::PatchFunction1Types + +SourceFiles + externalFileSource.C + +\*---------------------------------------------------------------------------*/ + +#ifndef fa_externalFileSource_H +#define fa_externalFileSource_H + +#include "faOption.H" +#include "areaFields.H" +#include "faceSetOption.H" +#include "MappedFile.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace fa +{ + +/*---------------------------------------------------------------------------*\ + Class externalFileSource Declaration +\*---------------------------------------------------------------------------*/ + +class externalFileSource +: + public faceSetOption +{ + // Private Data + + //- Name of the field to apply this source + word fieldName_; + + //- Name of the table + word tableName_; + + //- External pressure field + areaScalarField pExt_; + + //- Mapped data from file + autoPtr<PatchFunction1Types::MappedFile<scalar>> value_; + + //- Current time index (used for updating) + label curTimeIndex_; + + +public: + + //- Runtime type information + TypeName("externalFileSource"); + + + // Constructors + + //- Construct from explicit source name and mesh + externalFileSource + ( + const word& sourceName, + const word& modelType, + const dictionary& dict, + const fvPatch& patch + ); + + //- No copy construct + externalFileSource(const externalFileSource&) = delete; + + //- No copy assignment + void operator=(const externalFileSource&) = delete; + + + //- Destructor + virtual ~externalFileSource() = default; + + + // Member Functions + + // Evaluation + + //- Add explicit contribution to compressible momentum equation + virtual void addSup + ( + const areaScalarField& rho, + faMatrix<scalar>& eqn, + const label fieldi + ); + + + // IO + + //- Read source dictionary + virtual bool read(const dictionary& dict); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace fa +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/faOptions/sources/derived/externalHeatFluxSource/externalHeatFluxSource.C b/src/faOptions/sources/derived/externalHeatFluxSource/externalHeatFluxSource.C new file mode 100644 index 0000000000000000000000000000000000000000..478fc81b5cecb3f82c4b78f4e05cf0ded6076f02 --- /dev/null +++ b/src/faOptions/sources/derived/externalHeatFluxSource/externalHeatFluxSource.C @@ -0,0 +1,208 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "externalHeatFluxSource.H" +#include "addToRunTimeSelectionTable.H" +#include "physicoChemicalConstants.H" +#include "zeroGradientFaPatchFields.H" +#include "addToRunTimeSelectionTable.H" + +using Foam::constant::physicoChemical::sigma; + +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + +namespace Foam +{ +namespace fa +{ + defineTypeNameAndDebug(externalHeatFluxSource, 0); + addToRunTimeSelectionTable(option, externalHeatFluxSource, dictionary); +} +} + + +const Foam::Enum +< + Foam::fa::externalHeatFluxSource::operationMode +> +Foam::fa::externalHeatFluxSource::operationModeNames +({ + { operationMode::fixedPower, "power" }, + { operationMode::fixedHeatFlux, "flux" }, + { operationMode::fixedHeatTransferCoeff, "coefficient" }, +}); + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::fa::externalHeatFluxSource::externalHeatFluxSource +( + const word& sourceName, + const word& modelType, + const dictionary& dict, + const fvPatch& patch +) +: + faceSetOption(sourceName, modelType, dict, patch), + mode_(operationModeNames.get("mode", dict)), + TName_(dict.getOrDefault<word>("T", "T")), + Q_(0), + q_(0), + h_(0), + Ta_(), + emissivity_(dict.getOrDefault<scalar>("emissivity", 0)) +{ + fieldNames_.setSize(1, TName_); + + applied_.setSize(fieldNames_.size(), false); + + read(dict); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::fa::externalHeatFluxSource::addSup +( + const areaScalarField& h, + const areaScalarField& rho, + faMatrix<scalar>& eqn, + const label fieldi +) +{ + if (isActive()) + { + DebugInfo<< name() << ": applying source to " + << eqn.psi().name() << endl; + + IOobject io + ( + "Q", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ); + + auto tQ = new areaScalarField + ( + io, + regionMesh(), + dimensionedScalar("q", dimPower/sqr(dimLength), 0), + zeroGradientFaPatchScalarField::typeName + ); + areaScalarField& Q = *tQ; + + switch (mode_) + { + case fixedPower: + { + Q.primitiveFieldRef() = Q_/regionMesh().S().field(); + eqn += Q; + + break; + } + case fixedHeatFlux: + { + Q.primitiveFieldRef() = q_; + eqn += Q; + break; + } + case fixedHeatTransferCoeff: + { + const dimensionedScalar Ta + ( + "Ta", + dimTemperature, + Ta_->value(mesh_.time().timeOutputValue()) + ); + + areaScalarField hp + ( + io, + regionMesh(), + dimensionedScalar + ( + "h", + dimPower/sqr(dimLength)/dimTemperature, + h_ + ) + ); + + const areaScalarField hpTa(hp*Ta); + + if (emissivity_ > 0) + { + hp -= emissivity_*sigma.value()*pow3(eqn.psi()); + } + + eqn -= fam::SuSp(hp, eqn.psi()) - hpTa; + + } + } + } +} + + +bool Foam::fa::externalHeatFluxSource::read(const dictionary& dict) +{ + if (option::read(dict)) + { + dict.readIfPresent("T", TName_); + dict.readIfPresent("emissivity", emissivity_); + + mode_ = operationModeNames.get("mode", dict); + + switch (mode_) + { + case fixedPower: + { + dict.readEntry("Q", Q_); + break; + } + case fixedHeatFlux: + { + dict.readEntry("q", q_); + break; + } + case fixedHeatTransferCoeff: + { + dict.readEntry("h", h_); + Ta_ = Function1<scalar>::New("Ta", dict); + break; + } + } + + return true; + } + + return false; +} + + +// ************************************************************************* // diff --git a/src/faOptions/sources/derived/externalHeatFluxSource/externalHeatFluxSource.H b/src/faOptions/sources/derived/externalHeatFluxSource/externalHeatFluxSource.H new file mode 100644 index 0000000000000000000000000000000000000000..97873b29ffd9fbd0178c9c12e896960646424624 --- /dev/null +++ b/src/faOptions/sources/derived/externalHeatFluxSource/externalHeatFluxSource.H @@ -0,0 +1,241 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +Class + Foam::fa::externalHeatFluxSource + +Group + grpFaOptionsSources + +Description + Applies a heat flux condition for a specified \c faMesh region + to temperature on an external wall for compressible flows + in one of three modes: + + - fixed power: supply \c Q + - fixed heat flux: supply \c q + - fixed heat transfer coefficient: supply \c h and \c Ta + + where + \vartable + Q | Power [W] + q | Heat flux [W/m^2] + h | Heat transfer coefficient [W/m^2/K] + Ta | Ambient temperature [K] + \endvartable + + The ambient temperature \c Ta is specified + as a \c Foam::Function1 of time but uniform in space. + +Usage + Minimal example by using \c constant/faOptions: + \verbatim + externalHeatFluxSource1 + { + // Mandatory entries (unmodifiable) + type externalHeatFluxSource; + + // Mandatory entries (runtime modifiable) + mode <mode>; + + // Optional entries (runtime modifiable) + T <Tname>; + emissivity 0; + + // Conditional mandatory entries (runtime modifiable) + + // when mode=power + Q 1.0; + + // when mode=flux + q 1.0; + + // when mode=coefficient + h 1.0; + Ta <Function1>; + + // Mandatory/Optional (inherited) entries + ... + } + \endverbatim + + where the entries mean: + \table + Property | Description | Type | Reqd | Dflt + type | Type name: externalHeatFluxSource | word | yes | - + mode | Mode of heat flux condition | word | yes | - + T | Name of operand temperature field | word | no | T + emissivity | Surface emissivity for radiative flux to ambient <!-- + --> | scalar | no | 0 + Q | Fixed heat power [W] | scalar | cndtnl | - + q | Fixed heat flux [W/m2] | scalar | cndtnl | - + h | Heat transfer coefficient [W/m^2/K] | scalar | cndtnl | - + Ta | Ambient temperature [K] | Function1 | cndtnl | - + \endtable + + The inherited entries are elaborated in: + - \link faOption.H \endlink + - \link faceSetOption.H \endlink + + Options for the \c mode entry: + \verbatim + power | Use fixed power (supply Q) + flux | Use fixed heat flux (supply q) + coefficient | Use fixes heat transfer coefficient (supply h and T) + \endverbatim + +See also + - Foam::Function1 + +SourceFiles + externalHeatFluxSource.C + +\*---------------------------------------------------------------------------*/ + +#ifndef fa_externalHeatFluxSource_H +#define fa_externalHeatFluxSource_H + +#include "faOption.H" +#include "Function1.H" +#include "areaFields.H" +#include "faceSetOption.H" +#include "faCFD.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace fa +{ + +/*---------------------------------------------------------------------------*\ + Class externalHeatFluxSource Declaration +\*---------------------------------------------------------------------------*/ + +class externalHeatFluxSource +: + public faceSetOption +{ +public: + + // Public Enumeration + + //- Options for the heat transfer condition mode + enum operationMode + { + fixedPower, //!< Fixed heat power [W] + fixedHeatFlux, //!< Fixed heat flux [W/m2] + fixedHeatTransferCoeff, //!< Fixed heat transfer coefficient + }; + + //- Names for operationMode + static const Enum<operationMode> operationModeNames; + + +private: + + // Private Data + + //- Operation mode + operationMode mode_; + + //- Name of temperature field + word TName_; + + //- Heat power [W] + scalar Q_; + + //- Heat flux [W/m2] + scalar q_; + + //- Heat transfer coefficient [W/m2K] + scalar h_; + + //- Ambient temperature [K] + autoPtr<Function1<scalar>> Ta_; + + //- Optional surface emissivity for radiative transfer to ambient + scalar emissivity_; + + +public: + + //- Runtime type information + TypeName("externalHeatFluxSource"); + + + // Constructors + + //- Construct from explicit source name and mesh + externalHeatFluxSource + ( + const word& sourceName, + const word& modelType, + const dictionary& dict, + const fvPatch& patch + ); + + //- No copy construct + externalHeatFluxSource(const externalHeatFluxSource&) = delete; + + //- No copy assignment + void operator=(const externalHeatFluxSource&) = delete; + + + //- Destructor + virtual ~externalHeatFluxSource() = default; + + + // Member Functions + + // Evaluation + + //- Add explicit contribution to compressible momentum equation + virtual void addSup + ( + const areaScalarField& h, + const areaScalarField& rho, + faMatrix<scalar>& eqn, + const label fieldi + ); + + + // IO + + //- Read source dictionary + virtual bool read(const dictionary& dict); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace fa +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C b/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C new file mode 100644 index 0000000000000000000000000000000000000000..2d9cfc63218bb8a7993052feb939d735caa5d8e8 --- /dev/null +++ b/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C @@ -0,0 +1,193 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "jouleHeatingSource.H" +#include "faMatrices.H" +#include "faCFD.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + +namespace Foam +{ +namespace fa +{ + defineTypeNameAndDebug(jouleHeatingSource, 0); + addToRunTimeSelectionTable(option, jouleHeatingSource, dictionary); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::fa::jouleHeatingSource::jouleHeatingSource +( + const word& sourceName, + const word& modelType, + const dictionary& dict, + const fvPatch& patch +) +: + faceSetOption(sourceName, modelType, dict, patch), + TName_(dict.getOrDefault<word>("T", "T")), + V_ + ( + IOobject + ( + typeName + ":V_" + regionName_, + mesh().time().timeName(), + mesh(), + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + regionMesh() + ), + scalarSigmaVsTPtr_(nullptr), + tensorSigmaVsTPtr_(nullptr), + curTimeIndex_(-1), + nIter_(1), + anisotropicElectricalConductivity_(false) +{ + fieldNames_.setSize(1, TName_); + + applied_.setSize(fieldNames_.size(), false); + + if (anisotropicElectricalConductivity_) + { + Info<< " Using tensor electrical conductivity" << endl; + + initialiseSigma(coeffs_, tensorSigmaVsTPtr_); + } + else + { + Info<< " Using scalar electrical conductivity" << endl; + + initialiseSigma(coeffs_, scalarSigmaVsTPtr_); + } + + read(dict); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::fa::jouleHeatingSource::addSup +( + const areaScalarField& h, + const areaScalarField& rho, + faMatrix<scalar>& eqn, + const label fieldi +) +{ + if (isActive()) + { + DebugInfo<< name() << ": applying source to " << eqn.psi().name() + << endl; + + if (curTimeIndex_ != mesh().time().timeIndex()) + { + for (label i = 0; i < nIter_; ++i) + { + if (anisotropicElectricalConductivity_) + { + // Update sigma as a function of T if required + const areaTensorField& sigma = + updateSigma(tensorSigmaVsTPtr_); + + // Solve the electrical potential equation + faScalarMatrix VEqn(fam::laplacian(h*sigma, V_)); + VEqn.relax(); + VEqn.solve(); + } + else + { + // Update sigma as a function of T if required + const areaScalarField& sigma = + updateSigma(scalarSigmaVsTPtr_); + + // Solve the electrical potential equation + faScalarMatrix VEqn(fam::laplacian(h*sigma, V_)); + VEqn.relax(); + VEqn.solve(); + } + } + + curTimeIndex_ = mesh().time().timeIndex(); + } + + // Add the Joule heating contribution + areaVectorField gradV("gradV", fac::grad(V_)); + + if (anisotropicElectricalConductivity_) + { + const auto& sigma = + mesh_.lookupObject<areaTensorField> + ( + typeName + ":sigma_" + regionName_ + ); + + eqn += (h*sigma & gradV) & gradV; + } + else + { + const auto& sigma = + mesh_.lookupObject<areaScalarField> + ( + typeName + ":sigma_" + regionName_ + ); + + eqn += (h*sigma*gradV) & gradV; + + if (mesh().time().outputTime() && debug) + { + areaScalarField qgradV("gradVSource", (gradV & gradV)); + qgradV.write(); + } + } + } +} + + +bool Foam::fa::jouleHeatingSource::read(const dictionary& dict) +{ + if (option::read(dict)) + { + dict.readIfPresent("T", TName_); + + dict.readIfPresent("nIter", nIter_); + + anisotropicElectricalConductivity_ = + dict.get<bool>("anisotropicElectricalConductivity"); + + return true; + } + + return false; +} + + +// ************************************************************************* // diff --git a/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.H b/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.H new file mode 100644 index 0000000000000000000000000000000000000000..4a5a279a145362059d9906fdd3dd5fc1f647c723 --- /dev/null +++ b/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.H @@ -0,0 +1,265 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +Class + Foam::fa::jouleHeatingSource + +Group + grpFaOptionsSources + +Description + Evolves an electrical potential equation + + \f[ + \grad \left( \sigma \grad V \right) + \f] + + where \f$ V \f$ is electrical potential + and \f$\sigma\f$ is the electrical current. + + To provide a Joule heating contribution according to: + + Differential form of Joule heating - power per unit volume: + + \f[ + \frac{d(P)}{d(V)} = J \cdot E + \f] + + where \f$ J \f$ is the current density and \f$ E \f$ the electric field. + If no magnetic field is present: + + \f[ + J = \sigma E + \f] + + The electric field given by + + \f[ + E = \grad V + \f] + + Therefore: + + \f[ + \frac{d(P)}{d(V)} = J \cdot E + = (sigma E) \cdot E + = (sigma \grad V) \cdot \grad V + \f] + +Usage + Minimal example by using \c constant/faOptions: + \verbatim + jouleHeatingSource1 + { + // Mandatory entries (unmodifiable) + type jouleHeatingSource; + + // Mandatory entries (runtime modifiable) + anisotropicElectricalConductivity true; + + // Optional entries (runtime modifiable) + T <Tname>; + nIter -1; + + // Conditional mandatory entries (runtime modifiable) + + // when the entry "sigma" is present + sigma <Function1>; + + // when when the entry "sigma" is not present + // read "sigma" from file + + // Mandatory/Optional (inherited) entries + ... + } + \endverbatim + + where the entries mean: + \table + Property | Description | Type | Reqd | Dflt + type | Type name: jouleHeatingSource | word | yes | - + anisotropicElectricalConductivity | Flag to indicate that <!-- + --> if the electrical conductivity is anisotropic <!-- + --> | bool | yes | - + T | Name of operand temperature field | word | no | T + sigma | Electrical conductivity as a function of temperature <!-- + --> | table | no | - + nIter | Number of iterations for electrical potential equation <!-- + --> solution | label | no | -1 + \endtable + + The inherited entries are elaborated in: + - \link faOption.H \endlink + - \link faceSetOption.H \endlink + +Note + - \c anisotropicElectricalConductivity=true enables + anisotropic (tensorial) electrical conductivity. + - \c anisotropicElectricalConductivity=false enables + isotropic (scalar) electrical conductivity. + - The electrical conductivity can be specified using either: + - If the \c sigma entry is present the electrical conductivity is specified + as a function of temperature using a \c Function1 type. + - If not present the \c sigma field will be read from file. + - If the \c anisotropicElectricalConductivity flag is set to \c true, + \c sigma should be specified as a tensor quantity. + +See also + - Foam::Function1 + +SourceFiles + jouleHeatingSource.C + jouleHeatingSourceTemplates.C + +\*---------------------------------------------------------------------------*/ + +#ifndef fa_jouleHeatingSource_H +#define fa_jouleHeatingSource_H + +#include "faOption.H" +#include "Function1.H" +#include "areaFields.H" +#include "faceSetOption.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace fa +{ + +/*---------------------------------------------------------------------------*\ + Class jouleHeatingSource Declaration +\*---------------------------------------------------------------------------*/ + +class jouleHeatingSource +: + public faceSetOption +{ + // Private Data + + //- Name of temperature field + word TName_; + + //- Electrical potential field / [V] + areaScalarField V_; + + //- Electrical conductivity as a scalar function of temperature + autoPtr<Function1<scalar>> scalarSigmaVsTPtr_; + + //- Electrical conductivity as a tensor function of temperature + autoPtr<Function1<tensor>> tensorSigmaVsTPtr_; + + //- Current time index (used for updating) + label curTimeIndex_; + + //- Number of iterations for electrical potential equation solution + label nIter_; + + //- Flag to indicate that the electrical conductivity is anisotropic + bool anisotropicElectricalConductivity_; + + + // Private Member Functions + + //- Initialise the electrical conductivity field + template<class Type> + void initialiseSigma + ( + const dictionary& dict, + autoPtr<Function1<Type>>& sigmaVsTPtr + ); + + //- Update the electrical conductivity field + template<class Type> + const GeometricField<Type, faPatchField, areaMesh>& + updateSigma(const autoPtr<Function1<Type>>& sigmaVsTPtr) const; + + +public: + + //- Runtime type information + TypeName("jouleHeatingSource"); + + + // Constructors + + //- Construct from explicit source name and mesh + jouleHeatingSource + ( + const word& sourceName, + const word& modelType, + const dictionary& dict, + const fvPatch& patch + ); + + //- No copy construct + jouleHeatingSource(const jouleHeatingSource&) = delete; + + //- No copy assignment + void operator=(const jouleHeatingSource&) = delete; + + + //- Destructor + virtual ~jouleHeatingSource() = default; + + + // Member Functions + + // Evaluation + + //- Add explicit contribution to compressible momentum equation + virtual void addSup + ( + const areaScalarField& h, + const areaScalarField& rho, + faMatrix<scalar>& eqn, + const label fieldi + ); + + + // IO + + //- Read source dictionary + virtual bool read(const dictionary& dict); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace fa +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "jouleHeatingSourceTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C b/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C new file mode 100644 index 0000000000000000000000000000000000000000..55f8b8da199658e6b598129d0d9172904236e013 --- /dev/null +++ b/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C @@ -0,0 +1,140 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "emptyFaPatch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class Type> +void Foam::fa::jouleHeatingSource::initialiseSigma +( + const dictionary& dict, + autoPtr<Function1<Type>>& sigmaVsTPtr +) +{ + typedef GeometricField<Type, faPatchField, areaMesh> AreaFieldType; + + if (dict.found("sigma")) + { + // Sigma to be defined using a Function1 type + sigmaVsTPtr = Function1<Type>::New("sigma", dict); + + auto tsigma = tmp<AreaFieldType>::New + ( + IOobject + ( + typeName + ":sigma_" + regionName_, + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + regionMesh(), + dimensioned<Type>(sqr(dimCurrent)/dimPower/dimLength, Zero) + ); + + mesh_.objectRegistry::store(tsigma.ptr()); + + Info<< " Conductivity 'sigma' read from dictionary as f(T)" + << nl << endl; + } + else + { + // Sigma to be defined by user input + auto tsigma = tmp<AreaFieldType>::New + ( + IOobject + ( + typeName + ":sigma_" + regionName_, + mesh().time().timeName(), + mesh(), + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + regionMesh() + ); + + mesh().objectRegistry::store(tsigma.ptr()); + + Info<< " Conductivity 'sigma' read from file" << nl << endl; + } +} + + +template<class Type> +const Foam::GeometricField<Type, Foam::faPatchField, Foam::areaMesh>& +Foam::fa::jouleHeatingSource::updateSigma +( + const autoPtr<Function1<Type>>& sigmaVsTPtr +) const +{ + typedef GeometricField<Type, faPatchField, areaMesh> AreaFieldType; + + auto& sigma = + mesh().lookupObjectRef<AreaFieldType> + ( + typeName + ":sigma_" + regionName_ + ); + + if (!sigmaVsTPtr.valid()) + { + // Electrical conductivity field, sigma, was specified by the user + return sigma; + } + + const auto& T = mesh().lookupObject<areaScalarField>(TName_); + + // Internal field + forAll(sigma, i) + { + sigma[i] = sigmaVsTPtr->value(T[i]); + } + + + // Boundary field + typename AreaFieldType::Boundary& bf = sigma.boundaryFieldRef(); + forAll(bf, patchi) + { + faPatchField<Type>& pf = bf[patchi]; + if (!isA<emptyFaPatch>(bf[patchi])) + { + const scalarField& Tbf = T.boundaryField()[patchi]; + forAll(pf, facei) + { + pf[facei] = sigmaVsTPtr->value(Tbf[facei]); + } + } + } + + // Update processor patches + sigma.correctBoundaryConditions(); + + return sigma; +} + + +// ************************************************************************* // diff --git a/src/finiteArea/Make/files b/src/finiteArea/Make/files index 631570b62c043b050934969b006e9329fda1309e..a61dab59417d2d266df98a37ba0a533079b2bcb5 100644 --- a/src/finiteArea/Make/files +++ b/src/finiteArea/Make/files @@ -48,7 +48,8 @@ $(derivedFaPatchFields)/fixedValueOutflow/fixedValueOutflowFaPatchFields.C $(derivedFaPatchFields)/inletOutlet/inletOutletFaPatchFields.C $(derivedFaPatchFields)/slip/slipFaPatchFields.C $(derivedFaPatchFields)/edgeNormalFixedValue/edgeNormalFixedValueFaPatchVectorField.C -$(derivedFaPatchFields)/uniformFixedValue/uniformFixedValueFaPatchFields.C +$(derivedFaPatchFields)/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchFields.C +$(derivedFaPatchFields)/clampedPlate/clampedPlateFaPatchFields.C faePatchFields = fields/faePatchFields $(faePatchFields)/faePatchField/faePatchFields.C @@ -81,6 +82,7 @@ $(schemes)/upwind/upwindEdgeInterpolationMake.C $(schemes)/linearUpwind/linearUpwindEdgeInterpolationMake.C $(schemes)/Gamma/GammaEdgeInterpolationMake.C $(schemes)/blended/blendedEdgeInterpolationMake.C +$(schemes)/skewCorrected/skewCorrectedEdgeInterpolationMake.C finiteArea/fa/fa.C finiteArea/faSchemes/faSchemes.C diff --git a/src/finiteArea/faMesh/faPatches/faPatch/faPatch.C b/src/finiteArea/faMesh/faPatches/faPatch/faPatch.C index 2c954b2eea8917773061527d2a9878e975733e16..52f7a3ba6247d45e950bb2f58e34282bd940a269 100644 --- a/src/finiteArea/faMesh/faPatches/faPatch/faPatch.C +++ b/src/finiteArea/faMesh/faPatches/faPatch/faPatch.C @@ -343,8 +343,8 @@ Foam::tmp<Foam::vectorField> Foam::faPatch::ngbPolyPatchPointNormals() const const labelListList& pntEdges = pointEdges(); - tmp<vectorField> tpN(new vectorField(pntEdges.size(), Zero)); - vectorField& pN = tpN.ref(); + auto tpN = tmp<vectorField>::New(pntEdges.size(), Zero); + auto& pN = tpN.ref(); const vectorField faceNormals(ngbPolyPatchFaceNormals()); @@ -406,8 +406,8 @@ Foam::tmp<Foam::vectorField> Foam::faPatch::edgeNormals() const Foam::tmp<Foam::vectorField> Foam::faPatch::edgeFaceCentres() const { - tmp<vectorField> tfc(new vectorField(size())); - vectorField& fc = tfc.ref(); + auto tfc = tmp<vectorField>::New(size()); + auto& fc = tfc.ref(); // get reference to global face centres const vectorField& gfc = @@ -427,13 +427,22 @@ Foam::tmp<Foam::vectorField> Foam::faPatch::edgeFaceCentres() const Foam::tmp<Foam::vectorField> Foam::faPatch::delta() const { return edgeNormals()*(edgeNormals() & (edgeCentres() - edgeFaceCentres())); - //return edgeCentres() - edgeFaceCentres(); } void Foam::faPatch::makeDeltaCoeffs(scalarField& dc) const { - dc = 1.0/(edgeNormals() & delta()); + dc = scalar(1)/(edgeNormals() & delta()); +} + + +void Foam::faPatch::makeCorrectionVectors(vectorField& k) const +{ + vectorField unitDelta(delta()/mag(delta())); + vectorField edgeNormMag(edgeNormals()/mag(edgeNormals())); + scalarField dn(edgeNormals() & delta()); + + k = edgeNormMag - (scalar(1)/(unitDelta & edgeNormMag))*unitDelta; } @@ -445,7 +454,7 @@ const Foam::scalarField& Foam::faPatch::deltaCoeffs() const void Foam::faPatch::makeWeights(scalarField& w) const { - w = 1.0; + w = scalar(1); } diff --git a/src/finiteArea/faMesh/faPatches/faPatch/faPatch.H b/src/finiteArea/faMesh/faPatches/faPatch/faPatch.H index a3d6239faa59df5105c13e2795a859b4ee582cdd..52fb33e613a85966c8978da476aa6d4dca8718ea 100644 --- a/src/finiteArea/faMesh/faPatches/faPatch/faPatch.H +++ b/src/finiteArea/faMesh/faPatches/faPatch/faPatch.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 Wikki Ltd + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -35,7 +36,9 @@ Author SourceFiles faPatch.C - newFaPatch.C + faPatchNew.C + faPatchTemplates.C + faPatchFaMeshTemplates.C \*---------------------------------------------------------------------------*/ @@ -68,9 +71,7 @@ class faPatch public labelList, public patchIdentifier { -private: - - // Private data + // Private Data //- Neighbour polyPatch index const label ngbPolyPatchIndex_; @@ -106,6 +107,8 @@ private: protected: + // Protected Member Functions + //- The faPatch geometry initialisation is called by faBoundaryMesh friend class faBoundaryMesh; @@ -143,7 +146,6 @@ public: typedef faBoundaryMesh BoundaryMesh; - //- Runtime type information TypeName("patch"); @@ -189,7 +191,7 @@ public: faPatch(const faPatch&, const faBoundaryMesh&); //- Construct and return a clone, resetting the edge list - // and boundary mesh + //- and boundary mesh virtual autoPtr<faPatch> clone ( const faBoundaryMesh& bm, @@ -207,7 +209,7 @@ public: // Selectors //- Return a pointer to a new patch created - // on freestore from dictionary + //- on freestore from dictionary static autoPtr<faPatch> New ( const word& name, @@ -320,6 +322,8 @@ public: //- Make patch edge - neighbour face distances virtual void makeDeltaCoeffs(scalarField&) const; + void makeCorrectionVectors(vectorField&) const; + //- Return patch edge - neighbour face distances const scalarField& deltaCoeffs() const; @@ -330,7 +334,7 @@ public: void resetEdges(const labelList&); - // Evaluation functions + // Evaluation //- Return given internal field next to patch as patch field template<class Type> @@ -344,7 +348,7 @@ public: ) const; //- Lookup and return the patchField of the named field from the - // local objectRegistry. + //- local objectRegistry. // N.B. The dummy pointer arguments are used if this function is // instantiated within a templated function to avoid a bug in gcc. // See inletOutletFvPatchField.C and outletInletFvPatchField.C diff --git a/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchField.C b/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchField.C new file mode 100755 index 0000000000000000000000000000000000000000..d4f257b80e7bd3606546dd1a8e5c2ef7ad09fefd --- /dev/null +++ b/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchField.C @@ -0,0 +1,179 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/> + +\*---------------------------------------------------------------------------*/ + +#include "clampedPlateFaPatchField.H" +#include "areaFields.H" +#include "uniformDimensionedFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type> +clampedPlateFaPatchField<Type>::clampedPlateFaPatchField +( + const faPatch& p, + const DimensionedField<Type, areaMesh>& iF +) +: + faPatchField<Type>(p, iF) +{} + + +template<class Type> +clampedPlateFaPatchField<Type>::clampedPlateFaPatchField +( + const faPatch& p, + const DimensionedField<Type, areaMesh>& iF, + const dictionary& dict +) +: + faPatchField<Type>(p, iF) +{ + faPatchField<Type>::operator=(this->patchInternalField()); +} + + +template<class Type> +clampedPlateFaPatchField<Type>::clampedPlateFaPatchField +( + const clampedPlateFaPatchField<Type>& ptf, + const faPatch& p, + const DimensionedField<Type, areaMesh>& iF, + const faPatchFieldMapper& mapper +) +: + faPatchField<Type>(ptf, p, iF, mapper) +{} + + +template<class Type> +clampedPlateFaPatchField<Type>::clampedPlateFaPatchField +( + const clampedPlateFaPatchField<Type>& ptf +) +: + faPatchField<Type>(ptf) +{} + + +template<class Type> +clampedPlateFaPatchField<Type>::clampedPlateFaPatchField +( + const clampedPlateFaPatchField<Type>& ptf, + const DimensionedField<Type, areaMesh>& iF +) +: + faPatchField<Type>(ptf, iF) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type> +void clampedPlateFaPatchField<Type>::evaluate(const Pstream::commsTypes) +{ + notImplemented(type() + "::evaluate(const Pstream::commsType)"); +} + + +template<> +void clampedPlateFaPatchField<scalar>::evaluate(const Pstream::commsTypes) +{ + if (!this->updated()) + { + this->updateCoeffs(); + } + + Field<scalar>::operator=(pTraits<scalar>::zero); + + const labelUList& edgeFaces = this->patch().edgeFaces(); + forAll(edgeFaces, edgeID) + { + label faceID = edgeFaces[edgeID]; + const_cast<Field<scalar>&>(this->primitiveField())[faceID] = + pTraits<scalar>::zero; + } + + faPatchField<scalar>::evaluate(); +} + + +template<class Type> +tmp<Field<Type> > clampedPlateFaPatchField<Type>::valueInternalCoeffs +( + const tmp<scalarField>& +) const +{ + return tmp<Field<Type>> + (new Field<Type>(this->size(), pTraits<Type>::zero)); +} + + +template<class Type> +tmp<Field<Type> > clampedPlateFaPatchField<Type>::valueBoundaryCoeffs +( + const tmp<scalarField>& +) const +{ + return *this; +} + + +template<class Type> +tmp<Field<Type> > +clampedPlateFaPatchField<Type>::gradientInternalCoeffs() const +{ + return -Type(pTraits<Type>::one)*this->patch().deltaCoeffs(); +} + + +template<class Type> +tmp<Field<Type> > +clampedPlateFaPatchField<Type>::gradientBoundaryCoeffs() const +{ + return this->patch().deltaCoeffs()*(*this); +} + + +template<class Type> +void clampedPlateFaPatchField<Type>::write(Ostream& os) const +{ + faPatchField<Type>::write(os); + this->writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchField.H b/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchField.H new file mode 100755 index 0000000000000000000000000000000000000000..4178ffb782f3e0580a1b0e12cfbd22c8408f117e --- /dev/null +++ b/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchField.H @@ -0,0 +1,214 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +Class + Foam::clampedPlateFaPatchField + +Description + This BC provides a clamped BC. It sets zero fixe value and zeroGradient. + +Usage + Example of the boundary condition specification: + \verbatim + <patchName> + { + // Mandatory entries (unmodifiable) + type clampedPlate; + + // Mandatory/Optional (inherited) entries + ... + } + \endverbatim + + where the entries mean: + \table + Property | Description | Type | Reqd | Dflt + type | Type name: clampedPlate | word | yes | - + \endtable + + The inherited entries are elaborated in: + - \link faPatchFields.H \endlink + +SourceFiles + clampedPlateFaPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef clampedPlateFaPatchField_H +#define clampedPlateFaPatchField_H + +#include "faPatchField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class clampedPlateFaPatch Declaration +\*---------------------------------------------------------------------------*/ + +template<class Type> +class clampedPlateFaPatchField +: + public faPatchField<Type> +{ +public: + + //- Runtime type information + TypeName("clampedPlate"); + + + // Constructors + + //- Construct from patch and internal field + clampedPlateFaPatchField + ( + const faPatch&, + const DimensionedField<Type, areaMesh>& + ); + + //- Construct from patch, internal field and dictionary + clampedPlateFaPatchField + ( + const faPatch&, + const DimensionedField<Type, areaMesh>&, + const dictionary& + ); + + //- Construct by mapping the given clampedPlateFaPatchField<Type> + //- onto a new patch + clampedPlateFaPatchField + ( + const clampedPlateFaPatchField<Type>&, + const faPatch&, + const DimensionedField<Type, areaMesh>&, + const faPatchFieldMapper& + ); + + //- Construct as copy + clampedPlateFaPatchField + ( + const clampedPlateFaPatchField<Type>& + ); + + //- Construct and return a clone + virtual tmp<faPatchField<Type>> clone() const + { + return tmp<faPatchField<Type>> + ( + new clampedPlateFaPatchField<Type>(*this) + ); + } + + //- Construct as copy setting internal field reference + clampedPlateFaPatchField + ( + const clampedPlateFaPatchField<Type>&, + const DimensionedField<Type, areaMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp<faPatchField<Type> > clone + ( + const DimensionedField<Type, areaMesh>& iF + ) const + { + return tmp<faPatchField<Type> > + ( + new clampedPlateFaPatchField<Type>(*this, iF) + ); + } + + + //- Destructor + virtual ~clampedPlateFaPatchField() + {} + + + // Member Functions + + // Evaluation + + //- Return gradient at boundary + virtual tmp<Field<Type>> snGrad() const + { + return tmp<Field<Type>> + ( + new Field<Type>(this->size(), Zero) + ); + } + + //- Evaluate the patch field + virtual void evaluate + ( + const Pstream::commsTypes commsType=Pstream::commsTypes::blocking + ); + + //- Return the matrix diagonal coefficients corresponding to the + //- evaluation of the value of this patchField with given weights + virtual tmp<Field<Type> > valueInternalCoeffs + ( + const tmp<scalarField>& + ) const; + + //- Return the matrix source coefficients corresponding to the + //- evaluation of the value of this patchField with given weights + virtual tmp<Field<Type> > valueBoundaryCoeffs + ( + const tmp<scalarField>& + ) const; + + //- Return the matrix diagonal coefficients corresponding to the + //- evaluation of the gradient of this patchField + virtual tmp<Field<Type> > gradientInternalCoeffs() const; + + //- Return the matrix source coefficients corresponding to the + //- evaluation of the gradient of this patchField + virtual tmp<Field<Type> > gradientBoundaryCoeffs() const; + + + // IO + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "clampedPlateFaPatchField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchFields.C b/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchFields.C old mode 100644 new mode 100755 similarity index 95% rename from src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchFields.C rename to src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchFields.C index 0647d784cc4f8dd439f211531d8ce649aa3942ea..a2bb02c72d63c109896443a4216158dde125ab8d --- a/src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchFields.C +++ b/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchFields.C @@ -21,11 +21,11 @@ License for more details. You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/> \*---------------------------------------------------------------------------*/ -#include "uniformFixedValueFaPatchFields.H" +#include "clampedPlateFaPatchFields.H" #include "addToRunTimeSelectionTable.H" #include "areaFields.H" @@ -36,7 +36,7 @@ namespace Foam // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -makeFaPatchFields(uniformFixedValue); +makeFaPatchFields(clampedPlate); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchFields.H b/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchFields.H old mode 100644 new mode 100755 similarity index 90% rename from src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchFields.H rename to src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchFields.H index 17b020ae6ddc4d31b37b69e9351a3ccb7ea750b8..4a3a05490746eef783f94f7b7b45d014556866ad --- a/src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchFields.H +++ b/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchFields.H @@ -21,14 +21,14 @@ License for more details. You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/> \*---------------------------------------------------------------------------*/ -#ifndef uniformFixedValueFaPatchFields_H -#define uniformFixedValueFaPatchFields_H +#ifndef clampedPlateFaPatchFields_H +#define clampedPlateFaPatchFields_H -#include "uniformFixedValueFaPatchField.H" +#include "clampedPlateFaPatchField.H" #include "fieldTypes.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -38,7 +38,7 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -makeFaPatchTypeFieldTypedefs(uniformFixedValue) +makeFaPatchTypeFieldTypedefs(clampedPlate) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchFieldsFwd.H b/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchFieldsFwd.H new file mode 100755 index 0000000000000000000000000000000000000000..949f510afc3c843b908e1bc57663faa41376ec61 --- /dev/null +++ b/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchFieldsFwd.H @@ -0,0 +1,52 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/> + +\*---------------------------------------------------------------------------*/ + +#ifndef clampedPlateFaPatchFieldsFwd_H +#define clampedPlateFaPatchFieldsFwd_H + +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class Type> class clampedPlateFaPatchField; + +makeFaPatchTypeFieldTypedefs(clampedPlate) + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchField.C b/src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchField.C similarity index 65% rename from src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchField.C rename to src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchField.C index 4de3a60c88849459c750bd94301d6eb106d49e0f..1bba29333b639c1b71bdbffc0283238ad29ca254 100644 --- a/src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchField.C +++ b/src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchField.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2016-2017 Wikki Ltd ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,24 +25,27 @@ License \*---------------------------------------------------------------------------*/ -#include "uniformFixedValueFaPatchField.H" +#include "timeVaryingUniformFixedValueFaPatchField.H" +#include "Time.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class Type> -Foam::uniformFixedValueFaPatchField<Type>::uniformFixedValueFaPatchField +Foam::timeVaryingUniformFixedValueFaPatchField<Type>:: +timeVaryingUniformFixedValueFaPatchField ( const faPatch& p, const DimensionedField<Type, areaMesh>& iF ) : fixedValueFaPatchField<Type>(p, iF), - uniformValue_(nullptr) + timeSeries_() {} template<class Type> -Foam::uniformFixedValueFaPatchField<Type>::uniformFixedValueFaPatchField +Foam::timeVaryingUniformFixedValueFaPatchField<Type>:: +timeVaryingUniformFixedValueFaPatchField ( const faPatch& p, const DimensionedField<Type, areaMesh>& iF, @@ -50,83 +53,85 @@ Foam::uniformFixedValueFaPatchField<Type>::uniformFixedValueFaPatchField ) : fixedValueFaPatchField<Type>(p, iF), - uniformValue_(Function1<Type>::New("uniformValue", dict)) + timeSeries_(dict) { if (dict.found("value")) { - faPatchField<Type>::operator== - ( - Field<Type>("value", dict, p.size()) - ); + faPatchField<Type>::operator==(Field<Type>("value", dict, p.size())); } else { - this->evaluate(); + updateCoeffs(); } } template<class Type> -Foam::uniformFixedValueFaPatchField<Type>::uniformFixedValueFaPatchField +Foam::timeVaryingUniformFixedValueFaPatchField<Type>:: +timeVaryingUniformFixedValueFaPatchField ( - const uniformFixedValueFaPatchField<Type>& ptf, + const timeVaryingUniformFixedValueFaPatchField<Type>& ptf, const faPatch& p, const DimensionedField<Type, areaMesh>& iF, const faPatchFieldMapper& mapper ) : fixedValueFaPatchField<Type>(ptf, p, iF, mapper), - uniformValue_(ptf.uniformValue_.clone()) + timeSeries_(ptf.timeSeries_) {} template<class Type> -Foam::uniformFixedValueFaPatchField<Type>::uniformFixedValueFaPatchField +Foam::timeVaryingUniformFixedValueFaPatchField<Type>:: +timeVaryingUniformFixedValueFaPatchField ( - const uniformFixedValueFaPatchField<Type>& ptf + const timeVaryingUniformFixedValueFaPatchField<Type>& ptf ) : fixedValueFaPatchField<Type>(ptf), - uniformValue_(ptf.uniformValue_.clone()) + timeSeries_(ptf.timeSeries_) {} template<class Type> -Foam::uniformFixedValueFaPatchField<Type>::uniformFixedValueFaPatchField +Foam::timeVaryingUniformFixedValueFaPatchField<Type>:: +timeVaryingUniformFixedValueFaPatchField ( - const uniformFixedValueFaPatchField<Type>& ptf, + const timeVaryingUniformFixedValueFaPatchField<Type>& ptf, const DimensionedField<Type, areaMesh>& iF ) : fixedValueFaPatchField<Type>(ptf, iF), - uniformValue_(ptf.uniformValue_.clone()) + timeSeries_(ptf.timeSeries_) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> -void Foam::uniformFixedValueFaPatchField<Type>::updateCoeffs() +void Foam::timeVaryingUniformFixedValueFaPatchField<Type>::updateCoeffs() { if (this->updated()) { return; } - const scalar t = this->db().time().timeOutputValue(); - faPatchField<Type>::operator==(uniformValue_->value(t)); + faPatchField<Type>::operator== + ( + timeSeries_(this->db().time().timeOutputValue()) + ); fixedValueFaPatchField<Type>::updateCoeffs(); } template<class Type> -void Foam::uniformFixedValueFaPatchField<Type>::write +void Foam::timeVaryingUniformFixedValueFaPatchField<Type>::write ( Ostream& os ) const { faPatchField<Type>::write(os); - uniformValue_->writeData(os); + timeSeries_.write(os); this->writeEntry("value", os); } diff --git a/src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchField.H b/src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchField.H similarity index 56% rename from src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchField.H rename to src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchField.H index cf75c75e166112a159166d08365a6b7f91668e8b..70154cc728ad4e21870675455d70278d735d52ae 100644 --- a/src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchField.H +++ b/src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchField.H @@ -5,6 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- + Copyright (C) 2016-2017 Wikki Ltd Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License @@ -24,42 +25,59 @@ License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. Class - Foam::uniformFixedValueFaPatchField + Foam::timeVaryingUniformFixedValueFaPatchField Description - This finiteArea boundary condition - provides a uniform fixed value condition, which can also be time-varying. + A time-varying form of a uniform fixed value finite area + boundary condition. Usage - \table - Property | Description | Required | Default - uniformValue | uniform value | yes | - \endtable - Example of the boundary condition specification: \verbatim <patchName> { - type uniformFixedValue; - uniformValue constant 0.2; + // Mandatory entries (unmodifiable) + type timeVaryingUniformFixedValue; + fileName "<case>/time-series"; + outOfBounds clamp; // (error|warn|clamp|repeat) + + // Mandatory/Optional (inherited) entries + ... } \endverbatim + where the entries mean: + \table + Property | Description | Type | Reqd | Dflt + type | Type name: timeVaryingUniformFixedValue | word | yes | - + fileName | Name of operand file | word | yes | - + \endtable + + The inherited entries are elaborated in: + - \link faPatchFields.H \endlink + +Author + Zeljko Tukovic, FMENA + Hrvoje Jasak, Wikki Ltd. + +Note + This class is derived directly from a fixedValue patch rather than from + a uniformFixedValue patch. + See also - Foam::Function1Types - Foam::fixedValueFvPatchField - Foam::uniformFixedValueFvPatchField.C + - Foam::interpolationTable + - Foam::fixedValueFaPatchField SourceFiles - uniformFixedValueFaPatchField.C + timeVaryingUniformFixedValueFaPatchField.C \*---------------------------------------------------------------------------*/ -#ifndef uniformFixedValueFaPatchField_H -#define uniformFixedValueFaPatchField_H +#ifndef timeVaryingUniformFixedValueFaPatchField_H +#define timeVaryingUniformFixedValueFaPatchField_H #include "fixedValueFaPatchField.H" -#include "Function1.H" +#include "interpolationTable.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -67,56 +85,56 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class uniformFixedValueFaPatch Declaration + Class timeVaryingUniformFixedValueFaPatch Declaration \*---------------------------------------------------------------------------*/ template<class Type> -class uniformFixedValueFaPatchField +class timeVaryingUniformFixedValueFaPatchField : public fixedValueFaPatchField<Type> { // Private Data - //- Value - autoPtr<Function1<Type>> uniformValue_; + //- The time series being used, including the bounding treatment + interpolationTable<Type> timeSeries_; public: //- Runtime type information - TypeName("uniformFixedValue"); + TypeName("timeVaryingUniformFixedValue"); // Constructors //- Construct from patch and internal field - uniformFixedValueFaPatchField + timeVaryingUniformFixedValueFaPatchField ( const faPatch&, const DimensionedField<Type, areaMesh>& ); //- Construct from patch, internal field and dictionary - uniformFixedValueFaPatchField + timeVaryingUniformFixedValueFaPatchField ( const faPatch&, const DimensionedField<Type, areaMesh>&, const dictionary& ); - //- Construct by mapping onto a new patch - uniformFixedValueFaPatchField + //- Construct by mapping given patch field onto a new patch + timeVaryingUniformFixedValueFaPatchField ( - const uniformFixedValueFaPatchField<Type>&, + const timeVaryingUniformFixedValueFaPatchField<Type>&, const faPatch&, const DimensionedField<Type, areaMesh>&, const faPatchFieldMapper& ); - //- Copy construct - uniformFixedValueFaPatchField + //- Construct as copy + timeVaryingUniformFixedValueFaPatchField ( - const uniformFixedValueFaPatchField<Type>& + const timeVaryingUniformFixedValueFaPatchField<Type>& ); //- Construct and return a clone @@ -124,14 +142,14 @@ public: { return tmp<faPatchField<Type>> ( - new uniformFixedValueFaPatchField<Type>(*this) + new timeVaryingUniformFixedValueFaPatchField<Type>(*this) ); } //- Construct as copy setting internal field reference - uniformFixedValueFaPatchField + timeVaryingUniformFixedValueFaPatchField ( - const uniformFixedValueFaPatchField<Type>&, + const timeVaryingUniformFixedValueFaPatchField<Type>&, const DimensionedField<Type, areaMesh>& ); @@ -143,22 +161,36 @@ public: { return tmp<faPatchField<Type>> ( - new uniformFixedValueFaPatchField<Type>(*this, iF) + new timeVaryingUniformFixedValueFaPatchField<Type>(*this, iF) ); } //- Destructor - virtual ~uniformFixedValueFaPatchField() = default; + virtual ~timeVaryingUniformFixedValueFaPatchField() = default; // Member Functions - //- Update the coefficients associated with the patch field - virtual void updateCoeffs(); + // Access + + //- Return the time series used + const interpolationTable<Type>& timeSeries() const + { + return timeSeries_; + } + + + // Evaluation + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + // IO - //- Write - virtual void write(Ostream& os) const; + //- Write + virtual void write(Ostream&) const; }; @@ -169,7 +201,7 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #ifdef NoRepository - #include "uniformFixedValueFaPatchField.C" + #include "timeVaryingUniformFixedValueFaPatchField.C" #endif // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchFields.C b/src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchFields.C new file mode 100644 index 0000000000000000000000000000000000000000..fa19e8c9d892ba5c9e6897e77be2bb484222e7de --- /dev/null +++ b/src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchFields.C @@ -0,0 +1,46 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2016-2017 Wikki Ltd + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "timeVaryingUniformFixedValueFaPatchFields.H" +#include "addToRunTimeSelectionTable.H" +#include "areaFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +makeFaPatchFields(timeVaryingUniformFixedValue); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchFields.H b/src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchFields.H new file mode 100644 index 0000000000000000000000000000000000000000..46bfc57c7362c388db8d82b7683d92a9f731148a --- /dev/null +++ b/src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchFields.H @@ -0,0 +1,52 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2016-2017 Wikki Ltd + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#ifndef timeVaryingUniformFixedValueFaPatchFields_H +#define timeVaryingUniformFixedValueFaPatchFields_H + +#include "timeVaryingUniformFixedValueFaPatchField.H" +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makeFaPatchTypeFieldTypedefs(timeVaryingUniformFixedValue) + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchFieldsFwd.H b/src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchFieldsFwd.H new file mode 100644 index 0000000000000000000000000000000000000000..6691ec7fc24ef6c87f651a8538f67aceb30603e7 --- /dev/null +++ b/src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchFieldsFwd.H @@ -0,0 +1,54 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2016-2017 Wikki Ltd + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#ifndef timeVaryingUniformFixedValueFaPatchFieldsFwd_H +#define timeVaryingUniformFixedValueFaPatchFieldsFwd_H + +#include "faPatchField.H" +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class Type> class timeVaryingUniformFixedValueFaPatchField; + +makeFaPatchTypeFieldTypedefs(timeVaryingUniformFixedValue); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.H b/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.H index 3818dcb2ffa8be0765f2fa4dc3c3eec3a813970e..389510504c97b5588d63b9c0442fa5c40829922d 100644 --- a/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.H +++ b/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.H @@ -81,7 +81,7 @@ class faPatchField : public Field<Type> { - // Private data + // Private Data //- Reference to a patch const faPatch& patch_; @@ -94,8 +94,8 @@ class faPatchField bool updated_; //- Optional patch type, used to allow specified boundary conditions - // to be applied to constraint patches by providing the constraint - // patch type as 'patchType' + //- to be applied to constraint patches by providing the constraint + //- patch type as 'patchType' word patchType_; @@ -217,7 +217,7 @@ public: // Selectors //- Return a pointer to a new patchField created on freestore given - // patch and internal field + //- patch and internal field // (does not set the patch field values) static tmp<faPatchField<Type>> New ( @@ -228,7 +228,7 @@ public: ); //- Return a pointer to a new patchField created on freestore given - // patch and internal field + //- patch and internal field // (does not set the patch field values) static tmp<faPatchField<Type>> New ( @@ -238,7 +238,7 @@ public: ); //- Return a pointer to a new patchField created on freestore from - // a given faPatchField mapped onto a new patch + //- a given faPatchField mapped onto a new patch static tmp<faPatchField<Type>> New ( const faPatchField<Type>&, @@ -248,7 +248,7 @@ public: ); //- Return a pointer to a new patchField created on freestore - // from dictionary + //- from dictionary static tmp<faPatchField<Type>> New ( const faPatch&, @@ -257,7 +257,7 @@ public: ); //- Return a pointer to a new calculatedFaPatchField created on - // freestore without setting patchField values + //- freestore without setting patchField values template<class Type2> static tmp<faPatchField<Type>> NewCalculatedType ( @@ -269,7 +269,7 @@ public: virtual ~faPatchField<Type>() = default; - // Member functions + // Member Functions // Access @@ -330,7 +330,7 @@ public: } - // Mapping functions + // Mapping //- Map (and resize as needed) from self given a mapping object virtual void autoMap @@ -346,7 +346,7 @@ public: ); - // Evaluation functions + // Evaluation //- Return patch-normal gradient virtual tmp<Field<Type>> snGrad() const; @@ -383,9 +383,8 @@ public: Pstream::commsTypes::blocking ); - //- Return the matrix diagonal coefficients corresponding to the - // evaluation of the value of this patchField with given weights + //- evaluation of the value of this patchField with given weights virtual tmp<Field<Type>> valueInternalCoeffs ( const tmp<Field<scalar>>& @@ -396,7 +395,7 @@ public: } //- Return the matrix source coefficients corresponding to the - // evaluation of the value of this patchField with given weights + //- evaluation of the value of this patchField with given weights virtual tmp<Field<Type>> valueBoundaryCoeffs ( const tmp<Field<scalar>>& @@ -407,7 +406,7 @@ public: } //- Return the matrix diagonal coefficients corresponding to the - // evaluation of the gradient of this patchField + //- evaluation of the gradient of this patchField virtual tmp<Field<Type>> gradientInternalCoeffs() const { NotImplemented; @@ -415,7 +414,7 @@ public: } //- Return the matrix source coefficients corresponding to the - // evaluation of the gradient of this patchField + //- evaluation of the gradient of this patchField virtual tmp<Field<Type>> gradientBoundaryCoeffs() const { NotImplemented; @@ -423,8 +422,10 @@ public: } - //- Write - virtual void write(Ostream&) const; + // IO + + //- Write + virtual void write(Ostream&) const; // Check @@ -433,7 +434,7 @@ public: void check(const faPatchField<Type>&) const; - // Member operators + // Member Operators virtual void operator=(const UList<Type>&); diff --git a/src/finiteArea/fields/faPatchFields/faPatchField/faPatchFieldNew.C b/src/finiteArea/fields/faPatchFields/faPatchField/faPatchFieldNew.C index 55768d7d6c294d953d1ac84b51fb092d1128aa2b..04550acbb1c6e5dafa6f2e0fdb01a57ae06f3103 100644 --- a/src/finiteArea/fields/faPatchFields/faPatchField/faPatchFieldNew.C +++ b/src/finiteArea/fields/faPatchFields/faPatchField/faPatchFieldNew.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 Wikki Ltd - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -37,7 +37,12 @@ Foam::tmp<Foam::faPatchField<Type>> Foam::faPatchField<Type>::New const DimensionedField<Type, areaMesh>& iF ) { - DebugInFunction << "Constructing faPatchField<Type>" << endl; + DebugInFunction + << "Constructing faPatchField<Type> " + << "patchFieldType:" << patchFieldType + << "actualPatchType:" << actualPatchType + << "p.Type():" << p.type() + << endl; auto cstrIter = patchConstructorTablePtr_->cfind(patchFieldType); diff --git a/src/finiteArea/finiteArea/fam/famSup.C b/src/finiteArea/finiteArea/fam/famSup.C index ec63e51f19641ad0b301f66a82419aa14aa44dff..b0ad234b9a13250f28a69ac6eeeb2d9355b63418 100644 --- a/src/finiteArea/finiteArea/fam/famSup.C +++ b/src/finiteArea/finiteArea/fam/famSup.C @@ -165,9 +165,19 @@ SuSp ); faMatrix<Type>& fam = tfam.ref(); - fam.diag() += mesh.S()*max(sp.internalField(), scalar(0)); + fam.diag() += + mesh.S()*max + ( + sp.internalField(), + dimensionedScalar("0", sp.dimensions(), Zero) + ); - fam.source() -= mesh.S()*min(sp.internalField(), scalar(0)) + fam.source() -= + mesh.S()*min + ( + sp.internalField(), + dimensionedScalar("0", sp.dimensions(), Zero) + ) *vf.internalField(); return tfam; diff --git a/src/finiteArea/interpolation/edgeInterpolation/edgeInterpolate.C b/src/finiteArea/interpolation/edgeInterpolation/edgeInterpolate.C index 15a284e1b94cb723a5e8325cbc55d5fa84e1bbf1..54dcd271b1460ce156813086109b87c999756221 100644 --- a/src/finiteArea/interpolation/edgeInterpolation/edgeInterpolate.C +++ b/src/finiteArea/interpolation/edgeInterpolation/edgeInterpolate.C @@ -281,6 +281,7 @@ Foam::fac::interpolate tmp<GeometricField<Type, faePatchField, edgeMesh>> tsf = interpolate(tvf()); tvf.clear(); + return tsf; } diff --git a/src/finiteArea/interpolation/edgeInterpolation/edgeInterpolation.C b/src/finiteArea/interpolation/edgeInterpolation/edgeInterpolation.C index dbfe6c04321f78ed102ba156cd40181652c2e150..9e14d5cbb6de7660199e410d22529bf56143e727 100644 --- a/src/finiteArea/interpolation/edgeInterpolation/edgeInterpolation.C +++ b/src/finiteArea/interpolation/edgeInterpolation/edgeInterpolation.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 Wikki Ltd + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -47,8 +48,6 @@ void Foam::edgeInterpolation::clearOut() deleteDemandDrivenData(differenceFactors_); deleteDemandDrivenData(correctionVectors_); deleteDemandDrivenData(skewCorrectionVectors_); -// deleteDemandDrivenData(leastSquarePvectors_); -// deleteDemandDrivenData(leastSquareNvectors_); } @@ -64,8 +63,6 @@ Foam::edgeInterpolation::edgeInterpolation(const faMesh& fam) correctionVectors_(nullptr), skew_(true), skewCorrectionVectors_(nullptr) -// leastSquarePvectors_(nullptr), -// leastSquareNvectors_(nullptr) {} @@ -161,30 +158,6 @@ Foam::edgeInterpolation::skewCorrectionVectors() const } -// const Foam::edgeVectorField& -// Foam::edgeInterpolation::leastSquarePvectors() const -// { -// if (!leastSquarePvectors_) -// { -// makeLeastSquareVectors(); -// } -// -// return (*leastSquarePvectors_); -// } - - -// const Foam::edgeVectorField& -// Foam::edgeInterpolation::leastSquareNvectors() const -// { -// if (!leastSquareNvectors_) -// { -// makeLeastSquareVectors(); -// } -// -// return (*leastSquareNvectors_); -// } - - bool Foam::edgeInterpolation::movePoints() const { deleteDemandDrivenData(lPN_); @@ -197,9 +170,6 @@ bool Foam::edgeInterpolation::movePoints() const skew_ = true; deleteDemandDrivenData(skewCorrectionVectors_); -// deleteDemandDrivenData(leastSquarePvectors_); -// deleteDemandDrivenData(leastSquareNvectors_); - return true; } @@ -527,10 +497,12 @@ void Foam::edgeInterpolation::makeCorrectionVectors() const - deltaCoeffs[edgeI]*unitDelta; } + edgeVectorField::Boundary& CorrVecsbf = CorrVecs.boundaryFieldRef(); - for (faePatchVectorField& patchCorrVecs : CorrVecsbf) + + forAll(CorrVecs.boundaryField(), patchI) { - patchCorrVecs = vector::zero; + mesh().boundary()[patchI].makeCorrectionVectors(CorrVecsbf[patchI]); } scalar NonOrthogCoeff = 0.0; diff --git a/src/finiteArea/interpolation/edgeInterpolation/schemes/skewCorrected/skewCorrectedEdgeInterpolation.H b/src/finiteArea/interpolation/edgeInterpolation/schemes/skewCorrected/skewCorrectedEdgeInterpolation.H new file mode 100644 index 0000000000000000000000000000000000000000..da63c64444d2a01ba880adde40e7eb974dfec6de --- /dev/null +++ b/src/finiteArea/interpolation/edgeInterpolation/schemes/skewCorrected/skewCorrectedEdgeInterpolation.H @@ -0,0 +1,219 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2016-2017 Wikki Ltd + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +Class + Foam::skewCorrectedEdgeInterpolation + +Description + Linear/upwind blended differencing scheme + +SourceFiles + skewCorrectedEdgeInterpolationMake.C + +\*---------------------------------------------------------------------------*/ + +#ifndef skewCorrectedEdgeInterpolation_H +#define skewCorrectedEdgeInterpolation_H + +#include "edgeInterpolationScheme.H" +#include "linearEdgeInterpolation.H" +#include "gaussFaGrad.H" +#include "areaFields.H" +#include "zeroGradientFaPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class skewCorrectedEdgeInterpolation Declaration +\*---------------------------------------------------------------------------*/ + +template<class Type> +class skewCorrectedEdgeInterpolation +: + virtual public edgeInterpolationScheme<Type> +{ + // Private Data + + tmp<edgeInterpolationScheme<Type>> tScheme_; + + +public: + + //- Runtime type information + TypeName("skewCorrected"); + + + // Constructors + + //- Construct from Istream + skewCorrectedEdgeInterpolation(const faMesh& mesh, Istream& is) + : + edgeInterpolationScheme<Type>(mesh), + tScheme_ + ( + edgeInterpolationScheme<Type>::New(mesh, is) + ) + {} + + //- Construct from mesh, faceFlux and blendingFactor + skewCorrectedEdgeInterpolation + ( + const faMesh& mesh, + const edgeScalarField& faceFlux, + Istream& is + ) + : + edgeInterpolationScheme<Type>(mesh), + tScheme_ + ( + edgeInterpolationScheme<Type>::New(mesh, faceFlux, is) + ) + {} + + //- No copy construct + skewCorrectedEdgeInterpolation(const skewCorrectedEdgeInterpolation&) = + delete; + + //- No copy assignment + void operator=(const skewCorrectedEdgeInterpolation&) = delete; + + + // Member Functions + + //- Return the interpolation weighting factors + virtual tmp<edgeScalarField> weights + ( + const GeometricField<Type, faPatchField, areaMesh>& vf + ) const + { + return tScheme_().weights(vf); + } + + //- Return true if this scheme uses an explicit correction + virtual bool corrected() const + { + return + tScheme_().corrected() || (this->mesh()).skew(); + } + + tmp<GeometricField<Type, faePatchField, edgeMesh>> + skewCorrection + ( + const GeometricField<Type, faPatchField, areaMesh>& vf + ) const + { + const faMesh& mesh = this->mesh(); + + const edgeVectorField& scv = mesh.skewCorrectionVectors(); + + tmp<GeometricField<Type, faePatchField, edgeMesh>> tsfCorr + ( + new GeometricField<Type, faePatchField, edgeMesh> + ( + IOobject + ( + "skewCorrected::skewCorrection(" + vf.name() + ')', + vf.instance(), + vf.db() + ), + mesh, + dimensioned<Type>(vf.dimensions(), Zero) + ) + ); + + GeometricField<Type, faePatchField, edgeMesh>& corr = tsfCorr.ref(); + + for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; ++cmpt) + { + corr.replace + ( + cmpt, + scv & linearEdgeInterpolation + < + typename outerProduct + < + vector, + typename pTraits<Type>::cmptType + >::type + >(mesh).interpolate + ( + fa::gaussGrad<typename pTraits<Type>::cmptType> + (mesh).grad(vf.component(cmpt)) + ) + ); + } + + return tsfCorr; + } + + + //- Return the explicit correction to the face-interpolate + virtual tmp<GeometricField<Type, faePatchField, edgeMesh>> + correction + ( + const GeometricField<Type, faPatchField, areaMesh>& vf + ) const + { + if + ( + tScheme_().corrected() + && (this->mesh()).skew() + ) + { + return tScheme_().correction(vf) + skewCorrection(vf); + } + else if (tScheme_().corrected()) + { + return tScheme_().correction(vf); + } + else if ((this->mesh()).skew()) + { + return skewCorrection(vf); + } + else + { + return + tmp<GeometricField<Type, faePatchField, edgeMesh>> + ( + nullptr + ); + } + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteArea/interpolation/edgeInterpolation/schemes/skewCorrected/skewCorrectedEdgeInterpolationMake.C b/src/finiteArea/interpolation/edgeInterpolation/schemes/skewCorrected/skewCorrectedEdgeInterpolationMake.C new file mode 100644 index 0000000000000000000000000000000000000000..70c9e674621188e7c5750c5b1e24f6b9e6e5801c --- /dev/null +++ b/src/finiteArea/interpolation/edgeInterpolation/schemes/skewCorrected/skewCorrectedEdgeInterpolationMake.C @@ -0,0 +1,39 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2016-2017 Wikki Ltd + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "faMesh.H" +#include "skewCorrectedEdgeInterpolation.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makeEdgeInterpolationScheme(skewCorrectedEdgeInterpolation) +} + +// ************************************************************************* // diff --git a/src/finiteArea/interpolation/volSurfaceMapping/volSurfaceMapping.C b/src/finiteArea/interpolation/volSurfaceMapping/volSurfaceMapping.C index 4f814a9cd4954dc4ff6e8560ca9a49b8676f5dd5..e812353649570f35381c5241a26ce3bd99fe2657 100644 --- a/src/finiteArea/interpolation/volSurfaceMapping/volSurfaceMapping.C +++ b/src/finiteArea/interpolation/volSurfaceMapping/volSurfaceMapping.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 Wikki Ltd + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -38,11 +39,8 @@ Foam::tmp<Foam::Field<Type>> Foam::volSurfaceMapping::mapToSurface // Grab labels for all faces in faMesh const labelList& faceLabels = mesh_.faceLabels(); - tmp<Field<Type>> tresult - ( - new Field<Type>(faceLabels.size(), Zero) - ); - Field<Type>& result = tresult.ref(); + auto tresult = tmp<Field<Type>>::New(faceLabels.size(), Zero); + auto& result = tresult.ref(); // Get reference to volume mesh const polyMesh& pMesh = mesh_(); @@ -67,6 +65,41 @@ Foam::tmp<Foam::Field<Type>> Foam::volSurfaceMapping::mapToSurface } +template<class Type> +Foam::tmp<Foam::Field<Type>> Foam::volSurfaceMapping::mapInternalToSurface +( + const typename GeometricField<Type, fvPatchField, volMesh>::Boundary& df +) const +{ + // Grab labels for all faces in faMesh + const labelList& faceLabels = mesh_.faceLabels(); + + auto tresult = tmp<Field<Type>>::New(faceLabels.size(), Zero); + auto& result = tresult.ref(); + + // Get reference to volume mesh + const polyMesh& pMesh = mesh_(); + const polyBoundaryMesh& bm = pMesh.boundaryMesh(); + + label patchID, faceID; + + // Grab droplet cloud source by identifying patch and face + forAll(faceLabels, i) + { + // Escape if face is beyond active faces, eg belongs to a face zone + if (faceLabels[i] < pMesh.nFaces()) + { + patchID = bm.whichPatch(faceLabels[i]); + faceID = bm[patchID].whichFace(faceLabels[i]); + + result[i] = df[patchID].patchInternalField()()[faceID]; + } + } + + return tresult; +} + + template<class Type> void Foam::volSurfaceMapping::mapToVolume ( @@ -103,7 +136,7 @@ template<class Type> void Foam::volSurfaceMapping::mapToVolume ( const tmp<GeometricField<Type, faPatchField, areaMesh>>& taf, - typename GeometricField<Type, fvPatchField, volMesh>::Boundary& bf + typename GeometricField<Type, fvPatchField, volMesh>::Boundary& bf ) const { mapToVolume(taf(), bf); @@ -112,4 +145,31 @@ void Foam::volSurfaceMapping::mapToVolume } +template<class Type> +void Foam::volSurfaceMapping::mapToField +( + const GeometricField<Type, faPatchField, areaMesh>& af, + Field<Type>& f +) const +{ + const labelList& faceLabels = mesh_.faceLabels(); + + const polyMesh& pMesh = mesh_(); + const polyBoundaryMesh& bm = pMesh.boundaryMesh(); + label patchID, faceID; + + const Field<Type>& afi = af.internalField(); + + forAll(faceLabels, i) + { + if (faceLabels[i] < pMesh.nFaces()) + { + patchID = bm.whichPatch(faceLabels[i]); + faceID = bm[patchID].whichFace(faceLabels[i]); + f[faceID] = afi[i]; + } + } +} + + // ************************************************************************* // diff --git a/src/finiteArea/interpolation/volSurfaceMapping/volSurfaceMapping.H b/src/finiteArea/interpolation/volSurfaceMapping/volSurfaceMapping.H index 43f7be6e6e1909b963ce6256511ccdc97836bc3f..5b428f099c19df902ad6e9ba5fe28e0f9ea5e6f6 100644 --- a/src/finiteArea/interpolation/volSurfaceMapping/volSurfaceMapping.H +++ b/src/finiteArea/interpolation/volSurfaceMapping/volSurfaceMapping.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 Wikki Ltd - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -56,21 +56,12 @@ template<class Type> class fvPatchField; class volSurfaceMapping { - // Private data + // Private Data //- Reference to mesh const faMesh& mesh_; - // Private Member Functions - - //- No copy construct - volSurfaceMapping(const volSurfaceMapping&) = delete; - - //- No copy assignment - void operator=(const volSurfaceMapping&) = delete; - - public: // Constructors @@ -81,6 +72,12 @@ public: mesh_(mesh) {} + //- No copy construct + volSurfaceMapping(const volSurfaceMapping&) = delete; + + //- No copy assignment + void operator=(const volSurfaceMapping&) = delete; + //- Destructor ~volSurfaceMapping() = default; @@ -96,6 +93,15 @@ public: GeometricField<Type, fvPatchField, volMesh>::Boundary& df ) const; + + //- Map patch internal field to surface + template<class Type> + tmp<Field<Type>> mapInternalToSurface + ( + const typename + GeometricField<Type, fvPatchField, volMesh>::Boundary& df + ) const; + //- Map surface field to volume boundary field template<class Type> void mapToVolume @@ -104,12 +110,22 @@ public: typename GeometricField<Type, fvPatchField, volMesh>::Boundary& bf ) const; + //- Map surface tmp field to volume boundary field template<class Type> void mapToVolume ( const tmp<GeometricField<Type, faPatchField, areaMesh>>& taf, typename GeometricField<Type, fvPatchField, volMesh>::Boundary& bf ) const; + + //- Map surface field to field assumes Field + //- faces in the same order as Boundary + template<class Type> + void mapToField + ( + const GeometricField<Type, faPatchField, areaMesh>& af, + Field<Type>& f + ) const; }; diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index b4db8e8f3b37dbcca7954af236ce799ea96c4612..1f175aafaa45dc6c6044486efb2c137a8a87a6b2 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -227,6 +227,7 @@ $(derivedFvPatchFields)/fixedProfile/fixedProfileFvPatchFields.C $(derivedFvPatchFields)/plenumPressure/plenumPressureFvPatchScalarField.C $(derivedFvPatchFields)/interfaceCompression/interfaceCompressionFvPatchScalarField.C $(derivedFvPatchFields)/swirlFanVelocity/swirlFanVelocityFvPatchField.C +$(derivedFvPatchFields)/acousticWaveTransmissive/acousticWaveTransmissiveFvPatchFields.C $(derivedFvPatchFields)/mappedMixed/mappedMixedFvPatchFields.C $(derivedFvPatchFields)/mappedField/Sampled/makeSampledPatchFunction1s.C diff --git a/src/finiteVolume/fields/fvPatchFields/derived/acousticWaveTransmissive/acousticWaveTransmissiveFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/acousticWaveTransmissive/acousticWaveTransmissiveFvPatchField.C new file mode 100644 index 0000000000000000000000000000000000000000..9ebb26fbd5f03c1b91eacf23fed88bc8e6a7b68d --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/acousticWaveTransmissive/acousticWaveTransmissiveFvPatchField.C @@ -0,0 +1,119 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "acousticWaveTransmissiveFvPatchField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "EulerDdtScheme.H" +#include "CrankNicolsonDdtScheme.H" +#include "backwardDdtScheme.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class Type> +Foam::acousticWaveTransmissiveFvPatchField<Type>::acousticWaveTransmissiveFvPatchField +( + const fvPatch& p, + const DimensionedField<Type, volMesh>& iF +) +: + advectiveFvPatchField<Type>(p, iF), + advectiveU_(0) +{} + + +template<class Type> +Foam::acousticWaveTransmissiveFvPatchField<Type>::acousticWaveTransmissiveFvPatchField +( + const acousticWaveTransmissiveFvPatchField& ptf, + const fvPatch& p, + const DimensionedField<Type, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + advectiveFvPatchField<Type>(ptf, p, iF, mapper), + advectiveU_(ptf.advectiveU_) +{} + + +template<class Type> +Foam::acousticWaveTransmissiveFvPatchField<Type>::acousticWaveTransmissiveFvPatchField +( + const fvPatch& p, + const DimensionedField<Type, volMesh>& iF, + const dictionary& dict +) +: + advectiveFvPatchField<Type>(p, iF, dict), + advectiveU_(dict.get<scalar>("advectiveSpeed")) +{} + + +template<class Type> +Foam::acousticWaveTransmissiveFvPatchField<Type>::acousticWaveTransmissiveFvPatchField +( + const acousticWaveTransmissiveFvPatchField& ptpsf +) +: + advectiveFvPatchField<Type>(ptpsf), + advectiveU_(ptpsf.advectiveU_) +{} + + +template<class Type> +Foam::acousticWaveTransmissiveFvPatchField<Type>::acousticWaveTransmissiveFvPatchField +( + const acousticWaveTransmissiveFvPatchField& ptpsf, + const DimensionedField<Type, volMesh>& iF +) +: + advectiveFvPatchField<Type>(ptpsf, iF), + advectiveU_(ptpsf.advectiveU_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type> +Foam::tmp<Foam::scalarField> +Foam::acousticWaveTransmissiveFvPatchField<Type>::advectionSpeed() const +{ + return tmp<scalarField>::New(this->size(), advectiveU_); +} + + +template<class Type> +void Foam::acousticWaveTransmissiveFvPatchField<Type>::write(Ostream& os) const +{ + fvPatchField<Type>::write(os); + os.writeEntry("advectiveSpeed", advectiveU_); + this->writeEntry("value", os); +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/acousticWaveTransmissive/acousticWaveTransmissiveFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/acousticWaveTransmissive/acousticWaveTransmissiveFvPatchField.H new file mode 100644 index 0000000000000000000000000000000000000000..f0f31cfefb37317ba92139afe5abd946aeea88f9 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/acousticWaveTransmissive/acousticWaveTransmissiveFvPatchField.H @@ -0,0 +1,192 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +Class + Foam::acousticWaveTransmissiveFvPatchField + +Group + grpOutletBoundaryConditions + +Description + This boundary condition provides a wave transmissive outflow condition, + based on solving DDt(W, field) = 0 at the boundary \c W is the wave velocity + and \c field is the field to which this boundary condition is applied. + The wave speed is input in the BC. + +Usage + Example of the boundary condition specification: + \verbatim + <patchName> + { + // Mandatory entries (unmodifiable) + type acousticWaveTransmissive; + advectiveSpeed 50.0; + + // Mandatory/Optional (inherited) entries + ... + } + \endverbatim + + where the entries mean: + \table + Property | Description | Type | Reqd | Dflt + type | Type name: acousticWaveTransmissive | word | yes | - + advectiveSpeed | Advective speed value | scalar | yes | - + \endtable + + The inherited entries are elaborated in: + - \link advectiveFvPatchField.H \endlink + +See also + - Foam::advectiveFvPatchFields + +SourceFiles + acousticWaveTransmissiveFvPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef acousticWaveTransmissiveFvPatchField_H +#define acousticWaveTransmissiveFvPatchField_H + +#include "advectiveFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class acousticWaveTransmissiveFvPatchField Declaration +\*---------------------------------------------------------------------------*/ + +template<class Type> +class acousticWaveTransmissiveFvPatchField +: + public advectiveFvPatchField<Type> +{ + // Private Data + + //- Advection speed value + scalar advectiveU_; + + +public: + + //- Runtime type information + TypeName("acousticWaveTransmissive"); + + + // Constructors + + //- Construct from patch and internal field + acousticWaveTransmissiveFvPatchField + ( + const fvPatch&, + const DimensionedField<Type, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + acousticWaveTransmissiveFvPatchField + ( + const fvPatch&, + const DimensionedField<Type, volMesh>&, + const dictionary& + ); + + //- Construct by mapping given acousticWaveTransmissiveFvPatchField + //- onto a new patch + acousticWaveTransmissiveFvPatchField + ( + const acousticWaveTransmissiveFvPatchField<Type>&, + const fvPatch&, + const DimensionedField<Type, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + acousticWaveTransmissiveFvPatchField + ( + const acousticWaveTransmissiveFvPatchField& + ); + + //- Construct and return a clone + virtual tmp<fvPatchField<Type>> clone() const + { + return tmp<fvPatchField<Type>> + ( + new acousticWaveTransmissiveFvPatchField<Type>(*this) + ); + } + + //- Construct as copy setting internal field reference + acousticWaveTransmissiveFvPatchField + ( + const acousticWaveTransmissiveFvPatchField&, + const DimensionedField<Type, volMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp<fvPatchField<Type>> clone + ( + const DimensionedField<Type, volMesh>& iF + ) const + { + return tmp<fvPatchField<Type>> + ( + new acousticWaveTransmissiveFvPatchField<Type>(*this, iF) + ); + } + + + // Member Functions + + // Evaluation + + //- Calculate and return the advection speed at the boundary + virtual tmp<scalarField> advectionSpeed() const; + + + // IO + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "acousticWaveTransmissiveFvPatchField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/acousticWaveTransmissive/acousticWaveTransmissiveFvPatchFields.C b/src/finiteVolume/fields/fvPatchFields/derived/acousticWaveTransmissive/acousticWaveTransmissiveFvPatchFields.C new file mode 100644 index 0000000000000000000000000000000000000000..c1c37ed4361cae154b11a6eb8874a4c8d88588c0 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/acousticWaveTransmissive/acousticWaveTransmissiveFvPatchFields.C @@ -0,0 +1,46 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "volFields.H" +#include "surfaceFields.H" +#include "acousticWaveTransmissiveFvPatchFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +makePatchFields(acousticWaveTransmissive); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/acousticWaveTransmissive/acousticWaveTransmissiveFvPatchFields.H b/src/finiteVolume/fields/fvPatchFields/derived/acousticWaveTransmissive/acousticWaveTransmissiveFvPatchFields.H new file mode 100644 index 0000000000000000000000000000000000000000..9c13ce1790f7b4a93984d123efcfb2a419d9fdd0 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/acousticWaveTransmissive/acousticWaveTransmissiveFvPatchFields.H @@ -0,0 +1,51 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#ifndef acousticWaveTransmissiveFvPatchFields_H +#define acousticWaveTransmissiveFvPatchFields_H + +#include "acousticWaveTransmissiveFvPatchField.H" +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeFieldTypedefs(acousticWaveTransmissive); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchFieldsFwd.H b/src/finiteVolume/fields/fvPatchFields/derived/acousticWaveTransmissive/acousticWaveTransmissiveFvPatchFieldsFwd.H similarity index 88% rename from src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchFieldsFwd.H rename to src/finiteVolume/fields/fvPatchFields/derived/acousticWaveTransmissive/acousticWaveTransmissiveFvPatchFieldsFwd.H index 9facb8dce2da25afc034597568085e7bdc6b828a..cf54c570983e23a1b597a2949c2fd9dcaf5d9cb2 100644 --- a/src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchFieldsFwd.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/acousticWaveTransmissive/acousticWaveTransmissiveFvPatchFieldsFwd.H @@ -25,10 +25,9 @@ License \*---------------------------------------------------------------------------*/ -#ifndef uniformFixedValueFaPatchFieldsFwd_H -#define uniformFixedValueFaPatchFieldsFwd_H +#ifndef acousticWaveTransmissiveFvPatchFieldsFwd_H +#define acousticWaveTransmissiveFvPatchFieldsFwd_H -#include "faPatchField.H" #include "fieldTypes.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -38,9 +37,9 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -template<class Type> class uniformFixedValueFaPatchField; +template<class Type> class acousticWaveTransmissiveFvPatchField; -makeFaPatchTypeFieldTypedefs(uniformFixedValue); +makePatchTypeFieldTypedefs(acousticWaveTransmissive); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/regionFaModels/KirchhoffShell/KirchhoffShell.C b/src/regionFaModels/KirchhoffShell/KirchhoffShell.C new file mode 100644 index 0000000000000000000000000000000000000000..577a5262e118505b142a7a3c7774bf198f92f9eb --- /dev/null +++ b/src/regionFaModels/KirchhoffShell/KirchhoffShell.C @@ -0,0 +1,319 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "KirchhoffShell.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFields.H" +#include "zeroGradientFaPatchFields.H" +#include "subCycle.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace regionModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(KirchhoffShell, 0); + +addToRunTimeSelectionTable(vibrationShellModel, KirchhoffShell, dictionary); + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +bool KirchhoffShell::read(const dictionary& dict) +{ + this->solution().readEntry("nNonOrthCorr", nNonOrthCorr_); + return true; +} + + +void KirchhoffShell::solveDisplacement() +{ + if (debug) + { + InfoInFunction << endl; + } + + const Time& time = primaryMesh().time(); + + areaScalarField solidMass(rho()*h_); + areaScalarField solidD(D()/solidMass); + + // Save old times + areaScalarField w0(w_.oldTime()); + areaScalarField w00(w_.oldTime().oldTime()); + + if (nSubCycles_ > 1) + { + // Restore the oldTime in sub-cycling + w_.oldTime() = w0_; + w_.oldTime().oldTime() = w00_; + laplaceW_.oldTime() = laplaceW0_; + laplace2W_.oldTime() = laplace2W0_; + } + + for + ( + subCycleTime wSubCycle + ( + const_cast<Time&>(time), + nSubCycles_ + ); + !(++wSubCycle).end(); + ) + { + + laplaceW_ = fac::laplacian(w_); + laplace2W_ = fac::laplacian(laplaceW_); + + faScalarMatrix wEqn + ( + fam::d2dt2(w_) + + f1_*fam::ddt(w_) + - f0_*sqrt(solidD)*fac::ddt(laplaceW_) + + solidD*(laplace2W_ + f2_*fac::ddt(laplace2W_)) + == + ps_/solidMass + + faOptions()(solidMass, w_, dimLength/sqr(dimTime)) + ); + + faOptions().constrain(wEqn); + + wEqn.solve(); + + Info<< "w min/max = " << min(w_) << ", " << max(w_) << endl; + + if (wSubCycle.index() >= wSubCycle.nSubCycles()) + { + // Cache oldTimes inside the sub-cycling + w0_ = w_.oldTime(); + w00_ = w_.oldTime().oldTime(); + laplaceW0_ = laplaceW_.oldTime(); + laplace2W0_ = laplace2W_.oldTime(); + + // Update shell acceleration + a_ = fac::d2dt2(w_); + } + } + + // Restore old time in main time + w_.oldTime() = w0; + w_.oldTime().oldTime() = w00; + + faOptions().correct(w_); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +KirchhoffShell::KirchhoffShell +( + const word& modelType, + const fvPatch& patch, + const dictionary& dict +) +: + vibrationShellModel(modelType, patch, dict), + f0_("f0", dimless, dict), + f1_("f1", inv(dimTime), dict), + f2_("f2", dimTime, dict), + nNonOrthCorr_(1), + nSubCycles_(1), + ps_ + ( + IOobject + ( + "ps_" + regionName_, + primaryMesh().time().timeName(), + primaryMesh(), + IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE + ), + regionMesh(), + dimensionedScalar(dimPressure, Zero) + ), + h_ + ( + IOobject + ( + "h_" + regionName_, + primaryMesh().time().timeName(), + primaryMesh(), + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + regionMesh() + ), + laplaceW_ + ( + IOobject + ( + "laplaceW_" + regionName_, + primaryMesh().time().timeName(), + primaryMesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + regionMesh(), + dimensionedScalar(inv(dimLength), Zero) + ), + laplace2W_ + ( + IOobject + ( + "laplace2W_" + regionName_, + primaryMesh().time().timeName(), + primaryMesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + regionMesh(), + dimensionedScalar(inv(pow3(dimLength)), Zero) + ), + w0_ + ( + IOobject + ( + "w0_" + regionName_, + primaryMesh().time().timeName(), + primaryMesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + regionMesh(), + dimensionedScalar(dimLength, Zero) + ), + w00_ + ( + IOobject + ( + "w00_" + regionName_, + primaryMesh().time().timeName(), + primaryMesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + regionMesh(), + dimensionedScalar(dimLength, Zero) + ), + laplaceW0_ + ( + IOobject + ( + "laplaceW0_" + regionName_, + primaryMesh().time().timeName(), + primaryMesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + regionMesh(), + dimensionedScalar(inv(dimLength), Zero) + ), + laplace2W0_ + ( + IOobject + ( + "laplace2W0_" + regionName_, + primaryMesh().time().timeName(), + primaryMesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + regionMesh(), + dimensionedScalar(inv(pow3(dimLength)), Zero) + ) +{ + init(); +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void KirchhoffShell::init() +{} + + +void KirchhoffShell::preEvolveRegion() +{} + + +void KirchhoffShell::evolveRegion() +{ + nNonOrthCorr_ = solution().get<label>("nNonOrthCorr"); + nSubCycles_ = solution().get<label>("nSubCycles"); + + for (int nonOrth=0; nonOrth<=nNonOrthCorr_; nonOrth++) + { + solveDisplacement(); + } +} + + +const tmp<areaScalarField> KirchhoffShell::D() const +{ + const dimensionedScalar E("E", dimForce/dimArea , solid().E()); + const dimensionedScalar nu("nu", dimless, solid().nu()); + + return tmp<areaScalarField>(E*pow3(h_)/(12*(1 - sqr(nu)))); +} + + +const tmp<areaScalarField> KirchhoffShell::rho() const +{ + return tmp<areaScalarField> + ( + new areaScalarField + ( + IOobject + ( + "rhos", + primaryMesh().time().timeName(), + primaryMesh(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + regionMesh(), + dimensionedScalar("rho", dimDensity, solid().rho()), + zeroGradientFaPatchScalarField::typeName + ) + ); +} + + +void KirchhoffShell::info() +{} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace regionModels +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/regionFaModels/KirchhoffShell/KirchhoffShell.H b/src/regionFaModels/KirchhoffShell/KirchhoffShell.H new file mode 100644 index 0000000000000000000000000000000000000000..0a7762bedb4c102c7d84ec81673ca2b5aca96365 --- /dev/null +++ b/src/regionFaModels/KirchhoffShell/KirchhoffShell.H @@ -0,0 +1,217 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +Class + Foam::regionFaModels::KirchhoffShell + +Description + +Usage + Example of the boundary condition specification: + \verbatim + <patchName> + { + // Mandatory/Optional (inherited) entries + ... + + // Mandatory entries (unmodifiable) + vibrationShellModel KirchhoffShell; + f0 0.04; + f1 0.0; + f2 0.0; + } + \endverbatim + + where the entries mean: + \table + Property | Description | Type | Reqd | Dflt + vibrationShellModel | Type name: KirchhoffShell | word | yes | - + f0 | Damping coefficient [1/s] | scalar | yes | - + f1 | Damping coefficient [1/s] | scalar | yes | - + f2 | Damping coefficient [1/s] | scalar | yes | - + \endtable + + The inherited entries are elaborated in: + - \link vibrationShellModel.H \endlink + +SourceFiles + KirchhoffShell.C + +\*---------------------------------------------------------------------------*/ + +#ifndef KirchhoffShell_H +#define KirchhoffShell_H + +#include "volFieldsFwd.H" +#include "vibrationShellModel.H" +#include "faMesh.H" +#include "faCFD.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace regionModels +{ + +/*---------------------------------------------------------------------------*\ + Class KirchhoffShell Declaration +\*---------------------------------------------------------------------------*/ + +class KirchhoffShell +: + public vibrationShellModel +{ + // Private Data + + //- Damping coefficients [1/s] + dimensionedScalar f0_; + dimensionedScalar f1_; + dimensionedScalar f2_; + + + // Private Member Functions + + //- Initialize KirchhoffShell + void init(); + + +protected: + + // Protected Data + + // Solution parameters + + //- Number of non orthogonal correctors + label nNonOrthCorr_; + + //- Sub cycles + label nSubCycles_; + + + // Source term fields + + //- External surface source [Pa] + areaScalarField ps_; + + //- Thickness [m] + areaScalarField h_; + + //- Laplace of the displacement + areaScalarField laplaceW_; + + //- Laplace of the Laplace for the displacement + areaScalarField laplace2W_; + + //- Cache w.oldTime() in sub-cycling + areaScalarField w0_; + + //- Cache w.oldTime.oldTime() in sub-cycling + areaScalarField w00_; + + //- Cache laplaceW.oldTime() in sub-cycling + areaScalarField laplaceW0_; + + //- Cache laplace2.oldTime() in sub-cycling + areaScalarField laplace2W0_; + + + // Protected Member Functions + + //- Read control parameters from dictionary + virtual bool read(const dictionary& dict); + + + // Equations + + //- Solve energy equation + void solveDisplacement(); + + +public: + + //- Runtime type information + TypeName("KirchhoffShell"); + + + // Constructors + + //- Construct from components and dict + KirchhoffShell + ( + const word& modelType, + const fvPatch& patch, + const dictionary& dict + ); + + //- No copy construct + KirchhoffShell(const KirchhoffShell&) = delete; + + //- No copy assignment + void operator=(const KirchhoffShell&) = delete; + + + //- Destructor + virtual ~KirchhoffShell() = default; + + + // Member Functions + + // Fields + + //- Return stiffness + const tmp<areaScalarField> D() const; + + //- Return density [Kg/m3] + const tmp<areaScalarField> rho() const; + + + // Evolution + + //- Pre-evolve thermal baffle + virtual void preEvolveRegion(); + + //- Evolve the thermal baffle + virtual void evolveRegion(); + + + // IO + + //- Provide some feedback + virtual void info(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace regionModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +#endif + +// ************************************************************************* // diff --git a/src/regionFaModels/Make/files b/src/regionFaModels/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..3a3b9a4adddcd3f2bc9b9f3dd700bd6740cb2f91 --- /dev/null +++ b/src/regionFaModels/Make/files @@ -0,0 +1,16 @@ +/* Region models */ +regionFaModel/regionFaModel.C +thermalShellModel/thermalShellModel.C +thermalShellModel/thermalShellModelNew.C +vibrationShellModel/vibrationShellModel.C +vibrationShellModel/vibrationShellModelNew.C + +/* Shell models */ +thermalShell/thermalShell.C +KirchhoffShell/KirchhoffShell.C + +/* Boundary conditions */ +derivedFvPatchFields/thermalShell/thermalShellFvPatchScalarField.C +derivedFvPatchFields/vibrationShell/vibrationShellFvPatchScalarField.C + +LIB = $(FOAM_LIBBIN)/libregionFaModels diff --git a/src/regionFaModels/Make/options b/src/regionFaModels/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..cd4795b38d01292372b3c1514abe9745dcfa97ad --- /dev/null +++ b/src/regionFaModels/Make/options @@ -0,0 +1,16 @@ +EXE_INC = \ + -I$(LIB_SRC)/faOptions/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/finiteArea/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/thermophysicalProperties/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ + -I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude + +LIB_LIBS = \ + -lfiniteVolume \ + -lfiniteArea \ + -lmeshTools \ + -lthermophysicalProperties \ + -lspecie \ + -lfaOptions diff --git a/src/regionFaModels/derivedFvPatchFields/doc/thermalBaffleBoundaryConditionsDoc.H b/src/regionFaModels/derivedFvPatchFields/doc/thermalBaffleBoundaryConditionsDoc.H new file mode 100644 index 0000000000000000000000000000000000000000..2ea5aee695fb379c9278cf23f92754ca2a896f2e --- /dev/null +++ b/src/regionFaModels/derivedFvPatchFields/doc/thermalBaffleBoundaryConditionsDoc.H @@ -0,0 +1,34 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +\defgroup grpThermoBaffleBoundaryConditions Thermo baffle boundary conditions +@{ + \ingroup grpThermoBoundaryConditions + This group contains thermo baffle model boundary conditions +@} + +\*---------------------------------------------------------------------------*/ diff --git a/src/regionFaModels/derivedFvPatchFields/thermalShell/thermalShellFvPatchScalarField.C b/src/regionFaModels/derivedFvPatchFields/thermalShell/thermalShellFvPatchScalarField.C new file mode 100644 index 0000000000000000000000000000000000000000..6b1db5d3bbf72c50c8604d6588c41dc719548dfd --- /dev/null +++ b/src/regionFaModels/derivedFvPatchFields/thermalShell/thermalShellFvPatchScalarField.C @@ -0,0 +1,152 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "thermalShellFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +thermalShellFvPatchScalarField::thermalShellFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF +) +: + fixedValueFvPatchField<scalar>(p, iF), + baffle_(), + dict_(dictionary::null) +{} + + +thermalShellFvPatchScalarField::thermalShellFvPatchScalarField +( + const thermalShellFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchField<scalar> + ( + ptf, + p, + iF, + mapper + ), + baffle_(), + dict_(ptf.dict_) +{} + + +thermalShellFvPatchScalarField::thermalShellFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const dictionary& dict +) +: + fixedValueFvPatchField<scalar>(p, iF, dict), + baffle_(), + dict_(dict) +{ + typedef regionModels::thermalShellModel baffle; + + if (!baffle_) + { + baffle_.reset(baffle::New(p, dict).ptr()); + } +} + + +thermalShellFvPatchScalarField::thermalShellFvPatchScalarField +( + const thermalShellFvPatchScalarField& ptf, + const DimensionedField<scalar, volMesh>& iF +) +: + fixedValueFvPatchField<scalar>(ptf, iF), + baffle_(), + dict_(ptf.dict_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void thermalShellFvPatchScalarField::updateCoeffs() +{ + if (this->updated()) + { + return; + } + + baffle_->evolve(); + + volScalarField::Boundary& vfb = + db().lookupObjectRef<volScalarField> + ( + this->internalField().name() + ).boundaryFieldRef(); + + baffle_->vsm().mapToVolume(baffle_->T(), vfb); + + fixedValueFvPatchField<scalar>::updateCoeffs(); +} + + +void thermalShellFvPatchScalarField::write(Ostream& os) const +{ + fixedValueFvPatchField<scalar>::write(os); + + // Remove value and type already written by fixedValueFvPatchField + dict_.remove("value"); + dict_.remove("type"); + dict_.write(os, false); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + thermalShellFvPatchScalarField +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam + + +// ************************************************************************* // diff --git a/src/regionFaModels/derivedFvPatchFields/thermalShell/thermalShellFvPatchScalarField.H b/src/regionFaModels/derivedFvPatchFields/thermalShell/thermalShellFvPatchScalarField.H new file mode 100644 index 0000000000000000000000000000000000000000..4a9e01b52f3cb0ca415992965f37c961925e714b --- /dev/null +++ b/src/regionFaModels/derivedFvPatchFields/thermalShell/thermalShellFvPatchScalarField.H @@ -0,0 +1,184 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +Class + Foam::compressible::thermalShellFvPatchScalarField + +Group + grpThermoBoundaryConditions + +Description + This boundary condition provides a coupled temperature condition between + a primary region (3D mesh) and a thermal shell model (2D mesh). + + The primary region boundary creates the finite area region + and evolves its energy equation. + +Usage + Example of the boundary condition specification: + \verbatim + <masterPatchName> + { + // Mandatory entries (unmodifiable) + type compressible::thermalShell; + + // Mandatory/Optional (inherited) entries + ... + } + \endverbatim + + where the entries mean: + \table + Property | Description | Type | Reqd | Dflt + type | Type name: compressible::thermalShell | word | yes | - + \endtable + + The inherited entries are elaborated in: + - \link fixedValueFvPatchField.H \endlink + - \link thermalShellModel.H \endlink + +Note + - The two-dimensional area mesh needs to be + generated in the pre-processing steps. + +SourceFiles + thermalShellFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef thermalShellFvPatchScalarField_H +#define thermalShellFvPatchScalarField_H + +#include "autoPtr.H" +#include "thermalShellModel.H" +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +/*---------------------------------------------------------------------------*\ + Class thermalShellFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class thermalShellFvPatchScalarField +: + public fixedValueFvPatchField<scalar> +{ + // Private Data + + //- Thermal baffle + autoPtr<regionModels::thermalShellModel> baffle_; + + //- Dictionary + mutable dictionary dict_; + + +public: + + //- Runtime type information + TypeName("compressible::thermalShell"); + + + // Constructors + + //- Construct from patch and internal field + thermalShellFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + thermalShellFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const dictionary& + ); + + //- Construct by mapping given + //- thermalShellFvPatchScalarField onto a new patch + thermalShellFvPatchScalarField + ( + const thermalShellFvPatchScalarField&, + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct and return a clone + virtual tmp<fvPatchScalarField> clone() const + { + return tmp<fvPatchScalarField> + ( + new thermalShellFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + thermalShellFvPatchScalarField + ( + const thermalShellFvPatchScalarField&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp<fvPatchScalarField> clone + ( + const DimensionedField<scalar, volMesh>& iF + ) const + { + return tmp<fvPatchScalarField> + ( + new thermalShellFvPatchScalarField(*this, iF) + ); + } + + + // Member Functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +#endif + +// ************************************************************************* // diff --git a/src/regionFaModels/derivedFvPatchFields/vibrationShell/vibrationShellFvPatchScalarField.C b/src/regionFaModels/derivedFvPatchFields/vibrationShell/vibrationShellFvPatchScalarField.C new file mode 100644 index 0000000000000000000000000000000000000000..8b91815f80ccc904a74677c5af76adef27aedbac --- /dev/null +++ b/src/regionFaModels/derivedFvPatchFields/vibrationShell/vibrationShellFvPatchScalarField.C @@ -0,0 +1,169 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "vibrationShellFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +vibrationShellFvPatchScalarField::vibrationShellFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF +) +: + mixedFvPatchField<scalar>(p, iF), + baffle_(), + dict_(dictionary::null) +{ + refValue() = 0; + refGrad() = 0; + valueFraction() = 1; +} + + +vibrationShellFvPatchScalarField::vibrationShellFvPatchScalarField +( + const vibrationShellFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchField<scalar> + ( + ptf, + p, + iF, + mapper + ), + baffle_(), + dict_(ptf.dict_) +{} + + +vibrationShellFvPatchScalarField::vibrationShellFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const dictionary& dict +) +: + mixedFvPatchField<scalar>(p, iF), + baffle_(), + dict_(dict) +{ + fvPatchScalarField::operator=(scalarField("value", dict, p.size())); + + if (dict.found("refValue")) + { + // Full restart + refValue() = scalarField("refValue", dict, p.size()); + refGrad() = scalarField("refGradient", dict, p.size()); + valueFraction() = scalarField("valueFraction", dict, p.size()); + } + else + { + // Start from user entered data. Assume fixedValue. + refValue() = *this; + refGrad() = 0; + valueFraction() = 1; + } + + if (!baffle_) + { + baffle_.reset(regionModels::vibrationShellModel::New(p, dict).ptr()); + } +} + + +vibrationShellFvPatchScalarField::vibrationShellFvPatchScalarField +( + const vibrationShellFvPatchScalarField& ptf, + const DimensionedField<scalar, volMesh>& iF +) +: + mixedFvPatchField<scalar>(ptf, iF), + baffle_(), + dict_(ptf.dict_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void vibrationShellFvPatchScalarField::updateCoeffs() +{ + if (this->updated()) + { + return; + } + + baffle_->evolve(); + + const auto& transportProperties = + db().lookupObject<IOdictionary>("transportProperties"); + + dimensionedScalar rho("rho", dimDensity, transportProperties); + + const areaScalarField aRho(rho*baffle_->a()); + + baffle_->vsm().mapToField(aRho, this->refGrad()); + + this->refValue() = Zero; + this->valueFraction() = Zero; + + mixedFvPatchField<scalar>::updateCoeffs(); +} + + +void vibrationShellFvPatchScalarField::write(Ostream& os) const +{ + mixedFvPatchField<scalar>::write(os); + + dict_.write(os, false); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + vibrationShellFvPatchScalarField +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + + +// ************************************************************************* // diff --git a/src/regionFaModels/derivedFvPatchFields/vibrationShell/vibrationShellFvPatchScalarField.H b/src/regionFaModels/derivedFvPatchFields/vibrationShell/vibrationShellFvPatchScalarField.H new file mode 100644 index 0000000000000000000000000000000000000000..ae742242c7e7e4503b8cfae93cad888a8ff35176 --- /dev/null +++ b/src/regionFaModels/derivedFvPatchFields/vibrationShell/vibrationShellFvPatchScalarField.H @@ -0,0 +1,172 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +Class + Foam::compressible::vibrationShellFvPatchScalarField + +Group + grpVibrationBoundaryConditions + +Description + +Usage + Example of the boundary condition specification: + \verbatim + <masterPatchName> + { + // Mandatory entries (unmodifiable) + type vibrationShell; + + // Mandatory/Optional (inherited) entries + ... + } + \endverbatim + + where the entries mean: + \table + Property | Description | Type | Reqd | Dflt + type | Type name: vibrationShell | word | yes | - + \endtable + + The inherited entries are elaborated in: + - \link mixedFvPatchField.H \endlink + - \link vibrationShellModel.H \endlink + +SourceFiles + vibrationShellFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef vibrationShellFvPatchScalarField_H +#define vibrationShellFvPatchScalarField_H + +#include "autoPtr.H" +#include "vibrationShellModel.H" +#include "mixedFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class vibrationShellFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class vibrationShellFvPatchScalarField +: + public mixedFvPatchField<scalar> +{ + // Private Data + + //- Thermal baffle + autoPtr<regionModels::vibrationShellModel> baffle_; + + //- Dictionary + mutable dictionary dict_; + + +public: + + //- Runtime type information + TypeName("vibrationShell"); + + + // Constructors + + //- Construct from patch and internal field + vibrationShellFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + vibrationShellFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const dictionary& + ); + + //- Construct by mapping given + //- vibrationShellFvPatchScalarField onto a new patch + vibrationShellFvPatchScalarField + ( + const vibrationShellFvPatchScalarField&, + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct and return a clone + virtual tmp<fvPatchScalarField> clone() const + { + return tmp<fvPatchScalarField> + ( + new vibrationShellFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + vibrationShellFvPatchScalarField + ( + const vibrationShellFvPatchScalarField&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp<fvPatchScalarField> clone + ( + const DimensionedField<scalar, volMesh>& iF + ) const + { + return tmp<fvPatchScalarField> + ( + new vibrationShellFvPatchScalarField(*this, iF) + ); + } + + + // Member Functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +#endif + +// ************************************************************************* // diff --git a/src/regionFaModels/regionFaModel/regionFaModel.C b/src/regionFaModels/regionFaModel/regionFaModel.C new file mode 100644 index 0000000000000000000000000000000000000000..9a7078e036c3b1d77a37dc4dd2671a208e50b275 --- /dev/null +++ b/src/regionFaModels/regionFaModel/regionFaModel.C @@ -0,0 +1,172 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "regionFaModel.H" +#include "faMesh.H" +#include "Time.H" +#include "mappedWallPolyPatch.H" +#include "zeroGradientFvPatchFields.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace regionModels +{ + defineTypeNameAndDebug(regionFaModel, 0); +} +} + +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +void Foam::regionModels::regionFaModel::constructMeshObjects() +{ + regionMeshPtr_.reset + ( + new faMesh(primaryMesh_) + ); +} + + +void Foam::regionModels::regionFaModel::initialise() +{ + if (debug) + { + Pout<< "regionFaModel::initialise()" << endl; + } + + vsmPtr_.reset(new volSurfaceMapping(regionMeshPtr_())); +} + + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +bool Foam::regionModels::regionFaModel::read(const dictionary& dict) +{ + if (active_) + { + if (const dictionary* dictptr = dict.findDict(modelName_ + "Coeffs")) + { + coeffs_ <<= *dictptr; + } + + infoOutput_.readIfPresent("infoOutput", dict); + + return true; + } + + return false; +} + + +// * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * // + +const Foam::volSurfaceMapping& Foam::regionModels::regionFaModel::vsm() const +{ + return vsmPtr_(); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::regionModels::regionFaModel::regionFaModel +( + const fvPatch& patch, + const word& regionType, + const word& modelName, + const dictionary& dict, + bool readFields +) +: + primaryMesh_(patch.boundaryMesh().mesh()), + patch_(patch), + time_(patch.boundaryMesh().mesh().time()), + active_(dict.get<Switch>("active")), + infoOutput_(false), + modelName_(modelName), + regionMeshPtr_(nullptr), + coeffs_(dict.subOrEmptyDict(modelName + "Coeffs")), + vsmPtr_(nullptr), + patchID_(patch.index()), + regionName_(dict.lookup("region")) +{ + if (active_) + { + constructMeshObjects(); + initialise(); + + if (readFields) + { + read(dict); + } + } +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void Foam::regionModels::regionFaModel::evolve() +{ + if (active_) + { + Info<< "\nEvolving " << modelName_ << " for region " + << regionMesh().name() << endl; + + preEvolveRegion(); + + evolveRegion(); + + postEvolveRegion(); + + // Provide some feedback + if (infoOutput_) + { + Info<< incrIndent; + info(); + Info<< endl << decrIndent; + } + } +} + + +void Foam::regionModels::regionFaModel::preEvolveRegion() +{} + + +void Foam::regionModels::regionFaModel::evolveRegion() +{} + + +void Foam::regionModels::regionFaModel::postEvolveRegion() +{} + + +void Foam::regionModels::regionFaModel::info() +{} + + +// ************************************************************************* // diff --git a/src/regionFaModels/regionFaModel/regionFaModel.H b/src/regionFaModels/regionFaModel/regionFaModel.H new file mode 100644 index 0000000000000000000000000000000000000000..48cb985339bdc83b1b11e06e5e9387c99217e68a --- /dev/null +++ b/src/regionFaModels/regionFaModel/regionFaModel.H @@ -0,0 +1,256 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +Class + Foam::regionModels::regionFaModel + +Description + Base class for area region models. + +Usage + Example of the model specification: + \verbatim + <patchName> + { + // Mandatory entries (runtime modifiable) + region <regionName>; + active true; + + // Optional entries (runtime modifiable) + infoOutput false; + <model>Coeffs + { + // subdictionary entries + } + + // Mandatory/Optional (derived) entries + ... + } + \endverbatim + + where the entries mean: + \table + Property | Description | Type | Reqd | Dflt + region | Name of operand region | word | yes | - + active | Flag to activate the model | bool | yes | - + infoOutput | Flag to activate information output | bool | no | false + \endtable + +SourceFiles + regionFaModelI.H + regionFaModel.C + +\*---------------------------------------------------------------------------*/ + +#ifndef regionFaModel_H +#define regionFaModel_H + +#include "volMesh.H" +#include "IOdictionary.H" +#include "Switch.H" +#include "labelList.H" +#include "areaFields.H" +#include "faMesh.H" +#include "volSurfaceMapping.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +namespace regionModels +{ + +/*---------------------------------------------------------------------------*\ + Class regionFaModel Declaration +\*---------------------------------------------------------------------------*/ + +class regionFaModel +{ + // Private Member Functions + + //- Construct region mesh and fields + void constructMeshObjects(); + + //- Initialise the region + void initialise(); + + +protected: + + // Protected Data + + //- Reference to the primary mesh database + const fvMesh& primaryMesh_; + + //- Reference to fvPatch + const fvPatch& patch_; + + //- Reference to the time database + const Time& time_; + + //- Active flag + Switch active_; + + //- Active information output + Switch infoOutput_; + + //- Model name + const word modelName_; + + //- Pointer to the region mesh database + autoPtr<faMesh> regionMeshPtr_; + + //- Model coefficients dictionary + dictionary coeffs_; + + //-Volume-to surface mapping + autoPtr<volSurfaceMapping> vsmPtr_; + + + // Addressing + + //- Patch IDs on the primary region coupled to this region + label patchID_; + + + //- Region name + word regionName_; + + + // Protected Member Functions + + //- Read control parameters from dictionary + virtual bool read(const dictionary& dict); + + +public: + + //- Runtime type information + TypeName("regionFaModel"); + + + // Constructors + + //- Construct from mesh and name and dict + regionFaModel + ( + const fvPatch& patch, + const word& regionType, + const word& modelName, + const dictionary& dict, + bool readFields = true + ); + + //- No copy construct + regionFaModel(const regionFaModel&) = delete; + + //- No copy assignment + void operator=(const regionFaModel&) = delete; + + + //- Destructor + virtual ~regionFaModel() = default; + + + // Member Functions + + // Access + + //- Return the reference to the primary mesh database + inline const fvMesh& primaryMesh() const; + + //- Return the reference to the time database + inline const Time& time() const; + + //- Return the active flag + inline const Switch& active() const; + + //- Return the information flag + inline const Switch& infoOutput() const; + + //- Return the model name + inline const word& modelName() const; + + //- Return the region mesh database + inline const faMesh& regionMesh() const; + + //- Return the region mesh database for manipulation + inline faMesh& regionMesh(); + + //- Return the model coefficients dictionary + inline const dictionary& coeffs() const; + + //- Return the solution dictionary + inline const dictionary& solution() const; + + //- Return volSurfaceMapping + const volSurfaceMapping& vsm() const; + + + // Addressing + + //- Return the list of patch IDs on the primary region coupled + //- to this region + inline label patchID(); + + + // Evolution + + //- Main driver routing to evolve the region - calls other evolves + virtual void evolve(); + + //- Pre-evolve region + virtual void preEvolveRegion(); + + //- Evolve the region + virtual void evolveRegion(); + + //- Post-evolve region + virtual void postEvolveRegion(); + + + // IO + + //- Provide some feedback + virtual void info(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace regionFaModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "regionFaModelI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +#endif + +// ************************************************************************* // diff --git a/src/regionFaModels/regionFaModel/regionFaModelI.H b/src/regionFaModels/regionFaModel/regionFaModelI.H new file mode 100644 index 0000000000000000000000000000000000000000..35fe64d499775cc8b839899c8db846b0c1c4aad6 --- /dev/null +++ b/src/regionFaModels/regionFaModel/regionFaModelI.H @@ -0,0 +1,118 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "regionFaModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +inline const Foam::fvMesh& +Foam::regionModels::regionFaModel::primaryMesh() const +{ + return primaryMesh_; +} + + +inline const Foam::Time& Foam::regionModels::regionFaModel::time() const +{ + return time_; +} + + +inline const Foam::Switch& Foam::regionModels::regionFaModel::active() const +{ + return active_; +} + + +inline const Foam::Switch& Foam::regionModels::regionFaModel::infoOutput() const +{ + return infoOutput_; +} + + +inline const Foam::word& Foam::regionModels::regionFaModel::modelName() const +{ + return modelName_; +} + + +inline const Foam::faMesh& Foam::regionModels::regionFaModel::regionMesh() const +{ + const auto* regionPtr = time_.findObject<faMesh>(regionName_); + + if (regionPtr) + { + return *regionPtr; + } + else if (!regionMeshPtr_.valid()) + { + FatalErrorInFunction + << "Region mesh not available" << abort(FatalError); + } + + return *regionMeshPtr_; +} + + +inline Foam::faMesh& Foam::regionModels::regionFaModel::regionMesh() +{ + auto* regionPtr = time_.getObjectPtr<faMesh>(regionName_); + + if (regionPtr) + { + return *regionPtr; + } + else if (!regionMeshPtr_.valid()) + { + FatalErrorInFunction + << "Region mesh not available" << abort(FatalError); + } + + return *regionMeshPtr_; +} + + +inline const Foam::dictionary& Foam::regionModels::regionFaModel::coeffs() const +{ + return coeffs_; +} + + +inline const Foam::dictionary& +Foam::regionModels::regionFaModel::solution() const +{ + return regionMesh().solutionDict(); +} + + +inline Foam::label Foam::regionModels::regionFaModel::patchID() +{ + return patchID_; +} + + +// ************************************************************************* // diff --git a/src/regionFaModels/thermalShell/thermalShell.C b/src/regionFaModels/thermalShell/thermalShell.C new file mode 100644 index 0000000000000000000000000000000000000000..797de7e2d5e90fc32f705d7e77f4887541a86be2 --- /dev/null +++ b/src/regionFaModels/thermalShell/thermalShell.C @@ -0,0 +1,232 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "thermalShell.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFields.H" +#include "zeroGradientFaPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace regionModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(thermalShell, 0); + +addToRunTimeSelectionTable(thermalShellModel, thermalShell, dictionary); + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +bool thermalShell::read(const dictionary& dict) +{ + this->solution().readEntry("nNonOrthCorr", nNonOrthCorr_); + + return true; +} + + +void thermalShell::solveEnergy() +{ + if (debug) + { + InfoInFunction << endl; + } + + const areaScalarField rhoCph(Cp()*rho()*h_); + + faScalarMatrix TEqn + ( + fam::ddt(rhoCph, T_) + - fam::laplacian(kappa()*h_, T_) + == + qs_ + //+ q(T_) handled by faOption contactHeatFlux + + faOptions()(h_, rhoCph, T_) + ); + + TEqn.relax(); + + faOptions().constrain(TEqn); + + TEqn.solve(); + + faOptions().correct(T_); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +thermalShell::thermalShell +( + const word& modelType, + const fvPatch& patch, + const dictionary& dict +) +: + thermalShellModel(modelType, patch, dict), + nNonOrthCorr_(1), + thermo_(dict.subDict("thermo")), + qs_ + ( + IOobject + ( + "qs_" + regionName_, + primaryMesh().time().timeName(), + primaryMesh(), + IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE + ), + regionMesh(), + dimensionedScalar(dimPower/dimArea, Zero) + ), + h_ + ( + IOobject + ( + "h_" + regionName_, + primaryMesh().time().timeName(), + primaryMesh(), + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + regionMesh() + ) +{ + init(); +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void thermalShell::init() +{} + + +void thermalShell::preEvolveRegion() +{} + + +void thermalShell::evolveRegion() +{ + nNonOrthCorr_ = solution().get<label>("nNonOrthCorr"); + + for (int nonOrth = 0; nonOrth <= nNonOrthCorr_; ++nonOrth) + { + solveEnergy(); + } + + Info<< "T min/max = " << min(T_) << ", " << max(T_) << endl; +} + + +const tmp<areaScalarField> thermalShell::Cp() const +{ + return tmp<areaScalarField> + ( + new areaScalarField + ( + IOobject + ( + "Cps", + primaryMesh().time().timeName(), + primaryMesh(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + regionMesh(), + dimensionedScalar(dimEnergy/dimTemperature/dimMass, thermo_.Cp()), + zeroGradientFaPatchScalarField::typeName + ) + ); +} + + +const tmp<areaScalarField> thermalShell::rho() const +{ + return tmp<areaScalarField> + ( + new areaScalarField + ( + IOobject + ( + "rhos", + primaryMesh().time().timeName(), + primaryMesh(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + regionMesh(), + dimensionedScalar(dimDensity, thermo_.rho()), + zeroGradientFaPatchScalarField::typeName + ) + ); +} + + +const tmp<areaScalarField> thermalShell::kappa() const +{ + return tmp<areaScalarField> + ( + new areaScalarField + ( + IOobject + ( + "kappas", + primaryMesh().time().timeName(), + primaryMesh(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + regionMesh(), + dimensionedScalar + ( + dimPower/dimLength/dimTemperature, + thermo_.kappa() + ), + zeroGradientFaPatchScalarField::typeName + ) + ); +} + + +void thermalShell::info() +{} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace regionModels +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/regionFaModels/thermalShell/thermalShell.H b/src/regionFaModels/thermalShell/thermalShell.H new file mode 100644 index 0000000000000000000000000000000000000000..6160855c130e6b63aec44327d9f8f5ce421c0e5f --- /dev/null +++ b/src/regionFaModels/thermalShell/thermalShell.H @@ -0,0 +1,208 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +Class + Foam::regionFaModels::thermalShell + +Description + Thermal-shell finite-area model. It solves the energy + equation in 2D. The coupling with the 3D region is done through + the \c temperatureCoupledBase, plus \c faOption is available to + add extra sources on the shell such as \c externalHeatFluxSource etc. + +Usage + Example of the boundary condition specification: + \verbatim + <patchName> + { + // Mandatory/Optional (inherited) entries + ... + + // Mandatory entries (unmodifiable) + thermalShellModel thermalShell; + thermo + { + // subdictionary entries + } + + // Mandatory/Optional (derived) entries + ... + } + \endverbatim + + where the entries mean: + \table + Property | Description | Type | Reqd | Dflt + thermalShellModel | Type name: thermalShell | word | yes | - + thermo | Solid thermal properties | dictionary | yes | - + \endtable + + The inherited entries are elaborated in: + - \link thermalShellModel.H \endlink + +See also + - Foam::regionModels::thermalShellModels::thermalShellModel + +SourceFiles + thermalShell.C + thermalShellI.H + +\*---------------------------------------------------------------------------*/ + +#ifndef thermalShell_H +#define thermalShell_H + +#include "volFieldsFwd.H" +#include "thermalShellModel.H" +#include "solidProperties.H" +#include "faMesh.H" +#include "faCFD.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace regionModels +{ + +/*---------------------------------------------------------------------------*\ + Class thermalShell Declaration +\*---------------------------------------------------------------------------*/ + +class thermalShell +: + public thermalShellModel +{ + // Private Member Functions + + //- Initialize thermalShell + void init(); + + +protected: + + // Protected Data + + // Solution parameters + + //- Number of non orthogonal correctors + label nNonOrthCorr_; + + + // Thermo properties + + //- Solid properties + solidProperties thermo_; + + + // Source term fields + + //- External surface energy source / [J/m2/s] + areaScalarField qs_; + + //- Thickness + areaScalarField h_; + + + // Protected Member Functions + + //- Read control parameters from dictionary + virtual bool read(const dictionary& dict); + + + // Equations + + //- Solve energy equation + void solveEnergy(); + + +public: + + //- Runtime type information + TypeName("thermalShell"); + + + // Constructors + + //- Construct from components and dict + thermalShell + ( + const word& modelType, + const fvPatch& patch, + const dictionary& dict + ); + + //- No copy construct + thermalShell(const thermalShell&) = delete; + + //- No copy assignment + void operator=(const thermalShell&) = delete; + + + //- Destructor + virtual ~thermalShell() = default; + + + // Member Functions + + // Fields + + //- Return the film specific heat capacity [J/kg/K] + const tmp<areaScalarField> Cp() const; + + //- Return density [Kg/m3] + const tmp<areaScalarField> rho() const; + + //- Return thermal conductivity [W/m/K] + const tmp<areaScalarField> kappa() const; + + + // Evolution + + //- Pre-evolve thermal baffle + virtual void preEvolveRegion(); + + //- Evolve the thermal baffle + virtual void evolveRegion(); + + + // IO + + //- Provide some feedback + virtual void info(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace regionModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +#endif + +// ************************************************************************* // diff --git a/src/regionFaModels/thermalShellModel/thermalShellModel.C b/src/regionFaModels/thermalShellModel/thermalShellModel.C new file mode 100644 index 0000000000000000000000000000000000000000..4ee3c206e35e6ebf57b0e305dc5aa6f12f6c23ad --- /dev/null +++ b/src/regionFaModels/thermalShellModel/thermalShellModel.C @@ -0,0 +1,121 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "thermalShellModel.H" +#include "faMesh.H" +#include "fvMesh.H" +#include "fvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace regionModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(thermalShellModel, 0); + +defineRunTimeSelectionTable(thermalShellModel, dictionary); + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +bool thermalShellModel::read(const dictionary& dict) +{ + if (regionFaModel::read(dict)) + { + return true; + } + + return false; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +thermalShellModel::thermalShellModel +( + const word& modelType, + const fvPatch& p, + const dictionary& dict +) +: + regionFaModel(p, "thermalShell", modelType, dict, true), + TName_(dict.get<word>("T")), + Tp_(p.boundaryMesh().mesh().lookupObject<volScalarField>(TName_)), + T_ + ( + IOobject + ( + "Ts_" + regionName_, + p.boundaryMesh().mesh().time().timeName(), + p.boundaryMesh().mesh(), + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + regionMesh() + ), + faOptions_(Foam::fa::options::New(p)) +{ + if (!faOptions_.optionList::size()) + { + Info << "No finite area options present" << endl; + } +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void thermalShellModel::preEvolveRegion() +{} + + +const Foam::volScalarField& thermalShellModel::Tp() const +{ + return Tp_; +} + + +const Foam::areaScalarField& thermalShellModel::T() const +{ + return T_; +} + + +Foam::fa::options& thermalShellModel::faOptions() +{ + return faOptions_; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace regionModels +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/regionFaModels/thermalShellModel/thermalShellModel.H b/src/regionFaModels/thermalShellModel/thermalShellModel.H new file mode 100644 index 0000000000000000000000000000000000000000..2b2e9ec282980584ea472a5eff0af75185c7de38 --- /dev/null +++ b/src/regionFaModels/thermalShellModel/thermalShellModel.H @@ -0,0 +1,205 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +Class + Foam::regionModels::thermalShellModels::thermalShellModel + +Description + Intermediate class for thermal-shell finite-area models. + +Usage + Example of the boundary condition specification: + \verbatim + <patchName> + { + // Mandatory/Optional (inherited) entries + ... + + // Mandatory entries (unmodifiable) + T <Tname>; + + // Optional entries (unmodifiable) + thermalShellModel <thermalShellModelName>; + + // Mandatory/Optional (derived) entries + ... + } + \endverbatim + + where the entries mean: + \table + Property | Description | Type | Reqd | Dflt + T | Name of operand temperature field | word | yes | - + thermalShellModel | Name of thermal-shell model <!-- + --> | word | no | thermalShell + \endtable + + The inherited entries are elaborated in: + - \link regionFaModel.H \endlink + +SourceFiles + thermalShellModel.C + thermalShellModelNew.C + +\*---------------------------------------------------------------------------*/ + +#ifndef thermalShellModel_H +#define thermalShellModel_H + +#include "runTimeSelectionTables.H" +#include "autoPtr.H" +#include "areaFieldsFwd.H" +#include "volFieldsFwd.H" +#include "regionFaModel.H" +#include "faOptions.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace regionModels +{ + +/*---------------------------------------------------------------------------*\ + Class thermalShellModel Declaration +\*---------------------------------------------------------------------------*/ + +class thermalShellModel +: + public regionFaModel +{ + // Private Member Functions + + //- Initialize thermal Baffle + void init(); + + +protected: + + // Protected Data + + //- Name of the temperature field + word TName_; + + //- Primary region temperature + const volScalarField& Tp_; + + //- Shell temperature + areaScalarField T_; + + //- Pointer to faOptions + Foam::fa::options& faOptions_; + + + // Protected Member Functions + + //- Read control parameters from dictionary + virtual bool read(const dictionary&); + + +public: + + //- Runtime type information + TypeName("thermalShellModel"); + + + // Declare runtime constructor selection tables + + declareRunTimeSelectionTable + ( + autoPtr, + thermalShellModel, + dictionary, + ( + const word& modelType, + const fvPatch& patch, + const dictionary& dict + ), + (modelType, patch, dict) + ); + + + // Constructors + + //- Construct from type name and mesh and dict + thermalShellModel + ( + const word& modelType, + const fvPatch& patch, + const dictionary& dict + ); + + //- No copy construct + thermalShellModel(const thermalShellModel&) = delete; + + //- No copy assignment + void operator=(const thermalShellModel&) = delete; + + + // Selectors + + //- Return a reference to the selected model using dictionary + static autoPtr<thermalShellModel> New + ( + const fvPatch& patch, + const dictionary& dict + ); + + + //- Destructor + virtual ~thermalShellModel() = default; + + + // Member Functions + + // Access + + //- Return primary region temperature + const volScalarField& Tp() const; + + //- Return shell temperature + const areaScalarField& T() const; + + //- Return faOptions + Foam::fa::options& faOptions(); + + + // Evolution + + //- Pre-evolve region + virtual void preEvolveRegion(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace regionModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/regionFaModels/thermalShellModel/thermalShellModelNew.C b/src/regionFaModels/thermalShellModel/thermalShellModelNew.C new file mode 100644 index 0000000000000000000000000000000000000000..71848973d9335ff6572679e42178a3d9b72c864f --- /dev/null +++ b/src/regionFaModels/thermalShellModel/thermalShellModelNew.C @@ -0,0 +1,69 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "thermalShellModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace regionModels +{ + +// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // + +autoPtr<thermalShellModel> thermalShellModel::New +( + const fvPatch& p, + const dictionary& dict +) +{ + const word modelType = + dict.getOrDefault<word>("thermalShellModel", "thermalShell"); + + auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); + + if (!cstrIter.found()) + { + FatalErrorInFunction + << "Unknown thermalShellModel type " + << modelType << nl << nl + << "Valid thermalShellModel types :" << nl + << dictionaryConstructorTablePtr_->sortedToc() + << exit(FatalError); + } + + return autoPtr<thermalShellModel>(cstrIter()(modelType, p, dict)); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace regionModels +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/regionFaModels/vibrationShellModel/vibrationShellModel.C b/src/regionFaModels/vibrationShellModel/vibrationShellModel.C new file mode 100644 index 0000000000000000000000000000000000000000..ea309868a0de69e6d401c67ac5f17812733040fe --- /dev/null +++ b/src/regionFaModels/vibrationShellModel/vibrationShellModel.C @@ -0,0 +1,148 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "vibrationShellModel.H" +#include "faMesh.H" +#include "fvMesh.H" +#include "fvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace regionModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(vibrationShellModel, 0); + +defineRunTimeSelectionTable(vibrationShellModel, dictionary); + + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +bool vibrationShellModel::read(const dictionary& dict) +{ + if (regionFaModel::read(dict)) + { + return true; + } + + return false; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +vibrationShellModel::vibrationShellModel +( + const word& modelType, + const fvPatch& p, + const dictionary& dict +) +: + regionFaModel(p, "vibratingShell", modelType, dict, true), + pName_(dict.get<word>("p")), + pa_(p.boundaryMesh().mesh().lookupObject<volScalarField>(pName_)), + w_ + ( + IOobject + ( + "ws_" + regionName_, + p.boundaryMesh().mesh().time().timeName(), + p.boundaryMesh().mesh(), + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + regionMesh() + ), + a_ + ( + IOobject + ( + "as_" + regionName_, + p.boundaryMesh().mesh().time().timeName(), + p.boundaryMesh().mesh(), + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + regionMesh(), + dimensionedScalar(dimAcceleration, Zero) + ), + faOptions_(Foam::fa::options::New(p)), + solid_(dict.subDict("solid")) +{ + if (!faOptions_.optionList::size()) + { + Info << "No finite area options present" << endl; + } +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void vibrationShellModel::preEvolveRegion() +{} + + +const Foam::volScalarField& vibrationShellModel::pa() const +{ + return pa_; +} + + +const Foam::areaScalarField& vibrationShellModel::w() const +{ + return w_; +} + + +const Foam::areaScalarField& vibrationShellModel::a() const +{ + return a_; +} + + +Foam::fa::options& vibrationShellModel::faOptions() +{ + return faOptions_; +} + + +const Foam::solidProperties& vibrationShellModel::solid() const +{ + return solid_; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace regionModels +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/regionFaModels/vibrationShellModel/vibrationShellModel.H b/src/regionFaModels/vibrationShellModel/vibrationShellModel.H new file mode 100644 index 0000000000000000000000000000000000000000..566d4fd2bd0382aa0396281b857f288876600fdd --- /dev/null +++ b/src/regionFaModels/vibrationShellModel/vibrationShellModel.H @@ -0,0 +1,218 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +Class + Foam::regionModels::thermalShellModels::vibrationShellModel + +Description + Intermediate class for vibration-shell finite-area models. + +Usage + Example of the boundary condition specification: + \verbatim + <patchName> + { + // Mandatory/Optional (inherited) entries + ... + + // Mandatory entries (unmodifiable) + vibrationShellModel <thermalShellModelName>; + p <pName>; + + solid + { + // subdictionary entries + } + + // Mandatory/Optional (derived) entries + ... + } + \endverbatim + + where the entries mean: + \table + Property | Description | Type | Reqd | Dflt + vibrationShellModel | Name of vibration-shell model | word | yes | - + p | Name of the coupled field in the primary <!-- + --> region | word | yes | - + solid | Solid properties | dictionary | yes | - + \endtable + + The inherited entries are elaborated in: + - \link regionFaModel.H \endlink + +SourceFiles + vibrationShellModel.C + +\*---------------------------------------------------------------------------*/ + +#ifndef thermalShellModel_H +#define thermalShellModel_H + +#include "runTimeSelectionTables.H" +#include "autoPtr.H" +#include "areaFieldsFwd.H" +#include "volFieldsFwd.H" +#include "regionFaModel.H" +#include "faOptions.H" +#include "solidProperties.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace regionModels +{ + +/*---------------------------------------------------------------------------*\ + Class vibrationShellModel Declaration +\*---------------------------------------------------------------------------*/ + +class vibrationShellModel +: + public regionFaModel +{ + // Private Member Functions + + //- No copy construct + vibrationShellModel(const vibrationShellModel&) = delete; + + //- No copy assignment + void operator=(const vibrationShellModel&) = delete; + + +protected: + + // Protected Data + + //- Name of the coupled field in the primary region + word pName_; + + //- Primary region acoustic pressure + const volScalarField& pa_; + + //- Shell displacement + areaScalarField w_; + + //- Shell acceleration + areaScalarField a_; + + //- Pointer to faOptions + Foam::fa::options& faOptions_; + + //- Solid properties + solidProperties solid_; + + + // Protected Member Functions + + //- Read control parameters from dictionary + virtual bool read(const dictionary&); + + +public: + + //- Runtime type information + TypeName("vibrationShellModel"); + + + // Declare runtime constructor selection tables + + declareRunTimeSelectionTable + ( + autoPtr, + vibrationShellModel, + dictionary, + ( + const word& modelType, + const fvPatch& patch, + const dictionary& dict + ), + (modelType, patch, dict) + ); + + + // Constructors + + //- Construct from type name and mesh and dict + vibrationShellModel + ( + const word& modelType, + const fvPatch& patch, + const dictionary& dict + ); + + + // Selectors + + //- Return a reference to the selected model using dictionary + static autoPtr<vibrationShellModel> New + ( + const fvPatch& patch, + const dictionary& dict + ); + + + //- Destructor + virtual ~vibrationShellModel() = default; + + + // Member Functions + + // Access + + //- Return primary region pa + const volScalarField& pa() const; + + //- Return shell displacement + const areaScalarField& w() const; + + //- Return shell acceleration + const areaScalarField& a() const; + + //- Return faOptions + Foam::fa::options& faOptions(); + + //- Return solid properties + const solidProperties& solid() const; + + + // Evolution + + //- Pre-evolve region + virtual void preEvolveRegion(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace regionModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/regionFaModels/vibrationShellModel/vibrationShellModelNew.C b/src/regionFaModels/vibrationShellModel/vibrationShellModelNew.C new file mode 100644 index 0000000000000000000000000000000000000000..01234e3451129aa36a52ea9eb69b5c776134400d --- /dev/null +++ b/src/regionFaModels/vibrationShellModel/vibrationShellModelNew.C @@ -0,0 +1,68 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "vibrationShellModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace regionModels +{ + +// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // + +autoPtr<vibrationShellModel> vibrationShellModel::New +( + const fvPatch& p, + const dictionary& dict +) +{ + const word modelType = dict.get<word>("vibrationShellModel"); + + auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); + + if (!cstrIter.found()) + { + FatalErrorInFunction + << "Unknown vibrationShellModel type " + << modelType << nl << nl + << "Valid vibrationShellModel types :" << nl + << dictionaryConstructorTablePtr_->sortedToc() + << exit(FatalError); + } + + return autoPtr<vibrationShellModel>(cstrIter()(modelType, p, dict)); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace regionModels +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/surfMesh/writers/boundaryData/boundaryDataSurfaceWriter.H b/src/surfMesh/writers/boundaryData/boundaryDataSurfaceWriter.H index f8628882fed39cb3a09ae41cd55fadbf09f93c0a..65beade59151808bbda84068ca31f370ee1b9f3d 100644 --- a/src/surfMesh/writers/boundaryData/boundaryDataSurfaceWriter.H +++ b/src/surfMesh/writers/boundaryData/boundaryDataSurfaceWriter.H @@ -159,6 +159,9 @@ class boundaryDataWriter // Private Member Functions + //- Write option (default: IOstream::ASCII) + IOstream::streamFormat writeFormat_; + //- Templated write field operation template<class Type> fileName writeTemplate diff --git a/src/thermophysicalModels/thermophysicalProperties/solidProperties/C/C.C b/src/thermophysicalModels/thermophysicalProperties/solidProperties/C/C.C index 173eddf86d79bd5974798326f93dc412ea543e37..95315348a63e3008d92f9dd025d0cebebf859217 100644 --- a/src/thermophysicalModels/thermophysicalProperties/solidProperties/C/C.C +++ b/src/thermophysicalModels/thermophysicalProperties/solidProperties/C/C.C @@ -42,7 +42,7 @@ namespace Foam Foam::C::C() : - solidProperties(2010, 710, 0.04, 0.0, 1.0, 12.011) + solidProperties(2010, 710, 0.04, 0.0, 1.0, 12.011, 0.0, 0.0) { if (debug) { diff --git a/src/thermophysicalModels/thermophysicalProperties/solidProperties/CaCO3/CaCO3.C b/src/thermophysicalModels/thermophysicalProperties/solidProperties/CaCO3/CaCO3.C index 03fae10e83014669de4627292a9d6731b437cd9c..c4e2eae0b9c8af90ac5107dd67d0d5181a126182 100644 --- a/src/thermophysicalModels/thermophysicalProperties/solidProperties/CaCO3/CaCO3.C +++ b/src/thermophysicalModels/thermophysicalProperties/solidProperties/CaCO3/CaCO3.C @@ -42,7 +42,7 @@ namespace Foam Foam::CaCO3::CaCO3() : - solidProperties(2710, 850, 1.3, 0.0, 1.0, 100.086) + solidProperties(2710, 850, 1.3, 0.0, 1.0, 100.086, 0.0, 0.0) { if (debug) { diff --git a/src/thermophysicalModels/thermophysicalProperties/solidProperties/ash/ash.C b/src/thermophysicalModels/thermophysicalProperties/solidProperties/ash/ash.C index cd41a4824bad77d339b5629f7a1c709ce81cfff2..e6ace630763c2e8ea6072a6430fd54b08167e5e6 100644 --- a/src/thermophysicalModels/thermophysicalProperties/solidProperties/ash/ash.C +++ b/src/thermophysicalModels/thermophysicalProperties/solidProperties/ash/ash.C @@ -42,7 +42,7 @@ namespace Foam Foam::ash::ash() : - solidProperties(2010, 710, 0.04, 0.0, 1.0, 12.011) + solidProperties(2010, 710, 0.04, 0.0, 1.0, 12.011, 0.0, 0.0) { if (debug) { diff --git a/src/thermophysicalModels/thermophysicalProperties/solidProperties/solidProperties/solidProperties.C b/src/thermophysicalModels/thermophysicalProperties/solidProperties/solidProperties/solidProperties.C index d2afd3e5ec6c8d5f1ca465b92a998624ea3d034c..443c4c919789d9c3ab3df672bb148ae6e8e0600d 100644 --- a/src/thermophysicalModels/thermophysicalProperties/solidProperties/solidProperties/solidProperties.C +++ b/src/thermophysicalModels/thermophysicalProperties/solidProperties/solidProperties/solidProperties.C @@ -47,7 +47,9 @@ Foam::solidProperties::solidProperties scalar kappa, scalar Hf, scalar emissivity, - scalar W + scalar W, + scalar nu, + scalar E ) : rho_(rho), @@ -55,7 +57,9 @@ Foam::solidProperties::solidProperties kappa_(kappa), Hf_(Hf), emissivity_(emissivity), - W_(W) + W_(W), + nu_(nu), + E_(E) {} @@ -66,7 +70,9 @@ Foam::solidProperties::solidProperties(const dictionary& dict) kappa_(dict.getCompat<scalar>("kappa", {{"K", 1612}})), Hf_(dict.get<scalar>("Hf")), emissivity_(dict.get<scalar>("emissivity")), - W_(dict.get<scalar>("W")) + W_(dict.get<scalar>("W")), + nu_(dict.getOrDefault<scalar>("nu", 0.0)), + E_(dict.getOrDefault<scalar>("E", 0.0)) {} @@ -80,6 +86,8 @@ void Foam::solidProperties::readIfPresent(const dictionary& dict) dict.readIfPresent("Hf", Hf_); dict.readIfPresent("emissivity", emissivity_); dict.readIfPresent("W", W_); + dict.readIfPresent("nu", nu_); + dict.readIfPresent("E", E_); } @@ -90,7 +98,9 @@ void Foam::solidProperties::writeData(Ostream& os) const << kappa_ << token::SPACE << Hf_ << token::SPACE << emissivity_ << token::SPACE - << W_; + << W_ << token::SPACE + << nu_ << token::SPACE + << E_; } diff --git a/src/thermophysicalModels/thermophysicalProperties/solidProperties/solidProperties/solidProperties.H b/src/thermophysicalModels/thermophysicalProperties/solidProperties/solidProperties/solidProperties.H index 7c089ae0e443bfb0cba9c14444228d02c791f539..3d8729acc36295aa327f760bc1c6b629936cbf65 100644 --- a/src/thermophysicalModels/thermophysicalProperties/solidProperties/solidProperties/solidProperties.H +++ b/src/thermophysicalModels/thermophysicalProperties/solidProperties/solidProperties/solidProperties.H @@ -74,6 +74,12 @@ class solidProperties //- Molar weight [Kg/Kmol] scalar W_; + //- Poisson ration + scalar nu_; + + //- Young Modulus [N/m2] + scalar E_; + public: @@ -112,7 +118,9 @@ public: scalar kappa, scalar Hf, scalar emissivity, - scalar W + scalar W, + scalar nu, + scalar E ); //- Construct from dictionary @@ -163,6 +171,12 @@ public: //- Molar weight [Kg/Kmol] inline scalar W() const; + //- Poissons + inline scalar nu() const; + + //- Young modulus [N/m2] + inline scalar E() const; + // I-O diff --git a/src/thermophysicalModels/thermophysicalProperties/solidProperties/solidProperties/solidPropertiesI.H b/src/thermophysicalModels/thermophysicalProperties/solidProperties/solidProperties/solidPropertiesI.H index 16189b52b3d8038d8515c2d8596743586fe3a8c3..0f6148bdef62aa86a1c35295971fad56a5f10a8b 100644 --- a/src/thermophysicalModels/thermophysicalProperties/solidProperties/solidProperties/solidPropertiesI.H +++ b/src/thermophysicalModels/thermophysicalProperties/solidProperties/solidProperties/solidPropertiesI.H @@ -65,10 +65,23 @@ inline Foam::scalar Foam::solidProperties::emissivity() const return emissivity_; } + inline Foam::scalar Foam::solidProperties::W() const { return W_; } +inline Foam::scalar Foam::solidProperties::nu() const +{ + return nu_; +} + + +inline Foam::scalar Foam::solidProperties::E() const +{ + return E_; +} + + // ************************************************************************* // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/Allclean b/tutorials/compressible/acousticFoam/obliqueAirJet/Allclean new file mode 100755 index 0000000000000000000000000000000000000000..87adb1f6be77c6cc86ef936c3ea1750dd84cafca --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/Allclean @@ -0,0 +1,10 @@ +#!/bin/sh +cd "${0%/*}" || exit # Run from this directory +. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions # Tutorial clean functions +#------------------------------------------------------------------------------ + +(cd precursor && ./Allclean) + +(cd main && ./Allclean) + +# ----------------------------------------------------------------------------- diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/Allrun-parallel b/tutorials/compressible/acousticFoam/obliqueAirJet/Allrun-parallel new file mode 100755 index 0000000000000000000000000000000000000000..b3bcb07bffceb1a10268fe8c60eb800aff3052cb --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/Allrun-parallel @@ -0,0 +1,13 @@ +#!/bin/sh +cd "${0%/*}" || exit # Run from this directory +. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions +#------------------------------------------------------------------------------ + +# Run a precursor init case +(cd main && ./Allrun.pre) +(cd precursor && ./Allrun-parallel) + +# Run the main case +(cd main && ./Allrun-parallel) + +# ----------------------------------------------------------------------------- diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/main/0.orig/h_vibrationShell b/tutorials/compressible/acousticFoam/obliqueAirJet/main/0.orig/h_vibrationShell new file mode 100644 index 0000000000000000000000000000000000000000..7c4124634b09534a35b128da28da575bf80a20d6 --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/main/0.orig/h_vibrationShell @@ -0,0 +1,30 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class areaScalarField; + object h_ceilingShell; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 0 0 0 0 0]; + +internalField uniform 0.00485; + +boundaryField +{ + ".*" + { + type zeroGradient; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/main/0.orig/pa b/tutorials/compressible/acousticFoam/obliqueAirJet/main/0.orig/pa new file mode 100644 index 0000000000000000000000000000000000000000..0128164ecc970b379574e64a4d5c8080e8a4bd29 --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/main/0.orig/pa @@ -0,0 +1,67 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object pa; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + box + { + type acousticWaveTransmissive; + advectiveSpeed 340; + value $internalField; + } + + window + { + type vibrationShell; + active true; + p pa; + + solid + { + W 20; //Not used + rho 2500; + + kappa 200; + Cp 600; + Hf 0; + emissivity 0; + + E 7e10; + nu 0.22; + } + + region vibrationShell; + vibrationShellModel KirchhoffShell; + + f0 0.04; + f1 0; + f2 0; + + value $internalField; + } + + wall + { + type zeroGradient; + } +} + + +// ************************************************************************* // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/main/0.orig/ps_vibrationShell b/tutorials/compressible/acousticFoam/obliqueAirJet/main/0.orig/ps_vibrationShell new file mode 100644 index 0000000000000000000000000000000000000000..e708286b16c114d63ae03df9bbaad7fa222bae9d --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/main/0.orig/ps_vibrationShell @@ -0,0 +1,30 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class areaScalarField; + object ps; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + ".*" + { + type zeroGradient; + } +} + + +// ************************************************************************* // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/main/0.orig/ws_vibrationShell b/tutorials/compressible/acousticFoam/obliqueAirJet/main/0.orig/ws_vibrationShell new file mode 100644 index 0000000000000000000000000000000000000000..94a7f4b43f58e815dd734fdfa900c1ec174194b7 --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/main/0.orig/ws_vibrationShell @@ -0,0 +1,31 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class areaScalarField; + object wS; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 0 0 0 0 0]; + +internalField uniform 0.0; + +boundaryField +{ + sealing + { + type clampedPlate; + value $internalField; + } +} + + +// ************************************************************************* // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/main/Allclean b/tutorials/compressible/acousticFoam/obliqueAirJet/main/Allclean new file mode 100755 index 0000000000000000000000000000000000000000..25241a589c06d341d601d5c74690be6a0936198f --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/main/Allclean @@ -0,0 +1,12 @@ +#!/bin/sh +cd "${0%/*}" || exit # Run from this directory +. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions # Tutorial clean functions +#------------------------------------------------------------------------------ + +cleanCase0 + +rm -rf constant/boundaryData +rm -f constant/faMesh/faceLabels +rm -f constant/faMesh/faBoundary + +# ----------------------------------------------------------------------------- diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/main/Allrun-parallel b/tutorials/compressible/acousticFoam/obliqueAirJet/main/Allrun-parallel new file mode 100755 index 0000000000000000000000000000000000000000..28d05965c377fa25a9232f4e933ed2015cd1efca --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/main/Allrun-parallel @@ -0,0 +1,14 @@ +#!/bin/sh +cd "${0%/*}" || exit # Run from this directory +. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions +#------------------------------------------------------------------------------ + +restore0Dir + +runApplication decomposePar -force + +runParallel $(getApplication) + +runApplication reconstructPar + +#------------------------------------------------------------------------------ diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/main/Allrun.pre b/tutorials/compressible/acousticFoam/obliqueAirJet/main/Allrun.pre new file mode 100755 index 0000000000000000000000000000000000000000..8ac85a8f1732ed13b7fcd53c3efe2a1493aba61e --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/main/Allrun.pre @@ -0,0 +1,12 @@ +#!/bin/sh +cd "${0%/*}" || exit # Run from this directory +. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions +#------------------------------------------------------------------------------ + +runApplication blockMesh + +runApplication snappyHexMesh -overwrite + +runApplication makeFaMesh + +#------------------------------------------------------------------------------ diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/main/constant/faMesh/faMeshDefinition b/tutorials/compressible/acousticFoam/obliqueAirJet/main/constant/faMesh/faMeshDefinition new file mode 100644 index 0000000000000000000000000000000000000000..ed7eb31b7325b3bc302773b58a0c69994870fe6d --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/main/constant/faMesh/faMeshDefinition @@ -0,0 +1,30 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object faMeshDefinition; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +polyMeshPatches 1(window); + +boundary +{ + sealing + { + type patch; + ownerPolyPatch window; + neighbourPolyPatch fixedWall; + } +} + + +// ************************************************************************** // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/main/constant/transportProperties b/tutorials/compressible/acousticFoam/obliqueAirJet/main/constant/transportProperties new file mode 100644 index 0000000000000000000000000000000000000000..6697be20ead5a2a90b0928880d665b4063e15a46 --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/main/constant/transportProperties @@ -0,0 +1,21 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object transportProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +c0 340.; +rho 1.2; + + +// ************************************************************************* // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/main/constant/triSurface/window_box.stl.gz b/tutorials/compressible/acousticFoam/obliqueAirJet/main/constant/triSurface/window_box.stl.gz new file mode 100644 index 0000000000000000000000000000000000000000..06a030747e5659792b09eeac0ea5e7795267b000 Binary files /dev/null and b/tutorials/compressible/acousticFoam/obliqueAirJet/main/constant/triSurface/window_box.stl.gz differ diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/main/system/blockMeshDict b/tutorials/compressible/acousticFoam/obliqueAirJet/main/system/blockMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..cba6a4a543f974132883b8a6ca94e264de67702b --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/main/system/blockMeshDict @@ -0,0 +1,46 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +scale 1; + +vertices +( + (-.2 -.3 -.2) + (2.2 -.3 -.2) + (2.2 1.3 -.2) + (-.2 1.3 -.2) + + (-.2 -.3 2.2) + (2.2 -.3 2.2) + (2.2 1.3 2.2) + (-.2 1.3 2.2) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (15 10 15) simpleGrading (1 1 1) +); + +edges +( +); + +patches +( +); + + +// ************************************************************************* // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/main/system/controlDict b/tutorials/compressible/acousticFoam/obliqueAirJet/main/system/controlDict new file mode 100644 index 0000000000000000000000000000000000000000..2b7179b517931f82f216e75e3d1d939868d8bb17 --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/main/system/controlDict @@ -0,0 +1,48 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application acousticFoam; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 0.03; + +deltaT 1e-6; + +writeControl timeStep; + +writeInterval 200; + +purgeWrite 0; + +writeFormat binary; + +writePrecision 12; + +timeFormat general; + +timePrecision 12; + +runTimeModifiable yes; + +adjustTimeStep no; + + +// ************************************************************************* // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/main/system/decomposeParDict b/tutorials/compressible/acousticFoam/obliqueAirJet/main/system/decomposeParDict new file mode 100644 index 0000000000000000000000000000000000000000..1a5866caf17d2d3698b1f20b3d674f4fba06165a --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/main/system/decomposeParDict @@ -0,0 +1,22 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object decomposeParDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 6; + +method scotch; + + +// ************************************************************************* // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/main/system/faOptions b/tutorials/compressible/acousticFoam/obliqueAirJet/main/system/faOptions new file mode 100644 index 0000000000000000000000000000000000000000..2388c16064147cfac887dcfe6973e1fb72c73b0d --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/main/system/faOptions @@ -0,0 +1,31 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object faOptions; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +pressure +{ + type externalFileSource; + fieldName ws_vibrationShell; + tableName p; + active true; + timeStart 0.001; + duration 0.03; + region vibrationShell; + selectionMode all; + format binary; +} + + +//************************************************************************** // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/main/system/faSchemes b/tutorials/compressible/acousticFoam/obliqueAirJet/main/system/faSchemes new file mode 100644 index 0000000000000000000000000000000000000000..173abaa27949e2186c917f3985a89175d21b8679 --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/main/system/faSchemes @@ -0,0 +1,54 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object faSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +d2dt2Schemes +{ + default Euler; +} + +gradSchemes +{ + default leastSquares; + grad(ws_vibrationShell) leastSquares; +} + +divSchemes +{ + default Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default corrected; +} + + +// ************************************************************************* // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/main/system/faSolution b/tutorials/compressible/acousticFoam/obliqueAirJet/main/system/faSolution new file mode 100644 index 0000000000000000000000000000000000000000..14d0babd74dea50a26518e971883e8c099bb60eb --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/main/system/faSolution @@ -0,0 +1,37 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object faSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + ws_vibrationShell + { + solver diagonal; + preconditioner DILU; + tolerance 1e-08; + relTol 0; + } +} + +nNonOrthCorr 0; +nSubCycles 2; + +relaxationFactors +{ + w_vibrationShell 1; +} + + +// ************************************************************************* // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/main/system/fvSchemes b/tutorials/compressible/acousticFoam/obliqueAirJet/main/system/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..33b28299b6384d8ce4ffdec30441119fd4e21eaa --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/main/system/fvSchemes @@ -0,0 +1,59 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +d2dt2Schemes +{ + default Euler; +} + +gradSchemes +{ + default leastSquares; +} + +divSchemes +{ + default Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear orthogonal; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default orthogonal; +} + +wallDist +{ + method meshWave; + nRequired yes; +} + + +// ************************************************************************* // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/main/system/fvSolution b/tutorials/compressible/acousticFoam/obliqueAirJet/main/system/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..3e50abb3c3af5f2f9b8686c4fdda6aac55bc9cd7 --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/main/system/fvSolution @@ -0,0 +1,43 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + pa + { + solver GAMG; + tolerance 0; + relTol 0.01; + smoother DICGaussSeidel; + } + + paFinal + { + $p; + tolerance 1e-6; + relTol 0; + } +} + +PIMPLE +{ + nOuterCorrectors 3; + nCOrrectors 1; + nNonOrthogonalCorrectors 0; +} + + +// ************************************************************************* // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/main/system/snappyHexMeshDict b/tutorials/compressible/acousticFoam/obliqueAirJet/main/system/snappyHexMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..57c81d26cf2aa4969f10d59a3f291fc11cb92450 --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/main/system/snappyHexMeshDict @@ -0,0 +1,136 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object snappyHexMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +castellatedMesh true; +snap true; +addLayers false; + +geometry +{ + "window_box.stl" + { + type triSurfaceMesh; + name window_box; + regions + { + window {name window;} + box {name box;} + wall {name fixedWall;} + } + } + rbox_f + { + type searchableBox; + min (0.7 0 0.7); + max (1.3 0.5 1.3); + } + rbox_c + { + type searchableBox; + min (0 0 0); + max (2 1 2); + } +}; + + +castellatedMeshControls +{ + maxLocalCells 300000000; + maxGlobalCells 300000000; + minRefinementCells 10; + maxLoadUnbalance 0.10; + nCellsBetweenLevels 1; + + features + ( + ); + + refinementSurfaces + { + window_box + { + level (2 2); + regions + { + window{ level (3 3); } + } + } + } + + resolveFeatureAngle 30; + + refinementRegions + { + rbox_f + { + mode inside; + levels ((3 3)); + } + rbox_c + { + mode inside; + levels ((2 2)); + } + } + + locationInMesh (1.0134 0.543 1.0765); + + allowFreeStandingZoneFaces false; +} + + +snapControls +{ + nSmoothPatch 3; + tolerance 4.0; + nSolveIter 10; + nRelaxIter 5; + nFeatureSnapIter 10; + + explicitFeatureSnap false; + implicitFeatureSnap true; +} + + +addLayersControls +{} + + +meshQualityControls +{ + maxNonOrtho 65; + maxBoundarySkewness 20; + maxInternalSkewness 4; + maxConcave 80; + minVol 1e-13; + minTetQuality -1; + minArea -1; + minTwist 0.02; + minDeterminant 0.001; + minFaceWeight 0.05; + minVolRatio 0.01; + minTriangleTwist -1; + + nSmoothScale 4; + errorReduction 0.75; +} + +debug 0; + +mergeTolerance 1e-8; + + +// ************************************************************************* // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/0.orig/T b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/0.orig/T new file mode 100644 index 0000000000000000000000000000000000000000..92b10989cd6b42bd9374e527af2a02a9957f61bc --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/0.orig/T @@ -0,0 +1,45 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object T; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +Tinlet 293; + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform $Tinlet; + +boundaryField +{ + inlet + { + type fixedValue; + value uniform $Tinlet; + } + + "(window|fixedWall)" + { + type zeroGradient; + } + + box + { + type inletOutlet; + inletValue uniform $Tinlet; + value uniform $Tinlet; + } +} + + +// ************************************************************************* // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/0.orig/U b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/0.orig/U new file mode 100644 index 0000000000000000000000000000000000000000..6cecc4d74718120687fa409f12db627bc1a43a6f --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/0.orig/U @@ -0,0 +1,42 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: 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 fixedValue; + value uniform (0 -1 20); + } + + "(window|fixedWall)" + { + type noSlip; + } + + box + { + type pressureInletOutletVelocity; + value $internalField; + } +} + + +// ************************************************************************* // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/0.orig/alphat b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/0.orig/alphat new file mode 100644 index 0000000000000000000000000000000000000000..0d666dc61cdc89b1689d6ada8dcc4f1d74f3a257 --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/0.orig/alphat @@ -0,0 +1,43 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: 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; + } + + "(window|fixedWall)" + { + type compressible::alphatWallFunction; + value $internalField; + } + + box + { + type zeroGradient; + value $internalField; + } +} + + +// ************************************************************************* // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/0.orig/nuTilda b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/0.orig/nuTilda new file mode 100644 index 0000000000000000000000000000000000000000..4801adb0ddb372f03240298f5946c2d38fe6029e --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/0.orig/nuTilda @@ -0,0 +1,44 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object nuTilda; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -1 0 0 0 0]; + +internalField uniform 1.51e-05; + +boundaryField +{ + inlet + { + type fixedValue; + value $internalField; + } + + "(window|fixedWall)" + { + type zeroGradient; + value $internalField; + } + + box + { + type inletOutlet; + inletValue $internalField; + value $internalField; + } +} + + +// ************************************************************************* // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/0.orig/nut b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/0.orig/nut new file mode 100644 index 0000000000000000000000000000000000000000..bfe0450f34dd2e0af6d8906d9c6376300025d69e --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/0.orig/nut @@ -0,0 +1,43 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: 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 1e-5; + +boundaryField +{ + inlet + { + type calculated; + value $internalField; + } + + "(window|fixedWall)" + { + type nutUSpaldingWallFunction; + value $internalField; + } + + box + { + type calculated; + value $internalField; + } +} + + +// ************************************************************************* // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/0.orig/p b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/0.orig/p new file mode 100644 index 0000000000000000000000000000000000000000..7036695e94c5bfd986dfd5724fb495716b95b8a0 --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/0.orig/p @@ -0,0 +1,43 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: 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|window|fixedWall)" + { + type zeroGradient; + } + + box + { + type waveTransmissive; + field p; + phi phi; + rho rho; + psi thermo:psi; + gamma 1.4; + fieldInf 1e5; + lInf 5.0; + value $internalField; + } +} + + +// ************************************************************************* // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/Allclean b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/Allclean new file mode 100755 index 0000000000000000000000000000000000000000..91099c43c021465a716ffab192b8fa9e9b54c346 --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/Allclean @@ -0,0 +1,12 @@ +#!/bin/sh +cd "${0%/*}" || exit # Run from this directory +. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions # Tutorial clean functions +#------------------------------------------------------------------------------ + +vibroAcousticCase="../main" + +cleanCase0 + +rm -rf $vibroAcousticCase/constant/boundaryData + +# ----------------------------------------------------------------------------- diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/Allrun-parallel b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/Allrun-parallel new file mode 100755 index 0000000000000000000000000000000000000000..98c9f3495c8863de458769678984cafdc2a493cb --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/Allrun-parallel @@ -0,0 +1,20 @@ +#!/bin/sh +cd "${0%/*}" || exit # Run from this directory +. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions +#------------------------------------------------------------------------------ + +[[ -d constant/polyMesh ]] || runApplication ./Allrun.pre + +restore0Dir + +runApplication decomposePar + +runParallel $(getApplication) + +vibroAcousticCase="../main" +dataDir="postProcessing/surfaces/window" + +mkdir -p "$vibroAcousticCase/constant/boundaryData" +cp -rf "$dataDir" "$vibroAcousticCase/constant/boundaryData/window" + +# ----------------------------------------------------------------------------- diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/Allrun.pre b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/Allrun.pre new file mode 100755 index 0000000000000000000000000000000000000000..8a25610819714d122bb5e5351b86f761eb612ab3 --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/Allrun.pre @@ -0,0 +1,14 @@ +#!/bin/sh +cd "${0%/*}" || exit # Run from this directory +. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions +#------------------------------------------------------------------------------ + +runApplication extrudeMesh + +runApplication changeDictionary -constant + +runApplication topoSet + +runApplication createPatch -overwrite + +# ----------------------------------------------------------------------------- diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/constant/thermophysicalProperties b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/constant/thermophysicalProperties new file mode 100644 index 0000000000000000000000000000000000000000..9490a621cfd1d8694c32482398ec59ab7526a448 --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/constant/thermophysicalProperties @@ -0,0 +1,52 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object thermophysicalProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +thermoType +{ + type hePsiThermo; + mixture pureMixture; + transport const; + thermo hConst; + equationOfState perfectGas; + specie specie; + energy sensibleEnthalpy; +} + +mixture // air at room temperature (293 K) +{ + equationOfState + { + p0 103308.85730683322; + T0 225.24440406165331; + } + specie + { + molWeight 28.9; + } + thermodynamics + { + Cp 1005; + Hf 0; + } + transport + { + mu 1.82e-05; + Pr 0.71; + } +} + + +// ************************************************************************* // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/constant/turbulenceProperties b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/constant/turbulenceProperties new file mode 100644 index 0000000000000000000000000000000000000000..130f0d86b87fa3d8543556a8595afa0f9c510ef2 --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/constant/turbulenceProperties @@ -0,0 +1,36 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object turbulenceProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +simulationType LES; + +LES +{ + LESModel SpalartAllmarasDDES; + turbulence on; + printCoeffs on; + delta vanDriest; + vanDriestCoeffs + { + delta cubeRootVol; + cubeRootVolCoeffs + { + deltaCoeff 2.0; + } + } +} + + +// ************************************************************************* // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/system/blockMeshDict b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/system/blockMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..b0368fe2979118ee5209fb334e6edc04ced680b7 --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/system/blockMeshDict @@ -0,0 +1,231 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +scale 1; + +x_up 2.5; +x_down 3.5; +y_pad 4.0; +z_pad 1.0; + +x0 0.0; +x1 $x_up; +x2 #eval{ $x1 + 1.0 }; +x3 #eval{ $x2 + $x_down }; + +y0 0.0; +y1 $y_pad; +y2 #eval{ $y1 + 1.0 }; +y3 #eval{ $y2 + $y_pad }; + +z0 0.0; +z1 1.0; +z2 #eval{ $z1 + $z_pad }; + +nx1 40; +nx2 40; +nx3 80; +ny1 30; +ny2 $nx2; +ny3 $ny1; +nz1 $nx2; +nz2 40; + +vertices +( + ($x0 $y0 $z0) // 0 + ($x1 $y0 $z0) // 1 + ($x2 $y0 $z0) // 2 + ($x3 $y0 $z0) // 3 + ($x0 $y0 $z1) // 4 + ($x1 $y0 $z1) // 5 + ($x2 $y0 $z1) // 6 + ($x3 $y0 $z1) // 7 + ($x0 $y0 $z2) // 8 + ($x1 $y0 $z2) // 9 + ($x2 $y0 $z2) // 10 + ($x3 $y0 $z2) // 11 + + ($x0 $y1 $z0) // 12 + ($x1 $y1 $z0) // 13 + ($x2 $y1 $z0) // 14 + ($x3 $y1 $z0) // 15 + ($x0 $y1 $z1) // 16 + ($x1 $y1 $z1) // 17 + ($x2 $y1 $z1) // 18 + ($x3 $y1 $z1) // 19 + ($x0 $y1 $z2) // 20 + ($x1 $y1 $z2) // 21 + ($x2 $y1 $z2) // 22 + ($x3 $y1 $z2) // 23 + + ($x0 $y2 $z0) // 24 + ($x1 $y2 $z0) // 25 + ($x2 $y2 $z0) // 26 + ($x3 $y2 $z0) // 27 + ($x0 $y2 $z1) // 28 + ($x1 $y2 $z1) // 29 + ($x2 $y2 $z1) // 30 + ($x3 $y2 $z1) // 31 + ($x0 $y2 $z2) // 32 + ($x1 $y2 $z2) // 33 + ($x2 $y2 $z2) // 34 + ($x3 $y2 $z2) // 35 + + ($x0 $y3 $z0) // 36 + ($x1 $y3 $z0) // 37 + ($x2 $y3 $z0) // 38 + ($x3 $y3 $z0) // 39 + ($x0 $y3 $z1) // 40 + ($x1 $y3 $z1) // 41 + ($x2 $y3 $z1) // 42 + ($x3 $y3 $z1) // 43 + ($x0 $y3 $z2) // 44 + ($x1 $y3 $z2) // 45 + ($x2 $y3 $z2) // 46 + ($x3 $y3 $z2) // 47 +); + +edges +( +); + +x_up ((0.4 0.25 0.5)(0.3 0.25 0.75)(0.3 0.5 0.2)); +x_down ((0.15 0.45 3)(0.25 0.35 1.5)(0.6 0.2 5)); +z_top ((0.2 0.25 4)(0.6 0.5 1)(0.2 0.25 0.25)); +z_bottom ((0.2 0.25 4)(0.6 0.5 1)(0.2 0.25 0.25)); +y_side1 ((0.4 0.1 0.5)(0.4 0.2 0.5)(0.3 0.7 0.1)); +y_side2 ((0.3 0.7 10)(0.4 0.2 2)(0.4 0.1 2)); + +blocks +( + hex ( 0 1 13 12 4 5 17 16) ($nx1 $ny1 $nz1) simpleGrading ( $x_up $y_side1 $z_bottom) + hex ( 1 2 14 13 5 6 18 17) ($nx2 $ny1 $nz1) simpleGrading ( 1 $y_side1 $z_bottom) + hex ( 2 3 15 14 6 7 19 18) ($nx3 $ny1 $nz1) simpleGrading ($x_down $y_side1 $z_bottom) + hex ( 4 5 17 16 8 9 21 20) ($nx1 $ny1 $nz2) simpleGrading ( $x_up $y_side1 $z_top) + hex ( 5 6 18 17 9 10 22 21) ($nx2 $ny1 $nz2) simpleGrading ( 1 $y_side1 $z_top) + hex ( 6 7 19 18 10 11 23 22) ($nx3 $ny1 $nz2) simpleGrading ($x_down $y_side1 $z_top) + + hex (12 13 25 24 16 17 29 28) ($nx1 $ny2 $nz1) simpleGrading ($x_up 1 $z_bottom) + hex (14 15 27 26 18 19 31 30) ($nx3 $ny2 $nz1) simpleGrading ($x_down 1 $z_bottom) + hex (16 17 29 28 20 21 33 32) ($nx1 $ny2 $nz2) simpleGrading ($x_up 1 $z_top) + hex (17 18 30 29 21 22 34 33) ($nx2 $ny2 $nz2) simpleGrading (1 1 $z_top) + hex (18 19 31 30 22 23 35 34) ($nx3 $ny2 $nz2) simpleGrading ($x_down 1 $z_top) + + hex (24 25 37 36 28 29 41 40) ($nx1 $ny3 $nz1) simpleGrading ($x_up $y_side2 $z_bottom) + hex (25 26 38 37 29 30 42 41) ($nx2 $ny3 $nz1) simpleGrading (1 $y_side2 $z_bottom) + hex (26 27 39 38 30 31 43 42) ($nx3 $ny3 $nz1) simpleGrading ($x_down $y_side2 $z_bottom) + hex (28 29 41 40 32 33 45 44) ($nx1 $ny3 $nz2) simpleGrading ($x_up $y_side2 $z_top) + hex (29 30 42 41 33 34 46 45) ($nx2 $ny3 $nz2) simpleGrading (1 $y_side2 $z_top) + hex (30 31 43 42 34 35 47 46) ($nx3 $ny3 $nz2) simpleGrading ($x_down $y_side2 $z_top) +); + +boundary +( + cube + { + type wall; + faces + ( + (13 17 18 14) + (14 18 30 26) + (25 29 30 26) + (13 25 29 17) + (17 29 30 18) + ); + } + topAndBottom + { + type wall; + faces + ( + // floor + ( 0 12 13 1) + ( 1 13 14 2) + ( 2 14 15 3) + (12 24 25 13) + (14 26 27 15) + (24 36 37 25) + (25 37 38 26) + (26 38 39 27) + + // top + ( 8 9 21 20) + ( 9 10 22 21) + (10 11 23 22) + (20 21 33 32) + (21 22 34 33) + (22 23 35 34) + (32 33 45 44) + (33 34 46 45) + (34 35 47 46) + ); + } + + sides + { + type patch; + faces + ( + // minY + ( 0 1 5 4) + ( 1 2 6 5) + ( 2 3 7 6) + ( 4 5 9 8) + ( 5 6 10 9) + ( 6 7 11 10) + + // maxY + (36 40 41 37) + (37 41 42 38) + (38 42 43 39) + (40 44 45 41) + (41 45 46 42) + (42 46 47 43) + ); + } + + inlet + { + type patch; + faces + ( + ( 0 4 16 12) + (12 16 28 24) + (24 28 40 36) + ( 4 8 20 16) + (16 20 32 28) + (28 32 44 40) + ); + } + + outlet + { + type patch; + faces + ( + ( 3 15 19 7) + (15 27 31 19) + (27 39 43 31) + ( 7 19 23 11) + (19 31 35 23) + (31 43 47 35) + ); + } +); + + +// ************************************************************************* // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/system/changeDictionaryDict b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/system/changeDictionaryDict new file mode 100644 index 0000000000000000000000000000000000000000..c4df534a859b6e2bf4cc2f60185a831a323c597d --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/system/changeDictionaryDict @@ -0,0 +1,27 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object changeDictionaryDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +boundary +{ + box + { + type patch; + inGroups 1 ( patch ); + } +} + + +// ************************************************************************* // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/system/controlDict b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/system/controlDict new file mode 100644 index 0000000000000000000000000000000000000000..0879c268809654ca7a148d2da52e77173491cbad --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/system/controlDict @@ -0,0 +1,86 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application rhoPimpleAdiabaticFoam; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 0.05; + +deltaT 1e-5; + +writeControl timeStep; + +writeInterval 500; + +purgeWrite 0; + +writeFormat ascii; + +writePrecision 6; + +writeCompression off; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable true; + +adjustTimeStep no; + +maxCo 0.5; + +graphFormat raw; + +functions +{ + surfaces + { + type surfaces; + surfaceFormat boundaryData; + writeControl timeStep; + writeInterval 10; + interpolationScheme cell; + fields + ( + p + ); + formatOptions + { + boundaryData + { + format binary; + } + } + surfaces + { + window + { + type patch; + patches (window); + interpolate false; + } + } + } +} + + +// ************************************************************************* // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/system/createPatchDict b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/system/createPatchDict new file mode 100644 index 0000000000000000000000000000000000000000..0c80268fa725bdb051d6cd1772a93d89a3cab541 --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/system/createPatchDict @@ -0,0 +1,41 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object createPatchDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +pointSync false; + +// Patches to create. +patches +( + { + // Name of new patch + name inlet; + + // Dictionary to construct new patch from + patchInfo + { + type patch; + } + + // How to construct: either from 'patches' or 'set' + constructFrom set; + + // If constructFrom = set : name of faceSet + set f0; + } +); + + +// ************************************************************************* // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/system/decomposeParDict b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/system/decomposeParDict new file mode 100644 index 0000000000000000000000000000000000000000..59827275570208254a59ef7dfa64ee04e1bdff74 --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/system/decomposeParDict @@ -0,0 +1,22 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object decomposeParDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 6; + +method scotch; + + +// ************************************************************************* // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/system/extrudeMeshDict b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/system/extrudeMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..430caf8b89ab7c87d856c19da9368be8bb930491 --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/system/extrudeMeshDict @@ -0,0 +1,44 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object extrudeMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +constructFrom patch; + +// If construct from patch/mesh: +sourceCase "../main"; +sourcePatches (fixedWall window); + +exposedPatchName fixedWall; + +flipNormals false; + +extrudeModel linearDirection; + +nLayers 100; + +expansionRatio 1.0; + +linearDirectionCoeffs +{ + direction (0 -1 0); + thickness 1; +} + +mergeFaces false; + +mergeTol 0; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/system/fvSchemes b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/system/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..073db380a0b007d961a8ef4c903eb855985f533d --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/system/fvSchemes @@ -0,0 +1,63 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default backward 1; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default none; + div(phi,U) Gauss LUST grad(U); + div(phi,h) Gauss LUST grad(h); + div(phi,K) Gauss linear; + div(phiv,p) Gauss linear; + div(phi,k) Gauss limitedLinear 1; + div(phi,B) Gauss limitedLinear 1; + div(phi,nuTilda) Gauss limitedLinear 1; + div(B) Gauss linear; + div(phi,epsilon) Gauss limitedLinear 1; + div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default corrected; +} + +wallDist +{ + method meshWave; +} + + +// ************************************************************************* // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/system/fvSolution b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/system/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..468750044778bdc2f61f7dd03be6fe3f3dc5c65b --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/system/fvSolution @@ -0,0 +1,65 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + "(p|rho)" + { + solver PBiCGStab; + preconditioner DIC; + tolerance 1e-9; + relTol 0.01; + } + + "(p|rho)Final" + { + $p; + relTol 0; + } + + "(U|h|k|nuTilda|epsilon)" + { + solver PBiCGStab; + preconditioner DILU; + tolerance 1e-6; + relTol 0.01; + } + + "(U|h|k|nuTilda|epsilon)Final" + { + $U; + relTol 0; + } +} + +PIMPLE +{ + momentumPredictor yes; + nOuterCorrectors 1; + nCorrectors 2; + nNonOrthogonalCorrectors 0; +} + +relaxationFactors +{ + equations + { + ".*" 1; + } +} + + +// ************************************************************************* // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/system/topoSetDict b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/system/topoSetDict new file mode 100644 index 0000000000000000000000000000000000000000..37f685b78b49b818d076212dbc7aea14e7dcd80a --- /dev/null +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/precursor/system/topoSetDict @@ -0,0 +1,29 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2011 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object topoSetDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +actions +( + { + name f0; + type faceSet; + action new; + source boxToFace; + box (1 -0.7 -0.01)(1.5 -0.2 0.01); + } +); + + +// ************************************************************************* //