Commit Graph

1760 Commits

Author SHA1 Message Date
Henry Weller
22f4ad32b1 Completed boundaryField() -> boundaryFieldRef()
Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=1938

Because C++ does not support overloading based on the return-type there
is a problem defining both const and non-const member functions which
are resolved based on the const-ness of the object for which they are
called rather than the intent of the programmer declared via the
const-ness of the returned type.  The issue for the "boundaryField()"
member function is that the non-const version increments the
event-counter and checks the state of the stored old-time fields in case
the returned value is altered whereas the const version has no
side-effects and simply returns the reference.  If the the non-const
function is called within the patch-loop the event-counter may overflow.
To resolve this it in necessary to avoid calling the non-const form of
"boundaryField()" if the results is not altered and cache the reference
outside the patch-loop when mutation of the patch fields is needed.

The most straight forward way of resolving this problem is to name the
const and non-const forms of the member functions differently e.g. the
non-const form could be named:

    mutableBoundaryField()
    mutBoundaryField()
    nonConstBoundaryField()
    boundaryFieldRef()

Given that in C++ a reference is non-const unless specified as const:
"T&" vs "const T&" the logical convention would be

    boundaryFieldRef()
    boundaryFieldConstRef()

and given that the const form which is more commonly used is it could
simply be named "boundaryField()" then the logical convention is

    GeometricBoundaryField& boundaryFieldRef();

    inline const GeometricBoundaryField& boundaryField() const;

This is also consistent with the new "tmp" class for which non-const
access to the stored object is obtained using the ".ref()" member function.

This new convention for non-const access to the components of
GeometricField will be applied to "dimensionedInternalField()" and "internalField()" in the
future, i.e. "dimensionedInternalFieldRef()" and "internalFieldRef()".
2016-04-25 16:16:05 +01:00
Henry Weller
43beb06018 Standardized cell, patch and face loop index names 2016-04-25 10:28:32 +01:00
Henry Weller
2d5ff31649 boundaryField() -> boundaryFieldRef() 2016-04-24 22:07:37 +01:00
Henry Weller
673e0d1704 fireFoam: Added optional hydrostatic initialization of the pressure and density
Also added the new prghTotalHydrostaticPressure p_rgh BC which uses the
hydrostatic pressure field as the reference state for the far-field
which provides much more accurate entrainment is large open domains
typical of many fire simulations.

The hydrostatic field solution is controlled by the optional entries in
the fvSolution.PIMPLE dictionary, e.g.

    hydrostaticInitialization yes;
    nHydrostaticCorrectors 5;

and the solver must also be specified for the hydrostatic p_rgh field
ph_rgh e.g.

    ph_rgh
    {
        $p_rgh;
    }

Suitable boundary conditions for ph_rgh cannot always be derived from
those for p_rgh and so the ph_rgh is read to provide them.

To avoid accuracy issues with IO, restart and post-processing the p_rgh
and ph_rgh the option to specify a suitable reference pressure is
provided via the optional pRef file in the constant directory, e.g.

    dimensions      [1 -1 -2 0 0 0 0];
    value           101325;

which is used in the relationship between p_rgh and p:

    p = p_rgh + rho*gh + pRef;

Note that if pRef is specified all pressure BC specifications in the
p_rgh and ph_rgh files are relative to the reference to avoid round-off
errors.

For examples of suitable BCs for p_rgh and ph_rgh for a range of
fireFoam cases please study the tutorials in
tutorials/combustion/fireFoam/les which have all been updated.

Henry G. Weller
CFD Direct Ltd.
2016-04-23 10:04:39 +01:00
Henry Weller
a78beef988 JohnsonJacksonSchaefferFrictionalStress: Updated I2D expression 2016-04-22 15:13:45 +01:00
Henry Weller
bbca1fd5e7 reactingTwoPhaseEulerFoam: Corrected kineticTheory frictional stress at walls
Patch contributed by Juho Peltola, VTT

The new JohnsonJacksonSchaefferFrictionalStress model is included and
the LBend tutorial case to demonstrate the need for the changes to the
frictional stress models.

Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=2058
2016-04-22 14:25:58 +01:00
Henry Weller
8c6fa81eba vector::zero -> Zero 2016-04-16 18:34:41 +01:00
Henry Weller
77b03e2e0c Specialized dotInterpolate for the efficient calculation of flux fields
e.g. (fvc::interpolate(HbyA) & mesh.Sf()) -> fvc::flux(HbyA)

