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

Compile boundary condition as a new dynamic library

Register Blogs Community New Posts Updated Threads Search

Like Tree5Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 9, 2019, 06:57
Default
  #21
New Member
 
Lauren Johnston
Join Date: Mar 2019
Posts: 16
Rep Power: 7
laurenj95 is on a distinguished road
Quote:
Originally Posted by rudolf.hellmuth View Post
Paraboloid velocity profile on a circular patch:

Code:
    inlet
    {
        type            codedFixedValue;
        value           uniform (0 0 0);
        redirectType    Poiseuille;   
        code
        #{
            const fvPatch& boundaryPatch = patch(); 
            const vectorField& Cf = boundaryPatch.Cf(); 
            vectorField& U = *this;
        
            //gfunc calculates the function on decomposed patches for parallel runs.
            scalar patchArea = gSum(boundaryPatch.magSf());
            //Info << "Patch area: " << patchArea << endl;
            
            vector ctr = gSum(boundaryPatch.magSf()*Cf)/patchArea;
            //Info << "Patch center: " << ctr << endl;
            
            scalar R = sqrt(patchArea/constant::mathematical::pi);
            //Info << "Patch radius: " << R << endl;
            
            vector n = gSum(boundaryPatch.magSf()*boundaryPatch.nf())/patchArea;
            //Info << "Patch mean normal: " << normal << endl;
            
            scalar Umean = 1.0;
            
            forAll(Cf, i)
            {
                U[i] = -n*2.0*Umean*(1.0 - sqr(mag(Cf[i] - ctr)/R));
            }
            // operator==(vector(1.0, 0.0, 0.0));
        #};
    }
This codedFixedValue BC is working for me. You can use this code to compile a PoiseuilleBC.so if you want.

I hope it can help you,
Rudolf
Hi,

How may I modify this for flow in the y-direction with the inlet centre at coordinates [0 -0.010 0]

Thanks,

Lauren
laurenj95 is offline   Reply With Quote

Old   February 5, 2020, 11:53
Angry Parabolic Velocity condition
  #22
New Member
 
Syed Faisal Pasha Quadri
Join Date: Feb 2020
Posts: 1
Rep Power: 0
syedfaisalpasha is on a distinguished road
My bad

I am not able to implement parabolic velocity condition though I followed the instructions.Can anyone please help me in solving this issue.
Thanks and Regards
syedfaisalpasha
syedfaisalpasha is offline   Reply With Quote

Old   January 21, 2021, 06:53
Default Solution: paraboloid velocity profile
  #23
New Member
 
pardoa
Join Date: May 2018
Posts: 29
Rep Power: 8
pardoa is on a distinguished road
Hello everyone,

This is an old post that helped me a lot to code the paraboloid profile that I wished to define my velocity BC at the inlet from an input flowrate.

I post here the piece of code for anyone who wishes/needs to use it:

Code:
// Get range and orientation
boundBox bb(patch().patch().localPoints(), true);

//Parabola centre
vector paraCtr = vector(0.5*(bb.max() + bb.min()).x(),0.5*(bb.max() + bb.min()).y(),bb.max().z()); // For an open channel with paraCtr at the top centre

//Patch faces centres
const vectorField& cellCtr = patch().Cf();

//Patch face normal vectors
vectorField n(patch().nf());

// Patch mean normal: weighted mean of patch face normal vectors
vector n_vector = gSum(patch().magSf()*n)/gSum(patch().magSf());

//Depth direction
vector depthDir = (0 0 1);

//Transversal direction
vector transDir = n_vector ^ depthDir;

// Patch height and width 
scalar pHeight = ((bb.max() - bb.min()) & depthDir);
scalar pWidth = ((bb.max() - bb.min()) & transDir);

// Calculate local 1-D coordinate for the parabolic profile
scalarField verCoord = ((cellCtr - paraCtr) & depthDir_)/pHeight;
scalarField horCoord = ((cellCtr - paraCtr) & transDir)/(0.5*pWidth);	// Multiply by 0.5 to get the distance from the centre of the parabola to the patch end

//Mean velocity
scalar avgU = -flowRate/gSum(patch().magSf());

// Mean velocity multiplier to get the max velocity (centreline velocity)
scalar avgUmulti=2;

operator==(n*avgUmulti*avgU*(1.0 - sqr(verCoord))*(1.0 - sqr(horCoord)));
Hope this can help someone.

Álvaro
pardoa 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
compile errors of boundary condition "expDirectionMixed" liying02ts OpenFOAM Bugs 2 February 1, 2010 21:11
how to set up a wall boundary condition according to calculated wall shear stress? gameoverli OpenFOAM Pre-Processing 1 May 21, 2009 09:28
How to define a dynamic Boundary Condition? abrahamgx CFX 2 March 10, 2009 00:03
How to define a dynamic Boundary Condition? (New) abrahamgx CFX 2 March 9, 2009 08:43
Dynamic Temperature Boundary Condition Kshitij FLUENT 0 October 12, 2005 14:40


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