|
[Sponsors] |
April 26, 2021, 16:02 |
Add soure terms to the momentum equation
|
#1 |
Member
Join Date: Feb 2020
Posts: 90
Rep Power: 6 |
Hello to all,
I am becoming myself familiar with the method of manufactured solutions and would like to add a source term on the u and v components of the momentum equation with fvOptions in pimpleFoam. The sources have the following form: Currently, I have: Code:
MomentumSource { type vectorCodedSource; selectionMode all; fields (U); // Name of the coded source name sourceTime; codeInclude #{ #}; codeCorrect #{ #}; codeConstrain #{ #}; codeAddSup #{ // Info: Include sources into equation // Gets the cell volumes of the mesh const scalarField& V = mesh_.V(); // Gets the vector containing cell centers position of the mesh const volVectorField& cellCenter = mesh().C(); // Gets the equation source term vectorField& USource = eqn.source(); const scalar pi = constant::mathematical::pi; // Loop over the source term forAll(USource, cellI) { // Gets the x component of the current cell const scalar x = cellCenter[cellI].component(0); // Gets the y component of the current cell const scalar y = cellCenter[cellI].component(1); // U source term const scalar S_u = pi*(-1.6*(2.0*Foam::sin(0.8*pi*x) - 0.6)*Foam::cos(0.8*pi*y) + 1.28*pi*Foam::sin(0.8*pi*y)) // V source term const scalar S_v = -pi*(1.6*(2.0*Foam::sin(0.8*pi*y) + 1.0)*Foam::cos(0.8*pi*x) + 1.28*pi*Foam::sin(0.8*pi*x)) USource[cellI][0]=-V[cellI]*(S_u); USource[cellI][1]=-V[cellI]*(S_v); USource[cellI][2]= 0.0; }; #}; } Can anyone confirm this implementation? Does anyone have experience with this in OpenFOAM? Any advices? |
|
June 23, 2022, 16:27 |
|
#2 |
Member
Mahmoud
Join Date: Nov 2020
Location: United Kingdom
Posts: 43
Rep Power: 5 |
Quote:
Hi, did that work for you? |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to add a body force to a momentum equation | anon_q | OpenFOAM Programming & Development | 25 | May 11, 2021 16:39 |
Splitting Momentum Eqns and Adding Extra Terms to Each | ErenC | OpenFOAM | 13 | May 23, 2020 00:30 |
Adding two terms in the momentum equation in in chtMultiRegionSimpleFoam | zahraa | OpenFOAM Pre-Processing | 0 | June 13, 2015 13:42 |
Add the constant pressure gradient to the momentum equation | tzqfly | OpenFOAM Running, Solving & CFD | 0 | October 6, 2014 05:56 |
Add source to momentum equation | Fan | OpenFOAM Programming & Development | 0 | December 30, 2013 09:35 |