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

Writing/output of simple data into an ASCII-File

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

Like Tree23Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 3, 2016, 18:27
Default
  #21
New Member
 
Join Date: Jul 2014
Posts: 26
Rep Power: 11
Minisasi is on a distinguished road
Hello,
What I'd like to do is something a bit different.

I am implementing a new BC which is used by a certain volScalarField A.
This newBC calculates the values on the same patch of another volScalarField named B.
The B field is recalled inside the BC as

Code:
volScalarField B = this->db().lookupObject<volScalarField>("B");    
   fvPatchScalarField  Bs = B.boundaryField()[patchIndex];
Then (still inside the BC)
Code:
forAll (something, j) 
{
Bs[j]= .....bla bla bla
}
Both A and B are initialized in the createFields.H as:

Code:
volScalarField A
    (
        IOobject
        (
            "A",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ_IF_MODIFIED,
            IOobject::AUTO_WRITE
        ),
        mesh,
        dimensionedScalar("A",dimensionSet(1, 2, -3, 0, 0, -1, 0),0)
    );
My problem is that I don't know exactly how to extract the values of Bs and write them at each time step as BC for B. In the last section of my BC
Code:
void Foam::newBC::write(Ostream& os) const
I tried something like
Code:
writeEntry("Bs", os);
but of course it writes those values inside the patch of A where the BC is used.

Shall I have to code a different BC for B? If so how do I store those Bs value from my newBC of A? (because write now as soon as I get out of the newBC they are removed)
Any ideas?

(sorry for being messy)
Thx
Minisasi is offline   Reply With Quote

Old   May 4, 2016, 02:58
Default
  #22
Member
 
Vignesh
Join Date: Oct 2012
Location: Darmstadt, Germany
Posts: 66
Rep Power: 13
vigneshTG is on a distinguished road
Hi Minisasi,

Can you try something like this ?

Code:
    if (dimensionedInternalField().mesh().time().outputTime())
    {
       B.write();
    }
Hope it helps !!
__________________
Thanks and Regards

Vignesh
vigneshTG is offline   Reply With Quote

Old   May 4, 2016, 10:42
Default
  #23
New Member
 
Join Date: Jul 2014
Posts: 26
Rep Power: 11
Minisasi is on a distinguished road
Hi,

Thank you for your reply, but unfortunately it didn't work.

I tried to follow what they previously wrote couple of posts ago, and I wrote inside my newBC (for A)
Code:
fileName testFile("TEST.txt");
OFstream os(db().time().constant()/testFile);
os << "This is the first line in the file.\n";
os << B.boundaryField()[patchIndex].size();
os << endl

 forAll (something, j)
{
Bs[j]...... bla bla bla;
    os<< Bs[j];
    os << endl;
}
This kinda work, in the sense that it writes out in the /constant folder a .txt file with all the Bs values I wanted. The point is that I need those values inside the B boundary file.

Any hints?
joshwilliams likes this.
Minisasi is offline   Reply With Quote

Old   August 19, 2017, 17:00
Default increasing writing precision
  #24
Member
 
Reza khodadadi
Join Date: Apr 2011
Location: https://t.me/pump_upp
Posts: 32
Rep Power: 15
reza_65 is on a distinguished road
Send a message via ICQ to reza_65 Send a message via AIM to reza_65 Send a message via Yahoo to reza_65
Dear Former,

In my OpenFOAM code, I defined a variable to trace my flame front position. So, in my log file the x position of that variable will be reported (component (0)). It works fine, but my problem is I can not increase the writing precision of this value! For example, in my running log file, I have Time = 0.000000240, max flametip = 71.9713, but I want my flametip have more accuracy!
I will apperaciate any suggestion and help.
To bear in mind, in my control dict, I put writePrecision 9; , timePrecision 9; and writeFormat ascii;

Best Regards,
Reza
reza_65 is offline   Reply With Quote

Old   January 8, 2019, 13:28
Default
  #25
Senior Member
 
Join Date: Sep 2013
Posts: 353
Rep Power: 20
Bloerb will become famous soon enough
...........................
Hamed1117 likes this.
Bloerb is offline   Reply With Quote

Reply

Tags
output data, output to file, write data, write to file

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
Installation of OpenFOAM-1.6 on Ubuntu 9.10 marval OpenFOAM Installation 2 March 17, 2010 08:33
Problem installing on Ubuntu 9.10 -> 'Cannot open : No such file or directory' mfiandor OpenFOAM Installation 2 January 25, 2010 09:50
[OpenFOAM] ParaView 33 canbt open OpenFoam file hariya03 ParaView 7 September 25, 2008 17:33
[OpenFOAM] Paraview command not found hardy ParaView 7 September 18, 2008 04:59
DecomposePar links against liblamso0 with OpenMPI jens_klostermann OpenFOAM Bugs 11 June 28, 2007 17:51


All times are GMT -4. The time now is 18:56.