CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   domainIntegrate() vs Sum(...) (https://www.cfd-online.com/Forums/openfoam-programming-development/144819-domainintegrate-vs-sum.html)

Tobi November 22, 2014 10:01

domainIntegrate() vs Sum(...)
 
Hello all together,

just one question.
If I have the following code:
Code:

Info << fvc::domainIntegrate(rho);
This give me the mass in the system, isn't it? If I use that one:
Code:

forAll(rho, cellI)
{
    mass_ += rho[cellI]*mesh.V()[cellI];
}
Info << mass_;

It give me also the mass in the system. But the output is different? Why? If I have a look into the domainIntegrate function it is like:
Code:

  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 }

And in volumeIntegrate its the same as above! Value * VOlume

Tobi

jherb November 22, 2014 12:09

First idea: gSum supports multi-processor runs. Did you test with a single process?

Tobi November 22, 2014 20:17

Hi, only on single processor. But maybe I made a mistake because the calculation is exactly the same

wyldckat November 23, 2014 13:17

Greetings to all!

@Tobi: This is one of those situations I feel like complaining that I don't have a crystal ball.

My guess is that:
  1. Rookie mistake #1 - assuming a variable starts with 0.0:
    Code:

    forAll(rho, cellI)
    {
        mass_ += rho[cellI]*mesh.V()[cellI];
    }
    Info << mass_;

    It's missing this:
    Code:

    mass_ = 0.0;
    before the forAll cycle.
  2. Rookie mistake #2:
    Quote:

    Originally Posted by Tobi (Post 520514)
    But the output is different? Why?

    No scientific exposition to support one's statement. Are you sure you're doing Computational Fluid Dynamics?
    In other words, it's like saying that "a potato is identical to an orange", without even an image or values to support the statement :D
    Without any specific values for us to assess, the values might actually be as good as identical or actually be completely different, for example:
    • 1.0000001 vs 1.0000000
    • 1.0 vs 100002142134.012312
Best regards,
Bruno

Tobi November 23, 2014 14:30

Hi Bruno,

I set the mass_ to zero and I build a new model for shrinkage the mesh due to density changes in casting. I made an error but the calculation what I did is correct!
So its solved ... there is no error !
My fault - to tierd all the time and therefor I go to bed now.

doubledang October 18, 2016 11:41

Quote:

Originally Posted by Tobi (Post 520656)
Hi Bruno,

I set the mass_ to zero and I build a new model for shrinkage the mesh due to density changes in casting. I made an error but the calculation what I did is correct!
So its solved ... there is no error !
My fault - to tierd all the time and therefor I go to bed now.



Hi Tobi,

I have encountered exactly the same problem as this post,
Could you please disclose what kind of errors did you make leading the difference between the two approaches?
Many thanks!

Best regards,
Dang.

Tobi October 18, 2016 11:49

Hi Dang,

I am sorry that i did not post the solution to my problem here and based on the fact that it is already 2 years old, I can no remember how I solved it or what I did wrong.

Maybe I can check out the old stuff and figure out what I did.

doubledang October 18, 2016 11:54

Quote:

Originally Posted by Tobi (Post 621958)
Hi Dang,

I am sorry that i did not post the solution to my problem here and based on the fact that it is already 2 years old, I can no remember how I solved it or what I did wrong.

Maybe I can check out the old stuff and figure out what I did.


Hi Tobi,

I really appreciate if you could check a little bit (if possible),
I exhausted on this issue. ..

Thanks for your time!

Best regards,

Tobi October 18, 2016 13:55

Dear Dang,

I checked my code and the latest developments. Based on the fact that the first shrinkage model (2014) was not really physical, I switched the development line after some discussions with my colleague and there is no code anymore that includes this lines. However, I found some issues in my bitbucket history that are about that problem. Do you have access to that one: https://bitbucket.org/opencast/tscst...-conservation?

doubledang October 19, 2016 04:51

Quote:

Originally Posted by Tobi (Post 621981)
Dear Dang,

I checked my code and the latest developments. Based on the fact that the first shrinkage model (2014) was not really physical, I switched the development line after some discussions with my colleague and there is no code anymore that includes this lines. However, I found some issues in my bitbucket history that are about that problem. Do you have access to that one: https://bitbucket.org/opencast/tscst...-conservation?


Dear Tobi,

Thanks a lot for your kind help and time.
I tried to access the link, but denied.
Is it possible to work around?

Thanks!

Best regards,

Tobi October 19, 2016 05:45

5 Attachment(s)
Dear Dang,

the problem was not really critical in my case because it was only around 0.3%. See the bitbucket stuff (I added the pictures) because the project is closed (I forgot).

doubledang October 19, 2016 09:37

Quote:

Originally Posted by Tobi (Post 622069)
Dear Dang,

the problem was not really critical in my case because it was only around 0.3%. See the bitbucket stuff (I added the pictures) because the project is closed (I forgot).


Dear Tobi,

Okay, I see.
Thanks a lot for your kind help and time.


Best regards,
Dang.


All times are GMT -4. The time now is 07:00.