CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Darcy as coded source (https://www.cfd-online.com/Forums/openfoam-programming-development/236257-darcy-coded-source.html)

Pyrokrates May 21, 2021 03:59

Darcy as coded source
 
Hey,


I would like to define my Darcy-parameter D local inside my porous media. Therefor I try to write a vectorCodedSource to change the "fvOptions(U)" sink term in my Ueqn.H from porousSimpleFoam solver.
If if apply my code with constant D and nu hard coded, my velocity increases and I get wrong results. How can I applay change fvOptions(U) instead of U at the whole field (U changes not only in my filter cellZone).


The next problem is that I dont know how to load nu out of transportProperties instead of hard coding it. Different lookup and other code snippets didnīt work.



My fvOptions look like follows:
Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  v2006                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile                                                                       
{                                                                             
    version    2.0;                                                           
    format      ascii;                                                         
    class      dictionary;                                                   
    location    "constant";                                                   
    object      fvOptions;                                                     
}                                                                             
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //


PorousMediaSource
{
    type        vectorCodedSource;
    name        PMSource;
    active      true;
   

    vectorCodedSourceCoeffs
    {
        fields          (U);
        selectionMode  cellZone;
        cellZone        filter;

        codeInclude
        #{

        #};

        codeCorrect
        #{
            Pout<< "**codeCorrect**" << endl;
        #};

        codeAddSup
        #{
       
            double D_ = 0.000001;
            const double nu_ = 1.532e-05;

        const vectorField& U_ = mesh().lookupObject<volVectorField>("U");
            const vectorField& C = mesh_.C();

            vectorField& USource = eqn.source();

            forAll(C, i)
            {
        USource[i] -= U_[i] * D_ * nu_;       
        if (i < 1)
                {
                    Pout << U_[i] << USource[0] << endl;
                }
            }
            Pout << "***codeAddSup***" << endl;
        #};

        codeConstrain
        #{
            Pout<< "**codeSetValue**" << endl;
        #};

        // Dummy entry. Make dependent on above to trigger recompilation
        code
        #{
            $codeInclude
            $codeCorrect
            $codeAddSup
            $codeSetValue
        #};
    }

    sourceTimeCoeffs
    {
        // Dummy entry
    }
}


Thanks in advance


Chris

olesen May 22, 2021 04:16

Darcy-Forchheim should also be there in porous sources.
Can't you just use them, or in a modified form?
Probably better than writing from scratch.

Pyrokrates May 25, 2021 02:54

Hey,
thanks for your answer. I know that Darcy-Forchheimer is already implemented. The problem is, that I am not deep enough inside all the code to understand the whole structure. I mean the place, where fvOptions calls DarcyForchheimer.C and how it is calculated there (I`m also not familiar with all OF defined functions, classes, templates for variables , ...). If I write my own code it`s easier to define my input for local permeability.


To change the equations in DarcyForchheimer.C I need to know the whole part from fvOptions.C to DarcyForhcheimer.C so I can change the LIBS to my local coded data. That is another problem too.





Thanks in advance.


All times are GMT -4. The time now is 04:06.