# How to integrate a parameter in whole domain(domainIntegrate(alfa))

 Register Blogs Members List Search Today's Posts Mark Forums Read

 April 17, 2021, 11:39 How to integrate a parameter in whole domain(domainIntegrate(alfa)) #1 Senior Member   Farzad Faraji Join Date: Nov 2019 Posts: 127 Rep Power: 4 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 84 dimensioned 85 domainIntegrate 86 ( 87 const GeometricField& vf 88 ) 89 { 90 return dimensioned 91 ( 92 "domainIntegrate(" + vf.name() + ')', 93 dimVol*vf.dimensions(), 94 gSum(fvc::volumeIntegrate(vf)) 95 ); 96 } 97 98 99 template 100 dimensioned domainIntegrate 101 ( 102 const tmp >& tvf 103 ) 104 { 105 dimensioned integral = domainIntegrate(tvf()); 106 tvf.clear(); 107 return integral; 108 } 109 110 111 template 112 dimensioned domainIntegrate 113 ( 114 const DimensionedField& df 115 ) 116 { 117 return dimensioned 118 ( 119 "domainIntegrate(" + df.name() + ')', 120 dimVol*df.dimensions(), 121 gSum(fvc::volumeIntegrate(df)) 122 ); 123 } 124 125 126 template 127 dimensioned domainIntegrate 128 ( 129 const tmp >& tdf 130 ) 131 { 132 dimensioned integral = domainIntegrate(tdf()); 133 tdf.clear(); 134 return integral; 135 } 136 137 Now, my question is very simple; 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, 17:50 Extra explanation #2 Senior Member   Farzad Faraji Join Date: Nov 2019 Posts: 127 Rep Power: 4 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’ 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’ to ‘Foam::scalar {aka double}’ in assignment Do you know why? Thanks, Farzad

 April 17, 2021, 18:26 Answer!!! #3 Senior Member   Farzad Faraji Join Date: Nov 2019 Posts: 127 Rep Power: 4 Ok, instead of writing Code: fvc::domainIntegrate(p) it must be written; Code: fvc::domainIntegrate(p).value(); Thanks, Farzad

 April 18, 2021, 02:52 #4 Super Moderator     Tobias Holzmann Join Date: Oct 2010 Location: Tussenhausen Posts: 2,662 Blog Entries: 6 Rep Power: 48 The clarification of the problem was discussed within 3 text messages in LinkedIn between him and myself., 😉 __________________ Keep foaming, Tobias Holzmann

April 18, 2021, 12:01
Thanks
#5
Senior Member

Join Date: Nov 2019
Posts: 127
Rep Power: 4
Yes, Thanks a lot Tobias Holzmann. I am still working on other parts of domainIntegration and if I find something new, I will write it down in this post.

Quote:
 Originally Posted by Tobi The clarification of the problem was discussed within 3 text messages in LinkedIn between him and myself., 😉

 April 18, 2021, 13:11 New problem after integration #6 Senior Member   Farzad Faraji Join Date: Nov 2019 Posts: 127 Rep Power: 4 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" in order to use fvc::domainIntegrate(alfa).value(); 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()] = "<cell()] <

 April 20, 2021, 02:57 #7 Super Moderator     Tobias Holzmann Join Date: Oct 2010 Location: Tussenhausen Posts: 2,662 Blog Entries: 6 Rep Power: 48 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