Loading...
Searching...
No Matches
DTRMParticleIO.C
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) 2017-2022 OpenCFD Ltd.
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
26\*---------------------------------------------------------------------------*/
27
28#include "DTRMParticle.H"
29#include "IOstreams.H"
30
31// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32
35
37(
38 sizeof(DTRMParticle) - sizeof(particle)
39);
40
41
42// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43
45(
46 const polyMesh& mesh,
47 Istream& is,
48 bool readFields,
49 bool newFormat
50)
51:
52 particle(mesh, is, readFields, newFormat),
53 p0_(Zero),
54 p1_(Zero),
55 I0_(0),
56 I_(0),
57 dA_(0),
58 transmissiveId_(-1)
59{
60 if (readFields)
61 {
62 if (is.format() == IOstreamOption::ASCII)
63 {
64 is >> p0_ >> p1_ >> I0_ >> I_ >> dA_ >> transmissiveId_;
65 }
66 else
67 {
68 // No non-native streaming
69 is.fatalCheckNativeSizes(FUNCTION_NAME);
70
71 is.read(reinterpret_cast<char*>(&p0_), sizeofFields_);
72 }
73 }
74
75 is.check(FUNCTION_NAME);
76}
77
78
80(
81 Ostream& os,
82 const wordRes& filters,
83 const word& delim,
84 const bool namesOnly
85) const
86{
87 particle::writeProperties(os, filters, delim, namesOnly);
88
89 #undef writeProp
90 #define writeProp(Name, Value) \
91 particle::writeProperty(os, Name, Value, namesOnly, delim, filters)
92
93 writeProp("p0", p0_);
94 writeProp("p1", p1_);
95 writeProp("I0", I0_);
96 writeProp("I", I_);
97 writeProp("dA", dA_);
98 writeProp("transmissiveId", transmissiveId_);
99
100 #undef writeProp
101}
102
103
104Foam::Ostream& Foam::operator<<(Ostream& os, const DTRMParticle& p)
105{
107 {
109 << token::SPACE << p.p0_
110 << token::SPACE << p.p1_
111 << token::SPACE << p.I0_
112 << token::SPACE << p.I_
113 << token::SPACE << p.dA_
114 << token::SPACE << p.transmissiveId_;
115 }
116 else
117 {
119 os.write
120 (
121 reinterpret_cast<const char*>(&p.p0_),
123 );
124 }
125
126 // Check state of Ostream
128
129 return os;
130}
131
132
133// ************************************************************************* //
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
Discrete Transfer Radiation Model (DTRM) particle.
DTRMParticle(const polyMesh &mesh, const vector &position, const vector &targetPosition, const scalar I, const label cellI, const scalar dA, const label transmissiveId)
Construct from components, with searching for tetFace and.
static const std::size_t sizeofFields_
Size in bytes of the fields.
void writeProperties(Ostream &os, const wordRes &filters, const word &delim, const bool namesOnly=false) const
Write individual parcel properties to stream.
streamFormat format() const noexcept
Get the current stream format.
@ ASCII
"ascii" (normal default)
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition IOstream.C:45
virtual Ostream & write(const char c) override
Write character.
Definition OBJstream.C:69
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
static string propertyList()
Definition particle.H:455
void writeProperties(Ostream &os, const wordRes &filters, const word &delim, const bool namesOnly) const
Write individual particle properties to stream.
Definition particleIO.C:177
static string propertyList_
String representation of properties.
Definition particle.H:455
A class for handling character strings derived from std::string.
Definition string.H:76
@ SPACE
Space [isspace].
Definition token.H:144
volScalarField & p
dynamicFvMesh & mesh
OBJstream os(runTime.globalPath()/outputName)
#define writeProp(Name, Value)
#define FUNCTION_NAME
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const NameMatchPredicate &selectedFields, DynamicList< regIOobject * > &storedObjects)
Read the selected GeometricFields of the templated type and store on the objectRegistry.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).