/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see .
Class
Foam::externalCoupledMixedFvPatchField
Group
grpGenericBoundaryConditions grpCoupledBoundaryConditions
Description
This boundary condition provides an interface to an external application.
Values are transferred as plain text files, where OpenFOAM data is written
as:
\verbatim
# Patch:
...
\endverbatim
and received as the constituent pieces of the `mixed' condition, i.e.
\verbatim
# Patch:
...
\endverbatim
Data is sent/received as a single file for all patches from the directory
\verbatim
$FOAM_CASE/
\endverbatim
At start-up, the boundary creates a lock file, i.e..
\verbatim
OpenFOAM.lock
\endverbatim
... to signal the external source to wait. During the boundary condition
update, boundary values are written to file, e.g.
\verbatim
.out
\endverbatim
The lock file is then removed, instructing the external source to take
control of the program execution. When ready, the external program
should create the return values, e.g. to file
\verbatim
.in
\endverbatim
... and then re-instate the lock file. The boundary condition will then
read the return values, and pass program execution back to OpenFOAM.
Usage
\table
Property | Description | Required | Default value
commsDir | communications directory | yes |
fileName | transfer file name | yes |
waitInterval | interval [s] between file checks | no | 1
timeOut | time after which error invoked [s] |no |100*waitInterval
calcFrequency | calculation frequency | no | 1
initByExternal | external app to initialises values | yes |
log | log program control | no | no
\endtable
Example of the boundary condition specification:
\verbatim
{
type externalCoupled;
commsDir "$FOAM_CASE/comms";
fileName data;
calcFrequency 1;
initByExternal yes;
}
\endverbatim
See also
mixedFvPatchField
SourceFiles
externalCoupledMixedFvPatchField.C
\*---------------------------------------------------------------------------*/
#ifndef externalCoupledMixedFvPatchField_H
#define externalCoupledMixedFvPatchField_H
#include "mixedFvPatchFields.H"
#include "OFstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class IFstream;
/*---------------------------------------------------------------------------*\
Class externalCoupledMixedFvPatchField Declaration
\*---------------------------------------------------------------------------*/
template
class externalCoupledMixedFvPatchField
:
public mixedFvPatchField
{
private:
// Private data
//- Convenience typedefs
typedef externalCoupledMixedFvPatchField patchType;
typedef GeometricField volFieldType;
//- Path to communications directory
fileName commsDir_;
//- Name of data file
word fName_;
//- Interval time between checking for return data [s]
label waitInterval_;
//- Time out time [s]
label timeOut_;
//- Calculation frequency
label calcFrequency_;
//- Flag to indicate values are initialised by external application
bool initByExternal_;
//- Log flag
bool log_;
//- Master patch flag - controls when to pause/resume execution
// Note: only valid when collate option is selected
bool master_;
//- Offsets in data file to start reading at correct position
List> offsets_;
//- Initialised flag
bool initialised_;
//- List of coupled patch IDs
List