helpBoundaryTemplates.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) 2012-2017 OpenFOAM Foundation
9  Copyright (C) 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 "GeometricField.H"
30 #include "fvPatchField.H"
31 #include "volMesh.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 template<class Type>
37 (
38  const IOobject& io,
39  const bool write
40 ) const
41 {
42  typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
43 
44  if (io.isHeaderClass<VolFieldType>())
45  {
46  wordList types
47  (
48  fvPatchField<Type>::dictionaryConstructorTablePtr_->sortedToc()
49  );
50 
51  if (write)
52  {
53  Info<< "Available boundary conditions for "
54  << pTraits<Type>::typeName << " field: " << io.name() << nl;
55 
56  forAll(types, i)
57  {
58  Info<< " " << types[i] << nl;
59  }
60 
61  Info<< endl;
62  }
63 
64  return types;
65  }
66 
67  return wordList();
68 }
69 
70 
71 template<class Type>
73 (
74  const IOobject& io
75 ) const
76 {
77  typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
78 
79  wordList types(fieldConditions<Type>(io, false));
80 
81  if (!types.size())
82  {
83  return;
84  }
85 
86  const fvMesh& mesh = dynamic_cast<const fvMesh&>(io.db());
87 
88  VolFieldType fld
89  (
90  IOobject
91  (
92  "dummy",
93  mesh.time().timeName(),
94  mesh,
98  ),
99  mesh,
100  dimensioned<Type>(dimless, Zero)
101  );
102 
103 
104  Info<< "Fixed value boundary conditions for "
105  << pTraits<Type>::typeName << " field: " << io.name() << nl;
106 
107  // throw exceptions to avoid fatal errors when casting from generic patch
108  // type to incompatible patch type
109  FatalIOError.throwing(true);
110  FatalError.throwing(true);
111 
112  bool foundFixed = false;
113  forAll(types, i)
114  {
115  const word& patchType = types[i];
116 
117  try
118  {
119  polyPatch pp
120  (
121  "defaultFaces",
122  0,
123  mesh.nInternalFaces(),
124  0,
125  mesh.boundaryMesh(),
126  patchType
127  );
128 
129  fvPatch fvp(pp, mesh.boundary());
130 
131  tmp<fvPatchField<Type>> pf
132  (
134  (
135  patchType,
136  fvp,
137  fld
138  )
139  );
140 
141  if (pf().fixesValue())
142  {
143  Info<< " " << patchType << nl;
144  foundFixed = true;
145  }
146  }
147  catch (...)
148  {}
149  }
150 
151  if (!foundFixed)
152  {
153  // no conditions???
154  Info<< " none" << nl;
155  }
156 
157  Info<< endl;
158 }
159 
160 
161 // ************************************************************************* //
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
bool throwing() const noexcept
Return the current exception throwing state (on or off)
Definition: error.H:223
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
Ignore writing from objectRegistry::writeObject()
const dimensionSet dimless
Dimensionless.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
dynamicFvMesh & mesh
void fixedValueFieldConditions(const IOobject &io) const
Output the available fixed boundary conditions for fields of Type.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
wordList fieldConditions(const IOobject &io, const bool write) const
Return/output the available boundary conditions for fields of Type.
List< word > wordList
List of word.
Definition: fileName.H:59
Nothing to be read.
List< label > sortedToc(const UList< bool > &bools)
Return the (sorted) values corresponding to &#39;true&#39; entries.
Definition: BitOps.C:195
messageStream Info
Information stream (stdout output on master, null elsewhere)
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
Do not request registration (bool: false)
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
static tmp< fvPatchField< Type > > New(const word &patchFieldType, const fvPatch &, const DimensionedField< Type, volMesh > &)
Return a pointer to a new patchField created on freestore given.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL IO ERROR&#39; header text and ...
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127