This removes the need to create an intermediate face-vector field when
computing fluxes which is more efficient, reduces the peak storage and
improved cache coherency in addition to providing a simpler and cleaner
API.
2016-04-06 20:20:53 +01:00
Henry Weller
a9b8bb13e0 applications/.*/Allwmake: Updated to support "stop on 1st error"
Patch contributed by Bruno Santos
Resolved bug-report http://www.openfoam.org/mantisbt/view.php?id=2042
2016-04-04 09:03:40 +01:00
Henry Weller
730f89dc9d Use Zero rather than pTraits<Type>::zero unless a static typed '0' is required 2016-03-22 17:46:52 +00:00
Henry Weller
cb65ba71d7 Made all template declarations consistent using 'class' rather than 'typename' 2016-03-22 15:02:55 +00:00
Henry Weller
665f5243b1 reactingEulerFoam: Moved fluid.correctThermo() into energy corrector loop
to update the interfacial temperature.
Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=2029
2016-03-17 08:05:08 +00:00
Henry Weller
01cdde52b9 driftFluxFoam/relativeVelocityModels/general/general:: Corrected construction of residualAlpha 2016-03-15 20:33:06 +00:00
Henry Weller
e57874859a Updated Doxygen documentation and files
Contributed by Bruno Santos
Resolves patch report http://www.openfoam.org/mantisbt/view.php?id=2023

Update online documentation http://openfoam.github.io/Documentation-dev/html/
2016-03-14 11:00:24 +00:00
Henry Weller
e5045949f6 JohnsonJacksonParticle*FvPatchScalarField.C: Corrected null-construction initialization
Resolves bug-report http://openfoam.org/mantisbt/view.php?id=2022
2016-03-08 14:13:05 +00:00
Henry Weller
8a93701ef2 simpleFoam, SRFSimpleFoam: Added momentumPredictor option 2016-03-07 15:27:01 +00:00
Henry Weller
0f5059927c reactingTwoPhaseEulerFoam: Corrected mass exchange terms in the face-momentum equation
Thanks to Juho Peltola for the patch
2016-03-06 19:02:43 +00:00
Henry Weller
7ba41e0095 Removed duplicate, inconsistent and spurious comments in .C files 2016-02-29 18:33:54 +00:00
Henry Weller
95d146ecdf Rationalized the indentation of C-preprocessor directives 2016-02-29 15:42:03 +00:00
Henry Weller
cd852be3da OpenFOAM: Updated all libraries, solvers and utilities to use the new const-safe tmp
The deprecated non-const tmp functionality is now on the compiler switch
NON_CONST_TMP which can be enabled by adding -DNON_CONST_TMP to EXE_INC
in the Make/options file.  However, it is recommended to upgrade all
code to the new safer tmp by using the '.ref()' member function rather
than the non-const '()' dereference operator when non-const access to
the temporary object is required.

Please report any problems on Mantis.

Henry G. Weller
CFD Direct.
2016-02-26 17:31:28 +00:00
Henry Weller
37c1c04487 reactingTwoPhaseEulerFoam/Make/options: Removed temporary debug option 2016-02-24 14:05:20 +00:00
Henry Weller
c02bf70ea7 tmp: Improved reference count checks to provide better error diagnostics
in case of tmp misuse.

Simplified tmp reuse pattern in field algebra to use tmp copy and
assignment rather than the complex delayed call to 'ptr()'.

Removed support for unused non-const 'REF' storage of non-tmp objects due to C++
limitation in constructor overloading: if both tmp(T&) and tmp(const T&)
constructors are provided resolution is ambiguous.

The turbulence libraries have been upgraded and '-DCONST_TMP' option
specified in the 'options' file to switch to the new 'tmp' behavior.
2016-02-24 12:47:36 +00:00
Henry Weller
15b7e87da7 tmp: Updated to store and preserve the const-ness of the reference to a constant object
This change requires that the de-reference operator '()' returns a
const-reference to the object stored irrespective of the const-ness of
object stored and the new member function 'ref()' is provided to return
an non-const reference to stored object which throws a fatal error if the
stored object is const.

