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> 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 
71 template<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
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 // ************************************************************************* //
Foam::IOobject::NO_WRITE
@ NO_WRITE
Definition: IOobject.H:191
Foam::Zero
static constexpr const zero Zero
Definition: zero.H:131
volMesh.H
Foam::helpTypes::helpBoundary::fixedValueFieldConditions
void fixedValueFieldConditions(const IOobject &io) const
Foam::error::throwing
bool throwing() const noexcept
Definition: error.H:165
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Definition: Ostream.H:381
forAll
#define forAll(list, i)
Definition: stdFoam.H:349
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:58
Foam::Info
messageStream Info
fld
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))
Definition: gmvOutputLagrangian.H:23
Foam::FatalError
error FatalError
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvPatchField< Type >::New
static tmp< fvPatchField< Type > > New(const word &, const fvPatch &, const DimensionedField< Type, volMesh > &)
GeometricField.H
Foam::nl
constexpr char nl
Definition: Ostream.H:424
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:58
Foam::vtk::write
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Definition: foamVtkOutputTemplates.C:29
Foam::IOobject::NO_READ
@ NO_READ
Definition: IOobject.H:184
Foam::helpTypes::helpBoundary::fieldConditions
wordList fieldConditions(const IOobject &io, const bool write) const
Foam::dimless
const dimensionSet dimless
Definition: dimensionSets.C:182
fvPatchField.H