February 13, 2022, 16:14
|
problem with source term
|
#1
|
New Member
manou mouna
Join Date: Jan 2022
Posts: 7
Rep Power: 5
|
Hello, I want to add a volume force to the momentum equation which depends on the position, so I used fvOptions and codedSource, here is the code I used, I have no errors and the solution converges but the source term is not taken into account, what is the problem in the code please??
regards
PHP Code:
volumicForce
{
type vectorCodedSource;
active true;
name volumicForce;
vectorCodedSourceCoeffs
{
selectionMode points;
points
(
(0 0 0)
(0 0 0.01)
(0 0 0.02)
);
fields (U);
fieldNames (U);
codeInclude
#{
#};
codeCorrect
#{
Pout<< "**CorrectCode**" << endl;
#};
codeAddSup
#{
const scalarField&V = mesh_.V();
vectorField& FSource = eqn.source();
vectorField F(mesh_.nCells(), vector(0, 0, 1)); // declare F
scalarField rho2(mesh_.nCells(), scalar(1000.0)); //declare rho2...
const labelList& cellIDs = cell();
Info<<"eqn dimension "<<eqn.dimensions()<<nl; // to check the dimesnsions
forAll(cellIDs, i)
{
label celli = cellIDs[i];
FSource[cellI]-= F[cellI]/rho2[cellI]*V[cellI];
}
#};
codeSetValue
#{
Pout<< "**codeSetValue**" << endl;
#};
// Dummy entry. Make dependent on above to trigger recompilation
coded
#{
$codeInclude
$codeCorrect
$codeAddSup
$codeSetValue
#};
}
volumicForceCoeffs
{
selectionMode all;
}
}
|
|
|