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

Calculating the explicit terms of div(phi,U)

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By yeharav

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 16, 2019, 01:17
Default Calculating the explicit terms of div(phi,U)
  #1
Member
 
Join Date: Feb 2014
Posts: 32
Rep Power: 12
yeharav is on a distinguished road
Hi all,

I am trying to calculate the individual terms of the convection terms in post-process.

The convection term is the vector
Code:
fvc::div(phi,U).
The convection term evaluated on the surface works fine
Code:
fvc::div(phi*fvc::interpolate(U))
.

However, when I use
Code:
fvc::grad(phi*fvc::interpolate(U))
and take components 0,1 and 2
the results are not related to anything. Infact even just component 0 is not related to anything.

Any ideas?
yeharav is offline   Reply With Quote

Old   December 19, 2019, 13:19
Default
  #2
HPE
Senior Member
 
HPE's Avatar
 
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 932
Rep Power: 12
HPE is on a distinguished road
gradient of a vector is a tensor, not another vector.
HPE is offline   Reply With Quote

Old   March 16, 2020, 05:53
Default Solution
  #3
Member
 
Join Date: Feb 2014
Posts: 32
Rep Power: 12
yeharav is on a distinguished road
Hi,

I have solved this a while ago but I think its a good thing to post the solution here if somebody will ever need it.

So, as HPE mentioned the result is indeed a tensor. This is what we are trying to calculate.

That is we want a tensor whose [i.j] item /\frac{\partial u_i u_j}{dx_i}.


As I mentioned, just taking fvc::grad(phi*fvc::interpolate(U)) is erroneous.

There are several reasons for that:
1. phi is already multiplied by the surface area of the cell and therefore calling fvc::grad
multiplies it twice.
2. There are some correction for the boundary conditions.

Using the gauss term we try to calculate the surface integral of
/u_i u_j\cdot n. So the question is now to evaluate these
fields on the cell face that is consistent with the way OF calculate the div(phi,U) term.

My solution is:
First calcualte the tensor terms on the face of each cell.
Code:
 surfaceTensorField interpolateUU    =   (phi*mesh.Sf()/mesh.magSf()))*fvc::interpolate(U);
Note that phi is scalar and
Code:
mesh.Sf()/mesh.magSf()
is the vector that is normal to the face direction (whose length is 1).

Now we need to correct the boundary fields.
Code:
forAll(mesh.boundary(), patchi)
{   
		auto& boundary_interpolateUU 	= interpolateU2.boundaryFieldRef()[patchi];

		const auto& boundary_phi	     = phi.boundaryField()[patchi];
		const auto& boundary_interpolateU    = interpolateU.boundaryField()[patchi];
		const auto& boundary_mesh 	     = mesh.boundary()[patchi];

		forAll(boundary_mesh, facei)
        	{
		    vector n_inside = -(boundary_mesh.Sf()[facei]/boundary_mesh.magSf()[facei]);
		    tensor tt = (boundary_phi[facei]*n_inside )*boundary_interpolateU[facei];
		    for (int i=0; i<9;i++) { 
				boundary_interpolateUU[facei].component(i) = tt.component(i);
		    }
	        }
}
Finally, we can calculate the value of the flux using th surface integral.

fvc::surfaceIntegrate(interpolateUU);
Daniel_Khazaei likes this.
yeharav is offline   Reply With Quote

Reply


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
rotational and inviscid Mike Main CFD Forum 40 November 9, 2023 06:03
Implicit vs Explicit Houthuys Main CFD Forum 15 February 3, 2017 11:17
Explicit filtering in LES TJ Main CFD Forum 85 November 30, 2016 05:22
The terms that should be treated implicitly in LES ben Main CFD Forum 3 January 28, 2005 03:32
K-Epsilon model? Brindaban Ghosh Main CFD Forum 2 June 24, 2000 04:22


All times are GMT -4. The time now is 17:41.