mirror of
https://github.com/OpenFOAM/OpenFOAM-6.git
synced 2025-12-08 06:57:46 +00:00
foamNewBC: script to create template code for a new boundary condition
Run foamNewBC -h for details
This commit is contained in:
216
bin/foamNewBC
Executable file
216
bin/foamNewBC
Executable file
@ -0,0 +1,216 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# ========= |
|
||||||
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
# \\ / O peration |
|
||||||
|
# \\ / A nd | Copyright (C) 2015 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 <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# Script
|
||||||
|
# foamNewBC
|
||||||
|
#
|
||||||
|
# Description
|
||||||
|
# Create directory of source and compilation files for a new BC
|
||||||
|
#
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
Script=${0##*/}
|
||||||
|
DIR="$FOAM_ETC/codeTemplates/BC"
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
||||||
|
cat<<USAGE
|
||||||
|
Usage: $Script [-h | -help] <base> <type> <boundaryConditionName>
|
||||||
|
|
||||||
|
* Create directory of source and compilation files for a new boundary condition
|
||||||
|
<boundaryConditionName> (dir)
|
||||||
|
- .C and .H source files
|
||||||
|
- Make (dir)
|
||||||
|
- files
|
||||||
|
- options
|
||||||
|
Compiles a library named lib<boundaryConditionName>.so in \$FOAM_USER_LIBBIN:
|
||||||
|
$FOAM_USER_LIBBIN
|
||||||
|
|
||||||
|
<base> conditions:
|
||||||
|
-f | -fixedValue | fixedValue
|
||||||
|
-m | -mixed | mixed
|
||||||
|
|
||||||
|
<type> options:
|
||||||
|
-a | -all | all | template (creates a template class)
|
||||||
|
-s | -scalar | scalar
|
||||||
|
-v | -vector | vector
|
||||||
|
-t | -tensor | tensor
|
||||||
|
-symmTensor | symmTensor
|
||||||
|
-sphericalTensor | sphericalTensor
|
||||||
|
|
||||||
|
USAGE
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
cap() {
|
||||||
|
echo $1 | sed -e 's/^./\U&/'
|
||||||
|
}
|
||||||
|
|
||||||
|
# Implicitly covers a lone -help
|
||||||
|
[ "$#" -gt 1 ] || usage
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
(-h | -help)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
(-f | -fixedValue | fixedValue)
|
||||||
|
BASE=fixedValue
|
||||||
|
;;
|
||||||
|
(-m | -mixed | mixed )
|
||||||
|
BASE=mixed
|
||||||
|
;;
|
||||||
|
(*)
|
||||||
|
usage "Unknown <base> condition '$1'"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
(-a | -all | all | template)
|
||||||
|
TYPE=Type
|
||||||
|
UNIT='VALUE-or-(VALUE 0 0)'
|
||||||
|
;;
|
||||||
|
(-s | -scalar | scalar)
|
||||||
|
TYPE=scalar
|
||||||
|
UNIT=VALUE
|
||||||
|
;;
|
||||||
|
(-v | -vector | vector)
|
||||||
|
TYPE=vector
|
||||||
|
UNIT='(VALUE 0 0)'
|
||||||
|
;;
|
||||||
|
(-t | -tensor | tensor)
|
||||||
|
TYPE=tensor
|
||||||
|
UNIT='(VALUE 0 0 0 0 0 0 0 0)'
|
||||||
|
;;
|
||||||
|
(-symmTensor | symmTensor)
|
||||||
|
TYPE=symmTensor
|
||||||
|
UNIT='(VALUE 0 0 0 0 0)'
|
||||||
|
;;
|
||||||
|
(-sphericalTensor | sphericalTensor)
|
||||||
|
TYPE=sphericalTensor
|
||||||
|
UNIT=VALUE
|
||||||
|
;;
|
||||||
|
(*)
|
||||||
|
usage "Unknown <type> option '$1'"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
[ "$#" -eq 1 ] || usage "Wrong number of arguments"
|
||||||
|
NAME=$1
|
||||||
|
|
||||||
|
# Prevents over-writing of existing directory
|
||||||
|
[ -d $NAME ] && usage "$NAME directory already exists, aborting..."
|
||||||
|
echo "Creating $NAME directory" && mkdir $NAME
|
||||||
|
|
||||||
|
# Establish meta template files to copy
|
||||||
|
FILES=$(cd ${DIR} && ls *.*)
|
||||||
|
[ "$TYPE" = "Type" ] || FILES=$(cd ${DIR} && ls BC.[CH])
|
||||||
|
|
||||||
|
# Substitutions for meta-template files
|
||||||
|
FIELD="Field<${TYPE}>"
|
||||||
|
[ "$TYPE" = "Type" ] || FIELD=${TYPE}Field
|
||||||
|
|
||||||
|
FVPATCHF=fvPatch$(cap $FIELD)
|
||||||
|
CLASS=$NAME$(cap $FVPATCHF)
|
||||||
|
PARENT=$BASE$(cap $FVPATCHF)
|
||||||
|
CONSTRUCT=$(echo $CLASS | sed 's/<Type>//g')
|
||||||
|
|
||||||
|
# Create some example values for the Description
|
||||||
|
n=0
|
||||||
|
for N in $(echo "ZERO ONE TWO THREE FOUR")
|
||||||
|
do
|
||||||
|
eval $(expr $N='$(echo $UNIT | sed "s#VALUE#$n#g")')
|
||||||
|
n=$(( $n + 1 ))
|
||||||
|
done
|
||||||
|
|
||||||
|
# Make substitutions to meta-template files
|
||||||
|
for F in $FILES
|
||||||
|
do
|
||||||
|
EXT=$(echo $F | sed "s#BC##")
|
||||||
|
NEWFILE=${CONSTRUCT}${EXT}
|
||||||
|
echo " Adding file ${NEWFILE}..."
|
||||||
|
|
||||||
|
# Adds readScalar function when TYPE = scalar
|
||||||
|
sed -e "s#TYPE#${TYPE}#g" \
|
||||||
|
-e "s#NAME#${NAME}#g" \
|
||||||
|
-e "s#BASE#${BASE}#g" \
|
||||||
|
-e "s#CONSTRUCT#${CONSTRUCT}#g" \
|
||||||
|
-e "s#CLASS#${CLASS}#g" \
|
||||||
|
-e "s#FIELD#${FIELD}#g" \
|
||||||
|
-e "s#FVPATCHF#${FVPATCHF}#g" \
|
||||||
|
-e "s#PARENT#${PARENT}#g" \
|
||||||
|
-e "s#ZERO#${ZERO}#g" \
|
||||||
|
-e "s#ONE#${ONE}#g" \
|
||||||
|
-e "s#TWO#${TWO}#g" \
|
||||||
|
-e "s#THREE#${THREE}#g" \
|
||||||
|
-e "s#FOUR#${FOUR}#g" \
|
||||||
|
-e 's/>>/> >/g' \
|
||||||
|
${DIR}/${F} > ${NAME}/${NEWFILE}
|
||||||
|
|
||||||
|
case $BASE in
|
||||||
|
fixedValue)
|
||||||
|
# refValue(), refGrad(), valueFraction() removed
|
||||||
|
# phip removed
|
||||||
|
sed -i \
|
||||||
|
-e '/refValue/d' \
|
||||||
|
-e '/refGrad/d' \
|
||||||
|
-e '/valueFraction/d' \
|
||||||
|
-e '/phip/,/lookupPatchField/d' \
|
||||||
|
${NAME}/${NEWFILE}
|
||||||
|
;;
|
||||||
|
mixed)
|
||||||
|
# evaluate() removed
|
||||||
|
# operator== becomes refValue() =
|
||||||
|
sed -i \
|
||||||
|
-e '/evaluate/d' \
|
||||||
|
-e 's/operator==/refValue() =/g' \
|
||||||
|
${NAME}/${NEWFILE}
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case $TYPE in
|
||||||
|
Type)
|
||||||
|
# Build Macro removed (in ..Fields.C)
|
||||||
|
sed -i -e '/Build Macro/,/^}/d' \
|
||||||
|
${NAME}/${NEWFILE}
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# template<class Type> removed
|
||||||
|
# this-> removed
|
||||||
|
# .template functionTemplate<...> becomes functionTemplate<...>
|
||||||
|
# template instantiation repository removed
|
||||||
|
sed -i \
|
||||||
|
-e '/^template<class Type>$/d' \
|
||||||
|
-e 's/this->//g' \
|
||||||
|
-e 's/\.template[\t ]*\([a-Z]\)/\.\1/g' \
|
||||||
|
-e '/#ifdef NoRepository/,/\/\/ */d' \
|
||||||
|
${NAME}/${NEWFILE}
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Creating Make subdirectory" && cp -r ${DIR}/Make ${NAME}
|
||||||
|
COMPILED=$(cd ${NAME} && ls -r1 *C | head -1) # ...Fields.C for template class
|
||||||
|
sed -i -e "s#NAME#${NAME}#g" -e "s#COMPILED.*#${COMPILED}#g" ${NAME}/Make/files
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
240
etc/codeTemplates/BC/BC.C
Normal file
240
etc/codeTemplates/BC/BC.C
Normal file
@ -0,0 +1,240 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2015 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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "CONSTRUCT.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
#include "fvPatchFieldMapper.H"
|
||||||
|
#include "volFields.H"
|
||||||
|
#include "surfaceFields.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::scalar Foam::CLASS::t() const
|
||||||
|
{
|
||||||
|
return this->db().time().timeOutputValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::CLASS::
|
||||||
|
CONSTRUCT
|
||||||
|
(
|
||||||
|
const fvPatch& p,
|
||||||
|
const DimensionedField<TYPE, volMesh>& iF
|
||||||
|
)
|
||||||
|
:
|
||||||
|
PARENT(p, iF),
|
||||||
|
scalarData_(0.0),
|
||||||
|
data_(pTraits<TYPE>::zero),
|
||||||
|
fieldData_(p.size(), pTraits<TYPE>::zero),
|
||||||
|
timeVsData_(),
|
||||||
|
wordData_("wordDefault"),
|
||||||
|
labelData_(-1),
|
||||||
|
boolData_(false)
|
||||||
|
{
|
||||||
|
this->refValue() = pTraits<TYPE>::zero;
|
||||||
|
this->refGrad() = pTraits<TYPE>::zero;
|
||||||
|
this->valueFraction() = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::CLASS::
|
||||||
|
CONSTRUCT
|
||||||
|
(
|
||||||
|
const fvPatch& p,
|
||||||
|
const DimensionedField<TYPE, volMesh>& iF,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
PARENT(p, iF),
|
||||||
|
scalarData_(readScalar(dict.lookup("scalarData"))),
|
||||||
|
data_(pTraits<TYPE>(dict.lookup("data"))),
|
||||||
|
fieldData_("fieldData", dict, p.size()),
|
||||||
|
timeVsData_(DataEntry<TYPE>::New("timeVsData", dict)),
|
||||||
|
wordData_(dict.lookupOrDefault<word>("wordName", "wordDefault")),
|
||||||
|
labelData_(-1),
|
||||||
|
boolData_(false)
|
||||||
|
{
|
||||||
|
this->refGrad() = pTraits<TYPE>::zero;
|
||||||
|
this->valueFraction() = 0.0;
|
||||||
|
|
||||||
|
this->refValue() = FIELD("fieldData", dict, p.size());
|
||||||
|
FVPATCHF::operator=(this->refValue());
|
||||||
|
|
||||||
|
PARENT::evaluate();
|
||||||
|
|
||||||
|
/*
|
||||||
|
//Initialise with the value entry if evaluation is not possible
|
||||||
|
FVPATCHF::operator=
|
||||||
|
(
|
||||||
|
FIELD("value", dict, p.size())
|
||||||
|
);
|
||||||
|
this->refValue() = *this;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::CLASS::
|
||||||
|
CONSTRUCT
|
||||||
|
(
|
||||||
|
const CLASS& ptf,
|
||||||
|
const fvPatch& p,
|
||||||
|
const DimensionedField<TYPE, volMesh>& iF,
|
||||||
|
const fvPatchFieldMapper& mapper
|
||||||
|
)
|
||||||
|
:
|
||||||
|
PARENT(ptf, p, iF, mapper),
|
||||||
|
scalarData_(ptf.scalarData_),
|
||||||
|
data_(ptf.data_),
|
||||||
|
fieldData_(ptf.fieldData_, mapper),
|
||||||
|
timeVsData_(ptf.timeVsData_, false),
|
||||||
|
wordData_(ptf.wordData_),
|
||||||
|
labelData_(-1),
|
||||||
|
boolData_(ptf.boolData_)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::CLASS::
|
||||||
|
CONSTRUCT
|
||||||
|
(
|
||||||
|
const CLASS& ptf
|
||||||
|
)
|
||||||
|
:
|
||||||
|
PARENT(ptf),
|
||||||
|
scalarData_(ptf.scalarData_),
|
||||||
|
data_(ptf.data_),
|
||||||
|
fieldData_(ptf.fieldData_),
|
||||||
|
timeVsData_(ptf.timeVsData_, false),
|
||||||
|
wordData_(ptf.wordData_),
|
||||||
|
labelData_(-1),
|
||||||
|
boolData_(ptf.boolData_)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::CLASS::
|
||||||
|
CONSTRUCT
|
||||||
|
(
|
||||||
|
const CLASS& ptf,
|
||||||
|
const DimensionedField<TYPE, volMesh>& iF
|
||||||
|
)
|
||||||
|
:
|
||||||
|
PARENT(ptf, iF),
|
||||||
|
scalarData_(ptf.scalarData_),
|
||||||
|
data_(ptf.data_),
|
||||||
|
fieldData_(ptf.fieldData_),
|
||||||
|
timeVsData_(ptf.timeVsData_, false),
|
||||||
|
wordData_(ptf.wordData_),
|
||||||
|
labelData_(-1),
|
||||||
|
boolData_(ptf.boolData_)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::CLASS::autoMap
|
||||||
|
(
|
||||||
|
const fvPatchFieldMapper& m
|
||||||
|
)
|
||||||
|
{
|
||||||
|
PARENT::autoMap(m);
|
||||||
|
fieldData_.autoMap(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::CLASS::rmap
|
||||||
|
(
|
||||||
|
const FVPATCHF& ptf,
|
||||||
|
const labelList& addr
|
||||||
|
)
|
||||||
|
{
|
||||||
|
PARENT::rmap(ptf, addr);
|
||||||
|
|
||||||
|
const CLASS& tiptf =
|
||||||
|
refCast<const CLASS>(ptf);
|
||||||
|
|
||||||
|
fieldData_.rmap(tiptf.fieldData_, addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::CLASS::updateCoeffs()
|
||||||
|
{
|
||||||
|
if (this->updated())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PARENT::operator==
|
||||||
|
(
|
||||||
|
data_
|
||||||
|
+ fieldData_
|
||||||
|
+ scalarData_*timeVsData_->value(t())
|
||||||
|
);
|
||||||
|
|
||||||
|
const scalarField& phip =
|
||||||
|
this->patch().template lookupPatchField<surfaceScalarField, scalar>("phi");
|
||||||
|
this->valueFraction() = 1.0 - pos(phip);
|
||||||
|
|
||||||
|
PARENT::updateCoeffs();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::CLASS::write
|
||||||
|
(
|
||||||
|
Ostream& os
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
FVPATCHF::write(os);
|
||||||
|
os.writeKeyword("scalarData") << scalarData_ << token::END_STATEMENT << nl;
|
||||||
|
os.writeKeyword("data") << data_ << token::END_STATEMENT << nl;
|
||||||
|
fieldData_.writeEntry("fieldData", os);
|
||||||
|
timeVsData_->writeData(os);
|
||||||
|
os.writeKeyword("wordData") << wordData_ << token::END_STATEMENT << nl;
|
||||||
|
this->writeEntry("value", os);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Build Macro Function * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
makePatchTypeField
|
||||||
|
(
|
||||||
|
FVPATCHF,
|
||||||
|
CLASS
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
246
etc/codeTemplates/BC/BC.H
Normal file
246
etc/codeTemplates/BC/BC.H
Normal file
@ -0,0 +1,246 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2015 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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::CONSTRUCT
|
||||||
|
|
||||||
|
Group
|
||||||
|
grpGenericBoundaryConditions
|
||||||
|
|
||||||
|
Description
|
||||||
|
This boundary condition provides a NAME condition,
|
||||||
|
calculated as:
|
||||||
|
|
||||||
|
\f[
|
||||||
|
Q = Q_{0} + Q_{p} + s*Q_{t}
|
||||||
|
\f]
|
||||||
|
|
||||||
|
where
|
||||||
|
\vartable
|
||||||
|
s | single scalar value [units]
|
||||||
|
Q_{0} | single TYPE value [units]
|
||||||
|
Q_{p} | TYPE field across patch [units]
|
||||||
|
Q_{t} | TYPE function of time [units]
|
||||||
|
\endtable
|
||||||
|
|
||||||
|
\heading Patch usage
|
||||||
|
|
||||||
|
\table
|
||||||
|
Property | Description | Req'd? | Default
|
||||||
|
scalarData | single scalar value | yes |
|
||||||
|
data | single TYPE value | yes |
|
||||||
|
fieldData | TYPE field across patch | yes |
|
||||||
|
timeVsData | TYPE function of time | yes |
|
||||||
|
wordData | word, eg name of data object | no | wordDefault
|
||||||
|
\endtable
|
||||||
|
|
||||||
|
Example of the boundary condition specification:
|
||||||
|
\verbatim
|
||||||
|
myPatch
|
||||||
|
{
|
||||||
|
type NAME;
|
||||||
|
scalarData -1;
|
||||||
|
data ONE;
|
||||||
|
fieldData uniform THREE;
|
||||||
|
timeVsData table (
|
||||||
|
(0 ZERO)
|
||||||
|
(1 TWO)
|
||||||
|
);
|
||||||
|
wordName anotherName;
|
||||||
|
value uniform FOUR; // optional initial value
|
||||||
|
}
|
||||||
|
\endverbatim
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
CONSTRUCT.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef CONSTRUCT_H
|
||||||
|
#define CONSTRUCT_H
|
||||||
|
|
||||||
|
#include "BASEFvPatchFields.H"
|
||||||
|
#include "DataEntry.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class CONSTRUCT Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
class CONSTRUCT
|
||||||
|
:
|
||||||
|
public PARENT
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Single valued scalar quantity, e.g. a coefficient
|
||||||
|
scalar scalarData_;
|
||||||
|
|
||||||
|
//- Single valued Type quantity, e.g. reference pressure pRefValue_
|
||||||
|
// Other options include vector, tensor
|
||||||
|
TYPE data_;
|
||||||
|
|
||||||
|
//- Field of Types, typically defined across patch faces
|
||||||
|
// e.g. total pressure p0_. Other options include vectorField
|
||||||
|
FIELD fieldData_;
|
||||||
|
|
||||||
|
//- Type specified as a function of time for time-varying BCs
|
||||||
|
autoPtr<DataEntry<TYPE> > timeVsData_;
|
||||||
|
|
||||||
|
//- Word entry, e.g. pName_ for name of the pressure field on database
|
||||||
|
word wordData_;
|
||||||
|
|
||||||
|
//- Label, e.g. patch index, current time index
|
||||||
|
label labelData_;
|
||||||
|
|
||||||
|
//- Boolean for true/false, e.g. specify if flow rate is volumetric_
|
||||||
|
bool boolData_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Return current time
|
||||||
|
scalar t() const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("NAME");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from patch and internal field
|
||||||
|
CONSTRUCT
|
||||||
|
(
|
||||||
|
const fvPatch&,
|
||||||
|
const DimensionedField<TYPE, volMesh>&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from patch, internal field and dictionary
|
||||||
|
CONSTRUCT
|
||||||
|
(
|
||||||
|
const fvPatch&,
|
||||||
|
const DimensionedField<TYPE, volMesh>&,
|
||||||
|
const dictionary&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct by mapping given BASETypeFvPatchField
|
||||||
|
// onto a new patch
|
||||||
|
CONSTRUCT
|
||||||
|
(
|
||||||
|
const CLASS&,
|
||||||
|
const fvPatch&,
|
||||||
|
const DimensionedField<TYPE, volMesh>&,
|
||||||
|
const fvPatchFieldMapper&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct as copy
|
||||||
|
CONSTRUCT
|
||||||
|
(
|
||||||
|
const CLASS&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct and return a clone
|
||||||
|
virtual tmp<FVPATCHF> clone() const
|
||||||
|
{
|
||||||
|
return tmp<FVPATCHF>
|
||||||
|
(
|
||||||
|
new CLASS(*this)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Construct as copy setting internal field reference
|
||||||
|
CONSTRUCT
|
||||||
|
(
|
||||||
|
const CLASS&,
|
||||||
|
const DimensionedField<TYPE, volMesh>&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct and return a clone setting internal field reference
|
||||||
|
virtual tmp<FVPATCHF> clone
|
||||||
|
(
|
||||||
|
const DimensionedField<TYPE, volMesh>& iF
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return tmp<FVPATCHF>
|
||||||
|
(
|
||||||
|
new CLASS
|
||||||
|
(
|
||||||
|
*this,
|
||||||
|
iF
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Member functions
|
||||||
|
|
||||||
|
// Mapping functions
|
||||||
|
|
||||||
|
//- Map (and resize as needed) from self given a mapping object
|
||||||
|
virtual void autoMap
|
||||||
|
(
|
||||||
|
const fvPatchFieldMapper&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Reverse map the given fvPatchField onto this fvPatchField
|
||||||
|
virtual void rmap
|
||||||
|
(
|
||||||
|
const FVPATCHF&,
|
||||||
|
const labelList&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Evaluation functions
|
||||||
|
|
||||||
|
//- Update the coefficients associated with the patch field
|
||||||
|
virtual void updateCoeffs();
|
||||||
|
|
||||||
|
|
||||||
|
//- Write
|
||||||
|
virtual void write(Ostream&) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
# include "CONSTRUCT.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
43
etc/codeTemplates/BC/BCs.C
Normal file
43
etc/codeTemplates/BC/BCs.C
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2015 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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "CONSTRUCTs.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
#include "volFields.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
makePatchFields(NAME);
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
49
etc/codeTemplates/BC/BCs.H
Normal file
49
etc/codeTemplates/BC/BCs.H
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2015 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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef CONSTRUCTs_H
|
||||||
|
#define CONSTRUCTs_H
|
||||||
|
|
||||||
|
#include "CONSTRUCT.H"
|
||||||
|
#include "fieldTypes.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
makePatchTypeFieldTypedefs(NAME);
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
50
etc/codeTemplates/BC/BCsFwd.H
Normal file
50
etc/codeTemplates/BC/BCsFwd.H
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2015 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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef CONSTRUCTsFwd_H
|
||||||
|
#define CONSTRUCTsFwd_H
|
||||||
|
|
||||||
|
#include "fieldTypes.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type> class CONSTRUCT;
|
||||||
|
|
||||||
|
makePatchTypeFieldTypedefs(NAME);
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
3
etc/codeTemplates/BC/Make/files
Normal file
3
etc/codeTemplates/BC/Make/files
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
COMPILED.C
|
||||||
|
|
||||||
|
LIB = $(FOAM_USER_LIBBIN)/libNAME
|
||||||
7
etc/codeTemplates/BC/Make/options
Normal file
7
etc/codeTemplates/BC/Make/options
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
EXE_INC = \
|
||||||
|
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||||
|
-I$(LIB_SRC)/meshTools/lnInclude
|
||||||
|
|
||||||
|
LIB_LIBS = \
|
||||||
|
-lfiniteVolume \
|
||||||
|
-lmeshTools
|
||||||
Reference in New Issue
Block a user