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

Adding non-orthogonal corrector to snGrad in fixedValueBcs

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By ssss

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 18, 2015, 08:13
Default Adding non-orthogonal corrector to snGrad in fixedValueBcs
  #1
Senior Member
 
anonymous
Join Date: Aug 2014
Posts: 205
Rep Power: 12
ssss is on a distinguished road
Hi,

I'm willing to add non-orthogonal correction in the boundaries when I call the fvc::snGrad() function of a volScalarField.

The reason why I'm would to add this special non-orthogonal correction is described in the posts:

http://www.cfd-online.com/Forums/ope...tml#post382173

http://www.cfd-online.com/Forums/ope...d-surface.html

Basically OpenFOAM doesn't use non-orthogonal correction in the boundaries and thus high-oscillating results for the the heat flux in the boundaries are obtained.

In order to implement a new BC, I copied the original fixedValueBC, and I named it myFixedValue, and the I added the following function to the .C

Code:
template<class Type>
tmp<Field<Type> > myFixedValueFvPatchField<Type>::snGrad() const
{
return (*this - this->patchInternalField())*this->patch().deltaCoeffs();
}
This is the original definition of snGrad in fvPatch.C. I also added to the .H file:

Code:
virtual tmp<Field<Type> > snGrad() const;
And the it compiles OK. The problem appears when I modify the snGrad function in order to use non-orthogonal correctors:

