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

Adding non-orthogonal corrector to snGrad in fixedValueBcs

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

Reply
 
LinkBack Thread Tools 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: 198
Rep Power: 4
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:

snGradCorrection

oscilated wallHeatFlux on a curved surface

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 snGradCorrection). 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, 1 views)
File Type: gz myFixedValue.tar.gz (91.1 KB, 1 views)
ssss is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
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 23: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 18:16


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