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

Updating a boundary condition from the solver

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 2 Post By juho
  • 1 Post By eugene

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 30, 2008, 04:56
Default I'd like to bother you all wit
  #1
Member
 
Juho Peltola
Join Date: Mar 2009
Location: Finland
Posts: 89
Rep Power: 17
juho is on a distinguished road
I'd like to bother you all with a question again, sorry about it.

I've tried to update a boundary condition on each timestep based on values of the solution of the earlier steps.

The field I want to modify is a scalar and the boundary is defined as a uniform fixedValue.

I've tried to update it by including lines:

variable.boundaryField()[patchI] = newValue;
variable.correctBoundaryConditions();

in to the time loop. newValue is a scalar which is calculated on each timestep.

As many you must have noticed by now, it doesn't work. The values on the boundary patch don't change, even if the newValue changes.

What is the correct way to do this?
randolph and Luttappy like this.
juho is offline   Reply With Quote

Old   June 3, 2008, 06:28
Default Try variable.boundaryField(
  #2
Senior Member
 
Eugene de Villiers
Join Date: Mar 2009
Posts: 725
Rep Power: 21
eugene is on a distinguished road
Try

variable.boundaryField()[patchI] == newValue;

The important bit is the double "==".
Mirza8 likes this.
eugene is offline   Reply With Quote

Old   June 3, 2008, 07:00
Default Thank you!! Works perfectly!
  #3
Member
 
Juho Peltola
Join Date: Mar 2009
Location: Finland
Posts: 89
Rep Power: 17
juho is on a distinguished road
Thank you!! Works perfectly!

I had given up on doing it in the solver was writing a boundary condition to do it.
juho is offline   Reply With Quote

Old   June 3, 2008, 07:35
Default Well doing it as a boundary co
  #4
Senior Member
 
Eugene de Villiers
Join Date: Mar 2009
Posts: 725
Rep Power: 21
eugene is on a distinguished road
Well doing it as a boundary condition is probably the "best" way of going about things.

Performing the assignment in the solver is a lot quicker to code though!
eugene is offline   Reply With Quote

Old   September 19, 2008, 04:19
Default Hi "I've tried to update it
  #5
Senior Member
 
tian's Avatar
 
Tian
Join Date: Mar 2009
Location: Berlin, germany
Posts: 122
Rep Power: 17
tian is on a distinguished road
Hi

"I've tried to update it by including lines:"

Can you give me an excample for the time loop? I also want to update the boundary condition for U after every iteration. I want use the bouyantSimpleFoam.

Thanks a lot

Bye
Thomas
__________________
BIM HVACTool, The Green Building Simulation Tool for OpenFOAM, Energy Plus and Radiance.
tian is offline   Reply With Quote

Old   November 19, 2008, 08:29
Default Hi Juho and Eugene I want t
  #6
New Member
 
Niranjan Ghaisas
Join Date: Mar 2009
Location: Pune, Maharashtra, India
Posts: 10
Rep Power: 17
nsghaisas is on a distinguished road
Hi Juho and Eugene

I want to implement a boundary condition that reads values from the previous time step and sets the gradient of another variable at the boundaries.

More specifically, I am trying to set the pressure gradient at the boundaries based on the temperature calculated in the previous time step.
dp/dz = g*beta*(T-Tref)

Could you giveme some pointers for doing that?

Thanks

Niranjan
nsghaisas is offline   Reply With Quote

Old   November 20, 2008, 06:05
Default Hi Adam Am I glad that you
  #7
New Member
 
Niranjan Ghaisas
Join Date: Mar 2009
Location: Pune, Maharashtra, India
Posts: 10
Rep Power: 17
nsghaisas is on a distinguished road
Hi Adam

Am I glad that you jumped in!

Thanks for these detailed instructions. Will try them out.

Thanks a lot.

Niranjan
nsghaisas is offline   Reply With Quote

Old   March 18, 2011, 10:42
Default
  #8
Senior Member
 
isabel
Join Date: Apr 2009
Location: Spain
Posts: 171
Rep Power: 17
isabel is on a distinguished road
Hello everybody,

I want to update a boundary condition called “ABAJO” on each timestep based on the values of the solution of the previous timestep. Particularty, I want to correct the variable T2=110*gamma.
I have written this code:

label inletPatchID = mesh.boundaryMesh().findPatchID("ABAJO");
fvPatchScalarField& condition = T2.boundaryField()[inletPatchID];
forAll(condition, patchI)
{
T2.boundaryField()[patchI] = 110*gamma.boundaryField()[patchI];
}
T2.correctBoundaryConditions();

The solver compiles Ok, but when I run the tutorial I have the following error:

#0 Foam::error:rintStack(Foam::Ostream&) in "/home/isabel/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libOpenFOAM.so"
#1 Foam::sigSegv::sigSegvHandler(int) in "/home/isabel/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libOpenFOAM.so"
#2 Uninterpreted: [0xb7766400]
#3 main in "/home/isabel/OpenFOAM/OpenFOAM-1.5/applications/bin/linuxGccDPOpt/17marzo5"
#4 __libc_start_main in "/lib/tls/i686/cmov/libc.so.6"
#5 _start at /build/buildd/glibc-2.9/csu/../sysdeps/i386/elf/start.S:122
Segmentation error
isabel is offline   Reply With Quote

Old   June 14, 2021, 13:55
Default
  #9
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 but maybe any of you can help me to solve the issue that I am currently facing.

I wish to turn into zero the values calculated by interFoam at the boundaries if alpha1 (water fraction) is lower than 0.1. I have managed to achieve this at the cells, but somehow I cannot make it at the boundaries.

Since OpenFOAM treats the internalFields and boundaryFields separately, I need also to convert the values of the cells and boundary faces whose alpha1 value is smaller than 0.1 into 0. Everything works for the internalFields:

Code:
    forAll(alpha1,i)
    {
        if (alpha1[i] < 0.1)
        {
            dSur[i] = 0.0;
            piezoSur[i] = 0.0;
            hSur[i] = 0.0;
        }
        else
        {
            dSur[i] = p[i]/(rho[i]*mag(gSur[i]));
            piezoSur[i] = dSur[i] + (meshSurface.C()[i].component(vector::Z)+zRef[i]);
            hSur[i] = ((0.5*magSqr(U[i]))/mag(gSur[i])) + dSur[i] + (meshSurface.C()[i].component(vector::Z)+zRef[i]);
        }
    }
But at the boundaries it does not:

Code:
    forAll (meshSurface.boundaryMesh(),patchID) 
    {
        forAll (meshSurface.boundaryMesh()[patchID],i) 
        {
            dSur.boundaryField()[patchID][i] = p.boundaryField()[patchID][i]/(rho.boundaryField()[patchID][i]*mag(gSur[patchID][i]));
        }
    }
This is the error that I am prompted with when I try to compile the code:

PHP Code:
./surface/solve_surfaceFlow.HIn function &#8216;int main(int, char**)’:
./surface/solve_surfaceFlow.H:65:132errorassignment of read-only location &#8216;(&(& dSur.Foam::GeometricField<Type, PatchField, GeoMesh>::boundaryField<double, Foam::fvPatchField, Foam::volMesh>())->Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::Boundary::<anonymous>.Foam::FieldField<Foam::fvPatchField, double>::<anonymous>.Foam::PtrList<Foam::fvPatchField<double> >::<anonymous>.Foam::UPtrList<T>::operator[]<Foam::fvPatchField<double> >(patchID))->Foam::fvPatchField<double>::<anonymous>.Foam::Field<double>::<anonymous>.Foam::List<double>::<anonymous>.Foam::UList<T>::operator[]<double>(i)’
             
dSur.boundaryField()[patchID][i] = p.boundaryField()[patchID][i]/(rho.boundaryField()[patchID][i]*mag(gSur[patchID][i])); 
Could anyone help to me figure out what I am doing wrong? I have also try with boundaryFieldRef. Then the code compiles but the simulation crashes at the very beginning.

Any help will be greatly welcomed!

Thanks!
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
Boundary condition error depending on location of solver execution kjmaki OpenFOAM Running, Solving & CFD 0 June 18, 2008 16:04
Boundary condition of the third kind or Danckwertz boundary condition plage OpenFOAM Running, Solving & CFD 4 October 3, 2006 13:21
How to setup boundary condition with couple solver JINHUI FLUENT 0 September 8, 2006 18:07
boundary condition for high order Possion solver jen Main CFD Forum 0 November 16, 2005 20:04
boundary condition for high order possion solver *NM* jen Main CFD Forum 0 November 16, 2005 20:02


All times are GMT -4. The time now is 11:21.