|
[Sponsors] |
August 4, 2023, 05:51 |
CodedMixed Boundary condition
|
#1 |
New Member
Join Date: Jan 2022
Posts: 5
Rep Power: 4 |
Hi all,
I am a beginner in OpenFOAMv10 and currently solving a case using interFoam of a water droplet in a column. I have manually compiled a boundary condition for the velocity profile patch droplet that injects the velocity using parameters like flowrate & frequency. I have another field called alpha1 which can have value 0 or 1, where 0 signifies air and 1 is water. What I desire is that for the alpha1 field patch droplet to return a value of either 1 if velocity is greater than 0 or else return 0 for alpha1 field. For this I use the codedMixed boundary condition, where I try to read the velocity field for droplet patch and compare it using if-condition. And it seems that this boundary condition does not work fine. Can anyone guide me regarding this matter, how to read field patch value into another field? Thanking You in advance. Below are the fields U and alpha1: alpha.phase Field: [I]FoamFile { format ascii; class volScalarField; location "0"; object alpha1; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 0 0 0 0 0 0]; internalField uniform 0; boundaryField { atmosphere { type fixedValue; value uniform 0; } droplet { type codedMixed;//codedFixedValue; value $internalField; refValue uniform 0; refGradient uniform 0; valueFraction uniform 1; // Name of generated boundary condition name inletProfile2; codeInclude #{ #include "mathematicalConstants.H" #include <fstream> #}; code #{ const fvMesh& mesh = patch().boundaryMesh().mesh(); //accessing the mesh of the current patch const volVectorField& U = mesh.lookupObject<volVectorField>("U"); //accessing the velocity field defined at that mesh const label id = mesh.boundary().findPatchID("droplet"); // create a variable 'id' to store the patch droplet const fvPatch& patch = mesh.boundary()[id]; // to store the mesh data scalarField a(patch.size(), scalar(0)); // creating the variable a of patch(droplet) size and initializing value 0 scalarField updatedField = this->patchInternalField(); //current patchInternalField & assigned it to updatedField forAll(a, i) { scalar magnitude = mag(U[patch.faceCells()[i]]); if (magnitude == 0.0) { a[i] = 0.0; } else { a[i] = 1.0; } updatedField[i] = a; this->patchInternalField() = updatedField; } #}; } leftWall { type zeroGradient; } rightWall { type zeroGradient; } lowerWall { type zeroGradient; } frontAndBack { type empty; } } Velocity Field: FoamFile { format ascii; class volVectorField; location "0"; object U; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 1 -1 0 0 0 0]; internalField uniform (0 0 0); boundaryField { frontAndBack { type empty; } rightWall { type fixedValue; value uniform (0 0 0); } atmosphere { type pressureInletOutletVelocity; value uniform (0 0 0); } leftWall { type fixedValue; value uniform (0 0 0); } lowerWall { type fixedValue; value uniform (0 0 0); } droplet { type rainDropletInletVelocity; flowRate 5e-3; frequency 1; value uniform (0 0 0); } } |
|
August 22, 2023, 10:39 |
|
#2 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40 |
You would normally write the boundary condition so that it updates the refValue and then rely on the updateCoeffs() to finish the job for you. You should absolutely not be trying to modify the internalField directly.
Eg: https://develop.openfoam.com/Develop...chField.C#L286 |
|
Tags |
cfd, codedboundarycondition, codedfixed, codedmixed, openfoam-10 |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Question about different kinds of Boundaries and Boundary Conditions | granzer | Main CFD Forum | 17 | April 12, 2022 18:27 |
sliding mesh problem in CFX | Saima | CFX | 46 | September 11, 2021 08:38 |
Centrifugal fan | j0hnny | CFX | 13 | October 1, 2019 14:55 |
Radiation interface | hinca | CFX | 15 | January 26, 2014 18:11 |
An error has occurred in cfx5solve: | volo87 | CFX | 5 | June 14, 2013 18:44 |