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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2015 OpenFOAM Foundation
9  Copyright (C) 2018-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "interRegionOption.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  namespace fv
36  {
37  defineTypeNameAndDebug(interRegionOption, 0);
38  }
39 }
40 
41 
42 // * * * * * * * * * * * * Protected member functions * * * * * * * * * * * //
43 
45 {
46  if (master_)
47  {
48  Info<< indent << "- selecting inter region mapping" << endl;
49 
50  const auto& nbrMesh = mesh_.time().lookupObject<fvMesh>(nbrRegionName_);
51 
52  if (mesh_.name() == nbrMesh.name())
53  {
55  << "Inter-region model selected, but local and "
56  << "neighbour regions are the same: " << nl
57  << " local region: " << mesh_.name() << nl
58  << " secondary region: " << nbrMesh.name() << nl
59  << exit(FatalError);
60  }
61 
62  if (mesh_.bounds().overlaps(nbrMesh.bounds()))
63  {
64  meshInterpPtr_.reset
65  (
66  new meshToMesh
67  (
68  mesh_,
69  nbrMesh,
71  (
72  "interpolationMethod",
73  coeffs_,
75  ),
77  (
78  "procMapMethod",
79  coeffs_,
81  ),
82  false // not interpolating patches
83  )
84  );
85  }
86  else
87  {
89  << "regions " << mesh_.name() << " and "
90  << nbrMesh.name() << " do not intersect"
91  << exit(FatalError);
92  }
93  }
94 }
95 
96 
97 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
98 
100 (
101  const word& name,
102  const word& modelType,
103  const dictionary& dict,
104  const fvMesh& mesh
105 )
106 :
107  option
108  (
109  name,
110  modelType,
111  dict,
112  mesh
113  ),
114  master_(coeffs_.getOrDefault("master", true)),
115  nbrRegionName_(coeffs_.get<word>("nbrRegion")),
116  meshInterpPtr_()
117 {
118  if (active())
119  {
120  setMapper();
121  }
122 }
123 
124 
125 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
126 
128 {
129  if (fv::option::read(dict))
130  {
131  return true;
132  }
133 
134  return false;
135 }
136 
137 
138 // ************************************************************************* //
Foam::meshToMesh::interpolationMethodNames_
static const Enum< interpolationMethod > interpolationMethodNames_
Definition: meshToMesh.H:79
Foam::fv::interRegionOption::nbrRegionName_
word nbrRegionName_
Name of the neighbour region to map.
Definition: interRegionOption.H:119
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::fv::interRegionOption::setMapper
void setMapper()
Set the mesh to mesh interpolation object.
Definition: interRegionOption.C:44
Foam::meshToMesh::interpolationMethod::imCellVolumeWeight
Foam::meshToMesh::procMapMethodNames_
static const Enum< procMapMethod > procMapMethodNames_
Definition: meshToMesh.H:88
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::fv::interRegionOption::master_
bool master_
Master or slave region.
Definition: interRegionOption.H:116
Foam::fv::option::mesh_
const fvMesh & mesh_
Reference to the mesh database.
Definition: fvOption.H:139
Foam::boundBox::overlaps
bool overlaps(const boundBox &bb) const
Overlaps/touches boundingBox?
Definition: boundBoxI.H:221
Foam::meshToMesh
Class to calculate the cell-addressing between two overlapping meshes.
Definition: meshToMesh.H:64
Foam::fv::option
Base abstract class for handling finite volume options (i.e. fvOption).
Definition: fvOption.H:126
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
interRegionOption.H
Foam::fv::option::coeffs_
dictionary coeffs_
Dictionary containing source coefficients.
Definition: fvOption.H:145
Foam::fv::interRegionOption::meshInterpPtr_
autoPtr< meshToMesh > meshInterpPtr_
Mesh to mesh interpolation object.
Definition: interRegionOption.H:122
Foam::objectRegistry::lookupObject
const Type & lookupObject(const word &name, const bool recursive=false) const
Definition: objectRegistryTemplates.C:434
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::indent
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:339
Foam::meshToMesh::procMapMethod::pmAABB
Foam::fv::option::read
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: fvOptionIO.C:55
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::polyMesh::bounds
const boundBox & bounds() const
Return mesh bounding box.
Definition: polyMesh.H:450
fv
labelList fv(nPoints)
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::fvMesh::time
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:280
Foam::fv::defineTypeNameAndDebug
defineTypeNameAndDebug(atmAmbientTurbSource, 0)
Foam::fv::interRegionOption::interRegionOption
interRegionOption(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from dictionary.
Definition: interRegionOption.C:100
Foam::fv::interRegionOption::read
virtual bool read(const dictionary &dict)
Read dictionary.
Definition: interRegionOption.C:127
Foam::fvMesh::name
const word & name() const
Return reference to name.
Definition: fvMesh.H:300