magnet.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-2016 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
26Class
27 Foam::magnet
28
29Description
30 Class to hold the defining data for a permanent magnet, in particular
31 the name, relative permeability and remanence.
32
33SourceFiles
34
35\*---------------------------------------------------------------------------*/
36
37#ifndef magnet_H
38#define magnet_H
39
40#include "dimensionedVector.H"
41
42// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43
44namespace Foam
45{
46
47// Forward Declarations
48class magnet;
49Istream& operator>>(Istream&, magnet&);
50Ostream& operator<<(Ostream&, const magnet&);
51
52/*---------------------------------------------------------------------------*\
53 Class magnet Declaration
54\*---------------------------------------------------------------------------*/
56class magnet
57{
58 // Private data
59
60 word name_;
61 scalar relativePermeability_;
62 dimensionedScalar remanence_;
63 vector orientation_;
64
65public:
66
67 // Constructors
68
69 //- Null constructor for lists
70 inline magnet()
71 :
72 remanence_("Mr", dimensionSet(0, -1, 0, 0, 0, 1, 0), 0),
73 orientation_(Zero)
74 {}
75
76 //- Construct from components
77 inline magnet
78 (
79 const word& name,
80 const scalar mur,
81 const scalar Mr,
82 const vector& orientation
83 )
84 :
85 name_(name),
86 relativePermeability_(mur),
87 remanence_("Mr", dimensionSet(0, -1, 0, 0, 0, 1, 0), Mr),
88 orientation_(orientation)
89 {}
90
91 //- Construct from Istream
92 inline magnet(Istream& is)
93 :
94 remanence_("Mr", dimensionSet(0, -1, 0, 0, 0, 1, 0), 0),
95 orientation_(Zero)
96 {
97 is >> *this;
98 }
99
100
101 // Member Functions
102
103 //- Return name
104 inline const word& name() const
105 {
106 return name_;
107 }
108
109 //- Return relative permeability
110 inline scalar mur() const
111 {
112 return relativePermeability_;
113 }
114
115 //- Return remenance
116 inline const dimensionedScalar& Mr() const
117 {
118 return remanence_;
119 }
120
121 //- Return orientation
122 inline const vector& orientation() const
123 {
124 return orientation_;
125 }
126
127
128 // IOstream operators
130 inline friend Istream& operator>>(Istream& is, magnet& m)
131 {
132 is.readBegin("magnet");
133 is >> m.name_
134 >> m.relativePermeability_
135 >> m.remanence_.value()
136 >> m.orientation_;
137 is.readEnd("magnet");
138
140 return is;
141 }
143 inline friend Ostream& operator<<(Ostream& os, const magnet& m)
144 {
146 << m.name_ << token::SPACE
147 << m.relativePermeability_ << token::SPACE
148 << m.remanence_.value()
149 << m.orientation_
151
152 return os;
153 }
154};
155
156
157// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158
159} // End namespace Foam
160
161// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162
163#endif
164
165// ************************************************************************* //
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:58
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
bool readEnd(const char *funcName)
End read of data chunk, ends with ')'.
Definition: Istream.C:129
bool readBegin(const char *funcName)
Begin read of data chunk, starts with '('.
Definition: Istream.C:111
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
Definition: dimensionSet.H:109
const Type & value() const
Return const reference to value.
Class to hold the defining data for a permanent magnet, in particular the name, relative permeability...
Definition: magnet.H:56
const vector & orientation() const
Return orientation.
Definition: magnet.H:121
friend Ostream & operator<<(Ostream &os, const magnet &m)
Definition: magnet.H:142
magnet()
Null constructor for lists.
Definition: magnet.H:69
const word & name() const
Return name.
Definition: magnet.H:103
friend Istream & operator>>(Istream &is, magnet &m)
Definition: magnet.H:129
scalar mur() const
Return relative permeability.
Definition: magnet.H:109
const dimensionedScalar & Mr() const
Return remenance.
Definition: magnet.H:115
magnet(Istream &is)
Construct from Istream.
Definition: magnet.H:91
magnet(const word &name, const scalar mur, const scalar Mr, const vector &orientation)
Construct from components.
Definition: magnet.H:77
@ BEGIN_LIST
Begin list [isseparator].
Definition: token.H:155
@ END_LIST
End list [isseparator].
Definition: token.H:156
@ SPACE
Space [isspace].
Definition: token.H:125
A class for handling words, derived from Foam::string.
Definition: word.H:68
OBJstream os(runTime.globalPath()/outputName)
#define FUNCTION_NAME
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Istream & operator>>(Istream &, directionInfo &)
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131