Moukalled F., Mangani L., Darwish M. The finite volume method in computational fluid dynamics. An advanced introduction with OpenFOAM and Matlab (811443), страница 43
Текст из файла (страница 43)
(8.36) and (8.41).In OpenFOAM® the boundary coefficients are stored in “internalCoeffs”(FluxCb) and “boundaryCoeffs” (FluxVb), already defined in Sect. 7.6.In “fvmUncorrected”only the orthogonal discretization is accounted for.The non-orthogonal contribution is added, as shown in Listing 8.8, usingfvm.faceFluxCorrectionPtr() = newGeometricField<Type, fvsPatchField, surfaceMesh>(gammaMagSf*this->tsnGradScheme_().correction(vf));fvm.source() -=mesh.V()*fvc::div(*fvm.faceFluxCorrectionPtr())().internalField();Listing 8.8 Adding the nonorthogonal diffusion contributionAgain this term represents exactly the implementation of the last term ofEq. (8.77) in which the snGrad class wraps into the correction function thenon-orthogonal term as shown below in Listing (8.9).2648Spatial Discretization: The Diffusion Termtemplate<class Type>Foam::tmp<Foam::GeometricField<Type,Foam::fvsPatchField,Foam::surfaceMesh> >Foam::fv::correctedSnGrad<Type>::correction(const GeometricField<Type, fvPatchField, volMesh>& vf) const{const fvMesh& mesh = this->mesh();// construct GeometricField<Type, fvsPatchField, surfaceMesh>tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tssf(new GeometricField<Type, fvsPatchField, surfaceMesh>(IOobject("snGradCorr("+vf.name()+')',vf.instance(),mesh,IOobject::NO_READ,IOobject::NO_WRITE),mesh,vf.dimensions()*mesh.nonOrthDeltaCoeffs().dimensions()));GeometricField<Type, fvsPatchField, surfaceMesh>& ssf = tssf();for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; cmpt++){ssf.replace(cmpt,correctedSnGrad<typename pTraits<Type>::cmptType>(mesh).fullGradCorrection(vf.component(cmpt)));}template<class Type>Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField,>Foam::fv::correctedSnGrad<Type>::fullGradCorrection(const GeometricField<Type, fvPatchField, volMesh>& vf) const{const fvMesh& mesh = this->mesh();Foam::surfaceMesh>// construct GeometricField<Type, fvsPatchField, surfaceMesh>tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tssf =mesh.nonOrthCorrectionVectors()& linear<typename outerProduct<vector, Type>::type>(mesh).interpolate(gradScheme<Type>::New(mesh,mesh.gradScheme("grad(" + vf.name() + ')'))().grad(vf, "grad(" + vf.name() + ')'));tssf().rename("snGradCorr(" + vf.name() + ')');return tssf;}Listing 8.9 Implementation of the nonorthogonal term into the correction function8.10Computational Pointers265The non-orthogonal correction term is defined in the fullGradCorrection function where “mesh.nonOrthCorrectionVectors()” returns the T vector of Eq.
(8.66).The type of Laplacian discretization to be used is specified in the “fvSchemes”file, which is part of the case definition and is located in the system directorylaplacianSchemes{laplacian(gamma,phi) Gauss linear corrected;}Listing 8.10 The discretization type for the Laplacian operator(Listing 8.10), in which Gauss (the only available choice) defines the standardGauss discretization resulting in Eq. (8.18), linear refers to the type of interpolationused for calculating the diffusivity gamma at the face, and corrected describes thekind of non-orthogonal correction.More details on the implementation of boundary conditions in OpenFOAM® arepresented in later chapters.8.11ClosureIn this chapter the discretization of the diffusion equation was described.
A numberof issues were also addressed, such as the use of orthogonal and non-orthogonalgrid systems, the implementation of boundary conditions, and under and overrelaxation. The next chapter will concentrate on the calculation of the gradient field.8.12ExercisesExercise IConsider the diffusion of a property ϕ in the one-dimensional domain shown inFig. 8.16 with no internal sources. The domain is subdivided into 5 uniform elements of size Δx = 1 and subject to a Dirichlet and a Neumann condition atboundary ‘0’ and ‘6’, respectively.
The diffusion coefficient in the domain isconstant with a value of 1, i.e., C/ ¼ 1.a. Derive the discrete equation for each of the elements.b. Solve the system of equations using the Gauss-Seidel iterative method andreport the resulting cell-centroid values.c. Compute the diffusion flux ðCd/=dxÞ at each of the cell faces and show thatconservation is satisfied throughout the domain2668Spatial Discretization: The Diffusion Termd. Compare your solution with the exact solution (Note that even though thecomputed solution is conservative, it is not exact).e.
For the case where a zero flux boundary condition is defined at both boundaries‘0’ and ‘6’, reformulate the equations for elements 1 and 5 and explain why theequations cannot be solved.x/20= 100x12345J 6D =ddx= 106xFig. 8.16 Computational domain for a one dimensional diffusion problem with no internalsourcesExercise 2A fin is exposed to the surrounding fluid at a temperature Ta = 25 °C, as shown inFig. 8.17, with a heat transfer coefficient of h = 100 W/m2 K and a thermalconductivity with value of k = 160 W/m K. The fin has a length L = 0.1 m, a crosssectional area A = 10−5 m2, and a perimeter P = 0.1004 m.The temperature distribution in the fin is governed by the following differentialequationddTPhkþ ð T Ta Þ ¼ 0dxdxADiscretize the above equation by subdividing the computational domain into 5elements of equal size and find the values of the temperature field at the elementcentroids and boundaries in the following two situations:a.
T ðx ¼ 0Þ ¼ 200 C and T ðx ¼ LÞ ¼ 90 Cb. qðx ¼ 0Þ ¼ 20 kW=m2 and qðx ¼ LÞ ¼ 10 kW=m2where q is the rate of heat transfer given byq ¼ kdTdx8.12Exercises267TaFin1h (T2Ta )3P4A5LxddTkdxdxFig. 8.17 Computational domain for heat transfer from a finExercise 3The heat conduction in the two-dimensional domain shown in Fig. 8.18 is governedby the following differential equation:r krT ¼ 0The domain is subdivided into uniform elements and the boundary conditionsare as shown in the figure.a.
Derive the algebraic equations for all elements.b. Solve the system of equations obtained and compute the T values at the centroids of the elements.T = 250 CT = 225 C35T = 200 C24T = 100 CT n=061T n=03m1mT = 50 CFig. 8.18 Heat conduction in a two dimensional tilted Cartesian domain2688Spatial Discretization: The Diffusion Termc. Compute the values of T at the bottom and right boundaries.d.
Compute the net heat transfer through the top and left boundariesExercise 4Consider steady state conduction heat transfer in the non-orthogonal domain discretized into the four equal elements shown in Fig. 8.19, where L = 1 m. Derive thediscretization equations for the cells using two different methods for the decomposition of the diffusion flux and compare the temperature values at the elementcentroids after 4 coefficient iterations.T n=0=3TL40C31T n=0243T = 20 CLFig. 8.19 Computational domain for Exercise 4Exercise 5Discretize the equation −∇ · k∇T = QT where QT = 500 and k = 200, for the meshcomposed of quadrilateral triangles of side 0.1 shown in Fig.
8.20. Write thediscretized equations in the form of general algebraic equations.a= 40h = 10231bn=0b= 504Fig. 8.20 A triangular domain covered with an unstructured grid system8.12Exercises269Exercise 6The gradient for a variable ϕ over the computational domain shown in Fig. 8.21 isgiven byr/ ¼ 20i þ 30jCompute the value of ϕ at nodes 1 and 2 given that the length and width of thecomputational domain are 10 and 5 cm, respectively.= 20i + 30 j= 501= 25= 152= 20Fig.
8.21 A rectangular domain decomposed into two triangular elementsExercise 7Using the mesh constructed in exercise 3 of Chap. 7 (displayed in Fig. 7.12), setupa case in OpenFOAM® and uFVM to solve the diffusion equation subject to thefollowing conditions ðC/ ¼ 1Þ:Patch#1 ϕ = 1Patch#2 ϕ = 0Patch#3 ∇ϕ · n = 0Patch#4 h∞ = 1, ϕ∞ = 0.5Exercise 8Build an oblique parallelogram (size of horizontal side is 1 and size of oblique sideis 2 inclined at 60 degrees with respect to the horizontal) using blockMesh inOpenFOAM® with the boundary conditions shown in the figure below to solve thediffusion equation with no source term in two dimensions.
Generate a grid bydecomposing each side of the parallelogram into 50 equal segments. Setup the caseand using a diffusion coefficient of 1 compare the convergence history for the threedifferent approaches mentioned in this chapter to resolve the non-orthogonal termfor the diffusion equation (one at a time) in uFVM and in OpenFOAM®. Use anunder-relaxation factor of value 0.9 (Fig. 8.22).2708(0.2,0.2)Spatial Discretization: The Diffusion TermT=320(0.5,0.2)T=273T=320(0,0)T=273(0.3,0)Fig. 8.22 An oblique parallelogramExercise 9a. Use Doxygen [19] to find the list of all overloaded functions under the namefvmLaplacian and then under then name fvcLaplacian.b.