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

[swak4Foam] Using fieldAverage together with swak4foam expressionField

Register Blogs Community New Posts Updated Threads Search

Like Tree18Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 14, 2016, 04:38
Exclamation problem was generic, a general solution required
  #21
Member
 
a
Join Date: Oct 2014
Posts: 49
Rep Power: 12
cfd@kgp is on a distinguished road
Dear fgarita,

Thanks for your quick reply.

But the problem was generic, I wanted to multiply 32.0 and again divide by the square of temperature.

my full requirement is,

Code:
magSqrGradTinto2
 {  type expressionField;
 outputControl outputTime;
variables (
            "myscalar=32.0;"
            "sqrT=(pow(T,2.0));"
           // "angle=pi/180*(time()<duration ? time()/duration*maxAngle : maxAngle);"
        );
 outputInterval 1;
 fieldName magSqrGradTinto2;
 expression "(magSqr(snGrad(T))) * myscalar / sqrT";
 autowrite true;
 }
and again a similar error,
Quote:
Creating expression field magSqrGradTinto2 ...

--> FOAM FATAL ERROR:
Parser Error for driver FieldValueExpressionDriver at "1.21-28" :"syntax error, unexpected scalarID"
"(magSqr(snGrad(T)))*myscalar/sqrT"
^^^^^^^^
----------------------|

Context of the error:


- Driver constructed from scratch
Evaluating expression "(magSqr(snGrad(T)))*myscalar/sqrT"


From function parsingValue
in file lnInclude/CommonValueExpressionDriverI.H at line 1210.

FOAM exiting
it will be great to here some solution about this.

Thanks and regards.

Last edited by cfd@kgp; December 14, 2016 at 04:43. Reason: addition of error
cfd@kgp is offline   Reply With Quote

Old   December 14, 2016, 06:42
Default
  #22
Senior Member
 
Agustín Villa
Join Date: Apr 2013
Location: Alcorcón
Posts: 314
Rep Power: 15
agustinvo is on a distinguished road
Quote:
Originally Posted by cfd@kgp View Post
Dear fgarita,

Thanks for your quick reply.

But the problem was generic, I wanted to multiply 32.0 and again divide by the square of temperature.

my full requirement is,

Code:
magSqrGradTinto2
 {  type expressionField;
 outputControl outputTime;
variables (
            "myscalar=32.0;"
            "sqrT=(pow(T,2.0));"
           // "angle=pi/180*(time()<duration ? time()/duration*maxAngle : maxAngle);"
        );
 outputInterval 1;
 fieldName magSqrGradTinto2;
 expression "(magSqr(snGrad(T))) * myscalar / sqrT";
 autowrite true;
 }
and again a similar error,


it will be great to here some solution about this.

Thanks and regards.
Hi

I think this error can be related with the way you declare the variables. since you have two lines of declaring variables, try to put after "variables" and the first bracket "(" a "2"
agustinvo is offline   Reply With Quote

Old   December 14, 2016, 08:58
Default
  #23
Member
 
a
Join Date: Oct 2014
Posts: 49
Rep Power: 12
cfd@kgp is on a distinguished road
Quote:
Originally Posted by agustinvo View Post
Hi

I think this error can be related with the way you declare the variables. since you have two lines of declaring variables, try to put after "variables" and the first bracket "(" a "2"
Thanks Agustinvo!

