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