|
[Sponsors] |
Function returning uniform surfaceScalarField |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 22, 2012, 14:37 |
Function returning uniform surfaceScalarField
|
#1 |
New Member
Lorenzo A. Ricciardi
Join Date: Mar 2011
Posts: 27
Rep Power: 15 |
Hi Foamers,
I've stumbled upon what I think is a simple yet annoying difficulty... I looked for answers on the forum, but to no use. I need to write a recursive function returning a surfaceScalarField. It has several arguments, one of which is a scalar, and when this scalar is "0", then the surfaceScalarField should be 1 everywhere. Don't know how to make it work, though... Edit: The function is this surfaceScalarField int_u (int n, surfaceScalarField l, surfaceScalarField U) { if (n == 0) return 1.0; if (n == 1) return U; return U*int_u(n-1,l,U)+(n-1)/(2*l)*int_u(n-2,l,U); } Last edited by lichmaster; June 22, 2012 at 14:39. Reason: completion of message |
|
June 22, 2012, 14:50 |
|
#2 |
New Member
Lorenzo A. Ricciardi
Join Date: Mar 2011
Posts: 27
Rep Power: 15 |
Since one of the inputs is a surfaceScalarField l, a workaround is to return l/l (since l should be always positive), but I'd prefer a more efficient and robust solution
|
|
June 22, 2012, 17:47 |
|
#3 |
Senior Member
Mahdi Hosseinali
Join Date: Apr 2009
Location: NB, Canada
Posts: 273
Rep Power: 18 |
First of all it's better to pass the fields by reference rather than by value, which means
surfaceScalarField int_u (int n, surfaceScalarField& l, surfaceScalarField& U); What is your problem with the code? |
|
June 25, 2012, 04:46 |
|
#4 |
New Member
Lorenzo A. Ricciardi
Join Date: Mar 2011
Posts: 27
Rep Power: 15 |
Thanks for the suggestion, I was planning to optimize the code later but this modification takes almost zero time.
If you read the function I posted above, I need to return an uniform value when n is zero, and a calculated (nonuniform) value when is greater than zero. The problem is that i don't know how to cast the scalar 1.0 into the surfaceScalarField uniform 1.0. The line Code:
return 1.0 Code:
error: conversion from 'double' to non-scalar type "Foam::surfaceScalarField' requested" |
|
Tags |
surfacescalarfield, uniform |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Other] mesh airfoil NACA0012 | anand_30 | OpenFOAM Meshing & Mesh Conversion | 13 | March 7, 2022 18:22 |
channelFoam for a 3D pipe | AlmostSurelyRob | OpenFOAM | 3 | June 24, 2011 14:06 |
OpenFOAM static build on Cray XT5 | asaijo | OpenFOAM Installation | 9 | April 6, 2011 13:21 |
turbulent jet simulation | antonio_ing | OpenFOAM Running, Solving & CFD | 5 | September 16, 2010 03:31 |
Problem with compile the setParabolicInlet | ivanyao | OpenFOAM Running, Solving & CFD | 6 | September 5, 2008 21:50 |