DarcyForchheimerTemplates.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2012-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
30 template<class RhoFieldType>
31 void Foam::porosityModels::DarcyForchheimer::apply
32 (
33  scalarField& Udiag,
34  vectorField& Usource,
35  const scalarField& V,
36  const RhoFieldType& rho,
37  const scalarField& mu,
38  const vectorField& U
39 ) const
40 {
41  forAll(cellZoneIDs_, zoneI)
42  {
43  const tensorField& dZones = D_[zoneI];
44  const tensorField& fZones = F_[zoneI];
45 
46  const labelList& cells = mesh_.cellZones()[cellZoneIDs_[zoneI]];
47 
48  forAll(cells, i)
49  {
50  const label celli = cells[i];
51  const label j = this->fieldIndex(i);
52  const tensor Cd =
53  mu[celli]*dZones[j] + (rho[celli]*mag(U[celli]))*fZones[j];
54 
55  const scalar isoCd = tr(Cd);
56 
57  Udiag[celli] += V[celli]*isoCd;
58  Usource[celli] -= V[celli]*((Cd - I*isoCd) & U[celli]);
59  }
60  }
61 }
62 
63 
64 template<class RhoFieldType>
65 void Foam::porosityModels::DarcyForchheimer::apply
66 (
67  tensorField& AU,
68  const RhoFieldType& rho,
69  const scalarField& mu,
70  const vectorField& U
71 ) const
72 {
73  forAll(cellZoneIDs_, zoneI)
74  {
75  const tensorField& dZones = D_[zoneI];
76  const tensorField& fZones = F_[zoneI];
77 
78  const labelList& cells = mesh_.cellZones()[cellZoneIDs_[zoneI]];
79 
80  forAll(cells, i)
81  {
82  const label celli = cells[i];
83  const label j = this->fieldIndex(i);
84  const tensor D = dZones[j];
85  const tensor F = fZones[j];
86 
87  AU[celli] += mu[celli]*D + (rho[celli]*mag(U[celli]))*F;
88  }
89  }
90 }
91 
92 
93 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:67
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
Foam::constant::physicoChemical::mu
const dimensionedScalar mu
Atomic mass unit.
Definition: createFieldRefs.H:4
Foam::tensorField
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
Definition: primitiveFieldsFwd.H:57
F
volVectorField F(fluid.F())
Foam::porosityModel::cellZoneIDs_
labelList cellZoneIDs_
Cell zone IDs.
Definition: porosityModel.H:93
rho
rho
Definition: readInitialConditions.H:88
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::vectorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
Definition: primitiveFieldsFwd.H:54
Foam::polyMesh::cellZones
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
Definition: polyMesh.H:492
U
U
Definition: pEqn.H:72
Foam::porosityModel::fieldIndex
label fieldIndex(const label index) const
Return label index.
Definition: porosityModelI.H:36
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
D
const dimensionedScalar & D
Definition: solveBulkSurfactant.H:4
cells
const cellShapeList & cells
Definition: gmvOutputHeader.H:3
Foam::tr
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
Definition: dimensionedSphericalTensor.C:51
Foam::tensor
Tensor< scalar > tensor
Tensor of scalars, i.e. Tensor<scalar>.
Definition: symmTensor.H:61
Foam::porosityModel::mesh_
const fvMesh & mesh_
Reference to the mesh database.
Definition: porosityModel.H:78
Foam::I
static const Identity< scalar > I
Definition: Identity.H:95