interRegionOption.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 | Copyright (C) 2011-2015 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 "interRegionOption.H"
27 
28 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
32 namespace fv
33 {
34  defineTypeNameAndDebug(interRegionOption, 0);
35 }
36 }
37 
38 
39 // * * * * * * * * * * * * Protected member functions * * * * * * * * * * * //
40 
42 {
43  if (master_)
44  {
45  Info<< indent << "- selecting inter region mapping" << endl;
46 
47  const fvMesh& nbrMesh =
48  mesh_.time().lookupObject<fvMesh>(nbrRegionName_);
49 
50  if (mesh_.name() == nbrMesh.name())
51  {
52  FatalErrorIn("interRegionOption::setCellIds()")
53  << "Inter-region model selected, but local and "
54  << "neighbour regions are the same: " << nl
55  << " local region: " << mesh_.name() << nl
56  << " secondary region: " << nbrMesh.name() << nl
57  << exit(FatalError);
58  }
59 
60  if (mesh_.bounds().overlaps(nbrMesh.bounds()))
61  {
62  meshInterpPtr_.reset
63  (
64  new meshToMesh
65  (
66  mesh_,
67  nbrMesh,
69  (
70  coeffs_.lookup("interpolationMethod")
71  ),
72  false // not interpolating patches
73  )
74  );
75  }
76  else
77  {
78  FatalErrorIn("interRegionOption::setCellSet()")
79  << "regions " << mesh_.name() << " and "
80  << nbrMesh.name() << " do not intersect"
81  << exit(FatalError);
82  }
83  }
84 }
85 
86 
87 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
88 
90 (
91  const word& name,
92  const word& modelType,
93  const dictionary& dict,
94  const fvMesh& mesh
95 )
96 :
97  option
98  (
99  name,
100  modelType,
101  dict,
102  mesh
103  ),
104  master_(coeffs_.lookupOrDefault<bool>("master", true)),
105  nbrRegionName_(coeffs_.lookup("nbrRegionName")),
106  meshInterpPtr_()
107 {
108  if (active())
109  {
110  setMapper();
111  }
112 }
113 
114 
115 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
116 
118 {}
119 
120 
121 // ************************************************************************* //
defineTypeNameAndDebug(cellSetOption, 0)
Finite volume options abtract base class. Provides a base set of controls, e.g.
Definition: fvOption.H:65
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
const word & name() const
Return reference to name.
Definition: fvMesh.H:257
interRegionOption(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from dictionary.
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:221
A class for handling words, derived from string.
Definition: word.H:59
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
messageStream Info
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
static const NamedEnum< interpolationMethod, 3 > interpolationMethodNames_
Definition: meshToMesh.H:75
Namespace for OpenFOAM.
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:243
static const char nl
Definition: Ostream.H:260
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
virtual ~interRegionOption()
Destructor.
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
error FatalError
const boundBox & bounds() const
Return mesh bounding box.
Definition: polyMesh.H:427
labelList fv(nPoints)
void setMapper()
Set the mesh to mesh interpolation object.
bool read(const char *, int32_t &)
Definition: int32IO.C:87
Class to calculate the cell-addressing between two overlapping meshes.
Definition: meshToMesh.H:60