CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

Where is gSum implemented

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

Like Tree4Likes
  • 4 Post By leonardo13

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 19, 2007, 13:35
Default Hi Foamers, sorry because thi
  #1
Member
 
cosimo bianchini
Join Date: Mar 2009
Location: Florence, Tuscany, Italy
Posts: 88
Rep Power: 17
cosimobianchini is on a distinguished road
Send a message via Skype™ to cosimobianchini
Hi Foamers,
sorry because this might be a trivial question.
I would like to have a look at the piece of code where gSum is implemented but I was not able to find it. Where is this function implemented?

I need to understand if in such case:

gSum(volScalarField.boundaryField());

processor boundaries are included in the sum or not.
Thanks in advance,
Cosimo
__________________
Cosimo Bianchini

Ergon Research s.r.l.
Via Panciatichi, 92
50127 Florence - ITALY
Tel: +39 055 0763716
Mob: +39 320 9460153
e-mail: cosimo.bianchini@ergonresearch.it
URL: www.ergonresearch.it
cosimobianchini is offline   Reply With Quote

Old   April 29, 2021, 14:07
Default gSum is built in a template
  #2
New Member
 
Leonardo Jesus Miranda MIyazaki
Join Date: Jan 2018
Posts: 5
Rep Power: 8
leonardo13 is on a distinguished road
gSum is implemented in FieldFieldFunctions.C as a template function.



First the G_UNARY_FUNCTION is defined:


#define G_UNARY_FUNCTION(ReturnType, gFunc, func, rFunc) \

template<template<class> class Field, class Type> \

ReturnType gFunc(const FieldField<Field, Type>& f) \

{ \


ReturnType res = func(f); \

reduce(res, rFunc##Op<ReturnType>()); \

return res; \

}\


Then, gSum is defined as


G_UNARY_FUNCTION(Type, gSum, sum, sum)


Replacing the function imputs in the template the result is


Type gFunc(const FieldField<Field, Type>& f) {
Type res = sum(f);
reduce(res, sumOp<Type>());
return res;
}



Remember that reduce is a function to integrate operations from all the processors (parallel run). So, when using gSum, we are really using "reduce" backstage.



I know this thread is old, but hope some find help!
tonnykz, KillerBee, vsb and 1 others like this.
leonardo13 is offline   Reply With Quote

Old   June 7, 2022, 15:27
Default
  #3
Member
 
Join Date: Jan 2017
Posts: 71
Rep Power: 9
sadsid is on a distinguished road
Can we apply gSum on a list of scalars or vectors?
I tried the following code:

forAll(mesh.C(),i)
{
m_[Pstream::myProcNo()][i] = gSum((m[i].internalField()*mesh.V())());
}

But it gives error. If I use gSum((m.internalField()*mesh.V())()); without "[i]" then it does not give error but allocate a single value to the whole list of "m".

What I want to achieve: The summation should be performed on a per-element basis. That is the ith element of the array "m" are summed into the ith element of the resulting array (here m_).




Quote:
Originally Posted by leonardo13 View Post
gSum is implemented in FieldFieldFunctions.C as a template function.



First the G_UNARY_FUNCTION is defined:


#define G_UNARY_FUNCTION(ReturnType, gFunc, func, rFunc) \

template<template<class> class Field, class Type> \

ReturnType gFunc(const FieldField<Field, Type>& f) \

{ \


ReturnType res = func(f); \

reduce(res, rFunc##Op<ReturnType>()); \

return res; \

}\


Then, gSum is defined as


G_UNARY_FUNCTION(Type, gSum, sum, sum)


Replacing the function imputs in the template the result is


Type gFunc(const FieldField<Field, Type>& f) {
Type res = sum(f);
reduce(res, sumOp<Type>());
return res;
}



Remember that reduce is a function to integrate operations from all the processors (parallel run). So, when using gSum, we are really using "reduce" backstage.



I know this thread is old, but hope some find help!
sadsid is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
GammaContactAngle not implemented coastal593 OpenFOAM Running, Solving & CFD 5 November 9, 2010 06:21
Convective Schemes how are they implemented nicasch OpenFOAM Running, Solving & CFD 1 November 4, 2010 09:47
Understanding implemented PISO stephan OpenFOAM Running, Solving & CFD 0 January 28, 2006 12:11
Is it implemented the QUICK scheme in the CFX? Viana CFX 2 January 23, 2006 06:08
Has the adpativemesh feature be implemented in FOAM Luckyluke (Luckyluke) OpenFOAM Running, Solving & CFD 5 January 11, 2005 08:21


All times are GMT -4. The time now is 02:18.