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

Coded boundary condition

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By Tobermory

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 9, 2021, 12:07
Default Coded boundary condition
  #1
New Member
 
Join Date: Jan 2021
Location: Norway
Posts: 22
Rep Power: 5
subhojitkadiacfd is on a distinguished road
Hi all,
How can I introduce a boundary condition of a variable as a function of another variable. Lets say, how can I introduce the following boundary condition:
epsilon=0.391*k*y*z
Thanking you.
Subhojit

Last edited by subhojitkadiacfd; May 9, 2021 at 15:35.
subhojitkadiacfd is offline   Reply With Quote

Old   May 10, 2021, 09:26
Default
  #2
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 747
Rep Power: 14
Tobermory will become famous soon enough
Simplest would be to use the funkSetBoundaryField utility, but you want to do it with codeStream, so here's how. Use a fixedValue type for the epsilon boundary patch you are interested in (here I will assume that this patch is called "inlet"), and put this for the value:

Code:
inlet
{
   type    fixedValue;
   value   #codeStream {
               codeInclude #{ #include "fvCFD.H" #};
               codeOptions  #{ -I$(LIB_SRC)/finiteVolume/lnInclude -I$(LIB_SRC)/meshTools/lnInclude #};
               codeLibs #{ -lfiniteVolume -lmeshTools #};
               code #{
                  const IOdictionary& d = static_cast<const IOdictionary&>(dict.parent().parent());
                  const fvMesh& mesh = refCast<const fvMesh>(d.db());
                  const label id = mesh.boundary().findPatchID("inlet");
                  const fvPatch& patch = mesh.boundary()[id];
                  scalarField epsp(patch.size(), 0.0);

                  const volScalarField& k = mesh.lookupObject<volScalarField>("k");
                  const scalarField& kp = k.boundaryField()[id];

                  forAll(epsp, facei)
                  {
                     const scalar y = patch.Cf()[facei].y();
                     epsp[facei] = 0.391*kp[facei]*y;
                  }
                  writeEntry(os, "", epsp);
               #};
            };
    }
Note the footwork that's required to find the patch, and to get references to the mesh and other fields. Good luck!
Tobermory is offline   Reply With Quote

Old   May 12, 2021, 06:42
Default
  #3
New Member
 
Join Date: Jan 2021
Location: Norway
Posts: 22
Rep Power: 5
subhojitkadiacfd is on a distinguished road
Many thanks. It shows dict is not defined. How to remove it?
subhojitkadiacfd is offline   Reply With Quote

Reply

Tags
codedfixed, codedmixed


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
sliding mesh problem in CFX Saima CFX 46 September 11, 2021 08:38
Centrifugal fan j0hnny CFX 13 October 1, 2019 14:55
Accessing multiple boundary patches from a custom boundary condition file ripudaman OpenFOAM Programming & Development 0 October 22, 2014 19:34
Radiation interface hinca CFX 15 January 26, 2014 18:11
An error has occurred in cfx5solve: volo87 CFX 5 June 14, 2013 18:44


All times are GMT -4. The time now is 02:44.