CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   howto write a patch field during the run (http://www.cfd-online.com/Forums/openfoam/98709-howto-write-patch-field-during-run.html)

m2montazari March 16, 2012 16:15

howto write a patch field during the run
 
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 March 18, 2012 03:13

any comments?

no comments?!

m2montazari March 18, 2012 15:53

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

m2montazari March 22, 2012 08:51

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

gschaider March 22, 2012 10:21

Quote:

Originally Posted by m2montazari (Post 350880)
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

winden March 27, 2012 15:29

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

gschaider March 27, 2012 18:44

Quote:

Originally Posted by winden (Post 351806)
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

winden March 28, 2012 06:18

Ah, very clever. I didn't think of that. Thank you!

//Björn

m2montazari March 31, 2012 04:21

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

gschaider March 31, 2012 16:14

Quote:

Originally Posted by m2montazari (Post 352396)
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


All times are GMT -4. The time now is 09:15.