Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / finiteVolume / cfdTools / general / porousMedia / porousZones.C
blob6caf084303f4146f569475d214259b854da9a15b
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend 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 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "porousZones.H"
27 #include "foamTime.H"
28 #include "volFields.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 namespace Foam
34     defineTemplateTypeNameAndDebug(IOPtrList<porousZone>, 0);
37 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
39 Foam::porousZones::porousZones
41     const fvMesh& mesh
44     IOPtrList<porousZone>
45     (
46         IOobject
47         (
48             "porousZones",
49             mesh.time().constant(),
50             mesh,
51             IOobject::READ_IF_PRESENT,
52             IOobject::NO_WRITE
53         ),
54         porousZone::iNew(mesh)
55     ),
56     mesh_(mesh)
60 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
62 void Foam::porousZones::addResistance(fvVectorMatrix& UEqn) const
64     forAll(*this, i)
65     {
66         operator[](i).addResistance(UEqn);
67     }
71 void Foam::porousZones::addResistance
73     const fvVectorMatrix& UEqn,
74     volTensorField& AU
75 ) const
77     // addResistance for each zone, delaying the correction of the
78     // precessor BCs of AU
79     forAll(*this, i)
80     {
81         operator[](i).addResistance(UEqn, AU, false);
82     }
84     // Correct the boundary conditions of the tensorial diagonal to ensure
85     // processor bounaries are correctly handled when AU^-1 is interpolated
86     // for the pressure equation.
87     AU.correctBoundaryConditions();
91 bool Foam::porousZones::readData(Istream& is)
93     clear();
95     IOPtrList<porousZone> newLst
96     (
97         IOobject
98         (
99             "porousZones",
100             mesh_.time().constant(),
101             mesh_,
102             IOobject::MUST_READ,
103             IOobject::NO_WRITE,
104             false     // Don't re-register new zones with objectRegistry
105         ),
106         porousZone::iNew(mesh_)
107     );
109     transfer(newLst);
111     return is.good();
115 bool Foam::porousZones::writeData(Ostream& os, bool subDict) const
117     // Write size of list
118     os << nl << size();
120     // Write beginning of contents
121     os << nl << token::BEGIN_LIST;
123     // Write list contents
124     forAll(*this, i)
125     {
126         os << nl;
127         operator[](i).writeDict(os, subDict);
128     }
130     // Write end of contents
131     os << token::END_LIST << nl;
133     // Check state of IOstream
134     return os.good();
138 // ************************************************************************* //