Merge remote branch 'OpenCFD/master' into olesenm

This commit is contained in:
Mark Olesen 2011-02-21 15:51:40 +01:00
commit 7f7f3976d0
11 changed files with 358 additions and 23 deletions

View File

@ -190,7 +190,7 @@
outlet
{
type codedFixedValue;
type codedFixedValue<scalar>;
value uniform 0;
redirectType fixedValue10;
@ -230,6 +230,9 @@
+ =extrudeMesh=:
- option to add extrusion to existing mesh.
- works in parallel
+ =snappyHexMesh=:
+ extrude across multi-processor boundaries
+ preserve faceZones during layering
* Post-processing
+ =paraFoam=, =foamToVTK=: full support for polyhedral cell type in recent
Paraview versions.

View File

@ -48,6 +48,9 @@ Example: Look up dictionary entries and do some calculation
- the #codeStream entry reads the dictionary following it, extracts the
code, codeInclude, codeOptions sections (these are just strings) and
calculates the SHA1 checksum of the contents.
- it copies a template file
($FOAM_CODESTREAM_TEMPLATE_DIR/codeStreamTemplate.C), substituting all
occurences of code, codeInclude, codeOptions.
- it writes library source files to constant/codeStream/<sha1> and compiles it
using 'wmake libso'.
- the resulting library gets loaded (dlopen, dlsym) and the function
@ -59,11 +62,11 @@ gets used to construct the entry to replace the whole #codeStream section.
3. codedFixedValue
This uses the code from codeStream to have an in-line specialised
fixedValueFvPatchScalarField:
fixedValueFvPatchScalarField. For now only for scalars:
outlet
{
type codedFixedValue;
type codedFixedValue<scalar>;
value uniform 0;
redirectType fixedValue10;
@ -103,9 +106,9 @@ internalField #codeStream
code
#{
const IOdictionary& d = refCast<const IOdictionary&>(dict);
const IOdictionary& d = dynamicCast<const IOdictionary>(dict);
const fvMesh& mesh = refCast<const fvMesh>(d.db());
scalarField fld(mesh.nCells(), 0.0);
scalarField fld(mesh.nCells(), 12.34);
fld.writeEntry("", os);
#};
@ -115,18 +118,22 @@ internalField #codeStream
#};
};
There are unfortunately some exceptions. Following applications read
the field as a dictionary:
* There are unfortunately some exceptions. Following applications read
the field as a dictionary, not as an IOdictionary:
- foamFormatConvert
- changeDictionaryDict
- foamUpgradeCyclics
- fieldToCell
Note: above construct has the problem that the boundary conditions are
not evaluated so e.g. processor boundaries will might not hold the opposite
cell value.
Note: above field initialisation has the problem that the boundary
conditions are not evaluated so e.g. processor boundaries will
not hold the opposite cell value.
6. Other
- the implementation is still a bit raw - it compiles code overly much
- parallel running not tested a lot. What about distributed data parallel.
- both codeStream and codedFixedValue take the contents of the dictionary
and extract values and re-assemble list of files and environment vars to
replace. Should just directly pass the dictionary into codeStreamTools.
- parallel running not tested a lot. What about distributed data parallel?

View File

@ -0,0 +1,48 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ 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/>.
\*---------------------------------------------------------------------------*/
${codeInclude}
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
extern "C"
{
void ${typeName}
(
const dictionary& dict,
Ostream& os
)
{
${code};
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// ************************************************************************* //

View File

@ -0,0 +1,124 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 20101-2011 OpenCFD Ltd.
\\/ 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 "fixedValueFvPatchScalarFieldTemplate.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "surfaceFields.H"
${codeInclude}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
${typeName}FixedValueFvPatchScalarField::
${typeName}FixedValueFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(p, iF)
{}
${typeName}FixedValueFvPatchScalarField::
${typeName}FixedValueFvPatchScalarField
(
const ${typeName}FixedValueFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchScalarField(ptf, p, iF, mapper)
{}
${typeName}FixedValueFvPatchScalarField::
${typeName}FixedValueFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
fixedValueFvPatchScalarField(p, iF, dict)
{}
${typeName}FixedValueFvPatchScalarField::
${typeName}FixedValueFvPatchScalarField
(
const ${typeName}FixedValueFvPatchScalarField& ptf
)
:
fixedValueFvPatchScalarField(ptf)
{}
${typeName}FixedValueFvPatchScalarField::
${typeName}FixedValueFvPatchScalarField
(
const ${typeName}FixedValueFvPatchScalarField& ptf,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(ptf, iF)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void ${typeName}FixedValueFvPatchScalarField::updateCoeffs()
{
if (this->updated())
{
return;
}
${code}
fixedValueFvPatchScalarField::updateCoeffs();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField
(
fvPatchScalarField,
${typeName}FixedValueFvPatchScalarField
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,142 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ 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::fixedValueFvPatchScalarFieldTemplate
Description
Template for use with onTheFlyFixedValue.
- fixedValueFvPatchScalarField
- without state
SourceFiles
fixedValueFvPatchScalarFieldTemplate.C
\*---------------------------------------------------------------------------*/
#ifndef fixedValueFvPatchScalarFieldTemplate_H
#define fixedValueFvPatchScalarFieldTemplate_H
#include "fixedValueFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class fixedValueFvPatchScalarField Declaration
\*---------------------------------------------------------------------------*/
class ${typeName}FixedValueFvPatchScalarField
:
public fixedValueFvPatchScalarField
{
public:
//- Runtime type information
TypeName("${typeName}");
// Constructors
//- Construct from patch and internal field
${typeName}FixedValueFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
${typeName}FixedValueFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given
// ${typeName}FixedValueFvPatchScalarField
// onto a new patch
${typeName}FixedValueFvPatchScalarField
(
const ${typeName}FixedValueFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
${typeName}FixedValueFvPatchScalarField
(
const ${typeName}FixedValueFvPatchScalarField&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new ${typeName}FixedValueFvPatchScalarField(*this)
);
}
//- Construct as copy setting internal field reference
${typeName}FixedValueFvPatchScalarField
(
const ${typeName}FixedValueFvPatchScalarField&,
const DimensionedField<scalar, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return tmp<fvPatchScalarField>
(
new ${typeName}FixedValueFvPatchScalarField(*this, iF)
);
}
// Member functions
// Evaluation functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -63,6 +63,9 @@ setenv FOAM_SITE_LIBBIN $WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION/platforms/
setenv FOAM_USER_APPBIN $WM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/bin
setenv FOAM_USER_LIBBIN $WM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/lib
# codeStream templates
setenv FOAM_CODESTREAM_TEMPLATE_DIR $WM_PROJECT_DIR/etc/codeTemplates/codeStream
# convenience
setenv FOAM_APP $WM_PROJECT_DIR/applications
#setenv FOAM_LIB $WM_PROJECT_DIR/lib

View File

@ -86,6 +86,9 @@ export FOAM_SITE_LIBBIN=$WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION/platforms/
export FOAM_USER_APPBIN=$WM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/bin
export FOAM_USER_LIBBIN=$WM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/lib
# codeStream templates
export FOAM_CODESTREAM_TEMPLATE_DIR=$WM_PROJECT_DIR/etc/codeTemplates/codeStream
# convenience
export FOAM_APP=$WM_PROJECT_DIR/applications
#export FOAM_LIB=$WM_PROJECT_DIR/lib

View File

@ -143,14 +143,18 @@ bool Foam::functionEntries::codeStream::execute
{
Info<< "Creating new library in " << libPath << endl;
fileName templates(Foam::getEnv("OTF_TEMPLATE_DIR"));
fileName templates
(
Foam::getEnv("FOAM_CODESTREAM_TEMPLATE_DIR")
);
if (!templates.size())
{
FatalIOErrorIn
(
"functionEntries::codeStream::execute(..)",
parentDict
) << "Please set environment variable OTF_TEMPLATE_DIR"
) << "Please set environment variable"
" FOAM_CODESTREAM_TEMPLATE_DIR"
<< " to point to the location of codeStreamTemplate.C"
<< exit(FatalIOError);
}
@ -158,8 +162,8 @@ bool Foam::functionEntries::codeStream::execute
List<fileAndVars> copyFiles(1);
copyFiles[0].first() = templates/"codeStreamTemplate.C";
stringPairList bodyVars(2);
bodyVars[0] = Pair<string>("OTF_INCLUDES", codeInclude);
bodyVars[1] = Pair<string>("OTF_BODY", code);
bodyVars[0] = Pair<string>("codeInclude", codeInclude);
bodyVars[1] = Pair<string>("code", code);
copyFiles[0].second() = bodyVars;
List<fileAndContent> filesContents(2);

View File

@ -149,8 +149,8 @@ bool Foam::codeStreamTools::copyFilesContents(const fileName& dir) const
// Create dir
mkDir(dir);
//Info<< "Setting envvar OTF_TYPENAME=" << name_ << endl;
setEnv("OTF_TYPENAME", name_, true);
//Info<< "Setting envvar typeName=" << name_ << endl;
setEnv("typeName", name_, true);
// Copy any template files
forAll(copyFiles_, i)
{

View File

@ -78,14 +78,15 @@ void Foam::codedFixedValueFvPatchScalarField::writeLibrary
// Write files for new library
if (Pstream::master())
{
fileName templates(Foam::getEnv("OTF_TEMPLATE_DIR"));
fileName templates(Foam::getEnv("FOAM_CODESTREAM_TEMPLATE_DIR"));
if (!templates.size())
{
FatalIOErrorIn
(
"codedFixedValueFvPatchScalarField::writeLibrary(..)",
dict
) << "Please set environment variable OTF_TEMPLATE_DIR"
) << "Please set environment variable"
<< " FOAM_CODESTREAM_TEMPLATE_DIR"
<< " to point to the location of "
<< "fixedValueFvPatchScalarFieldTemplate.C"
<< exit(FatalIOError);
@ -112,8 +113,8 @@ void Foam::codedFixedValueFvPatchScalarField::writeLibrary
templates/"fixedValueFvPatchScalarFieldTemplate.C";
copyFiles[0].second().setSize(2);
copyFiles[0].second()[0] = Pair<string>("OTF_INCLUDES", codeInclude);
copyFiles[0].second()[1] = Pair<string>("OTF_UPDATECOEFFS", code);
copyFiles[0].second()[0] = Pair<string>("codeInclude", codeInclude);
copyFiles[0].second()[1] = Pair<string>("code", code);
copyFiles[1].first() =
templates/"fixedValueFvPatchScalarFieldTemplate.H";

View File

@ -35,7 +35,7 @@ Description
movingWall
{
type codedFixedValue;
type codedFixedValue<scalar>;
value uniform 0;
redirectType rampedFixedValue; // name of generated bc
@ -118,7 +118,7 @@ class codedFixedValueFvPatchScalarField
public:
//- Runtime type information
TypeName("codedFixedValue");
TypeName("codedFixedValue<scalar>");
// Constructors