|
[Sponsors] |
How pass dimensionedScalar vector for a function made in C language?. |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 16, 2014, 12:50 |
How pass dimensionedScalar vector for a function made in C language?.
|
#1 |
New Member
bahia
Join Date: Jun 2013
Posts: 2
Rep Power: 0 |
i'm just a new user of openfoam.
I am trying to implement a function. This function code was implemented in C language. Firstly, I initialize a list of dimensionedScalar, as can be seen below: Code:
// const wordList criticaNames(criticaDict.toc()); wordList criticaNames ( criticaDict.lookup("componentes") ); PtrList<dimensionedScalar> Tc(criticaNames.size()); PtrList<dimensionedScalar> Pc(criticaNames.size()); PtrList<dimensionedScalar> wc(criticaNames.size()); PtrList<dimensionedScalar> PM(criticaNames.size()); forAll(criticaNames, i) { const word& criticaName = criticaNames[i]; const dictionary& subDict = criticaDict.subDict(criticaName); Tc.set ( i, new dimensionedScalar(subDict.lookup("Tc")) ); Pc.set ( i, new dimensionedScalar(subDict.lookup("Pc")) ); wc.set ( i, new dimensionedScalar(subDict.lookup("wc")) ); PM.set ( i, new dimensionedScalar(subDict.lookup("PM")) ); Info<< "Reading field Fugacidade\n" << endl; volScalarField fug ( IOobject ( "Fug", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh ); #include "fug.H" Code:
forAll(fug, cellI) { fugacidade(thermo1.T()[cellI],Tc,Pc,wc,fug[cellI]); } Code:
double fugacidade(double T, PtrList<dimensionedScalar> Tc, PtrList<dimensionedScalar> Pc, PtrList<dimensionedScalar> wc, double result1) result1 = (Tc[0].value+Pc[0].value+wc[0].value)/T) return (result1); } Code:
/home/leonardo/OpenFOAM/OpenFOAM-2.2.0/src/OpenFOAM/lnInclude/PtrList.C: In instantiation of ‘Foam::PtrList<T>::PtrList(const Foam::PtrList<T>&) [with T = Foam::dimensioned<double>]’: fug.H:4:114: required from here /home/leonardo/OpenFOAM/OpenFOAM-2.2.0/src/OpenFOAM/lnInclude/PtrList.C:54:18: error: ‘const class Foam::dimensioned<double>’ has no member named ‘clone’ ptrs_[i] = (a[i]).clone().ptr(); ^ make: ** [Make/linuxGccDPOpt/MixtcompressibleTwoPhaseEulerFoam.o] Erro 1 |
|
May 16, 2014, 14:10 |
|
#2 |
Senior Member
|
Hi,
as in fact you don't need a copy of PtrList, you can pass constant reference to the function, i.e. Code:
double fugacidade(const double& T, const PtrList<dimensionedScalar>& Tc, const PtrList<dimensionedScalar>& Pc, const PtrList<dimensionedScalar>& wc, double& result1) |
|
May 16, 2014, 14:29 |
|
#3 |
New Member
bahia
Join Date: Jun 2013
Posts: 2
Rep Power: 0 |
Thanks for your attention, Alexey Matveichev,
My problem was solved. The function returns result1. |
|
May 16, 2014, 17:56 |
|
#4 |
Senior Member
|
Well,
if you return value from function, you don't need to pass return value as a parameter to the function. If you'd like to do it FORTRAN style, it's your choice. I mean instead of Code:
fugacidade(thermo1.T()[cellI],Tc,Pc,wc,fug[cellI]); Code:
fug[cellI] = fugacidade(thermo1.T()[cellI],Tc,Pc,wc); |
|
Tags |
c language, dimensionedscalar, ptrlist |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
whats the cause of error? | immortality | OpenFOAM Running, Solving & CFD | 13 | March 24, 2021 08:15 |
[blockMesh] Errors during blockMesh meshing | Madeleine P. Vincent | OpenFOAM Meshing & Mesh Conversion | 51 | May 30, 2016 11:51 |
is internalField(U) equivalent to zeroGradient? | immortality | OpenFOAM Running, Solving & CFD | 7 | March 29, 2013 02:27 |
Problem with rhoSimpleFoam | matteo_gautero | OpenFOAM Running, Solving & CFD | 0 | February 28, 2008 07:51 |
Droplet Evaporation | Christian | Main CFD Forum | 2 | February 27, 2007 07:27 |