CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

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

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 17, 2021, 11:39
Default How to integrate a parameter in whole domain(domainIntegrate(alfa))
  #1
Senior Member
 
Farzad Faraji
Join Date: Nov 2019
Posts: 127
Rep Power: 4
farzadmech is on a distinguished road
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
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
farzadmech is offline   Reply With Quote

Old   April 17, 2021, 17:50
Default Extra explanation
  #2
Senior Member
 
Farzad Faraji
Join Date: Nov 2019
Posts: 127
Rep Power: 4
farzadmech is on a distinguished road
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
farzadmech is offline   Reply With Quote

Old   April 17, 2021, 18:26
Default Answer!!!
  #3
Senior Member
 
Farzad Faraji
Join Date: Nov 2019
Posts: 127
Rep Power: 4
farzadmech is on a distinguished road
Ok, instead of writing
Code:
fvc::domainIntegrate(p)
it must be written;
Code:
fvc::domainIntegrate(p).value();
Thanks,
Farzad
farzadmech is offline   Reply With Quote

Old   April 18, 2021, 02:52
Default
  #4
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,662
Blog Entries: 6
Rep Power: 48
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
The clarification of the problem was discussed within 3 text messages in LinkedIn between him and myself., 😉
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   April 18, 2021, 12:01
Default Thanks
  #5
Senior Member
 
Farzad Faraji
Join Date: Nov 2019
Posts: 127
Rep Power: 4
farzadmech is on a distinguished road
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 View Post
The clarification of the problem was discussed within 3 text messages in LinkedIn between him and myself., 😉
farzadmech is offline   Reply With Quote

Old   April 18, 2021, 13:11
Default New problem after integration
  #6
Senior Member
 
Farzad Faraji
Join Date: Nov 2019
Posts: 127
Rep Power: 4
farzadmech is on a distinguished road
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()] = "<<cloud.rhoTrans(gid)[this->cell()]  <<endl;
		 
        scalar sumKinematicParcelYO2 = 0.;

 	sumKinematicParcelYO2 = fvc::domainIntegrate(cloud.rhoTrans(0)).value();

        Info<<"WaterfordMizz(insideKinematicParcel.C) - sumKinematicParcelYO2 ="<< sumKinematicParcelYO2 <<endl;
And the result is this one

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
farzadmech is offline   Reply With Quote

Old   April 20, 2021, 02:57
Default
  #7
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,662
Blog Entries: 6
Rep Power: 48
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
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
Tobi is offline   Reply With Quote

Reply

Tags
domain, domainintegrate, integration, parameter

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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 05:11
meshing of a compound volume in GMSH shawn3531 OpenFOAM 4 March 12, 2015 10:45
Force can not converge colopolo CFX 13 October 4, 2011 22:03
Error when input new parameter in Fluent micro11sl FLUENT 0 July 1, 2011 06:42
compile errors of boundary condition "expDirectionMixed" liying02ts OpenFOAM Bugs 2 February 1, 2010 20:11


All times are GMT -4. The time now is 01:19.