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

timeVaryingMappedFixedValueFvPatchField for Traction control at boundaries

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By bigphil
  • 1 Post By bigphil

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 18, 2011, 10:34
Default timeVaryingMappedFixedValueFvPatchField for Traction control at boundaries
  #1
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17
Hisham is on a distinguished road
Dear Foamers,

Using the solidDisplacementFoam, I need to introduce a timeVaryingMappedFixedValue -like BC for traction. As far as I know, the tractionDisplacement BC supports integration over neither time nor space. However, I am not so sure what the autoMap and rmap functions do exactly!

If there were any such BC out there, I would highly appreciate it if it were to be shared

Else, to introduce such BC, what do you suggest I should start with? I found this groovyTractionDisplacementBC and I thought to use it as a guideline. Any help or advice is appreciated.

Thanks in advance and best regards,
Hisham

Last edited by Hisham; September 18, 2011 at 12:35.
Hisham is offline   Reply With Quote

Old   September 18, 2011, 12:48
Default
  #2
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17
Hisham is on a distinguished road
I think I'll copy the timeVaryingMappedFixedValue BC files, rename them and let them inhere tractionDisplacementFvPatchVectorField to use it's autoMap, rmap, updateCoeffs & write functions. I would, then, "untemplate" the functions and modify them for a tractionDisplacementFvPatchField instead of a fixedValue one. Am I planning in the right direction????
Hisham is offline   Reply With Quote

Old   September 18, 2011, 13:38
Default
  #3
Super Moderator
 
bigphil's Avatar
 
Philip Cardiff
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 1,097
Rep Power: 34
bigphil will become famous soon enoughbigphil will become famous soon enough
Hi Hisham,

Using groovyTractionDisplacementBC would be the easiest option, it will give you a time-varying traction boundary condition.

tractionDisplacementFvPatchField derives from a fixedGradientFvPatchField so you would need to start with some sort of timeVaryingMappedFixedGradient boundary condition, but I think this would be quite a bit of effort so groovy is a more straight forward option.

Philip
bigphil is offline   Reply With Quote

Old   September 18, 2011, 14:00
Default
  #4
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17
Hisham is on a distinguished road
Hi Phillip

My problem is that I have a random time series for traction/pressure that is, also, not uniform (also random) all over the patch. Therefore, I need some space and time interpolation and hence I am thinking of using timeVaryingMappedFixedValue as a base for a new BC and to replace whatever fixed value patch field with a traction Displacement one which inherits a fixed gradient patch by default.

Is it possible to use groovyBC in my case? Can you elaborate please!

Thanks
Hisham
Hisham is offline   Reply With Quote

Old   September 18, 2011, 14:18
Default
  #5
Super Moderator
 
bigphil's Avatar
 
Philip Cardiff
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 1,097
Rep Power: 34
bigphil will become famous soon enoughbigphil will become famous soon enough
Hisham,


You want your boundary to vary in time AND space, OK I don't think the current groovyTractionDisplacement can do that at the moment (but could probably be altered to do this).

I think the easiest way for you to achieve what you want would be to create a header file in the time loop that updates your boundary conditions. The header file should be something like the following:

Code:
label patchID = mesh.boundaryMesh().findPatchID("patch_of_interest");

if(patchID == -1)
   {
      Info << "Patch of interest not found." << endl;
      return 0;
    }


tractionDisplacementFvPatchVectorField& Dpatch =
refCast<tractionDisplacementFvPatchVectorField>
   (
       D.boundaryField()[patchID]
    );

vectorField patchFaceCentres = mesh.boundaryMesh()[patchID].faceCentres();

forAll(Dpatch.traction(), facei)
{
	Dpatch.traction()[facei] = runTime.value() * patchFaceCentres[facei];
}
This code will set the traction on each patch face as some function of time and the patch face position. Obviously you set the traction however you would like, I was just giving an example traction to set.


Philip
charmc likes this.

Last edited by bigphil; September 19, 2011 at 13:05. Reason: Typo: Changed "Upatch" to "Dpatch"
bigphil is offline   Reply With Quote

Old   September 18, 2011, 17:12
Default
  #6
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17
Hisham is on a distinguished road
I got the error:

Quote:
error: ‘tractionDisplacementFvPatchVectorField’ was not declared in this scope
I tried to include the tractionDisplacement header but then got "Additional" errors:
Quote:
In file included from /opt/openfoam201/src/finiteVolume/lnInclude/fixedGradientFvPatchFields.H:29:0,
from tractionDisplacement/tractionDisplacementFvPatchVectorField.H:40,
from Try.H:1,
from geotechFoam.C:100:
/opt/openfoam201/src/finiteVolume/lnInclude/fixedGradientFvPatchField.H: In function ‘int main(int, char**)’:
/opt/openfoam201/src/finiteVolume/lnInclude/fixedGradientFvPatchField.H:42:1: error: ‘namespace’ definition is not allowed here
In file included from /opt/openfoam201/src/finiteVolume/lnInclude/fixedGradientFvPatchField.H:208:0,
from /opt/openfoam201/src/finiteVolume/lnInclude/fixedGradientFvPatchFields.H:29,
from tractionDisplacement/tractionDisplacementFvPatchVectorField.H:40,
from Try.H:1,

I have no clue to what I'm doing wrong.

Also, what is the Upatch in the forAll loop?

Last edited by Hisham; September 19, 2011 at 13:32.
Hisham is offline   Reply With Quote

Old   September 19, 2011, 05:49
Default
  #7
Super Moderator
 
bigphil's Avatar
 
Philip Cardiff
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 1,097
Rep Power: 34
bigphil will become famous soon enoughbigphil will become famous soon enough
Hisham,


Quote:
Originally Posted by Hisham View Post
I tried to include the tractionDisplacement header but then got "Additional" errors:
If you include the following line at the top of your solver:
Code:
#include "tractionDisplacementFvPatchVectorField.H"

Quote:
Originally Posted by Hisham View Post
Also, what is the Upatch in the forAll loop?
Sorry the Upatch is meant to be "Dpatch". (In my solvers I call the displacement variable U.)

If it still doesn't compile then paste the full compilation log here.


Philip
bigphil is offline   Reply With Quote

Old   September 19, 2011, 12:48
Default
  #8
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17
Hisham is on a distinguished road
Philip,

The include line is:
Quote:
#include "tractionDisplacement/tractionDisplacementFvPatchVectorField.H"
The error I get after a wclean all - wmake all

Quote:
hisham@hisham-Aspire-6930G:~/OpenFOAM/hisham-2.0.1/geotechFoam$ wclean all
wclean ./
hisham@hisham-Aspire-6930G:~/OpenFOAM/hisham-2.0.1/geotechFoam$ wmake all
Making dependency list for source file tractionDisplacement/tractionDisplacementFvPatchVectorField.C
Making dependency list for source file geotechFoam.C
SOURCE=tractionDisplacement/tractionDisplacementFvPatchVectorField.C ; g++ -m32 -Dlinux -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam201/src/finiteVolume/lnInclude -ItractionDisplacement/lnInclude -IlnInclude -I. -I/opt/openfoam201/src/OpenFOAM/lnInclude -I/opt/openfoam201/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linuxGccDPOpt/tractionDisplacementFvPatchVectorField.o
SOURCE=geotechFoam.C ; g++ -m32 -Dlinux -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam201/src/finiteVolume/lnInclude -ItractionDisplacement/lnInclude -IlnInclude -I. -I/opt/openfoam201/src/OpenFOAM/lnInclude -I/opt/openfoam201/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linuxGccDPOpt/geotechFoam.o
In file included from /opt/openfoam201/src/finiteVolume/lnInclude/fixedGradientFvPatchFields.H:29:0,
from tractionDisplacement/tractionDisplacementFvPatchVectorField.H:40,
from geotechFoam.C:85:
/opt/openfoam201/src/finiteVolume/lnInclude/fixedGradientFvPatchField.H: In function ‘int main(int, char**)’:
/opt/openfoam201/src/finiteVolume/lnInclude/fixedGradientFvPatchField.H:42:1: error: ‘namespace’ definition is not allowed here
In file included from /opt/openfoam201/src/finiteVolume/lnInclude/fixedGradientFvPatchField.H:208:0,
from /opt/openfoam201/src/finiteVolume/lnInclude/fixedGradientFvPatchFields.H:29,
from tractionDisplacement/tractionDisplacementFvPatchVectorField.H:40,
from geotechFoam.C:85:
/opt/openfoam201/src/finiteVolume/lnInclude/fixedGradientFvPatchField.C:31:1: error: ‘namespace’ definition is not allowed here
In file included from tractionDisplacement/tractionDisplacementFvPatchVectorField.H:40:0,
from geotechFoam.C:85:
/opt/openfoam201/src/finiteVolume/lnInclude/fixedGradientFvPatchFields.H:34:1: error: ‘namespace’ definition is not allowed here
In file included from geotechFoam.C:85:0:
tractionDisplacement/tractionDisplacementFvPatchVectorField.H:44:1: error: ‘namespace’ definition is not allowed here
In file included from geotechFoam.C:100:0:
Try.H:4:1: error: ‘tractionDisplacementFvPatchVectorField’ was not declared in this scope
Try.H:4:41: error: ‘Dpatch’ was not declared in this scope
Try.H:5:13: error: ‘tractionDisplacementFvPatchVectorField’ cannot appear in a constant-expression
Try.H:8:5: error: no matching function for call to ‘refCast(Foam::fvPatchField<Foam::Vector<double> >&)’
readGeotechFoamControls.H:3:11: warning: unused variable ‘nCorr’
readGeotechFoamControls.H:5:29: warning: unused variable ‘convergenceTolerance’
geotechFoam.C:111:13: warning: unused variable ‘iCorr’
geotechFoam.C:112:16: warning: unused variable ‘initialResidual’
readGeotechFoamControls.H:3:11: warning: unused variable ‘nCorr’
readGeotechFoamControls.H:5:29: warning: unused variable ‘convergenceTolerance’
make: *** [Make/linuxGccDPOpt/geotechFoam.o] Error 1
hisham@hisham-Aspire-6930G:~/OpenFOAM/hisham-2.0.1/geotechFoam$
Hisham is offline   Reply With Quote

