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-------------------------------------------------------------------------------
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 "GeometricField.H"
30#include "fvPatchField.H"
31#include "volMesh.H"
32
33// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34
35template<class Type>
37(
38 const IOobject& io,
39 const bool write
40) const
41{
42 typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
43
44 if (io.headerClassName() == fieldType::typeName)
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
71template<class Type>
73(
74 const IOobject& io
75) const
76{
77 wordList types(fieldConditions<Type>(io, false));
78
79 if (!types.size())
80 {
81 return;
82 }
83
84 typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
85
86 const fvMesh& mesh = dynamic_cast<const fvMesh&>(io.db());
87
88 fieldType fld
89 (
90 IOobject
91 (
92 "dummy",
93 mesh.time().timeName(),
94 mesh,
97 false
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
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// ************************************************************************* //
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:65
const word & headerClassName() const noexcept
Return name of the class name read from header.
Definition: IOobjectI.H:83
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
bool throwing() const noexcept
Return the current exception throwing state (on or off)
Definition: error.H:169
wordList fieldConditions(const IOobject &io, const bool write) const
Return/output the available boundary conditions for fields of Type.
void fixedValueFieldConditions(const IOobject &io) const
Output the available fixed boundary conditions for fields of Type.
dynamicFvMesh & mesh
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
List< label > sortedToc(const UList< bool > &bools)
Return the (sorted) values corresponding to 'true' entries.
Definition: BitOps.C:203
List< word > wordList
A List of words.
Definition: fileName.H:63
const dimensionSet dimless
Dimensionless.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
IOerror FatalIOError
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
error FatalError
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
runTime write()
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333