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/)
-   -   problem specifying alpha at inlet during a parallel run (https://www.cfd-online.com/Forums/openfoam-solving/67365-problem-specifying-alpha-inlet-during-parallel-run.html)

phsieh2005 August 12, 2009 19:35

problem specifying alpha at inlet during a parallel run
 
Dear OpenFOAM experts:

I want to specify alpha field at the inlet as a function of time. The following piece of code worked fine when running in a serial case. It also run fine when the inlet is NOT partitioned into different processors. However, got alpha 0() if the inlet is partitioned to different processors.

It will be appreciated if someone can shed some light on how to fix this problem:

Thanks!

Pei
----
code:

label tIndex = label(runTime.value()/tPeriod);
scalar localTime = runTime.value() - tIndex*tPeriod;

// Get index of patch
label inletPatchID = mesh.boundaryMesh().findPatchID("inlet");

// Get reference to boundary value
vectorField& inletU = U.boundaryField()[inletPatchID];

// Manipulate value
if(localTime >= 0 && localTime < time1)
{
velInlet = Wmx*localTime/time1;
}
else if(localTime < time6)
{
velInlet = Wmx;
}
else if(localTime < time7)
{
scalar tempTime = localTime - time6;

velInlet = Wmx*(1.0 - (tempTime/(time7 - time6)));
}
else if(localTime < tPeriod)
{
velInlet = 0.0;
}

inletU = vector(velInlet, 0, 0);
Info<< "inletU:" << velInlet << endl;

scalarField& inletAlpha = alpha1.boundaryField()[inletPatchID];
if(localTime >= 0 && localTime < time3)
{
inletAlpha = 1;
}
else if(localTime < tPeriod)
{
inletAlpha = 0.0;
}
Info<< "inlet alpha = " << inletAlpha << endl;

gschaider August 13, 2009 04:15

Quote:

Originally Posted by phsieh2005 (Post 226158)
Dear OpenFOAM experts:

I want to specify alpha field at the inlet as a function of time. The following piece of code worked fine when running in a serial case. It also run fine when the inlet is NOT partitioned into different processors. However, got alpha 0() if the inlet is partitioned to different processors.

It will be appreciated if someone can shed some light on how to fix this problem:

Am I right in assuming that you're doing this in the actual solver? Such things should be done in a boundary condition. Anyway: an alpha1.correctBoundaryConditions() might help to bring the processor patches to a consistent state.

On the other hand: why don't you use the timeVaryingUniform-boundaryCondition for that? Or groovyBC? Hardcoding boundary conditions into solver code is soooo Fortran

Bernhard

phsieh2005 August 13, 2009 08:23

Thanks Bernhard!

Yes, this should have been done using timeVaryingUniformFvPatch BC - still learning how to do what I want using this derived BC.

According to Mattijs, Info prints out the info on the priminary processor. In my case, the inlet faces happen to be not on the priminary processor, hence, 0(). I have changed from Info to Pout, and now, it writes out the correct information and the code was correct.

Pei


All times are GMT -4. The time now is 19:20.