Skip to content

Commit a688fa7

Browse files
committed
Squashed commit of the following:
commit 8abb1654d434f0ba3f537f55cd6e2317ff769b48 Author: Ferran de Miguel <[email protected]> Date: Wed Dec 20 14:01:13 2023 +0100 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. Removed GroovyBC in Partitioned Heat Conduction Added internalField initialization (not tested)
1 parent de9e5b9 commit a688fa7

File tree

6 files changed

+140
-23
lines changed

6 files changed

+140
-23
lines changed

partitioned-heat-conduction/dirichlet-openfoam/0.orig/T

+56-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,46 @@ FoamFile
99
dimensions [0 0 0 1 0 0 0];
1010

1111

12-
internalField uniform 0;
12+
internalField #codeStream
13+
{
14+
codeInclude
15+
#{
16+
#include "fvCFD.H"
17+
#};
18+
19+
codeOptions
20+
#{
21+
-I$(LIB_SRC)/finiteVolume/lnInclude \
22+
-I$(LIB_SRC)/meshTools/lnInclude
23+
#};
24+
25+
codeLibs
26+
#{
27+
-lmeshTools \
28+
-lfiniteVolume
29+
#};
30+
31+
code
32+
33+
#{
34+
const IOdictionary& d = static_cast<const IOdictionary&>(dict);
35+
const fvMesh& mesh = refCast<const fvMesh>(d.db());
36+
37+
scalarField T(mesh.nCells());
38+
39+
const vectorField& CC = mesh.C(); //cell center
40+
41+
42+
forAll(CC,cellI)
43+
{
44+
scalar x = CC[cellI].x();
45+
scalar y = CC[cellI].y();
46+
47+
T[cellI] = 1+pow(x,2)+(3*pow(y,2));//t is zero for initial conditions
48+
}
49+
T.writeEntry("", os);
50+
#};
51+
};
1352

