|
[Sponsors] |
September 19, 2007, 13:35 |
Hi Foamers,
sorry because thi
|
#1 |
Member
|
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 |
|
April 29, 2021, 14:07 |
gSum is built in a template
|
#2 |
New Member
Leonardo Jesus Miranda MIyazaki
Join Date: Jan 2018
Posts: 5
Rep Power: 8 |
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! |
|
June 7, 2022, 15:27 |
|
#3 | |
Member
Join Date: Jan 2017
Posts: 71
Rep Power: 9 |
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:
|
||
|
|
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 |