In order to smooth the transition to this new safer 'tmp' the now
deprecated and unsafe non-const de-reference operator '()' is still
provided by default but may be switched-off with the compilation switch
'CONST_TMP'.

The main OpenFOAM library has already been upgraded and '-DCONST_TMP'
option specified in the 'options' file to switch to the new 'tmp'
behavior.  The rest of OpenFOAM-dev will be upgraded over the following
few weeks.

Henry G. Weller
CFD Direct
2016-02-22 16:23:21 +00:00
Henry Weller
99a10ecea6 Boundary conditions: Added extrapolatedCalculatedFvPatchField
To be used instead of zeroGradientFvPatchField for temporary fields for
which zero-gradient extrapolation is use to evaluate the boundary field
but avoiding fields derived from temporary field using field algebra
inheriting the zeroGradient boundary condition by the reuse of the
temporary field storage.

zeroGradientFvPatchField should not be used as the default patch field
for any temporary fields and should be avoided for non-temporary fields
except where it is clearly appropriate;
extrapolatedCalculatedFvPatchField and calculatedFvPatchField are
generally more suitable defaults depending on the manner in which the
boundary values are specified or evaluated.

The entire OpenFOAM-dev code-base has been updated following the above
recommendations.

Henry G. Weller
CFD Direct
2016-02-20 22:44:37 +00:00
Henry Weller
46df3ab456 kineticTheoryModel: Corrected handling of the SuSp term in the Theta equation
Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=2002
2016-02-19 13:26:41 +00:00
Henry Weller
8b71babfdd interFoam, interMixingFoam, interPhaseChangeFoam: construct rho with calculated BCs
Avoids problems with inherited complex BCs for which the controlling
fields and parameters are not initialized.
2016-02-18 21:26:25 +00:00
Henry Weller
9162fedfc4 chemFoam: use default (empty) BCs for U rather than inheriting from p 2016-02-18 21:18:54 +00:00
Henry Weller
aa81dee52d sprayEngineFoam: Corrected included pEqn.H
Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=2000
2016-02-18 08:27:21 +00:00
Henry Weller
350d03246e scripts: Reformat with consistent section separators 2016-02-15 18:30:24 +00:00
Henry Weller
fc2ce73723 Solvers: Added support for extrapolated pressure boundary conditions
The boundary conditions of HbyA are now constrained by the new "constrainHbyA"
function which applies the velocity boundary values for patches for which the
velocity cannot be modified by assignment and pressure extrapolation is
not specified via the new
"fixedFluxExtrapolatedPressureFvPatchScalarField".

The new function "constrainPressure" sets the pressure gradient
appropriately for "fixedFluxPressureFvPatchScalarField" and
"fixedFluxExtrapolatedPressureFvPatchScalarField" boundary conditions to
ensure the evaluated flux corresponds to the known velocity values at
the boundary.

The "fixedFluxPressureFvPatchScalarField" boundary condition operates
exactly as before, ensuring the correct flux at fixed-flux boundaries by
compensating for the body forces (gravity in particular) with the
pressure gradient.

The new "fixedFluxExtrapolatedPressureFvPatchScalarField" boundary
condition may be used for cases with or without body-forces to set the
pressure gradient to compensate not only for the body-force but also the
extrapolated "HbyA" which provides a second-order boundary condition for
pressure.  This is useful for a range a problems including impinging
flow, extrapolated inlet conditions with body-forces or for highly
viscous flows, pressure-induced separation etc.  To test this boundary
condition at walls in the motorBike tutorial case set

    lowerWall
    {
        type            fixedFluxExtrapolatedPressure;
    }

    motorBikeGroup
    {
        type            fixedFluxExtrapolatedPressure;
    }

Currently the new extrapolated pressure boundary condition is supported
for all incompressible and sub-sonic compressible solvers except those
providing implicit and tensorial porosity support.  The approach will be
extended to cover these solvers and options in the future.

Note: the extrapolated pressure boundary condition is experimental and
requires further testing to assess the range of applicability,
stability, accuracy etc.

