CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Pre-Processing (http://www.cfd-online.com/Forums/openfoam-pre-processing/)
-   -   How to create a vector field out of scalar fields (http://www.cfd-online.com/Forums/openfoam-pre-processing/62191-how-create-vector-field-out-scalar-fields.html)

 anja April 6, 2006 14:37

Hi all, does someone know h

Hi all,

does someone know how to create a vector field out of scalar fields (concerning user defined bc)? Or anything similar?

here is the problem:
I do have scalar fields for Ux, Uy, Uz and want to create a vector field for the velocity of an inlet. but inlet=vector(Ux Uz Uy) does not work.

thanks
Anja

 anja April 7, 2006 10:45

But something like that does n

But something like that does not work:
scalarField Ux = sqrt((s-d*d*a)*(s-d*d*a)/(n_1*n_1 + n_2*n_2))* n_1;
scalarField Uy = sqrt((s-d*d*a)*(s-d*d*a)/(n_1*n_1 + n_2*n_2))* n_2;
scalar Uz = 0.0;
forAll(U.boundaryField()[inletPatchID], faceI)
{
U.boundaryField()[inletPatchID][faceI] = vector(Ux, Uy, Uz);
}

here is the error message:
no matching function for call to 'Foam::Vector<foam::scalar>::Vector(Foam::scalarFi eld&, Foam::scalarField&, Foam::scalar&)'

Do you see the mistake?

regards Anja

 brooksmoses April 7, 2006 16:20

You're trying to combine two s

You're trying to combine two scalar fields and one individual scalar into an individual vector. You can't stuff an entire field into a vector.

What you need instead is (I think):

U.boundaryField()[inletPatchID][faceI]
= vector(Ux.boundaryField()[inletPatchID][faceI], Uy.boundaryField()[inletPatchID][faceI], Uz);

That way, you're making the vector out of three individual scalar values.

 hartinger April 8, 2006 11:15

probably do it like that. Defi

probably do it like that. Define a function which returns the desired vector with the faceCentre as an argument

vector getInletVector(const vector centre)
{
vector inletVector;

inletVector.x() = centre.x() * ....
inletVector.y() = ....
inletVector.z() = 0.0;

return inletVector;
}

and then call your geometry function like

forAll(U.boundaryField()[inletPatchID], faceI)
{
U.boundaryField()[inletPatchID][faceI] =
getInletVector(mesh.boundaryMesh[inletPatchID].faceCentres()[faceI]);
}

 newbee May 31, 2006 03:20

Hi, is there a command for edi

Hi, is there a command for editing the outermost cells that are next to a specific patch without having to loop throu a cell index?

Thanks
/Erik

 mattijs May 31, 2006 04:48

Not as far as I know, you'll h

Not as far as I know, you'll have to get the patchCells and work your way through them.

(I assume with editing you mean changing the value)

 newbee May 31, 2006 06:35

With editing I actually ment setting a value that will be constant and uniform for the whole celllayer.

I found the following entry on cellFace on the forum that might help me:

" If you want lots of faces and cells, go onto the boundary patch and as for faceCells(), which gives you cells on the inside of the patch. This is good if you want to do lots of them, but if you only want one face of one cell, that would involve search, which is not good.

This would look something like:

const fvPatchVectorField& patchU = U.boundaryField()[patchI];

const labelList::subList fc = patchU.patch().faceCells();
"

/Erik

 hjasak May 31, 2006 11:56

Yup, just use faceCells - that

Yup, just use faceCells - that gives you the cell index hext to a patch face.

Hrv

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