externalCoupledMixedFvPatchField.C
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) 2013-2015 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 \*---------------------------------------------------------------------------*/
27 
29 #include "fvPatchFieldMapper.H"
30 #include "ISstream.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
34 template<class Type>
37 (
38  const fvPatch& p,
40 )
41 :
43 {
44  this->refValue() = Type(Zero);
45  this->refGrad() = Type(Zero);
46  this->valueFraction() = 0.0;
47 }
48 
49 
50 template<class Type>
53 (
55  const fvPatch& p,
57  const fvPatchFieldMapper& mapper
58 )
59 :
60  mixedFvPatchField<Type>(ptf, p, iF, mapper)
61 {}
62 
63 
64 template<class Type>
67 (
68  const fvPatch& p,
70  const dictionary& dict
71 )
72 :
74 {}
75 
76 
77 template<class Type>
80 (
82 )
83 :
85 {}
86 
87 
88 template<class Type>
91 (
94 )
95 :
96  mixedFvPatchField<Type>(ecmpf, iF)
97 {}
98 
99 
100 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
101 
102 template<class Type>
104 (
105  Ostream& os
106 ) const
107 {
108  os << "# Values: value snGrad refValue refGrad valueFraction" << endl;
109 }
110 
111 
112 template<class Type>
114 (
115  Ostream& os
116 ) const
117 {
118  const Field<Type> snGrad(this->snGrad());
119  const Field<Type>& refValue(this->refValue());
120  const Field<Type>& refGrad(this->refGrad());
121  const scalarField& valueFraction(this->valueFraction());
122 
123  forAll(refValue, facei)
124  {
125  os << this->operator[](facei) << token::SPACE
126  << snGrad[facei] << token::SPACE
127  << refValue[facei] << token::SPACE
128  << refGrad[facei] << token::SPACE
129  << valueFraction[facei] << nl;
130  }
131 }
132 
133 
134 template<class Type>
136 {
137  // Assume generic input stream so we can do line-based format and skip
138  // unused columns
139  ISstream& iss = dynamic_cast<ISstream&>(is);
140 
141  string line;
142 
143  forAll(*this, facei)
144  {
145  iss.getLine(line);
146  IStringStream lineStr(line);
147 
148  // For symmetry with writing ignore value, snGrad columns
149 
150  Type value, snGrad;
151 
152  lineStr
153  >> value
154  >> snGrad
155  >> this->refValue()[facei]
156  >> this->refGrad()[facei]
157  >> this->valueFraction()[facei];
158  }
159 }
160 
161 
162 // ************************************************************************* //
Foam::externalCoupledMixedFvPatchField::writeData
virtual void writeData(Ostream &os) const
Write data.
Definition: externalCoupledMixedFvPatchField.C:114
Foam::fvc::snGrad
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > snGrad(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvcSnGrad.C:47
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::ISstream::getLine
ISstream & getLine(std::string &str, char delim='\n')
Raw, low-level getline (until delimiter) into a string.
Definition: ISstreamI.H:76
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
ISstream.H
Foam::ISstream
Generic input stream using a standard (STL) stream.
Definition: ISstream.H:55
Foam::externalCoupledMixedFvPatchField::writeHeader
virtual void writeHeader(Ostream &os) const
Write header.
Definition: externalCoupledMixedFvPatchField.C:104
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
fvPatchFieldMapper.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::externalCoupledMixedFvPatchField
Extends the mixed boundary condition with serialisation functions.
Definition: externalCoupledMixedFvPatchField.H:76
Foam::externalCoupledMixedFvPatchField::externalCoupledMixedFvPatchField
externalCoupledMixedFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: externalCoupledMixedFvPatchField.C:37
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam::IStringStream
Input from string buffer, using a ISstream. Always UNCOMPRESSED.
Definition: StringStream.H:108
Foam::mixedFvPatchField
This boundary condition provides a base class for 'mixed' type boundary conditions,...
Definition: mixedFvPatchField.H:123
Foam::nl
constexpr char nl
Definition: Ostream.H:404
externalCoupledMixedFvPatchField.H
Foam::line
A line primitive.
Definition: line.H:53
Foam::externalCoupledMixedFvPatchField::readData
virtual void readData(Istream &is)
Read data.
Definition: externalCoupledMixedFvPatchField.C:135
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54