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

[swak4Foam] Using lookuptables in momentumSourceDict with swak4Foam

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 10, 2013, 12:43
Default
  #21
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 alighaffari View Post
Hello Bernhard
Do you have any tutorial or example that teach me how to define a source term from solving a PDE and how to apply it to interFoam solver. If could kindly send me any example related to this field it will be very helpful for me.
Regards
Ali Ghaffari
There isn't a ready-made example for this (and I can't guarantee that it will work for you): examples for using the PDF-functionObjects are (amongst others) in Examples/groovyBC/pulsedPitzDaily. The solution field can then be used like any other field in the expressions of the source term
__________________
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   October 27, 2013, 10:07
Default Create a new field from an expression
  #22
Member
 
alighaffari
Join Date: May 2011
Posts: 31
Rep Power: 14
alighaffari is on a distinguished road
Hi Dear Bernhard
thanks for your posts, replies and "swak4Foam". I could solve a PDE using "solveLaplacianPDE" function But I have another question on the "expessionField" function. I am trying to create and calculate a new transformed velocity field using this function. I followed ,for starting, the example available in slides on swak4Foam (No C++, please. We’re users!, Bernhard F.W. Gschaider, June 2011, slide number 61/176):
---------------------------------------------------------------------------------------------------------------------------------
libs (
" libswakFunctionObjects .so"
);
functions (
liquidVel
{
type expressionField;
outputControl outputTime;
//outputInterval 1;

fieldName Uliquid;
expression "U*alpha1";
autowrite true
}
) ;
---------------------------------------------------------------------------------------------------------------------------------------

but it does not work and OpenFoam gives the following error:

---------------------------------------------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.1.x |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
Build : 2.1.x-0cbac23c1af5
Exec : interFoamWithSources
Date : Oct 27 2013
Time : 17:53:21
Host : "ali-pc"
PID : 2918
Case : /home/ali/OpenFOAM/ali-2.1.x/run/Afkhami2008/cylinder-radius0.2-sourceterm-PDE
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Disallowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0


PIMPLE: Operating solver in PISO mode

Reading field p_rgh

Reading field alpha1

Reading field U

Reading/calculating face flux field phi

Reading transportProperties

Selecting incompressible transport model Newtonian
Selecting incompressible transport model Newtonian
Selecting turbulence model type laminar

Reading g
Calculating field g.h

time step continuity errors : sum local = 0, global = 0, cumulative = 0
DICPCG: Solving for pcorr, Initial residual = 0, Final residual = 0, No Iterations 0
time step continuity errors : sum local = 0, global = 0, cumulative = 0
Courant Number mean: 0 max: 0

Starting time loop



--> FOAM FATAL IO ERROR:
attempt to read beyond EOF

file: /home/ali/OpenFOAM/ali-2.1.x/run/Afkhami2008/cylinder-radius0.2-sourceterm-PDE/system/controlDict::functions at line 88.

From function ITstream::read(token&)
in file db/IOstreams/Tstreams/ITstream.C at line 83.

FOAM exiting
-----------------------------------------------------------------------------------------------------------------------------------
I have created the "Uliquid" file in the "0" folder based on the "U" file. I have no idea on this error message.
I'm Looking forward to some directions. your valuable time is highly appreciated.

thanks,
Ali Ghaffari
alighaffari is offline   Reply With Quote

Old   October 28, 2013, 04:13
Default
  #23
Senior Member
 
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,266
Blog Entries: 1
Rep Power: 24
nimasam is on a distinguished road
you missed semicolon in your expression, it should be like that:
Quote:
expression "U*alpha1;";
__________________
My Personal Website (http://nimasamkhaniani.ir/)
Telegram channel (https://t.me/cfd_foam)
nimasam is offline   Reply With Quote

Old   October 28, 2013, 09:23
Default
  #24
Member
 
alighaffari
Join Date: May 2011
Posts: 31
Rep Power: 14
alighaffari is on a distinguished road
Quote:
Originally Posted by nimasam View Post
you missed semicolon in your expression, it should be like that:
Hi Dear Nima Sam
thanks for your reply. I modified it by semicolon But again exactly the same error message appears. What else may be wrong?
thanks
alighaffari is offline   Reply With Quote

Old   October 28, 2013, 18:25
Default
  #25
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 alighaffari View Post
Hi Dear Nima Sam
thanks for your reply. I modified it by semicolon But again exactly the same error message appears. What else may be wrong?
thanks
Which is line 88 in your controlDict (that is the one that is mentioned in the error message you quoted. I must stress that this message means that your file is syntactically wrong. swak hasn't even seen it yet)

Is it maybe the line "autowrite true" without the semicolon?
__________________
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   October 29, 2013, 09:52
Default
  #26
Member
 
alighaffari
Join Date: May 2011
Posts: 31
Rep Power: 14
alighaffari is on a distinguished road
Hi Dear Bernhard Gschaider
yes it was the reason for error : "autowrite true" without the semicolon. thanks so much.
alighaffari is offline   Reply With Quote

Old   November 4, 2013, 11:07
Default
  #27
Member
 
alighaffari
Join Date: May 2011
Posts: 31
Rep Power: 14
alighaffari is on a distinguished road
Hi Dear Bernhard Gschaider
Its me again with another question. I have calculated the magnitude of the gradient of a scalar field in two ways:
1) by using the "magGrad" from "foamCalc" utility:

foamCalc magGrad distance


2) by defining a new Field in "controldict" file:
functions(
distGrad {
type expressionField;
outputControl timeStep;
outputInterval 1;
fieldName graddistance;
expression "-grad(distance)";
autowrite true;
}
);

and finally I have calculated the magnitude of the new field "graddistance".
("distance" is a new scalar field which is calculated from solving the Laplaces equation via "solveLaplacianPDE" function.)

But the results are very much different (in order of 1000000). It is so strange and confusing for me. Which way is more reliable?
I need the gradient of "distance" in the solution time. Is there any better method for its calculation?

Thank you
Regards
alighaffari is offline   Reply With Quote

Old   November 4, 2013, 11:19
Default
  #28
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 alighaffari View Post
Hi Dear Bernhard Gschaider
Its me again with another question. I have calculated the magnitude of the gradient of a scalar field in two ways:
1) by using the "magGrad" from "foamCalc" utility:

