# How to create a vector field out of scalar fields

 Register Blogs Members List Search Today's Posts Mark Forums Read

 April 6, 2006, 14:37 Hi all, does someone know h #1 Member   Anja Stretz Join Date: Mar 2009 Posts: 92 Rep Power: 8 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

 April 7, 2006, 10:45 But something like that does n #2 Member   Anja Stretz Join Date: Mar 2009 Posts: 92 Rep Power: 8 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::Vector(Foam::scalarFi eld&, Foam::scalarField&, Foam::scalar&)' Do you see the mistake? regards Anja

 April 7, 2006, 16:20 You're trying to combine two s #3 brooksmoses Guest   Posts: n/a 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.

 April 8, 2006, 11:15 probably do it like that. Defi #4 Senior Member   Markus Hartinger Join Date: Mar 2009 Posts: 102 Rep Power: 8 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]); }

 May 31, 2006, 03:20 Hi, is there a command for edi #5 newbee Guest   Posts: n/a 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

 May 31, 2006, 04:48 Not as far as I know, you'll h #6 Super Moderator   Mattijs Janssens Join Date: Mar 2009 Posts: 1,416 Rep Power: 16 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)

 May 31, 2006, 06:35 Thanks for your answer, Wit #7 newbee Guest   Posts: n/a Thanks for your answer, 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

 May 31, 2006, 11:56 Yup, just use faceCells - that #8 Senior Member   Hrvoje Jasak Join Date: Mar 2009 Location: London, England Posts: 1,758 Rep Power: 21 Yup, just use faceCells - that gives you the cell index hext to a patch face. Hrv __________________ Hrvoje Jasak Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post simone Marras ParaView 2 April 3, 2013 06:34 edoardo OpenFOAM Running, Solving & CFD 6 February 16, 2009 12:05 gorgeta OpenFOAM Post-Processing 0 January 9, 2008 12:32 MHDWill FLUENT 0 September 29, 2007 17:04 Mounir Main CFD Forum 1 January 21, 1999 11:08

All times are GMT -4. The time now is 00:58.