diff --git a/.gitignore b/.gitignore index ac8ae3c1f..2bc8e9e9a 100644 --- a/.gitignore +++ b/.gitignore @@ -116,3 +116,8 @@ runs/ .project .settings/ *.swp + +# OpenFOAM solvers +**/Make/* +!**/Make/files +!**/Make/option diff --git a/changelog-entries/551.md b/changelog-entries/551.md new file mode 100644 index 000000000..86ff9b8ac --- /dev/null +++ b/changelog-entries/551.md @@ -0,0 +1 @@ +- Added OpenFOAM variant of the transport participant to the channel-transport tutorial. diff --git a/channel-transport/README.md b/channel-transport/README.md index 3f597ac24..8f187ea35 100644 --- a/channel-transport/README.md +++ b/channel-transport/README.md @@ -45,6 +45,8 @@ Transport participant: * Nutils with support for [adaptive mesh refinement](https://precice.org/couple-your-code-moving-or-changing-meshes.html#pseudo-reference-domain). For more information, have a look at the [Nutils adapter documentation](https://precice.org/adapter-nutils.html). This Nutils solver requires at least Nutils v7.0 and a preCICE release with [remeshing support](couple-your-code-moving-or-changing-meshes.html#remeshing-using-precice). +* OpenFOAM. This case uses a modified version of scalarTransportFoam, which recomputes `phi` after the preCICE adapter reads the velocity field. Find it in the `solver-openfoam` folder and build it with `wmake`. Read more details in the [OpenFOAM adapter](https://precice.org/adapter-openfoam-overview.html). + ## Running the simulation For the fluid solver, use Nutils for ease of installation and OpenFOAM for speed. diff --git a/channel-transport/solver-openfoam/Make/files b/channel-transport/solver-openfoam/Make/files new file mode 100644 index 000000000..6a9053551 --- /dev/null +++ b/channel-transport/solver-openfoam/Make/files @@ -0,0 +1,3 @@ +dynamicScalarTransportFoam.C + +EXE = $(FOAM_USER_APPBIN)/dynamicScalarTransportFoam diff --git a/channel-transport/solver-openfoam/Make/options b/channel-transport/solver-openfoam/Make/options new file mode 100644 index 000000000..acbe7a647 --- /dev/null +++ b/channel-transport/solver-openfoam/Make/options @@ -0,0 +1,10 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/sampling/lnInclude + +EXE_LIBS = \ + -lfiniteVolume \ + -lfvOptions \ + -lmeshTools \ + -lsampling diff --git a/channel-transport/solver-openfoam/clean.sh b/channel-transport/solver-openfoam/clean.sh new file mode 100755 index 000000000..2ca6224c6 --- /dev/null +++ b/channel-transport/solver-openfoam/clean.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +set -e -u + +wclean diff --git a/channel-transport/solver-openfoam/createFields.H b/channel-transport/solver-openfoam/createFields.H new file mode 100644 index 000000000..82417fbb0 --- /dev/null +++ b/channel-transport/solver-openfoam/createFields.H @@ -0,0 +1,43 @@ +Info << "Reading field T\n" + << endl; + +volScalarField T( + IOobject( + "T", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE), + mesh); + +Info << "Reading field U\n" + << endl; + +volVectorField U( + IOobject( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE), + mesh); + +Info << "Reading transportProperties\n" + << endl; + +IOdictionary transportProperties( + IOobject( + "transportProperties", + runTime.constant(), + mesh, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE)); + +Info << "Reading diffusivity DT\n" + << endl; + +dimensionedScalar DT("DT", dimViscosity, transportProperties); + +#include "createPhi.H" + +#include "createFvOptions.H" diff --git a/channel-transport/solver-openfoam/dynamicScalarTransportFoam.C b/channel-transport/solver-openfoam/dynamicScalarTransportFoam.C new file mode 100644 index 000000000..e36e0103e --- /dev/null +++ b/channel-transport/solver-openfoam/dynamicScalarTransportFoam.C @@ -0,0 +1,62 @@ +// +// This file is based on the OpenFOAM example application scalarTransportFoam +// +// GitLab link: https://gitlab.com/openfoam/core/openfoam/-/tree/master/applications/solvers/basic/scalarTransportFoam +// +// This modified version doesn't expect a static velocity field U, instead, it repomputes it every time step. +// Therefore it allows the preCICE adapter to provide the velocities. + +#include "fvCFD.H" +#include "fvOptions.H" +#include "simpleControl.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + argList::addNote( + "Dynamic scalar transport equation solver."); + +#include "addCheckCaseOptions.H" +#include "createMesh.H" +#include "createTime.H" +#include "setRootCaseLists.H" + + simpleControl simple(mesh); + +#include "createFields.H" + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info << "\nCalculating scalar transport\n" + << endl; + + while (simple.loop()) { + Info << "Time = " << runTime.timeName() << nl << endl; + + Info << "Recompute phi" << endl; + fvOptions.correct(U); + phi = fvc::flux(U); +#include "CourantNo.H" + + while (simple.correctNonOrthogonal()) { + fvScalarMatrix TEqn( + fvm::ddt(T) + fvm::div(phi, T) - fvm::laplacian(DT, T) == + fvOptions(T)); + + TEqn.relax(); + fvOptions.constrain(TEqn); + TEqn.solve(); + fvOptions.correct(T); + } + + runTime.write(); + } + + Info << "End\n" + << endl; + + return 0; +} + +// ************************************************************************* // diff --git a/channel-transport/transport-openfoam/.clang-format b/channel-transport/transport-openfoam/.clang-format new file mode 100644 index 000000000..00adea7a3 --- /dev/null +++ b/channel-transport/transport-openfoam/.clang-format @@ -0,0 +1,175 @@ +--- +Language: Cpp +# BasedOnStyle: LLVM +# +# Proposed clang-format-11 style for OpenFOAM, trying to follow the OpenFOAM style guide: +# https://develop.openfoam.com/Development/openfoam/-/wikis/coding/style/style +# Configuration developed for the OpenFOAM-preCICE adapter code: +# https://github.com/precice/openfoam-adapter +# Contribute to the discussion at the respective OpenFOAM issue: +# https://develop.openfoam.com/Development/openfoam/-/issues/1634 +# +# Keep `public:` at the first indentation level +AccessModifierOffset: -4 +# Undocumented guideline: align arguments after an open bracket. +AlignAfterOpenBracket: Align +AlignConsecutiveMacros: false +AlignConsecutiveAssignments: false +AlignConsecutiveBitFields: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: Right +# Align operands after operators (+,*,<<) (see BreakBeforeBinaryOperators) +AlignOperands: AlignAfterOperator +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: true +AllowAllConstructorInitializersOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortEnumsOnASingleLine: true +AllowShortBlocksOnASingleLine: Never +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortLambdasOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Always +AllowShortLoopsOnASingleLine: false +# Guideline: Splitting return type and function name +# (this guideline is apparently not strictly followed in OpenFOAM) +# AlwaysBreakAfterReturnType: All +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: Yes +BinPackArguments: false +BinPackParameters: false +# Covered by "BreakBeforeBraces" +BraceWrapping: + AfterCaseLabel: true + AfterClass: true + AfterControlStatement: Always + AfterEnum: true + AfterFunction: true + AfterNamespace: true + AfterObjCDeclaration: true + AfterStruct: true + AfterUnion: true + AfterExternBlock: true + BeforeCatch: true + BeforeElse: true + BeforeLambdaBody: true + BeforeWhile: true + IndentBraces: true + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +# Guideline (almost): Splitting long lines at an = sign. Indent after split. +# Guideline (almost): Splitting formulae over several lines. +BreakBeforeBinaryOperators: NonAssignment +# Always break before braces: if, for, functions, classes, etc. +BreakBeforeBraces: Allman +BreakBeforeInheritanceComma: false +BreakInheritanceList: BeforeColon +# Guideline (almost): Splitting logical tests over several lines. +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +# Undocumented guideline (almost): Have the initializer : in a new line. +BreakConstructorInitializers: BeforeColon +BreakStringLiterals: true +# Here we could set the 80 charactes limit, but that would lead to more aggressive changes. +ColumnLimit: 0 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 0 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DeriveLineEnding: true +DerivePointerAlignment: false +DisableFormat: false +# Undocumented guideline: add line after "public:" etc (since clang-format 12) +# EmptyLineAfterAccessModifier: Always +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: false +# Guideline: Macro loops are like for loops, but without a space. +ForEachMacros: + - forAllIters + - forAllConstIters + - forAllReverseIters + - forAllConstReverseIters + - forAll + - forAllReverse + - forAllIter + - forAllConstIter +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + SortPriority: 0 + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 3 + SortPriority: 0 + - Regex: '.*' + Priority: 1 + SortPriority: 0 +IncludeIsMainRegex: '(Test)?$' +IncludeIsMainSourceRegex: '' +IndentCaseLabels: false +IndentCaseBlocks: false +IndentGotoLabels: true +IndentPPDirectives: None +IndentExternBlock: AfterExternBlock +# Guideline: The normal indentation is 4 spaces per logical level. +IndentWidth: 4 +IndentWrappedFunctionNames: false +InsertTrailingCommas: None +KeepEmptyLinesAtTheStartOfBlocks: true +MacroBlockBegin: '' +MacroBlockEnd: '' +# Required to not change code following the guidelines +# "Leave two empty lines between sections" and +# "Use two empty lines between functions" +MaxEmptyLinesToKeep: 2 +NamespaceIndentation: None +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Left +ReflowComments: true +# Do not change the order of include statements (could be catastrophic for OpenFOAM) +SortIncludes: false +SortUsingDeclarations: false +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +# No "template " (guideline already used, but not documented) +SpaceAfterTemplateKeyword: false +SpaceBeforeAssignmentOperators: true +# No a{1} (no guideline) +SpaceBeforeCpp11BracedList: true +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +# Guideline: Spaces in "if ()", "for ()", but not "forAll ()". +SpaceBeforeParens: ControlStatementsExceptForEachMacros +# Guideline: Range-based for should have a space surrounding the ':'. +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInConditionalStatement: false +# No "arr[3] = [ 1, 2, 3 ]" (no guideline). +SpacesInContainerLiterals: false +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +SpaceBeforeSquareBrackets: false +# Treat the code as C++11 or later +Standard: Latest +StatementMacros: +TabWidth: 4 +UseCRLF: false +# Guideline: No tab characters - only use spaces for indentation. +UseTab: Never +WhitespaceSensitiveMacros: +... + diff --git a/channel-transport/transport-openfoam/.gitignore b/channel-transport/transport-openfoam/.gitignore new file mode 100644 index 000000000..e20d1247a --- /dev/null +++ b/channel-transport/transport-openfoam/.gitignore @@ -0,0 +1 @@ +0/ diff --git a/channel-transport/transport-openfoam/0.orig/T b/channel-transport/transport-openfoam/0.orig/T new file mode 100644 index 000000000..7a51af811 --- /dev/null +++ b/channel-transport/transport-openfoam/0.orig/T @@ -0,0 +1,44 @@ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object T; +} + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + inlet + { + type zeroGradient; + } + + outlet + { + type advective; + } + + obstacle + { + type zeroGradient; + } + + upperWall + { + type zeroGradient; + } + + lowerWall + { + type zeroGradient; + } + + frontAndBack + { + type empty; + } +} diff --git a/channel-transport/transport-openfoam/0.orig/U b/channel-transport/transport-openfoam/0.orig/U new file mode 100644 index 000000000..1f4cb2292 --- /dev/null +++ b/channel-transport/transport-openfoam/0.orig/U @@ -0,0 +1,39 @@ +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 $internalField; + } + outlet + { + type zeroGradient; + } + obstacle + { + type noSlip; + } + upperWall + { + type noSlip; + } + lowerWall + { + type noSlip; + } + frontAndBack + { + type empty; + } +} diff --git a/channel-transport/transport-openfoam/clean.sh b/channel-transport/transport-openfoam/clean.sh new file mode 100755 index 000000000..5120c1355 --- /dev/null +++ b/channel-transport/transport-openfoam/clean.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env sh +set -e -u + +. ../../tools/cleaning-tools.sh + +clean_openfoam . +rm -rf ./0/ diff --git a/channel-transport/transport-openfoam/constant/transportProperties b/channel-transport/transport-openfoam/constant/transportProperties new file mode 100644 index 000000000..8d841ddc5 --- /dev/null +++ b/channel-transport/transport-openfoam/constant/transportProperties @@ -0,0 +1,9 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object transportProperties; +} + +DT 0.1; diff --git a/channel-transport/transport-openfoam/createMesh.py b/channel-transport/transport-openfoam/createMesh.py new file mode 100755 index 000000000..d567572d5 --- /dev/null +++ b/channel-transport/transport-openfoam/createMesh.py @@ -0,0 +1,101 @@ +#!/bin/env -S uv run --script +# /// script +# requires-python = ">=3.14" +# dependencies = ["classy_blocks", "typing_extensions"] +# /// + +# Generator script for the system/blockMeshDict + +import classy_blocks as cb +import pathlib + +x0 = 0 +x1 = 2 +x2 = 3 +x3 = 5.5 +x4 = 6 + +y0 = 0 +y1 = 1 +y2 = 2 + +# Blocks + + +def blockFor(l, r, b, t): + return cb.Extrude(cb.Face([ + [l, b, 0], + [r, b, 0], + [r, t, 0], + [l, t, 0]]), 1) + + +lb = blockFor(x0, x1, y0, y1) +lt = blockFor(x0, x1, y1, y2) + +mt = blockFor(x1, x2, y1, y2) + +rt1 = blockFor(x2, x3, y1, y2) +rb1 = blockFor(x2, x3, y0, y1) +rt2 = blockFor(x3, x4, y1, y2) +rb2 = blockFor(x3, x4, y0, y1) + +# Patches + + +def patch(side: str, name: str, *items): + for i in items: + i.set_patch(side, name) + + +patch("left", "inlet", lb, lt) +patch("right", "outlet", rb2, rt2) + +patch("back", "upperWall", lt, mt, rt1, rt2) +patch("front", "lowerWall", lb, rb1, rb2) + +patch("right", "obstacle", lb) +patch("front", "obstacle", mt) +patch("left", "obstacle", rb1) + +for b in [lb, lt, mt, rt1, rt2, rb1, rb2]: + b.set_patch(["top", "bottom"], "frontAndBack") + +# Cells + + +def chop(x, *items): + for i in items: + i.chop(0, count=x) + i.chop(1, count=5) + i.chop(2, count=1) + + +chop(10, lb, lt, rb1, rt1) +chop(5, mt) + +rb2.chop(0, count=10, start_size=0.1) +rb2.chop(1, count=5) +rb2.chop(2, count=1) + +rt2.chop(0, count=10, start_size=0.1) +rt2.chop(1, count=5) +rt2.chop(2, count=1) + +# Mesh + +m = cb.Mesh() +m.add(lb) +m.add(lt) +m.add(mt) +m.add(rb1) +m.add(rb2) +m.add(rt1) +m.add(rt2) + +m.modify_patch("obstacle", "wall") +m.modify_patch("upperWall", "wall") +m.modify_patch("lowerWall", "wall") +m.modify_patch("frontAndBack", "empty") + +m.write(pathlib.Path(__file__).parent / "system" / "blockMeshDict") diff --git a/channel-transport/transport-openfoam/run.sh b/channel-transport/transport-openfoam/run.sh new file mode 100755 index 000000000..9a8884f2c --- /dev/null +++ b/channel-transport/transport-openfoam/run.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +set -e -u + +. ../../tools/log.sh +exec > >(tee --append "$LOGFILE") 2>&1 + +blockMesh +cp -r 0.orig 0 +setExprFields -time 0 + +../../tools/run-openfoam.sh "$@" +. ../../tools/openfoam-remove-empty-dirs.sh && openfoam_remove_empty_dirs + +close_log diff --git a/channel-transport/transport-openfoam/system/blockMeshDict b/channel-transport/transport-openfoam/system/blockMeshDict new file mode 100644 index 000000000..a5addedc3 --- /dev/null +++ b/channel-transport/transport-openfoam/system/blockMeshDict @@ -0,0 +1,158 @@ +/*---------------------------------------------------------------------------*\ +| ========= | | +| \ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \ / O peration | Script: ./createMesh.py | +| \ / A nd | Time: 2025-12-10 15:40:31.134565 | +| \/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +vertices +( + (0.00000000 0.00000000 0.00000000) // 0 + (2.00000000 0.00000000 0.00000000) // 1 + (2.00000000 1.00000000 0.00000000) // 2 + (0.00000000 1.00000000 0.00000000) // 3 + (0.00000000 0.00000000 1.00000000) // 4 + (2.00000000 0.00000000 1.00000000) // 5 + (2.00000000 1.00000000 1.00000000) // 6 + (0.00000000 1.00000000 1.00000000) // 7 + (2.00000000 2.00000000 0.00000000) // 8 + (0.00000000 2.00000000 0.00000000) // 9 + (2.00000000 2.00000000 1.00000000) // 10 + (0.00000000 2.00000000 1.00000000) // 11 + (3.00000000 1.00000000 0.00000000) // 12 + (3.00000000 2.00000000 0.00000000) // 13 + (3.00000000 1.00000000 1.00000000) // 14 + (3.00000000 2.00000000 1.00000000) // 15 + (3.00000000 0.00000000 0.00000000) // 16 + (5.50000000 0.00000000 0.00000000) // 17 + (5.50000000 1.00000000 0.00000000) // 18 + (3.00000000 0.00000000 1.00000000) // 19 + (5.50000000 0.00000000 1.00000000) // 20 + (5.50000000 1.00000000 1.00000000) // 21 + (6.00000000 0.00000000 0.00000000) // 22 + (6.00000000 1.00000000 0.00000000) // 23 + (6.00000000 0.00000000 1.00000000) // 24 + (6.00000000 1.00000000 1.00000000) // 25 + (5.50000000 2.00000000 0.00000000) // 26 + (5.50000000 2.00000000 1.00000000) // 27 + (6.00000000 2.00000000 0.00000000) // 28 + (6.00000000 2.00000000 1.00000000) // 29 +); + +blocks +( + hex ( 0 1 2 3 4 5 6 7 ) ( 10 5 1 ) simpleGrading ( 1 1 1 ) // 0 + hex ( 3 2 8 9 7 6 10 11 ) ( 10 5 1 ) simpleGrading ( 1 1 1 ) // 1 + hex ( 2 12 13 8 6 14 15 10 ) ( 5 5 1 ) simpleGrading ( 1 1 1 ) // 2 + hex ( 16 17 18 12 19 20 21 14 ) ( 10 5 1 ) simpleGrading ( 1 1 1 ) // 3 + hex ( 17 22 23 18 20 24 25 21 ) ( 10 5 1 ) simpleGrading ( 0.19032670369558663 1 1 ) // 4 + hex ( 12 18 26 13 14 21 27 15 ) ( 10 5 1 ) simpleGrading ( 1 1 1 ) // 5 + hex ( 18 23 28 26 21 25 29 27 ) ( 10 5 1 ) simpleGrading ( 0.19032670369558663 1 1 ) // 6 +); + +edges +( +); + +boundary +( + frontAndBack + { + type empty; + faces + ( + (14 21 27 15) + (6 14 15 10) + (2 12 13 8) + (18 23 28 26) + (16 17 18 12) + (17 22 23 18) + (0 1 2 3) + (12 18 26 13) + (19 20 21 14) + (7 6 10 11) + (20 24 25 21) + (3 2 8 9) + (4 5 6 7) + (21 25 29 27) + ); + } + + lowerWall + { + type wall; + faces + ( + (20 24 22 17) + (4 5 1 0) + (19 20 17 16) + ); + } + + obstacle + { + type wall; + faces + ( + (5 1 2 6) + (19 16 12 14) + (6 14 12 2) + ); + } + + inlet + { + type patch; + faces + ( + (7 3 9 11) + (4 0 3 7) + ); + } + + upperWall + { + type wall; + faces + ( + (27 29 28 26) + (15 27 26 13) + (11 10 8 9) + (10 15 13 8) + ); + } + + outlet + { + type patch; + faces + ( + (24 22 23 25) + (25 23 28 29) + ); + } + +); + +faces +( +); + +mergePatchPairs +( +); + +scale 1; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Created with classy_blocks: https://github.com/damogranlabs/classy_blocks // +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/channel-transport/transport-openfoam/system/controlDict b/channel-transport/transport-openfoam/system/controlDict new file mode 100644 index 000000000..ef74b7f99 --- /dev/null +++ b/channel-transport/transport-openfoam/system/controlDict @@ -0,0 +1,44 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object controlDict; +} + +application dynamicScalarTransportFoam; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 1.0; + +deltaT 0.005; + +writeControl adjustableRunTime; + +writeInterval 0.005; + +purgeWrite 0; + +writeFormat ascii; + +writePrecision 6; + +writeCompression off; + +timeFormat general; + +timePrecision 6; + +functions +{ + preCICE_Adapter + { + type preciceAdapterFunctionObject; + libs ("libpreciceAdapterFunctionObject.so"); + } +} diff --git a/channel-transport/transport-openfoam/system/decomposeParDict b/channel-transport/transport-openfoam/system/decomposeParDict new file mode 100644 index 000000000..f9eae003a --- /dev/null +++ b/channel-transport/transport-openfoam/system/decomposeParDict @@ -0,0 +1,16 @@ +FoamFile { + version 2.0; + class dictionary; + object decomposeParDict; + format ascii; +} + +numberOfSubdomains 4; + +method simple; + +simpleCoeffs +{ + n (2 2 1); + delta 0.001; +} \ No newline at end of file diff --git a/channel-transport/transport-openfoam/system/fvSchemes b/channel-transport/transport-openfoam/system/fvSchemes new file mode 100644 index 000000000..f3a636050 --- /dev/null +++ b/channel-transport/transport-openfoam/system/fvSchemes @@ -0,0 +1,50 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2312 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default none; + div(phi,T) Gauss linearUpwind grad(T); +} + +laplacianSchemes +{ + default none; + laplacian(DT,T) Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default corrected; +} + + +// ************************************************************************* // diff --git a/channel-transport/transport-openfoam/system/fvSolution b/channel-transport/transport-openfoam/system/fvSolution new file mode 100644 index 000000000..b258c9b1b --- /dev/null +++ b/channel-transport/transport-openfoam/system/fvSolution @@ -0,0 +1,35 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2312 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + T + { + solver PBiCGStab; + preconditioner DILU; + tolerance 1e-6; + relTol 0; + norm default; + } +} + +SIMPLE +{ + nNonOrthogonalCorrectors 0; +} + + +// ************************************************************************* // diff --git a/channel-transport/transport-openfoam/system/preciceDict b/channel-transport/transport-openfoam/system/preciceDict new file mode 100644 index 000000000..aca923918 --- /dev/null +++ b/channel-transport/transport-openfoam/system/preciceDict @@ -0,0 +1,37 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object preciceDict; +} + +preciceConfig "../precice-config.xml"; + +participant Transport; + +modules (FF); + +interfaces +{ + Interface1 + { + mesh Transport-Mesh; + patches (); + locations volumeCenters; + + readData + ( + Velocity + ); + + writeData + ( + ); + }; +}; + +FF +{ + solverType incompressible; +} diff --git a/channel-transport/transport-openfoam/system/setExprFieldsDict b/channel-transport/transport-openfoam/system/setExprFieldsDict new file mode 100644 index 000000000..dc859d900 --- /dev/null +++ b/channel-transport/transport-openfoam/system/setExprFieldsDict @@ -0,0 +1,31 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object setExprFieldsDict; +} + +// Initializes the blob at coordinates (bx,by) with given radius. +// The formula is consistent with the one used in the original nutils case. +expressions +( + T + { + field T; + + variables + ( + "x = pos().x()" + "y = pos().y()" + "r = 0.5" + "bx = 1" + "by = 1" + ); + + expression + #{ + r - r * tanh(((x - bx)*(x - bx) + (y - by)*(y - by) - r) / 0.1) + #}; + } +);