Forward compatibility: flex
[foam-extend-3.2.git] / src / engine / derivedFvPatchFields / engineTimeVaryingUniformFixedValue / engineTimeVaryingUniformFixedValueFvPatchField.C
blob30a0fd7916906d9658a14f0240c442f02ba66367
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation, either version 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "engineTimeVaryingUniformFixedValueFvPatchField.H"
27 #include "graph.H"
28 #include "IFstream.H"
29 #include "interpolateXY.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 namespace Foam
36 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
38 template<class Type>
39 engineTimeVaryingUniformFixedValueFvPatchField<Type>::
40 engineTimeVaryingUniformFixedValueFvPatchField
42     const fvPatch& p,
43     const DimensionedField<Type, volMesh>& iF
46     fixedValueFvPatchField<Type>(p, iF),
47     timeDataPtr_(NULL),
48     engineDB_((refCast<const engineTime>(this->db().time())))
52 template<class Type>
53 engineTimeVaryingUniformFixedValueFvPatchField<Type>::
54 engineTimeVaryingUniformFixedValueFvPatchField
56     const engineTimeVaryingUniformFixedValueFvPatchField<Type>& ptf,
57     const fvPatch& p,
58     const DimensionedField<Type, volMesh>& iF,
59     const fvPatchFieldMapper& mapper
62     fixedValueFvPatchField<Type>(ptf, p, iF, mapper),
63     timeDataFileName_(ptf.timeDataFileName_),
64     timeDataPtr_(NULL),
65     engineDB_((refCast<const engineTime>(this->db().time())))
69 template<class Type>
70 engineTimeVaryingUniformFixedValueFvPatchField<Type>::
71 engineTimeVaryingUniformFixedValueFvPatchField
73     const fvPatch& p,
74     const DimensionedField<Type, volMesh>& iF,
75     const dictionary& dict
78     fixedValueFvPatchField<Type>(p, iF),
79     timeDataFileName_(fileName(dict.lookup("timeDataFileName")).expand()),
80     timeDataPtr_(NULL),
81     engineDB_((refCast<const engineTime>(this->db().time())))
83     if (dict.found("value"))
84     {
85         fvPatchField<Type>::operator==(Field<Type>("value", dict, p.size()));
86     }
87     else
88     {
89         updateCoeffs();
90     }
94 template<class Type>
95 engineTimeVaryingUniformFixedValueFvPatchField<Type>::
96 engineTimeVaryingUniformFixedValueFvPatchField
98     const engineTimeVaryingUniformFixedValueFvPatchField<Type>& ptf
101     fixedValueFvPatchField<Type>(ptf),
102     timeDataFileName_(ptf.timeDataFileName_),
103     timeDataPtr_(NULL),
104     engineDB_((refCast<const engineTime>(this->db().time())))
108 template<class Type>
109 engineTimeVaryingUniformFixedValueFvPatchField<Type>::
110 engineTimeVaryingUniformFixedValueFvPatchField
112     const engineTimeVaryingUniformFixedValueFvPatchField<Type>& ptf,
113     const DimensionedField<Type, volMesh>& iF
116     fixedValueFvPatchField<Type>(ptf, iF),
117     timeDataFileName_(ptf.timeDataFileName_),
118     timeDataPtr_(NULL),
119     engineDB_((refCast<const engineTime>(this->db().time())))
123 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
125 template<class Type>
126 void engineTimeVaryingUniformFixedValueFvPatchField<Type>::checkTable()
128     if (!timeDataPtr_.valid())
129     {
130         timeDataPtr_.reset
131         (
132             new graph("title", "x", "y", IFstream(timeDataFileName_)())
133         );
134     }
136 //    if (this->db().time().value() < min(timeDataPtr_().x()))
137     if (engineDB_.theta() < min(timeDataPtr_().x()))
138     {
139         WarningIn
140         (
141             "engineTimeVaryingUniformFixedValueFvPatchField<Type>::updateCoeffs()"
142         )   << "current time (" << engineDB_.theta()
143             << ") is less than the minimum in the data table ("
144             << min(timeDataPtr_().x()) << ')' << endl
145             << "    Continuing with the value for the smallest time"
146             << endl;
147     }
149 //    if (this->db().time().value() > max(timeDataPtr_().x()))
150     if (engineDB_.theta() < min(timeDataPtr_().x()))
151     {
152         WarningIn
153         (
154             "engineTimeVaryingUniformFixedValueFvPatchField<Type>::updateCoeffs()"
155         )   << "current time (" << engineDB_.theta()
156             << ") is greater than the maximum in the data table ("
157             << max(timeDataPtr_().x()) << ')' << endl
158             << "    Continuing with the value for the largest time"
159             << endl;
160     }
164 template<class Type>
165 void engineTimeVaryingUniformFixedValueFvPatchField<Type>::write(Ostream& os) const
167     fvPatchField<Type>::write(os);
168     os.writeKeyword("timeDataFileName")
169         << timeDataFileName_ << token::END_STATEMENT << nl;
170     this->writeEntry("value", os);
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 } // End namespace Foam
178 // ************************************************************************* //