Loading...
Searching...
No Matches
writeMeshObject.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) 2011-2017 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Global
27 writeMeshObject
28
29Description
30 Write a mesh object in the format specified in controlDict.
31
32\*---------------------------------------------------------------------------*/
33
34#ifndef Foam_writeMeshObject_H
35#define Foam_writeMeshObject_H
37// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38
39namespace Foam
40{
41
42// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43
44template<class Type, class CheckType = Type>
45inline bool writeMeshObject
46(
47 const word& name,
48 const fileName& meshDir,
50 const bool strictTypeChecking = true,
51 const bool disableHeaderChecking = false
52)
53{
55 (
56 name,
57 runTime.timeName(),
58 meshDir,
59 runTime,
63 );
64
65 bool writeOk = false;
66
67 if (io.typeHeaderOk<CheckType>(strictTypeChecking, true, false))
68 {
69 Info<< " Reading " << io.headerClassName()
70 << " : " << name << endl;
71
72 // Switch off type checking (for reading e.g. faceZones as
73 // generic list of dictionaries).
74 const word oldTypeName = Type::typeName;
75 if (disableHeaderChecking)
76 {
77 const_cast<word&>(Type::typeName) = word::null;
78 }
79
80 Type meshObject(io);
81
82 if (disableHeaderChecking)
83 {
84 const_cast<word&>(Type::typeName) = oldTypeName;
85 // Fake type back to what was in field
86 const_cast<word&>(meshObject.type()) = io.headerClassName();
87 }
88
89 Info<< " Writing " << name << endl;
90 writeOk = meshObject.regIOobject::write();
91 }
92
93 return writeOk;
94}
95
96
97// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
98
99} // End namespace Foam
100
101// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
102
103#endif
104
105// ************************************************************************* //
@ NO_REGISTER
Do not request registration (bool: false).
@ MUST_READ
Reading required.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition Time.H:75
A class for handling file names.
Definition fileName.H:75
The meshObject is a concrete regIOobject to register MeshObject items.
Definition MeshObject.H:93
A class for handling words, derived from Foam::string.
Definition word.H:66
static const word null
An empty word.
Definition word.H:84
engineTime & runTime
const auto & io
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
bool writeMeshObject(const word &name, const fileName &meshDir, Time &runTime, const bool strictTypeChecking=true, const bool disableHeaderChecking=false)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127