foamCalc magGrad distance


2) by defining a new Field in "controldict" file:
functions(
distGrad {
type expressionField;
outputControl timeStep;
outputInterval 1;
fieldName graddistance;
expression "-grad(distance)";
autowrite true;
}
);

and finally I have calculated the magnitude of the new field "graddistance".
("distance" is a new scalar field which is calculated from solving the Laplaces equation via "solveLaplacianPDE" function.)

But the results are very much different (in order of 1000000). It is so strange and confusing for me. Which way is more reliable?
I need the gradient of "distance" in the solution time. Is there any better method for its calculation?

Thank you
Regards
Could you check WHERE these differences occur? For instance by calculating the diff between the two fields with funkySetFields? My guess is that the difference is in boundary cells
__________________
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   November 5, 2013, 09:05
Default
  #29
Member
 
alighaffari
Join Date: May 2011
Posts: 31
Rep Power: 14
alighaffari is on a distinguished road
Quote:
Originally Posted by gschaider View Post
Could you check WHERE these differences occur? For instance by calculating the diff between the two fields with funkySetFields? My guess is that the difference is in boundary cells
the difference is all over the solution domain. It seems that the results from magGrad function from "foamCalc" are true. But I need the gradient over the solution time. What can I do? Is there any other Method?
alighaffari is offline   Reply With Quote

Old   November 8, 2013, 17:31
Default
  #30
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 alighaffari View Post
the difference is all over the solution domain. It seems that the results from magGrad function from "foamCalc" are true. But I need the gradient over the solution time. What can I do? Is there any other Method?
That's strange. "mag(grad(T))" in swak uses the same functions as magGrad. I think I need to see pictures of the differences to tell what might be the problem
__________________
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   November 9, 2013, 09:18
Default
  #31
Member
 
alighaffari
Join Date: May 2011
Posts: 31
Rep Power: 14
alighaffari is on a distinguished road
Dear Bernhard Gschaider
Thanks for your attention. I could finally find the reason of the differences. It was due to the "writePrecision" in the controlDict file. The differences were existed when the default value ,6, was chosen. But by increasing the "writePrecision" the differences decreased. finally no differences were observed by choosing the "20" for "writePrecision". I think that the "magGrad" function from "foamCalc" reads the data from written results files But the "grad" function from "swak" reads data from RAM. Please correct me if I am wrong?
thanks
Ali
nimasam likes this.
alighaffari is offline   Reply With Quote

Old   November 9, 2013, 19:08
Default
  #32
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 alighaffari View Post
Dear Bernhard Gschaider
Thanks for your attention. I could finally find the reason of the differences. It was due to the "writePrecision" in the controlDict file. The differences were existed when the default value ,6, was chosen. But by increasing the "writePrecision" the differences decreased. finally no differences were observed by choosing the "20" for "writePrecision". I think that the "magGrad" function from "foamCalc" reads the data from written results files But the "grad" function from "swak" reads data from RAM. Please correct me if I am wrong?
thanks
Ali
Depends. funkySetFields reads from disc. But the function Objects use the field from memory.

So that problem solved itself? Fine.
__________________
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

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
InterDyMFoam+simpleFunctionObject Elham OpenFOAM Running, Solving & CFD 5 July 10, 2017 11:59
[swak4Foam] and twoPhaseEulerFoam mnikku OpenFOAM Community Contributions 1 February 19, 2016 05:21
source term in near wall cell rajcfd OpenFOAM Pre-Processing 5 February 1, 2016 10:31
[swak4Foam] Install swak4Foam on OpenFOAM1.7.1 on Ubuntu 13.04 kobayashi OpenFOAM Community Contributions 2 January 5, 2014 17:33
[swak4Foam] fails in parallel with -otherTime? Phicau OpenFOAM Community Contributions 3 June 26, 2013 13:00


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