Skip to content

Change U to use custom code for parabolic profile #428

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

Closed
wants to merge 4 commits into from
Closed
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
62 changes: 56 additions & 6 deletions partitioned-heat-conduction/openfoam-dirichlet/0.orig/T
Original file line number Diff line number Diff line change
Expand Up @@ -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<const IOdictionary&>(dict);
const fvMesh& mesh = refCast<const fvMesh>(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
{
Expand All @@ -21,11 +60,22 @@ boundaryField

DirichletBoundary
{
type groovyBC;
variables "val=1+pow(pos().x,2)+(3*pow(pos().y,2))+1.2*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.2*t;
}

#};
}

defaultFaces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ 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.2*time()' -time '0'
62 changes: 56 additions & 6 deletions partitioned-heat-conduction/openfoam-neumann/0.orig/T
Original file line number Diff line number Diff line change
Expand Up @@ -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<const IOdictionary&>(dict);
const fvMesh& mesh = refCast<const fvMesh>(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
{
Expand All @@ -21,11 +60,22 @@ boundaryField

DirichletBoundary
{
type groovyBC;
variables "val=1+pow(pos().x,2)+(3*pow(pos().y,2))+1.2*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.2*t;
}

#};
}

defaultFaces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ 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.2*time()' -time '0'
33 changes: 28 additions & 5 deletions turek-hron-fsi3/fluid-openfoam/0/U
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}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
Expand Down
2 changes: 0 additions & 2 deletions turek-hron-fsi3/fluid-openfoam/system/controlDict
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down