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-------------------------------------------------------------------------------
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 "helpBoundary.H"
31
32// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33
34namespace Foam
35{
36 namespace helpTypes
37 {
40 (
41 helpType,
43 dictionary,
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(word::null);
96 word fieldName(word::null);
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// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addNamedToRunTimeSelectionTable(baseType, thisType, argNames, lookupName)
Add to construction table with 'lookupName' as the key.
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:178
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
Definition: argList.C:324
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
Definition: argListI.H:323
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:335
virtual bool execute()
Calculate the output fields.
static wordList constraintTypes()
Return a list of all the constraint patch types.
Definition: fvPatch.C:91
This class provides help for boundary conditions (patch fields). When no additional arguments are giv...
virtual void init()
Initialise - typically setting static variables,.
virtual ~helpBoundary()
Destructor.
virtual void init()
Initialise - typically setting static variables,.
static const word null
An empty word.
Definition: word.H:80
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
faceListList boundary
dynamicFvMesh & mesh
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Namespace for OpenFOAM.
bool setEnv(const word &name, const std::string &value, const bool overwrite)
Set an environment variable, return true on success.
Definition: MSwindows.C:395
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:82
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
HashSet< word, Hash< word > > wordHashSet
A HashSet of words, uses string hasher.
Definition: HashSet.H:82
error FatalError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
Foam::argList args(argc, argv)