But I could not precisely follow your suggestion "try to put after "variables" and the first bracket "(" a "2""

could you please elaborate?
cfd@kgp is offline   Reply With Quote

Old   December 14, 2016, 09:04
Default
  #24
Senior Member
 
Agustín Villa
Join Date: Apr 2013
Location: Alcorcón
Posts: 314
Rep Power: 15
agustinvo is on a distinguished road
Quote:
Originally Posted by cfd@kgp View Post
Thanks Agustinvo!

But I could not precisely follow your suggestion "try to put after "variables" and the first bracket "(" a "2""

could you please elaborate?
Hi

something like this:

Code:
variables 2 (             "myscalar=32.0;"             "sqrT=(pow(T,2.0));"            // "angle=pi/180*(time()<duration ? time()/duration*maxAngle : maxAngle);"         );
agustinvo is offline   Reply With Quote

Old   December 14, 2016, 09:13
Unhappy
  #25
Member
 
a
Join Date: Oct 2014
Posts: 49
Rep Power: 12
cfd@kgp is on a distinguished road
Quote:
Originally Posted by agustinvo View Post
Hi

something like this:

Code:
variables 2 (             "myscalar=32.0;"             "sqrT=(pow(T,2.0));"            // "angle=pi/180*(time()<duration ? time()/duration*maxAngle : maxAngle);"         );

Thanks Agustinvo!

I tried your suggestion, it does not help. infact in the expression direct operation of multiplication by 2.0 or infact any other number also fails...
cfd@kgp is offline   Reply With Quote

Old   December 14, 2016, 10:11
Default Solved
  #26
Member
 
a
Join Date: Oct 2014
Posts: 49
Rep Power: 12
cfd@kgp is on a distinguished road
As it was pointed out by Bernhard in #7
"grad is not available on patches (simply because OF doesn't have it). snGrad is."

I suggest for internalFields snGrad is not available, and grad work smootly.
cfd@kgp is offline   Reply With Quote

Old   December 15, 2016, 06:00
Default
  #27
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 cfd@kgp View Post
Dear fgarita,

Thanks for your quick reply.

But the problem was generic, I wanted to multiply 32.0 and again divide by the square of temperature.

my full requirement is,

Code:
magSqrGradTinto2
 {  type expressionField;
 outputControl outputTime;
variables (
            "myscalar=32.0;"
            "sqrT=(pow(T,2.0));"
           // "angle=pi/180*(time()<duration ? time()/duration*maxAngle : maxAngle);"
        );
 outputInterval 1;
 fieldName magSqrGradTinto2;
 expression "(magSqr(snGrad(T))) * myscalar / sqrT";
 autowrite true;
 }
and again a similar error,


it will be great to here some solution about this.

Thanks and regards.
The problem is that by default internalField calculates on the cells. And myScalar is therefor a cell-field. snGrad(T) produces a face-field and therefor all subsequent calculations with it are face-values. To combine with a constant value you'll have make that value a face-value. With "interpolate(myscalar/sqrT)".

A bit more about that can be found in the incomplete reference guide with the sources. Look for "native" and "secondary structures" and "Functions that interpolate"
__________________
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   December 15, 2016, 06:35
Smile
  #28
Member
 
a
Join Date: Oct 2014
Posts: 49
Rep Power: 12
cfd@kgp is on a distinguished road
Quote:
Originally Posted by gschaider View Post
The problem is that by default internalField calculates on the cells. And myScalar is therefor a cell-field. snGrad(T) produces a face-field and therefor all subsequent calculations with it are face-values. To combine with a constant value you'll have make that value a face-value. With "interpolate(myscalar/sqrT)".

A bit more about that can be found in the incomplete reference guide with the sources. Look for "native" and "secondary structures" and "Functions that interpolate"

Thanks gschaider! Information shared is certainly useful...

I will try snGrad along with the interpolate function.

One quick question--> grad() operator calculated gradient by which method? --Guass, least square, etc. can we specify it?
cfd@kgp is offline   Reply With Quote

Old   December 15, 2016, 08:20
Default
  #29
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 cfd@kgp View Post
Thanks gschaider! Information shared is certainly useful...

I will try snGrad along with the interpolate function.

One quick question--> grad() operator calculated gradient by which method? --Guass, least square, etc. can we specify it?
swak4Foam just calls fvc::grad(). Which scheme that function uses is determined by system/fvSchemes

If you want to experiment with discretization schemes: there is a Plugin-Function-Library swakFvcSchemesFunctionPlugin that extends the internalField-parser with a number of functions where you can explicitely choose the discretization scheme for grad() and friends
__________________
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   December 15, 2016, 08:31
Talking
  #30
Member
 
a
Join Date: Oct 2014
Posts: 49
Rep Power: 12
cfd@kgp is on a distinguished road
Quote:
Originally Posted by gschaider View Post
swak4Foam just calls fvc::grad(). Which scheme that function uses is determined by system/fvSchemes

If you want to experiment with discretization schemes: there is a Plugin-Function-Library swakFvcSchemesFunctionPlugin that extends the internalField-parser with a number of functions where you can explicitely choose the discretization scheme for grad() and friends
Thanks Bernhard!
cfd@kgp is offline   Reply With Quote

Old   December 15, 2016, 09:24
Default swakExpression cannot accept sum(myfl*vol())
  #31
Member
 
a
Join Date: Oct 2014
Posts: 49
Rep Power: 12
cfd@kgp is on a distinguished road
Dear Bernhard ,

One more swakExpression gives error while run-time,
[CODE
uysqr
{
aliases {
myfl sMS1:alpha1; //
}
type swakExpression;
valueType cellZone;
zoneName solid; // or whatever is your zoneName
accumulations (
min
);

expression "sum(myfl*(U.y*U.y)*vol())/sum(myfl*1.0*vol())"; // expression "sum((U.y*U.y)*vol()*myfl)/sum(vol()*myfl)";
verbose true;
//outputControlMode timestep
}
[/CODE]

There is no error "sum(myfl*(U.y*U.y)*vol())/sum(vol())" but it crashes with the following error for "sum(myfl*(U.y*U.y)*vol())/sum(myfl*1.0*vol())"

Quote:
Expression uysqr : #0 Foam::error::printStack(Foam::Ostream&) at ??:?
#1 Foam::sigFpe::sigHandler(int) at ??:?
#2 ? in "/opt/openfoam30/platforms/linuxGccDPInt32Opt/lib/libOpenFOAM.so"
#3 Foam::divide(Foam::Field<double>&, Foam::UList<double> const&, Foam::UList<double> const&) at ??:?
#4 Foam::operator/(Foam::UList<double> const&, Foam::UList<double> const&) at ??:?
#5 parserSubset::SubsetValueExpressionParser::parse() at SubsetValueExpressionParser.yy.C:?
#6 Foam::SubsetValueExpressionDriver::parseInternal(i nt) at ??:?
#7 Foam::CommonValueExpressionDriver::parse(Foam::exp rString const&, Foam::word const&) at ??:?
#8 Foam::swakExpressionFunctionObject::write() at ??:?
#9 Foam::simpleFunctionObject::execute(bool) at ??:?
#10 Foam::functionObjectList::execute(bool) at ??:?
#11 Foam::Time::run() const at ??:?
#12 ? at ??:?
#13 __libc_start_main in "/lib/i386-linux-gnu/libc.so.6"
#14 ? at ??:?
here myfl is a volscalar field at the cell-centre and vol() scalar firld is also defined at the cell-centres.
Please give your expert opinion..:confused::confused:

Thanks and regards,
cfd@kgp is offline   Reply With Quote

Old   December 18, 2016, 07:03
Unhappy
  #32
Member
 
a
Join Date: Oct 2014
Posts: 49
Rep Power: 12
cfd@kgp is on a distinguished road
Quote:
Originally Posted by gschaider View Post
swak4Foam just calls fvc::grad(). Which scheme that function uses is determined by system/fvSchemes

If you want to experiment with discretization schemes: there is a Plugin-Function-Library swakFvcSchemesFunctionPlugin that extends the internalField-parser with a number of functions where you can explicitely choose the discretization scheme for grad() and friends
Dear Bernhard,

Please answer my query in post #31.

I am eagerly waiting to hear from you.

Thank,
cfd@kgp is offline   Reply With Quote

Old   December 18, 2016, 08:26
Default
  #33
Senior Member
 
Zeppo's Avatar
 
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 21
Zeppo will become famous soon enough
Looks like you've got division by zero here:
Code:
sum(myfl*1.0*vol())
Check your myfl
Zeppo is offline   Reply With Quote

Old   December 18, 2016, 08:49
Talking
  #34
Member
 
a
Join Date: Oct 2014
Posts: 49
Rep Power: 12
cfd@kgp is on a distinguished road
Quote:
Originally Posted by Zeppo View Post
Looks like you've got division by zero here:
Code:
sum(myfl*1.0*vol())
Check your myfl

Many thanks Zeppo!
cfd@kgp is offline   Reply With Quote

Reply

Tags
fieldaverage, functionobjects, swak4foam


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
[swak4Foam] problems with averaging a new field fgarita OpenFOAM Community Contributions 1 October 28, 2016 04:27
[swak4Foam] expressionField + execFlowFunctionObjects + AMI pbachant OpenFOAM Community Contributions 0 July 16, 2015 02:09
[swak4Foam] Using swak4foam to implement a BC for heat convection with h(Tamb,Twall) zfaraday OpenFOAM Community Contributions 5 January 19, 2015 15:05
[swak4Foam] expressionField aylalisa OpenFOAM Community Contributions 1 October 28, 2014 18:42
[swak4Foam] fails in parallel with -otherTime? Phicau OpenFOAM Community Contributions 3 June 26, 2013 14:00


All times are GMT -4. The time now is 06:44.