
[Sponsors] 
[swak4Foam] Using fieldAverage together with swak4foam expressionField 

LinkBack  Thread Tools  Search this Thread  Display Modes 
December 14, 2016, 04:38 
problem was generic, a general solution required

#21  
Member
a
Join Date: Oct 2014
Posts: 49
Rep Power: 12 
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; } Quote:
Thanks and regards. Last edited by cfd@kgp; December 14, 2016 at 04:43. Reason: addition of error 

December 14, 2016, 06:42 

#22  
Senior Member
Agustín Villa
Join Date: Apr 2013
Location: Alcorcón
Posts: 314
Rep Power: 15 
Quote:
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" 

December 14, 2016, 08:58 

#23  
Member
a
Join Date: Oct 2014
Posts: 49
Rep Power: 12 
Quote:
But I could not precisely follow your suggestion "try to put after "variables" and the first bracket "(" a "2"" could you please elaborate? 

December 14, 2016, 09:04 

#24  
Senior Member
Agustín Villa
Join Date: Apr 2013
Location: Alcorcón
Posts: 314
Rep Power: 15 
Quote:
something like this: Code:
variables 2 ( "myscalar=32.0;" "sqrT=(pow(T,2.0));" // "angle=pi/180*(time()<duration ? time()/duration*maxAngle : maxAngle);" ); 

December 14, 2016, 09:13 

#25  
Member
a
Join Date: Oct 2014
Posts: 49
Rep Power: 12 
Quote:
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... 

December 15, 2016, 06:00 

#27  
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 
Quote:
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 

December 15, 2016, 06:35 

#28  
Member
a
Join Date: Oct 2014
Posts: 49
Rep Power: 12 
Quote:
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? 

December 15, 2016, 08:20 

#29  
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 
Quote:
If you want to experiment with discretization schemes: there is a PluginFunctionLibrary swakFvcSchemesFunctionPlugin that extends the internalFieldparser 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 

December 15, 2016, 08:31 

#30  
Member
a
Join Date: Oct 2014
Posts: 49
Rep Power: 12 
Quote:


December 15, 2016, 09:24 
swakExpression cannot accept sum(myfl*vol())

#31  
Member
a
Join Date: Oct 2014
Posts: 49
Rep Power: 12 
Dear Bernhard ,
One more swakExpression gives error while runtime, [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:
Please give your expert opinion..:confused::confused: Thanks and regards, 

December 18, 2016, 07:03 

#32  
Member
a
Join Date: Oct 2014
Posts: 49
Rep Power: 12 
Quote:
Please answer my query in post #31. I am eagerly waiting to hear from you. Thank, 

December 18, 2016, 08:26 

#33 
Senior Member
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 21 
Looks like you've got division by zero here:
Code:
sum(myfl*1.0*vol()) 

December 18, 2016, 08:49 

#34 
Member
a
Join Date: Oct 2014
Posts: 49
Rep Power: 12 

Tags 
fieldaverage, functionobjects, swak4foam 
Thread Tools  Search this Thread 
Display Modes  


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 