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

How to put an already-obtained velocity distribution as initial condition???

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 23, 2016, 12:19
Default How to put an already-obtained velocity distribution as initial condition???
  #1
Member
 
Sheikh Ahmed
Join Date: Dec 2015
Location: South Carolina, USA
Posts: 88
Rep Power: 7
sahmed is on a distinguished road
Hello Foamers
I need your suggestion regarding a very interesting and useful topic. Suppose I got a fully-developed velocity profile from a pipe flow solution (U Vs. Z) and I want to implement it to another problem as an initial velocity field. This might save some of the computational time since the solver is already dealing with a good solution.
Did anyone use this type of condition in any of your simulations?? ANY type of suggestion is highly appreciated.
sahmed is offline   Reply With Quote

Old   June 23, 2016, 15:44
Default
  #2
Member
 
Sheikh Ahmed
Join Date: Dec 2015
Location: South Carolina, USA
Posts: 88
Rep Power: 7
sahmed is on a distinguished road
Anybody please give me some hints from your experience how to add my own initial conditions to a problem, say an initial temperature profile or an initial velocity profile
sahmed is offline   Reply With Quote

Old   June 23, 2016, 16:06
Default
  #3
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 36
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
User Guide, chapter 2.1.5.3. In fact whole section 2.1.5 could be useful - http://cfd.direct/openfoam/user-guid...#x5-170002.1.5.
alexeym is offline   Reply With Quote

Old   June 23, 2016, 16:20
Default
  #4
Member
 
Sheikh Ahmed
Join Date: Dec 2015
Location: South Carolina, USA
Posts: 88
Rep Power: 7
sahmed is on a distinguished road
Thanks Alexey. I was thinking of using somehow the setFields utility to specify a user-defined initial velocity of temperature profile. This might be the easiest option if I can do that.
Not necessarily that I have to merge the older one with the new one as you mentioned. Suppose that I have any profile and I want to use it as my initial condition instead of a fixed value.

PLEASE help me if you have any idea.
sahmed is offline   Reply With Quote

Old   June 23, 2016, 16:36
Default
  #5
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 36
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Well, you can use setFields, you can use codeStream as internalField (if you know OpenFOAM's C++), you can use so called funkySetFields (according to forum it can be used for the case you have described, yet I have never used it myself). Below is an example of codeStream as internalField for velocity:

Code:
FoamFile
{
    version     2.0;
    format      ascii;
    class       volVectorField;
    object      U;
}

dimensions      [0 1 -1 0 0 0 0];

internalField   #codeStream
{
    codeInclude
    #{
        #include "fvCFD.H"
        #include "vectorField.H"
    #};

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

    code
    #{
        const IOdictionary& d = static_cast<const IOdictionary&>(dict);
        const fvMesh& mesh = refCast<const fvMesh>(d.db());
        vectorField U(mesh.nCells());
        const vector C = vector(0.05, 0.05, 0.005);
        forAll(U, i)
        {
            const vector& Ci = mesh.C()[i];
            const vector R = Ci - C;
            U[i] = R ^ Ci;
        }
        U.writeEntry("", os);
    #};
};
...
[your boundary conditions]
Since your description of the problem is rather vague, there are plenty of possibilities. "Any profile" proposes random solution.
alexeym is offline   Reply With Quote

Old   September 5, 2019, 12:18
Default
  #6
Senior Member
 
Alejandro
Join Date: Jan 2014
Location: Argentina
Posts: 119
Rep Power: 9
ancolli is on a distinguished road
Quote:
Originally Posted by alexeym View Post
Well, you can use setFields, you can use codeStream as internalField (if you know OpenFOAM's C++), you can use so called funkySetFields (according to forum it can be used for the case you have described, yet I have never used it myself). Below is an example of codeStream as internalField for velocity:

Code:
FoamFile
{
    version     2.0;
    format      ascii;
    class       volVectorField;
    object      U;
}

dimensions      [0 1 -1 0 0 0 0];

internalField   #codeStream
{
    codeInclude
    #{
        #include "fvCFD.H"
        #include "vectorField.H"
    #};

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

    code
    #{
        const IOdictionary& d = static_cast<const IOdictionary&>(dict);
        const fvMesh& mesh = refCast<const fvMesh>(d.db());
        vectorField U(mesh.nCells());
        const vector C = vector(0.05, 0.05, 0.005);
        forAll(U, i)
        {
            const vector& Ci = mesh.C()[i];
            const vector R = Ci - C;
            U[i] = R ^ Ci;
        }
        U.writeEntry("", os);
    #};
};
...
[your boundary conditions]
Since your description of the problem is rather vague, there are plenty of possibilities. "Any profile" proposes random solution.
I am having the following Error in OpenFOAM-dev

Code:
error: ‘Foam::vectorField {aka class Foam::Field<Foam::Vector<double> >}’ has no member named ‘writeEntry’
/opt/openfoam-dev/wmake/rules/General/transform:25: recipe for target 'Make/linux64GccDPInt32Opt/codeStreamTemplate.o' failed
make: *** [Make/linux64GccDPInt32Opt/codeStreamTemplate.o] Error 1
however, in OpenFOAM-6 is working well.
ancolli is offline   Reply With Quote

Old   September 6, 2019, 07:16
Default
  #7
Senior Member
 
Carlo_P
Join Date: May 2019
Location: Italy
Posts: 176
Rep Power: 5
Carlo_P is on a distinguished road
A very simplem method can be copy and paste the value in the oldSim/U to the nuew 0/U.


If the mesh is different, you can easily apply a mesh conversion
Carlo_P is offline   Reply With Quote

Reply

Tags
fully developed flow, initial velocity field, velocity profile

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Compressor Simulation using rhoPimpleDyMFoam Jetfire OpenFOAM Running, Solving & CFD 107 December 9, 2014 13:38
pimpleFoam: turbulence->correct(); is not executed when using residualControl hfs OpenFOAM Running, Solving & CFD 3 October 29, 2013 08:35
SLTS+rhoPisoFoam: what is rDeltaT??? nileshjrane OpenFOAM Running, Solving & CFD 4 February 25, 2013 04:13
Error while running rhoPisoFoam.. nileshjrane OpenFOAM Running, Solving & CFD 8 August 26, 2010 12:50
Differences between serial and parallel runs carsten OpenFOAM Bugs 11 September 12, 2008 11:16


All times are GMT -4. The time now is 05:24.