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

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

 June 23, 2016, 12:19 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: 10 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.

 June 23, 2016, 15:44 #2 Member   Sheikh Ahmed Join Date: Dec 2015 Location: South Carolina, USA Posts: 88 Rep Power: 10 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

 June 23, 2016, 16:06 #3 Senior Member   Alexey Matveichev Join Date: Aug 2011 Location: Nancy, France Posts: 1,938 Rep Power: 38 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.

 June 23, 2016, 16:20 #4 Member   Sheikh Ahmed Join Date: Dec 2015 Location: South Carolina, USA Posts: 88 Rep Power: 10 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.

 June 23, 2016, 16:36 #5 Senior Member   Alexey Matveichev Join Date: Aug 2011 Location: Nancy, France Posts: 1,938 Rep Power: 38 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(dict); const fvMesh& mesh = refCast(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.

September 5, 2019, 12:18
#6
Senior Member

Alejandro
Join Date: Jan 2014
Location: Argentina
Posts: 128
Rep Power: 12
Quote:
 Originally Posted by 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(dict); const fvMesh& mesh = refCast(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.

 September 6, 2019, 07:16 #7 Senior Member   Carlo_P Join Date: May 2019 Location: Italy Posts: 176 Rep Power: 8 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