1453
boundaryField
1554
{
@@ -21,11 +60,22 @@ boundaryField
2160

2261
DirichletBoundary
2362
{
24-
type groovyBC;
25-
variables "val=1+pow(pos().x,2)+(3*pow(pos().y,2))+1.2*time();";
26-
valueExpression "val";
27-
value uniform 0;
28-
evaluateDuringConstruction 1;
63+
type codedFixedValue;
64+
value uniform 1;
65+
name DirichletBoundary;
66+
code
67+
#{
68+
const vectorField& Cf = patch().Cf();
69+
scalarField& field = *this;
70+
const scalar t = this->db().time().value();
71+
forAll(Cf,faceI)
72+
{
73+
const scalar x=Cf[faceI][0];
74+
const scalar y=Cf[faceI][1];
75+
field[faceI]=1+pow(x,2)+(3*pow(y,2))+1.2*t;
76+
}
77+
78+
#};
2979
}
3080

3181
defaultFaces

partitioned-heat-conduction/dirichlet-openfoam/setInitialField.sh

-2
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,3 @@ set -e -u
44
# Remove the old directory and copy the uninitialized field
55
rm -rf ./0
66
cp -r ./0.orig 0
7-
# Initialize the new field
8-
funkySetFields -keepPatches -field T -expression '1+pow(pos().x,2)+(3*pow(pos().y,2))+1.2*time()' -time '0'

partitioned-heat-conduction/neumann-openfoam/0.orig/T

+56-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,46 @@ FoamFile
99
dimensions [0 0 0 1 0 0 0];
1010

1111

12-
internalField uniform 0;
12+
internalField #codeStream
13+
{
14+
codeInclude
15+
#{
16+
#include "fvCFD.H"
17+
#};
18+
19+
codeOptions
20+
#{
21+
-I$(LIB_SRC)/finiteVolume/lnInclude \
22+
-I$(LIB_SRC)/meshTools/lnInclude
23+
#};
24+
25+
codeLibs
26+
#{
27+
-lmeshTools \
28+
-lfiniteVolume
29+
#};
30+
31+
code
32+
33+
#{
34+
const IOdictionary& d = static_cast<const IOdictionary&>(dict);
35+
const fvMesh& mesh = refCast<const fvMesh>(d.db());
36+
37+
scalarField T(mesh.nCells());
38+
39+
const vectorField& CC = mesh.C(); //cell center
40+
41+
42+
forAll(CC,cellI)
43+
{
44+
scalar x = CC[cellI].x();
45+
scalar y = CC[cellI].y();
46+
47+
T[cellI] = 1+pow(x,2)+(3*pow(y,2));//t is zero for initial conditions
48+
}
49+
T.writeEntry("", os);
50+
#};
51+
};
1352

1453
boundaryField
1554
{
@@ -21,11 +60,22 @@ boundaryField
2160

2261
DirichletBoundary
2362
{
24-
type groovyBC;
25-
variables "val=1+pow(pos().x,2)+(3*pow(pos().y,2))+1.2*time();";
26-
valueExpression "val";
27-
value uniform 0;
28-
evaluateDuringConstruction 1;
63+
type codedFixedValue;
64+
value uniform 1;
65+
name DirichletBoundary;
66+
code
67+
#{
68+
const vectorField& Cf = patch().Cf();
69+
scalarField& field = *this;
70+
const scalar t = this->db().time().value();
71+
forAll(Cf,faceI)
72+
{
73+
const scalar x=Cf[faceI][0];
74+
const scalar y=Cf[faceI][1];
75+
field[faceI]=1+pow(x,2)+(3*pow(y,2))+1.2*t;
76+
}
77+
78+
#};
2979
}
3080

3181
defaultFaces

partitioned-heat-conduction/neumann-openfoam/setInitialField.sh

-2
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,3 @@ set -e -u
44
# Remove the old directory and copy the uninitialized field
55
rm -rf ./0
66
cp -r ./0.orig 0
7-
# Initialize the new field
8-
funkySetFields -keepPatches -field T -expression '1+pow(pos().x,2)+(3*pow(pos().y,2))+1.2*time()' -time '0'

turek-hron-fsi3/fluid-openfoam/0/U

+28-5
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,34 @@ boundaryField
3636

3737
inlet
3838
{
39-
// Time-varying parabolic inlet profile
40-
type groovyBC;
41-
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();";
42-
valueExpression "time()<2 ? 0.5*(1-cos(0.5*pi*time()))*2*para : 2*para";
43-
value uniform (2 0 0);
39+
// Time-varying parabolic inlet profile
40+
type codedFixedValue;
41+
value uniform (1 0 0);
42+
name parabolicVelocity;
43+
44+
code
45+
#{
46+
const vectorField& Cf = patch().Cf();
47+
vectorField& field = *this;
48+
49+
const scalar pi=3.14159265358979;
50+
const scalar Umean=2.0;
51+
const scalar t = this->db().time().value();
52+
if(t<2){
53+
forAll(Cf,faceI)
54+
{
55+
const scalar y=Cf[faceI][1];
56+
field[faceI]=vector((1.5*Umean*4.0/0.1681)*y*(0.41-y)*((1-cos(pi/2 *t))/2),0,0);
57+
}
58+
}else
59+
{
60+
forAll(Cf,faceI)
61+
{
62+
const scalar y=Cf[faceI][1];
63+
field[faceI]=vector((1.5*Umean*4.0/0.1681)*y*(0.41-y),0,0);
64+
}
65+
}
66+
#};
4467
}
4568

4669
outlet

turek-hron-fsi3/fluid-openfoam/system/controlDict

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ FoamFile
99
application pimpleFoam; // latest OpenFOAM
1010
// application pimpleDyMFoam; // OpenFOAM v1712, OpenFOAM 5.x, or older
1111

12-
libs ( "libgroovyBC.so" ) ;
13-
1412
startFrom startTime;
1513

1614
startTime 0;

0 commit comments

Comments
 (0)