|
[Sponsors] |
mathematical functions not working with Foam data type in ODE solver |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 24, 2021, 06:25 |
mathematical functions not working with Foam data type in ODE solver
|
#1 |
New Member
Arham Javed
Join Date: Sep 2020
Posts: 3
Rep Power: 6 |
Hi
I am working on a project to solve 17 ordinary differential equations. And later manipulating the data obtained from these equations. The error says error: no matching function for call to ‘pow(Foam::tmp<Foam::Field<int> >, int)’ and if I remove Cpmax from the Up function I get error: no matching function for call to ‘pow(Foam::labelList&, int)’ I have used labelList Cp to store y[8] at different iterations. I have tried with float Cp[] as well but that somehow led to an infinite loop. Can you help me by proposing an appropriate data type to store y[8] in Cp or a possible way to conver the data type to float so as to perform mathematical functions such as pow, tanh, sinh etc. Or any way to perform mathematical functions to the data that we get. Thank you The main code is given below: Code:
int main(int argc, char *argv[]) { argList::validArgs.append("ODESolver"); argList args(argc, argv); // Create the ODE system testODE ode; dictionary dict; dict.add("solver", args[1]); // Create the selected ODE system solver autoPtr<ODESolver> odeSolver = ODESolver::New(ode, dict); // Initialise the ODE system fields scalar xStart = 0.0; scalarField yStart(ode.nEqns()); for (label i=0; i<19; i++) yStart[i] = 15977.4; for (label i=9; i<19; i++) yStart[i] = 16391.7; // Print the evolution of the solution and the time-step scalarField dyStart(ode.nEqns()); ode.derivatives(xStart, yStart, dyStart); scalarField y(yStart); scalar dxEst = 1; scalarField yMid(yStart); scalarField yFinal; labelList Cp[2300]; labelList Cn[2300]; Cp[0]=15977.4; Cn[0]=16391.7; for (label i=0; i<2300; i++) { scalar x = i; scalarField y(yMid); scalar xEnd = x + 1 ; odeSolver->relTol() = 1e-4; odeSolver->solve(x, xEnd, y, dxEst); Info << "Iteration Number :"<< i << endl; Info << " Cs (Anode) " << y[8] << endl; Info << " Cs (Cathode) " << y[17] << endl; yMid = y; Cp[i+1] = y[8]; } labelList Up[2300]; labelList Un[2300]; label Cpmax = 30357.07; for(label i=0; i<2300; i++) { Up[i] = (-4.656 + 88.669*pow((Cp[i])/Cpmax),2) ; } return 0; } |
|
May 25, 2021, 12:24 |
|
#2 |
New Member
Arham Javed
Join Date: Sep 2020
Posts: 3
Rep Power: 6 |
I have figured it out by setting
Code:
Cp[i] = float (y[8]); |
|
May 26, 2021, 07:42 |
|
#3 |
Senior Member
Joern Beilke
Join Date: Mar 2009
Location: Dresden
Posts: 533
Rep Power: 20 |
Have you tried
Code:
Foam::pow() |
|
May 26, 2021, 11:25 |
|
#4 |
New Member
Arham Javed
Join Date: Sep 2020
Posts: 3
Rep Power: 6 |
Yes tried that as well
Code:
Test-ODE.C:576:43: error: expected primary-expression before ‘(’ token 576 | Up[i] = (-4.656 + 88.669*(::Foam(pow((Cp[i]/Cpmax),2))) Btw tried ::Foam inside pow as well. Then I got "Cp is not a member function of Foam". |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
2DOF Planning hull resistance study with overset | CFD_fan | OpenFOAM Running, Solving & CFD | 7 | July 13, 2021 06:03 |
snappyHexMesh multiRegion failure | Liz1219 | OpenFOAM | 7 | March 5, 2021 07:00 |
time step continuity problem in VAWT simulation | lpz_michele | OpenFOAM Running, Solving & CFD | 5 | February 22, 2018 20:50 |
[blockMesh] error message with modeling a cube with a hold at the center | hsingtzu | OpenFOAM Meshing & Mesh Conversion | 2 | March 14, 2012 10:56 |
Pressure instability with rhoSimpleFoam | daniel_mills | OpenFOAM Running, Solving & CFD | 44 | February 17, 2011 18:08 |