From eea8bca455f06c92432b89e3a6b2605e63541f75 Mon Sep 17 00:00:00 2001 From: Ferran de Miguel <95434477+Ferraan@users.noreply.github.com> Date: Wed, 20 Dec 2023 14:01:13 +0100 Subject: [PATCH 1/3] Change U to use custom code for parabolic profile Change the inlet velocity profile so as not to use the swak4foam external library with the groovyBC inlet conditions. --- turek-hron-fsi3/fluid-openfoam/0/U | 33 +++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/turek-hron-fsi3/fluid-openfoam/0/U b/turek-hron-fsi3/fluid-openfoam/0/U index 298a0809e..dff152853 100644 --- a/turek-hron-fsi3/fluid-openfoam/0/U +++ b/turek-hron-fsi3/fluid-openfoam/0/U @@ -36,11 +36,34 @@ boundaryField inlet { - // Time-varying parabolic inlet profile - type groovyBC; - variables "yp=pts().y;minY=min(yp);maxY=max(yp);para=-1.5*(maxY-pos().y)*(pos().y-minY)/(0.25*pow(maxY-minY,2))*normal();"; - valueExpression "time()<2 ? 0.5*(1-cos(0.5*pi*time()))*2*para : 2*para"; - value uniform (2 0 0); + // Time-varying parabolic inlet profile + type codedFixedValue; + value uniform (1 0 0); + name parabolicVelocity; + + code + #{ + const vectorField& Cf = patch().Cf(); + vectorField& field = *this; + + const scalar pi=3.14159265358979; + const scalar Umean=2.0; + const scalar t = this->db().time().value(); + if(t<2){ + forAll(Cf,faceI) + { + const scalar y=Cf[faceI][1]; + field[faceI]=vector((1.5*Umean*4.0/0.1681)*y*(0.41-y)*((1-cos(pi/2 *t))/2),0,0);//((1-cos(pi/2 *t)/2)) + } + }else + { + forAll(Cf,faceI) + { + const scalar y=Cf[faceI][1]; + field[faceI]=vector((1.5*Umean*4.0/0.1681)*y*(0.41-y),0,0); + } + } + #}; } outlet From 6681c96553427a7008aca04d5bce49b310254ee7 Mon Sep 17 00:00:00 2001 From: Ferran de Miguel Date: Mon, 22 Jan 2024 16:57:56 +0100 Subject: [PATCH 2/3] Removed GroovyBC in Partitioned Heat Conduction --- .../openfoam-dirichlet/0.orig/T | 22 ++++++++++++++----- .../openfoam-dirichlet/setInitialField.sh | 3 +-- .../openfoam-neumann/0.orig/T | 22 ++++++++++++++----- .../openfoam-neumann/setInitialField.sh | 3 +-- turek-hron-fsi3/fluid-openfoam/0/U | 2 +- .../fluid-openfoam/system/controlDict | 2 -- 6 files changed, 37 insertions(+), 17 deletions(-) diff --git a/partitioned-heat-conduction/openfoam-dirichlet/0.orig/T b/partitioned-heat-conduction/openfoam-dirichlet/0.orig/T index fed3ddbc4..e9caf99f7 100644 --- a/partitioned-heat-conduction/openfoam-dirichlet/0.orig/T +++ b/partitioned-heat-conduction/openfoam-dirichlet/0.orig/T @@ -21,11 +21,23 @@ boundaryField DirichletBoundary { - type groovyBC; - variables "val=1+pow(pos().x,2)+(3*pow(pos().y,2))+1.3*time();"; - valueExpression "val"; - value uniform 0; - evaluateDuringConstruction 1; + type codedFixedValue; + value uniform 1; + name DirichletBoundary; + code + #{ + const vectorField& Cf = patch().Cf(); + scalarField& field = *this; + const scalar t = this->db().time().value(); + forAll(Cf,faceI) + { + const scalar x=Cf[faceI][0]; + const scalar y=Cf[faceI][1]; + field[faceI]=1+pow(x,2)+(3*pow(y,2))+1.3*t; + } + + #}; + } defaultFaces diff --git a/partitioned-heat-conduction/openfoam-dirichlet/setInitialField.sh b/partitioned-heat-conduction/openfoam-dirichlet/setInitialField.sh index bf3dfd29c..b8a9a578e 100755 --- a/partitioned-heat-conduction/openfoam-dirichlet/setInitialField.sh +++ b/partitioned-heat-conduction/openfoam-dirichlet/setInitialField.sh @@ -4,5 +4,4 @@ set -e -u # Remove the old directory and copy the uninitialized field rm -rf ./0 cp -r ./0.orig 0 -# Initialize the new field -funkySetFields -keepPatches -field T -expression '1+pow(pos().x,2)+(3*pow(pos().y,2))+1.3*time()' -time '0' + diff --git a/partitioned-heat-conduction/openfoam-neumann/0.orig/T b/partitioned-heat-conduction/openfoam-neumann/0.orig/T index 01f8fc1af..57b3912fe 100644 --- a/partitioned-heat-conduction/openfoam-neumann/0.orig/T +++ b/partitioned-heat-conduction/openfoam-neumann/0.orig/T @@ -21,11 +21,23 @@ boundaryField DirichletBoundary { - type groovyBC; - variables "val=1+pow(pos().x,2)+(3*pow(pos().y,2))+1.3*time();"; - valueExpression "val"; - value uniform 0; - evaluateDuringConstruction 1; + type codedFixedValue; + value uniform 1; + name DirichletBoundary; + code + #{ + const vectorField& Cf = patch().Cf(); + scalarField& field = *this; + const scalar t = this->db().time().value(); + forAll(Cf,faceI) + { + const scalar x=Cf[faceI][0]; + const scalar y=Cf[faceI][1]; + field[faceI]=1+pow(x,2)+(3*pow(y,2))+1.3*t; + } + + #}; + } defaultFaces diff --git a/partitioned-heat-conduction/openfoam-neumann/setInitialField.sh b/partitioned-heat-conduction/openfoam-neumann/setInitialField.sh index bf3dfd29c..b8a9a578e 100755 --- a/partitioned-heat-conduction/openfoam-neumann/setInitialField.sh +++ b/partitioned-heat-conduction/openfoam-neumann/setInitialField.sh @@ -4,5 +4,4 @@ set -e -u # Remove the old directory and copy the uninitialized field rm -rf ./0 cp -r ./0.orig 0 -# Initialize the new field -funkySetFields -keepPatches -field T -expression '1+pow(pos().x,2)+(3*pow(pos().y,2))+1.3*time()' -time '0' + diff --git a/turek-hron-fsi3/fluid-openfoam/0/U b/turek-hron-fsi3/fluid-openfoam/0/U index dff152853..9842e9db9 100644 --- a/turek-hron-fsi3/fluid-openfoam/0/U +++ b/turek-hron-fsi3/fluid-openfoam/0/U @@ -53,7 +53,7 @@ boundaryField forAll(Cf,faceI) { const scalar y=Cf[faceI][1]; - field[faceI]=vector((1.5*Umean*4.0/0.1681)*y*(0.41-y)*((1-cos(pi/2 *t))/2),0,0);//((1-cos(pi/2 *t)/2)) + field[faceI]=vector((1.5*Umean*4.0/0.1681)*y*(0.41-y)*((1-cos(pi/2 *t))/2),0,0); } }else { diff --git a/turek-hron-fsi3/fluid-openfoam/system/controlDict b/turek-hron-fsi3/fluid-openfoam/system/controlDict index 8be725212..3091c4343 100644 --- a/turek-hron-fsi3/fluid-openfoam/system/controlDict +++ b/turek-hron-fsi3/fluid-openfoam/system/controlDict @@ -9,8 +9,6 @@ FoamFile application pimpleFoam; // latest OpenFOAM // application pimpleDyMFoam; // OpenFOAM v1712, OpenFOAM 5.x, or older -libs ( "libgroovyBC.so" ) ; - startFrom startTime; startTime 0; From fc17842d0e4e0e23f70a779581d467aa49aa91bf Mon Sep 17 00:00:00 2001 From: Ferran de Miguel Date: Wed, 24 Jan 2024 03:07:33 +0100 Subject: [PATCH 3/3] Added internalField initialization (not tested) --- .../openfoam-dirichlet/0.orig/T | 41 ++++++++++++++++++- .../openfoam-neumann/0.orig/T | 41 ++++++++++++++++++- 2 files changed, 80 insertions(+), 2 deletions(-) diff --git a/partitioned-heat-conduction/openfoam-dirichlet/0.orig/T b/partitioned-heat-conduction/openfoam-dirichlet/0.orig/T index b7b6ab9bc..9416fa60a 100644 --- a/partitioned-heat-conduction/openfoam-dirichlet/0.orig/T +++ b/partitioned-heat-conduction/openfoam-dirichlet/0.orig/T @@ -9,7 +9,46 @@ FoamFile dimensions [0 0 0 1 0 0 0]; -internalField uniform 0; +internalField #codeStream +{ + codeInclude + #{ + #include "fvCFD.H" + #}; + + codeOptions + #{ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude + #}; + + codeLibs + #{ + -lmeshTools \ + -lfiniteVolume + #}; + + code + + #{ + const IOdictionary& d = static_cast(dict); + const fvMesh& mesh = refCast(d.db()); + + scalarField T(mesh.nCells()); + + const vectorField& CC = mesh.C(); //cell center + + + forAll(CC,cellI) + { + scalar x = CC[cellI].x(); + scalar y = CC[cellI].y(); + + T[cellI] = 1+pow(x,2)+(3*pow(y,2));//t is zero for initial conditions + } + T.writeEntry("", os); + #}; +}; boundaryField { diff --git a/partitioned-heat-conduction/openfoam-neumann/0.orig/T b/partitioned-heat-conduction/openfoam-neumann/0.orig/T index 5363e2c62..f258d6e84 100644 --- a/partitioned-heat-conduction/openfoam-neumann/0.orig/T +++ b/partitioned-heat-conduction/openfoam-neumann/0.orig/T @@ -9,7 +9,46 @@ FoamFile dimensions [0 0 0 1 0 0 0]; -internalField uniform 0; +internalField #codeStream +{ + codeInclude + #{ + #include "fvCFD.H" + #}; + + codeOptions + #{ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude + #}; + + codeLibs + #{ + -lmeshTools \ + -lfiniteVolume + #}; + + code + + #{ + const IOdictionary& d = static_cast(dict); + const fvMesh& mesh = refCast(d.db()); + + scalarField T(mesh.nCells()); + + const vectorField& CC = mesh.C(); //cell center + + + forAll(CC,cellI) + { + scalar x = CC[cellI].x(); + scalar y = CC[cellI].y(); + + T[cellI] = 1+pow(x,2)+(3*pow(y,2));//t is zero for initial conditions + } + T.writeEntry("", os); + #}; +}; boundaryField {