|
[Sponsors] |
How to integrate a parameter in whole domain(domainIntegrate(alfa)) |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 17, 2021, 12:39 |
How to integrate a parameter in whole domain(domainIntegrate(alfa))
|
#1 |
Senior Member
Farzad Faraji
Join Date: Nov 2019
Posts: 206
Rep Power: 8 |
Dear foamers
I want to use domainIntegrate(alfa) to integrate a parameter in all my domain. I checked the main code for domainIntegrate(alfa) in below address; https://cpp.openfoam.org/v3/a05655_source.html and it is written as below; Code:
82 83 template<class Type> 84 dimensioned<Type> 85 domainIntegrate 86 ( 87 const GeometricField<Type, fvPatchField, volMesh>& vf 88 ) 89 { 90 return dimensioned<Type> 91 ( 92 "domainIntegrate(" + vf.name() + ')', 93 dimVol*vf.dimensions(), 94 gSum(fvc::volumeIntegrate(vf)) 95 ); 96 } 97 98 99 template<class Type> 100 dimensioned<Type> domainIntegrate 101 ( 102 const tmp<GeometricField<Type, fvPatchField, volMesh> >& tvf 103 ) 104 { 105 dimensioned<Type> integral = domainIntegrate(tvf()); 106 tvf.clear(); 107 return integral; 108 } 109 110 111 template<class Type> 112 dimensioned<Type> domainIntegrate 113 ( 114 const DimensionedField<Type, volMesh>& df 115 ) 116 { 117 return dimensioned<Type> 118 ( 119 "domainIntegrate(" + df.name() + ')', 120 dimVol*df.dimensions(), 121 gSum(fvc::volumeIntegrate(df)) 122 ); 123 } 124 125 126 template<class Type> 127 dimensioned<Type> domainIntegrate 128 ( 129 const tmp<DimensionedField<Type, volMesh> >& tdf 130 ) 131 { 132 dimensioned<Type> integral = domainIntegrate(tdf()); 133 tdf.clear(); 134 return integral; 135 } 136 137 if I want to integrate alfa over whole domain, I should use domainIntegrate(alfa), but what is alfa? I mean it is volScalarField? or Scalar? or dimensionedScalar? Thanks, Farzad |
|
April 17, 2021, 18:50 |
Extra explanation
|
#2 |
Senior Member
Farzad Faraji
Join Date: Nov 2019
Posts: 206
Rep Power: 8 |
For clarification, I used pressure to integrate which is a volScalarField and it gives me error;
Code:
In file included from DPMFoamFarzadd.C:216:0: YO2cEqnYN2cEqn.H: In function ‘int main(int, char**)’: YO2cEqnYN2cEqn.H:20:40: error: cannot convert ‘Foam::dimensioned<double>’ to ‘Foam::scalar {aka double}’ in assignment sumcloudSYO2 = fvc::domainIntegrate(p); and it gives me this error; Code:
YO2cEqnYN2cEqn.H:20:40: error: cannot convert ‘Foam::dimensioned<double>’ to ‘Foam::scalar {aka double}’ in assignment Do you know why? Thanks, Farzad |
|
April 17, 2021, 19:26 |
Answer!!!
|
#3 |
Senior Member
Farzad Faraji
Join Date: Nov 2019
Posts: 206
Rep Power: 8 |
Ok, instead of writing
Code:
fvc::domainIntegrate(p) Code:
fvc::domainIntegrate(p).value(); Farzad |
|
April 18, 2021, 03:52 |
|
#4 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
The clarification of the problem was discussed within 3 text messages in LinkedIn between him and myself., 😉
__________________
Keep foaming, Tobias Holzmann |
|
April 18, 2021, 13:01 |
Thanks
|
#5 |
Senior Member
Farzad Faraji
Join Date: Nov 2019
Posts: 206
Rep Power: 8 |
||
April 18, 2021, 14:11 |
New problem after integration
|
#6 |
Senior Member
Farzad Faraji
Join Date: Nov 2019
Posts: 206
Rep Power: 8 |
I am doing a lagrangian particel tracking using DPMFoam, and inside lagrangian part(src/lagrangian/intermediate/parcels/Templates/KinematicParcel), you need to add
Code:
#include "fvCFD.H" I did this, and code compiles and works fine, but still I have a problem after doing the integration. Let's I explain it; Code:
scalar np0 = 1 Info<< "dMass[0] = " << dMass[0] << endl; scalar dm = np0*dMass[0]; label gid = 0; cloud.rhoTrans(gid)[this->cell()] += dm; Info<< "cloud.rhoTrans(gid)[this->cell()] = "<<cloud.rhoTrans(gid)[this->cell()] <<endl; scalar sumKinematicParcelYO2 = 0.; sumKinematicParcelYO2 = fvc::domainIntegrate(cloud.rhoTrans(0)).value(); Info<<"WaterfordMizz(insideKinematicParcel.C) - sumKinematicParcelYO2 ="<< sumKinematicParcelYO2 <<endl; Code:
dMass[0] = 3.5044329e-28 cloud.rhoTrans(gid)[this->cell()] = 3.5044329e-28 WaterfordMizz(insideKinematicParcel.C) - sumKinematicParcelYO2 = 3.4299845e-34 Or in the next Lagrangian time step(2) dMass[0] = 2.6911542e-15 cloud.rhoTrans(gid)[this->cell()] = 2.6911542e-15 WaterfordMizz(insideKinematicParcel.C) - sumKinematicParcelYO2 = 2.6339832e-21 And in the next Lagrangian time step(3) dMass[0] = 3.1145925e-15 cloud.rhoTrans(gid)[this->cell()] = 8.7192363e-15 WaterfordMizz(insideKinematicParcel.C) - sumKinematicParcelYO2 = 8.5340044e-21 Now, we have the value inside one cell, and the remaining cells are empty(initialized zero). After integration, integration results is 6 order magnitude less than the value inside one cell, why? Farzad |
|
April 20, 2021, 03:57 |
|
#7 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
I expect that domainIntegrate is not suitable for particles. Check out any lagrangian code to see how they create the overall mass or whatever you want to do.
__________________
Keep foaming, Tobias Holzmann |
|
Tags |
domain, domainintegrate, integration, parameter |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[ANSYS Meshing] ANSYS Mesher cann't update geometry from parameter set | M.Shousha | ANSYS Meshing & Geometry | 4 | November 25, 2016 06:11 |
meshing of a compound volume in GMSH | shawn3531 | OpenFOAM | 4 | March 12, 2015 11:45 |
Force can not converge | colopolo | CFX | 13 | October 4, 2011 23:03 |
Error when input new parameter in Fluent | micro11sl | FLUENT | 0 | July 1, 2011 07:42 |
compile errors of boundary condition "expDirectionMixed" | liying02ts | OpenFOAM Bugs | 2 | February 1, 2010 21:11 |