Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / finiteVolume / fields / fvPatchFields / derived / syringePressure / syringePressureFvPatchScalarField.H
blob4deeb9853822472ccb5659bb510f65a8d3ad3e85
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 Class
25     Foam::syringePressureFvPatchScalarField
27 Description
28     Pressure boundary condition obtained from a 0-D model of the cylinder
29     of a syringe.
31     The syringe cylinder is defined by its initial volume, piston area and
32     velocity profile specified by regions of constant acceleration, speed
33     and deceleration.  The gas in the cylinder is described by its initial
34     pressure and compressibility which is assumed constant, i.e. isothermal
35     expansion/compression.
37     Example of the BC specification:
38     @verbatim
39         outlet
40         {
41             type            syringePressure;
42             Ap              1.388e-6; // syringe piston area
43             Sp              0.01;     // syringe piston speed
44             VsI             1.388e-8; // Initial syringe volume
45             tas             0.001;    // Start of piston acceleration
46             tae             0.002;    // End of piston acceleration
47             tds             0.005;    // Start of piston deceleration
48             tde             0.006;    // end of piston deceleration
49             psI             1e5;      // Initial syringe pressure
50             psi             1e-5;     // Gas compressibility
51             ams             0;        // Added (or removed) gas mass
52                                       // Initially 0 but used for restarting.
53         }
54     @endverbatim
56 SourceFiles
57     syringePressureFvPatchScalarField.C
59 \*---------------------------------------------------------------------------*/
61 #ifndef syringePressureFvPatchScalarField_H
62 #define syringePressureFvPatchScalarField_H
64 #include "fixedValueFvPatchFields.H"
66 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68 namespace Foam
71 /*---------------------------------------------------------------------------*\
72                            Class syringePressureFvPatch Declaration
73 \*---------------------------------------------------------------------------*/
75 class syringePressureFvPatchScalarField
77     public fixedValueFvPatchScalarField
79     // Private data
81         //- syringe piston area
82         scalar Ap_;
84         //- syringe piston speed
85         scalar Sp_;
87         //- Initial syringe volume
88         scalar VsI_;
90         //- Start of piston acceleration
91         scalar tas_;
93         //- End of piston acceleration
94         scalar tae_;
96         //- Start of piston deceleration
97         scalar tds_;
99         //- end of piston deceleration
100         scalar tde_;
102         //- Initial syringe pressure
103         scalar psI_;
105         //- Gas compressibility
106         scalar psi_;
108         //- Added gas mass
109         scalar ams_;
111         //- Added gas mass at previous time step
112         scalar ams0_;
114         //- Current time index used to store ms0_
115         label curTimeIndex_;
118         //- return the volume of the syringe at time t
119         scalar Vs(const scalar t) const;
122 public:
124     //- Runtime type information
125     TypeName("syringePressure");
128     // Constructors
130         //- Construct from patch and internal field
131         syringePressureFvPatchScalarField
132         (
133             const fvPatch&,
134             const DimensionedField<scalar, volMesh>&
135         );
137         //- Construct from patch, internal field and dictionary
138         syringePressureFvPatchScalarField
139         (
140             const fvPatch&,
141             const DimensionedField<scalar, volMesh>&,
142             const dictionary&
143         );
145         //- Construct by mapping given syringePressureFvPatchScalarField
146         //  onto a new patch
147         syringePressureFvPatchScalarField
148         (
149             const syringePressureFvPatchScalarField&,
150             const fvPatch&,
151             const DimensionedField<scalar, volMesh>&,
152             const fvPatchFieldMapper&
153         );
155         //- Construct and return a clone
156         virtual tmp<fvPatchScalarField> clone() const
157         {
158             return tmp<fvPatchScalarField>
159             (
160                 new syringePressureFvPatchScalarField(*this)
161             );
162         }
164         //- Construct as copy
165         syringePressureFvPatchScalarField
166         (
167             const syringePressureFvPatchScalarField&
168         );
170         //- Construct as copy setting internal field reference
171         syringePressureFvPatchScalarField
172         (
173             const syringePressureFvPatchScalarField&,
174             const DimensionedField<scalar, volMesh>&
175         );
177         //- Construct and return a clone setting internal field reference
178         virtual tmp<fvPatchScalarField> clone
179         (
180             const DimensionedField<scalar, volMesh>& iF
181         ) const
182         {
183             return tmp<fvPatchScalarField>
184             (
185                 new syringePressureFvPatchScalarField(*this, iF)
186             );
187         }
190     // Member functions
192         // Evaluation functions
194             //- Update the coefficients associated with the patch field
195             virtual void updateCoeffs();
198         //- Write
199         virtual void write(Ostream&) const;
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 } // End namespace Foam
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 #endif
211 // ************************************************************************* //