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

howto write a patch field during the run

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 16, 2012, 16:15
Default howto write a patch field during the run
  #1
Senior Member
 
Mohammad
Join Date: Feb 2010
Location: Shiraz, Iran
Posts: 108
Rep Power: 16
m2montazari is on a distinguished road
hi all,
I'm a beginner in OpenFOAM, but I think my problem is not so trivial.
I run a transient problem and I want to write a field (like pressure) on one or more of patches every n timestep during the process. Although I don't want to write all the fields on the whole domain cells or nodes which would fill my hard disk! but I just need one or some fields, on one or more patches to be written somewhere. I think OF doesn't have such a capability by itself and I should write and add a new utility or something like that.

any help or comment would be welcomed.
thanks.
mohammad
m2montazari is offline   Reply With Quote

Old   March 18, 2012, 03:13
Default
  #2
Senior Member
 
Mohammad
Join Date: Feb 2010
Location: Shiraz, Iran
Posts: 108
Rep Power: 16
m2montazari is on a distinguished road
any comments?

no comments?!
m2montazari is offline   Reply With Quote

Old   March 18, 2012, 15:53
Default
  #3
Senior Member
 
Mohammad
Join Date: Feb 2010
Location: Shiraz, Iran
Posts: 108
Rep Power: 16
m2montazari is on a distinguished road
I found something in OF called partialwrite. it does something similar to what I want; but if I'm right, it writes some data in less frequent times. it is the opposite of what I want. I want to write all data each 1000 timesteps, but some specific data each 10 timesteps. if I want to use partial write It would write all data each 10 timesteps and then deletes all but the specified ones (what uses too much time to write and delete).

I'm waiting for any comments yet.
mohammad

Last edited by m2montazari; March 22, 2012 at 08:45.
m2montazari is offline   Reply With Quote

Old   March 22, 2012, 08:51
Default
  #4
Senior Member
 
Mohammad
Join Date: Feb 2010
Location: Shiraz, Iran
Posts: 108
Rep Power: 16
m2montazari is on a distinguished road
as I mentioned in my later post, partialwrite writes all fields and then deletes all but the specified fields that mentioned in controldict. the other problem is that I just need pressure on one of the boundaries(a wall) but partialwrite writes on all cells of mesh region.
can't anyone help me?!!!
any comments or key points are sincerely welcomed

mohammad
m2montazari is offline   Reply With Quote

Old   March 22, 2012, 10:21
Default
  #5
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 m2montazari View Post
as I mentioned in my later post, partialwrite writes all fields and then deletes all but the specified fields that mentioned in controldict. the other problem is that I just need pressure on one of the boundaries(a wall) but partialwrite writes on all cells of mesh region.
can't anyone help me?!!!
any comments or key points are sincerely welcomed

mohammad
Have a look at the sample-utility. In the surfaces-section it is possible (if I remember it correctly) to specify patches. They will then be written in (for instance) VTK-format
gschaider is offline   Reply With Quote

Old   March 27, 2012, 16:29
Default
  #6
Member
 
Björn Windén
Join Date: Feb 2012
Location: National Maritime Research Institute, Tokyo, Japan
Posts: 37
Rep Power: 14
winden is on a distinguished road
Hi.

I had a similar problem and I too found it frustrating that all utilities that I looked at that were supposed to calculate/write a variable on a patch used:


variable.boundaryField()[patchi] = <expression>
variable.write()

which only sets the value on the specified patch but forces the whole field to be written (usually to zero.) I settled for that because I don't have a harddrive-space issue at the moment but it would be nice to know if there is a better way of doing it. Sample works if the field already exists but what if you want to create a new one? I guess the problem is that all fVfields have to be derived from the polyMesh.

//Björn
winden is offline   Reply With Quote

Old   March 27, 2012, 19:44
Default
  #7
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 winden View Post
Hi.

I had a similar problem and I too found it frustrating that all utilities that I looked at that were supposed to calculate/write a variable on a patch used:


variable.boundaryField()[patchi] = <expression>
variable.write()

