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

How to interpret the arguments of fvc::grad function in OpenFOAM8?

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By überschwupper

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 25, 2022, 12:58
Default How to interpret the arguments of fvc::grad function in OpenFOAM8?
  #1
Member
 
Ivan Nepomnyashchikh
Join Date: Sep 2019
Location: USA
Posts: 30
Blog Entries: 1
Rep Power: 6
nepomnyi is on a distinguished road
Hello dear CFDonline community.


I'm trying to decipher line 109 in interfaceProperties.C file in OpenFOAM8.



Here's the line itself:


Code:
// Cell gradient of alpha
     const volVectorField gradAlpha(fvc::grad(alpha1_, "nHat"));
I have managed to interpret everything in that line except for
Code:
"nHat"
.


Since it's taken in quotation marks, I conclude this is a variable of the string type. I couldn't find this variable anywhere in the interfaceProperties.C file or interfaceProperties.H file, therefore I went to the definition file of fvc::grad() function which is called fvcGrad.C (the function is defined on lines 68-80 in the file).



The function takes 3 arguments:
Code:
const tmp<GeometricField<Type
,
Code:
fvsPatchField
and
Code:
surfaceMesh>>& tssf
The first thing I don't understand is why we supply only 2 arguments to the function whereas, by its definition, it requires 3 arguments.



The second thing I don't understand is what these 3 arguments are and which one corresponds to "nHat".


Thank you in advance.
Ivan
nepomnyi is offline   Reply With Quote

Old   October 26, 2022, 04:55
Default
  #2
Member
 
Join Date: Jan 2022
Location: Germany
Posts: 72
Rep Power: 4
überschwupper is on a distinguished road
I believe here is a strong misunderstanding. I would highly recommend to you, to take a C++ Tutorial.

The function you quoted is:
Code:
template<class Type>
 tmp<GeometricField<typename outerProduct<vector,Type>::type, fvPatchField,volMesh>> grad
 (
  const tmp<GeometricField<Type, fvsPatchField, surfaceMesh>>& tssf
 )
 {
  typedef typename outerProduct<vector, Type>::type GradType;
  tmp<GeometricField<GradType, fvPatchField, volMesh>> Grad
  (
  fvc::grad(tssf())
  );
  tssf.clear();
  return Grad;
 }
This function is templated. This is done because otherwise it would be necessary to tell the compiler each type of that function that we need (=a lot of overloaded functions, less readable, less flexible). The function only needs 1 argument of type "const tmp<GeometricField<Type, fvsPatchField, surfaceMesh>>& tssf", the template here is of type "class Type" -> you can substitute Type by vector, scalar or whatever is possible.
nepomnyi likes this.
überschwupper is offline   Reply With Quote

Reply

Tags
fvc::grad(), twophaseflow


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
[mesh manipulation] refineMesh Error mohsen.boojari OpenFOAM Meshing & Mesh Conversion 3 March 1, 2018 22:07
is internalField(U) equivalent to zeroGradient? immortality OpenFOAM Running, Solving & CFD 7 March 29, 2013 01:27
How to install CGNS under windows xp? lzgwhy Main CFD Forum 1 January 11, 2011 18:44
Problem with compile the setParabolicInlet ivanyao OpenFOAM Running, Solving & CFD 6 September 5, 2008 20:50
Droplet Evaporation Christian Main CFD Forum 2 February 27, 2007 06:27


All times are GMT -4. The time now is 01:32.