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

[PyFoam] Writing a data in the OpenFoam Case

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 5, 2017, 21:29
Default Writing a data in the OpenFoam Case
  #1
Senior Member
 
Himanshu Sharma
Join Date: Jul 2012
Posts: 101
Rep Power: 13
himanshu28 is on a distinguished road
Hi,

I am trying to achieve following using PyFoam. I know it can be done in a very trivial way, but not sure how to go about it.

I have a data(scalarField(Numpy array)), I want to write it as a initial condition of a Passive scalar at a given time-step. Here is how I implemented it using PyFoam.
Code:
fname= loc+"T";
f = ParsedParameterFile(fname)
    for j in range(0,len(data)):
        f["internalField"][j] = data[j];
    f.writeFile()
But the bottleneck of this implementation is that the T should have a nonuniform<list> in it so that each entry in that list can be replaced by my data.
Following is I want, I want to use the a general T file of following format
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.4.0                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0; 
    format      ascii;
    class       volScalarField;
    location    "0"; 
    object      T;   
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //  

dimensions      [0 0 0 1 0 0 0]; 

internalField   uniform 0;


boundaryField
{
    inlet
    {    
        type            zeroGradient;
    }    
    outlet
    {    
        type            zeroGradient;
    }    
    wall.ceiling
    {    
        type            zeroGradient;
    }    
 wall.1
    {
        type            zeroGradient;
    }
    wall.3
    {
        type            zeroGradient;
    }
    emptyZ
    {
        type            empty;
    }
}
and replace the uniform to the non-uniform list of my data. I don't know how to go about it. I looked into various *.py files like PyFoam.RunDictionary.SolutionFile import SolutionFile
and some other too but couldn't accomplish, I am not able to get any detail documentations of using these functions.Any guidance will be really helpful.

Edit:
In simple words I would like to write the data in the openFoam format using the case file as a template.

@gschaider any suggestions...


Regards

Last edited by himanshu28; April 6, 2017 at 12:27.
himanshu28 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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Other] Contribution a new utility: refine wall layer mesh based on yPlus field lakeat OpenFOAM Community Contributions 58 December 23, 2021 02:36
Map of the OpenFOAM Forum - Understanding where to post your questions! wyldckat OpenFOAM 10 September 2, 2021 05:29
[snappyHexMesh] crash sHM H25E OpenFOAM Meshing & Mesh Conversion 11 November 10, 2014 11:27
[Commercial meshers] fluentMeshToFoam multidomain mesh conversion problem Attesz OpenFOAM Meshing & Mesh Conversion 12 May 2, 2013 10:52
Need help to open an OpenFoam case with Paraviw aaurouss OpenFOAM 2 July 6, 2009 13:18


All times are GMT -4. The time now is 06:10.