Code:
template<class Type>
tmp<Field<Type> > myFixedValueFvPatchField<Type>::snGrad() const
{
    const fvPatchField<vector>& gradField =this->patch().lookupPatchField<volVectorField, vector>("grad(T)");
    vectorField n = this->patch().nf();
    vectorField delta = this->patch().delta();

    //- correction vector
    vectorField k = delta - n*(n&delta);

    return
    (
        *this
      - (this->patchInternalField() + (k&gradField.patchInternalField()))
      )*this->patch().deltaCoeffs();
}
(The code is obtained from http://www.cfd-online.com/Forums/ope...tml#post382173). When I compile this new code I obtain a lot of errors, here you will find the first lines of the log:

Code:
In file included from myFixedValueFvPatchField.H:219:0,
                 from myFixedValueFvPatchFields.H:29,
                 from myFixedValueFvPatchFields.C:26:
myFixedValueFvPatchField.C: In member function ‘virtual Foam::tmp<Foam::Field<Type> > Foam::myFixedValueFvPatchField<Type>::snGrad() const’:
myFixedValueFvPatchField.C:149:87: error: expected primary-expression before ‘,’ token
     const fvPatchField<Type>& gradField =this->patch().lookupPatchField<volVectorField, Type>("grad(T)");
                                                                                       ^
myFixedValueFvPatchField.C:149:93: error: expected initializer before ‘>’ token
     const fvPatchField<Type>& gradField =this->patch().lookupPatchField<volVectorField, Type>("grad(T)");
                                                                                             ^
In file included from /opt/openfoam231/src/OpenFOAM/lnInclude/doubleFloat.H:30:0,
                 from /opt/openfoam231/src/OpenFOAM/lnInclude/floatScalar.H:38,
                 from /opt/openfoam231/src/OpenFOAM/lnInclude/scalar.H:39,
                 from /opt/openfoam231/src/OpenFOAM/lnInclude/IOstream.H:49,
                 from /opt/openfoam231/src/OpenFOAM/lnInclude/Ostream.H:39,
                 from /opt/openfoam231/src/OpenFOAM/lnInclude/OSstream.H:39,
                 from /opt/openfoam231/src/OpenFOAM/lnInclude/messageStream.H:220,
                 from /opt/openfoam231/src/OpenFOAM/lnInclude/error.H:51,
                 from /opt/openfoam231/src/OpenFOAM/lnInclude/UListI.H:26,
                 from /opt/openfoam231/src/OpenFOAM/lnInclude/UList.H:393,
                 from /opt/openfoam231/src/OpenFOAM/lnInclude/List.H:43,
                 from /opt/openfoam231/src/OpenFOAM/lnInclude/wordList.H:42,
                 from /opt/openfoam231/src/OpenFOAM/lnInclude/patchIdentifier.H:38,
                 from /opt/openfoam231/src/OpenFOAM/lnInclude/polyPatch.H:42,
                 from /opt/openfoam231/src/finiteVolume/lnInclude/fvPatch.H:39,
                 from /opt/openfoam231/src/finiteVolume/lnInclude/fvPatchField.H:47,
                 from myFixedValueFvPatchField.H:58,
                 from myFixedValueFvPatchFields.H:29,
                 from myFixedValueFvPatchFields.C:26:
/opt/openfoam231/src/OpenFOAM/lnInclude/products.H: In instantiation of ‘class Foam::innerProduct<Foam::Vector<double>, double>’:
/opt/openfoam231/src/OpenFOAM/lnInclude/FieldFunctions.C:774:1:   required by substitution of ‘template<class Type1, class Type2> Foam::tmp<Foam::Field<typename Foam::innerProduct<Type1, Type2>::type> > Foam::operator&(const Foam::UList<T>&, const Foam::tmp<Foam::Field<Type2> >&) [with Type1 = Foam::Vector<double>; Type2 = double]’
myFixedValueFvPatchField.C:161:41:   required from ‘Foam::tmp<Foam::Field<Type> > Foam::myFixedValueFvPatchField<Type>::snGrad() const [with Type = double]’
myFixedValueFvPatchFields.C:41:1:   required from here
/opt/openfoam231/src/OpenFOAM/lnInclude/products.H:97:13: error: no type named ‘type’ in ‘class Foam::typeOfRank<double, -1>’
     >::type type;
             ^
In file included from myFixedValueFvPatchField.H:219:0,
                 from myFixedValueFvPatchFields.H:29,
                 from myFixedValueFvPatchFields.C:26:
myFixedValueFvPatchField.C: In instantiation of ‘Foam::tmp<Foam::Field<Type> > Foam::myFixedValueFvPatchField<Type>::snGrad() const [with Type = double]’:
myFixedValueFvPatchFields.C:41:1:   required from here
myFixedValueFvPatchField.C:161:41: error: no match for ‘operator&’ (operand types are ‘Foam::vectorField {aka Foam::Field<Foam::Vector<double> >}’ and ‘Foam::tmp<Foam::Field<double> >’)
       - (this->patchInternalField() + (k&gradField.patchInternalField()))
                                         ^
myFixedValueFvPatchField.C:161:41: note: candidates are:
In file included from /opt/openfoam231/src/OpenFOAM/lnInclude/word.H:144:0,
                 from /opt/openfoam231/src/OpenFOAM/lnInclude/wordList.H:41,
                 from /opt/openfoam231/src/OpenFOAM/lnInclude/patchIdentifier.H:38,
                 from /opt/openfoam231/src/OpenFOAM/lnInclude/polyPatch.H:42,
                 from /opt/openfoam231/src/finiteVolume/lnInclude/fvPatch.H:39,
                 from /opt/openfoam231/src/finiteVolume/lnInclude/fvPatchField.H:47,
                 from myFixedValueFvPatchField.H:58,
                 from myFixedValueFvPatchFields.H:29,
                 from myFixedValueFvPatchFields.C:26:
Attached to the post you will find the full log and the files of the new boundary condition.

So does anyone know if there is a solution to this? I think that there might be problems with te templateFunction, as I'm only using vectors for every template, but I don't know how to change this.

Thank you very much
Attached Files
File Type: gz log.tar.gz (35.9 KB, 3 views)
File Type: gz myFixedValue.tar.gz (91.1 KB, 6 views)
Zhiheng Wang likes this.
ssss is offline   Reply With Quote

Old   October 9, 2018, 12:40
Default
  #2
Senior Member
 
Reviewer #2
Join Date: Jul 2015
Location: Knoxville, TN
Posts: 141
Rep Power: 10
randolph is on a distinguished road
why not just put orthogonal layer near the boundary and avoid all these hassles?

This paper may help
https://www.sciencedirect.com/scienc...78475417303762
randolph is offline   Reply With Quote

Old   October 10, 2018, 00:53
Default
  #3
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi all,

I never realized that problem in the field of computational fluid dynamics and heat-flux difficulties (maybe, because I never made complex calculations) but within my solid mechanic solver as mentioned by Phil Cardiff (by the way, he made a nice - long - article about solid mechanics and FVM); very stiff problems and the boundaries are highly explicit. However, as I already did this, I will refer you to the foam-extend solidMechanics solvers to check how to implement the non-ortho correction. It is not difficult to obtain, so there should not be any problem. If you gain any stability increase, please let us know.

By the way, the code you posted is related to foam-extend and is already a while ago. Objects/classes/functions changes during time. Thus, you have to find the correct functions and objects. I suggest using Doxygen for that purpose.
__________________
Keep foaming,
Tobias Holzmann
Tobi 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
chtMultiRegionSimpleFoam samiam1000 OpenFOAM Running, Solving & CFD 39 March 31, 2016 08:43
chtMultiRegionSimpleFoam: strange error samiam1000 OpenFOAM Running, Solving & CFD 26 December 29, 2015 22:14
Problems in my first attempt with chtMultiRegionSimpleFoam zfaraday OpenFOAM Running, Solving & CFD 1 April 8, 2014 18:20
Help with chtMultiRegionFoam jbvw96 OpenFOAM Running, Solving & CFD 2 December 26, 2010 17:16


All times are GMT -4. The time now is 23:17.