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

[swak4Foam] Illegible characters when set initial field using funkySetFields

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By duguyoudi

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 7, 2019, 03:33
Default Illegible characters when set initial field using funkySetFields
  #1
New Member
 
Join Date: May 2013
Posts: 29
Rep Power: 12
duguyoudi is on a distinguished road
Hi everyone,


I met a problem when I try to set the initial field using funkySetFields. I am sorry that I can't upload the file since it's too big. Please see the screenshot I uploaded. The mesh was generated by snappyHexMesh with 5.3 million cells. The expression I used is



Code:
expressions
(
  u0
  {
     field U;
     expression "vector(3.824*pow((pos().z/0.08),0.28),0,0)";
  }
);

I tested to initialize the background mesh generated by blockMesh (0.16 m cells). Everything is fine.



Anyone knows how to solve this problem?


Leo
Attached Images
File Type: jpg Screenshot from 2019-08-07 15-20-12.jpg (191.9 KB, 4 views)
duguyoudi is offline   Reply With Quote

Old   August 8, 2019, 03:22
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by duguyoudi View Post
Hi everyone,


I met a problem when I try to set the initial field using funkySetFields. I am sorry that I can't upload the file since it's too big. Please see the screenshot I uploaded. The mesh was generated by snappyHexMesh with 5.3 million cells. The expression I used is



Code:
expressions
(
  u0
  {
     field U;
     expression "vector(3.824*pow((pos().z/0.08),0.28),0,0)";
  }
);
I tested to initialize the background mesh generated by blockMesh (0.16 m cells). Everything is fine.



Anyone knows how to solve this problem?


Leo

The "problem" is that this is a binary file (see header and your controlDict). These are supposed to look like this
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   August 12, 2019, 05:26
Default
  #3
New Member
 
Join Date: May 2013
Posts: 29
Rep Power: 12
duguyoudi is on a distinguished road
Hi Gschaider,


Thank you for your reply.


I have checked the header of funkySetFieldsDict and controlDict. Both files are ascii. I am not sure if funkySetFields converts ascii file to binary file if the size of the file is big. I find that the boundary conditions in the same file ./0/U are ascii format. Does the inconsistent data format lead to openFoam failing to read the initial field?


Best,


Leo.


For someone who is interested in non-uniform initial field, the following code may be helpful.


internalField #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);
const fvMesh& mesh = refCast<const fvMesh>(d.db());
vectorField U(mesh.nCells(), vector(0, 0, 0));

forAll(U, i)
{
const scalar z = mesh.C()[i][2];
const scalar Uref=3.824;
const scalar zref=0.08;
const scalar alpha=0.28;
U[i] = vector(Uref*pow(z/zref,alpha), 0.0, 0.0);
}

U.writeEntry("", os);
#};

};
duguyoudi is offline   Reply With Quote

Old   August 12, 2019, 06:25
Default
  #4
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
According to your screenshot it is a binary file. funkySetFields does not change that setting. It is irrelevant what the headers of those files say. Important is the setting writeFormat in your controlDict. That seems to have been binary at the time funkySetFields was run (maybe you changed it later)



Quote:
Originally Posted by duguyoudi View Post
Hi Gschaider,


Thank you for your reply.


I have checked the header of funkySetFieldsDict and controlDict. Both files are ascii. I am not sure if funkySetFields converts ascii file to binary file if the size of the file is big. I find that the boundary conditions in the same file ./0/U are ascii format. Does the inconsistent data format lead to openFoam failing to read the initial field?


Best,


Leo.


For someone who is interested in non-uniform initial field, the following code may be helpful.


internalField #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);
const fvMesh& mesh = refCast<const fvMesh>(d.db());
vectorField U(mesh.nCells(), vector(0, 0, 0));

forAll(U, i)
{
const scalar z = mesh.C()[i][2];
const scalar Uref=3.824;
const scalar zref=0.08;
const scalar alpha=0.28;
U[i] = vector(Uref*pow(z/zref,alpha), 0.0, 0.0);
}

U.writeEntry("", os);
#};

};
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   August 12, 2019, 21:38
Default
  #5
New Member
 
Join Date: May 2013
Posts: 29
Rep Power: 12
duguyoudi is on a distinguished road
Hi Gschaider,


Thank you for your help.



It's my mistake. I thought the writeFormat only controlling output format of openfoam solvers.

Leo
gschaider likes this.
duguyoudi 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
[mesh manipulation] Importing Multiple Meshes thomasnwalshiii OpenFOAM Meshing & Mesh Conversion 18 December 19, 2015 18:57
Floating point exception error lpz_michele OpenFOAM Running, Solving & CFD 53 October 19, 2015 02:50
Micro Scale Pore, icoFoam gooya_kabir OpenFOAM Running, Solving & CFD 2 November 2, 2013 13:58
Orifice Plate with a fully developed flow - Problems with convergence jonmec OpenFOAM Running, Solving & CFD 3 July 28, 2011 05:24


All times are GMT -4. The time now is 07:13.