CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   pisoFoam with two passive scalars (https://www.cfd-online.com/Forums/openfoam-solving/218135-pisofoam-two-passive-scalars.html)

stootoon June 10, 2019 07:19

pisoFoam with two passive scalars
 
Hi folks,

A while ago I modified pisoFoam to include a single passive scalar (S1) with a codedFixedValue boundary condition, and this works fine. I recently decided to add a second scalar (S2) with its own, slightly different, codedFixedValue boundary condition. The dynamicCode seems to be created correctly and the simulation runs, but it seems to use the S1 boundary condition for both fields, so that the actual values of S1 and S2 that it then computes over time are identical. Is there some additional step I need to take to allow the two scalar fields to use their own boundary conditions?

Thanks in advance for your help. I've included some code snippets below to assist.

Cheers,

Sina

----

Here's a snippet from 0/S1 showing the boundary condition.

code
#{
const fvPatch& boundaryPatch = patch();
const vectorField& Cf = boundaryPatch.Cf();
scalarField& field = *this;

//scalar tmp=1;
forAll(Cf, faceI)
{
field[faceI] = Cf[faceI].y() >= 0.245 && Cf[faceI].y() < 0.255 ? 1. : 0.;
}
#};

Here's a snippet from 0/S2 showing the shifted and attenuated value of this field:

forAll(Cf, faceI)
{
field[faceI] = Cf[faceI].y() >= 0.445 && Cf[faceI].y() < 0.455 ? 0.1 : 0.;
}

Here's the output generated when I first run the solver, showing that the files above are actually being read to create the inlet profile shared libraries (Note: I've manually replaced the actual case path with CASEPATH for clarity)

Reading field S1 (passive scalar 1)

Using dynamicCode for patch inlet on field S1 at line 28 in "CASEPATH/0/S1.boundaryField.inlet"
Creating new library in "dynamicCode/inletProfile/platforms/linux64GccDPInt32Opt/lib/libinletProfile_6e3be35a37396bc5dbbf9ba93849e6d43f b03527.so"
Invoking "wmake -s libso CASEPATH/dynamicCode/inletProfile"
wmake libso CASEPATH/dynamicCode/inletProfile
ln: ./lnInclude
wmkdep: fixedValueFvPatchFieldTemplate.C
Ctoo: fixedValueFvPatchFieldTemplate.C
ld: CASEPATH/dynamicCode/inletProfile/../platforms/linux64GccDPInt32Opt/lib/libinletProfile_6e3be35a37396bc5dbbf9ba93849e6d43f b03527.so
Reading field S2 (passive scalar 2)

Using dynamicCode for patch inlet on field S2 at line 28 in "CASEPATH/0/S2.boundaryField.inlet"
Creating new library in "dynamicCode/inletProfile/platforms/linux64GccDPInt32Opt/lib/libinletProfile_d2e006f319249d14a660d352136052442b ddbf96.so"
Invoking "wmake -s libso CASEPATH/dynamicCode/inletProfile"
wmake libso CASEPATH/dynamicCode/inletProfile
ln: ./lnInclude
wmkdep: fixedValueFvPatchFieldTemplate.C
Ctoo: fixedValueFvPatchFieldTemplate.C
ld: CASEPATH/dynamicCode/inletProfile/../platforms/linux64GccDPInt32Opt/lib/libinletProfile_d2e006f319249d14a660d352136052442b ddbf96.so


Here is a step of the solver output showing that the initial and final residuals are identical for S1 and S2

Time = 2e-05

Courant Number mean: 0.111471 max: 0.863113
smoothSolver: Solving for Ux, Initial residual = 0.954158, Final residual = 3.41239e-07, No Iterations 4
smoothSolver: Solving for Uy, Initial residual = 0.392274, Final residual = 9.67449e-06, No Iterations 3
GAMG: Solving for p, Initial residual = 0.00526645, Final residual = 0.000316501, No Iterations 9
time step continuity errors : sum local = 5.89439e-05, global = 4.92787e-06, cumulative = 4.38353e-06
GAMG: Solving for p, Initial residual = 0.0595064, Final residual = 5.43383e-07, No Iterations 10
time step continuity errors : sum local = 4.41967e-08, global = -3.65106e-11, cumulative = 4.38349e-06
smoothSolver: Solving for S1, Initial residual = 0.312745, Final residual = 4.35842e-06, No Iterations 3
smoothSolver: Solving for S2, Initial residual = 0.312745, Final residual = 4.35842e-06, No Iterations 3
ExecutionTime = 5.85 s ClockTime = 71 s

I've also manually checked the actual values of S1 and S2 and they are the same.


All times are GMT -4. The time now is 23:32.