createMesh.H
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) 2018-2023 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
12 
13 Description
14  Create a fvMesh (specified region or defaultRegion) with
15  additional handling of -dry-run and -dry-run-write options.
16 
17 Required Classes
18  - Foam::fvMesh
19  - Foam::simplifiedMeshes::columnFvMesh
20 
21 Required Variables
22  - args [argList]
23  - runTime [Time]
24 
25 Provided Variables
26  - regionName [word]
27  - mesh [fvMesh]
28  - meshPtr [autoPtr<fvMesh>]
29 
30 \*---------------------------------------------------------------------------*/
31 
33 
34 // "getRegionOption.H"
36 (
38 );
39 
40 if (args.dryRun() || args.found("dry-run-write"))
41 {
43  << "Operating in 'dry-run' mode: case will run for 1 time step. "
44  << "All checks assumed OK on a clean exit" << Foam::endl;
45 
47 
48  // Create a simplified 1D mesh and attempt to re-create boundary conditions
50  (
52  );
53 
54  // Stop after 1 iteration of the simplified mesh
55 
56  if (args.found("dry-run-write"))
57  {
58  // Using saWriteNow triggers function objects execute(), write()
60 
61  // Make sure mesh gets output to the current time (since instance
62  // no longer constant)
63  meshPtr().setInstance(runTime.timeName());
64  }
65  else
66  {
67  // Using saNoWriteNow triggers function objects execute(),
68  // but not write()
70  }
71 
72  Foam::functionObject::outputPrefix = "postProcessing-dry-run";
73 }
74 else
75 {
76  Foam::Info << "Create mesh";
78  {
79  Foam::Info << ' ' << regionName;
80  }
81  Foam::Info << " for time = " << runTime.timeName() << Foam::nl;
82 
84  (
85  new Foam::fvMesh
86  (
88  (
89  regionName,
90  runTime.timeName(),
91  runTime,
93  ),
94  false
95  )
96  );
97  meshPtr().init(true); // initialise all (lower levels and current)
98 
100 }
101 
103 
104 
105 // ************************************************************************* //
Generates a 1D column representation of a mesh based on an existing mesh and/or fields.
Definition: columnFvMesh.H:160
adjust endTime to stop immediately w/ writing
Definition: Time.H:101
const word & regionName() const
The mesh region name or word::null if polyMesh::defaultRegion.
Definition: polyMesh.C:847
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
T getOrDefault(const word &optName, const T &deflt) const
Get a value from the named option if present, or return default.
Definition: argListI.H:300
Foam::autoPtr< Foam::fvMesh > meshPtr(nullptr)
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
Definition: autoPtrI.H:37
dynamicFvMesh & mesh
A class for handling words, derived from Foam::string.
Definition: word.H:63
int dryRun() const noexcept
Return the dry-run flag.
Definition: argListI.H:109
static word defaultRegion
Return the default region name.
Definition: polyMesh.H:405
Adjust endTime to stop immediately w/o writing.
Definition: Time.H:100
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
static word outputPrefix
Directory prefix.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
static bool allowConstructFromLargerSize
Permit read construct from a larger size.
Definition: Field.H:93
Foam::argList args(argc, argv)
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:171