Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
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 Classes
18 - Foam::fvMesh
19 - Foam::simplifiedMeshes::columnFvMesh
20
21Required Variables
22 - args [argList]
23 - runTime [Time]
24
25Provided Variables
26 - regionName [word]
27 - mesh [fvMesh]
28 - meshPtr [autoPtr<fvMesh>]
29
30\*---------------------------------------------------------------------------*/
31
33
34// "getRegionOption.H"
36(
37 args.getOrDefault<word>("region", Foam::polyMesh::defaultRegion)
38);
39
40if (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
49 meshPtr.reset
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}
74else
75{
76 Foam::Info << "Create mesh";
78 {
79 Foam::Info << ' ' << regionName;
80 }
81 Foam::Info << " for time = " << runTime.timeName() << Foam::nl;
82
83 meshPtr.reset
84 (
85 new Foam::fvMesh
86 (
88 (
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// ************************************************************************* //
static bool allowConstructFromLargerSize
Permit read construct from a larger size.
Definition Field.H:100
@ MUST_READ
Reading required.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
@ saNoWriteNow
Adjust endTime to stop immediately w/o writing.
Definition Time.H:99
@ saWriteNow
adjust endTime to stop immediately w/ writing
Definition Time.H:100
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
static word outputPrefix
Directory prefix.
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
static const word & regionName(const word &region)
The mesh region name or word::null if polyMesh::defaultRegion.
Definition polyMesh.C:796
static word defaultRegion
Return the default region name.
Definition polyMesh.H:406
Generates a 1D column representation of a mesh based on an existing mesh and/or fields.
A class for handling words, derived from Foam::string.
Definition word.H:66
dynamicFvMesh & mesh
engineTime & runTime
Foam::autoPtr< Foam::fvMesh > meshPtr(nullptr)
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
Foam::autoPtr< Foam::dynamicFvMesh > meshPtr
Foam::word regionName(args.getOrDefault< word >("region", 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:519
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
Foam::argList args(argc, argv)