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

Saving data from codedMixed BC

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 1 Post By rol97
  • 1 Post By crubio.abujas
  • 1 Post By trailer

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 17, 2021, 07:38
Default Saving data from codedMixed BC
  #1
New Member
 
Raoul
Join Date: Apr 2021
Posts: 16
Rep Power: 5
rol97 is on a distinguished road
Hi everyone,
I am dealing with codedMixed BC and I need to check the value of the variables that are used within the calculation. I wanted to save the values to post-process them and check if the bc are calculated in the correct way. I do not care how they are saved, as long as I am able to access them.
However I am not managing to store such information, I have tried with ofstream inside the bc code, to save the variables as a CSV, but it does not work.

Any advice?
trailer likes this.
rol97 is offline   Reply With Quote

Old   July 19, 2021, 16:30
Default
  #2
Senior Member
 
Carlos Rubio Abujas
Join Date: Jan 2018
Location: Spain
Posts: 127
Rep Power: 9
crubio.abujas is on a distinguished road
I think that the problem may be that you're executing the code when correcting the boundary condition insted of when you're writting. It would be interesting to see the code though.

If you want to have better control to when is the information written you may try a codedFunctionObject instead.

Code:
coded
{
    libs            ("libutilityFunctionObjects.so");
    type            coded;
    name            codedFunction;

    codeWrite
    #{
        word timeName(mesh().time().timeName());
        fileName outputFile (timeName/"mimimi");
        OFstream os(outputFile);

        const scalarField& V = mesh().V();
        const volVectorField& C = mesh().C();

        label patchID = mesh().boundaryMesh().findPatchID("outlet");
        const volVectorField& U = mesh().lookupObject<volVectorField>("U");
        const vectorField& patch = C.boundaryField()[patchID];
        const vectorField& Upatch = U.boundaryField()[patchID];
        
        os  << "# This is the header of the CSV" << nl
            << "# X , Y, Z, UX, UY, UZ" << nl;
        forAll(patch, facei)
        {
            os << patch[facei].x() << "," 
               << patch[facei].y() << "," 
               << patch[facei].z() << "," 
               << Upatch[facei][0] << ","
               << Upatch[facei][1] << ","
               << Upatch[facei][2] << nl ;
        }
        os << endl;
    #};
}
I've tried this function on OF7 and worked fine. There you can identify the field/patch of interest and write the information.

An alternative may be to write a custom boundary condition and modify the write() method in there.

Give it a try and let's hope it works for you as well.
rol97 likes this.
crubio.abujas is offline   Reply With Quote

Old   July 19, 2021, 17:47
Default
  #3
Member
 
Join Date: Mar 2021
Posts: 39
Rep Power: 5
trailer is on a distinguished road
Quote:
Originally Posted by rol97 View Post
Hi everyone,
I am dealing with codedMixed BC and I need to check the value of the variables that are used within the calculation. I wanted to save the values to post-process them and check if the bc are calculated in the correct way. I do not care how they are saved, as long as I am able to access them.
However I am not managing to store such information, I have tried with ofstream inside the bc code, to save the variables as a CSV, but it does not work.

Any advice?

Will this be useful? https://www.openfoam.com/documentati...bcs-mixed.html

Code:
    "(Patch1|Patch2)"
    {                                                                   
       type            codedMixed;                 
       refValue        uniform 0;                 
       refGradient     uniform 0;                 
       valueFraction   uniform 0;                  
                                                   
       name        test;                             
                                                   
       code                                        
       #{                                
                                                                                  
           forAll(this->patch(), faceI)            
           {                                       
               CodeGoes in here
           } 

          Info << (this->refValue()*this->valueFraction() ) + (1-this->valueFraction())*(this->patchInternalField() + this->refGrad()/this->patch().deltaCoeffs()) << endl;
        #}; 
    }
rol97 likes this.
trailer is offline   Reply With Quote

Reply

Tags
codedmixed, storing data


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
[General] Extracting ParaView Data into Python Arrays Jeffzda ParaView 30 November 6, 2023 22:00
Run OpenFoam in 2 nodes of a cluster WhiteW OpenFOAM Running, Solving & CFD 16 December 20, 2016 01:51
Fuse Mesh Zone not Saving / Reopening in Case and data jagpreetw FLUENT 0 July 27, 2015 03:59
[Commercial meshers] fluentMeshToFoam multidomain mesh conversion problem Attesz OpenFOAM Meshing & Mesh Conversion 12 May 2, 2013 11:52
Urgent : Saving the plot data to a file ck1973 FLUENT 1 July 14, 2006 08:44


All times are GMT -4. The time now is 13:55.