CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Surface gradient (snGrad) calculation

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Zeppo

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 16, 2018, 11:06
Default Surface gradient (snGrad) calculation
  #1
New Member
 
Artem
Join Date: Apr 2014
Posts: 29
Rep Power: 12
Kombinator is on a distinguished road
Hello dear Foamers,
I have a following issue, may be somebody could help me.

I have a VolScalarField PotE
I am trying to calculate surface gradient for this variable. As I read in programmers guide, fvc:: snGrad(PotE) must help me with this. But when I try to create new variable
Code:
SurfaceVectorField A = fvc:: snGrad(PotE)*mesh.Sf() ;
I get an error and I don't understand why it happens. fvc:: snGrad(PotE) is a scalar, mesh.Sf() is a vector. Their multiplication must be a vector. Everything seems fine. Maybe is something wrong with my snGrad function?
Thanks in advance.

Best regards,
Artem
Kombinator is offline   Reply With Quote

Old   May 16, 2018, 13:57
Default
  #2
Member
 
Emad Tandis
Join Date: Sep 2010
Posts: 77
Rep Power: 15
EmadTandis is on a distinguished road
Hello
Is it possible to show the error?
EmadTandis is offline   Reply With Quote

Old   May 16, 2018, 14:08
Default
  #3
Senior Member
 
Zeppo's Avatar
 
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 21
Zeppo will become famous soon enough
It should be surfaceVectorField not SurfaceVectorField. Check it carefully.
EmadTandis likes this.
Zeppo is offline   Reply With Quote

Old   May 17, 2018, 03:45
Default
  #4
New Member
 
Artem
Join Date: Apr 2014
Posts: 29
Rep Power: 12
Kombinator is on a distinguished road
Hello all, thank you for your answers

Quote:
Originally Posted by Zeppo View Post
It should be surfaceVectorField not SurfaceVectorField. Check it carefully.
It is a misprint, in the code it was "surfaceVectorField" with small "s"

Quote:
Originally Posted by EmadTandis View Post
Hello
Is it possible to show the error?
Sure but is so huge, so I provide only the headline with the most important information (I guess)

Code:
mhdEpot2Foam.C: In function ‘int main(int, char**)’:
mhdEpot2Foam.C:148:66:  error: conversion from  ‘Foam::tmp<Foam::GeometricField<Foam::Vector<double>,  Foam::fvsPatchField, Foam::surfaceMesh> >’ to non-scalar type  ‘Foam::surfaceScalarField {aka Foam::GeometricField<double,  Foam::fvsPatchField, Foam::surfaceMesh>}’ requested
    surfaceScalarField jn = -sigma * fvc::snGrad(PotE)*mesh.Sf()  + psiub;  
                                                                  ^
Kombinator is offline   Reply With Quote

Old   May 17, 2018, 06:00
Default
  #5
Senior Member
 
Zeppo's Avatar
 
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 21
Zeppo will become famous soon enough
If you want a dot-product of vector fields you should use
Code:
&
Code:
fvc::snGrad(PotE) & mesh.Sf()
It would give you a scalar field.
Zeppo is offline   Reply With Quote

Old   May 17, 2018, 07:05
Default
  #6
New Member
 
Artem
Join Date: Apr 2014
Posts: 29
Rep Power: 12
Kombinator is on a distinguished road
Quote:
Originally Posted by Zeppo View Post
If you want a dot-product of vector fields you should use
Code:
&
Code:
fvc::snGrad(PotE) & mesh.Sf()
It would give you a scalar field.
Hello, thank you for your answer. I have already tried &, unfortunately it didn't work, the same error:

Code:
mhdEpot2Foam.C: In function ‘int main(int, char**)’:
mhdEpot2Foam.C:148:55: error: no match for ‘operator&’ (operand types are ‘Foam::tmp<Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> >’ and ‘Foam::tmp<Foam::GeometricField<Foam::Vector<double>, Foam::fvsPatchField, Foam::surfaceMesh> >’)
    surfaceScalarField jn = -sigma * fvc::snGrad(PotE) & mesh.Sf()  + psiub;  
                                                       ^
Kombinator is offline   Reply With Quote

Old   May 17, 2018, 15:59
Default
  #7
Senior Member
 
Zeppo's Avatar
 
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 21
Zeppo will become famous soon enough
My bad, fvc::snGrad results in a scalar field, you can't dot-product it with a vector field. Stick to your first option. Then fvc::snGrad(PotE)*mesh.Sf() is a vector field, what is psiub, how is it defined? It must be a vector field as well as summation fvc::snGrad(PotE) & mesh.Sf() + psiub only make sense over two vector fields.
Zeppo is offline   Reply With Quote

Old   May 22, 2023, 09:03
Default Respond
  #8
New Member
 
Alex
Join Date: May 2023
Posts: 1
Rep Power: 0
Alex21 is on a distinguished road
Quote:
Originally Posted by Kombinator View Post
Hello dear Foamers,
I have a following issue, may be somebody could help me.

I have a VolScalarField PotE
I am trying to calculate surface gradient for this variable. As I read in programmers guide, fvc:: snGrad(PotE) must help me with this. But when I try to create new variable
Code:
SurfaceVectorField A = fvc:: snGrad(PotE)*mesh.Sf() ;
I get an error and I don't understand why it happens. fvc:: snGrad(PotE) is a scalar, mesh.Sf() is a vector. Their multiplication must be a vector. Everything seems fine. Maybe is something wrong with my snGrad function?
Thanks in advance.

Best regards,
Artem
I propose you to use the alternative mesh.magSf() instead of mesh.Sf() using the operator "*" for scalars.

Since the snGrad isn't a tensor as you use the scalar "PotE" inside, it still a surfaceScalarField. Thus as you are already "speaking" in projections, use the magnitude of the surface because your snGrad is already oriented with it.

Even if its too late ...
Alex21 is offline   Reply With Quote

Reply


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 Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Gmsh] Error : Self intersecting surface mesh, computing intersections & Error : Impossible velan OpenFOAM Meshing & Mesh Conversion 3 October 22, 2015 11:05
[Gmsh] Problem with Gmsh nishant_hull OpenFOAM Meshing & Mesh Conversion 23 August 5, 2015 02:09
[General] Problem in the calculation of the normal gradient on a boundary face N1colas ParaView 1 June 28, 2013 09:38
[Gmsh] boundaries with gmshToFoam‏ ouafa OpenFOAM Meshing & Mesh Conversion 7 May 21, 2010 12:43
Warning 097- AB Siemens 6 November 15, 2004 04:41


All times are GMT -4. The time now is 20:16.