which only sets the value on the specified patch but forces the whole field to be written (usually to zero.) I settled for that because I don't have a harddrive-space issue at the moment but it would be nice to know if there is a better way of doing it. Sample works if the field already exists but what if you want to create a new one? I guess the problem is that all fVfields have to be derived from the polyMesh.

//Björn
"Sample works if the field already exists": Well. You created your field variable. So it is already there. Suppose in the IOobject-constructor you gave it the name "bjornsVariable". Then you can sample for "bjornsVariable" on the patch (if it was created outside the time-loop). You'll only need the first line of your code-example for this to work
gschaider is offline   Reply With Quote

Old   March 28, 2012, 07:18
Default
  #8
Member
 
Björn Windén
Join Date: Feb 2012
Location: National Maritime Research Institute, Tokyo, Japan
Posts: 37
Rep Power: 14
winden is on a distinguished road
Ah, very clever. I didn't think of that. Thank you!

//Björn
winden is offline   Reply With Quote

Old   March 31, 2012, 05:21
Default
  #9
Senior Member
 
Mohammad
Join Date: Feb 2010
Location: Shiraz, Iran
Posts: 108
Rep Power: 16
m2montazari is on a distinguished road
hi all,
thanks for your your replies. I had tried the way bjorn said and the problem was that it writes all cells value(as bjorns mentioned, too). bernhard suggested to use sample utility; but if I'm correct, sample utility is a post-processing utility and uses written fields to sample them in specified points, lines or surfaces. but as I said, I want to write some fields on some patches more frequent. for example I want to write a field each 10 timesteps, but other fields each 1000 timesteps. so using sample utility wont help(if I'm correct)
I wonder if I could write a filed on a patch simply by "variableField.boundaryField()[sourcePatchID].write();" but fvPatch doesn't have write function!
anyway I will take a look at the source files of sample utility and try to find a good solution.
thanks,
mohammad
m2montazari is offline   Reply With Quote

Old   March 31, 2012, 17:14
Default
  #10
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 m2montazari View Post
hi all,
thanks for your your replies. I had tried the way bjorn said and the problem was that it writes all cells value(as bjorns mentioned, too). bernhard suggested to use sample utility; but if I'm correct, sample utility is a post-processing utility and uses written fields to sample them in specified points, lines or surfaces. but as I said, I want to write some fields on some patches more frequent. for example I want to write a field each 10 timesteps, but other fields each 1000 timesteps. so using sample utility wont help(if I'm correct)
I wonder if I could write a filed on a patch simply by "variableField.boundaryField()[sourcePatchID].write();" but fvPatch doesn't have write function!
anyway I will take a look at the source files of sample utility and try to find a good solution.
thanks,
mohammad
There is a surfaces-functionObject that allows you to write sampledSurfaces (which means also patches) at arbitrary intervalls. You can have one FO for the fields you want every 1000 timesteps and one for every 10 timesteps
gschaider is offline   Reply With Quote

Old   September 5, 2016, 09:06
Default
  #11
hfs
Member
 
Join Date: Jul 2012
Posts: 66
Rep Power: 14
hfs is on a distinguished road
Quote:
Originally Posted by gschaider View Post
There is a surfaces-functionObject that allows you to write sampledSurfaces (which means also patches) at arbitrary intervalls. You can have one FO for the fields you want every 1000 timesteps and one for every 10 timesteps

The idea is to write only specific fields on specific patches in the run time.
Is there a sample tool that is a run-time tool?
hfs is offline   Reply With Quote

Old   September 5, 2016, 09:07
Default
  #12
hfs
Member
 
Join Date: Jul 2012
Posts: 66
Rep Power: 14
hfs is on a distinguished road
Quote:
Originally Posted by m2montazari View Post
hi all,
thanks for your your replies. I had tried the way bjorn said and the problem was that it writes all cells value(as bjorns mentioned, too). bernhard suggested to use sample utility; but if I'm correct, sample utility is a post-processing utility and uses written fields to sample them in specified points, lines or surfaces. but as I said, I want to write some fields on some patches more frequent. for example I want to write a field each 10 timesteps, but other fields each 1000 timesteps. so using sample utility wont help(if I'm correct)
I wonder if I could write a filed on a patch simply by "variableField.boundaryField()[sourcePatchID].write();" but fvPatch doesn't have write function!
anyway I will take a look at the source files of sample utility and try to find a good solution.
thanks,
mohammad


