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

Fields write out

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By Anup Singh

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 5, 2020, 02:48
Default Fields write out
  #1
New Member
 
Jagan Mohan
Join Date: Dec 2019
Location: New York
Posts: 18
Rep Power: 2
jagan1mohan is on a distinguished road
Hello Friends, lets say we have an OpenFOAM setup which is working, converging and producing results. I'm interested in writing out each term of the governing equation as fields, either during run time or after run. That is, lets say, I'm solving ddt(T) - laplacian(gama, T).



1. How to get ddt(T) field for each timestep written out into time folders at all control volume centroids? Ideally, this should go to zero as time proceeds.


2. Also, how to write out laplacian(gama, T) field? I will try to extend it to other equation terms in in-compressible flow.



Thank you,
Jagan Mohan.
jagan1mohan is offline   Reply With Quote

Old   July 5, 2020, 06:26
Default
  #2
New Member
 
Anup Singh
Join Date: Mar 2020
Posts: 9
Rep Power: 2
Anup Singh is on a distinguished road
You can simply store them in a variable and then as your wish you can either print them out or store it in a file for later use.
Anup Singh is offline   Reply With Quote

Old   July 5, 2020, 10:10
Default
  #3
New Member
 
Jagan Mohan
Join Date: Dec 2019
Location: New York
Posts: 18
Rep Power: 2
jagan1mohan is on a distinguished road
Hello Anup, thanks for your reply. Could you elaborate on any one of the terms as an example?


Thank you,
Jagan Mohan.
jagan1mohan is offline   Reply With Quote

Old   July 5, 2020, 10:55
Default
  #4
New Member
 
Anup Singh
Join Date: Mar 2020
Posts: 9
Rep Power: 2
Anup Singh is on a distinguished road
first you can declare a new variable as



volVectorField Tlap or volScalarField Tlap - depending on your field type
(
IOobject
(
"Tlap",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh
);


and then update it as



Tlap = laplacian(gama, T);


This will in the end automatically write the file upon encountering runTime.write(); command. There are several other formats which you can use in one way or other. You can find about different ways for writing the data in the other threads in the fourum.
jagan1mohan likes this.
Anup Singh is offline   Reply With Quote

Old   October 2, 2020, 20:03
Default
  #5
New Member
 
Jagan Mohan
Join Date: Dec 2019
Location: New York
Posts: 18
Rep Power: 2
jagan1mohan is on a distinguished road
Hello Anup, thank you for your reply.



This method works. One problem is we are forced to create text files in 0/ directory for each of the term in the governing equation. For example, here, I have to create Tlap text file similar to T text file.



1. Is there a way where we can circumvent this and still create a field variable inside the solver?


Thank you,
Jagan Mohan.
jagan1mohan is offline   Reply With Quote

Old   October 3, 2020, 03:29
Default
  #6
New Member
 
Anup Singh
Join Date: Mar 2020
Posts: 9
Rep Power: 2
Anup Singh is on a distinguished road
As mentioned you can use different formats..



You can simply initialize your variable when you are creating it..


This eliminates the need read a file in 0 directory as all the conditions are defined as per calculation performed during initialization.


For example in your case..


volVectorField Tlap or volScalarField Tlap - depending on your field type
(
IOobject
(
"Tlap",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
laplacian(gama, T)
);
Anup Singh is offline   Reply With Quote

Old   October 3, 2020, 10:57
Default
  #7
New Member
 
Jagan Mohan
Join Date: Dec 2019
Location: New York
Posts: 18
Rep Power: 2
jagan1mohan is on a distinguished road
Hello Anup, thank you for the quick reply. Perhaps, we have to initialize as fvc::laplacian(gama, T) as the object class is volScalarField and fvc:: returns a geometricField class object.



I tried with fvc::, the code compiles and runs. I'd post-process the results. Ideally, the field should approach zero as iterations progress as I'm solving a steady-state conduction equation.


Thank you,
Jagan Mohan.
jagan1mohan is offline   Reply With Quote

Old   October 4, 2020, 20:44
Default
  #8
New Member
 
Jagan Mohan
Join Date: Dec 2019
Location: New York
Posts: 18
Rep Power: 2
jagan1mohan is on a distinguished road
I tested with fvc::laplacian(gama, T) as initialization to volScalarField variable. It works and field approaches to zero for all the interior cells (but not on the boundary cells, needs further understanding. This value is exceptional high at the corner cells).



Now how to intialize a volVectorField, say velocity of (1i + 1j + 0k) at all the cell centres?



Thank you,
Jagan Mohan.
jagan1mohan is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
CFX-Pre: Write .mdef instead of.def Stroopwafelandcoffee CFX 0 June 15, 2018 13:01
modify pimpleFoam to write sampled fields on a patch each runtime moh-farmani OpenFOAM Programming & Development 0 August 19, 2017 16:17
[mesh manipulation] Importing Multiple Meshes thomasnwalshiii OpenFOAM Meshing & Mesh Conversion 18 December 19, 2015 19:57
several fields modified by single boundary condition schröder OpenFOAM Programming & Development 3 April 21, 2015 06:09
write nut fields in simpleFoam maurice OpenFOAM Running, Solving & CFD 5 March 23, 2009 02:57


All times are GMT -4. The time now is 05:14.