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

How to write output only for cellset and not entire domain!

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 26, 2020, 10:03
Exclamation How to write output only for cellset and not entire domain!
  #1
Member
 
Tom Waits
Join Date: Aug 2018
Posts: 38
Rep Power: 7
TomWaits is on a distinguished road
I have the following code in my fvOptions to write "USource" to a file. This works, however it writes "USource" for every cell in my domain, which is very slow. I am only interested in writing "USource" for the CellSet I define in topoSetDict. Could someone please help with a way to do this?

Code:
    
    if (mesh_.time().outputTime())
    {   
        volVectorField momentumSourceField
        (
            IOobject
            (
                "momentumSourceField",
                mesh_.time().timeName(),
                mesh_,
                IOobject::NO_READ,
                IOobject::AUTO_WRITE
            ),
            mesh_,
            vector::zero
        );        
        forAll(cells, i)
        {
            momentumSourceField[cells[i]] = Usource[cells[i]];
            momentumSourceField.write();
        }
Many thanks in advance,

Tom Waits
TomWaits is offline   Reply With Quote

Old   August 26, 2020, 10:10
Default
  #2
Senior Member
 
zhangyan's Avatar
 
Yan Zhang
Join Date: May 2014
Posts: 120
Rep Power: 11
zhangyan is on a distinguished road
Are you looking for this?
https://github.com/StachuraMichal/Op...sampleCellZone
__________________
https://openfoam.top
zhangyan is offline   Reply With Quote

Old   August 26, 2020, 10:28
Default
  #3
Member
 
Tom Waits
Join Date: Aug 2018
Posts: 38
Rep Power: 7
TomWaits is on a distinguished road
Quote:
Originally Posted by zhangyan View Post
Thank you for your response. I do not think so (although I am new to OpenFoam so I am unsure). "USource" is not a velocity or pressure that I am sampling in post, it is a variable that is calculated during fvOptions (see actuationDiskSourceTemplates.C in the source code).

I was hoping for a minor modification to the code I posted to loop over the cells defined in toposet as opposed to the entire grid.

As an aside, when I try to compile the code you sent, I get the following error:
Code:
cellZoneSet/cellZoneSet.C:139:20: error: ‘const class Foam::dictionary’ has no member named ‘get’; did you mean ‘set’?
     zoneName_(dict.get<word>("cellZone"))
                    ^~~
                    set
cellZoneSet/cellZoneSet.C:139:28: error: expected primary-expression before ‘>’ token
     zoneName_(dict.get<word>("cellZone"))
Any ideas as to why?

Regards,

Tom Waits
TomWaits is offline   Reply With Quote

Reply


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



All times are GMT -4. The time now is 08:19.