CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Pre-Processing (https://www.cfd-online.com/Forums/openfoam-pre-processing/)
-   -   issue with mesh_.V() (https://www.cfd-online.com/Forums/openfoam-pre-processing/228378-issue-mesh_-v.html)

saj216 June 29, 2020 20:56

issue with mesh_.V()
 
Hey guys,

I found this here https://www.openfoam.com/documentati...ces-coded.html and I was wondering if there was an error here. This is regarding the treatment of V (heSource[i] += 1e5*sin(200*cellx[i])*V[i];) surely this is should be divided instead. If not why? I just wish to check.

Usage
An example showing how to add a source to the energy equation of the form

Sh=1/V*100000sin(200Cx)
is shown below:

codedSource
{
type coded;
selectionMode all;

fields (h);
name sourceTime;

codeAddSup
#{
const Time& time = mesh().time();
const scalarField& V = mesh_.V();
scalarField& heSource = eqn.source();

// Start time
const scalar startTime = 2.0;

// Retrieve the x component of the cell centres
const scalarField& cellx = mesh_.C().component(0);

// Only apply when we have reached the start time
if (time.value() > startTime)
{
// Apply the source
forAll(cellx, i)
{
// cell volume specific source
heSource[i] += 1e5*sin(200*cellx[i])*V[i];
};
}
#};
}

Thanks,

Sam


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