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 | Copyright (C) 2012-2016 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "GeometricField.H"
27 #include "fvPatchField.H"
28 #include "volMesh.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 template<class Type>
34 (
35  const IOobject& io,
36  const bool write
37 ) const
38 {
39  typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
40 
41  if (io.headerClassName() == fieldType::typeName)
42  {
43  wordList types
44  (
45  fvPatchField<Type>::dictionaryConstructorTablePtr_->sortedToc()
46  );
47 
48  if (write)
49  {
50  Info<< "Available boundary conditions for "
51  << pTraits<Type>::typeName << " field: " << io.name() << nl;
52 
53  forAll(types, i)
54  {
55  Info<< " " << types[i] << nl;
56  }
57 
58  Info<< endl;
59  }
60 
61  return types;
62  }
63 
64  return wordList();
65 }
66 
67 
68 template<class Type>
70 (
71  const IOobject& io
72 ) const
73 {
74  wordList types(fieldConditions<Type>(io, false));
75 
76  if (!types.size())
77  {
78  return;
79  }
80 
81  typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
82 
83  const fvMesh& mesh = dynamic_cast<const fvMesh&>(io.db());
84 
85  fieldType fld
86  (
87  IOobject
88  (
89  "dummy",
90  mesh.time().timeName(),
91  mesh,
94  false
95  ),
96  mesh,
97  dimensioned<Type>("zero", dimless, Zero)
98  );
99 
100 
101  Info<< "Fixed value boundary conditions for "
102  << pTraits<Type>::typeName << " field: " << io.name() << nl;
103 
104  // throw exceptions to avoid fatal errors when casting from generic patch
105  // type to incompatible patch type
108 
109  bool foundFixed = false;
110  forAll(types, i)
111  {
112  const word& patchType = types[i];
113 
114  try
115  {
116  polyPatch pp
117  (
118  "defaultFaces",
119  0,
120  mesh.nInternalFaces(),
121  0,
122  mesh.boundaryMesh(),
123  patchType
124  );
125 
126  fvPatch fvp(pp, mesh.boundary());
127 
128  tmp<fvPatchField<Type>> pf
129  (
131  (
132  patchType,
133  fvp,
134  fld
135  )
136  );
137 
138  if (pf().fixesValue())
139  {
140  Info<< " " << patchType << nl;
141  foundFixed = true;
142  }
143  }
144  catch (...)
145  {
146  // do nothing
147  }
148  }
149 
150  if (!foundFixed)
151  {
152  // no conditions???
153  Info<< " none" << nl;
154  }
155 
156  Info<< endl;
157 }
158 
159 
160 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
error FatalError
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
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
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().x()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().y()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().z()<< ' ';}gmvFile<< nl;forAll(lagrangianScalarNames, i){const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
void throwExceptions()
Definition: error.H:122
static tmp< fvPatchField< Type > > New(const word &, const fvPatch &, const DimensionedField< Type, volMesh > &)
Return a pointer to a new patchField created on freestore given.
static const zero Zero
Definition: zero.H:91
static const char nl
Definition: Ostream.H:262
List< word > wordList
A List of words.
Definition: fileName.H:54
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:47
messageStream Info
IOerror FatalIOError