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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "GeometricField.H"
29 #include "fvPatchField.H"
30 #include "volMesh.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 template<class Type>
36 (
37  const IOobject& io,
38  const bool write
39 ) const
40 {
41  typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
42 
43  if (io.headerClassName() == fieldType::typeName)
44  {
45  wordList types
46  (
47  fvPatchField<Type>::dictionaryConstructorTablePtr_->sortedToc()
48  );
49 
50  if (write)
51  {
52  Info<< "Available boundary conditions for "
53  << pTraits<Type>::typeName << " field: " << io.name() << nl;
54 
55  forAll(types, i)
56  {
57  Info<< " " << types[i] << nl;
58  }
59 
60  Info<< endl;
61  }
62 
63  return types;
64  }
65 
66  return wordList();
67 }
68 
69 
70 template<class Type>
72 (
73  const IOobject& io
74 ) const
75 {
76  wordList types(fieldConditions<Type>(io, false));
77 
78  if (!types.size())
79  {
80  return;
81  }
82 
83  typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
84 
85  const fvMesh& mesh = dynamic_cast<const fvMesh&>(io.db());
86 
87  fieldType fld
88  (
89  IOobject
90  (
91  "dummy",
92  mesh.time().timeName(),
93  mesh,
96  false
97  ),
98  mesh,
99  dimensioned<Type>(dimless, Zero)
100  );
101 
102 
103  Info<< "Fixed value boundary conditions for "
104  << pTraits<Type>::typeName << " field: " << io.name() << nl;
105 
106  // throw exceptions to avoid fatal errors when casting from generic patch
107  // type to incompatible patch type
110 
111  bool foundFixed = false;
112  forAll(types, i)
113  {
114  const word& patchType = types[i];
115 
116  try
117  {
118  polyPatch pp
119  (
120  "defaultFaces",
121  0,
122  mesh.nInternalFaces(),
123  0,
124  mesh.boundaryMesh(),
125  patchType
126  );
127 
128  fvPatch fvp(pp, mesh.boundary());
129 
130  tmp<fvPatchField<Type>> pf
131  (
133  (
134  patchType,
135  fvp,
136  fld
137  )
138  );
139 
140  if (pf().fixesValue())
141  {
142  Info<< " " << patchType << nl;
143  foundFixed = true;
144  }
145  }
146  catch (...)
147  {}
148  }
149 
150  if (!foundFixed)
151  {
152  // no conditions???
153  Info<< " none" << nl;
154  }
155 
156  Info<< endl;
157 }
158 
159 
160 // ************************************************************************* //
Foam::IOobject::NO_WRITE
Definition: IOobject.H:130
Foam::dimless
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Dimensionless.
Definition: dimensionSets.H:50
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
volMesh.H
Foam::helpTypes::helpBoundary::fixedValueFieldConditions
void fixedValueFieldConditions(const IOobject &io) const
Output the available fixed boundary conditions for fields of Type.
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:59
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
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
GeometricField.H
Foam::fvPatchField::New
static tmp< fvPatchField< Type > > New(const word &, const fvPatch &, const DimensionedField< Type, volMesh > &)
Return a pointer to a new patchField created on freestore given.
Definition: fvPatchFieldNew.C:88
Foam::nl
constexpr char nl
Definition: Ostream.H:385
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:102
Foam::vtk::write
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
Definition: foamVtkOutputTemplates.C:35
Foam::IOobject::NO_READ
Definition: IOobject.H:123
Foam::helpTypes::helpBoundary::fieldConditions
wordList fieldConditions(const IOobject &io, const bool write) const
Return/output the available boundary conditions for fields of Type.
Foam::error::throwExceptions
bool throwExceptions(bool doThrow)
Activate/deactivate exception throwing.
Definition: error.H:145
fvPatchField.H