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

Time varying BCs changed inside the code

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By olesen

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 4, 2024, 11:42
Default Time varying BCs changed inside the code
  #1
New Member
 
Eva
Join Date: Jan 2024
Posts: 3
Rep Power: 2
emunoz is on a distinguished road
Hi all,

I am solving a problem for which I need to update the boundary conditions in each iteration based on the same terms that the internal field uses.

The variable is:

volScalarField& Ui = Um[i];

I tried to change the boundary conditions (to a dummy value = 0.25) as:

/************************************************** *******/
forAll(Um[0].boundaryField(), patchi)
{
if(Um[0].boundaryField()[patchi].type() == "uniformFixedValue" )
{
forAll(Ui.boundaryFieldRef()[patchi], facei) //update
Ui.boundaryFieldRef()[patchi][facei] = 0.25;
}
}

Ui.boundaryFieldRef().updateCoeffs();

....

UiEqn.boundaryManipulate(Ui.boundaryFieldRef());

UiEqn.relax();

fvConstraints.constrain(UiEqn);

UiEqn.solve("Ui");

fvConstraints.constrain(Ui);

/************************************************** *******/

Even if Ui.boundaryField() is the desired during the "solve" part, the fvMatrix does not take into account this value but the value from the initialitation in the 0/Umdefault file.

I tried with "fixedValue" and "uniformFixedValue" boundary conditions but the result doesn't change.

Can anyone give me insights of how I can force my new boundary condition values in the fvMatrix UiEqn?

Thanks you all,

Eva
emunoz is offline   Reply With Quote

Old   January 6, 2024, 11:05
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
You are partly there but you need to adjust the boundary condition value with in boundary condition itself, not in the solver.
Probably best to use a uniformFixedValue as you have done, but use a coded type for the PatchFunction1 value. There are a few examples in the tutorials (you'll need to look). Your boundary condition may also lend itself to an expression for the PatchFunction1.
saeed jamshidi and emunoz like this.
olesen is offline   Reply With Quote

Old   January 12, 2024, 04:47
Default
  #3
New Member
 
Eva
Join Date: Jan 2024
Posts: 3
Rep Power: 2
emunoz is on a distinguished road
Quote:
Originally Posted by olesen View Post
You are partly there but you need to adjust the boundary condition value with in boundary condition itself, not in the solver.
Probably best to use a uniformFixedValue as you have done, but use a coded type for the PatchFunction1 value. There are a few examples in the tutorials (you'll need to look). Your boundary condition may also lend itself to an expression for the PatchFunction1.
Thanks for your answer.
As I needed to use terms that were on the Eqn itself but the BC of Ui can not be imposed on the code, I solved it by creating an auxiliary variable.
That way, I imposed the BC I wanted for Ui in the variable aux_Ui, and I impose in the BC of Ui that it has to match the values of aux_Ui:

//////////////////

code #{
const fvPatch& boundaryPatch = patch();
const fvBoundaryMesh& boundaryMesh = boundaryPatch.boundaryMesh();
const fvMesh& mesh = patch().boundaryMesh().mesh();
const vectorField& Cf = boundaryPatch.Cf();
const label patchid = mesh.boundary().findPatchID(this->patch().name());

const volScalarField& aux_Ui((mesh.lookupObject<volScalarField>("aux_Um0 ")));
scalarField& field = *this;

forAll(Cf,faceI){
field[faceI]=aux_Ui.boundaryField()[patchid][faceI];
}
#};

////////////////

Thanks a lot for your valuable help
emunoz is offline   Reply With Quote

Reply

Tags
boundary conditions, fvmatrix, internal field, time varying bcs


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
bash script for pseudo-parallel usage of reconstructPar kwardle OpenFOAM Post-Processing 42 May 7, 2024 23:17
AMI speed performance danny123 OpenFOAM 21 October 24, 2020 04:13
Extrusion with OpenFoam problem No. Iterations 0 Lord Kelvin OpenFOAM Running, Solving & CFD 8 March 28, 2016 11:08
Help for the small implementation in turbulence model shipman OpenFOAM Programming & Development 25 March 19, 2014 10:08
mixerVesselAMI2D's mass is not balancing sharonyue OpenFOAM Running, Solving & CFD 6 June 10, 2013 09:34


All times are GMT -4. The time now is 23:35.