A set of libraries and executables creating a workflow for performing
gradient-based optimisation loops. The main executable (adjointOptimisationFoam)
solves the flow (primal) equations, followed by the adjoint equations and,
eventually, the computation of sensitivity derivatives.
Current functionality supports the solution of the adjoint equations for
incompressible turbulent flows, including the adjoint to the Spalart-Allmaras
turbulence model and the adjoint to the nutUSpaldingWallFunction, [1], [2].
Sensitivity derivatives are computed with respect to the normal displacement of
boundary wall nodes/faces (the so-called sensitivity maps) following the
Enhanced Surface Integrals (E-SI) formulation, [3].
The software was developed by PCOpt/NTUA and FOSS GP, with contributions from
Dr. Evangelos Papoutsis-Kiachagias,
Konstantinos Gkaragounis,
Professor Kyriakos Giannakoglou,
Andy Heather
and contributions in earlier version from
Dr. Ioannis Kavvadias,
Dr. Alexandros Zymaris,
Dr. Dimitrios Papadimitriou
[1] A.S. Zymaris, D.I. Papadimitriou, K.C. Giannakoglou, and C. Othmer.
Continuous adjoint approach to the Spalart-Allmaras turbulence model for
incompressible flows. Computers & Fluids, 38(8):1528–1538, 2009.
[2] E.M. Papoutsis-Kiachagias and K.C. Giannakoglou. Continuous adjoint methods
for turbulent flows, applied to shape and topology optimization: Industrial
applications. 23(2):255–299, 2016.
[3] I.S. Kavvadias, E.M. Papoutsis-Kiachagias, and K.C. Giannakoglou. On the
proper treatment of grid sensitivities in continuous adjoint methods for shape
optimization. Journal of Computational Physics, 301:1–18, 2015.
Integration into the official OpenFOAM release by OpenCFD
Integration of VOF MULES new interfaces. Update of VOF solvers and all instances
of MULES in the code.
Integration of reactingTwoPhaseEuler and reactingMultiphaseEuler solvers and sub-models
Updating reactingEuler tutorials accordingly (most of them tested)
New eRefConst thermo used in tutorials. Some modifications at thermo specie level
affecting mostly eThermo. hThermo mostly unaffected
New chtMultiRegionTwoPhaseEulerFoam solver for quenching and tutorial.
Phases sub-models for reactingTwoPhaseEuler and reactingMultiphaseEuler were moved
to src/phaseSystemModels/reactingEulerFoam in order to be used by BC for
chtMultiRegionTwoPhaseEulerFoam.
Update of interCondensatingEvaporatingFoam solver.
Modified revert of commit 6c6f777bd5.
- The "alphaContactAngleFvPatchScalarField" occurs in several
places in the code base:
- as abstract class for two-phase properties
- in various multiphase solvers
To resolve potential linking conflicts, renamed the abstract class
as "alphaContactAngleTwoPhaseFvPatchScalarField" instead.
This permits potential linking of two-phase and multi-phase
libraries without symbol conflicts and has no effect on concrete
uses of two-phase alphaContactAngle boudary conditions.
- number of particles per parcel info to kinematic cloud
- added turbulent dispersion to basicHeterogeneousReactingParcel
- corrected dhsTrans in MUCSheterogeneousRate::calculate
- added cloud macro system to reactingParcelFoam and fixed calculation
of average particles per parcel
- added progress variable dimension to reacting model (nF)
- added ReactingHeterogeneous tutorial
ENH: Several modifycations to avoid erroneuos rays to be shot
from wrong faces.
ENH: Updating tutorials and avoiding registration of the
coarse singleCellFvMesh
Adding solarLoad tutorial case simpleCarSolarPanel
ENH: Changes needed for the merge
- Eg, with surface writers now in surfMesh, there are fewer libraries
depending on conversion and sampling.
COMP: regularize linkage ordering and avoid some implicit linkage (#1238)
- Global functions are unary or combining binary functions, which are
defined in MinMax.H (MinMaxOps.H).
There are also global reduction functions (gMinMax, gMinMaxMag)
as well as supporting 'Op' classes:
- minMaxOp, minMaxEqOp, minMaxMagOp, minMaxMagEqOp
Since the result of the functions represents a content reduction
into a single MinMax<T> value (a min/max pair), field operations
returning a field simply do not make sense.
- Implemented for lists, fields, field-fields, DimensionedField,
GeometricField (parallel reducing, with boundaries).
- Since the minMax evaluates during its operation, this makes it more
efficient for cases where both min/max values are required since it
avoids looping twice through the data.
* Changed GeometricField writeMinMax accordingly.
ENH: clip as field function
- clipping provides a more efficient, single-pass operation to apply
lower/upper limits on single or multiple values.
Examples,
scalarMinMax limiter(0, 1);
limiter.clip(value)
-> returns a const-ref to the value if within the range, or else
returns the appropriate lower/upper limit
limiter.inplaceClip(value)
-> Modifies the value if necessary to be within lower/upper limit
Function calls
clip(value, limiter)
-> returns a copy after applying lower/upper limit
clip(values, limiter)
-> returns a tmp<Field> of clipped values
- Can result in inadvertent conversions where the user should really
know or check if the pointer is valid prior to using.
- Still have several places to fix that are using the deprecated copy
construct and copy assignment
- accidentally introduced by 27c62303ad
STYLE: trial use of brace-initialized dimensionSet
- instead of writing
dimensionedScalar(dimensionSet(1, -2, -2, 0, 0, 0), Zero);
we can use C++11 brace-initialization to bundle the parameters
for the dimensionSet construction and simply write
dimensionedScalar({1, -2, -2, 0, 0, 0}, Zero);
Note the following is incorrect syntax (extra brackets):
dimensionedScalar(({1, -2, -2, 0, 0, 0}), Zero);
- identical to found(), which should be used for more consistency.
The contains() is a remnant from when hashedWordList was generalized
from a speciesTable (OCT 2010)
- provide a lookupOrDefault constructor form, since this is a fairly
commonly used requirement and simplifies the calling sequence.
Before
dimensionedScalar rhoMax
(
dimensionedScalar::lookupOrDefault
(
"rhoMax",
pimple.dict(),
dimDensity,
GREAT
)
);
After
dimensionedScalar rhoMax("rhoMax", dimDensity, GREAT, pimple.dict());
- read, readIfPresent methods with alternative lookup names.
- Mark the Istream related constructors with compile-time deprecated
warnings.
BUG: read, readIfPresent methods not handling optional dimensions (#1148)
- makes the intent clearer and avoids the need for additional
constructor casting. Eg,
labelList(10, Zero) vs. labelList(10, 0)
scalarField(10, Zero) vs. scalarField(10, scalar(0))
vectorField(10, Zero) vs. vectorField(10, vector::zero)
- for some special cases we wish to mark command-line arguments as
being optional, in order to do our own treatment. For example,
when an arbitrary number of arguments should be allowed.
Now tag this situation with argList::noMandatoryArgs().
The argList::argsMandatory() query can then be used in any further
logic, including the standard default argument checking.
- with the new default check, can consolidate the special-purpose
"setRootCaseNonMandatoryArgs.H"
into the regular
"setRootCase.H"
- revert to a simple "setRootCase.H" and move all the listing related
bits to a "setRootCaseLists.H" file. This leaves the information
available for solvers, or whoever else wishes, without being
introduced everywhere.
- add include guards and scoping to the listing files and rename to
something less generic.
listOptions.H -> setRootCaseListOptions.H
listOutput.H -> setRootCaseListOutput.H
- deprecate dimensionedType constructors using an Istream in favour of
versions accepting a keyword and a dictionary.
Dictionary entries are almost the exclusive means of read
constructing a dimensionedType. By construct from the dictionary
entry instead of doing a lookup() first, we can detect possible
input errors such as too many tokens as a result of a input syntax
error.
Constructing a dimensionedType from a dictionary entry now has
two forms.
1. dimensionedType(key, dims, dict);
This is the constructor that will normally be used.
It accepts entries with optional leading names and/or
dimensions. If the entry contains dimensions, they are
verified against the expected dimensions and an IOError is
raised if they do not correspond. On conclusion, checks the
token stream for any trailing rubbish.
2. dimensionedType(key, dict);
This constructor is used less frequently.
Similar to the previous description, except that it is initially
dimensionless. If entry contains dimensions, they are used
without further verification. The constructor also includes a
token stream check.
This constructor is useful when the dimensions are entirely
defined from the dictionary input, but also when handling
transition code where the input dimensions are not obvious from
the source.
This constructor can also be handy when obtaining values from
a dictionary without needing to worry about the input dimensions.
For example,
Info<< "rho: " << dimensionedScalar("rho", dict).value() << nl;
This will accept a large range of inputs without hassle.
ENH: consistent handling of dimensionedType for inputs (#1083)
BUG: incorrect Omega dimensions (fixes#2084)
- as part of the cleanup of dictionary access methods (c6520033c9)
made the dictionary class single inheritance from IDLList<entry>.
This eliminates any ambiguities for iterators and allows
for simple use of range-for looping.
Eg,
for (const entry& e : topDict))
{
Info<< "entry:" << e.keyword() << " is dict:" << e.isDict() << nl;
}
vs
forAllConstIter(dictionary, topDict, iter))
{
Info<< "entry:" << iter().keyword()
<< " is dict:" << iter().isDict() << nl;
}
- more dictionary-like methods, enforce keyType::LITERAL for all
lookups to avoid any spurious keyword matching.
- new readEntry, readIfPresent methods
- The get() method replaces the now deprecate lookup() method.
- Deprecate lookupOrFailsafe()
Failsafe behaviour is now an optional parameter for lookupOrDefault,
which makes it easier to tailor behaviour at runtime.
- output of the names is now always flatted without line-breaks.
Thus,
os << flatOutput(someEnumNames.names()) << nl;
os << someEnumNames << nl;
both generate the same output.
- Constructor now uses C-string (const char*) directly instead of
Foam::word in its initializer_list.
- Remove special enum + initializer_list constructor form since
it can create unbounded lookup indices.
- Removd old hasEnum, hasName forms that were provided during initial
transition from NamedEnum.
- Added static_assert on Enum contents to restrict to enum or
integral values. Should not likely be using this class to enumerate
other things since it internally uses an 'int' for its values.
Changed volumeType accordingly to enumerate on its type (enum),
not the class itself.
Update of overRhoPimpleDyMFoam and overInterDyMFoam solvers.
Adding corresponding tutorials with best possible settings
The main effort was put on reducing pressure spikes as the
stencil change with hole cells on the background mesh.
New name: findObject(), cfindObject()
Old name: lookupObjectPtr()
Return a const pointer or nullptr on failure.
New name: findObject()
Old name: --
Return a non-const pointer or nullptr on failure.
New name: getObjectPtr()
Old name: lookupObjectRefPtr()
Return a non-const pointer or nullptr on failure.
Can be called on a const object and it will perform a
const_cast.
- use these updated names and functionality in more places
NB: The older methods names are deprecated, but continue to be defined.
- use the dictionary 'get' methods instead of readScalar for
additional checking
Unchecked: readScalar(dict.lookup("key"));
Checked: dict.get<scalar>("key");
- In templated classes that also inherit from a dictionary, an additional
'template' keyword will be required. Eg,
this->coeffsDict().template get<scalar>("key");
For this common use case, the predefined getXXX shortcuts may be
useful. Eg,
this->coeffsDict().getScalar("key");
Previously the coordinate system functionality was split between
coordinateSystem and coordinateRotation. The coordinateRotation stored
the rotation tensor and handled all tensor transformations.
The functionality has now been revised and consolidated into the
coordinateSystem classes. The sole purpose of coordinateRotation
is now just to provide a selectable mechanism of how to define the
rotation tensor (eg, axis-angle, euler angles, local axes) for user
input, but after providing the appropriate rotation tensor it has
no further influence on the transformations.
--
The coordinateSystem class now contains an origin and a base rotation
tensor directly and various transformation methods.
- The origin represents the "shift" for a local coordinate system.
- The base rotation tensor represents the "tilt" or orientation
of the local coordinate system in general (eg, for mapping
positions), but may require position-dependent tensors when
transforming vectors and tensors.
For some coordinate systems (currently the cylindrical coordinate system),
the rotation tensor required for rotating a vector or tensor is
position-dependent.
The new coordinateSystem and its derivates (cartesian, cylindrical,
indirect) now provide a uniform() method to define if the rotation
tensor is position dependent/independent.
The coordinateSystem transform and invTransform methods are now
available in two-parameter forms for obtaining position-dependent
rotation tensors. Eg,
... = cs.transform(globalPt, someVector);
In some cases it can be useful to use query uniform() to avoid
storage of redundant values.
if (cs.uniform())
{
vector xx = cs.transform(someVector);
}
else
{
List<vector> xx = cs.transform(manyPoints, someVector);
}
Support transform/invTransform for common data types:
(scalar, vector, sphericalTensor, symmTensor, tensor).
====================
Breaking Changes
====================
- These changes to coordinate systems and rotations may represent
a breaking change for existing user coding.
- Relocating the rotation tensor into coordinateSystem itself means
that the coordinate system 'R()' method now returns the rotation
directly instead of the coordinateRotation. The method name 'R()'
was chosen for consistency with other low-level entities (eg,
quaternion).
The following changes will be needed in coding:
Old: tensor rot = cs.R().R();
New: tensor rot = cs.R();
Old: cs.R().transform(...);
New: cs.transform(...);
Accessing the runTime selectable coordinateRotation
has moved to the rotation() method:
Old: Info<< "Rotation input: " << cs.R() << nl;
New: Info<< "Rotation input: " << cs.rotation() << nl;
- Naming consistency changes may also cause code to break.
Old: transformVector()
New: transformPrincipal()
The old method name transformTensor() now simply becomes transform().
====================
New methods
====================
For operations requiring caching of the coordinate rotations, the
'R()' method can be used with multiple input points:
tensorField rots(cs.R(somePoints));
and later
Foam::transformList(rots, someVectors);
The rotation() method can also be used to change the rotation tensor
via a new coordinateRotation definition (issue #879).
The new methods transformPoint/invTransformPoint provide
transformations with an origin offset using Cartesian for both local
and global points. These can be used to determine the local position
based on the origin/rotation without interpreting it as a r-theta-z
value, for example.
================
Input format
================
- Streamline dictionary input requirements
* The default type is cartesian.
* The default rotation type is the commonly used axes rotation
specification (with e1/e2/3), which is assumed if the 'rotation'
sub-dictionary does not exist.
Example,
Compact specification:
coordinateSystem
{
origin (0 0 0);
e2 (0 1 0);
e3 (0.5 0 0.866025);
}
Full specification (also accepts the longer 'coordinateRotation'
sub-dictionary name):
coordinateSystem
{
type cartesian;
origin (0 0 0);
rotation
{
type axes;
e2 (0 1 0);
e3 (0.5 0 0.866025);
}
}
This simplifies the input for many cases.
- Additional rotation specification 'none' (an identity rotation):
coordinateSystem
{
origin (0 0 0);
rotation { type none; }
}
- Additional rotation specification 'axisAngle', which is similar
to the -rotate-angle option for transforming points (issue #660).
For some cases this can be more intuitive.
For example,
rotation
{
type axisAngle;
axis (0 1 0);
angle 30;
}
vs.
rotation
{
type axes;
e2 (0 1 0);
e3 (0.5 0 0.866025);
}
- shorter names (or older longer names) for the coordinate rotation
specification.
euler EulerRotation
starcd STARCDRotation
axes axesRotation
================
Coding Style
================
- use Foam::coordSystem namespace for categories of coordinate systems
(cartesian, cylindrical, indirect). This reduces potential name
clashes and makes a clearer declaration. Eg,
coordSystem::cartesian csys_;
The older names (eg, cartesianCS, etc) remain available via typedefs.
- added coordinateRotations namespace for better organization and
reduce potential name clashes.
- there were previously no hashing mechanisms for lists so they
would fall back to the definition for primitives and hash the
memory location of the allocated List object.
- provide a UList::Hash<> sub-class for inheritance, and also a global
specialization for UList<T>, List<T> such that the hash value for
List<List<T>> cascades properly.
- provide similar function in triFace to ensure that it remains
similar in behaviour to face.
- added SymmHash to Pair, for use when order is unimportant.
STYLE: use string::hash() more consistently
- no particular reason to use Hash<word>() which forwards to
string::hash() anyhow
- With argList::noFunctionObjects() we use the logic added in
4b93333292 (issue #352)
By removing the '-noFunctionObjects' option, we automatically
suppress the creation of function-objects via Time (with argList
as a parameter).
There is generally no need in these cases for an additional
runTime.functionObjects().off() statement
Use the argList::noFunctionObjects() for more direct configuration
and reduce unnecessary clutter in the -help information.
In previous versions, the -noFunctionObjects would have been redundant
anyhow, so we can also just ignore it now instead.
General:
* -roots, -hostRoots, -fileHandler
Specific:
* -to <coordinateSystem> -from <coordinateSystem>
- Display -help-compat when compatibility or ignored options are available
STYLE: capitalization of options text
- avoids compiler ambiguity when virtual methods such as
IOdictionary::read() exist.
- the method was introduced in 1806, and was thus not yet widely used
- what was previously termed 'setLargeCellSubset()' is now simply
'setCellSubset()' and supports memory efficient interfaces.
The new parameter ordering avoids ambiguities caused by default
parameters.
Old parameter order:
setLargeCellSubset
(
const labelList& region,
const label currentRegion,
const label patchID = -1,
const bool syncCouples = true
);
New parameter order:
setCellSubset
(
const label regioni,
const labelUList& regions,
const label patchID = -1,
const bool syncCouples = true
);
And without ambiguity:
setCellSubset
(
const labelUList& selectedCells,
const label patchID = -1,
const bool syncCouples = true
);
- support bitSet directly for specifying the selectedCells for
memory efficiency and ease of use.
- Additional constructors to perform setCellSubset() immediately,
which simplifies coding.
For example,
meshParts.set
(
zonei,
new fvMeshSubset(mesh, selectedCells)
);
Or even
return autoPtr<fvMeshSubset>::New(mesh, selectedCells);
- instead of dict.lookup(name) >> val;
can use dict.readEntry(name, val);
for checking of input token sizes.
This helps catch certain types of input errors:
{
key1 ; // <- Missing value
key2 1234 // <- Missing ';' terminator
key3 val;
}
STYLE: readIfPresent() instead of 'if found ...' in a few more places.
This method waits until all the threads have completed IO operations and
then clears any cached information about the files on disk. This
replaces the deactivation of threading by means of zeroing the buffer
size when writing and reading of a file happen in sequence. It also
allows paraFoam to update the list of available times.
Patch contributed by Mattijs Janssens
Resolves bug report https://bugs.openfoam.org/view.php?id=2962
twoPhaseMixtureThermo writes the temperatures during construction only
for them to be read again immediately after by construction of the
individual phases' thermo models. When running with collated file
handling this behaviour is not thread safe. This change deactivates
threading for the duration of this behaviour.
Patch contributed by Mattijs Janssens
- use Enum instead of NamedEnum
- shorter form for dimensionedScalar
- reduce verbosity about missed seeding for DTRM cloud.
Re-enable old warnings in debug mode.
- relocate some standard functionality to TimePaths to allow a lighter
means of managing time directories without using the entire Time
mechanism.
- optional enableLibs for Time construction (default is on)
and a corresponding argList::noLibs() and "-no-libs" option
STYLE:
- mark Time::outputTime() as deprecated MAY-2016
- use pre-increment for runTime, although there is no difference in
behaviour or performance.
- Reimplemented treatment of alpha1, phi and U in case of
nOuterCorrectors > 1 based on storePrevIter() to avoid cluttering the
solver with unnecessary fields in case of nOuterCorrectors = 1.
- Updated tutorial headers
- Added copyright note to isoAdvector src
- Removed outcommented code lines in interIsoFoam solver
- Removed all LTS from interIsoFoam since this is not currently supported
- Confirmed that discInConstantFlow gives identical results with N subCylces and time step N*dt
- Confirmed that this also holds when nOuterCorrectors > 1.
- Since 'bool' and 'Switch' use the _identical_ input mechanism
(ie, both accept true/false, on/off, yes/no, none, 1/0), the main
reason to prefer one or the other is the output.
The output for Switch is as text (eg, "true"), whereas for bool
it is label (0 or 1). If the output is required for a dictionary,
Switch may be appropriate. If the output is not required, or is only
used for Pstream exchange, bool can be more appropriate.
- disallow insert() of raw pointers, since a failed insertion
(ie, entry already existed) results in an unmanaged pointer.
Either insert using an autoPtr, or set() with raw pointers or autoPtr.
- IOobjectList::add() now takes an autoPtr instead of an object reference
- IOobjectList::remove() now returns an autoPtr instead of a raw pointer
- The iterator for a HashSet dereferences directly to its key.
- Eg,
for (const label patchi : patchSet)
{
...
}
vs.
forAllConstIter(labelHashSet, patchSet, iter)
{
const label patchi = iter.key();
...
}
- controlled by the the 'printExecutionFormat' InfoSwitch in
etc/controlDict
// Style for "ExecutionTime = " output
// - 0 = seconds (with trailing 's')
// - 1 = day-hh:mm:ss
ExecutionTime = 112135.2 s ClockTime = 113017 s
ExecutionTime = 1-07:08:55.20 ClockTime = 1-07:23:37
- Callable via the new Time::printExecutionTime() method,
which also helps to reduce clutter in the applications.
Eg,
runTime.printExecutionTime(Info);
vs
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
--
ENH: return elapsedClockTime() and clockTimeIncrement as double
- previously returned as time_t, which is less portable.
- parsing error state only arises from a missing final newline
in the file (which the dnl macro does not capture).
Report with a warning instead of modifying the dnl macro since
we generally wish to know about this anyhow.
- add missing newline to YEqn.H file.
- The bitSet class replaces the old PackedBoolList class.
The redesign provides better block-wise access and reduced method
calls. This helps both in cases where the bitSet may be relatively
sparse, and in cases where advantage of contiguous operations can be
made. This makes it easier to work with a bitSet as top-level object.
In addition to the previously available count() method to determine
if a bitSet is being used, now have simpler queries:
- all() - true if all bits in the addressable range are empty
- any() - true if any bits are set at all.
- none() - true if no bits are set.
These are faster than count() and allow early termination.
The new test() method tests the value of a single bit position and
returns a bool without any ambiguity caused by the return type
(like the get() method), nor the const/non-const access (like
operator[] has). The name corresponds to what std::bitset uses.
The new find_first(), find_last(), find_next() methods provide a faster
means of searching for bits that are set.
This can be especially useful when using a bitSet to control an
conditional:
OLD (with macro):
forAll(selected, celli)
{
if (selected[celli])
{
sumVol += mesh_.cellVolumes()[celli];
}
}
NEW (with const_iterator):
for (const label celli : selected)
{
sumVol += mesh_.cellVolumes()[celli];
}
or manually
for
(
label celli = selected.find_first();
celli != -1;
celli = selected.find_next()
)
{
sumVol += mesh_.cellVolumes()[celli];
}
- When marking up contiguous parts of a bitset, an interval can be
represented more efficiently as a labelRange of start/size.
For example,
OLD:
if (isA<processorPolyPatch>(pp))
{
forAll(pp, i)
{
ignoreFaces.set(i);
}
}
NEW:
if (isA<processorPolyPatch>(pp))
{
ignoreFaces.set(pp.range());
}
- generalize some of the library extensions (.so vs .dylib).
Provide as wmake 'sysFunctions'
- added note about unsupported/incomplete system support
- centralize detection of ThirdParty packages into wmake/ subdirectory
by providing a series of scripts in the spirit of GNU autoconfig.
For example,
have_boost, have_readline, have_scotch, ...
Each of the `have_<package>` scripts will generally provide the
following type of functions:
have_<package> # detection
no_<package> # reset
echo_<package> # echoing
and the following type of variables:
HAVE_<package> # unset or 'true'
<package>_ARCH_PATH # root for <package>
<package>_INC_DIR # include directory for <package>
<package>_LIB_DIR # library directory for <package>
This simplifies the calling scripts:
if have_metis
then
wmake metisDecomp
fi
As well as reducing clutter in the corresponding Make/options:
EXE_INC = \
-I$(METIS_INC_DIR) \
-I../decompositionMethods/lnInclude
LIB_LIBS = \
-L$(METIS_LIB_DIR) -lmetis
Any additional modifications (platform-specific or for an external build
system) can now be made centrally.
- both autoPtr and tmp are defined with an implicit construct from
nullptr (but with explicit construct from a pointer to null).
Thus is it safe to use 'nullptr' when returning an empty autoPtr or tmp.
- when constructing dimensioned fields that are to be zero-initialized,
it is preferrable to use a form such as
dimensionedScalar(dims, Zero)
dimensionedVector(dims, Zero)
rather than
dimensionedScalar("0", dims, 0)
dimensionedVector("zero", dims, vector::zero)
This reduces clutter and also avoids any suggestion that the name of
the dimensioned quantity has any influence on the field's name.
An even shorter version is possible. Eg,
dimensionedScalar(dims)
but reduces the clarity of meaning.
- NB: UniformDimensionedField is an exception to these style changes
since it does use the name of the dimensioned type (instead of the
regIOobject).
- in many cases can just use lookupOrDefault("key", bool) instead of
lookupOrDefault<bool> or lookupOrDefault<Switch> since reading a
bool from an Istream uses the Switch(Istream&) anyhow
STYLE: relocated Switch string names into file-local scope
- eliminate iterators from PackedList since they were unused, had
lower performance than direct access and added unneeded complexity.
- eliminate auto-vivify for the PackedList '[] operator.
The set() method provides any required auto-vivification and
removing this ability from the '[]' operator allows for a lower
when accessing the values. Replaced the previous cascade of iterators
with simpler reference class.
PackedBoolList:
- (temporarily) eliminate logic and addition operators since
these contained partially unclear semantics.
- the new test() method tests the value of a single bit position and
returns a bool without any ambiguity caused by the return type
(like the get() method), nor the const/non-const access (like
operator[] has). The name corresponds to what std::bitset uses.
- more consistent use of PackedBoolList test(), set(), unset() methods
for fewer operation and clearer code. Eg,
if (list.test(index)) ... | if (list[index]) ...
if (!list.test(index)) ... | if (list[index] == 0u) ...
list.set(index); | list[index] = 1u;
list.unset(index); | list[index] = 0u;
- deleted the operator=(const labelUList&) and replaced with a setMany()
method for more clarity about the intended operation and to avoid any
potential inadvertent behaviour.
This class is largely a pre-C++11 holdover. It is now possible to
simply use move construct/assignment directly.
In a few rare cases (eg, polyMesh::resetPrimitives) it has been
replaced by an autoPtr.
Improve alignment of its behaviour with std::unique_ptr
- element_type typedef
- release() method - identical to ptr() method
- get() method to get the pointer without checking and without releasing it.
- operator*() for dereferencing
Method name changes
- renamed rawPtr() to get()
- renamed rawRef() to ref(), removed unused const version.
Removed methods/operators
- assignment from a raw pointer was deleted (was rarely used).
Can be convenient, but uncontrolled and potentially unsafe.
Do allow assignment from a literal nullptr though, since this
can never leak (and also corresponds to the unique_ptr API).
Additional methods
- clone() method: forwards to the clone() method of the underlying
data object with argument forwarding.
- reset(autoPtr&&) as an alternative to operator=(autoPtr&&)
STYLE: avoid implicit conversion from autoPtr to object type in many places
- existing implementation has the following:
operator const T&() const { return operator*(); }
which means that the following code works:
autoPtr<mapPolyMesh> map = ...;
updateMesh(*map); // OK: explicit dereferencing
updateMesh(map()); // OK: explicit dereferencing
updateMesh(map); // OK: implicit dereferencing
for clarity it may preferable to avoid the implicit dereferencing
- prefer operator* to operator() when deferenced a return value
so it is clearer that a pointer is involve and not a function call
etc Eg, return *meshPtr_; vs. return meshPtr_();
- more consistent with STL practices for function classes.
- string::hash function class now operates on std::string rather
than Foam::string since we have now avoided inadvertent use of
string conversion from int in more places.
- use succincter method names that more closely resemble dictionary
and HashTable method names. This improves method name consistency
between classes and also requires less typing effort:
args.found(optName) vs. args.optionFound(optName)
args.readIfPresent(..) vs. args.optionReadIfPresent(..)
...
args.opt<scalar>(optName) vs. args.optionRead<scalar>(optName)
args.read<scalar>(index) vs. args.argRead<scalar>(index)
- the older method names forms have been retained for code compatibility,
but are now deprecated
further investigation on the consequences on dynamic mesh for compressibleInterDyMFoam.
alphaSuSp.H has to be added in the solver folder in order to make it compatible with the alpha Eq.
chtMultiRegionFoam now supports reaction/combustion modelling in fluid
regions in the same way as reactingFoam.
TUT: chtMultiRegionFoam: Added reverseBurner tutorial
This tutorial demonstrates chtMultiRegionFoam's combustion capability
Thermo and reaction thermo macros have been renamed and refactored. If
the name is plural (make???Thermos) then it adds the model to all
selection tables. If not (make???Thermo) then it only adds to the
requested psi or rho table.
This mixture allows a reacting solver to be used with a single component
fluid without the additional case files usually required for reacting
thermodynamics.
reactionThermo: Instantiated more single component mixtures
ENH: reactionThermo: Select singleComponentMixture as pureMixture
A pureMixture can now be specified in a reacting solver. This further
enhances compatibility between non-reacting and reacting solvers.
To achieve this, mixtures now have a typeName function of the same form
as the lower thermodyanmic models. In addition, to avoid name clashes,
the reacting thermo make macros have been split into those that create
entries on multiple selection tables, and those that just add to the
reaction thermo table.
The combustion and chemistry models no longer select and own the
thermodynamic model; they hold a reference instead. The construction of
the combustion and chemistry models has been changed to require a
reference to the thermodyanmics, rather than the mesh and a phase name.
At the solver-level the thermo, turbulence and combustion models are now
selected in sequence. The cyclic dependency between the three models has
been resolved, and the raw-pointer based post-construction step for the
combustion model has been removed.
The old solver-level construction sequence (typically in createFields.H)
was as follows:
autoPtr<combustionModels::psiCombustionModel> combustion
(
combustionModels::psiCombustionModel::New(mesh)
);
psiReactionThermo& thermo = combustion->thermo();
// Create rho, U, phi, etc...
autoPtr<compressible::turbulenceModel> turbulence
(
compressible::turbulenceModel::New(rho, U, phi, thermo)
);
combustion->setTurbulence(*turbulence);
The new sequence is:
autoPtr<psiReactionThermo> thermo(psiReactionThermo::New(mesh));
// Create rho, U, phi, etc...
autoPtr<compressible::turbulenceModel> turbulence
(
compressible::turbulenceModel::New(rho, U, phi, *thermo)
);
autoPtr<combustionModels::psiCombustionModel> combustion
(
combustionModels::psiCombustionModel::New(*thermo, *turbulence)
);
ENH: combustionModel, chemistryModel: Simplified model selection
The combustion and chemistry model selection has been simplified so
that the user does not have to specify the form of the thermodynamics.
Examples of new combustion and chemistry entries are as follows:
In constant/combustionProperties:
combustionModel PaSR;
combustionModel FSD;
In constant/chemistryProperties:
chemistryType
{
solver ode;
method TDAC;
}
All the angle bracket parts of the model names (e.g.,
<psiThermoCombustion,gasHThermoPhysics>) have been removed as well as
the chemistryThermo entry.
The changes are mostly backward compatible. Only support for the
angle bracket form of chemistry solver names has been removed. Warnings
will print if some of the old entries are used, as the parts relating to
thermodynamics are now ignored.
ENH: combustionModel, chemistryModel: Simplified model selection
Updated all tutorials to the new format
STYLE: combustionModel: Namespace changes
Wrapped combustion model make macros in the Foam namespace and removed
combustion model namespace from the base classes. This fixes a namespace
specialisation bug in gcc 4.8. It is also somewhat less verbose in the
solvers.
This resolves bug report https://bugs.openfoam.org/view.php?id=2787
ENH: combustionModels: Default to the "none" model
When the constant/combustionProperties dictionary is missing, the solver
will now default to the "none" model. This is consistent with how
radiation models are selected.
and replaced multiphaseInterDyMFoam with a script which reports this change.
The multiphaseInterDyMFoam tutorials have been moved into the multiphaseInterFoam directory.
This change is one of a set of developments to merge dynamic mesh functionality
into the standard solvers to improve consistency, usability, flexibility and
maintainability of these solvers.
Henry G. Weller
CFD Direct Ltd.
and replaced interDyMFoam with a script which reports this change.
The interDyMFoam tutorials have been moved into the interFoam directory.
This change is one of a set of developments to merge dynamic mesh functionality
into the standard solvers to improve consistency, usability, flexibility and
maintainability of these solvers.
Henry G. Weller
CFD Direct Ltd.
interMixingFoam, multiphaseInterFoam: Updated for changes to interFoam
and replaced rhoPimpleDyMFoam with a script which reports this change.
The rhoPimpleDyMFoam tutorials have been moved into the rhoPimpleFoam directory.
This change is the first of a set of developments to merge dynamic mesh
functionality into the standard solvers to improve consistency, usability,
flexibility and maintainability of these solvers.
Henry G. Weller
CFD Direct Ltd.
rhoReactingFoam: Updated for changes to rhoPimpleFoam files
Now pimpleDyMFoam is exactly equivalent to pimpleFoam when running on a
staticFvMesh. Also when the constant/dynamicMeshDict is not present a
staticFvMesh is automatically constructed so that the pimpleDyMFoam solver can
run any pimpleFoam case without change.
pimpleDyMFoam: Store Uf as an autoPtr for better error handling
pimpleFoam: Set initial deltaT from the Courant number
for improved stability on start-up and compatibility with pimpleDyMFoam
ENH: pimpleFoam: Merged dynamic mesh functionality of pimpleDyMFoam into pimpleFoam
and replaced pimpleDyMFoam with a script which reports this change.
The pimpleDyMFoam tutorials have been moved into the pimpleFoam directory.
This change is the first of a set of developments to merge dynamic mesh
functionality into the standard solvers to improve consistency, usability,
flexibility and maintainability of these solvers.
Henry G. Weller
CFD Direct Ltd.
tutorials/incompressible/pimpleFoam: Updated pimpleDyMFoam tutorials to run pimpleFoam
Renamed tutorials/incompressible/pimpleFoam/RAS/wingMotion/wingMotion2D_pimpleDyMFoam
-> tutorials/incompressible/pimpleFoam/RAS/wingMotion/wingMotion2D_pimpleFoam
- this provides a better typesafe means of locating predefined cell
models than relying on strings. The lookup is now ptr() or ref()
directly. The lookup functions behave like on-demand singletons when
loading "etc/cellModels".
Functionality is now located entirely in cellModel but a forwarding
version of cellModeller is provided for API (but not ABI) compatibility
with older existing user code.
STYLE: use constexpr for cellMatcher constants
XiEngineFoam is a premixed/partially-premixed combustion engine solver which
exclusively uses the Xi flamelet combustion model.
engineFoam is a general engine solver for inhomogeneous combustion with or
without spray supporting run-time selection of the chemistry-based combustion
model.
Standard crank-connecting rod and the new free-piston kinematics motion options
are provides, others can easily be added.
Contributed by Francesco Contino and Nicolas Bourgeois, BURN Research Group.
Resolves bug-report https://bugs.openfoam.org/view.php?id=2785
ENH: compressibleInterFoam family: merged two-phase momentum stress modelling from compressibleInterPhaseTransportFoam
The new momentum stress model selector class
compressibleInterPhaseTransportModel is now used to select between the options:
Description
Transport model selection class for the compressibleInterFoam family of
solvers.
By default the standard mixture transport modelling approach is used in
which a single momentum stress model (laminar, non-Newtonian, LES or RAS) is
constructed for the mixture. However if the \c simulationType in
constant/turbulenceProperties is set to \c twoPhaseTransport the alternative
Euler-Euler two-phase transport modelling approach is used in which separate
stress models (laminar, non-Newtonian, LES or RAS) are instantiated for each
of the two phases allowing for different modeling for the phases.
Mixture and two-phase momentum stress modelling is now supported in
compressibleInterFoam, compressibleInterDyMFoam and compressibleInterFilmFoam.
The prototype compressibleInterPhaseTransportFoam solver is no longer needed and
has been removed.
To unsure fvOptions are instantiated for post-processing createFvOptions.H must
be included in createFields.H rather than in the solver directly.
Resolves bug-report https://bugs.openfoam.org/view.php?id=2733
BUG: porousSimpleFoam: moved createFvOptions.H into createFields.H for -postProcess option
Resolves bug-report https://bugs.openfoam.org/view.php?id=2733
BUG: solvers: Moved fvOption construction into createFields.H for post-processing
This ensures that the fvOptions are constructed for the -postProcessing option
so that functionObjects which process fvOption data operate correctly in this
mode.
The combined solver includes the most advanced and general functionality from
each solver including:
Continuous phase
Lagrangian multiphase parcels
Optional film
Continuous and Lagrangian phase reactions
Radiation
Strong buoyancy force support by solving for p_rgh
The reactingParcelFoam and reactingParcelFilmFoam tutorials have been combined
and updated.
Mixture molecular weight is now evaluated in heThermo like everything
else, relying on the low level specie mixing rules. Units have also been
corrected.
SpecieMixture: Pure virtual definition for W to prevent Clang warning
In this version of compressibleInterFoam separate stress models (laminar,
non-Newtonian, LES or RAS) are instantiated for each of the two phases allowing
for completely different modeling for the phases.
e.g. in the climbingRod tutorial case provided a Newtonian laminar model is
instantiated for the air and a Maxwell non-Newtonian model is instantiated for
the viscoelastic liquid. To stabilize the Maxwell model in regions where the
liquid phase-fraction is 0 the new symmTensorPhaseLimitStabilization fvOption is
applied.
Other phase stress modeling combinations are also possible, e.g. the air may be
turbulent but the liquid laminar and an RAS or LES model applied to the air
only. However, to stabilize this combination a suitable fvOption would need to
be applied to the turbulence properties where the air phase-fraction is 0.
Henry G. Weller, Chris Greenshields
CFD Direct Ltd.
XiEngineFoam is a premixed/partially-premixed combustion engine solver which
exclusively uses the Xi flamelet combustion model.
engineFoam is a general engine solver for inhomogeneous combustion with or
without spray supporting run-time selection of the chemistry-based combustion
model.
Standard crank-connecting rod and the new free-piston kinematics motion options
are provides, others can easily be added.
Contributed by Francesco Contino and Nicolas Bourgeois, BURN Research Group.