Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add channel-transport transport OpenFOAM #551

Open
wants to merge 18 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog-entries/551.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Added OpenFOAM variant of the transport participant to the channel-transport tutorial.
2 changes: 2 additions & 0 deletions channel-transport/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Transport participant:

* Nutils. 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.

* OpenFOAM. This case uses a modified version of scalarTransportFoam, which recomputes `phi` after the preCICE adapter reads the velocity field. Build it with `wmake`. Read more details in the [OpenFOAM adapter](https://precice.org/adapter-openfoam-overview.html). Note that T accumulates in front of the outlet as this case conserves overall T.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* OpenFOAM. This case uses a modified version of scalarTransportFoam, which recomputes `phi` after the preCICE adapter reads the velocity field. Build it with `wmake`. Read more details in the [OpenFOAM adapter](https://precice.org/adapter-openfoam-overview.html). Note that T accumulates in front of the outlet as this case conserves overall T.
* OpenFOAM. This case uses a modified version of scalarTransportFoam, which recomputes `phi` after the preCICE adapter reads the velocity field. Build it with `wmake`. Read more details in the [OpenFOAM adapter](https://precice.org/adapter-openfoam-overview.html). Note that `T` accumulates in front of the outlet as this case conserves overall `T`.

For consistency.

However: is this really intended, or a modelling issue?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a modelling issue that I couldn't find a solution for. I also ran out of people to ask for help

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should better understand this, and either add details, or fix it. I think right now it just looks wrong.


## Running the simulation

Open two separate terminals and start one fluid and one transport participant by calling the respective run scripts `run.sh` located in each of the participants' directory. For example:
Expand Down
175 changes: 175 additions & 0 deletions channel-transport/transport-openfoam/.clang-format
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I start feeling very uneasy that we duplicate this file everywhere.
Opened an issue: #559

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no uniform style in the tutorials repo. I don't see an easy solution for this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a .clang-format file in the root directory: https://github.com/precice/tutorials/blob/develop/.clang-format

Let's discuss in #559.

Original file line number Diff line number Diff line change
@@ -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 <T>" (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:
...

4 changes: 4 additions & 0 deletions channel-transport/transport-openfoam/.gitignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have these in the central gitignore: https://github.com/precice/tutorials/blob/develop/.gitignore

The 0/ is already covered, the rest could go there as-is (strange we don't have them already).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the other way around.

0/ is tracked and 0.*/ ignored by default. In my case I generate 0/ from 0.orig/, which is the exact opposite of what the gitignore defines.

tutorials/.gitignore

Lines 41 to 43 in 3f253cc

0.*/
[1-9]*/
!0/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly, we don't have a .gitignore in https://github.com/precice/tutorials/tree/develop/partitioned-pipe-two-phase, which should have the same issue.

But again, the Make/-related rules can go into the central .gitignore, or at least moved to the solver directory.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Make/*
!Make/files
!Make/options
0/
44 changes: 44 additions & 0 deletions channel-transport/transport-openfoam/0.orig/T
Original file line number Diff line number Diff line change
@@ -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 zeroGradient;
}

obstacle
{
type zeroGradient;
}

upperWall
{
type zeroGradient;
}

lowerWall
{
type zeroGradient;
}

frontAndBack
{
type empty;
}
}
39 changes: 39 additions & 0 deletions channel-transport/transport-openfoam/0.orig/U
Original file line number Diff line number Diff line change
@@ -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;
}
}
3 changes: 3 additions & 0 deletions channel-transport/transport-openfoam/Make/files
fsimonis marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dynamicScalarTransportFoam.C

EXE = $(FOAM_USER_APPBIN)/dynamicScalarTransportFoam
10 changes: 10 additions & 0 deletions channel-transport/transport-openfoam/Make/options
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions channel-transport/transport-openfoam/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env sh
set -e -u

. ../../tools/cleaning-tools.sh

clean_openfoam .
rm -rf ./0/
rm -rf ./Make/linux*
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object transportProperties;
}

DT 0.1;
43 changes: 43 additions & 0 deletions channel-transport/transport-openfoam/createFields.H
Original file line number Diff line number Diff line change
@@ -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"
Loading
Loading