# how to program the formula ddy(ux)+ddx(uy)

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

 July 9, 2009, 21:34 how to program the formula ddy(ux)+ddx(uy) #1 New Member   yan Join Date: Mar 2009 Posts: 2 Rep Power: 0 hi, foamers. i want to implement the formula ddy(ux)+ddx(uy) in program, can you tell how to write in source code? thanks

 July 15, 2009, 05:00 #3 Senior Member   isabel Join Date: Apr 2009 Location: Spain Posts: 171 Rep Power: 9 And do you know how to program this? x / (x² + y²)

 July 15, 2009, 05:49 #4 Senior Member     su junwei Join Date: Mar 2009 Location: Xi'an China Posts: 151 Rep Power: 11 const volVectorField & C=mesh.C(); volScalarField x=C.component(0); volScalarField y=C.component(1); your formulation x/(sqr(x)+sqr(y)) Junwei

 July 15, 2009, 06:18 #5 Senior Member   Henrik Rusche Join Date: Mar 2009 Location: Braunschweig, Niedersachsen, Germany Posts: 275 Rep Power: 10 or even simpler, if z is zero: Code: ```const volVectorField & C=mesh.C(); volScalarField res = C.component(vector::X)/magSqr(C);``` Henrik

 July 24, 2009, 11:09 #6 Senior Member   isabel Join Date: Apr 2009 Location: Spain Posts: 171 Rep Power: 9 Thank you very much. Sorry for disturb you again, but I have other problem: I need a function_new which values x/(x² + ²) if x > 0 and 1 if x < 0 So I have tipped const volVectorField & C = mesh.C(); volScalarField x = C.component(0); volScalarField y = C.component(1); volScalarField function = x/(sqrt(x)+sqrt(y)); volScalarField function_new = scalar(1); forAll(x, gI) { if (x[gI] < 0) function_new[gI] = 1; else function_new[gI] = function[gI]; } I have no errors but “fuction_new” always is “1”. I think that the error is that “gI” is not the word I have to type.

 July 24, 2009, 12:30 #7 Senior Member   Henrik Rusche Join Date: Mar 2009 Location: Braunschweig, Niedersachsen, Germany Posts: 275 Rep Power: 10 Isabel, the long answer is: I do not see what's wrong. Try and put some Info-statements into the loop and if-statement. the short answer is: Code: `volScalarField function_new = max(function, scalar(0));` Henrik

 July 24, 2009, 13:04 #8 Senior Member   isabel Join Date: Apr 2009 Location: Spain Posts: 171 Rep Power: 9 Thank you very much, Henrik. But my error continues. To see the error better, I have tipped this: volScalarField x = C.component(0); volScalarField function_new = scalar(1); forAll(x,gI) { function_new[gI] = x[gI]; } And when I execute, “function_new” always is 1 and should be equal to "x" Why is always 1?

 July 24, 2009, 13:26 #9 Senior Member   isabel Join Date: Apr 2009 Location: Spain Posts: 171 Rep Power: 9 Sorry Henrik, you were right. I have discovered that I was other different problem. These lines were Ok. Only a last doubt, I don't know which is better: use forAll(x,gI) or forAll(x,celli) ???

 July 24, 2009, 14:06 #10 Senior Member   Henrik Rusche Join Date: Mar 2009 Location: Braunschweig, Niedersachsen, Germany Posts: 275 Rep Power: 10 Isabel, the difference between the two statements is only the name of the variable - Nothing else. Henrik

 August 19, 2009, 10:50 #11 New Member   Benjamin Join Date: May 2009 Posts: 5 Rep Power: 9 Hi, why is it not possible to do: volVectorField Grad_X volTensorField gradU=fvc::grad(U); Info << gradU.T()*Grad_X << endl ; It gaves me the following error: no match for ‘operator*’ in ‘Foam::GeometricField::T() const [with Type = Foam::Tensor, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]() * Grad_X’ On the other hand: gradU.T() & Grad_X seems to give the correct result. Thank you Last edited by N2a; August 19, 2009 at 12:47.

 August 19, 2009, 13:11 #12 Senior Member   Henrik Rusche Join Date: Mar 2009 Location: Braunschweig, Niedersachsen, Germany Posts: 275 Rep Power: 10 Dear N2a, Please, have a look into the Programmer's Guide (P-24) and around. "*" represents the outer product. Hence, tensor * vector = third rank tensor which are not implemented. Probably you want the inner product, ie. vector & tensor = vector. Henrik

 August 21, 2009, 13:55 #13 Member   Sven Winkler Join Date: May 2009 Posts: 70 Rep Power: 9 Can someone explain what the line Code: `const volVectorField & C=mesh.C();` stands for? especially, what does the & sign mean? How can I define a volVectorField with initial values, that is how can I define a volVectorField with defining a value of each of its components? Thank you!

 October 13, 2010, 02:55 #14 Senior Member   isabel Join Date: Apr 2009 Location: Spain Posts: 171 Rep Power: 9 Hello everybody, I need to define a surfaceScalarField vector (-1,0,0) which I have done as follows: volVectorField vectorv = vector(-1,0,0); surfaceScalarField vectors = mesh.Sf() & fvc::interpolate(vectorv); But when I try to compile I have the following error in the first line: levelSetEqn.H:73: error: conversion from ‘Foam::vector’ to non-scalar type ‘Foam::volVectorField’ requested Does anybody know how can I define my surfaceScalarField?

 October 18, 2010, 07:39 #15 Senior Member   Eugene de Villiers Join Date: Mar 2009 Posts: 725 Rep Power: 13 Your surfaceScalarField definition is fine. Your volVectorField definition is not. Check the constructors for a volField and use one of them to construct your volVectorField.

 October 18, 2010, 09:21 #16 Senior Member   isabel Join Date: Apr 2009 Location: Spain Posts: 171 Rep Power: 9 Where can I check the constructors for a volVectorField?

 October 18, 2010, 09:45 #17 Senior Member   Join Date: Mar 2009 Posts: 248 Rep Power: 10 Dear Isabel What you really need is to create a volumetric vector field i.e. a field in which: a vector is stored at the cell centre in the internalField; a vector is stored at the face centre on the boundaryField; What Eugene meant is that look for a previous declaration of some volVectorField and declare yours analogously. You are getting an error because you are trying to convert a vector to a field. This is not possible because the field needs information about the mesh so that it can calculate the size of the field. For your case your can do something like this : volVectorField vectorV ( IOobject ( "vectorV", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh, dimensionedVector("vectorV", dimless, vector(x,y,z)) ); Above given is just one option. This will create a volVectorField named vectorV. At each location a dimensionless vector with the components x,y,z is stored . Also the boundaryField type of this field is by default set to calculated. In case you want to have the same but a vector with dimensions then do the following: volVectorField vectorV ( IOobject ( "vectorV", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh, dimensionedVector ( "vectorV", dimensionSet( 0, 1, -1, 0, 0, 0, 0 ), vector(x,y,z) ) ); Now you have field with vector at each location which has dimesnions of velocity. Additionally if you want to presupply the boundaryField types then you can define: volVectorField vectorV ( IOobject ( "vectorV", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh, dimensionedVector ( "vectorV", dimensionSet( 0, 1, -1, 0, 0, 0, 0 ), vector(x,y,z) ), fixedValueFvPatchVectorField::typeName ); If you want to copy the boundaryField types of some already existing field then you can do something similar to what is done in the file interFoam/correctPhi.H. Have a look at that and you will understand how to do this . Hope that will help. Regards jaswi

 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 Rogerio Fernandes Brito FLUENT 0 February 3, 2008 12:22 tib FLUENT 0 January 28, 2004 15:13 kokey FLUENT 0 March 19, 2002 11:21 CD adapco Group Marketing CD-adapco 13 February 7, 2002 10:33 Radhakrishnan Main CFD Forum 3 March 4, 1999 02:03

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