CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   OpenFOAM 1D solver (https://www.cfd-online.com/Forums/openfoam/100025-openfoam-1d-solver.html)

nandiganavishal April 18, 2012 16:40

OpenFOAM 1D solver
 
Dear Foamers,

I would like to solve a poisson equation in a simple 1D domain (6 units) using OpenFOAM. I have created a blockmesh file and ensured the XY and XZ patches are defined as empty.

See below


convertToMeters 1e3;

vertices
(
(0 0 0) //0
(6 0 0) //1
(6 0.1 0) //2
(0 0.1 0) //3
(0 0 0.1) //4
(6 0 0.1) //5
(6 0.1 0.1) //6
(0 0.1 0.1) //7
);

blocks
(
hex (0 1 2 3 4 5 6 7) (600 1 1) simpleGrading (1 1 1)
);

edges
(
);

patches
(
patch inlet
(
(0 4 7 3)
)
patch outlet
(
(1 5 6 2)
)

empty frontAndBack
(
(0 1 5 4)
(3 2 6 7)
(0 1 2 3)
(4 5 6 7)
)
);

mergePatchPairs
(
);


Now I would like to solve poisson equation with different source terms at different regions in the 1D domain. For instance for the aforementioned example I would like to solve

d^2T/dx^2 = a/R for 0<= x<2000
d^2T/dx^2 = a+b/R for 2000<= x <=4000
d^2T/dx^2 = a/R for 4000< x<=6000

I have looked at know how to implement the laplacian solver and define the source terms. But I would like to know how to define the source term by considering the domain. Kindly let me know.

Thanks for the help.

Regards
Vishal Nandigana

nimasam April 19, 2012 01:22

it seems easy! your general equation is laplacian(T) = Q
and your source temr (Q) is non-uniform! then you just need to define this non-uniform volScalarField Q some like this:
forAll (Q, celli){
if (Q[celli].x() < 2000){ Q[celli] =a/R }
if ( 2000<Q[celli].x() < 4000 ) {...}
if ( 4000<Q[celli].x() < 6000 ) {...}
}

i hope you get the idea ;)

nandiganavishal April 19, 2012 11:29

Thanks for the reply.

It works.

Vishal


All times are GMT -4. The time now is 03:12.