ssss |
April 18, 2015 09:13 |
Adding non-orthogonal corrector to snGrad in fixedValueBcs
2 Attachment(s)
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
|