CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Cyclic Boundary conditions (http://www.cfd-online.com/Forums/openfoam-solving/59253-cyclic-boundary-conditions.html)

johndeas January 4, 2008 10:41

Hi, I am a beginner in Open
 
Hi,

I am a beginner in OpenFOAM, and I would like to use it to perform DNS calculation of turbulent channel flow. I need a periodic condition on inlet/outlet and sides, and a wall condition on lower/upper wall. Since I need a driving force for the flow, I tried to include the gradp from channeloodles into icoFoam. My calculation runs, but it seems that my wall condition is not taken into account, as the flow is constant in the channel and correspond to the value I wrote as "ubar" in the transportProperties dictionnary.

My modified code is

#include "fvCFD.H"
#include "IFstream.H"
#include "OFstream.H"
#include "Random.H" // peut-Ítre inutile

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

int main(int argc, char *argv[])
{

# include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"
# include "createFields.H"
# include "initContinuityErrs.H"
# include "createGradP.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

Info<< "\nStarting time loop\n" << endl;

for (runTime++; !runTime.end(); runTime++)
{
Info<< "Time = " << runTime.timeName() << nl << endl;

# include "readPISOControls.H"
# include "CourantNo.H"

fvVectorMatrix UEqn
(
fvm::ddt(U)
+ fvm::div(phi, U)
- fvm::laplacian(nu, U)
==
flowDirection*gradP
);

solve(UEqn == -fvc::grad(p));

// --- PISO loop

volScalarField rUA = 1.0/UEqn.A();

for (int corr=0; corr<nCorr; corr++)
{


U = rUA*UEqn.H();
phi = (fvc::interpolate(U) & mesh.Sf())
+ fvc::ddtPhiCorr(rUA, U, phi);

adjustPhi(phi, U, p);

for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
fvScalarMatrix pEqn
(
fvm::laplacian(rUA, p) == fvc::div(phi)
);

pEqn.setReference(pRefCell, pRefValue);
pEqn.solve();

if (nonOrth == nNonOrthCorr)
{
phi -= pEqn.flux();
}
}

# include "continuityErrs.H"

U -= rUA*fvc::grad(p);
U.correctBoundaryConditions();
}

// Correct driving force for a constant mass flow rate

// Extract the velocity in the flow direction
dimensionedScalar magUbarStar =
(flowDirection & U)().weightedAverage(mesh.V());

// Calculate the pressure gradient increment needed to
// adjust the average flow-rate to the correct value
dimensionedScalar gragPplus =
(magUbar - magUbarStar)/rUA.weightedAverage(mesh.V());

U += flowDirection*rUA*gragPplus;

gradP += gragPplus;

Info<< "Uncorrected Ubar = " << magUbarStar.value() << tab
<< "pressure gradient = " << gradP.value() << endl;

runTime.write();

Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}

Info<< "End\n" << endl;

return(0);
}


// ************************************************** *********************** //

Can you help me or give some direction to debug ?

Thanks

JD

santos January 4, 2008 21:34

Hello I think you can just
 
Hello

I think you can just use channelOodles for your situation. Why do you need to write another solver?

Regards
Josť Santos


All times are GMT -4. The time now is 09:47.