1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
28 #include "snGradScheme.H"
29 #include "volFields.H"
30 #include "surfaceFields.H"
31 #include "HashTable.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
46 tmp<snGradScheme<Type> > snGradScheme<Type>::New
54 Info<< "snGradScheme<Type>::New(const fvMesh&, Istream&)"
55 " : constructing snGradScheme<Type>"
63 "snGradScheme<Type>::New(const fvMesh&, Istream&)",
65 ) << "Discretisation scheme not specified"
67 << "Valid schemes are :" << endl
68 << MeshConstructorTablePtr_->toc()
69 << exit(FatalIOError);
72 word schemeName(schemeData);
74 typename MeshConstructorTable::iterator constructorIter =
75 MeshConstructorTablePtr_->find(schemeName);
77 if (constructorIter == MeshConstructorTablePtr_->end())
81 "snGradScheme<Type>::New(const fvMesh&, Istream&)",
83 ) << "Unknown discretisation scheme " << schemeName
85 << "Valid schemes are :" << endl
86 << MeshConstructorTablePtr_->toc()
87 << exit(FatalIOError);
90 return constructorIter()(mesh, schemeData);
94 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
97 snGradScheme<Type>::~snGradScheme()
101 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
104 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
105 snGradScheme<Type>::snGrad
107 const GeometricField<Type, fvPatchField, volMesh>& vf,
108 const tmp<surfaceScalarField>& tdeltaCoeffs,
109 const word& snGradName
112 const fvMesh& mesh = vf.mesh();
114 // construct GeometricField<Type, fvsPatchField, surfaceMesh>
115 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tssf
117 new GeometricField<Type, fvsPatchField, surfaceMesh>
121 snGradName + "("+vf.name()+')',
128 vf.dimensions()*tdeltaCoeffs().dimensions()
131 GeometricField<Type, fvsPatchField, surfaceMesh>& ssf = tssf();
133 // set reference to difference factors array
134 const scalarField& deltaCoeffs = tdeltaCoeffs().internalField();
136 // owner/neighbour addressing
137 const unallocLabelList& owner = mesh.owner();
138 const unallocLabelList& neighbour = mesh.neighbour();
143 deltaCoeffs[faceI]*(vf[neighbour[faceI]] - vf[owner[faceI]]);
146 forAll(vf.boundaryField(), patchI)
148 ssf.boundaryField()[patchI] = vf.boundaryField()[patchI].snGrad();
155 //- Return the face-snGrad of the given cell field
156 // with explicit correction
158 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
159 snGradScheme<Type>::snGrad
161 const GeometricField<Type, fvPatchField, volMesh>& vf
164 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tsf
165 = snGrad(vf, deltaCoeffs(vf));
169 tsf() += correction(vf);
176 //- Return the face-snGrad of the given cell field
177 // with explicit correction
179 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
180 snGradScheme<Type>::snGrad
182 const tmp<GeometricField<Type, fvPatchField, volMesh> >& tvf
185 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tinterpVf
192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 } // End namespace fv
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 } // End namespace Foam
200 // ************************************************************************* //