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

How to access mesh information to define a boundar condition

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 21, 2022, 17:10
Default How to access mesh information to define a boundar condition
  #1
New Member
 
Waheed Bello
Join Date: Nov 2022
Posts: 2
Rep Power: 0
Vader92 is on a distinguished road
Hi, I'm new to OpenFoam. I'm looking to develop an adjoint optimization solver in OpenFOAM. I have a mesh size of (20,20,1) .I added a new volScalarField vf which i defined in my 0 folder.

internalField nonuniform List<scalar>
400

I want to implement a coded boundary condition such that for each element on the boundary, if vf=1 , U=(5, 0 0) and if vf=0, U=(0,0,0). My implementation looks something like

inlet
{
type codedMixed;
refValue uniform (0 0 0);
refGradient uniform (0 0 0);
valueFraction uniform 1;

name inletBC;

code
{
const fvPatch& boundaryPatch = patch();
vectorField& field = *this;
vectorField vf= vf;

forAll(boundaryPatch, faceI)
{
field[faceI] = vector((1-vf[faceI])*0 + vf[faceI]*5,0,0);
}

}
}

I believe the bolded line is causing some errors as I don't think that's the correct way to get the volScalarField vf. I am unsure as to how I could access vf and use it in this BC. Any help will be appreciated.
Vader92 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
Getting access to mesh (fvMesh) via object registry Chris Lucas OpenFOAM Programming & Development 18 January 15, 2024 02:57
Calculating source term total cell-zone volume parallel computation RobV Fluent UDF and Scheme Programming 2 May 30, 2022 03:46
sliding mesh problem in CFX Saima CFX 46 September 11, 2021 07:38
[solids4Foam] MultiMaterial in FSI problems Hgholami OpenFOAM CC Toolkits for Fluid-Structure Interaction 12 July 7, 2021 19:18
Laminar Kinetic Energy Model (Walters 2008) logoswort Fluent UDF and Scheme Programming 2 May 19, 2017 19:41


All times are GMT -4. The time now is 10:51.