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 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 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  defineTypeNameAndDebug(blockEdge, 0);
37  defineRunTimeSelectionTable(blockEdge, Istream);
38 }
39 
40 
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 
44 (
45  const pointField& points,
46  const label start,
47  const label end
48 )
49 :
50  points_(points),
51  start_(start),
52  end_(end)
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 cstrIter = IstreamConstructorTablePtr_->cfind(edgeType);
91 
92  if (!cstrIter.found())
93  {
95  (
96  dict,
97  "blockEdge",
98  edgeType,
99  *IstreamConstructorTablePtr_
100  ) << abort(FatalIOError);
101  }
102 
103  return autoPtr<blockEdge>(cstrIter()(dict, index, geometry, points, is));
104 }
105 
106 
107 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
108 
110 (
111  const pointField& points,
112  const label start,
113  const label end,
114  const pointField& otherKnots
115 )
116 {
117  pointField allKnots(otherKnots.size() + 2);
118 
119  // Start/end knots
120  allKnots[0] = points[start];
121  allKnots[otherKnots.size() + 1] = points[end];
122 
123  // Intermediate knots
124  forAll(otherKnots, knotI)
125  {
126  allKnots[knotI+1] = otherKnots[knotI];
127  }
128 
129  return allKnots;
130 }
131 
132 
135 {
136  tmp<pointField> tpoints(new pointField(lambdas.size()));
137  pointField& points = tpoints.ref();
138 
139  forAll(lambdas, i)
140  {
141  points[i] = position(lambdas[i]);
142  }
143  return tpoints;
144 }
145 
146 
147 void Foam::blockEdge::write(Ostream& os, const dictionary& d) const
148 {
149  blockVertex::write(os, start_, d);
150  os << tab;
151  blockVertex::write(os, end_, d);
152  os << endl;
153 }
154 
155 
156 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
157 
159 {
160  os << p.start_ << tab << p.end_ << endl;
161 
162  return os;
163 }
164 
165 
166 // ************************************************************************* //
Foam::pointField
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::blockEdge::appendEndPoints
static pointField appendEndPoints(const pointField &, const label start, const label end, const pointField &otherKnots)
Return a complete point field by appending the start/end points.
Definition: blockEdge.C:110
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Foam::blockEdge::blockEdge
blockEdge(const pointField &points, const label start, const label end)
Construct from components.
Definition: blockEdge.C:44
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
Foam::blockEdge
Define a curved edge that is parameterized for 0<lambda<1 between the start and end point.
Definition: blockEdge.H:59
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:419
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:258
FatalIOErrorInLookup
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:380
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
Foam::Field< vector >
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
DebugInFunction
#define DebugInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:356
Foam::blockMeshTools::read
void read(Istream &, label &, const dictionary &)
In-place read with dictionary lookup.
Definition: blockMeshTools.C:33
dict
dictionary dict
Definition: searchingEngine.H:14
blockVertex.H
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
stdFoam::end
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
Definition: stdFoam.H:115
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:137
Foam::blockEdge::New
static autoPtr< blockEdge > New(const dictionary &dict, const label index, const searchableSurfaces &geometry, const pointField &, Istream &)
New function which constructs and returns pointer to a blockEdge.
Definition: blockEdge.C:78
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::tab
constexpr char tab
Definition: Ostream.H:371
Foam::List< scalar >
Foam::searchableSurfaces
Container for searchableSurfaces. The collection is specified as a dictionary. For example,...
Definition: searchableSurfaces.H:92
Foam::start
label ListType::const_reference const label start
Definition: ListOps.H:408
Foam::blockEdge::clone
virtual autoPtr< blockEdge > clone() const
Clone function.
Definition: blockEdge.C:70
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::blockEdge::write
void write(Ostream &, const dictionary &) const
Write edge with variable backsubstitution.
Definition: blockEdge.C:147
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::blockVertex::write
static void write(Ostream &, const label, const dictionary &)
Write vertex index with optional name backsubstitution.
Definition: blockVertex.C:118
blockEdge.H
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::blockEdge::position
virtual point position(const scalar) const =0
Return the point position corresponding to the curve parameter.
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &)
Definition: boundaryPatch.C:102