Loading...
Searching...
No Matches
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> 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
71template<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
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// ************************************************************************* //
writer write("magLe", fld)
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
@ NO_REGISTER
Do not request registration (bool: false).
@ NO_READ
Nothing to be read.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
bool throwing() const noexcept
Return the current exception throwing state (on or off).
Definition error.H:223
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.
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
const auto & io
List< label > sortedToc(const UList< bool > &bools)
Return the (sorted) values corresponding to 'true' entries.
Definition BitOps.C:200
List< word > wordList
List of word.
Definition fileName.H:60
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:519
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
runTime write()
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299