|
[Sponsors] |
codedFIxedValue, writing only to Z-Component of an Inletpatch |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 12, 2018, 11:20 |
codedFIxedValue, writing only to Z-Component of an Inletpatch
|
#1 |
Member
Join Date: Oct 2011
Posts: 53
Rep Power: 15 |
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); } } 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?). |
|
May 12, 2018, 12:28 |
|
#2 |
Senior Member
Taher Chegini
Join Date: Nov 2014
Location: Houston, Texas
Posts: 125
Rep Power: 13 |
Because you've defined v as a field then you've used it as a scalar!
Either directly calculate v in the loop using rhop[i] or use v[i]. |
|
May 12, 2018, 13:55 |
|
#3 |
Member
Join Date: Oct 2011
Posts: 53
Rep Power: 15 |
Thanks for the hint, this is the code:
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 // scalar v = (m_dot/(rhop[2]*patchArea)); fixedValueFvPatchVectorField myPatch(*this); forAll(this->patch().Cf(),i) { myPatch[i]=vector(0,0, (m_dot/(rhop[2]*patchArea))); } operator==(myPatch); #}; } outlet { type zeroGradient; } wall { type noSlip; } defaultFaces { type fixedValue; value uniform (0 0 0); } } // ************************************************************************* // |
|
May 24, 2018, 11:28 |
|
#4 | |
Member
Zhiheng Wang
Join Date: Mar 2016
Posts: 72
Rep Power: 10 |
Quote:
|
||
|
|
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 03:36 |
[Other] refineWallLayer Error | Yuby | OpenFOAM Meshing & Mesh Conversion | 2 | November 11, 2021 12:04 |
decomposePar problem: Cell 0contains face labels out of range | vaina74 | OpenFOAM Pre-Processing | 37 | July 20, 2020 06:38 |
[mesh manipulation] Importing Multiple Meshes | thomasnwalshiii | OpenFOAM Meshing & Mesh Conversion | 18 | December 19, 2015 19:57 |
[snappyHexMesh] crash sHM | H25E | OpenFOAM Meshing & Mesh Conversion | 11 | November 10, 2014 12:27 |