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/)
-   -   invoking volVectorField class parameter which exist in "0" folder (https://www.cfd-online.com/Forums/openfoam-programming-development/173157-invoking-volvectorfield-class-parameter-exist-0-folder.html)

k.farnagh June 14, 2016 16:15

invoking volVectorField class parameter which exist in "0" directory to .c file drag
 
Hi dears,

I want to lookup or invoke Ub (inflow air velocity at inlet) to drag model (.c file).

Ub is valued in "0" directory and is volVectorField type but its not important for me to keep type class, in other word scalar output is better for me.

I apply "twoPhaseEulerFoam" solver of 2.1.1 OF and drag model is "GidaspowErgunWenYu".

Would you please guide me.

k.farnagh June 23, 2016 06:44

no body no suggestion?

epi_c June 23, 2016 23:01

Hi Kasra,

Maybe you can try

const label patchI = U.mesh().boundaryMesh().findPatchID("inlet");
const vectorField Uinlet = U.boundaryField()[patchI];

k.farnagh June 24, 2016 06:55

Hi Dear Jianzhi,

Thanks for reply, As I'm newcomer in coding would you please explain where should I put them. .c file of drag model --> member function or somewhere else?
furthermore should I include some .H file, change Constructor or ...?

Sincerely Yours
Kasra

k.farnagh June 24, 2016 10:25

Hi,

I've added below code to end of Member Function of "GidaspowErgunWenYu.c" and nothing else.

Code:

Info<< "Looking up field Ub\n" << endl;
const volVectorField& Ub = Ub.mesh().lookupObject<volVectorField>("Ub");

Info<< "Reading inlet velocity uInlet\n" << endl;
scalar UInlet = 0.0;
const label inletI = Ub.mesh().boundaryMesh().findPatchID("inlet");
const fvPatchVectorField& fvp = Ub.boundaryField()[inletI];

if (fvp.size())
{
UInlet = fvp[0].y();
}
reduce(UInlet, maxOp<scalar>());

I've compiled new drag model and encountered just below warning
Code:

dragModels/GidaspowErgunWenYulogvelo/GidaspowErgunWenYulogvelo.C:98:36: warning: ‘Ub’ may be used uninitialized in this function [-Wmaybe-uninitialized] const volVectorField& Ub = Ub.mesh().lookupObject<volVectorField>("Ub");
However I've ran a case with new drag model and it has stopped calculation when looking for Ub field.

would you please guide me to solve it. thanks again Jianzhi.

Sincerely Yours,
Kasra


All times are GMT -4. The time now is 16:54.