|
[Sponsors] |
Adding non-orthogonal corrector to snGrad in fixedValueBcs |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 18, 2015, 08:13 |
Adding non-orthogonal corrector to snGrad in fixedValueBcs
|
#1 |
Senior Member
anonymous
Join Date: Aug 2014
Posts: 205
Rep Power: 12 |
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(); } Code:
virtual tmp<Field<Type> > snGrad() const; 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(); } 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: 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 |
|
October 9, 2018, 12:40 |
|
#2 |
Senior Member
Reviewer #2
Join Date: Jul 2015
Location: Knoxville, TN
Posts: 141
Rep Power: 10 |
why not just put orthogonal layer near the boundary and avoid all these hassles?
This paper may help https://www.sciencedirect.com/scienc...78475417303762 |
|
October 10, 2018, 00:53 |
|
#3 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51 |
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 |
|
|
|
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 |