Henry G. Weller
CFD Direct Ltd.
2016-02-13 17:48:26 +00:00
Henry Weller
566512bc28 driftFluxFoam: Set Udm BCs to type calculated 2016-02-11 08:48:15 +00:00
Henry Weller
3205337e81 scalarTransportFoam: Added support for steady-state solution and all fvOptions
Optional under-relaxation is provided for steady-state solution.
Added missing fvOptions.constrain and fvOptions.correct calls.
2016-01-19 21:20:03 +00:00
Henry Weller
bbb5a8086a reactingEulerFoam/interfacialModels/wallLubricationModels: Apply zero-gradient condition at walls 2016-01-19 15:26:42 +00:00
Henry Weller
8effc018c1 reactingEulerFoam,twoPhaseEulerFoam: Corrected pressure equations for transonic operation
Resolves bug-report http://openfoam.org/mantisbt/view.php?id=1971
2016-01-17 11:02:21 +00:00
Henry Weller
f19f48132e Consistently indent continuation backslashes in macro definitions 2016-01-11 13:00:56 +00:00
Henry Weller
56fa7c0906 Update code to use the simpler C++11 template syntax removing spaces between closing ">"s 2016-01-10 22:41:16 +00:00
Henry Weller
75cf86b769 Correct formatting: "forAll (" -> "forAll("
Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=1967
2016-01-09 23:10:16 +00:00
Henry Weller
2647d178fa solvers: Change from pure RAS to any turbulence model
Provides support for running laminar.
2015-12-16 10:13:09 +00:00
Henry Weller
4976c6e522 SRFSimpleFoam: Change from pure RAS to any turbulence model
Provides support for running laminar.
Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=1951
2015-12-15 19:05:08 +00:00
Henry Weller
fc98b1f6dc reactingEulerFoam/interfacialModels/dragModels/TomiyamaKataokaZunSakaguchi: New drag model
Drag model for gas-liquid system of Tomiyama et al.

Reference:
    "Drag coefficients of single bubbles under normal and microgravity
     conditions"
    Tomiyama, A., Kataoka, I., Zun, I., Sakaguchi, T.
    JSME International Series B, Fluids and Thermal Engineering,
    Vol. 41, 1998, pp. 472-479

Provided by Alberto Passalacq
2015-12-09 16:51:46 +00:00
Henry Weller
4930a5169a reactingMultiphaseEulerFoam: Correct and test LTS support 2015-12-09 15:39:45 +00:00
Henry Weller
1d893a0bd6 reactingEulerFoam: Move LTS controls maxCo, maxDeltaT and rDeltaTSmoothingCoeff into the PIMPLE sub-dictionary
For consistency with all other solvers supporting the LTS option
2015-12-09 15:38:09 +00:00
Henry Weller
fb871828a5 fvPatchFields, fvsPatchFields, pointPatchFields: specifically declare namespace of functions
It is better to declare the namespace of each function in the C file
rather than "open" the namespace as this may lead to inconsistencies
between the declaration in the H files and definition in the C file.
2015-12-08 22:29:05 +00:00
Henry Weller
17cc8483ef saturationModels/Antoine: Corrected dimensions in Tsat
Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=1940
2015-12-05 16:12:57 +00:00
Henry Weller
4025d6ebdd reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels: Added support for fvOptions 2015-12-03 16:39:13 +00:00
Henry Weller
a52cae9102 reactingEulerFoam: Lookup fvOptions from the mesh rather than construct a local copy 2015-12-02 15:39:45 +00:00
Henry Weller
736621b945 fvOptions: Reorganized and updated to simplify use in sub-models and maintenance
fvOptions are transferred to the database on construction using
fv::options::New which returns a reference.  The same function can be
use for construction and lookup so that fvOptions are now entirely
demand-driven.

The abstract base-classes for fvOptions now reside in the finiteVolume
library simplifying compilation and linkage.  The concrete
implementations of fvOptions are still in the single monolithic
fvOptions library but in the future this will be separated into smaller
libraries based on application area which may be linked at run-time in
the same manner as functionObjects.
2015-12-02 11:49:52 +00:00
Henry Weller
ba2f46f12a applications: Added fvOptions library to link 2015-12-01 16:09:19 +00:00
Henry Weller
3dfe844d9a applications/solvers: Added call to validate the turbulence model after construction
See also commit 52d83407f3
2015-12-01 10:25:38 +00:00
Henry Weller
90afa6ddb5 adjointShapeOptimizationFoam: Added support for fvOptions 2015-12-01 10:05:44 +00:00