Hello Mohammad,

Have you found a solution to this. I have a hard-drive limitation and I am looking for a solution.

Thanks,
hfs is offline   Reply With Quote

Old   September 5, 2016, 15:11
Default
  #13
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 hfs View Post
The idea is to write only specific fields on specific patches in the run time.
Is there a sample tool that is a run-time tool?
There is a sampledSurface type patch that does exactly this. Which is usable from either the sample-utility or the function object
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   September 6, 2016, 06:26
Default
  #14
hfs
Member
 
Join Date: Jul 2012
Posts: 66
Rep Power: 14
hfs is on a distinguished road
Quote:
Originally Posted by gschaider View Post
There is a sampledSurface type patch that does exactly this. Which is usable from either the sample-utility or the function object
Hey Bernhard!

Thank you very much for the quick reply!
This sounds like the perfect solution. I do not know exactly how to go about it though. I am doing an air flow simulation. The used mesh is realized using snappyHexMesh. Shall I change the patch type of the obstacle from "wall" to sampledSurface in constant/polyMesh/boundary? If true, how/what to add the to the function object part in controlDict to make it write out the needed filed "p" each timeStep only on that patch?

BTW, would the patch still act like a wall, with wallFunctions etc? or shall I make two patches from the STL file; one as a wall and another as a sampledSurface?


I tried to search "sampledSurface function object", but lead me no where. Would appreciate your further guidance.

Thank you again,
Hosam
hfs is offline   Reply With Quote

Old   September 6, 2016, 09:52
Default
  #15
New Member
 
Ehsan Mahravan
Join Date: Dec 2014
Location: Tehran, Iran
Posts: 9
Rep Power: 12
EhsanMh is on a distinguished road
Quote:
Originally Posted by hfs View Post
Hey Bernhard!

Thank you very much for the quick reply!
This sounds like the perfect solution. I do not know exactly how to go about it though. I am doing an air flow simulation. The used mesh is realized using snappyHexMesh. Shall I change the patch type of the obstacle from "wall" to sampledSurface in constant/polyMesh/boundary? If true, how/what to add the to the function object part in controlDict to make it write out the needed filed "p" each timeStep only on that patch?

BTW, would the patch still act like a wall, with wallFunctions etc? or shall I make two patches from the STL file; one as a wall and another as a sampledSurface?


I tried to search "sampledSurface function object", but lead me no where. Would appreciate your further guidance.

Thank you again,
Hosam
Hi Hosam

In OF4 you can run post utilities at run time, for an example see

incompressible/pimpleDyMFoam/propeller

Last edited by EhsanMh; September 6, 2016 at 23:57.
EhsanMh is offline   Reply With Quote

Old   September 6, 2016, 09:57
Default
  #16
hfs
Member
 
Join Date: Jul 2012
Posts: 66
Rep Power: 14
hfs is on a distinguished road
Quote:
Originally Posted by EhsanMh View Post
Hi Hosam

In OF4 you can run post utilities at run time, for an example of what Bernhard said, see

incompressible/pimpleDyMFoam/propeller

Thanks! I will download OF4 and try that out. Hope it works
hfs is offline   Reply With Quote

Reply

Tags
sampling, write


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
[Commercial meshers] Using starToFoam clo OpenFOAM Meshing & Mesh Conversion 33 September 26, 2012 05:04
[blockMesh] Cyclic BC's: Possible face ordering problem? (Channel flow) sega OpenFOAM Meshing & Mesh Conversion 3 September 28, 2010 13:46
mapFields : internal edges Gearb0x OpenFOAM Running, Solving & CFD 3 April 19, 2010 10:02
Problem with rhoSimpleFoam matteo_gautero OpenFOAM Running, Solving & CFD 0 February 28, 2008 07:51
Boundary condition vector field gradient from two sides of patch face quba OpenFOAM 0 December 12, 2007 06:26


All times are GMT -4. The time now is 16:17.