mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' into pairPatchAgglomeration
Conflicts: applications/solvers/lagrangian/steadyReactingParcelFoam/pEqn.H
This commit is contained in:
125
ReleaseNotes-dev
125
ReleaseNotes-dev
@ -35,43 +35,44 @@
|
||||
*** Core library
|
||||
+ Large number of code refinements and consistency improvements to support
|
||||
other developments.
|
||||
Parallel : using non-blocking communications wherever possible. This will
|
||||
+ Parallel : using non-blocking communications wherever possible. This will
|
||||
lead to lower requirements for MPI_BUFFER_SIZE and possibly better
|
||||
start-up performance on larger numbers of processors.
|
||||
*** Turbulence modelling
|
||||
*** *Updated* thermophysical libraries
|
||||
+ Now use the more descriptive dictionary input format, e.g. for a single
|
||||
component mixture:
|
||||
#+BEGIN_SRC c++
|
||||
thermoType hPsiThermo<pureMixture<sutherlandTransport<specieThermo<hConstThermo<perfectGas>>>>>;
|
||||
|
||||
thermoType hPsiThermo<pureMixture<sutherlandTransport<specieThermo<hConstThermo<perfectGas>>>>>;
|
||||
|
||||
mixture
|
||||
{
|
||||
nMoles 1;
|
||||
molWeight 28.9;
|
||||
Cp 1007;
|
||||
Hf 0;
|
||||
As 1.4792e-06;
|
||||
Ts 116;
|
||||
}
|
||||
mixture
|
||||
{
|
||||
nMoles 1;
|
||||
molWeight 28.9;
|
||||
Cp 1007;
|
||||
Hf 0;
|
||||
As 1.4792e-06;
|
||||
Ts 116;
|
||||
}
|
||||
#+END_SRC
|
||||
*** Lagrangian intermediate library
|
||||
Extensively updated
|
||||
*Updated* input format
|
||||
Extended to include steady cloud tracking
|
||||
*New* collision modelling
|
||||
*Coupled* to new surface film modelling library
|
||||
*New* sub-models
|
||||
+ NonSphereDrag: drag model to account for non-spherical particles
|
||||
+ ParticleTracks: post-processing model to generate track data, typically
|
||||
during steady calculations
|
||||
*Updated* sub-models
|
||||
+ Devolatilisation models: now act on a per-specie basis
|
||||
+ Extensively updated
|
||||
+ *Updated* input format
|
||||
+ Extended to include steady cloud tracking
|
||||
+ *New* collision modelling
|
||||
+ *Coupled* to new surface film modelling library
|
||||
+ *New* sub-models
|
||||
+ NonSphereDrag: drag model to account for non-spherical particles
|
||||
+ ParticleTracks: post-processing model to generate track data, typically
|
||||
during steady calculations
|
||||
+ *Updated* sub-models
|
||||
+ Devolatilisation models: now act on a per-specie basis
|
||||
|
||||
*** DSMC
|
||||
*** Dynamic Mesh
|
||||
*** Numerics
|
||||
*** *Updated* command line help, e.g. `snappyHexMesh -help' now gives:
|
||||
|
||||
#+BEGIN_SRC c++
|
||||
Usage: snappyHexMesh [OPTIONS]
|
||||
options:
|
||||
-case <dir> specify alternate case directory, default is the cwd
|
||||
@ -80,12 +81,13 @@
|
||||
-srcDoc display source code in browser
|
||||
-doc display application documentation in browser
|
||||
-help print the usage
|
||||
|
||||
#+END_SRC
|
||||
*** *New* basicSolidThermo solids thermophysical library
|
||||
+ Used in all conjugate heat transfer solvers
|
||||
+ constant properties
|
||||
+ temperature dependent properties
|
||||
+ temperature and direction (in local coordinate system) dependent properties
|
||||
+ temperature and direction (in local coordinate system) dependent
|
||||
properties
|
||||
*** *New* Surface film library
|
||||
+ Creation of films by particle addition, or initial film distribution
|
||||
+ Coupled with the lagrangian/intermediate cloud hierarchy library
|
||||
@ -113,13 +115,16 @@
|
||||
polyPatches holding data can map the data.
|
||||
*** *Updated* particle tracking algorithm
|
||||
+ uses non-blocking parallel transfers
|
||||
+ does 'minimum-tet' decomposition of face to work with warped faces (snappyHexMesh!)
|
||||
+ does 'minimum-tet' decomposition of face to work with warped faces
|
||||
(snappyHexMesh!)
|
||||
+ reuses tracking state in interpolation - improves consistency and speed
|
||||
*** *Updated* split cyclics into two separate patches. See doc/changed/splitCyclics.txt
|
||||
*** *Updated* split cyclics into two separate patches.
|
||||
See [[./doc/changes/splitCyclic.txt]]
|
||||
* *Updated* interpolation (volPointInterpolation) now works without the
|
||||
globalPointPatch. Moving mesh cases can now be run non-parallel and
|
||||
continued in parallel and reconstructed without any limitation.
|
||||
*** *New* compact binary I/O for faces and cells. This speeds up reading/writing meshes in binary.
|
||||
*** *New* compact binary I/O for faces and cells.
|
||||
This speeds up reading/writing meshes in binary.
|
||||
*** *Updated* runTimeModifiable
|
||||
+ user selectable model to use for checking run-time modifiable
|
||||
dictionaries (see also doc/changes/inotify.txt):
|
||||
@ -129,11 +134,34 @@
|
||||
contents from master.
|
||||
+ inotifyMaster : only master checks and reads file. Slaves get file
|
||||
contents from master.
|
||||
+ on linux optionally uses inotify instead of time stamps - more efficient for large
|
||||
numbers of monitored files. No more fileModificationSkew needed.
|
||||
+ on linux optionally uses inotify instead of time stamps - more efficient
|
||||
for large numbers of monitored files. No more fileModificationSkew needed.
|
||||
+ single integer reduction instead of one reduction per monitored file.
|
||||
+ only files that can be re-read are being checked. Drastic reduction of
|
||||
number of files to check.
|
||||
*** *New* #codeStream dictionary entry
|
||||
Uses on-the-fly compilation of OpenFOAM C++ code to construct dictionary.
|
||||
E.g. in blockMeshDict:
|
||||
#+BEGIN_SRC c++
|
||||
convertToMeters 0.001;
|
||||
|
||||
vertices #codeStream
|
||||
{
|
||||
code
|
||||
#{
|
||||
label nVerts =
|
||||
readLabel(dict.lookup("nx"))
|
||||
*readLabel(dict.lookup("ny"))
|
||||
*readLabel(dict.lookup("nz"));
|
||||
pointField verts(nVerts);
|
||||
// Now fill verts here
|
||||
// ..
|
||||
os << verts;
|
||||
#};
|
||||
}
|
||||
#+END_SRC
|
||||
See also ./[[doc/changes/codeStream.org]]
|
||||
|
||||
* Solvers
|
||||
A number of new solvers have been developed for a range of engineering
|
||||
applications. There has been a set of improvements to certain classes of
|
||||
@ -163,6 +191,23 @@
|
||||
+ takes optional fieldName to sample
|
||||
+ directMapped patch added 'normal' method to calculate sample points
|
||||
to e.g. sample fields just above wall (e.g. for streaklines)
|
||||
+ *New* codedFixedValue: Uses the on-the-fly code compilation from #codeStream
|
||||
to provide an in-line fixedValueFvPatchScalarField. E.g.
|
||||
#+BEGIN_SRC c++
|
||||
outlet
|
||||
{
|
||||
type codedFixedValue<scalar>;
|
||||
value uniform 0;
|
||||
redirectType fixedValue10;
|
||||
|
||||
code
|
||||
#{
|
||||
operator==(min(10, 0.1*this->db().time().value()));
|
||||
#};
|
||||
}
|
||||
#+END_SRC
|
||||
See also [[./doc/changes/codeStream.org]]
|
||||
|
||||
* Utilities
|
||||
There have been some utilities added and updated in this release.
|
||||
*** *New* utilities
|
||||
@ -182,20 +227,24 @@
|
||||
+ =topoSet=: replacement of cellSet,faceSet,pointSet utilities.
|
||||
Comparable to a dictionary driven =setSet= utility.
|
||||
*** Updated utilities
|
||||
+ =setFields=: optionally use faceSets to set patch values (see e.g. hotRoom tutorial).
|
||||
+ =setFields=: optionally use faceSets to set patch values (see
|
||||
e.g. =hotRoom= tutorial).
|
||||
+ =blockMesh=: specify patches via dictionary instead of type only. This
|
||||
makes rereading the boundary file superfluous. see
|
||||
e.g. pitzDailyDirectMapped tutorial.
|
||||
+ =setSet=: allows time range (e.g. 0:100) in combination with -batch argument
|
||||
to execute the commands for multiple times.
|
||||
+ =setSet=: allows time range (e.g. 0:100) in combination with -batch
|
||||
argument to execute the commands for multiple times.
|
||||
+ =extrudeMesh=:
|
||||
- option to add extrusion to existing mesh.
|
||||
- works in parallel
|
||||
- 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.
|
||||
+ =foamToEnsight=: parallel continuous data. new =-nodeValues= option to generate and output nodal
|
||||
field data.
|
||||
+ =foamToEnsight=: parallel continuous data. new =-nodeValues= option to
|
||||
generate and output nodal field data.
|
||||
+ =singleCellMesh=: new utility to convert mesh and fields to a single cell
|
||||
mesh. Great for postprocessing.
|
||||
+ =steadyParticleTracks=: Generates VTK tracks from the output of the cloud
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
(
|
||||
fvc::ddt(rho) + psi*correction(fvm::ddt(p))
|
||||
+ fvc::div(phi)
|
||||
==
|
||||
==
|
||||
parcels.Srho()
|
||||
+ massSource.SuTot()
|
||||
);
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
estimateScalarError.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/estimateScalarError
|
||||
@ -1,9 +0,0 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/errorEstimation/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lerrorEstimation \
|
||||
-lfiniteVolume \
|
||||
-lmeshTools \
|
||||
-ldynamicMesh
|
||||
@ -1,133 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2004-2010 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/>.
|
||||
|
||||
Application
|
||||
estimateScalarError
|
||||
|
||||
Description
|
||||
Estimates the error in the solution for a scalar transport equation in the
|
||||
standard form
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "errorEstimate.H"
|
||||
#include "resError.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
timeSelector::addOptions();
|
||||
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
|
||||
instantList timeDirs = timeSelector::select0(runTime, args);
|
||||
|
||||
# include "createMesh.H"
|
||||
|
||||
Info<< "\nEstimating error in scalar transport equation\n"
|
||||
<< "Reading transportProperties\n" << endl;
|
||||
|
||||
IOdictionary transportProperties
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"transportProperties",
|
||||
runTime.constant(),
|
||||
mesh,
|
||||
IOobject::MUST_READ_IF_MODIFIED,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
Info<< "Reading diffusivity DT\n" << endl;
|
||||
|
||||
dimensionedScalar DT
|
||||
(
|
||||
transportProperties.lookup("DT")
|
||||
);
|
||||
|
||||
|
||||
forAll(timeDirs, timeI)
|
||||
{
|
||||
runTime.setTime(timeDirs[timeI], timeI);
|
||||
|
||||
Info<< "Time = " << runTime.timeName() << endl;
|
||||
|
||||
mesh.readUpdate();
|
||||
|
||||
IOobject THeader
|
||||
(
|
||||
"T",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ
|
||||
);
|
||||
|
||||
IOobject Uheader
|
||||
(
|
||||
"U",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ
|
||||
);
|
||||
|
||||
if (THeader.headerOk() && Uheader.headerOk())
|
||||
{
|
||||
Info<< "Reading T" << endl;
|
||||
volScalarField T(THeader, mesh);
|
||||
|
||||
Info<< "Reading U" << endl;
|
||||
volVectorField U(Uheader, mesh);
|
||||
|
||||
# include "createPhi.H"
|
||||
|
||||
errorEstimate<scalar> ee
|
||||
(
|
||||
resError::div(phi, T)
|
||||
- resError::laplacian(DT, T)
|
||||
);
|
||||
|
||||
ee.residual()().write();
|
||||
volScalarField e(ee.error());
|
||||
e.write();
|
||||
mag(e)().write();
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " No T or U" << endl;
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,4 +0,0 @@
|
||||
icoErrorEstimate.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/icoErrorEstimate
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/errorEstimation/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lerrorEstimation \
|
||||
-lmeshTools \
|
||||
-ldynamicMesh \
|
||||
-lfiniteVolume
|
||||
@ -1,129 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2004-2010 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/>.
|
||||
|
||||
Application
|
||||
icoErrorEstimate
|
||||
|
||||
Description
|
||||
Estimates error for the incompressible laminar CFD application icoFoam.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "errorEstimate.H"
|
||||
#include "resError.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
timeSelector::addOptions();
|
||||
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
|
||||
instantList timeDirs = timeSelector::select0(runTime, args);
|
||||
|
||||
# include "createMesh.H"
|
||||
|
||||
Info<< "\nEstimating error in the incompressible momentum equation\n"
|
||||
<< "Reading transportProperties\n" << endl;
|
||||
|
||||
IOdictionary transportProperties
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"transportProperties",
|
||||
runTime.constant(),
|
||||
mesh,
|
||||
IOobject::MUST_READ_IF_MODIFIED,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
dimensionedScalar nu
|
||||
(
|
||||
transportProperties.lookup("nu")
|
||||
);
|
||||
|
||||
forAll(timeDirs, timeI)
|
||||
{
|
||||
runTime.setTime(timeDirs[timeI], timeI);
|
||||
|
||||
Info<< "Time = " << runTime.timeName() << endl;
|
||||
|
||||
mesh.readUpdate();
|
||||
|
||||
IOobject pHeader
|
||||
(
|
||||
"p",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ
|
||||
);
|
||||
|
||||
IOobject Uheader
|
||||
(
|
||||
"U",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ
|
||||
);
|
||||
|
||||
if (pHeader.headerOk() && Uheader.headerOk())
|
||||
{
|
||||
Info<< "Reading p" << endl;
|
||||
volScalarField p(pHeader, mesh);
|
||||
|
||||
Info<< "Reading U" << endl;
|
||||
volVectorField U(Uheader, mesh);
|
||||
|
||||
# include "createPhi.H"
|
||||
|
||||
errorEstimate<vector> ee
|
||||
(
|
||||
resError::div(phi, U)
|
||||
- resError::laplacian(nu, U)
|
||||
==
|
||||
-fvc::grad(p)
|
||||
);
|
||||
|
||||
volVectorField e(ee.error());
|
||||
e.write();
|
||||
mag(e)().write();
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " No p or U" << endl;
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,4 +0,0 @@
|
||||
icoMomentError.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/icoMomentError
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/errorEstimation/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lerrorEstimation \
|
||||
-lmeshTools \
|
||||
-ldynamicMesh \
|
||||
-lfiniteVolume
|
||||
@ -1,188 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2004-2010 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/>.
|
||||
|
||||
Application
|
||||
icoMomentError
|
||||
|
||||
Description
|
||||
Estimates error for the incompressible laminar CFD application icoFoam.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "linear.H"
|
||||
#include "gaussConvectionScheme.H"
|
||||
#include "gaussLaplacianScheme.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
timeSelector::addOptions();
|
||||
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
|
||||
instantList timeDirs = timeSelector::select0(runTime, args);
|
||||
|
||||
# include "createMesh.H"
|
||||
|
||||
Info<< "\nEstimating error in the incompressible momentum equation\n"
|
||||
<< "Reading transportProperties\n" << endl;
|
||||
|
||||
IOdictionary transportProperties
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"transportProperties",
|
||||
runTime.constant(),
|
||||
mesh,
|
||||
IOobject::MUST_READ_IF_MODIFIED,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
dimensionedScalar nu
|
||||
(
|
||||
transportProperties.lookup("nu")
|
||||
);
|
||||
|
||||
forAll(timeDirs, timeI)
|
||||
{
|
||||
runTime.setTime(timeDirs[timeI], timeI);
|
||||
|
||||
Info<< "Time = " << runTime.timeName() << endl;
|
||||
|
||||
mesh.readUpdate();
|
||||
|
||||
IOobject pHeader
|
||||
(
|
||||
"p",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ
|
||||
);
|
||||
|
||||
IOobject Uheader
|
||||
(
|
||||
"U",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ
|
||||
);
|
||||
|
||||
if (pHeader.headerOk() && Uheader.headerOk())
|
||||
{
|
||||
Info<< "Reading p" << endl;
|
||||
volScalarField p(pHeader, mesh);
|
||||
|
||||
Info<< "Reading U" << endl;
|
||||
volVectorField U(Uheader, mesh);
|
||||
|
||||
# include "createPhi.H"
|
||||
|
||||
volScalarField ek(0.5*magSqr(U));
|
||||
volTensorField gradU(fvc::grad(U));
|
||||
|
||||
// Divergence of the error in U squared
|
||||
|
||||
volScalarField L
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"L",
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("one", dimLength, 1.0)
|
||||
);
|
||||
|
||||
L.internalField() =
|
||||
mesh.V()/fvc::surfaceSum(mesh.magSf())().internalField();
|
||||
|
||||
// Warning: 4th row of this equation specially modified
|
||||
// for the momentum equation. The "real" formulation would
|
||||
// have diffusivity*(gradV && gradV)
|
||||
volScalarField momError
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"momErrorL" + U.name(),
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
sqrt
|
||||
(
|
||||
2.0*mag
|
||||
(
|
||||
(
|
||||
fv::gaussConvectionScheme<scalar>
|
||||
(
|
||||
mesh,
|
||||
phi,
|
||||
tmp<surfaceInterpolationScheme<scalar> >
|
||||
(
|
||||
new linear<scalar>(mesh)
|
||||
)
|
||||
).fvcDiv(phi, ek)
|
||||
|
||||
- nu*
|
||||
fv::gaussLaplacianScheme<scalar, scalar>(mesh)
|
||||
.fvcLaplacian
|
||||
(
|
||||
ek
|
||||
)
|
||||
- (U & fvc::grad(p))
|
||||
// + nu*(gradU && gradU)
|
||||
+ 0.5*nu*
|
||||
(
|
||||
gradU && (gradU + gradU.T())
|
||||
)
|
||||
)*L/(mag(U) + nu/L)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
momError.boundaryField() = 0.0;
|
||||
momError.write();
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " No p or U" << endl;
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,3 +0,0 @@
|
||||
momentScalarError.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/momentScalarError
|
||||
@ -1,8 +0,0 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/errorEstimation/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lmeshTools \
|
||||
-ldynamicMesh \
|
||||
-lfiniteVolume
|
||||
@ -1,185 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2004-2010 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/>.
|
||||
|
||||
Application
|
||||
momentScalarError
|
||||
|
||||
Description
|
||||
Estimates the error in the solution for a scalar transport equation in the
|
||||
standard form
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "linear.H"
|
||||
#include "gaussConvectionScheme.H"
|
||||
#include "gaussLaplacianScheme.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
timeSelector::addOptions();
|
||||
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
|
||||
instantList timeDirs = timeSelector::select0(runTime, args);
|
||||
|
||||
# include "createMesh.H"
|
||||
|
||||
Info<< "\nEstimating error in scalar transport equation\n"
|
||||
<< "Reading transportProperties\n" << endl;
|
||||
|
||||
IOdictionary transportProperties
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"transportProperties",
|
||||
runTime.constant(),
|
||||
mesh,
|
||||
IOobject::MUST_READ_IF_MODIFIED,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
Info<< "Reading diffusivity DT\n" << endl;
|
||||
|
||||
dimensionedScalar DT
|
||||
(
|
||||
transportProperties.lookup("DT")
|
||||
);
|
||||
|
||||
|
||||
forAll(timeDirs, timeI)
|
||||
{
|
||||
runTime.setTime(timeDirs[timeI], timeI);
|
||||
|
||||
Info<< "Time = " << runTime.timeName() << endl;
|
||||
|
||||
mesh.readUpdate();
|
||||
|
||||
IOobject THeader
|
||||
(
|
||||
"T",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ
|
||||
);
|
||||
|
||||
IOobject Uheader
|
||||
(
|
||||
"U",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ
|
||||
);
|
||||
|
||||
if (THeader.headerOk() && Uheader.headerOk())
|
||||
{
|
||||
Info<< "Reading T" << endl;
|
||||
volScalarField T(THeader, mesh);
|
||||
|
||||
Info<< "Reading U" << endl;
|
||||
volVectorField U(Uheader, mesh);
|
||||
|
||||
# include "createPhi.H"
|
||||
|
||||
volVectorField gradT(fvc::grad(T));
|
||||
|
||||
volScalarField TE(0.5*sqr(T));
|
||||
|
||||
volScalarField L
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"L",
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("one", dimLength, 1.0)
|
||||
);
|
||||
|
||||
L.internalField() =
|
||||
mesh.V()/fvc::surfaceSum(mesh.magSf())().internalField();
|
||||
|
||||
// Divergence of the error in the T squared
|
||||
volScalarField momError
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"momErrorL" + T.name(),
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
sqrt
|
||||
(
|
||||
2.0*mag
|
||||
(
|
||||
(
|
||||
fv::gaussConvectionScheme<scalar>
|
||||
(
|
||||
mesh,
|
||||
phi,
|
||||
tmp<surfaceInterpolationScheme<scalar> >
|
||||
(
|
||||
new linear<scalar>(mesh)
|
||||
)
|
||||
).fvcDiv(phi, TE)
|
||||
|
||||
- DT*
|
||||
fv::gaussLaplacianScheme<scalar, scalar>(mesh)
|
||||
.fvcLaplacian
|
||||
(
|
||||
TE
|
||||
)
|
||||
+ DT*(gradT & gradT)
|
||||
)*L/(mag(U) + DT/L)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
momError.boundaryField() = 0.0;
|
||||
momError.write();
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " No T or U" << endl;
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -19,7 +19,6 @@ EXE_LIBS = \
|
||||
-ldynamicMesh \
|
||||
-ledgeMesh \
|
||||
-lengine \
|
||||
-lerrorEstimation \
|
||||
-lextrudeModel \
|
||||
-lfieldFunctionObjects \
|
||||
-lfileFormats \
|
||||
|
||||
@ -105,8 +105,8 @@ int main()
|
||||
Z[Count] = Phi + 1.0;
|
||||
Count++;
|
||||
|
||||
X[Count] = -X[Count - 1];
|
||||
Y[Count] = -Y[Count - 1];
|
||||
X[Count] = -X[Count - 1];
|
||||
Y[Count] = -Y[Count - 1];
|
||||
Z[Count] = -Z[Count - 1];
|
||||
Count++;
|
||||
|
||||
@ -115,18 +115,18 @@ int main()
|
||||
Z[Count] = Phi - 1.0;
|
||||
Count++;
|
||||
|
||||
X[Count] = -X[Count - 1];
|
||||
Y[Count] = -Y[Count - 1];
|
||||
X[Count] = -X[Count - 1];
|
||||
Y[Count] = -Y[Count - 1];
|
||||
Z[Count] = -Z[Count - 1];
|
||||
Count++;
|
||||
}
|
||||
|
||||
INTEGER4 IsDouble = 1;
|
||||
|
||||
|
||||
I = TECDAT112(&NumPts, X, &IsDouble);
|
||||
I = TECDAT112(&NumPts, Y, &IsDouble);
|
||||
I = TECDAT112(&NumPts, Z, &IsDouble);
|
||||
|
||||
|
||||
delete X;
|
||||
delete Y;
|
||||
delete Z;
|
||||
@ -371,6 +371,6 @@ int main()
|
||||
I = TECEND112();
|
||||
/* DOCEND */
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Binary file not shown.
@ -3,7 +3,7 @@
|
||||
# ========= |
|
||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
# \\ / O peration |
|
||||
# \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
||||
# \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
|
||||
# \\/ M anipulation |
|
||||
#-------------------------------------------------------------------------------
|
||||
# License
|
||||
@ -94,7 +94,7 @@ do
|
||||
wildcard=$1
|
||||
shift
|
||||
##DEBUG echo "remove>$wildcard<" 1>&2
|
||||
dirList=$(echo "$dirList" | sed -e "s@${wildcard}[^:]*:@@g")
|
||||
dirList=$(echo "$dirList:" | sed -e "s@${wildcard}[^:]*:@@g")
|
||||
done
|
||||
|
||||
# split on ':' (and on space as well to avoid any surprises)
|
||||
|
||||
@ -105,7 +105,7 @@ echo $timeStamp 2>/dev/null > $packDir/.timeStamp
|
||||
if [ "$nogit" = true ]
|
||||
then
|
||||
echo "pack manually" 1>&2
|
||||
$toolsDir/foamPackSource $packDir $packFile
|
||||
foamPackSource $packDir $packFile
|
||||
else
|
||||
echo "pack with git-archive" 1>&2
|
||||
( cd $packDir && git archive --format=tar --prefix=$packDir/ HEAD) > $packBase.tar
|
||||
|
||||
@ -101,6 +101,6 @@ fi
|
||||
# add time-stamp file before packing
|
||||
echo $timeStamp 2>/dev/null > $packDir/.timeStamp
|
||||
echo "pack manually" 1>&2
|
||||
$toolsDir/foamPackSource $packDir $packFile
|
||||
foamPackSource $packDir $packFile
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
135
doc/changes/codeStream.org
Normal file
135
doc/changes/codeStream.org
Normal file
@ -0,0 +1,135 @@
|
||||
# -*- mode: org; -*-
|
||||
#
|
||||
#+TITLE: =codeStream=: On-the-fly code compilation
|
||||
#+AUTHOR: OpenCFD Ltd.
|
||||
#+DATE: TBA
|
||||
#+LINK: http://www.openfoam.com
|
||||
#+OPTIONS: author:nil ^:{}
|
||||
# Copyright (c) 2011 OpenCFD Ltd.
|
||||
|
||||
* Dictionary preprocessing directive: =#codeStream=
|
||||
This is a dictionary preprocessing directive ('=functionEntry=') which
|
||||
provides a snippet of OpenFOAM C++ code which gets compiled and executed to
|
||||
provide the actual dictionary entry. The snippet gets provided as three
|
||||
sections of C++ code which just gets inserted into a template:
|
||||
- =code= section: the actual body of the code. It gets called with arguments
|
||||
=const dictionary& dict, OStream& os= and the C++ code can do a
|
||||
=dict.lookup= to find current dictionary values.
|
||||
- optional =codeInclude= section: any #include statements to include OpenFOAM
|
||||
files.
|
||||
- optional 'codeOptions' section: any extra compilation flags to be added to
|
||||
=EXE_INC= in =Make/options=
|
||||
|
||||
To ease inputting mulit-line code there is the =#{ #}= syntax. Anything in
|
||||
between these two delimiters becomes a string with all newlines, quotes etc
|
||||
preserved.
|
||||
|
||||
Example: Look up dictionary entries and do some calculation
|
||||
#+BEGIN_SRC c++
|
||||
startTime 0;
|
||||
endTime 100;
|
||||
..
|
||||
writeInterval #codeStream
|
||||
{
|
||||
code
|
||||
#{
|
||||
scalar start = readScalar(dict["startTime"]);
|
||||
scalar end = readScalar(dict["endTime"]);
|
||||
label nDumps = 5;
|
||||
label interval = end-start
|
||||
os << ((start-end)/nDumps)
|
||||
#}
|
||||
};
|
||||
#+END_SRC
|
||||
|
||||
* Implementation
|
||||
- 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
|
||||
executed
|
||||
- the function will have written its output into the Ostream which then gets
|
||||
used to construct the entry to replace the whole =#codeStream= section.
|
||||
- using the sha1 means that same code will only be compiled and loaded once.
|
||||
|
||||
* Boundary condition: =codedFixedValue=
|
||||
This uses the code from codeStream to have an in-line specialised
|
||||
=fixedValueFvPatchScalarField=. For now only for scalars:
|
||||
#+BEGIN_SRC c++
|
||||
outlet
|
||||
{
|
||||
type codedFixedValue<scalar>;
|
||||
value uniform 0;
|
||||
redirectType fixedValue10;
|
||||
|
||||
code
|
||||
#{
|
||||
operator==(min(10, 0.1*this->db().time().value()));
|
||||
#};
|
||||
}
|
||||
#+END_SRC
|
||||
It by default always includes =fvCFD.H= and adds the =finiteVolume= library to
|
||||
the include search path.
|
||||
|
||||
* Security
|
||||
Allowing the case to execute C++ code does introduce security risks. A
|
||||
third-party case might have a =#codeStream{#code system("rm -rf .");};= hidden
|
||||
somewhere in a dictionary. =#codeStream= is therefore not enabled by default
|
||||
you have to enable it by setting in the system-wide =controlDict=
|
||||
#+BEGIN_SRC c++
|
||||
InfoSwitches
|
||||
{
|
||||
// Allow case-supplied c++ code (#codeStream, codedFixedValue)
|
||||
allowSystemOperations 1;
|
||||
}
|
||||
#+END_SRC
|
||||
|
||||
* Field manipulation
|
||||
Fields are read in as =IOdictionary= so can be upcast to provide access to the
|
||||
mesh:
|
||||
#+BEGIN_SRC c++
|
||||
internalField #codeStream
|
||||
{
|
||||
codeInclude
|
||||
#{
|
||||
#include "fvCFD.H"
|
||||
#};
|
||||
|
||||
code
|
||||
#{
|
||||
const IOdictionary& d = dynamicCast<const IOdictionary>(dict);
|
||||
const fvMesh& mesh = refCast<const fvMesh>(d.db());
|
||||
scalarField fld(mesh.nCells(), 12.34);
|
||||
fld.writeEntry("", os);
|
||||
#};
|
||||
|
||||
codeOptions
|
||||
#{
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude
|
||||
#};
|
||||
};
|
||||
#+END_SRC
|
||||
|
||||
* Exceptions
|
||||
There are unfortunately some exceptions. Following applications read
|
||||
the field as a dictionary, not as an =IOdictionary=:
|
||||
- =foamFormatConvert=
|
||||
- =changeDictionaryDict=
|
||||
- =foamUpgradeCyclics=
|
||||
- =fieldToCell=
|
||||
|
||||
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.
|
||||
|
||||
* Other
|
||||
- the implementation is still a bit raw - it compiles code overly much
|
||||
- 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?
|
||||
@ -38,7 +38,7 @@ cleaned=`$WM_PROJECT_DIR/bin/foamCleanPath "$PATH" "$WM_THIRD_PARTY_DIR/platform
|
||||
|
||||
# determine the cmake to be used
|
||||
unset CMAKE_HOME
|
||||
for cmake in cmake-2.8.3 cmake-2.8.1
|
||||
for cmake in cmake-2.8.4 cmake-2.8.3 cmake-2.8.1
|
||||
do
|
||||
cmake=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$cmake
|
||||
if [ -r $cmake ]
|
||||
|
||||
@ -39,7 +39,7 @@ if ( $status == 0 ) setenv PATH $cleaned
|
||||
|
||||
# determine the cmake to be used
|
||||
unsetenv CMAKE_HOME
|
||||
foreach cmake ( cmake-2.8.3 cmake-2.8.1 )
|
||||
foreach cmake ( cmake-2.8.4 cmake-2.8.3 cmake-2.8.1 )
|
||||
set cmake=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$cmake
|
||||
if ( -r $cmake ) then
|
||||
setenv CMAKE_HOME $cmake
|
||||
|
||||
48
etc/codeTemplates/codeStream/codeStreamTemplate.C
Normal file
48
etc/codeTemplates/codeStream/codeStreamTemplate.C
Normal 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};
|
||||
}
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -868,6 +868,9 @@ InfoSwitches
|
||||
{
|
||||
writePrecision 6;
|
||||
writeJobInfo 0;
|
||||
|
||||
// Allow case-supplied c++ code (#codeStream, codedFixedValue)
|
||||
allowSystemOperations 0;
|
||||
}
|
||||
|
||||
OptimisationSwitches
|
||||
|
||||
@ -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
|
||||
@ -84,7 +87,7 @@ _foamAddLib ${FOAM_USER_LIBBIN}:${FOAM_SITE_LIBBIN}:${FOAM_LIBBIN}:${FOAM_EXT_L
|
||||
# Compiler settings
|
||||
# ~~~~~~~~~~~~~~~~~
|
||||
unset gcc_version gmp_version mpfr_version mpc_version
|
||||
unsetenv MPFR_ARCH_PATH
|
||||
unsetenv MPFR_ARCH_PATH GMP_ARCH_PATH
|
||||
|
||||
|
||||
# Location of compiler installation
|
||||
@ -178,6 +181,7 @@ case ThirdParty:
|
||||
|
||||
# used by boost/CGAL:
|
||||
setenv MPFR_ARCH_PATH $mpfrDir
|
||||
setenv GMP_ARCH_PATH $gmpDir
|
||||
endif
|
||||
unset gcc_version gccDir
|
||||
unset gmp_version gmpDir mpfr_version mpfrDir mpc_version mpcDir
|
||||
@ -243,7 +247,7 @@ if ( -d "$CGAL_ARCH_PATH" ) then
|
||||
endif
|
||||
_foamAddLib $CGAL_ARCH_PATH/lib
|
||||
else
|
||||
unsetenv BOOST_ARCH_PATH CGAL_ARCH_PATH MPFR_ARCH_PATH
|
||||
unsetenv BOOST_ARCH_PATH CGAL_ARCH_PATH MPFR_ARCH_PATH GMP_ARCH_PATH
|
||||
endif
|
||||
|
||||
unset boost_version cgal_version
|
||||
|
||||
@ -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
|
||||
@ -107,7 +110,7 @@ _foamAddLib $FOAM_USER_LIBBIN:$FOAM_SITE_LIBBIN:$FOAM_LIBBIN:$FOAM_EXT_LIBBIN:$
|
||||
# Compiler settings
|
||||
# ~~~~~~~~~~~~~~~~~
|
||||
unset gcc_version gmp_version mpfr_version mpc_version
|
||||
unset MPFR_ARCH_PATH
|
||||
unset MPFR_ARCH_PATH GMP_ARCH_PATH
|
||||
|
||||
# Location of compiler installation
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@ -198,6 +201,7 @@ OpenFOAM | ThirdParty)
|
||||
|
||||
# used by boost/CGAL:
|
||||
export MPFR_ARCH_PATH=$mpfrDir
|
||||
export GMP_ARCH_PATH=$gmpDir
|
||||
fi
|
||||
unset gcc_version gccDir
|
||||
unset gmp_version gmpDir mpfr_version mpfrDir mpc_version mpcDir
|
||||
@ -264,7 +268,7 @@ then
|
||||
fi
|
||||
_foamAddLib $CGAL_ARCH_PATH/lib
|
||||
else
|
||||
unset BOOST_ARCH_PATH CGAL_ARCH_PATH MPFR_ARCH_PATH
|
||||
unset BOOST_ARCH_PATH CGAL_ARCH_PATH MPFR_ARCH_PATH GMP_ARCH_PATH
|
||||
fi
|
||||
|
||||
unset boost_version cgal_version
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -51,6 +51,7 @@ Description
|
||||
#include <sys/stat.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
@ -164,6 +165,12 @@ Foam::word Foam::userName()
|
||||
}
|
||||
|
||||
|
||||
bool Foam::isAdministrator()
|
||||
{
|
||||
return (geteuid() == 0);
|
||||
}
|
||||
|
||||
|
||||
// use $HOME environment variable or passwd info
|
||||
Foam::fileName Foam::home()
|
||||
{
|
||||
@ -240,7 +247,7 @@ Foam::fileName Foam::cwd()
|
||||
|
||||
bool Foam::chDir(const fileName& dir)
|
||||
{
|
||||
return chdir(dir.c_str()) != 0;
|
||||
return chdir(dir.c_str()) == 0;
|
||||
}
|
||||
|
||||
|
||||
@ -1065,4 +1072,31 @@ int Foam::system(const string& command)
|
||||
}
|
||||
|
||||
|
||||
void* Foam::dlOpen(const fileName& lib)
|
||||
{
|
||||
return dlopen(lib.c_str(), RTLD_LAZY|RTLD_GLOBAL);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::dlClose(void* handle)
|
||||
{
|
||||
return dlclose(handle) == 0;
|
||||
}
|
||||
|
||||
|
||||
void* Foam::dlSym(void* handle, const string& symbol)
|
||||
{
|
||||
void* fun = dlsym(handle, symbol.c_str());
|
||||
|
||||
char *error;
|
||||
if ((error = dlerror()) != NULL)
|
||||
{
|
||||
WarningIn("dlSym(void*, const string&)")
|
||||
<< "Cannot lookup symbol " << symbol << " : " << error
|
||||
<< endl;
|
||||
}
|
||||
return fun;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -159,6 +159,8 @@ $(dictionaryEntry)/dictionaryEntry.C
|
||||
$(dictionaryEntry)/dictionaryEntryIO.C
|
||||
|
||||
functionEntries = $(dictionary)/functionEntries
|
||||
$(functionEntries)/codeStream/codeStream.C
|
||||
$(functionEntries)/codeStream/codeStreamTools.C
|
||||
$(functionEntries)/functionEntry/functionEntry.C
|
||||
$(functionEntries)/includeEntry/includeEntry.C
|
||||
$(functionEntries)/includeIfPresentEntry/includeIfPresentEntry.C
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -27,6 +27,7 @@ License
|
||||
#include "int.H"
|
||||
#include "token.H"
|
||||
#include <cctype>
|
||||
#include "IOstreams.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
@ -109,6 +110,27 @@ char Foam::ISstream::nextValid()
|
||||
}
|
||||
|
||||
|
||||
void Foam::ISstream::readWordToken(token& t)
|
||||
{
|
||||
word* wPtr = new word;
|
||||
|
||||
if (read(*wPtr).bad())
|
||||
{
|
||||
delete wPtr;
|
||||
t.setBad();
|
||||
}
|
||||
else if (token::compound::isCompound(*wPtr))
|
||||
{
|
||||
t = token::compound::New(*wPtr, *this).ptr();
|
||||
delete wPtr;
|
||||
}
|
||||
else
|
||||
{
|
||||
t = wPtr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::Istream& Foam::ISstream::read(token& t)
|
||||
{
|
||||
static const int maxLen = 128;
|
||||
@ -181,7 +203,44 @@ Foam::Istream& Foam::ISstream::read(token& t)
|
||||
|
||||
return *this;
|
||||
}
|
||||
// Verbatim string
|
||||
case token::HASH :
|
||||
{
|
||||
char nextC;
|
||||
if (read(nextC).bad())
|
||||
{
|
||||
// Return hash as word
|
||||
t = token(word(c));
|
||||
return *this;
|
||||
}
|
||||
else if (nextC == token::BEGIN_BLOCK)
|
||||
{
|
||||
// Verbatim string
|
||||
string* sPtr = new string;
|
||||
|
||||
if (readVerbatim(*sPtr).bad())
|
||||
{
|
||||
delete sPtr;
|
||||
t.setBad();
|
||||
}
|
||||
else
|
||||
{
|
||||
t = sPtr;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Word beginning with #
|
||||
putback(nextC);
|
||||
putback(c);
|
||||
|
||||
readWordToken(t);
|
||||
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
// Number: integer or floating point
|
||||
//
|
||||
@ -302,22 +361,7 @@ Foam::Istream& Foam::ISstream::read(token& t)
|
||||
default:
|
||||
{
|
||||
putback(c);
|
||||
word* wPtr = new word;
|
||||
|
||||
if (read(*wPtr).bad())
|
||||
{
|
||||
delete wPtr;
|
||||
t.setBad();
|
||||
}
|
||||
else if (token::compound::isCompound(*wPtr))
|
||||
{
|
||||
t = token::compound::New(*wPtr, *this).ptr();
|
||||
delete wPtr;
|
||||
}
|
||||
else
|
||||
{
|
||||
t = wPtr;
|
||||
}
|
||||
readWordToken(t);
|
||||
|
||||
return *this;
|
||||
}
|
||||
@ -504,6 +548,60 @@ Foam::Istream& Foam::ISstream::read(string& str)
|
||||
}
|
||||
|
||||
|
||||
Foam::Istream& Foam::ISstream::readVerbatim(string& str)
|
||||
{
|
||||
static const int maxLen = 8000;
|
||||
static const int errLen = 80; // truncate error message for readability
|
||||
static char buf[maxLen];
|
||||
|
||||
char c;
|
||||
|
||||
register int nChar = 0;
|
||||
|
||||
while (get(c))
|
||||
{
|
||||
if (c == token::HASH)
|
||||
{
|
||||
char nextC;
|
||||
get(nextC);
|
||||
if (nextC == token::END_BLOCK)
|
||||
{
|
||||
buf[nChar] = '\0';
|
||||
str = buf;
|
||||
return *this;
|
||||
}
|
||||
else
|
||||
{
|
||||
putback(nextC);
|
||||
}
|
||||
}
|
||||
|
||||
buf[nChar++] = c;
|
||||
if (nChar == maxLen)
|
||||
{
|
||||
buf[errLen] = '\0';
|
||||
|
||||
FatalIOErrorIn("ISstream::readVerbatim(string&)", *this)
|
||||
<< "string \"" << buf << "...\"\n"
|
||||
<< " is too long (max. " << maxLen << " characters)"
|
||||
<< exit(FatalIOError);
|
||||
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// don't worry about a dangling backslash if string terminated prematurely
|
||||
buf[errLen] = buf[nChar] = '\0';
|
||||
|
||||
FatalIOErrorIn("ISstream::readVerbatim(string&)", *this)
|
||||
<< "problem while reading string \"" << buf << "...\""
|
||||
<< exit(FatalIOError);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Foam::Istream& Foam::ISstream::read(label& val)
|
||||
{
|
||||
is_ >> val;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -64,9 +64,15 @@ class ISstream
|
||||
|
||||
char nextValid();
|
||||
|
||||
void readWordToken(token&);
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
|
||||
//- Read a verbatim string (excluding block delimiters).
|
||||
Istream& readVerbatim(string&);
|
||||
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const ISstream&);
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -104,6 +104,7 @@ public:
|
||||
END_BLOCK = '}',
|
||||
COLON = ':',
|
||||
COMMA = ',',
|
||||
HASH = '#',
|
||||
|
||||
BEGIN_STRING = '"',
|
||||
END_STRING = BEGIN_STRING,
|
||||
|
||||
@ -0,0 +1,249 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "codeStream.H"
|
||||
#include "addToMemberFunctionSelectionTable.H"
|
||||
#include "IStringStream.H"
|
||||
#include "OStringStream.H"
|
||||
#include "IOstreams.H"
|
||||
#include "SHA1Digest.H"
|
||||
#include "OSHA1stream.H"
|
||||
#include "codeStreamTools.H"
|
||||
#include "dlLibraryTable.H"
|
||||
#include "OSspecific.H"
|
||||
#include "Time.H"
|
||||
#include "Pstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionEntries
|
||||
{
|
||||
defineTypeNameAndDebug(codeStream, 0);
|
||||
|
||||
addToMemberFunctionSelectionTable
|
||||
(
|
||||
functionEntry,
|
||||
codeStream,
|
||||
execute,
|
||||
primitiveEntryIstream
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionEntries::codeStream::execute
|
||||
(
|
||||
const dictionary& parentDict,
|
||||
primitiveEntry& entry,
|
||||
Istream& is
|
||||
)
|
||||
{
|
||||
if (isAdministrator())
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"functionEntries::codeStream::execute(..)",
|
||||
parentDict
|
||||
) << "This code should not be executed by someone with administrator"
|
||||
<< " rights due to security reasons." << endl
|
||||
<< "(it writes a shared library which then gets loaded "
|
||||
<< "using dlopen)"
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
|
||||
// Read three sections of code. Remove any leading empty lines
|
||||
// (necessary for compilation options, just visually pleasing for includes
|
||||
// and body).
|
||||
dictionary codeDict(is);
|
||||
|
||||
string codeInclude = "";
|
||||
if (codeDict.found("codeInclude"))
|
||||
{
|
||||
codeInclude = codeStreamTools::stripLeading(codeDict["codeInclude"]);
|
||||
}
|
||||
string code = codeStreamTools::stripLeading(codeDict["code"]);
|
||||
|
||||
string codeOptions = "";
|
||||
if (codeDict.found("codeOptions"))
|
||||
{
|
||||
codeOptions = codeStreamTools::stripLeading(codeDict["codeOptions"]);
|
||||
}
|
||||
|
||||
|
||||
// Create name out of contents
|
||||
|
||||
SHA1Digest sha;
|
||||
{
|
||||
OSHA1stream os;
|
||||
os << codeInclude << code << codeOptions;
|
||||
sha = os.digest();
|
||||
}
|
||||
fileName name;
|
||||
{
|
||||
OStringStream str;
|
||||
str << sha;
|
||||
name = "codeStream" + str.str();
|
||||
}
|
||||
|
||||
fileName dir;
|
||||
if (isA<IOdictionary>(parentDict))
|
||||
{
|
||||
const IOdictionary& d = static_cast<const IOdictionary&>(parentDict);
|
||||
dir = d.db().time().constantPath()/"codeStream"/name;
|
||||
}
|
||||
else
|
||||
{
|
||||
dir = "codeStream"/name;
|
||||
}
|
||||
|
||||
|
||||
fileName libPath
|
||||
(
|
||||
Foam::getEnv("FOAM_USER_LIBBIN")
|
||||
/ "lib"
|
||||
+ name
|
||||
+ ".so"
|
||||
);
|
||||
|
||||
void* lib = dlLibraryTable::findLibrary(libPath);
|
||||
|
||||
if (!lib)
|
||||
{
|
||||
if (Pstream::master())
|
||||
{
|
||||
if (!codeStreamTools::upToDate(dir, sha))
|
||||
{
|
||||
Info<< "Creating new library in " << libPath << endl;
|
||||
|
||||
fileName templates
|
||||
(
|
||||
Foam::getEnv("FOAM_CODESTREAM_TEMPLATE_DIR")
|
||||
);
|
||||
if (!templates.size())
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"functionEntries::codeStream::execute(..)",
|
||||
parentDict
|
||||
) << "Please set environment variable"
|
||||
" FOAM_CODESTREAM_TEMPLATE_DIR"
|
||||
<< " to point to the location of codeStreamTemplate.C"
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
List<fileAndVars> copyFiles(1);
|
||||
copyFiles[0].first() = templates/"codeStreamTemplate.C";
|
||||
stringPairList bodyVars(2);
|
||||
bodyVars[0] = Pair<string>("codeInclude", codeInclude);
|
||||
bodyVars[1] = Pair<string>("code", code);
|
||||
copyFiles[0].second() = bodyVars;
|
||||
|
||||
List<fileAndContent> filesContents(2);
|
||||
// Write Make/files
|
||||
filesContents[0].first() = "Make/files";
|
||||
filesContents[0].second() =
|
||||
"codeStreamTemplate.C \n\
|
||||
LIB = $(FOAM_USER_LIBBIN)/lib" + name;
|
||||
// Write Make/options
|
||||
filesContents[1].first() = "Make/options";
|
||||
filesContents[1].second() =
|
||||
"EXE_INC = -g\\\n" + codeOptions + "\n\nLIB_LIBS = ";
|
||||
|
||||
codeStreamTools writer(name, copyFiles, filesContents);
|
||||
if (!writer.copyFilesContents(dir))
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"functionEntries::codeStream::execute(..)",
|
||||
parentDict
|
||||
) << "Failed writing " << endl
|
||||
<< copyFiles << endl
|
||||
<< filesContents
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
|
||||
Foam::string wmakeCmd("wmake libso " + dir);
|
||||
Info<< "Invoking " << wmakeCmd << endl;
|
||||
if (Foam::system(wmakeCmd))
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"functionEntries::codeStream::execute(..)",
|
||||
parentDict
|
||||
) << "Failed " << wmakeCmd << exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
|
||||
if (!dlLibraryTable::open(libPath))
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"functionEntries::codeStream::execute(..)",
|
||||
parentDict
|
||||
) << "Failed loading library " << libPath << exit(FatalIOError);
|
||||
}
|
||||
|
||||
lib = dlLibraryTable::findLibrary(libPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "Reusing library in " << libPath << endl;
|
||||
}
|
||||
|
||||
|
||||
// Find the library handle.
|
||||
void (*function)(const dictionary&, Ostream&);
|
||||
function = reinterpret_cast<void(*)(const dictionary&, Ostream&)>
|
||||
(
|
||||
dlSym(lib, name)
|
||||
);
|
||||
|
||||
if (!function)
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"functionEntries::codeStream::execute(..)",
|
||||
parentDict
|
||||
) << "Failed looking up symbol " << name
|
||||
<< " in library " << lib << exit(FatalIOError);
|
||||
}
|
||||
|
||||
OStringStream os;
|
||||
(*function)(parentDict, os);
|
||||
IStringStream resultStream(os.str());
|
||||
entry.read(parentDict, resultStream);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,136 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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::functionEntries::codeStream
|
||||
|
||||
Description
|
||||
Dictionary entry that contains C++ OpenFOAM code that is compiled to
|
||||
generate the entry itself. So
|
||||
- codeStream reads three entries: 'code', 'codeInclude' (optional),
|
||||
'codeOptions' (optional)
|
||||
and uses those to generate library sources inside constant/codeStream/
|
||||
- these get compiled using 'wmake libso'
|
||||
- the resulting library is loaded in executed with as arguments
|
||||
const dictionary& dict,
|
||||
Ostream& os
|
||||
where the dictionary is the current dictionary.
|
||||
- the code has to write into Ostream which is then used to construct
|
||||
the actual dictionary entry.
|
||||
|
||||
|
||||
E.g. to set the internal field of a field:
|
||||
|
||||
internalField #codeStream
|
||||
{
|
||||
code
|
||||
#{
|
||||
const IOdictionary& d = static_cast<const IOdictionary&>(dict);
|
||||
const fvMesh& mesh = refCast<const fvMesh>(d.db());
|
||||
scalarField fld(mesh.nCells(), 12.34);
|
||||
fld.writeEntry("", os);
|
||||
#};
|
||||
|
||||
//- Optional:
|
||||
codeInclude
|
||||
#{
|
||||
#include "fvCFD.H"
|
||||
#};
|
||||
codeOptions
|
||||
#{
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude
|
||||
#};
|
||||
};
|
||||
|
||||
|
||||
Note the #{ #} syntax which is just a way of inputting strings with embedded
|
||||
newlines.
|
||||
|
||||
Limitations:
|
||||
- '~' symbol not allowed inside the code sections.
|
||||
- probably some other limitations (uses string::expand which expands $, ~)
|
||||
|
||||
SourceFiles
|
||||
codeStream.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef codeStream_H
|
||||
#define codeStream_H
|
||||
|
||||
#include "functionEntry.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
class ISstream;
|
||||
|
||||
namespace functionEntries
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class codeStream Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class codeStream
|
||||
:
|
||||
public functionEntry
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
codeStream(const codeStream&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const codeStream&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
ClassName("codeStream");
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
static bool execute
|
||||
(
|
||||
const dictionary& parentDict,
|
||||
primitiveEntry& entry,
|
||||
Istream& is
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionEntries
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,282 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "codeStreamTools.H"
|
||||
#include "IFstream.H"
|
||||
#include "OFstream.H"
|
||||
#include "OSspecific.H"
|
||||
#include "dictionary.H"
|
||||
#include "dlLibraryTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
int Foam::codeStreamTools::allowSystemOperations
|
||||
(
|
||||
Foam::debug::infoSwitch("allowSystemOperations", 0)
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::codeStreamTools::copyAndExpand
|
||||
(
|
||||
ISstream& sourceStr,
|
||||
OSstream& destStr
|
||||
) const
|
||||
{
|
||||
if (!sourceStr.good())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"codeStreamTools::copyAndExpand()"
|
||||
" const"
|
||||
) << "Failed opening for reading " << sourceStr.name()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
if (!destStr.good())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"codeStreamTools::copyAndExpand()"
|
||||
" const"
|
||||
) << "Failed writing " << destStr.name() << exit(FatalError);
|
||||
}
|
||||
|
||||
// Copy file whilst rewriting environment vars
|
||||
string line;
|
||||
do
|
||||
{
|
||||
sourceStr.getLine(line);
|
||||
line.expand(true, true); // replace any envvars inside substitutions
|
||||
destStr<< line.c_str() << nl;
|
||||
}
|
||||
while (sourceStr.good());
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::codeStreamTools::codeStreamTools()
|
||||
{}
|
||||
|
||||
|
||||
Foam::codeStreamTools::codeStreamTools
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
name_(name)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
Foam::codeStreamTools::codeStreamTools
|
||||
(
|
||||
const word& name,
|
||||
const List<fileAndVars>& copyFiles,
|
||||
const List<fileAndContent>& filesContents
|
||||
)
|
||||
:
|
||||
name_(name),
|
||||
copyFiles_(copyFiles),
|
||||
filesContents_(filesContents)
|
||||
{}
|
||||
|
||||
|
||||
Foam::codeStreamTools::codeStreamTools(const codeStreamTools& otf)
|
||||
:
|
||||
name_(otf.name_),
|
||||
copyFiles_(otf.copyFiles_),
|
||||
filesContents_(otf.filesContents_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::codeStreamTools::copyFilesContents(const fileName& dir) const
|
||||
{
|
||||
if (!allowSystemOperations)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"codeStreamTools::copyFilesContents(const fileName&) const"
|
||||
) << "Loading a shared library using case-supplied code is not"
|
||||
<< " enabled by default" << endl
|
||||
<< "because of security issues. If you trust the code you can"
|
||||
<< " enable this" << endl
|
||||
<< "facility be adding to the InfoSwitches setting in the system"
|
||||
<< " controlDict:" << endl
|
||||
<< endl
|
||||
<< " allowSystemOperations 1" << endl
|
||||
<< endl
|
||||
<< "The system controlDict is either" << endl
|
||||
<< endl
|
||||
<< " ~/.OpenFOAM/$WM_PROJECT_VERSION/controlDict" << endl
|
||||
<< endl
|
||||
<< "or" << endl
|
||||
<< endl
|
||||
<< " $WM_PROJECT_DIR/etc/controlDict" << endl
|
||||
<< endl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
// Create dir
|
||||
mkDir(dir);
|
||||
|
||||
//Info<< "Setting envvar typeName=" << name_ << endl;
|
||||
setEnv("typeName", name_, true);
|
||||
// Copy any template files
|
||||
forAll(copyFiles_, i)
|
||||
{
|
||||
const List<Pair<string> >& rules = copyFiles_[i].second();
|
||||
forAll(rules, j)
|
||||
{
|
||||
//Info<< "Setting envvar " << rules[j].first() << endl;
|
||||
setEnv(rules[j].first(), rules[j].second(), true);
|
||||
}
|
||||
|
||||
const fileName sourceFile = fileName(copyFiles_[i].first()).expand();
|
||||
const fileName destFile = dir/sourceFile.name();
|
||||
|
||||
IFstream sourceStr(sourceFile);
|
||||
//Info<< "Reading from " << sourceStr.name() << endl;
|
||||
if (!sourceStr.good())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"codeStreamTools::copyFilesContents()"
|
||||
" const"
|
||||
) << "Failed opening " << sourceFile << exit(FatalError);
|
||||
}
|
||||
|
||||
OFstream destStr(destFile);
|
||||
//Info<< "Writing to " << destFile.name() << endl;
|
||||
if (!destStr.good())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"codeStreamTools::copyFilesContents()"
|
||||
" const"
|
||||
) << "Failed writing " << destFile << exit(FatalError);
|
||||
}
|
||||
|
||||
copyAndExpand(sourceStr, destStr);
|
||||
}
|
||||
|
||||
// Files that are always written:
|
||||
forAll(filesContents_, i)
|
||||
{
|
||||
fileName f = fileName(dir/filesContents_[i].first()).expand();
|
||||
|
||||
mkDir(f.path());
|
||||
OFstream str(f);
|
||||
//Info<< "Writing to " << filesContents_[i].first() << endl;
|
||||
if (!str.good())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"codeStreamTools::copyFilesContents()"
|
||||
" const"
|
||||
) << "Failed writing " << f << exit(FatalError);
|
||||
}
|
||||
str << filesContents_[i].second().c_str() << endl;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Foam::string Foam::codeStreamTools::stripLeading(const string& s)
|
||||
{
|
||||
label sz = s.size();
|
||||
if (sz > 0 && s[0] == '\n')
|
||||
{
|
||||
return s(1, sz-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Foam::codeStreamTools::writeDigest
|
||||
(
|
||||
const fileName& dir,
|
||||
const SHA1Digest& sha1
|
||||
)
|
||||
{
|
||||
OFstream str(dir/"SHA1Digest");
|
||||
str << sha1;
|
||||
return str.good();
|
||||
}
|
||||
|
||||
|
||||
Foam::SHA1Digest Foam::codeStreamTools::readDigest(const fileName& dir)
|
||||
{
|
||||
IFstream str(dir/"SHA1Digest");
|
||||
return SHA1Digest(str);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::codeStreamTools::upToDate
|
||||
(
|
||||
const fileName& dir,
|
||||
const SHA1Digest& sha1
|
||||
)
|
||||
{
|
||||
if (!exists(dir/"SHA1Digest") || readDigest(dir) != sha1)
|
||||
{
|
||||
writeDigest(dir, sha1);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Foam::codeStreamTools::read(const dictionary& dict)
|
||||
{
|
||||
dict.lookup("copyFiles") >> copyFiles_;
|
||||
dict.lookup("filesContents") >> filesContents_;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::codeStreamTools::writeDict(Ostream& os) const
|
||||
{
|
||||
os.writeKeyword("copyFiles") << copyFiles_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("filesContents") << filesContents_ << token::END_STATEMENT
|
||||
<< nl;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,144 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::codeStreamTools
|
||||
|
||||
Description
|
||||
Base for all things on-the-fly from dictionary
|
||||
|
||||
SourceFiles
|
||||
codeStreamTools.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef codeStreamTools_H
|
||||
#define codeStreamTools_H
|
||||
|
||||
#include "Tuple2.H"
|
||||
#include "Pair.H"
|
||||
#include "SHA1Digest.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
|
||||
typedef List<Pair<string> > stringPairList;
|
||||
typedef Tuple2<fileName, List<Pair<string> > > fileAndVars;
|
||||
typedef Tuple2<fileName, string> fileAndContent;
|
||||
|
||||
|
||||
class OSstream;
|
||||
class ISstream;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class codeStreamTools Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class codeStreamTools
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Name for underlying set
|
||||
word name_;
|
||||
|
||||
//- Files to copy
|
||||
List<fileAndVars> copyFiles_;
|
||||
|
||||
//- Direct contents for files
|
||||
List<fileAndContent> filesContents_;
|
||||
|
||||
protected:
|
||||
|
||||
void copyAndExpand(ISstream&, OSstream&) const;
|
||||
|
||||
public:
|
||||
|
||||
static int allowSystemOperations;
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
codeStreamTools();
|
||||
|
||||
//- Construct from dictionary
|
||||
codeStreamTools(const word& name, const dictionary& dict);
|
||||
|
||||
//- Copy from components
|
||||
codeStreamTools
|
||||
(
|
||||
const word& name,
|
||||
const List<fileAndVars>&,
|
||||
const List<fileAndContent>&
|
||||
);
|
||||
|
||||
//- Construct copy
|
||||
codeStreamTools(const codeStreamTools& otf);
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
const List<Tuple2<fileName, List<Pair<string> > > >& copyFiles() const
|
||||
{
|
||||
return copyFiles_;
|
||||
}
|
||||
|
||||
const List<Tuple2<fileName, string> >& filesContents() const
|
||||
{
|
||||
return filesContents_;
|
||||
}
|
||||
|
||||
const word& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
bool copyFilesContents(const fileName& dir) const;
|
||||
|
||||
static void* findLibrary(const fileName& libPath);
|
||||
|
||||
static string stripLeading(const string&);
|
||||
|
||||
static bool writeDigest(const fileName& dir, const SHA1Digest& sha1);
|
||||
static SHA1Digest readDigest(const fileName& dir);
|
||||
static bool upToDate(const fileName& dir, const SHA1Digest& sha1);
|
||||
|
||||
bool read(const dictionary&);
|
||||
|
||||
void writeDict(Ostream&) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -24,8 +24,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "dlLibraryTable.H"
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include "OSspecific.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -56,7 +55,7 @@ Foam::dlLibraryTable::~dlLibraryTable()
|
||||
{
|
||||
forAllConstIter(dlLibraryTable, *this, iter)
|
||||
{
|
||||
dlclose(iter.key());
|
||||
dlClose(iter.key());
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,15 +66,14 @@ bool Foam::dlLibraryTable::open(const fileName& functionLibName)
|
||||
{
|
||||
if (functionLibName.size())
|
||||
{
|
||||
void* functionLibPtr =
|
||||
dlopen(functionLibName.c_str(), RTLD_LAZY|RTLD_GLOBAL);
|
||||
void* functionLibPtr = dlOpen(functionLibName);
|
||||
|
||||
if (!functionLibPtr)
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"dlLibraryTable::open(const fileName& functionLibName)"
|
||||
) << "could not load " << dlerror()
|
||||
) << "could not load " << functionLibName
|
||||
<< endl;
|
||||
|
||||
return false;
|
||||
@ -99,6 +97,43 @@ bool Foam::dlLibraryTable::open(const fileName& functionLibName)
|
||||
}
|
||||
|
||||
|
||||
bool Foam::dlLibraryTable::close(const fileName& functionLibName)
|
||||
{
|
||||
void* libPtr = findLibrary(functionLibName);
|
||||
if (libPtr)
|
||||
{
|
||||
loadedLibraries.erase(libPtr);
|
||||
|
||||
if (!dlClose(libPtr))
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"dlLibraryTable::close(const fileName& functionLibName)"
|
||||
) << "could not close " << functionLibName
|
||||
<< endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void* Foam::dlLibraryTable::findLibrary(const fileName& functionLibName)
|
||||
{
|
||||
forAllConstIter(dlLibraryTable, loadedLibraries, iter)
|
||||
{
|
||||
if (iter() == functionLibName)
|
||||
{
|
||||
return iter.key();
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::dlLibraryTable::open
|
||||
(
|
||||
const dictionary& dict,
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -97,6 +97,12 @@ public:
|
||||
//- Open the named library
|
||||
static bool open(const fileName& name);
|
||||
|
||||
//- Close the named library
|
||||
static bool close(const fileName& name);
|
||||
|
||||
//- Find the handle of the named library
|
||||
static void* findLibrary(const fileName& name);
|
||||
|
||||
//- Open all the libraries listed in the 'libsEntry' entry in the
|
||||
// given dictionary if present
|
||||
static bool open(const dictionary&, const word& libsEntry);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -46,11 +46,11 @@ UNARY_FUNCTION(tensor, tensor, dev2, transform)
|
||||
UNARY_FUNCTION(scalar, tensor, det, transform)
|
||||
UNARY_FUNCTION(tensor, tensor, cof, cof)
|
||||
UNARY_FUNCTION(tensor, tensor, inv, inv)
|
||||
UNARY_FUNCTION(vector, tensor, eigenValues, sign)
|
||||
UNARY_FUNCTION(tensor, tensor, eigenVectors, transform)
|
||||
UNARY_FUNCTION(vector, tensor, eigenValues, transform)
|
||||
UNARY_FUNCTION(tensor, tensor, eigenVectors, sign)
|
||||
|
||||
UNARY_FUNCTION(vector, symmTensor, eigenValues, sign)
|
||||
UNARY_FUNCTION(symmTensor, symmTensor, eigenVectors, transform)
|
||||
UNARY_FUNCTION(vector, symmTensor, eigenValues, transform)
|
||||
UNARY_FUNCTION(symmTensor, symmTensor, eigenVectors, sign)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * global operators * * * * * * * * * * * * * //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -59,11 +59,11 @@ UNARY_FUNCTION(tensor, tensor, dev2, transform)
|
||||
UNARY_FUNCTION(scalar, tensor, det, transform)
|
||||
UNARY_FUNCTION(tensor, tensor, cof, cof)
|
||||
UNARY_FUNCTION(tensor, tensor, inv, inv)
|
||||
UNARY_FUNCTION(vector, tensor, eigenValues, sign)
|
||||
UNARY_FUNCTION(tensor, tensor, eigenVectors, transform)
|
||||
UNARY_FUNCTION(vector, tensor, eigenValues, transform)
|
||||
UNARY_FUNCTION(tensor, tensor, eigenVectors, sign)
|
||||
|
||||
UNARY_FUNCTION(vector, symmTensor, eigenValues, sign)
|
||||
UNARY_FUNCTION(symmTensor, symmTensor, eigenVectors, transform)
|
||||
UNARY_FUNCTION(vector, symmTensor, eigenValues, transform)
|
||||
UNARY_FUNCTION(symmTensor, symmTensor, eigenVectors, sign)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * global operators * * * * * * * * * * * * * //
|
||||
|
||||
@ -32,6 +32,7 @@ License
|
||||
#include "JobInfo.H"
|
||||
#include "labelList.H"
|
||||
#include "regIOobject.H"
|
||||
#include "codeStreamTools.H"
|
||||
|
||||
#include <cctype>
|
||||
|
||||
@ -787,6 +788,16 @@ Foam::argList::argList
|
||||
regIOobject::fileModificationChecking
|
||||
]
|
||||
<< endl;
|
||||
|
||||
Info<< "allowSystemOperations : ";
|
||||
if (codeStreamTools::allowSystemOperations)
|
||||
{
|
||||
Info<< "Allowing user-supplied system call operations" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "Disallowing user-supplied system call operations" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (Pstream::master() && bannerEnabled)
|
||||
|
||||
@ -77,6 +77,9 @@ word domainName();
|
||||
//- Return the user's login name
|
||||
word userName();
|
||||
|
||||
//- Is user administrator
|
||||
bool isAdministrator();
|
||||
|
||||
//- Return home directory path name for the current user
|
||||
fileName home();
|
||||
|
||||
@ -181,6 +184,16 @@ bool ping(const word&, const label timeOut=10);
|
||||
//- Execute the specified command
|
||||
int system(const string& command);
|
||||
|
||||
//- open a shared library. Return handle to library
|
||||
void* dlOpen(const fileName& lib);
|
||||
|
||||
//- Close a dlopened library using handle. Return true if successful
|
||||
bool dlClose(void*);
|
||||
|
||||
//- Lookup a symbol in a dlopened library using handle
|
||||
void* dlSym(void* handle, const string& symbol);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -94,7 +94,7 @@ Foam::string& Foam::string::replaceAll
|
||||
|
||||
|
||||
// Expand all occurences of environment variables and initial tilde sequences
|
||||
Foam::string& Foam::string::expand(const bool recurse)
|
||||
Foam::string& Foam::string::expand(const bool recurse, const bool allowEmptyVar)
|
||||
{
|
||||
size_type startEnvar = 0;
|
||||
|
||||
@ -142,7 +142,7 @@ Foam::string& Foam::string::expand(const bool recurse)
|
||||
{
|
||||
if (recurse)
|
||||
{
|
||||
enVarString.expand();
|
||||
enVarString.expand(recurse, allowEmptyVar);
|
||||
}
|
||||
std::string::replace
|
||||
(
|
||||
@ -152,11 +152,18 @@ Foam::string& Foam::string::expand(const bool recurse)
|
||||
);
|
||||
startEnvar += enVarString.size();
|
||||
}
|
||||
else if (allowEmptyVar)
|
||||
{
|
||||
std::string::replace
|
||||
(
|
||||
startEnvar,
|
||||
endEnvar - startEnvar + 1,
|
||||
""
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
//startEnvar = endEnvar;
|
||||
|
||||
FatalErrorIn("string::expand()")
|
||||
FatalErrorIn("string::expand(const bool, const bool)")
|
||||
<< "Unknown variable name " << enVar << '.'
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
@ -182,7 +182,11 @@ public:
|
||||
//
|
||||
// \sa
|
||||
// Foam::findEtcFile
|
||||
string& expand(const bool recurse=false);
|
||||
string& expand
|
||||
(
|
||||
const bool recurse=false,
|
||||
const bool allowEmptyVar = false
|
||||
);
|
||||
|
||||
//- Remove repeated characters returning true if string changed
|
||||
bool removeRepeated(const char);
|
||||
|
||||
@ -114,6 +114,8 @@ derivedFvPatchFields = $(fvPatchFields)/derived
|
||||
$(derivedFvPatchFields)/activeBaffleVelocity/activeBaffleVelocityFvPatchVectorField.C
|
||||
$(derivedFvPatchFields)/advective/advectiveFvPatchFields.C
|
||||
|
||||
$(derivedFvPatchFields)/codedFixedValue/codedFixedValueFvPatchScalarField.C
|
||||
$(derivedFvPatchFields)/codedFixedValue/codeProperties.C
|
||||
$(derivedFvPatchFields)/directMappedFixedValue/directMappedFixedValueFvPatchFields.C
|
||||
$(derivedFvPatchFields)/directMappedVelocityFluxFixedValue/directMappedVelocityFluxFixedValueFvPatchField.C
|
||||
$(derivedFvPatchFields)/fan/fanFvPatchFields.C
|
||||
|
||||
@ -0,0 +1,59 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "codeProperties.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(Foam::codeProperties, 0);
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::codeProperties::codeProperties(const IOobject& io)
|
||||
:
|
||||
IOdictionary(io),
|
||||
modified_(true)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::codeProperties::read()
|
||||
{
|
||||
if (regIOobject::read())
|
||||
{
|
||||
modified_ = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,96 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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::codeProperties
|
||||
|
||||
Description
|
||||
IOdictionary + flag whether file has changed.
|
||||
|
||||
SourceFiles
|
||||
codeProperties.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef codeProperties_H
|
||||
#define codeProperties_H
|
||||
|
||||
#include "MeshObject.H"
|
||||
#include "IOdictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class codeProperties Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class codeProperties
|
||||
:
|
||||
public IOdictionary
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- File change
|
||||
mutable bool modified_;
|
||||
|
||||
public:
|
||||
|
||||
// Declare name of the class and its debug switch
|
||||
ClassName("codeDict");
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from IOobject
|
||||
codeProperties(const IOobject&);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
bool modified() const
|
||||
{
|
||||
return modified_;
|
||||
}
|
||||
|
||||
void setUnmodified() const
|
||||
{
|
||||
modified_ = false;
|
||||
}
|
||||
|
||||
//- Read the solution dictionary
|
||||
virtual bool read();
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,420 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2010-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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "codedFixedValueFvPatchScalarField.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "fvPatchFieldMapper.H"
|
||||
#include "surfaceFields.H"
|
||||
#include "volFields.H"
|
||||
#include "dlLibraryTable.H"
|
||||
#include "IFstream.H"
|
||||
#include "OFstream.H"
|
||||
#include "codeStreamTools.H"
|
||||
#include "codeProperties.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
const Foam::codeProperties&
|
||||
Foam::codedFixedValueFvPatchScalarField::dict() const
|
||||
{
|
||||
if (db().foundObject<codeProperties>(codeProperties::typeName))
|
||||
{
|
||||
return db().lookupObject<codeProperties>
|
||||
(
|
||||
codeProperties::typeName
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
codeProperties* props = new codeProperties
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
codeProperties::typeName,
|
||||
db().time().system(),
|
||||
db(),
|
||||
IOobject::MUST_READ_IF_MODIFIED,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
return db().store(props);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::codedFixedValueFvPatchScalarField::writeLibrary
|
||||
(
|
||||
const fileName dir,
|
||||
const fileName libPath,
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
Info<< "Creating new library in " << libPath << endl;
|
||||
|
||||
// Write files for new library
|
||||
if (Pstream::master())
|
||||
{
|
||||
fileName templates(Foam::getEnv("FOAM_CODESTREAM_TEMPLATE_DIR"));
|
||||
if (!templates.size())
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"codedFixedValueFvPatchScalarField::writeLibrary(..)",
|
||||
dict
|
||||
) << "Please set environment variable"
|
||||
<< " FOAM_CODESTREAM_TEMPLATE_DIR"
|
||||
<< " to point to the location of "
|
||||
<< "fixedValueFvPatchScalarFieldTemplate.C"
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
|
||||
// Extract sections of code
|
||||
string codeInclude = "";
|
||||
if (dict.found("codeInclude"))
|
||||
{
|
||||
codeInclude = codeStreamTools::stripLeading(dict["codeInclude"]);
|
||||
}
|
||||
string code = codeStreamTools::stripLeading(dict["code"]);
|
||||
|
||||
string codeOptions = "";
|
||||
if (dict.found("codeOptions"))
|
||||
{
|
||||
codeOptions = codeStreamTools::stripLeading(dict["codeOptions"]);
|
||||
}
|
||||
|
||||
|
||||
List<fileAndVars> copyFiles(2);
|
||||
copyFiles[0].first() =
|
||||
templates/"fixedValueFvPatchScalarFieldTemplate.C";
|
||||
|
||||
copyFiles[0].second().setSize(2);
|
||||
copyFiles[0].second()[0] = Pair<string>("codeInclude", codeInclude);
|
||||
copyFiles[0].second()[1] = Pair<string>("code", code);
|
||||
|
||||
copyFiles[1].first() =
|
||||
templates/"fixedValueFvPatchScalarFieldTemplate.H";
|
||||
|
||||
|
||||
|
||||
List<fileAndContent> filesContents(2);
|
||||
// Write Make/files
|
||||
filesContents[0].first() = "Make/files";
|
||||
filesContents[0].second() =
|
||||
"fixedValueFvPatchScalarFieldTemplate.C \n\n"
|
||||
"LIB = $(FOAM_USER_LIBBIN)/lib" + redirectType_;
|
||||
// Write Make/options
|
||||
filesContents[1].first() = "Make/options";
|
||||
filesContents[1].second() =
|
||||
"EXE_INC = -g\\\n -I$(LIB_SRC)/finiteVolume/lnInclude\\\n"
|
||||
+ codeOptions
|
||||
+ "\n\nLIB_LIBS = ";
|
||||
|
||||
codeStreamTools writer(redirectType_, copyFiles, filesContents);
|
||||
if (!writer.copyFilesContents(dir))
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"codedFixedValueFvPatchScalarField::writeLibrary(..)",
|
||||
dict
|
||||
) << "Failed writing " << endl
|
||||
<< copyFiles << endl
|
||||
<< filesContents
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::codedFixedValueFvPatchScalarField::updateLibrary()
|
||||
{
|
||||
if (isAdministrator())
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"codedFixedValueFvPatchScalarField::updateLibrary()",
|
||||
dict_
|
||||
) << "This code should not be executed by someone with administrator"
|
||||
<< " rights due to security reasons." << endl
|
||||
<< "(it writes a shared library which then gets loaded "
|
||||
<< "using dlopen)"
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
const fileName dir =
|
||||
db().time().constantPath()/"codeStream"/redirectType_;
|
||||
//Info<< "dir:" << dir << endl;
|
||||
|
||||
const fileName libPath
|
||||
(
|
||||
Foam::getEnv("FOAM_USER_LIBBIN")
|
||||
/ "lib"
|
||||
+ redirectType_
|
||||
+ ".so"
|
||||
);
|
||||
//Info<< "libPath:" << libPath << endl;
|
||||
|
||||
void* lib = dlLibraryTable::findLibrary(libPath);
|
||||
|
||||
if (dict_.found("code"))
|
||||
{
|
||||
if (!lib)
|
||||
{
|
||||
writeLibrary(dir, libPath, dict_);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const codeProperties& onTheFlyDict = dict();
|
||||
|
||||
if (onTheFlyDict.modified())
|
||||
{
|
||||
onTheFlyDict.setUnmodified();
|
||||
|
||||
// Remove instantiation of fvPatchField provided by library
|
||||
redirectPatchFieldPtr_.clear();
|
||||
// Unload library
|
||||
if (lib)
|
||||
{
|
||||
if (!dlLibraryTable::close(libPath))
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"codedFixedValueFvPatchScalarField::updateLibrary(..)",
|
||||
onTheFlyDict
|
||||
) << "Failed unloading library " << libPath
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
lib = NULL;
|
||||
}
|
||||
|
||||
const dictionary& codeDict = onTheFlyDict.subDict(redirectType_);
|
||||
writeLibrary(dir, libPath, codeDict);
|
||||
}
|
||||
}
|
||||
|
||||
if (!lib)
|
||||
{
|
||||
if (Pstream::master())
|
||||
{
|
||||
Foam::string wmakeCmd("wmake libso " + dir);
|
||||
Info<< "Invoking " << wmakeCmd << endl;
|
||||
if (Foam::system(wmakeCmd))
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"codedFixedValueFvPatchScalarField::updateLibrary()",
|
||||
dict_
|
||||
) << "Failed " << wmakeCmd << exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
|
||||
bool dummy = true;
|
||||
reduce(dummy, orOp<bool>());
|
||||
|
||||
if (!dlLibraryTable::open(libPath))
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"codedFixedValueFvPatchScalarField::updateLibrary()",
|
||||
dict_
|
||||
) << "Failed loading library " << libPath << exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::codedFixedValueFvPatchScalarField::
|
||||
codedFixedValueFvPatchScalarField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<scalar>(p, iF),
|
||||
redirectPatchFieldPtr_(NULL)
|
||||
{}
|
||||
|
||||
|
||||
Foam::codedFixedValueFvPatchScalarField::
|
||||
codedFixedValueFvPatchScalarField
|
||||
(
|
||||
const codedFixedValueFvPatchScalarField& ptf,
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF,
|
||||
const fvPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<scalar>(ptf, p, iF, mapper),
|
||||
dict_(ptf.dict_),
|
||||
redirectType_(ptf.redirectType_),
|
||||
redirectPatchFieldPtr_(NULL)
|
||||
{}
|
||||
|
||||
|
||||
Foam::codedFixedValueFvPatchScalarField::
|
||||
codedFixedValueFvPatchScalarField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<scalar>(p, iF, dict),
|
||||
dict_(dict),
|
||||
redirectType_(dict.lookup("redirectType")),
|
||||
redirectPatchFieldPtr_(NULL)
|
||||
{
|
||||
updateLibrary();
|
||||
}
|
||||
|
||||
|
||||
Foam::codedFixedValueFvPatchScalarField::
|
||||
codedFixedValueFvPatchScalarField
|
||||
(
|
||||
const codedFixedValueFvPatchScalarField& ptf
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<scalar>(ptf),
|
||||
dict_(ptf.dict_),
|
||||
redirectType_(ptf.redirectType_),
|
||||
redirectPatchFieldPtr_(NULL)
|
||||
{}
|
||||
|
||||
|
||||
Foam::codedFixedValueFvPatchScalarField::
|
||||
codedFixedValueFvPatchScalarField
|
||||
(
|
||||
const codedFixedValueFvPatchScalarField& ptf,
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<scalar>(ptf, iF),
|
||||
dict_(ptf.dict_),
|
||||
redirectType_(ptf.redirectType_),
|
||||
redirectPatchFieldPtr_(NULL)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::fvPatchScalarField&
|
||||
Foam::codedFixedValueFvPatchScalarField::redirectPatchField() const
|
||||
{
|
||||
if (!redirectPatchFieldPtr_.valid())
|
||||
{
|
||||
// Construct a patch
|
||||
|
||||
// Make sure to construct the patchfield with uptodate value.
|
||||
OStringStream os;
|
||||
os.writeKeyword("type") << redirectType_ << token::END_STATEMENT
|
||||
<< nl;
|
||||
static_cast<const scalarField&>(*this).writeEntry("value", os);
|
||||
IStringStream is(os.str());
|
||||
dictionary dict(is);
|
||||
Info<< "constructing patchField from :" << dict << endl;
|
||||
|
||||
redirectPatchFieldPtr_.set
|
||||
(
|
||||
fvPatchScalarField::New
|
||||
(
|
||||
patch(),
|
||||
dimensionedInternalField(),
|
||||
dict
|
||||
).ptr()
|
||||
);
|
||||
}
|
||||
return redirectPatchFieldPtr_();
|
||||
}
|
||||
|
||||
|
||||
void Foam::codedFixedValueFvPatchScalarField::updateCoeffs()
|
||||
{
|
||||
if (updated())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure library containing user-defined fvPatchField is uptodate
|
||||
updateLibrary();
|
||||
|
||||
const fvPatchScalarField& fvp = redirectPatchField();
|
||||
|
||||
const_cast<fvPatchScalarField&>(fvp).updateCoeffs();
|
||||
|
||||
// Copy through value
|
||||
operator==(fvp);
|
||||
|
||||
fixedValueFvPatchField<scalar>::updateCoeffs();
|
||||
}
|
||||
|
||||
|
||||
void Foam::codedFixedValueFvPatchScalarField::evaluate
|
||||
(
|
||||
const Pstream::commsTypes commsType
|
||||
)
|
||||
{
|
||||
// Make sure library containing user-defined fvPatchField is uptodate
|
||||
updateLibrary();
|
||||
|
||||
const fvPatchScalarField& fvp = redirectPatchField();
|
||||
|
||||
const_cast<fvPatchScalarField&>(fvp).evaluate(commsType);
|
||||
|
||||
fixedValueFvPatchField<scalar>::evaluate(commsType);
|
||||
}
|
||||
|
||||
|
||||
void Foam::codedFixedValueFvPatchScalarField::write(Ostream& os) const
|
||||
{
|
||||
//dict_.set("value", static_cast<const scalarField&>(*this));
|
||||
//os << dict_ << token::END_STATEMENT << nl;
|
||||
fixedValueFvPatchField<scalar>::write(os);
|
||||
os.writeKeyword("redirectType") << redirectType_ << token::END_STATEMENT
|
||||
<< nl;
|
||||
if (dict_.found("code"))
|
||||
{
|
||||
os.writeKeyword("code") << string(dict_["code"]) << token::END_STATEMENT
|
||||
<< nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
makePatchTypeField
|
||||
(
|
||||
fvPatchScalarField,
|
||||
codedFixedValueFvPatchScalarField
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,221 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2010-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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::codedFixedValueFvPatchScalarField
|
||||
|
||||
Description
|
||||
Constructs on-the-fly a new boundary condition (derived from
|
||||
fixedValueFvPatchScalarField) which is then used to evaluate.
|
||||
|
||||
See also codeStream.
|
||||
|
||||
Example:
|
||||
|
||||
movingWall
|
||||
{
|
||||
type codedFixedValue<scalar>;
|
||||
value uniform 0;
|
||||
redirectType rampedFixedValue; // name of generated bc
|
||||
|
||||
code
|
||||
#{
|
||||
operator==(min(10, 0.1*this->db().time().value()));
|
||||
#};
|
||||
|
||||
//codeInclude
|
||||
//#{
|
||||
// #include "fvCFD.H"
|
||||
//#};
|
||||
|
||||
//codeOptions
|
||||
//#{
|
||||
// -I$(LIB_SRC)/finiteVolume/lnInclude
|
||||
//#};
|
||||
|
||||
}
|
||||
|
||||
A special form is if the 'code' section is not supplied. In this case
|
||||
the code gets read from a (runTimeModifiable!) dictionary system/codeDict
|
||||
which would have an entry
|
||||
|
||||
rampedFixedValue
|
||||
{
|
||||
code
|
||||
#{
|
||||
operator==(min(10, 0.1*this->db().time().value()));
|
||||
#};
|
||||
}
|
||||
|
||||
SourceFiles
|
||||
codedFixedValueFvPatchScalarField.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef codedFixedValueFvPatchScalarField_H
|
||||
#define codedFixedValueFvPatchScalarField_H
|
||||
|
||||
#include "fixedValueFvPatchFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class codeProperties;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class codedFixedValueFvPatchScalarField Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class codedFixedValueFvPatchScalarField
|
||||
:
|
||||
public fixedValueFvPatchScalarField
|
||||
{
|
||||
// Private data
|
||||
|
||||
mutable dictionary dict_;
|
||||
|
||||
const word redirectType_;
|
||||
|
||||
mutable autoPtr<fvPatchScalarField> redirectPatchFieldPtr_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
const codeProperties& dict() const;
|
||||
|
||||
void writeLibrary
|
||||
(
|
||||
const fileName dir,
|
||||
const fileName libPath,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
void updateLibrary();
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("codedFixedValue<scalar>");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from patch and internal field
|
||||
codedFixedValueFvPatchScalarField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct from patch, internal field and dictionary
|
||||
codedFixedValueFvPatchScalarField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
//- Construct by mapping given
|
||||
// codedFixedValueFvPatchScalarField
|
||||
// onto a new patch
|
||||
codedFixedValueFvPatchScalarField
|
||||
(
|
||||
const codedFixedValueFvPatchScalarField&,
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&,
|
||||
const fvPatchFieldMapper&
|
||||
);
|
||||
|
||||
//- Construct as copy
|
||||
codedFixedValueFvPatchScalarField
|
||||
(
|
||||
const codedFixedValueFvPatchScalarField&
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<fvPatchScalarField> clone() const
|
||||
{
|
||||
return tmp<fvPatchScalarField>
|
||||
(
|
||||
new codedFixedValueFvPatchScalarField
|
||||
(
|
||||
*this
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
//- Construct as copy setting internal field reference
|
||||
codedFixedValueFvPatchScalarField
|
||||
(
|
||||
const codedFixedValueFvPatchScalarField&,
|
||||
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 codedFixedValueFvPatchScalarField
|
||||
(
|
||||
*this,
|
||||
iF
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Get reference to the underlying patch
|
||||
const fvPatchScalarField& redirectPatchField() const;
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
virtual void updateCoeffs();
|
||||
|
||||
//- Evaluate the patch field, sets Updated to false
|
||||
virtual void evaluate
|
||||
(
|
||||
const Pstream::commsTypes commsType=Pstream::blocking
|
||||
);
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -139,7 +139,6 @@ Foam::pointField Foam::treeDataCell::points() const
|
||||
}
|
||||
|
||||
|
||||
// Check if any point on shape is inside cubeBb.
|
||||
bool Foam::treeDataCell::overlaps
|
||||
(
|
||||
const label index,
|
||||
@ -167,8 +166,6 @@ bool Foam::treeDataCell::contains
|
||||
}
|
||||
|
||||
|
||||
// Calculate nearest point to sample. Updates (if any) nearestDistSqr, minIndex,
|
||||
// nearestPoint.
|
||||
void Foam::treeDataCell::findNearest
|
||||
(
|
||||
const labelUList& indices,
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -24,8 +24,8 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "systemCall.H"
|
||||
#include "dictionary.H"
|
||||
#include "Time.H"
|
||||
#include "codeStreamTools.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -71,6 +71,30 @@ void Foam::systemCall::read(const dictionary& dict)
|
||||
<< "no executeCalls, endCalls or writeCalls defined."
|
||||
<< endl;
|
||||
}
|
||||
else if (!codeStreamTools::allowSystemOperations)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"systemCall::read(const dictionary&)"
|
||||
) << "Executing user-supplied system calls is not"
|
||||
<< " enabled by default" << endl
|
||||
<< "because of security issues. If you trust the case you can"
|
||||
<< " enable this" << endl
|
||||
<< "facility be adding to the InfoSwitches setting in the system"
|
||||
<< " controlDict:" << endl
|
||||
<< endl
|
||||
<< " allowSystemOperations 1" << endl
|
||||
<< endl
|
||||
<< "The system controlDict is either" << endl
|
||||
<< endl
|
||||
<< " ~/.OpenFOAM/$WM_PROJECT_VERSION/controlDict" << endl
|
||||
<< endl
|
||||
<< "or" << endl
|
||||
<< endl
|
||||
<< " $WM_PROJECT_DIR/etc/controlDict" << endl
|
||||
<< endl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -78,7 +102,7 @@ void Foam::systemCall::execute()
|
||||
{
|
||||
forAll(executeCalls_, callI)
|
||||
{
|
||||
::system(executeCalls_[callI].c_str());
|
||||
Foam::system(executeCalls_[callI].c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,7 +111,7 @@ void Foam::systemCall::end()
|
||||
{
|
||||
forAll(endCalls_, callI)
|
||||
{
|
||||
::system(endCalls_[callI].c_str());
|
||||
Foam::system(endCalls_[callI].c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,7 +120,7 @@ void Foam::systemCall::write()
|
||||
{
|
||||
forAll(writeCalls_, callI)
|
||||
{
|
||||
::system(writeCalls_[callI].c_str());
|
||||
Foam::system(writeCalls_[callI].c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -26,8 +26,21 @@ License
|
||||
#include "Reaction.H"
|
||||
#include "DynamicList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Static Data * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class ReactionThermo>
|
||||
Foam::label Foam::Reaction<ReactionThermo>::nUnNamedReactions = 0;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class ReactionThermo>
|
||||
Foam::label Foam::Reaction<ReactionThermo>::getNewReactionID()
|
||||
{
|
||||
return nUnNamedReactions++;
|
||||
}
|
||||
|
||||
|
||||
template<class ReactionThermo>
|
||||
Foam::string Foam::Reaction<ReactionThermo>::reactionStr() const
|
||||
{
|
||||
@ -114,6 +127,7 @@ Foam::Reaction<ReactionThermo>::Reaction
|
||||
)
|
||||
:
|
||||
ReactionThermo(*thermoDatabase[species[0]]),
|
||||
name_("un-named-reaction-" + Foam::name(getNewReactionID())),
|
||||
species_(species),
|
||||
lhs_(lhs),
|
||||
rhs_(rhs)
|
||||
@ -130,6 +144,7 @@ Foam::Reaction<ReactionThermo>::Reaction
|
||||
)
|
||||
:
|
||||
ReactionThermo(r),
|
||||
name_(r.name() + "Copy"),
|
||||
species_(species),
|
||||
lhs_(r.lhs_),
|
||||
rhs_(r.rhs_)
|
||||
@ -236,6 +251,7 @@ Foam::Reaction<ReactionThermo>::Reaction
|
||||
)
|
||||
:
|
||||
ReactionThermo(*thermoDatabase[species[0]]),
|
||||
name_("un-named-reaction" + Foam::name(getNewReactionID())),
|
||||
species_(species)
|
||||
{
|
||||
setLRhs(is);
|
||||
@ -252,6 +268,7 @@ Foam::Reaction<ReactionThermo>::Reaction
|
||||
)
|
||||
:
|
||||
ReactionThermo(*thermoDatabase[species[0]]),
|
||||
name_(dict.dictName()),
|
||||
species_(species)
|
||||
{
|
||||
setLRhs(IStringStream(dict.lookup("reaction"))());
|
||||
@ -318,7 +335,7 @@ Foam::Reaction<ReactionThermo>::New
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
const word& reactionTypeName = dict.dictName();
|
||||
const word& reactionTypeName = dict.lookup("type");
|
||||
|
||||
typename dictionaryConstructorTable::iterator cstrIter
|
||||
= dictionaryConstructorTablePtr_->find(reactionTypeName);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -69,6 +69,12 @@ class Reaction
|
||||
|
||||
public:
|
||||
|
||||
// Static data
|
||||
|
||||
//- Number of un-named reactions
|
||||
static label nUnNamedReactions;
|
||||
|
||||
|
||||
// Public data types
|
||||
|
||||
//- Class to hold the specie index and its coefficients in the
|
||||
@ -112,6 +118,9 @@ private:
|
||||
|
||||
// Private data
|
||||
|
||||
//- Name of reaction
|
||||
const word name_;
|
||||
|
||||
//- List of specie names present in reaction system
|
||||
const speciesTable& species_;
|
||||
|
||||
@ -136,6 +145,9 @@ private:
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const Reaction<ReactionThermo>&);
|
||||
|
||||
//- Return new reaction ID for un-named reactions
|
||||
label getNewReactionID();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -282,6 +294,9 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
inline word& name();
|
||||
inline const word& name() const;
|
||||
|
||||
inline const List<specieCoeffs>& lhs() const;
|
||||
inline const List<specieCoeffs>& rhs() const;
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -32,6 +32,20 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class ReactionThermo>
|
||||
inline word& Reaction<ReactionThermo>::name()
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
|
||||
template<class ReactionThermo>
|
||||
inline const word& Reaction<ReactionThermo>::name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
|
||||
template<class ReactionThermo>
|
||||
inline const List<typename Reaction<ReactionThermo>::specieCoeffs>&
|
||||
Reaction<ReactionThermo>::lhs() const
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2010-2011 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -105,13 +105,15 @@ bool Foam::ReactionList<ThermoType>::readReactionDict()
|
||||
|
||||
forAllConstIter(dictionary, reactions, iter)
|
||||
{
|
||||
const word reactionName = iter().keyword();
|
||||
|
||||
this->append
|
||||
(
|
||||
Reaction<ThermoType>::New
|
||||
(
|
||||
species_,
|
||||
thermoDb_,
|
||||
reactions.subDict(iter().keyword())
|
||||
reactions.subDict(reactionName)
|
||||
).ptr()
|
||||
);
|
||||
}
|
||||
@ -129,8 +131,9 @@ void Foam::ReactionList<ThermoType>::write(Ostream& os) const
|
||||
forAllConstIter(typename SLPtrList<Reaction<ThermoType> >, *this, iter)
|
||||
{
|
||||
const Reaction<ThermoType>& r = iter();
|
||||
os << indent << r.type() << nl
|
||||
os << indent << r.name() << nl
|
||||
<< indent << token::BEGIN_BLOCK << incrIndent << nl;
|
||||
os.writeKeyword("type") << r.type() << token::END_STATEMENT << nl;
|
||||
r.write(os);
|
||||
os << decrIndent << indent << token::END_BLOCK << nl;
|
||||
}
|
||||
|
||||
@ -9,8 +9,9 @@ species
|
||||
|
||||
reactions
|
||||
{
|
||||
irreversibleArrheniusReaction
|
||||
methaneReaction
|
||||
{
|
||||
type irreversibleArrheniusReaction;
|
||||
reaction "CH4 + 2O2 = CO2 + 2H2O";
|
||||
A 5.2e16;
|
||||
beta 0;
|
||||
|
||||
@ -10,15 +10,17 @@ species
|
||||
|
||||
reactions
|
||||
{
|
||||
irreversibleArrheniusReaction
|
||||
methaneReaction
|
||||
{
|
||||
type irreversibleArrheniusReaction;
|
||||
reaction "CH4 + 2O2^1.0 = CO2 + 2H2O^1.0";
|
||||
A 7e+06;
|
||||
beta 0;
|
||||
Ta 10063.8;
|
||||
}
|
||||
irreversibleArrheniusReaction
|
||||
hydrogenReaction
|
||||
{
|
||||
type irreversibleArrheniusReaction;
|
||||
reaction "H2 + 0.5O2^1.0 = H2O";
|
||||
A 4.74342e+12;
|
||||
beta 0;
|
||||
|
||||
@ -9,11 +9,12 @@ species
|
||||
|
||||
reactions
|
||||
{
|
||||
irreversibleArrheniusReaction
|
||||
methaneReaction
|
||||
{
|
||||
type irreversibleArrheniusReaction;
|
||||
reaction "CH4 + 2O2 = CO2 + 2H2O";
|
||||
A 5.2e16;
|
||||
beta 0;
|
||||
Ta 14906;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,8 @@ CGAL_INC = \
|
||||
-Wno-old-style-cast \
|
||||
-I$(CGAL_ARCH_PATH)/include \
|
||||
-I$(MPFR_ARCH_PATH)/include \
|
||||
-I$(BOOST_ARCH_PATH)/include/boost
|
||||
-I$(GMP_ARCH_PATH)/include \
|
||||
-I$(BOOST_ARCH_PATH)/include
|
||||
|
||||
CGAL_LIBS = \
|
||||
-L$(MPFR_ARCH_PATH)/lib \
|
||||
|
||||
Reference in New Issue
Block a user