blockEdge.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-2016 OpenFOAM Foundation
9  Copyright (C) 2019-2021 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 "blockEdge.H"
30 #include "blockVertex.H"
31 #include "polyLine.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  defineTypeNameAndDebug(blockEdge, 0);
39 }
40 
41 
42 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43 
45 (
46  const pointField& points,
47  const edge& fromTo
48 )
49 :
50  points_(points),
51  start_(fromTo.first()),
52  end_(fromTo.last())
53 {}
54 
55 
57 (
58  const dictionary& dict,
59  const label index,
60  const pointField& points,
61  Istream& is
62 )
63 :
64  points_(points),
65  start_(blockVertex::read(is, dict)),
66  end_(blockVertex::read(is, dict))
67 {}
68 
69 
71 {
73  return nullptr;
74 }
75 
76 
78 (
79  const dictionary& dict,
80  const label index,
81  const searchableSurfaces& geometry,
82  const pointField& points,
83  Istream& is
84 )
85 {
86  DebugInFunction << "Constructing blockEdge" << endl;
87 
88  const word edgeType(is);
89 
90  auto* ctorPtr = IstreamConstructorTable(edgeType);
91 
92  if (!ctorPtr)
93  {
95  (
96  dict,
97  "blockEdge",
98  edgeType,
99  *IstreamConstructorTablePtr_
100  ) << abort(FatalIOError);
101  }
102 
103  return autoPtr<blockEdge>(ctorPtr(dict, index, geometry, points, is));
104 }
105 
106 
107 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
108 
110 (
111  const pointField& p,
112  const label from,
113  const label to,
114  const pointField& intermediate
115 )
116 {
117  return pointField(polyLine::concat(p[from], intermediate, p[to]));
118 }
119 
120 
121 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
122 
124 Foam::blockEdge::position(const scalarList& lambdas) const
125 {
126  auto tpoints = tmp<pointField>::New(lambdas.size());
127  auto& points = tpoints.ref();
128 
129  forAll(lambdas, i)
130  {
131  points[i] = position(lambdas[i]);
132  }
133  return tpoints;
134 }
135 
136 
137 void Foam::blockEdge::write(Ostream& os, const dictionary& dict) const
138 {
139  blockVertex::write(os, start_, dict);
140  os << tab;
142  os << endl;
143 }
144 
145 
146 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
147 
148 Foam::Ostream& Foam::operator<<(Ostream& os, const blockEdge& e)
149 {
150  os << e.start_ << tab << e.end_ << endl;
151 
152  return os;
153 }
154 
155 
156 // ************************************************************************* //
dictionary dict
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
blockEdge(const pointField &points, const label from, const label to)
Construct from components.
Definition: blockEdge.H:106
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
constexpr char tab
The tab &#39;\t&#39; character(0x09)
Definition: Ostream.H:49
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
static autoPtr< blockEdge > New(const dictionary &dict, const label index, const searchableSurfaces &geometry, const pointField &points, Istream &is)
New function which constructs and returns pointer to a blockEdge.
Definition: blockEdge.C:71
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:38
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
virtual point position(const scalar lambda) const =0
The point position corresponding to the curve parameter.
const pointField & points
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
Definition: edge.H:59
static pointField appendEndPoints(const pointField &p, const label from, const label to, const pointField &intermediate)
Return a complete point field by appending the start/end points to the given list.
Definition: blockEdge.C:103
A class for handling words, derived from Foam::string.
Definition: word.H:63
#define DebugInFunction
Report an information message using Foam::Info.
Container for searchableSurfaces. The collection is specified as a dictionary. For example...
void write(Ostream &os, const dictionary &dict) const
Write edge with variable back-substitution.
Definition: blockEdge.C:130
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
Definition: tmp.H:206
errorManip< error > abort(error &err)
Definition: errorManip.H:139
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
virtual autoPtr< blockEdge > clone() const
Clone function.
Definition: blockEdge.C:63
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
void read(Istream &, label &val, const dictionary &)
In-place read with dictionary lookup.
OBJstream os(runTime.globalPath()/outputName)
Define a block vertex.
Definition: blockVertex.H:47
defineTypeNameAndDebug(combustionModel, 0)
static tmp< pointField > concat(const point &start, const pointField &intermediate, const point &end)
Concatenate begin, intermediate and end points.
Definition: polyLine.C:28
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:77
Define a curved edge that is parameterized for 0<lambda<1 between the start/end points.
Definition: blockEdge.H:60
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
volScalarField & p
A class for managing temporary objects.
Definition: HashPtrTable.H:50
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:686
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:635
static void write(Ostream &, const label, const dictionary &)
Write vertex index with optional name backsubstitution.
Definition: blockVertex.C:111
Namespace for OpenFOAM.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL IO ERROR&#39; header text and ...