CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   setting a reference value using conjugateHeatFoam (or coupledFvScalarMatrix) (http://www.cfd-online.com/Forums/openfoam/79420-setting-reference-value-using-conjugateheatfoam-coupledfvscalarmatrix.html)

benk August 23, 2010 11:46

setting a reference value using conjugateHeatFoam (or coupledFvScalarMatrix)
 
Hi, I'm using a modified conjugateHeatFoam solver to solve my multi-region problem. One of my equations has zeroGradient boundary conditions on each end (it's a 1D problem) and so I need to set a reference value for the equation. Usually I'd just use:

equationName.setReference(position, value);

But when it comes to the coupledFvScalarMatrix used in conjugateHeatFoam, what is the eqationName? For example, coupledFvScalarMatrix is set up like this:

Code:

coupledFvScalarMatrix equations(9);

    equations.set
    (
        0,
        new fvScalarMatrix
        (
            eqn0...
        )
    );
   
    equations.set
    (
        1,
        new fvScalarMatrix
        (
          eqn1...
        )
    );
   
    equations.set
    (
        2,
        new fvScalarMatrix
        (
            eqn2...
        )
    );

etc...

I've tried something like:

equations[0].setReference(position, value);

but this doesn't compile and gives the error "class Foam::lduMatrix has no member named setReference"

Can anybody help me out with this?

hjasak August 24, 2010 14:59

Yes, setReference will be in the fvMatrix. First, make the fvMatrix, then set the reference and finally insert it in. If this is inconvenient, you can refCast the equations[0] into fvMatrix and it will then let you set the reference.

The problem (well, advantage) is that coupledMatrix is a PtrList of lduMatrices, and fvMatrix is derived from lduMatrix.

Enjoy,

Hrv

benk August 24, 2010 16:46

Thanks for your help.

I went with your first suggestion and this seemed to work:

Code:

fvScalarMatrix Eqn0( fvm::laplacian(D1,c1) );

Eqn0.setReference(location, value);

coupledFvScalarMatrix Equations(3);

Equations.set( 0, new fvScalarMatrix(Eqn0) );

Equations.set(1,new fvScalarMatrix(fvm::laplacian(D2,c2)));

Equations.set(2,new fvScalarMatrix(fvm::laplacian(D3, c3)));


hjasak August 25, 2010 04:27

Better. If you play with pointers a bit, you can avoid copies.

fvScalarMatrix* Eqn0Ptr = new fvScalarMatrix( fvm::laplacian(D1,c1) );
Eqn0Ptr->setReference(location, value);

coupledFvScalarMatrix Equations(3);
Equations.set(0, Eqn0Ptr);
...

Enjoy,

Hrv

hut September 9, 2010 19:09

I figured out my problem. Thanks


All times are GMT -4. The time now is 00:31.