From 208de6b320dbdc494c31303d9721717159fb1f2d Mon Sep 17 00:00:00 2001 From: Andrew Heather <a.heather@opencfd.co.uk> Date: Wed, 29 Jun 2016 21:34:33 +0100 Subject: [PATCH] ENH: Added new mapFields function object --- .../functionObjects/utilities/Make/files | 2 - .../utilities/mapFields/IOmapFields.H | 49 ++++ .../utilities/mapFields/mapFields.C | 221 ++++++++++++++++++ .../utilities/mapFields/mapFields.H | 200 ++++++++++++++++ .../mapFields/mapFieldsFunctionObject.C | 42 ++++ .../mapFields/mapFieldsFunctionObject.H | 53 +++++ .../utilities/mapFields/mapFieldsTemplates.C | 65 ++++++ .../icoFoam/cavityMappingTest/0/U | 41 ++++ .../icoFoam/cavityMappingTest/0/p | 39 ++++ .../icoFoam/cavityMappingTest/Allclean | 11 + .../icoFoam/cavityMappingTest/Allrun-parallel | 22 ++ .../icoFoam/cavityMappingTest/Allrun-serial | 15 ++ .../constant/transportProperties | 21 ++ .../system/blockMeshDict.coarse | 75 ++++++ .../system/blockMeshDict.fine | 75 ++++++ .../system/coarseMesh/decomposeParDict | 23 ++ .../system/coarseMesh/fvSchemes | 43 ++++ .../system/coarseMesh/fvSolution | 19 ++ .../cavityMappingTest/system/controlDict | 66 ++++++ .../cavityMappingTest/system/decomposeParDict | 23 ++ .../cavityMappingTest/system/fvSchemes | 51 ++++ .../cavityMappingTest/system/fvSolution | 52 +++++ 22 files changed, 1206 insertions(+), 2 deletions(-) create mode 100644 src/postProcessing/functionObjects/utilities/mapFields/IOmapFields.H create mode 100644 src/postProcessing/functionObjects/utilities/mapFields/mapFields.C create mode 100644 src/postProcessing/functionObjects/utilities/mapFields/mapFields.H create mode 100644 src/postProcessing/functionObjects/utilities/mapFields/mapFieldsFunctionObject.C create mode 100644 src/postProcessing/functionObjects/utilities/mapFields/mapFieldsFunctionObject.H create mode 100644 src/postProcessing/functionObjects/utilities/mapFields/mapFieldsTemplates.C create mode 100644 tutorials/incompressible/icoFoam/cavityMappingTest/0/U create mode 100644 tutorials/incompressible/icoFoam/cavityMappingTest/0/p create mode 100755 tutorials/incompressible/icoFoam/cavityMappingTest/Allclean create mode 100755 tutorials/incompressible/icoFoam/cavityMappingTest/Allrun-parallel create mode 100755 tutorials/incompressible/icoFoam/cavityMappingTest/Allrun-serial create mode 100644 tutorials/incompressible/icoFoam/cavityMappingTest/constant/transportProperties create mode 100644 tutorials/incompressible/icoFoam/cavityMappingTest/system/blockMeshDict.coarse create mode 100644 tutorials/incompressible/icoFoam/cavityMappingTest/system/blockMeshDict.fine create mode 100644 tutorials/incompressible/icoFoam/cavityMappingTest/system/coarseMesh/decomposeParDict create mode 100644 tutorials/incompressible/icoFoam/cavityMappingTest/system/coarseMesh/fvSchemes create mode 100644 tutorials/incompressible/icoFoam/cavityMappingTest/system/coarseMesh/fvSolution create mode 100644 tutorials/incompressible/icoFoam/cavityMappingTest/system/controlDict create mode 100644 tutorials/incompressible/icoFoam/cavityMappingTest/system/decomposeParDict create mode 100644 tutorials/incompressible/icoFoam/cavityMappingTest/system/fvSchemes create mode 100644 tutorials/incompressible/icoFoam/cavityMappingTest/system/fvSolution diff --git a/src/postProcessing/functionObjects/utilities/Make/files b/src/postProcessing/functionObjects/utilities/Make/files index 89186248875..29ca6fe361c 100644 --- a/src/postProcessing/functionObjects/utilities/Make/files +++ b/src/postProcessing/functionObjects/utilities/Make/files @@ -18,10 +18,8 @@ fluxSummary/fluxSummaryFunctionObject.C Lambda2/Lambda2.C Lambda2/Lambda2FunctionObject.C -/* mapFields/mapFields.C mapFields/mapFieldsFunctionObject.C -*/ Peclet/Peclet.C Peclet/PecletFunctionObject.C diff --git a/src/postProcessing/functionObjects/utilities/mapFields/IOmapFields.H b/src/postProcessing/functionObjects/utilities/mapFields/IOmapFields.H new file mode 100644 index 00000000000..abcd07e3b27 --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/mapFields/IOmapFields.H @@ -0,0 +1,49 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Typedef + Foam::IOmapFields + +Description + Instance of the generic IOOutputFilter for mapFields. + +\*---------------------------------------------------------------------------*/ + +#ifndef IOmapFields_H +#define IOmapFields_H + +#include "mapFields.H" +#include "IOOutputFilter.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef IOOutputFilter<mapFields> IOmapFields; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/mapFields/mapFields.C b/src/postProcessing/functionObjects/utilities/mapFields/mapFields.C new file mode 100644 index 00000000000..136b3210057 --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/mapFields/mapFields.C @@ -0,0 +1,221 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "mapFields.H" +#include "meshToMesh.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(mapFieldsFO, 0); +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::mapFieldsFO::createInterpolation(const dictionary& dict) +{ + const fvMesh& meshTarget = static_cast<const fvMesh&>(obr_); + const word mapRegionName(dict.lookup("mapRegion")); + + if (log_) + { + Info<< name_ << ':' << nl + << " Reading mesh " << mapRegionName << endl; + } + + mapRegionPtr_.reset + ( + new fvMesh + ( + IOobject + ( + mapRegionName, + meshTarget.time().constant(), + meshTarget.time() + ) + ) + ); + const fvMesh& mapRegion = mapRegionPtr_(); + word mapMethodName(dict.lookup("mapMethod")); + if (!meshToMesh::interpolationMethodNames_.found(mapMethodName)) + { + FatalErrorInFunction + << type() << " " << name_ << ": unknown map method " + << mapMethodName << nl + << "Available methods include: " + << meshToMesh::interpolationMethodNames_.sortedToc() + << exit(FatalError); + } + + meshToMesh::interpolationMethod mapMethod + ( + meshToMesh::interpolationMethodNames_[mapMethodName] + ); + + // Lookup corresponding AMI method + word patchMapMethodName = + AMIPatchToPatchInterpolation::interpolationMethodToWord + ( + meshToMesh::interpolationMethodAMI(mapMethod) + ); + + // Optionally override + if (dict.readIfPresent("patchMapMethod", patchMapMethodName)) + { + if (log_) + Info<< " Patch mapping method: " << patchMapMethodName << endl; + } + + bool consistent = readBool(dict.lookup("consistent")); + + if (log_) Info<< " Creating mesh to mesh interpolation" << endl; + + if (consistent) + { + interpPtr_.reset + ( + new meshToMesh + ( + mapRegion, + meshTarget, + mapMethodName, + patchMapMethodName + ) + ); + } + else + { + HashTable<word> patchMap(dict.lookup("patchMap")); + wordList cuttingPatches(dict.lookup("cuttingPatches")); + + interpPtr_.reset + ( + new meshToMesh + ( + mapRegion, + meshTarget, + mapMethodName, + patchMapMethodName, + patchMap, + cuttingPatches + ) + ); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::mapFieldsFO::mapFieldsFO +( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool loadFromFiles +) +: + name_(name), + obr_(obr), + active_(true), + log_(true), + mapRegionPtr_(), + interpPtr_(), + fieldNames_() +{ + if (!isA<fvMesh>(obr_)) + { + active_ = false; + WarningInFunction + << "No fvMesh available, deactivating " << name_ << nl + << endl; + } + + read(dict); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::mapFieldsFO::~mapFieldsFO() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::mapFieldsFO::read(const dictionary& dict) +{ + if (active_) + { + log_.readIfPresent("log", dict); + dict.lookup("fields") >> fieldNames_; + + createInterpolation(dict); + } +} + + +void Foam::mapFieldsFO::execute() +{} + + +void Foam::mapFieldsFO::end() +{} + + +void Foam::mapFieldsFO::timeSet() +{} + + +void Foam::mapFieldsFO::write() +{ + if (active_) + { + if (log_) Info + << type() << " " << name_ << " output:" << nl; + + bool ok = false; + + ok = writeFieldType<scalar>() || ok; + ok = writeFieldType<vector>() || ok; + ok = writeFieldType<sphericalTensor>() || ok; + ok = writeFieldType<symmTensor>() || ok; + ok = writeFieldType<tensor>() || ok; + + if (log_) + { + if (!ok) + { + Info<< " none" << nl; + } + + Info<< endl; + } + } +} + + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/mapFields/mapFields.H b/src/postProcessing/functionObjects/utilities/mapFields/mapFields.H new file mode 100644 index 00000000000..80c2ebe1193 --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/mapFields/mapFields.H @@ -0,0 +1,200 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::mapFields + +Group + grpUtilitiesFunctionObjects + +Description + Map fields from local mesh to secondary mesh at run-time. + + Example of function object specification to map fields: + \verbatim + mapFields1 + { + type mapFields; + functionObjectLibs ("libutilityFunctionObjects.so"); + ... + + mapRegion coarseMesh; + mapMethod cellVolumeWeight; + consistent yes; + + fields ("U.*" p); + } + + \heading Function object usage + \table + Property | Description | Required | Default value + type | Type name: mapFields | yes | + mapRgion | Name of region to map to | yes | + mapMethod | Mapping method | yes | + patchMapMethod | Patch mapping method | no | <auto> + consistent | Mapping meshes have consistent boundaries | yes | + fields | List of field names to map | yes | + log | Log to standard output | no | yes + \endtable + + +SourceFiles + mapFields.C + IOmapFields.H + +\*---------------------------------------------------------------------------*/ + +#ifndef mapFieldsFO_H +#define mapFieldsFO_H + +#include "volFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class objectRegistry; +class dictionary; +class polyMesh; +class mapPolyMesh; +class meshToMesh; + +/*---------------------------------------------------------------------------*\ + Class mapFields Declaration +\*---------------------------------------------------------------------------*/ + +class mapFieldsFO +{ + // Private data + + //- Name of this set of mapFields objects + word name_; + + //- Reference to the database + const objectRegistry& obr_; + + //- On/off switch + bool active_; + + //- Switch to send output to Info as well as to file + Switch log_; + + //- Locally cached map region mesh (map to this mesh) + autoPtr<fvMesh> mapRegionPtr_; + + //- Mesh-to-mesh interpolation + autoPtr<meshToMesh> interpPtr_; + + //- List of field names to interpolate + wordReList fieldNames_; + + + // Private Member Functions + + //- Disallow default bitwise copy construct + mapFieldsFO(const mapFieldsFO&); + + //- Disallow default bitwise assignment + void operator=(const mapFieldsFO&) = delete; + + //- Helper function to create the mesh-to-mesh interpolation + void createInterpolation(const dictionary& dict); + + //- Helper function to interpolate and write the fied + template<class Type> + bool writeFieldType() const; + + +public: + + //- Runtime type information + TypeName("mapFieldsFO"); + + + // Constructors + + //- Construct for given objectRegistry and dictionary. + // Allow the possibility to load fields from files + mapFieldsFO + ( + const word& name, + const objectRegistry&, + const dictionary&, + const bool loadFromFiles = false + ); + + + //- Destructor + virtual ~mapFieldsFO(); + + + // Member Functions + + //- Return name of the set of mapFields + virtual const word& name() const + { + return name_; + } + + //- Read the mapFields data + virtual void read(const dictionary&); + + //- Execute, currently does nothing + virtual void execute(); + + //- Execute at the final time-loop, currently does nothing + virtual void end(); + + //- Called when time was set at the end of the Time::operator++ + virtual void timeSet(); + + //- Calculate the mapFields and write + virtual void write(); + + //- Update for changes of mesh + virtual void updateMesh(const mapPolyMesh&) + {} + + //- Update for changes of mesh + virtual void movePoints(const polyMesh&) + {} +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "mapFieldsTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/mapFields/mapFieldsFunctionObject.C b/src/postProcessing/functionObjects/utilities/mapFields/mapFieldsFunctionObject.C new file mode 100644 index 00000000000..f9d94f7b517 --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/mapFields/mapFieldsFunctionObject.C @@ -0,0 +1,42 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "mapFieldsFunctionObject.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineNamedTemplateTypeNameAndDebug(mapFieldsFunctionObject, 0); + + addToRunTimeSelectionTable + ( + functionObject, + mapFieldsFunctionObject, + dictionary + ); +} + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/mapFields/mapFieldsFunctionObject.H b/src/postProcessing/functionObjects/utilities/mapFields/mapFieldsFunctionObject.H new file mode 100644 index 00000000000..087d93d230a --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/mapFields/mapFieldsFunctionObject.H @@ -0,0 +1,53 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Typedef + Foam::mapFieldsFunctionObject + +Description + FunctionObject wrapper around mapFields to allow it to be created + via the functions entry within controlDict. + +SourceFiles + mapFieldsFunctionObject.C + +\*---------------------------------------------------------------------------*/ + +#ifndef mapFieldsFunctionObject_H +#define mapFieldsFunctionObject_H + +#include "mapFields.H" +#include "OutputFilterFunctionObject.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef OutputFilterFunctionObject<mapFieldsFO> mapFieldsFunctionObject; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/mapFields/mapFieldsTemplates.C b/src/postProcessing/functionObjects/utilities/mapFields/mapFieldsTemplates.C new file mode 100644 index 00000000000..de269ea8674 --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/mapFields/mapFieldsTemplates.C @@ -0,0 +1,65 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "meshToMesh.H" + +template<class Type> +bool Foam::mapFieldsFO::writeFieldType() const +{ + typedef GeometricField<Type, fvPatchField, volMesh> FieldType; + + const fvMesh& mapRegion = mapRegionPtr_(); + + wordList fieldNames(obr_.names(FieldType::typeName)); + labelList selected = findStrings(fieldNames_, fieldNames); + forAll(selected, i) + { + const word& fieldName = fieldNames[selected[i]]; + const FieldType& field = obr_.lookupObject<FieldType>(fieldName); + + if (log_) Info << " " << fieldName; + + IOobject mapRegionIO + ( + fieldName, + field.time().timeName(), + mapRegion + ); + + tmp<FieldType> tfieldMapRegion(interpPtr_->mapTgtToSrc(field)); + + if (log_) Info<< ": interpolated"; + + FieldType fieldMapRegion(mapRegionIO, tfieldMapRegion); + fieldMapRegion.write(); + + if (log_) Info<< " and written" << nl; + } + + return selected.size() > 0; +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/icoFoam/cavityMappingTest/0/U b/tutorials/incompressible/icoFoam/cavityMappingTest/0/U new file mode 100644 index 00000000000..d7c2b911650 --- /dev/null +++ b/tutorials/incompressible/icoFoam/cavityMappingTest/0/U @@ -0,0 +1,41 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform (0 0 0); + +boundaryField +{ + movingWall + { + type fixedValue; + value uniform (1 0 0); + } + + fixedWalls + { + type fixedValue; + value uniform (0 0 0); + } + + frontAndBack + { + type empty; + } +} + +// ************************************************************************* // diff --git a/tutorials/incompressible/icoFoam/cavityMappingTest/0/p b/tutorials/incompressible/icoFoam/cavityMappingTest/0/p new file mode 100644 index 00000000000..0976329cedb --- /dev/null +++ b/tutorials/incompressible/icoFoam/cavityMappingTest/0/p @@ -0,0 +1,39 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object p; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -2 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + movingWall + { + type zeroGradient; + } + + fixedWalls + { + type zeroGradient; + } + + frontAndBack + { + type empty; + } +} + +// ************************************************************************* // diff --git a/tutorials/incompressible/icoFoam/cavityMappingTest/Allclean b/tutorials/incompressible/icoFoam/cavityMappingTest/Allclean new file mode 100755 index 00000000000..0280fc46544 --- /dev/null +++ b/tutorials/incompressible/icoFoam/cavityMappingTest/Allclean @@ -0,0 +1,11 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory + +# Source tutorial run functions +. $WM_PROJECT_DIR/bin/tools/CleanFunctions + +cleanCase + +rm -rf constant/coarseMesh + + diff --git a/tutorials/incompressible/icoFoam/cavityMappingTest/Allrun-parallel b/tutorials/incompressible/icoFoam/cavityMappingTest/Allrun-parallel new file mode 100755 index 00000000000..bd03d75d47d --- /dev/null +++ b/tutorials/incompressible/icoFoam/cavityMappingTest/Allrun-parallel @@ -0,0 +1,22 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory + +# Source tutorial run functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions + +runApplication -s coarseMesh blockMesh -dict system/blockMeshDict.coarse + +mkdir constant/coarseMesh +mv constant/polyMesh constant/coarseMesh + +runApplication -s fine blockMesh -dict system/blockMeshDict.fine + +runApplication -s fine decomposePar + +runApplication -s coarseMesh decomposePar -region coarseMesh + +runParallel $(getApplication) + +#runApplication -s fine reconstructPar +# +#runApplication -s coarseMesh reconstructPar -region coarseMesh diff --git a/tutorials/incompressible/icoFoam/cavityMappingTest/Allrun-serial b/tutorials/incompressible/icoFoam/cavityMappingTest/Allrun-serial new file mode 100755 index 00000000000..166a1200d59 --- /dev/null +++ b/tutorials/incompressible/icoFoam/cavityMappingTest/Allrun-serial @@ -0,0 +1,15 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory + +# Source tutorial run functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions + +runApplication -s coarseMesh blockMesh -dict system/blockMeshDict.coarse + +mkdir constant/coarseMesh +mv constant/polyMesh constant/coarseMesh + +runApplication -s fine blockMesh -dict system/blockMeshDict.fine + +runApplication $(getApplication) + diff --git a/tutorials/incompressible/icoFoam/cavityMappingTest/constant/transportProperties b/tutorials/incompressible/icoFoam/cavityMappingTest/constant/transportProperties new file mode 100644 index 00000000000..2509c116703 --- /dev/null +++ b/tutorials/incompressible/icoFoam/cavityMappingTest/constant/transportProperties @@ -0,0 +1,21 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object transportProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +nu [0 2 -1 0 0 0 0] 0.01; + + +// ************************************************************************* // diff --git a/tutorials/incompressible/icoFoam/cavityMappingTest/system/blockMeshDict.coarse b/tutorials/incompressible/icoFoam/cavityMappingTest/system/blockMeshDict.coarse new file mode 100644 index 00000000000..3118c894d87 --- /dev/null +++ b/tutorials/incompressible/icoFoam/cavityMappingTest/system/blockMeshDict.coarse @@ -0,0 +1,75 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +convertToMeters 0.1; + +vertices +( + (0 0 0) + (1 0 0) + (1 1 0) + (0 1 0) + (0 0 0.1) + (1 0 0.1) + (1 1 0.1) + (0 1 0.1) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (10 10 1) simpleGrading (1 1 1) +); + +edges +( +); + +boundary +( + movingWall + { + type wall; + faces + ( + (3 7 6 2) + ); + } + fixedWalls + { + type wall; + faces + ( + (0 4 7 3) + (2 6 5 1) + (1 5 4 0) + ); + } + frontAndBack + { + type empty; + faces + ( + (0 3 2 1) + (4 5 6 7) + ); + } +); + +mergePatchPairs +( +); + +// ************************************************************************* // diff --git a/tutorials/incompressible/icoFoam/cavityMappingTest/system/blockMeshDict.fine b/tutorials/incompressible/icoFoam/cavityMappingTest/system/blockMeshDict.fine new file mode 100644 index 00000000000..ff18fe91723 --- /dev/null +++ b/tutorials/incompressible/icoFoam/cavityMappingTest/system/blockMeshDict.fine @@ -0,0 +1,75 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +convertToMeters 0.1; + +vertices +( + (0 0 0) + (1 0 0) + (1 1 0) + (0 1 0) + (0 0 0.1) + (1 0 0.1) + (1 1 0.1) + (0 1 0.1) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (40 40 1) simpleGrading (1 1 1) +); + +edges +( +); + +boundary +( + movingWall + { + type wall; + faces + ( + (3 7 6 2) + ); + } + fixedWalls + { + type wall; + faces + ( + (0 4 7 3) + (2 6 5 1) + (1 5 4 0) + ); + } + frontAndBack + { + type empty; + faces + ( + (0 3 2 1) + (4 5 6 7) + ); + } +); + +mergePatchPairs +( +); + +// ************************************************************************* // diff --git a/tutorials/incompressible/icoFoam/cavityMappingTest/system/coarseMesh/decomposeParDict b/tutorials/incompressible/icoFoam/cavityMappingTest/system/coarseMesh/decomposeParDict new file mode 100644 index 00000000000..cf5823a268b --- /dev/null +++ b/tutorials/incompressible/icoFoam/cavityMappingTest/system/coarseMesh/decomposeParDict @@ -0,0 +1,23 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + note "mesh decomposition control dictionary"; + object decomposeParDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 4; + +method scotch; + + +// ************************************************************************* // diff --git a/tutorials/incompressible/icoFoam/cavityMappingTest/system/coarseMesh/fvSchemes b/tutorials/incompressible/icoFoam/cavityMappingTest/system/coarseMesh/fvSchemes new file mode 100644 index 00000000000..ed9c4fbcc41 --- /dev/null +++ b/tutorials/incompressible/icoFoam/cavityMappingTest/system/coarseMesh/fvSchemes @@ -0,0 +1,43 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ +} + +gradSchemes +{ +} + +divSchemes +{ +} + +laplacianSchemes +{ +} + +interpolationSchemes +{ +} + +snGradSchemes +{ +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/icoFoam/cavityMappingTest/system/coarseMesh/fvSolution b/tutorials/incompressible/icoFoam/cavityMappingTest/system/coarseMesh/fvSolution new file mode 100644 index 00000000000..cb6c43877e5 --- /dev/null +++ b/tutorials/incompressible/icoFoam/cavityMappingTest/system/coarseMesh/fvSolution @@ -0,0 +1,19 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +// ************************************************************************* // diff --git a/tutorials/incompressible/icoFoam/cavityMappingTest/system/controlDict b/tutorials/incompressible/icoFoam/cavityMappingTest/system/controlDict new file mode 100644 index 00000000000..ba55911fb4f --- /dev/null +++ b/tutorials/incompressible/icoFoam/cavityMappingTest/system/controlDict @@ -0,0 +1,66 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application icoFoam; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 0.5; + +deltaT 0.005; + +writeControl timeStep; + +writeInterval 20; + +purgeWrite 0; + +writeFormat ascii; + +writePrecision 6; + +writeCompression off; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable true; + +functions +{ + meshInterp1 + { + type mapFieldsFO; + functionObjectLibs ("libutilityFunctionObjects.so"); + outputControl timeStep; + outputInterval 1; + + mapRegion coarseMesh; + mapMethod cellVolumeWeight; + consistent yes; + + fields (U); // ("U.*" "p.*"); + } +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/icoFoam/cavityMappingTest/system/decomposeParDict b/tutorials/incompressible/icoFoam/cavityMappingTest/system/decomposeParDict new file mode 100644 index 00000000000..cf5823a268b --- /dev/null +++ b/tutorials/incompressible/icoFoam/cavityMappingTest/system/decomposeParDict @@ -0,0 +1,23 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + note "mesh decomposition control dictionary"; + object decomposeParDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 4; + +method scotch; + + +// ************************************************************************* // diff --git a/tutorials/incompressible/icoFoam/cavityMappingTest/system/fvSchemes b/tutorials/incompressible/icoFoam/cavityMappingTest/system/fvSchemes new file mode 100644 index 00000000000..b43ea748aca --- /dev/null +++ b/tutorials/incompressible/icoFoam/cavityMappingTest/system/fvSchemes @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; + grad(p) Gauss linear; +} + +divSchemes +{ + default none; + div(phi,U) Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear orthogonal; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default orthogonal; +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/icoFoam/cavityMappingTest/system/fvSolution b/tutorials/incompressible/icoFoam/cavityMappingTest/system/fvSolution new file mode 100644 index 00000000000..fb6e8e4622b --- /dev/null +++ b/tutorials/incompressible/icoFoam/cavityMappingTest/system/fvSolution @@ -0,0 +1,52 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + p + { + solver PCG; + preconditioner DIC; + tolerance 1e-06; + relTol 0.05; + } + + pFinal + { + $p; + relTol 0; + } + + U + { + solver smoothSolver; + smoother symGaussSeidel; + tolerance 1e-05; + relTol 0; + } +} + +PISO +{ + nCorrectors 2; + nNonOrthogonalCorrectors 0; + pRefCell 0; + pRefValue 0; +} + + +// ************************************************************************* // -- GitLab