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/)
-   -   Conservatively Smoothing a Source Term (https://www.cfd-online.com/Forums/openfoam-programming-development/241509-conservatively-smoothing-source-term.html)

Kellis March 2, 2022 16:18

Conservatively Smoothing a Source Term
 
Hello all,

I am attempting to solve a conjugate heat transfer problem where viscous heating plays an important role in the overall process. I am solving the energy equation as follows:

\rho c_p \frac{\partial T}{\partial t} + \rho c_p \textbf{U} \cdot \nabla T = \nabla \cdot (k \nabla T) + \mu \Phi

Due to the nature of the problem, the viscous heating term varies many orders of magnitude over the width of a few cells, and causes some instabilities / oscillations when solving for the temperature. To combat this, I am hoping to implement some sort of smoothing algorithm which conserves the overall amount of viscous heating, but distributes it within a wider area to make the computation more stable. For instance in 1D, assuming a uniform grid spacing, this smoothing algorithm might turn a field that looks like this:

[ 1 1 1 10 1 1 1 ]

Into one which looks like this:

[ 1 2 3 4 3 2 1 ]

Ideally, the "width" of the spread would be controllable by the user. I am sure such an algorithm exists already, but I am not sure what the correct search terms would be, and my initial efforts to find such a method have not yielded any good leads.

If anyone has a suggestion for a method I might try, I would be grateful. Additionally, any other strategies I might try to increase the stability of the problem would be appreciated.

Thanks,
Kellis

mAlletto March 3, 2022 04:44

Hello,

You can try to first interpolate to the faces and then avarage over the faces of the cell. The code would look like this:

Code:


volScalarField smoothedSoure (fvc::average(fvc::interpolate(source)));

This will smooth the source a bit

mkraposhin March 3, 2022 05:14

You can solve diffusion equation in pseudo-time, like that:




dimensionedScalar pseudoDeltaT ("dT", dimTime, 1.0);
dimensionedScalar Dphi ("Dphi", dimLength*dimLength/dimTime, 1.0);



solve
(
fvm::Sp(1.0/pseudoDeltaT, Phi)
- fvc::Sp(1.0/pseudoDeltaT, Phi)
- fvm::laplacian(Dphi, Phi)



);

mAlletto March 3, 2022 05:59

What's the purpose of

fvm::Sp(1.0/pseudoDeltaT, Phi)
- fvc::Sp(1.0/pseudoDeltaT, Phi)

Numerical stability of the equations?

mkraposhin March 3, 2022 06:15

Quote:

Originally Posted by mAlletto (Post 823438)
What's the purpose of

fvm::Sp(1.0/pseudoDeltaT, Phi)
- fvc::Sp(1.0/pseudoDeltaT, Phi)

Numerical stability of the equations?


If you use diffusion equation w/o temporal term, then your Phi distribution will be smoothed across a whole domain. But with adjustment of ratio between "pseudoDeltaT" and Dphi you can tune how many cells around initial field will be affected during one pseudo iteration.

mAlletto March 3, 2022 06:25

That's interesting. Can you recommend someone regarding about the method?

mkraposhin March 3, 2022 06:28

This is a simple idea, which arises from the concept of numerical diffusion of convection equation.


http://www.mathematik.tu-dortmund.de.../Transport.pdf


Or just walk around this personal page: http://www.mathematik.tu-dortmund.de/~kuzmin/

joshwilliams March 5, 2022 14:12

Quote:

Originally Posted by mAlletto (Post 823444)
That's interesting. Can you recommend someone regarding about the method?


I used code from the CFDEMcoupling library to do something similar. You can copy the function from this GitHub repository. There are some user-defined lengths and lower/upper limits you can use to tune the diffusion.


All times are GMT -4. The time now is 05:47.