helpBoundary.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-2014 OpenFOAM Foundation
9  Copyright (C) 2015 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 "helpBoundary.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  namespace helpTypes
37  {
38  defineTypeNameAndDebug(helpBoundary, 0);
40  (
41  helpType,
42  helpBoundary,
43  dictionary,
44  boundary
45  );
46  }
47 }
48 
49 
50 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
51 
53 {}
54 
55 
56 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
57 
59 {}
60 
61 
62 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
63 
65 {
67 
69  (
70  "field",
71  "word",
72  "List available conditions for field"
73  );
75  (
76  "constraint",
77  "List constraint patches"
78  );
80  (
81  "fixedValue",
82  "List fixed value patches (use with -field option)"
83  );
84 }
85 
86 
88 (
89  const argList& args,
90  const fvMesh& mesh
91 )
92 {
93  setEnv("FOAM_ABORT", "", true);
94 
95  word condition;
96  word fieldName;
97 
98  if (args.readIfPresent("browse", condition))
99  {
100  // TODO: strip scoping info if present?
101  // e.g. conditions with leading "compressible::" will not be found
102  // ".*[fF]vPatchField.*" + className + ".*"
103  displayDoc(condition, ".*[fF]vPatchField.*", false, "H");
104  }
105  else if (args.found("constraint"))
106  {
107  wordHashSet constraintTypes(fvPatch::constraintTypes());
108  Info<< "Constraint types:" << nl;
109  for (const word& cType : constraintTypes)
110  {
111  Info<< " " << cType << nl;
112  }
113  Info<< endl;
114  }
115  else if (args.readIfPresent("field", fieldName))
116  {
117  IOobject fieldHeader
118  (
119  fieldName,
120  mesh.time().timeName(),
121  mesh,
123  );
124 
125  // Check for any type of volField
126  if (fieldHeader.typeHeaderOk<volScalarField>(false))
127  {
128  if (args.found("fixedValue"))
129  {
130  fixedValueFieldConditions<scalar>(fieldHeader);
131  fixedValueFieldConditions<vector>(fieldHeader);
132  fixedValueFieldConditions<sphericalTensor>(fieldHeader);
133  fixedValueFieldConditions<symmTensor>(fieldHeader);
134  fixedValueFieldConditions<tensor>(fieldHeader);
135  }
136  else
137  {
138  (void)fieldConditions<scalar>(fieldHeader, true);
139  (void)fieldConditions<vector>(fieldHeader, true);
140  (void)fieldConditions<sphericalTensor>(fieldHeader, true);
141  (void)fieldConditions<symmTensor>(fieldHeader, true);
142  (void)fieldConditions<tensor>(fieldHeader, true);
143  }
144  }
145  else
146  {
148  << "Unable to read field " << fieldName << exit(FatalError);
149  }
150  }
151  else if (args.readIfPresent("fixedValue", fieldName))
152  {
154  << "-field option must be specified when using the -fixedValue "
155  << "option" << exit(FatalError);
156  }
157  else
158  {
159  // TODO: strip scoping info if present?
160  // e.g. conditions with leading "compressible::" will not be found
161  // ".*[fF]vPatchField.*" + className + ".*"
162  displayDocOptions(".*[fF]vPatchField.*", false, "H");
163  }
164 }
165 
166 
167 // ************************************************************************* //
faceListList boundary
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:608
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
Definition: argList.C:374
Macros for easy insertion into run-time selection tables.
addNamedToRunTimeSelectionTable(topoSetCellSource, badQualityToCell, word, badQuality)
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:72
dynamicFvMesh & mesh
static void addOption(const word &optName, const string &param="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
Definition: argList.C:385
HashSet< word, Hash< word > > wordHashSet
A HashSet of words, uses string hasher.
Definition: HashSet.H:73
defineTypeNameAndDebug(combustionModel, 0)
virtual void execute(const argList &args, const fvMesh &mesh)
Execute the help.
virtual ~helpBoundary()
Destructor.
virtual void init()
Initialise - typically setting static variables,.
messageStream Info
Information stream (stdout output on master, null elsewhere)
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
Definition: argListI.H:316
Foam::argList args(argc, argv)
virtual void init()
Initialise - typically setting static variables,.
bool setEnv(const word &name, const std::string &value, const bool overwrite)
Set an environment variable, return true on success.
Definition: POSIX.C:356
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:171
Namespace for OpenFOAM.
static wordList constraintTypes()
Return a list of all the constraint patch types.
Definition: fvPatch.C:85