1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
28 Class to hold the defining data for a permanent magnet, in particular
29 the name, relative permeability and remanence.
33 \*---------------------------------------------------------------------------*/
38 #include "dimensionedVector.H"
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 // Forward declaration of classes
49 // Forward declaration of friend functions and operators
51 Istream& operator>>(Istream&, magnet&);
52 Ostream& operator<<(Ostream&, const magnet&);
54 /*---------------------------------------------------------------------------*\
55 Class magnet Declaration
56 \*---------------------------------------------------------------------------*/
63 scalar relativePermeability_;
64 dimensionedScalar remanence_;
71 //- Null constructor for lists
74 remanence_("Mr", dimensionSet(0, -1, 0, 0, 0, 1, 0), 0),
75 orientation_(vector::zero)
78 //- Construct from components
84 const vector& orientation
88 relativePermeability_(mur),
89 remanence_("Mr", dimensionSet(0, -1, 0, 0, 0, 1, 0), Mr),
90 orientation_(orientation)
93 //- Construct from Istream
94 inline magnet(Istream& is)
96 remanence_("Mr", dimensionSet(0, -1, 0, 0, 0, 1, 0), 0),
97 orientation_(vector::zero)
106 inline const word& name() const
111 //- Return relative permeability
112 inline scalar mur() const
114 return relativePermeability_;
118 inline const dimensionedScalar& Mr() const
123 //- Return orientation
124 inline const vector& orientation() const
130 // IOstream operators
132 inline friend Istream& operator>>(Istream& is, magnet& m)
134 is.readBegin("magnet");
136 >> m.relativePermeability_
137 >> m.remanence_.value()
139 is.readEnd("magnet");
141 // Check state of Istream
142 is.check("operator>>(Istream&, magnet&)");
147 inline friend Ostream& operator<<(Ostream& os, const magnet& m)
149 os << token::BEGIN_LIST
150 << m.name_ << token::SPACE
151 << m.relativePermeability_ << token::SPACE
152 << m.remanence_.value()
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163 } // End namespace Foam
165 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 // ************************************************************************* //