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-------------------------------------------------------------------------------
11License
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
33namespace Foam
34{
35 namespace fv
36 {
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{
130 {
131 return true;
132 }
133
134 return false;
135}
136
137
138// ************************************************************************* //
virtual bool read()
Re-read model coefficients if they have changed.
bool overlaps(const boundBox &bb) const
Overlaps/touches boundingBox?
Definition: boundBoxI.H:221
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:290
const word & name() const
Return reference to name.
Definition: fvMesh.H:310
Intermediate class for handling inter-region exchanges.
word nbrRegionName_
Name of the neighbour region to map.
autoPtr< meshToMesh > meshInterpPtr_
Mesh to mesh interpolation object.
void setMapper()
Set the mesh to mesh interpolation object.
bool master_
Master or slave region.
Base abstract class for handling finite volume options (i.e. fvOption).
Definition: fvOption.H:127
const fvMesh & mesh_
Reference to the mesh database.
Definition: fvOption.H:139
bool active() const noexcept
True if source is active.
Definition: fvOptionI.H:49
dictionary coeffs_
Dictionary containing source coefficients.
Definition: fvOption.H:145
Class to calculate the cell-addressing between two overlapping meshes.
Definition: meshToMesh.H:65
static const Enum< procMapMethod > procMapMethodNames_
Definition: meshToMesh.H:88
static const Enum< interpolationMethod > interpolationMethodNames_
Definition: meshToMesh.H:79
const Type & lookupObject(const word &name, const bool recursive=false) const
const boundBox & bounds() const
Return mesh bounding box.
Definition: polyMesh.H:462
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
dynamicFvMesh & mesh
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:342
error FatalError
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
labelList fv(nPoints)
dictionary dict