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

Change of boundary conditions during run time

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By gschaider
  • 1 Post By gschaider

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 17, 2011, 10:38
Default Change of boundary conditions during run time
  #1
New Member
 
Alexander Sakowitz
Join Date: Jan 2011
Posts: 1
Rep Power: 0
Alexsakowitz is on a distinguished road
I would like to simulate the flow in an engine with valves opening and closing. In order to do this I would like to set a zero gradient condition for the velocity, if the valve is open and a fixedValue condition (value =0) if the valve is closed. Has someone done this before or do you have some recommendations how to start with this problem?
Alexsakowitz is offline   Reply With Quote

Old   January 17, 2011, 12:05
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by Alexsakowitz View Post
I would like to simulate the flow in an engine with valves opening and closing. In order to do this I would like to set a zero gradient condition for the velocity, if the valve is open and a fixedValue condition (value =0) if the valve is closed. Has someone done this before or do you have some recommendations how to start with this problem?
Basically you need a boundary condition based on mixed (have a look at the OF-UserGuide for a brief explanation). Not sure whether there are any ready-made BCs for what you're trying to do. I recommend (but I'm biased) groovyBC (either in the "pure" form or as part of swak4Foam) for that. There such a BC would look like that

valve {
type groovyBC;
valueExpression "vector(0,0,0)";
gradientExpression "vector(0,0,0)"; // not strictly necessary. Default
fractionExpression "sin(time())>0 ? 1 : 0";
}

That opens closes the valve with a frequency of 1/2pi

Bernhard
the_ichthyologist likes this.

Last edited by gschaider; January 17, 2011 at 15:33. Reason: Defined valueExpression twice
gschaider is offline   Reply With Quote

Old   January 17, 2011, 14:18
Default
  #3
Senior Member
 
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 19
benk is on a distinguished road
Hi Bernhard,
First of all, I'm a big fan of groovyBC.

I have a similar question:
What if I had 2 (or more) conditions that had to be met before changing the boundary condition? Just as an example, time and say, max(Temperature).

In my solver, I'd like to set a flag that captures this condition:
Code:
scalar switchBC = 0;
if (time >= someValue1 || max(temp) >= someValue2) {
switchBC = 1;
} else {
switchBC = 0;
}
and then in the boundary file, I would like to have

Code:
valve {
type groovyBC;
valueExpression "vector(0,0,0)";
gradientExpression "vector(0,0,0)"; // not strictly necessary. Default
valueExpression "switchBC>0 ? 1 : 0";
}
I know this isn't possible with groovyBC because it doesn't "see" the switchBC variable. For the moment I've been making a dummy volumeScalarField and hard coding the boundary of this dummy volumeScalarField setting it equal to switchBC, which can then be read by groovyBC. Is this the best way to do what I want to achieve? I feel as if making a dummy volScalarField might be a bit of a waste.
benk is offline   Reply With Quote

Old   January 17, 2011, 15:32
Default
  #4
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by benk View Post
Hi Bernhard,
First of all, I'm a big fan of groovyBC.

I have a similar question:
What if I had 2 (or more) conditions that had to be met before changing the boundary condition? Just as an example, time and say, max(Temperature).

In my solver, I'd like to set a flag that captures this condition:
Code:
scalar switchBC = 0;
if (time >= someValue1 || max(temp) >= someValue2) {
switchBC = 1;
} else {
switchBC = 0;
}
and then in the boundary file, I would like to have

Code:
valve {
type groovyBC;
valueExpression "vector(0,0,0)";
gradientExpression "vector(0,0,0)"; // not strictly necessary. Default
valueExpression "switchBC>0 ? 1 : 0";
}
I know this isn't possible with groovyBC because it doesn't "see" the switchBC variable. For the moment I've been making a dummy volumeScalarField and hard coding the boundary of this dummy volumeScalarField setting it equal to switchBC, which can then be read by groovyBC. Is this the best way to do what I want to achieve? I feel as if making a dummy volScalarField might be a bit of a waste.
I don't quite understand your question. Let me rephrase: I think it contradicts itself. If I go strictly by your example then things are quite easy:
Code:
valve {
type groovyBC;
variables "switchBC=time >= someValue1 || max(temp) >= someValue2;";
valueExpression "vector(0,0,0)";
gradientExpression "vector(0,0,0)"; // not strictly necessary. Default
fractionExpression "switchBC>0 ? 1 : 0";
}
(or you write the condition directly into the valueExpression. BTW: did you mean to write fractionExpression - my original example was wrong). Here switchBC would be evaluated at every timestep using the current state.

The other interpretation (that is not based on the code but on your text) would be that once switchBC changed its value to 1 it would stay one (even if the temperature drops afterwards and the threshold time is not yet used). Such a memory variable is not yet possible in groovyBC (a work-around may be possible using the expressionField-functionObject in swak but I'm not 100% sure). If a bugReport/featureRequest shows up in the swak4Foam-Mantis (feature additions like this will not be done in the "pure" groovyBC anymore) I will think about a way to implement it (no promises)

Bernhard
the_ichthyologist likes this.
gschaider is offline   Reply With Quote

Old   January 17, 2011, 16:09
Default
  #5
Senior Member
 
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 19
benk is on a distinguished road
Ah, ok, thanks. I see how it can be done now.

I guess my example was a bit ambiguous but what I was trying to ask is if there's any way for groovyBC to access a memory variable (like an int) which is set in the solver.
benk is offline   Reply With Quote

Old   April 12, 2014, 02:23
Default
  #6
New Member
 
Laurien Vandewalle
Join Date: Jun 2013
Location: Ghent, Belgium
Posts: 29
Rep Power: 13
lavdwall is on a distinguished road
Hi,

I was wondering if it is possible to change the gradient of a fixedGradient boundary field in a solver/utility.

More specifically, I am simulating a pipe flow with a constant heat flux imposed at the wall. When the simulation is complete, I use a self-written utility myMoveMesh that calculates a certain wall displacement and subsequently moves the wall radially inwards. In this way the diameter/area of the pipe decreases and hence, the gradient of the temperature at the wall needs to change.

When the new mesh is written, I want to restart the simulation with the new pipe dimensions. Therefore, I need to read the new boundary condition from the T-file in a time folder.

What I want to do is calculate the new gradient in the myMoveMesh utility, assign this somehow to the wall boundary and than have this new gradient written in the boundaryField of the T-file after calling T.write().

Is there a way to do this?

Kind regards,
Laurien
lavdwall is offline   Reply With Quote

Reply

Tags
boundary conditions, transient


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
Residence Time Distribution with Periodic Boundary Conditions sanjose FLUENT 1 September 7, 2016 05:13
non reflective boundary conditions for incompresible flow Pascal_doran OpenFOAM Programming & Development 16 August 25, 2015 06:35
CFX doesn't continue calculation... mactech001 CFX 6 November 15, 2009 22:25
Convective Heat Transfer - Heat Exchanger Mark CFX 6 November 15, 2004 16:55
A problem about setting boundary conditions lyang Main CFD Forum 0 September 19, 1999 19:29


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