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

Initial and Boundary Conditions in the .C File

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 28, 2020, 04:56
Default Initial and Boundary Conditions in the .C File
  #1
New Member
 
Mohammad Khojastehmehr
Join Date: Jul 2020
Posts: 19
Rep Power: 5
MCrossover97 is on a distinguished road
Hey everybody Hope you are doing great!

I wanted to write a program in which the initial and boundary conditions for the fields depend on some initial calculations.
At first, I thought it would be a good idea to write a C++ program that reads and edits the files in the 0 the folder; then I figured out it is not that easy; so I came to the conclusion that it might be best to try this method but I'm not quite sure yet:
I decided to define the fields in the main file. Is there any way to create a volVectorField or volScalarField in the .C file with defined boundary and initial condition? For example, I want to have something like this in my .C file:
Code:
/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  7
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       volScalarField;
    object      eps;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 0 0 0 0 0 0];

internalField   nonuniform List<scalar>
10
(
0.154467036866835
0.162033854429180
0.135407628800740
0.165665945521539
0.150504310464983
0.163532375941872
0.134619297472226
0.163464960781439
0.147743669796071
0.146223849079981
);

boundaryField
{
    inlet
    {
        type            zeroGradient;
    }
    outlet
    {
        type            zeroGradient;
    }
    fixedWalls
    {
        type            zeroGradient;
    }
}


// ************************************************************************* //
I would be very appreciative If someone could help me with this!
Mohammad
MCrossover97 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
Suppress twoPhaseEulerFoam energy AlmostSurelyRob OpenFOAM Running, Solving & CFD 33 September 25, 2018 17:45
HeatSource BC to the whole region in chtMultiRegionHeater xsa OpenFOAM Running, Solving & CFD 3 November 7, 2016 05:07
simpleFoam error - "Floating point exception" mbcx4jc2 OpenFOAM Running, Solving & CFD 12 August 4, 2015 02:20
Micro Scale Pore, icoFoam gooya_kabir OpenFOAM Running, Solving & CFD 2 November 2, 2013 13:58
Error finding variable "THERMX" sunilpatil CFX 8 April 26, 2013 07:00


All times are GMT -4. The time now is 12:53.