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/)
-   -   Normal vector issue (https://www.cfd-online.com/Forums/openfoam-programming-development/125166-normal-vector-issue.html)

tayo October 21, 2013 02:34

Normal vector issue
 
Hello all, I have two quick questions. I want to implement heat conduction equation in my phaseChange solver.

1.) How to get a normal vector, n in OF?
2.) How to obtain area A, of the cell face?
Here is what I've tried so far:

Code:

volVectorField gradT = fvc::grad(T);
volVectorField n = T.mesh().Sf()/T.mesh().magSf();  ;)
volScalarField A = T.mesh().magSf();  ;)
volScalarField q = A*(gradT & n);

I keep getting errors in the form of: "conversion from GeometricField, fvsPatchField, SurfaceMesh> to non-scalar type requested". I guess I'm not doing something right. Thank you for your help.

Tobi October 21, 2013 06:37

not correct post

tayo October 21, 2013 13:11

Quote:

Originally Posted by Tobi (Post 458048)
not correct post

Hi Tobi,

I don't understand what you mean; :confused: the gradient of a scalar field is a vector field, so grad(T) will give me a volVectorField. The code is actually works up to that point so I dont have a problem with gradT. Here is how I call my "T".

Code:

const volScalarField& T = alpha1_.db().lookupObject<volScalarField>("T");
My question is how do I compute the normal vector and facearea of the cell. Thanks

tayo October 21, 2013 15:16

Never mind, problem fixed :D. I simply used the wrong syntax in defining the normal and face area. Here's the correction. Thanks

Code:

volVectorField gradT = fvc::grad(T);
vectorField n = T.mesh().Sf()/T.mesh().magSf();
scalarField A = T.mesh().magSf();
scalarField q = A*(gradT & n);


Tobi October 22, 2013 04:20

Hi,

as I wrote later - I made a mistake because I had mixed up some Information. The Gradient of a scalar is a vector field with it s gradients of the components in x, y, z. So I was wrong in my first post.

And your error was the following signs:
Code:

;)
Regards Tobi


All times are GMT -4. The time now is 22:38.