geomDecomp.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-2017 OpenFOAM Foundation
9  Copyright (C) 2018 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 "geomDecomp.H"
30 
31 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32 
33 void Foam::geomDecomp::readCoeffs()
34 {
36  coeffsDict_.readEntry("n", n_);
37 
38  // Verify that the input makes sense
39  if (nDomains_ != n_.x()*n_.y()*n_.z())
40  {
42  << "Wrong number of domain divisions in geomDecomp:" << nl
43  << "Number of domains : " << nDomains_ << nl
44  << "Wanted decomposition : " << n_
45  << exit(FatalError);
46  }
47 
48  const scalar d = 1 - 0.5*delta_*delta_;
49  const scalar d2 = sqr(d);
50 
51  const scalar a = delta_;
52  const scalar a2 = sqr(a);
53 
55  (
56  d2, -a*d, a,
57  a*d - a2*d, a*a2 + d2, -2*a*d,
58  a*d2 + a2, a*d - a2*d, d2 - a2
59  );
60 }
61 
62 
64 (
65  const Vector<label>& meshDirs
66 ) const
67 {
68  for (direction dir = 0; dir < Vector<label>::nComponents; ++dir)
69  {
70  if (n_[dir] > 1 && meshDirs[dir] == -1)
71  {
73  << "Trying to decompose a 1/2D mesh"
74  << " into " << n_[dir]
75  << " parts in direction "
77  << endl;
78  }
79  }
80 }
81 
82 
83 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
84 
86 (
87  const word& derivedType,
88  const dictionary& decompDict,
89  int select
90 )
91 :
92  decompositionMethod(decompDict),
93  coeffsDict_(findCoeffsDict(derivedType + "Coeffs", select)),
94  n_(1,1,1),
95  delta_(0.001),
96  rotDelta_(I)
97 {
98  readCoeffs();
99 }
100 
101 
103 (
104  const word& derivedType,
105  const dictionary& decompDict,
106  const word& regionName,
107  int select
108 )
109 :
110  decompositionMethod(decompDict, regionName),
111  coeffsDict_(findCoeffsDict(derivedType + "Coeffs", select)),
112  n_(1,1,1),
113  delta_(0.001),
114  rotDelta_(I)
115 {
116  readCoeffs();
117 }
118 
119 
120 // ************************************************************************* //
Foam::decompositionMethod::nDomains_
label nDomains_
Number of domains for the decomposition.
Definition: decompositionMethod.H:95
Foam::Vector::x
const Cmpt & x() const
Access to the vector x component.
Definition: VectorI.H:73
geomDecomp.H
Foam::geomDecomp::rotDelta_
tensor rotDelta_
Definition: geomDecomp.H:93
Foam::geomDecomp::coeffsDict_
const dictionary & coeffsDict_
Coefficients for all derived methods.
Definition: geomDecomp.H:86
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::Vector::z
const Cmpt & z() const
Access to the vector z component.
Definition: VectorI.H:85
regionName
Foam::word regionName
Definition: createNamedDynamicFvMesh.H:1
Foam::geomDecomp::geomDecomp
geomDecomp(const word &derivedType, const dictionary &decompDict, int select=selectionType::DEFAULT)
Construct for derived type name and decomposition dictionary.
Definition: geomDecomp.C:86
Foam::geomDecomp::checkDecompositionDirections
void checkDecompositionDirections(const Vector< label > &) const
Check that mesh directions are compatible with decomposition.
Definition: geomDecomp.C:64
Foam::dictionary::readEntry
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
Definition: dictionaryTemplates.C:314
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:121
Foam::decompositionMethod
Abstract base class for domain decomposition.
Definition: decompositionMethod.H:51
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::Vector::y
const Cmpt & y() const
Access to the vector y component.
Definition: VectorI.H:79
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:381
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:51
Foam::nl
constexpr char nl
Definition: Ostream.H:385
Foam::Vector< label >
Foam::direction
uint8_t direction
Definition: direction.H:52
Foam::geomDecomp::delta_
scalar delta_
Default = 0.001.
Definition: geomDecomp.H:91
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:303
Foam::tensor
Tensor< scalar > tensor
Tensor of scalars, i.e. Tensor<scalar>.
Definition: symmTensor.H:61
Foam::dictionary::readIfPresent
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:417
Foam::I
static const Identity< scalar > I
Definition: Identity.H:95
Foam::geomDecomp::n_
Vector< label > n_
Definition: geomDecomp.H:88