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 -------------------------------------------------------------------------------
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 Variables
18  - args [argList]
19  - runTime [Time]
20 
21 Provided Variables
22  - regionName [word]
23  - mesh [fvMesh]
24  - meshPtr [autoPtr<fvMesh>]
25 
26 \*---------------------------------------------------------------------------*/
27 
30 
31 if (args.dryRun() || args.found("dry-run-write"))
32 {
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 }
68 else
69 {
70  if (args.readIfPresent("region", regionName))
71  {
72  Foam::Info << "Create mesh " << regionName;
73  }
74  else
75  {
76  Foam::Info << "Create mesh";
77  }
78  Foam::Info << " for time = " << runTime.timeName() << Foam::nl;
79 
81  (
82  new Foam::fvMesh
83  (
85  (
86  regionName,
87  runTime.timeName(),
88  runTime,
90  ),
91  false
92  )
93  );
94  meshPtr().init(true); // initialise all (lower levels and current)
95 
97 }
98 
100 
101 
102 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
meshPtr
Foam::autoPtr< Foam::fvMesh > meshPtr(nullptr)
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::polyMesh::defaultRegion
static word defaultRegion
Return the default region name.
Definition: polyMesh.H:318
Foam::FieldBase::allowConstructFromLargerSize
static bool allowConstructFromLargerSize
Permit read construct from a larger size.
Definition: FieldBase.H:63
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::argList::readIfPresent
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
Definition: argListI.H:323
Foam::argList::dryRun
int dryRun() const noexcept
Return the dry-run flag.
Definition: argListI.H:116
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::Time::saNoWriteNow
Adjust endTime to stop immediately w/o writing.
Definition: Time.H:100
Foam::functionObject::outputPrefix
static word outputPrefix
Directory prefix.
Definition: functionObject.H:376
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam::autoPtr::reset
void reset(autoPtr< T > &&other) noexcept
Delete managed object and set to new given pointer.
Definition: autoPtrI.H:117
Foam::autoPtr< Foam::fvMesh >
Foam::Time::saWriteNow
adjust endTime to stop immediately w/ writing
Definition: Time.H:101
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::simplifiedMeshes::columnFvMesh
Generates a 1D column representation of a mesh based on an existing mesh and/or fields.
Definition: columnFvMesh.H:136
args
Foam::argList args(argc, argv)
regionName
Foam::word regionName(Foam::polyMesh::defaultRegion)
Foam::argList::found
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:178
Foam::IOobject::MUST_READ
Definition: IOobject.H:185