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

Problem in codestream for applying time dependent boundary condition in OF V1906/2112

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 3, 2022, 05:52
Default Problem in codestream for applying time dependent boundary condition in OF V1906/2112
  #1
Senior Member
 
chandra shekhar pant
Join Date: Oct 2010
Posts: 220
Rep Power: 17
chandra shekhar pant is on a distinguished road
Dear Foamers,
For a couple of weeks I am trying to write a time dependent boundary condition for pressure, after looking multiple post in the CFD Online, I found that codeStream boundary condition could do that (also swak4FOAM could do that, but unfortunately I am unable to compile that). This code runs and compiles well with OF v 1906/2112 but it's actually not been able to calculate the time variable, instead it is treating "t" as variable with value 0.
Code:
source
{
type fixedValue;
value #codeStream
{
codeInclude
#{
#include "fvCFD.H"
#};

codeOptions
#{
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
#};

codeLibs
#{
-lmeshTools \
-lfiniteVolume
#};

code
#{
const IOdictionary& d = static_cast<const IOdictionary&>
(
dict.parent().parent()
);
const fvMesh& mesh = refCast<const fvMesh>(d.db());
const label id = mesh.boundary().findPatchID("source");
const fvPatch& patch = mesh.boundary()[id];
scalarField p(patch.size(), scalar(0));

const scalar t = d.db().time().value();
scalar t2 = t-tp*(floor(t/tp)); //
const scalar tp = 0.035;
const scalar tf = 0.0116;
{
forAll(p, i)
{
{
if (t2<tf)
{
p[i] = 1000000.0*t;
}
if (t2>=tf && t2<=tp)
{
p[i] = 1.0*(t-0.01);
}
}
}
}

p.writeEntry("", os);


#};
};

 }

Any comment/suggestion would be a great help, thanks in advance.
chandra shekhar pant is offline   Reply With Quote

Old   July 14, 2022, 04:16
Default
  #2
Senior Member
 
chandra shekhar pant
Join Date: Oct 2010
Posts: 220
Rep Power: 17
chandra shekhar pant is on a distinguished road
I am still struggling with this issue, could any one please help.
chandra shekhar pant is offline   Reply With Quote

Old   July 14, 2022, 09:28
Default
  #3
Senior Member
 
chandra shekhar pant
Join Date: Oct 2010
Posts: 220
Rep Power: 17
chandra shekhar pant is on a distinguished road
Hello again,

After struggling for a very quite long time, finally I managed to get the things working using the instructions given in the link http://www.wolfdynamics.com/wiki/pro...streamINIT.pdf



Previously maybe I was messing up with the initial condition and boundary condition. I have done the following to make it work (could be useful to someone):



Code:
 source
    {
      type             codedFixedValue;
      value             uniform 0;
      name            inletProfile2;
       
    code
    #{

      const fvPatch& boundaryPatch = patch();
        const vectorField& Cf = boundaryPatch.Cf();
        scalarField& p = *this;
        p = patchInternalField();
        scalar t = this->db().time().value();
      const scalar tf = 0.5;
    const scalar tp = 1.0;

  forAll(p, i)
        {
        
        {
            if (t<=tf)
            {
                    p[i] = 1000000.0*t;
                    
                    
            }
            if (t>=tf && t<=tp)
            {
                p[i] = 1.0*(t-0.01);    
                
            }
            
            }   
        
        }
    #}; 
   }
chandra shekhar pant 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
courant number increases to rather large values 6863523 OpenFOAM Running, Solving & CFD 22 July 6, 2023 00:48
Postprocess: sampleDict works but creates no output folder shock77 OpenFOAM Post-Processing 14 November 15, 2021 09:27
Groovy BC : time dependent boundary condition from a data table (timelines) ARC_P&P OpenFOAM 0 July 21, 2021 10:31
Question about adaptive timestepping Guille1811 CFX 25 November 12, 2017 18:38
Problem in setting Boundary Condition Madhatter92 CFX 12 January 12, 2016 05:39


All times are GMT -4. The time now is 01:11.