Old   September 19, 2011, 13:05
Default
  #9
Super Moderator
 
bigphil's Avatar
 
Philip Cardiff
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 1,097
Rep Power: 34
bigphil will become famous soon enoughbigphil will become famous soon enough
Hisham,


Did you include the traction BC file at the top of your solver? (ie before the main() function NOT inside the main function.

Also normally when I include a BC in my solver I add it to Make/files (ie tractionDisplacementFvPatchVectorField.C) and I use "wclean" and "wmake" to compile the solver and the BC will be automatically linked. I am not sure what "wmake all" does in this situation...

Could you post a "stripped-down" version of your solver here so I can try to compile it?


Philip
bigphil is offline   Reply With Quote

Old   September 19, 2011, 13:42
Default
  #10
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17
Hisham is on a distinguished road
Quote:
Originally Posted by bigphil View Post

Did you include the traction BC file at the top of your solver? (ie before the main() function NOT inside the main function.
Yes! (EDIT: No, read following answer)

Quote:
Originally Posted by bigphil View Post
Also normally when I include a BC in my solver I add it to Make/files (ie tractionDisplacementFvPatchVectorField.C)
I believe the tractionDisplacement BC .C file is included in the wmake (files & option) files for the solver before I edit it (it is based on solidDisplacementFoam) or else I'm not following

Quote:
Originally Posted by bigphil View Post
and I use "wclean" and "wmake" to compile the solver and the BC will be automatically linked. I am not sure what "wmake all" does in this situation...
I guess "wmake all" here is equivalent to wmake as there is only one destination to compile!

Quote:
Originally Posted by bigphil View Post
Could you post a "stripped-down" version of your solver here so I can try to compile it?
I will as soon as I return to the machine that has the code. Nevertheless, I commented out all lines except the includes, the lines you suggest and the time loop.

Last edited by Hisham; September 19, 2011 at 14:08.
Hisham is offline   Reply With Quote

Old   September 19, 2011, 13:52
Default
  #11
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17
Hisham is on a distinguished road
Sorry Philip, you are right. I had, foolishly, misplaced the include inside int Main()

I edited it and it compiled (for solidDisplacementFoam). I will post further info later.

Thanks a lot
Hisham is offline   Reply With Quote

Old   September 19, 2011, 14:03
Default
  #12
Super Moderator
 
bigphil's Avatar
 
Philip Cardiff
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 1,097
Rep Power: 34
bigphil will become famous soon enoughbigphil will become famous soon enough
Great,

Hopefully it will do what you want.

Philip
Hisham likes this.
bigphil is offline   Reply With Quote

Old   September 19, 2011, 14:13
Default
  #13
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17
Hisham is on a distinguished road
It has worked beautifully. I have another question though! How can I apply that to internal faces? Say I need to define a variable (e.g. displacement) for a face or volume inside the domain.

I want to know how to define an internal face (not a boundary patch) and assign values to its parameters from within the code.
Hisham is offline   Reply With Quote

Old   September 19, 2011, 14:30
Default
  #14
Super Moderator
 
bigphil's Avatar
 
Philip Cardiff
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 1,097
Rep Power: 34
bigphil will become famous soon enoughbigphil will become famous soon enough
Hisham,

Hmmnn I am not really sure what you mean by applying a BC to internal face...

The value at an internal face is solved for so you could set the value of D at an internal cell but when you solve the system then the value an this internal face will change.
Maybe I am not quite understanding. Also D is stored (and solved for) at cell centres not faces.
If you really wanted to set the value of D in the internal cells, something like this would do it (but when you solve the equations then these values will be overwritten):
Code:
vectorField cellCentres = mesh.C();
forAll(D.internalField(), celli)
{
   D.internalField()[celli] = cellCentres[celli] * runTime.value() * .....;
}
Philip
bigphil is offline   Reply With Quote

Old   September 19, 2011, 14:59
Default
  #15
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17
Hisham is on a distinguished road
Thanks a lot Philip for your quick responses.

I do not mean the full domain. Just a pre-defined face. For example, I see there is a faceZone and cellZone. I know how to assign cellZones in say blockMesh or Gmsh (sadly I can't say the same for faceZones). How can I retrieve the id of contained or nearest cells "for faceZone case" (or loop them knowing their position) and assign variables to these cells.

I guess it is possible take for example that setFields (funkySetFields) utility can work for time steps other than the initial.

Thanks again
Hisham

Last edited by Hisham; September 19, 2011 at 16:23.
Hisham is offline   Reply With Quote

Old   September 19, 2011, 15:20
Default
  #16
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 Hisham View Post
Thanks a lot Philip for your quick responses.

I do not mean the full domain. Just a pre-defined face. For example, I see there is a faceZone and cellZone. I know how to assign cellZones in say blockMesh or Gmsh (sadly I can't say the same for faceZones). How can I retrieve the id of contained or nearest cells "for faceZone case" (or loop them knowing their position) and assign variables to these cells.

I guess it is possible take for example that setFields (setFunkyFields) utility can work for time steps other than the initial.
That is my cue

swak4Foam (which now is the home of funkySetFields) has two possibilities to do that (fix the solution in selected cells):

- the functionObject manipulateField. That overwrites the values of a field in selected cells at the end of each timesteps. That doesn't need a modification of the solver but as the equation is solved for those cells anyway the results may be weird
- an object forceEquation that helps to fix the equations in selected cells before they are solved. You'll have to modify the solver for this (there comes an example of a modified interFoam with swak4Foam). It does so using the setValues-method of the fvMatrix-class (so you can also do that without swak4Foam, but you're on your own here)

Please beware that if used wrongly both of them are ugly hacks and I don't accept responsibility for wrong physics

Bernhard
gschaider is offline   Reply With Quote

Old   September 19, 2011, 15:36
Default
  #17
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17
Hisham is on a distinguished road
Hi Bernhard,

The idea is, for example, if I want to define the temperature inside part of a given domain for a thermal-stress analysis (it is not wrong physically). I am sure (as you said) it is possible to implement such constraint on a numerical solution. I will research the forceEquation option as it seems the proper tool for the task. I will look into swak4Foam for that.

Another thing is: how can I recognize cells for a cellZone or faceZone from inside the code (and their positions). And (if not yet too much to ask) how can I define faceZones in input

Thanks a lot Bernhard & Philip
Hisham

EDIT: from the gmshToFoam code, it seems that any internal surface defined as physical surface is transformed into a faceZone!

Last edited by Hisham; September 19, 2011 at 16:05.
Hisham is offline   Reply With Quote

Reply

Tags
groovybc, groovytractiondispbc, soliddisplacementfoam, timevaryingmappedbc, tractiondisplacement


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
Problems of running Oscillating plate tutorial vovogoal CFX 20 February 4, 2016 08:03
error in two way fsi kmgraju CFX 1 May 2, 2011 03:32
periodic boundaries - flow through a net PK FLUENT 0 July 12, 2007 12:58
maintaining a logarithmic velocity distribution Morten Andersen CFX 1 January 8, 2007 12:37
mass flux correction at outflow boundaries Subhra Datta Main CFD Forum 2 November 24, 2003 14:11


All times are GMT -4. The time now is 04:25.