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 -------------------------------------------------------------------------------
10 License
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 Class
27  Foam::magnet
28 
29 Description
30  Class to hold the defining data for a permanent magnet, in particular
31  the name, relative permeability and remanence.
32 
33 SourceFiles
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef magnet_H
38 #define magnet_H
39 
40 #include "dimensionedVector.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 // Forward Declarations
48 class magnet;
49 Istream& operator>>(Istream&, magnet&);
50 Ostream& operator<<(Ostream&, const magnet&);
51 
52 /*---------------------------------------------------------------------------*\
53  Class magnet Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 class magnet
57 {
58  // Private data
59 
60  word name_;
61  scalar relativePermeability_;
62  dimensionedScalar remanence_;
63  vector orientation_;
64 
65 public:
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
129 
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 
139  is.check(FUNCTION_NAME);
140  return is;
141  }
142 
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_
150  << token::END_LIST;
151 
152  return os;
153  }
154 };
155 
156 
157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158 
159 } // End namespace Foam
160 
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 
163 #endif
164 
165 // ************************************************************************* //
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::magnet::magnet
magnet()
Null constructor for lists.
Definition: magnet.H:69
Foam::magnet::operator>>
friend Istream & operator>>(Istream &is, magnet &m)
Definition: magnet.H:129
Foam::operator>>
Istream & operator>>(Istream &, directionInfo &)
Definition: directionInfo.C:230
Foam::dimensioned::value
const Type & value() const
Return const reference to value.
Definition: dimensionedType.C:434
Foam::dimensionSet
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
Definition: dimensionSet.H:108
Foam::Istream::readEnd
bool readEnd(const char *funcName)
End read of data chunk, ends with ')'.
Definition: Istream.C:129
Foam::Istream::readBegin
bool readBegin(const char *funcName)
Begin read of data chunk, starts with '('.
Definition: Istream.C:111
Foam::magnet::mur
scalar mur() const
Return relative permeability.
Definition: magnet.H:109
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::magnet::orientation
const vector & orientation() const
Return orientation.
Definition: magnet.H:121
Foam::magnet::name
const word & name() const
Return name.
Definition: magnet.H:103
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::magnet
Class to hold the defining data for a permanent magnet, in particular the name, relative permeability...
Definition: magnet.H:55
Foam::magnet::magnet
magnet(Istream &is)
Construct from Istream.
Definition: magnet.H:91
dimensionedVector.H
Foam::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:58
os
OBJstream os(runTime.globalPath()/outputName)
Foam::dimensioned< scalar >
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::magnet::Mr
const dimensionedScalar & Mr() const
Return remenance.
Definition: magnet.H:115
Foam::Vector< scalar >
Foam::token::SPACE
Space [isspace].
Definition: token.H:125
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:295
Foam::token::END_LIST
End list [isseparator].
Definition: token.H:156
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::token::BEGIN_LIST
Begin list [isseparator].
Definition: token.H:155
Foam::magnet::operator<<
friend Ostream & operator<<(Ostream &os, const magnet &m)
Definition: magnet.H:142