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/)
-   -   Apply boundary condition functions (https://www.cfd-online.com/Forums/openfoam-pre-processing/62232-apply-boundary-condition-functions.html)

billy July 18, 2005 14:50

Hello, Is there a way to ap
 
Hello,

Is there a way to apply boundary conditions as a function on specified patch?

Has anyone developed a code to do this?

billy July 18, 2005 16:16

This is the code I am trying t
 
This is the code I am trying to work with. I want to calculate the non-uniform boundary field of a patch named lid instead of the internal field. So I guess it would be something like:

U.boundaryField = vector(0, 0, 1)*Uz;

instead of:

U.boundaryField = vector(0, 0, 1)*Uz;

Can anyone please tell me the syntax because I can't find it anywhere.

/**********************/

int main(int argc, char *argv[])
{

# include "setRootCase.H"

# include "createDatabase.H"
# include "createMesh.H"
# include "createFields.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

volScalarField Ux = mesh.C().component(vector::X);
volScalarField Uy = mesh.C().component(vector::Y);
volScalarField Uz = mesh.C().component(vector::Z);

U.internalField = vector(0, 0, 1)*Uz;
U.internalField = vector(1, 0, 0)*Ux;

U.write();

Info<< "End\n" << endl;

return(0);
}

billy July 18, 2005 17:07

This is the code I am trying t
 
This is the code I am trying to work with. I want to calculate the non-uniform boundary field of a patch named lid instead of the internal field. So I guess it would be something like:

U.boundaryField = vector(0, 0, 1)*Uz;

instead of:

U.internalField = vector(0, 0, 1)*Uz;

Can anyone please tell me the syntax because I can't find it anywhere.

/**********************/

int main(int argc, char *argv[])
{

# include "setRootCase.H"

# include "createDatabase.H"
# include "createMesh.H"
# include "createFields.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

volScalarField Ux = mesh.C().component(vector::X);
volScalarField Uy = mesh.C().component(vector::Y);
volScalarField Uz = mesh.C().component(vector::Z);

U.internalField = vector(0, 0, 1)*Uz;
U.internalField = vector(1, 0, 0)*Ux;

U.write();

Info<< "End\n" << endl;

return(0);
}

mattijs July 18, 2005 17:54

Search for 'boundaryField' on
 
Search for 'boundaryField' on this board.

billy July 18, 2005 18:57

This also does not work. //
 
This also does not work.

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

int main(int argc, char *argv[])
{

# include "setRootCase.H"

# include "createDatabase.H"
# include "createMesh.H"
# include "createFields.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

label lidPatchID = mesh.boundaryMesh().findPatchID("lid");

//access boundary elements
const polyPatch& cPatch = mesh.boundaryMesh()[lidPatchID];

const vectorField& faceCentres = cPatch.faceCentres();

// Radial velocity
scalar omega = 10;

volScalarField Ux = +omega * faceCentres.component(vector::Z);
volScalarField Uz = -omega * faceCentres.component(vector::X);

//check boundary name
forAll (cPatch, faceI)
{
//calculate boundary velocity
U.boundaryField()[lidPatchID][faceI] = vector(Ux, 0.0, Uz);
}

U.write();

Info<< "End\n" << endl;

return(0);
}


// ************************************************** *********************** //

Can anyone please help?

eugene July 18, 2005 19:24

"Info" is your friend.
 
"Info" is your friend.

billy July 18, 2005 19:33

OK. It is now fixed.
 
OK. It is now fixed.

liugx212 December 18, 2005 21:22

Dear Billy, I am also tryi
 
Dear Billy,

I am also trying to change the value of the X,Y and Z of U. I add the code in icoFoam.C, but it does not work yet. Could you please help me see.

Thanks a lot.
code:
forAll (centers, celli)
{
double angle = 45;
U.component(vector::X) = U.component(vector::X) * Foam::sin(angle);
U.component(vector::Y) = U.component(vector::Y) * Foam::cos(angle);
U.component(vector::Z) = U.component(vector::Z) * 0;
}


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