MRFPatchField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2022 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "MRFPatchField.H"
27 #include "IOMRFZoneList.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
32 {}
33 
34 
36 :
37  MRFZoneName_(dict.lookupOrDefault("MRFZoneName", word::null))
38 {}
39 
40 
41 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
42 
44 (
45  const objectRegistry& obr
46 ) const
47 {
48  // Get reference to the MRF model
49  const MRFZoneList& mrf =
50  obr.lookupObject<IOMRFZoneList>("MRFProperties");
51 
52  if (MRFZoneName_ != word::null)
53  {
54  forAll(mrf, i)
55  {
56  if (mrf[i].name() == MRFZoneName_)
57  {
58  return mrf[i];
59  }
60  }
61 
63  << "Cannot find MRF zone " << MRFZoneName_
64  << exit(FatalError);
65  }
66  else if (mrf.size() == 1)
67  {
68  return mrf[0];
69  }
70  else if (mrf.size() == 0)
71  {
73  << "There are no MRF zones"
74  << exit(FatalError);
75  }
76  else
77  {
79  << "MRFZoneName not specified"
80  << exit(FatalError);
81  }
82 
83  return mrf[0];
84 }
85 
86 
88 {
89  MRFzone(Up.db()).makeAbsolute(Up, Up.patch().index());
90 }
91 
92 
94 {
95  MRFzone(Up.db()).makeRelative(Up, Up.patch().index());
96 }
97 
98 
100 {
101  if (MRFZoneName_ != word::null)
102  {
103  writeEntry(os, "MRFZoneName", MRFZoneName_);
104  }
105 }
106 
107 
108 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
List of MRF zones with IO functionality. MRF zones are specified by a list of dictionary entries,...
Definition: IOMRFZoneList.H:68
void makeRelative(fvPatchField< vector > &Up) const
Definition: MRFPatchField.C:93
void makeAbsolute(fvPatchField< vector > &Up) const
Definition: MRFPatchField.C:87
void write(Ostream &) const
Definition: MRFPatchField.C:99
MRFPatchField()
Construct null.
Definition: MRFPatchField.C:31
const MRFZone & MRFzone(const objectRegistry &obr) const
Definition: MRFPatchField.C:44
List container for MRF zones.
Definition: MRFZoneList.H:58
MRF zone definition based on cell zone and parameters obtained from a control dictionary constructed ...
Definition: MRFZone.H:56
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:87
const objectRegistry & db() const
Return local objectRegistry.
Definition: fvPatchField.C:145
const fvPatch & patch() const
Return patch.
Definition: fvPatchField.H:355
label index() const
Return the index of this patch in the fvBoundaryMesh.
Definition: fvPatch.H:175
Registry of regIOobjects.
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type and name.
A class for handling words, derived from string.
Definition: word.H:62
static const word null
An empty word.
Definition: word.H:77
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
error FatalError
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
dictionary dict