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

codedFIxedValue, writing only to Z-Component of an Inletpatch

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By fanta
  • 1 Post By fanta

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old   May 12, 2018, 10:20
Arrow codedFIxedValue, writing only to Z-Component of an Inletpatch
  #1
Member
 
Join Date: Oct 2011
Posts: 49
Rep Power: 14
fanta is on a distinguished road
Hi,

i am working on a codedFixedValue Boundarycondition and i am stuck.
At the inlet i want to read the calculated rho from the field and correct the mass flow rate with the continuity equation. It starts with a rho read from the file rho.
Here ist my U file:


Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.1.x                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       volVectorField;
    object      U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 1 -1 0 0 0 0];

internalField   uniform (0 0 0);

boundaryField
{
    inlet
    {    
        type            codedFixedValue;
    value        uniform (0 0 0.011449586); //5kg/h in +Z-Direction respectiv to the inlet;
    redirectType    rho_corrected;
    code
    #{
        const fvPatch& boundaryPatch = this->patch(); 
        vectorField& U = *this;
             const vectorField& Cf = boundaryPatch.Cf();
        scalar patchArea = gSum(boundaryPatch.magSf());
         const volScalarField& rhop = this->db().lookupObject<volScalarField>("rho");
        const scalar m_dot = 5.0/3600.0; // 5 kg/h Massflowrate
        volScalarField v = (m_dot/(rhop*patchArea)); //Continuity Equation
//        tmp<vectorField> n = this->patch().nf();
        fixedValueFvPatchVectorField myPatch(*this);
        forAll(this->patch().Cf(),i)
        {
            myPatch[i]=vector(0,0,v);
//            myPatch[i]=vector(0,0,0.011449586);
        }
        operator==(myPatch);
    #};
    }
    outlet
    {
        type            zeroGradient;
    }

    wall
    {
        type            noSlip;
    }
    defaultFaces
    {
    type         fixedValue;
    value        uniform (0 0 0);
    }
}
Can someone help me? It doesn't run because of this line:
myPatch[i]=vector(0,0,v);


in the For loop. Seems i cannot apply v as a component to a vector. How do i do this? v is from the type volScalarField, vector is a vector (of which type of components?).
Kummi likes this.
fanta is offline   Reply With Quote

 


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
[Other] Contribution a new utility: refine wall layer mesh based on yPlus field lakeat OpenFOAM Community Contributions 58 December 23, 2021 02:36
[Other] refineWallLayer Error Yuby OpenFOAM Meshing & Mesh Conversion 2 November 11, 2021 11:04
decomposePar problem: Cell 0contains face labels out of range vaina74 OpenFOAM Pre-Processing 37 July 20, 2020 05:38
[mesh manipulation] Importing Multiple Meshes thomasnwalshiii OpenFOAM Meshing & Mesh Conversion 18 December 19, 2015 18:57
[snappyHexMesh] crash sHM H25E OpenFOAM Meshing & Mesh Conversion 11 November 10, 2014 11:27


All times are GMT -4. The time now is 16:57.