CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

codeStream to update b.c.

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 21, 2022, 12:56
Post codeStream to update b.c.
  #1
Member
 
Eric Segalerba
Join Date: Dec 2021
Location: Italy
Posts: 31
Rep Power: 4
EricS is on a distinguished road
Hi Foamers!



I'm struggling with a problem which consists in implementing a boundary condtion that changes in time.
I tried to solve this problem using codeStream but, so far, I only ended up with errors and, not being a skillful programmer, I'm stuck here ..


The boundary condition that I'm trying to implement should do what it follows:
1. I impose a value of power (called CPI) which is: CPI = mass_flow_rate * delta_P;
2. I estimate a value of delta_P which becomes delta_P^(1);
3. I compute the resulting mass_flow_rate as: mass_flow_rate^(2) = CPI/delta_P^(1);
4. I use mass_flow_rate^(2) as a boundary condition and I compute delta_P^(2) for that timestep;
5. then I use delta_P^(2) to compute mass_flow_rate^(3) and so on...


I can summarize as mass_flow_rate^(i+1) = CPI/delta_P^(i)


So far I wrote:

Code:
throat
    {
    type            flowRateOutletVelocity;
    volumetricFlowRate     #codeStream
        {
            codeInclude
            #{
                #include "fvCFD.H"
            #};

            codeOptions
            #{
                -I$(LIB_SRC)/finiteVolume/lnInclude \
                -I$(LIB_SRC)/meshTools/lnInclude
            #};

            //libs needed to visualize BC in paraview
            codeLibs
            #{
            -lmeshTools \
            -lfiniteVolume
            #};

            code
            #{    
        /* CYCLE EXPLAINED
        input = CPI = massFlowRate * deltaP
        1. massFlowRate = CPI / deltaP;
        2. compute first timestep with the massFlowRate just calculated;
        3. compute deltaP (which is deltaP = p_amb - p_throat = 0 - p_throat = -p_throat);
        4. correct massFlowRate with the new value of p_throat;
        5. keep iterating...
            massFlowRate^(i+1) = - CPI / p_throat^(i)
        */
                const IOdictionary& d = static_cast<const IOdictionary&>
        (
                    dict.parent().parent()
                );
                const fvMesh& mesh = refCast<const fvMesh>(d.db());
                const label id = mesh.boundary().findPatchID("throat");
                const fvPatch& patch = mesh.boundary()[id];
                vectorField U(patch.size(), vector(0, 0, 0));            
        const CPI = 500;                        
                const surfaceVectorField& p = patch().lookupObject("p");    
        const massFlowRate = -CPI/average(p)                
                writeEntry(os,"", massFlowRate);
            #};
        };
    value            uniform (0 0 0);        
    }
but it's only giving me errors...
any tips to make it work?

Thank you in advance!!!
EricS is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get current time using codeStream in b.c. CarlesCQL OpenFOAM Pre-Processing 1 July 14, 2022 07:09
B.C. CodeStream does not repeat during runtime sjafarik OpenFOAM Programming & Development 3 March 4, 2022 02:48
CodeStream Error EzgiCFD OpenFOAM Running, Solving & CFD 0 January 31, 2022 14:38
PROBLEMS DEFINING A LIST USING #CODESTREAM !! Help please !! angatri_14 OpenFOAM Programming & Development 1 August 21, 2020 18:16
How to get current time using codeStream in b.c. CarlesCQL OpenFOAM Programming & Development 0 February 17, 2016 12:02


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