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 | Copyright (C) 2012-2015 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 "helpBoundary.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33  namespace helpTypes
34  {
35  defineTypeNameAndDebug(helpBoundary, 0);
37  (
38  helpType,
39  helpBoundary,
40  dictionary,
41  boundary
42  );
43  }
44 }
45 
46 
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 
50 {}
51 
52 
53 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
54 
56 {}
57 
58 
59 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
60 
62 {
64 
65  argList::validArgs.append("boundary");
66 
68  (
69  "field",
70  "word",
71  "list available conditions for field"
72  );
74  (
75  "constraint",
76  "list constraint patches"
77  );
79  (
80  "fixedValue",
81  "list fixed value patches (use with -field option)"
82  );
83 }
84 
85 
87 (
88  const argList& args,
89  const fvMesh& mesh
90 )
91 {
92  bool abortVar(env("FOAM_ABORT"));
93  if (abortVar)
94  {
96  << "Please unset FOAM_ABORT to use this utlity"
97  << exit(FatalError);
98  }
99 
100  word condition(word::null);
101  word fieldName(word::null);
102 
103  if (args.optionReadIfPresent("browse", condition))
104  {
105  // TODO: strip scoping info if present?
106  // e.g. conditions with leading "compressible::" will not be found
107  // ".*[fF]vPatchField.*" + className + ".*"
108  displayDoc(condition, ".*[fF]vPatchField.*", false);
109  }
110  else if (args.optionFound("constraint"))
111  {
112  HashSet<word> constraintTypes(fvPatch::constraintTypes());
113  Info<< "Constraint types:" << nl;
114  forAllConstIter(HashSet<word>, constraintTypes, iter)
115  {
116  Info<< " " << iter.key() << nl;
117  }
118  Info<< endl;
119  }
120  else if (args.optionReadIfPresent("field", fieldName))
121  {
122  IOobject fieldHeader
123  (
124  fieldName,
125  mesh.time().timeName(),
126  mesh,
128  );
129 
130  if (fieldHeader.headerOk())
131  {
132  if (args.optionFound("fixedValue"))
133  {
134  fixedValueFieldConditions<scalar>(fieldHeader);
135  fixedValueFieldConditions<vector>(fieldHeader);
136  fixedValueFieldConditions<sphericalTensor>(fieldHeader);
137  fixedValueFieldConditions<symmTensor>(fieldHeader);
138  fixedValueFieldConditions<tensor>(fieldHeader);
139  }
140  else
141  {
142  (void)fieldConditions<scalar>(fieldHeader, true);
143  (void)fieldConditions<vector>(fieldHeader, true);
144  (void)fieldConditions<sphericalTensor>(fieldHeader, true);
145  (void)fieldConditions<symmTensor>(fieldHeader, true);
146  (void)fieldConditions<tensor>(fieldHeader, true);
147  }
148  }
149  else
150  {
152  << "Unable to read field " << fieldName << exit(FatalError);
153  }
154  }
155  else if (args.optionReadIfPresent("fixedValue", fieldName))
156  {
158  << "-field option must be specified when using the -fixedValue "
159  << "option" << exit(FatalError);
160  }
161  else
162  {
163  // TODO: strip scoping info if present?
164  // e.g. conditions with leading "compressible::" will not be found
165  // ".*[fF]vPatchField.*" + className + ".*"
166  displayDocOptions(".*[fF]vPatchField.*", false);
167  }
168 }
169 
170 
171 // ************************************************************************* //
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
static SLList< string > validArgs
A list of valid (mandatory) arguments.
Definition: argList.H:154
Macros for easy insertion into run-time selection tables.
dynamicFvMesh & mesh
static void addOption(const word &opt, const string &param="", const string &usage="")
Add to an option to validOptions with usage information.
Definition: argList.C:93
static const word null
An empty word.
Definition: word.H:77
faceListList boundary(nPatches)
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:29
static const char nl
Definition: Ostream.H:262
defineTypeNameAndDebug(combustionModel, 0)
virtual void execute(const argList &args, const fvMesh &mesh)
Execute the help.
addNamedToRunTimeSelectionTable(GAMGProcAgglomeration, noneGAMGProcAgglomeration, GAMGAgglomeration, none)
virtual ~helpBoundary()
Destructor.
virtual void init()
Initialise - typically setting static variables,.
messageStream Info
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
Definition: argList.C:83
bool env(const word &)
Return true if environment variable of given name is defined.
Definition: POSIX.C:96
virtual void init()
Initialise - typically setting static variables,.
Namespace for OpenFOAM.
static wordList constraintTypes()
Return a list of all the constraint patch types.
Definition: fvPatch.C:67