Commit Graph

2484 Commits

Author SHA1 Message Date
3a78203863 DEFEATURE: remove mixed precision support for streaming particles (#3412)
- since direct streaming of particles is only ever used internally and
  never for disk I/O (which is collated by property), mixed precision
  will never occur when constructing a particle from a stream.

  Due to padding issues, the previous code would have been faulty anyhow.
  Thus remove that code and replace with a simple sanity check.
2025-08-19 10:56:23 +00:00
53af711c6a ENH: simplify assign zero for Dimensioned and Geometric fields (#3402)
- regular or forced assignment from `zero` does not need dimension
  checking:

    Old:  U = dimensionedVector(U.dimensions(), Zero);
    New:  U = Zero;

  this eliminates a fair bit of clutter and simplifies new coding
  without losing general dimension checking capabilities.
2025-07-30 09:29:53 +02:00
2b0e4dc97a ENH: potentialFoam: allow swirl bc. See #3211
Bypasses the constraint override. Contentious -
does field algebra or boundary constraints take
priority.
2025-06-16 17:13:31 +01:00
4e513cec18 ENH: DimensionedField, GeometricField enhancements and style changes
- constCast() convenience methods.
  This simplies coding in places, especially in solvers

- inline some methods within headers, for better overview/maintenance

- only set DimensionedField default value on construct if not read

- storeOldTimes() does not require const_cast
2025-05-21 14:19:36 +02:00
ae3adc1007 ENH: add fvPatch::offset() as pass-through to polyPatch::offset()
- makes fvPatch consistent with faPatch etc and can simplify coding

ENH: handle sizing within extrapolateInternal() patch field methods

- reduces reliance on any sub-components

ENH: extend polyBoundaryMesh patch selectors

- indices_if() method with a predicate, or with a patch-type
  behaves similarly to findPatchIDs(), but returns a sorted
  labelList instead of a labelHashSet

- nFaces_if() method with a predicate return the number of boundary
  faces for patches matching the given predicate.
2025-05-21 14:19:36 +02:00
59f3c55871 STYLE: avoid implicit cast of UList to List 2025-04-09 15:58:30 +02:00
0be19b7fae COMP: namespace qualify min/max functions (#3348)
FIX: missing patch face index writeFields (#3347)
2025-04-09 15:58:30 +02:00
01727c84f1 ENH: use gMinMax() instead of separate gMin(), gMax()
- for reciprocal values, gMinMax() first and then calculate the
  reciprocal, which avoids creating temporaries

STYLE: prefer MinMax to separate min/max accounting

COMP: namespace qualify min/max for deltaT, CourantNo, etc (#3348)
2025-04-09 15:58:30 +02:00
6c20df2808 ENH: additional in-place clamp_min(), clamp_max() field methods
- these already existed for a single value, but now handle the full
  field. This is more memory-friendly.

      fld.clamp_min(lower);  OLD: fld = max(fld, lower);
      fld.clamp_max(upper);  OLD: fld = min(fld, upper);
2025-04-09 15:58:29 +02:00
b9b0d1b3aa STYLE: use weighted average/sum in a few places
- minor adjustments to some BCs construction:
  * ensure origin/axis are zero-initialized
  * use dictionary get<> instead of lookup
2025-03-20 11:14:39 +01:00
7904a2734f BUG: twoPhaseEuler: incorrect phase. Fixes #3295. 2025-01-06 11:30:02 +00:00
8340317a46 COMP: missing dynamicMesh,dynamicFvMesh linkage for simpleFoam (#3269) 2024-12-16 10:49:29 +01:00
e45b26eaf0 ENH: simpleFoam: add dynamicFvMesh. Fixes #3269 2024-11-28 11:58:48 +00:00
782f22feb8 ENH: continuity: avoid excess evaluations. See #3225 2024-09-18 14:01:26 +01:00
d8d3e34d5c COMP: fix dangling references (gcc13+: -Wdangling-reference) 2024-06-26 16:53:05 +02:00
f6ba6bc40e ENH: MRF - added work term to compressible solver energy eqns 2024-06-07 14:48:47 +00:00
2d52ee13b1 ENH: icoReactingMultiphaseInterFoam - added frozenFlow option. Fixes #3128 2024-05-31 14:31:00 +01:00
cd8bc891f0 ENH: fvMatrix, faMatrix: replace raw pointers with unique_ptr (#3107) 2024-03-05 18:13:59 +00:00
8b73d06898 ENH: use tmp field factory methods [12] (#2723)
- applications
2024-02-21 14:31:40 +01:00
ac574a6ccb STYLE: use static call for regIOobject::store (#1507) 2024-02-20 16:56:22 +01:00
182afc27ba STYLE: noexcept for nullObject functions
STYLE: use nullObject for return values of NotImplemented

STYLE: shallowCopy(nullptr) shortcut
2024-01-25 16:03:09 +01:00
152eceeb56 Use factory Clone for patch fields 2024-01-23 11:22:19 +00:00
bb16c493b7 Code adjustments to avoid gcc-13 warnings about dangling references 2024-01-11 10:08:45 +00:00
987dbe4589 ENH: use factory Clone method for handling member clone() methods
- reduces code clutter, simplifies modification for new types.
  Handled classes:

    Function1, PatchFunction1, coordinateRotation, coordinateSystem,
    particle, liquidProperties, solidProperties
2024-01-09 11:56:45 +00:00
b5b48b66d1 ENH: enabled the postProcess option in adjointOptimisationFoam 2023-12-18 18:01:35 +00:00
b6a30fae61 ENH: overhaul of the adjoint optimisation library
Parts of the adjoint optimisation library were re-designed to generalise
the way sensitivity derivatives (SDs) are computed and to allow easier
extension to primal problems other than the ones governed by
incompressible flows. In specific:
- the adjoint solver now holds virtual functions returning the part of
  SDs that depends only on the primal and the adjoint fields.
- a new class named designVariables was introduced which, apart from
  defining the design variables of the optimisation problem and
  providing hooks for updating them in an optimisation loop, provides
  the part of the SDs that affects directly the flow residuals (e.g.
  geometric variations in shape optimisation, derivatives of source
  terms in topology optimisation, etc). The final assembly of the SDs
  happens here, with the updated sensitivity class acting as an
  intermediate.

With the new structure, when the primal problem changes (for instance,
passive scalars are included), the same design variables and sensitivity
classes can be re-used for all physics, with additional contributions to
the SDs being limited (and contained) to the new adjoint solver to be
implemented. The old code structure would require new SD classes for
each additional primal problem.

As a side-effect, setting up a case has arguably become a bit easier and
more intuitive.

Additional changes include:
---------------------------

- Changes in the formulation and computation of shape sensitivity derivatives
  using the E-SI approach. The latter is now derived directly from the
  FI approach, with proper discretization for the terms and boundary
  conditions that emerge from applying the Gauss divergence theorem used
  to transition from FI to E-SI. When E-SI and FI are based on the same
  Laplace grid displacement model, they are now numerically equivalent
  (the previous formulation proved the theoretical equivalence of the
  two approaches but numerical results could differ, depending on the
  case).
- Sensitivity maps at faces are now computed based (and are deriving
  from) sensitivity maps at points, with a constistent point-to-face
  interpolation (requires the differentiation of volPointInterpolation).
- The objective class now allocates only the member pointers that
  correspond to the non-zero derivatives of the objective w.r.t. the
  flow and geometric quantities, leading to a reduced memory footprint.
  Additionally, contributions from volume-based objectives to the
  adjoint equations have been re-worked, removing the need for
  objectiveManager to be virtual.
- In constrained optimisation, an adjoint solver needs to be present for
  each constraint function. For geometric constraints though, no adjoint
  equations need to solved. This is now accounted for through the null
  adjoint solver and the geometric objectives which do not allocate
  adjoint fields for this kind of constraints, reducing memory
  requirements and file clutter.
- Refactoring of the updateMethod to collaborate with the new
  designVariables. Additionally, all updateMethods can now read and
  write restart data in binary, facilitating exact continuation.
  Furthermore, code shared by various quasi-Newton methods (BFGS, DBFGS,
  LBFGS, SR1) has been organised in the namesake class. Over and above,
  an SQP variant capable of tackling inequality constraints has been
  added (ISQP, with I indicating that the QP problem in the presence of
  inequality constraints is solved through an interior point method).
  Inequality constraints can be one-sided (constraint < upper-value)
  or double-sided (lower-value < constraint < upper-value).
- Bounds can now be defined for the design variables.
  For volumetricBSplines in specific, these can be computed as the
  mid-points of the control points and their neighbouring ones. This
  usually leads to better-defined optimisation problems and reduces the
  chances of an invalid mesh during optimisation.
- Convergence criteria can now be defined for the optimisation loop
  which will stop if the relative objective function reduction over
  the last objective value is lower than a given threshold and
  constraints are satisfied within a give tolerance. If no criteria are
  defined, the optimisation will run for the max. given number of cycles
  provided in controlDict.
- Added a new grid displacement method based on the p-Laplacian
  equation, which seems to outperform other PDE-based approaches.

TUT: updated the shape optimisation tutorials and added a new one
showcasing the use of double-sided constraints, ISQP, applying
no-overlapping constraints to volumetric B-Splines control points
and defining convergence criteria for the optimisation loop.
2023-12-18 18:01:35 +00:00
c9a9309b8c ENH: simplify construction of zero-sized Clouds
- use Foam::zero as a dispatch tag

FIX: return moleculeCloud::constProps() List by reference not copy

STYLE: range-for when iterating cloud parcels

STYLE: more consistent typedefs / declarations for Clouds
2023-12-15 16:17:15 +01:00
05f2d54979 ENH: masterCoarsest: demo case for processorAgglom. See !645 2023-12-11 12:28:08 +00:00
8ae0056edd ENH: GAMG: processor agglomeration extended for all interfaces 2023-12-07 17:33:29 +00:00
ef44df91f2 ENH: support direct lookup of solver controls
OLD:
        pEqn.solve(mesh.solver(p.select(piso.finalInnerIter())));
        pEqn.solve(mesh.solver("Yi"));

    NEW:
        pEqn.solve(p.select(piso.finalInnerIter()));
        pEqn.solve("Yi");
2023-12-07 17:42:24 +01:00
149cd7042f ENH: use thisDb reference when referencing/creating finite-area fields
COMP: remove faMesh::operator()() in favour of mesh() or thisDb() instead

- makes the purpose and usage clearer
2023-12-07 17:42:24 +01:00
0ff86ee2e7 ENH: replaced fragile dict interactions by meshState functions 2023-12-01 11:54:35 +00:00
79cd147de0 STYLE: Refactoring use of meshState in {fv|faMesh}
{fv|fa}Mesh classes inherited the [old] data class (renamed meshState)
- meshState removed from inheritance list and added as data members
2023-12-01 11:54:35 +00:00
eea72282ab ENH: CHT solvers - avoid fvSolution persisting on time db 2023-11-20 14:32:11 +00:00
9ac0f03963 ENH: pisoFoam: allow runTimeModifiable. Fixes #2997. 2023-10-11 15:54:30 +01:00
b620152191 ENH: add UPstream::msgType() setter method and UPstream::incrMsgType()
- like UPstream::parRun() etc, returns old value
2023-08-18 15:08:42 +02:00
db16d80840 ENH: use objectRegistry/IOobjectList sorted instead of lookupClass
- in most cases a parallel-consistent order is required.
  Even when the order is not important, it will generally require
  fewer allocations to create a UPtrList of entries instead of a
  HashTable or even a wordList.
2023-07-31 20:11:32 +02:00
ed314b2740 ENH: use sorted order for patch IDs in fieldFunctionObjects (#2819)
- replaces labelHashSet with a sorted labelList to ensure that patches
  will be processed in consistent order in parallel
2023-07-31 20:11:32 +02:00
945e3e41b1 ENH: more consistent use of good() or direct testing instead valid() 2023-07-27 16:52:03 +02:00
d5a0eaeeee STYLE: changes to Time and TimeState
- update TimeState access methods

- use writeTime() instead of old method name outputTime()

- use deltaTValue() instead of deltaT().value()
  to avoids pointless construct of intermediate
2023-07-04 17:25:25 +02:00
2d145e070e COMP: chtMultiRegionTwoPhaseEulerFoam: compile local files only 2023-06-28 16:35:47 +01:00
fc86e52451 ENH: extrapolateInternal() method for patch fields
- provides a more succinct way of writing

      {fa,fv}PatchField<Type>::patchInternalField(*this)

  as well as a consistent naming that can be used for patches derived
  from valuePointPatchField

ENH: readGradientEntry helper method for fixedGradient conditions

- simplifies coding and logic.
- support different read construct modes for fixedGradient
2023-06-19 17:47:03 +02:00
adc38d55ac ENH: coupled: enforce consistency. See #2783 2023-06-01 08:14:42 +00:00
59b1cf080e ENH: Tensor/SymmTensor: add devSymm and devTwoSymm funcs to avoid intermediates 2023-05-15 17:05:10 +01:00
e967305ef2 STYLE: use calculatedType() and zeroGradientType() methods 2023-05-02 13:34:12 +02:00
5042d1296f ENH: consistent UniformDimensionedField naming
- construct from components, or use word::null to ensure
  consistent avoid naming between IOobject vs dimensioned type.

- support construct with parameter ordering as per DimensionedField

ENH: instantiate a uniformDimensionedLabelField

- eg, for registering standalone integer counters
2023-04-24 15:46:04 +02:00
87eed5e3b8 ENH: place more patch field attributes under template invariant Base
- attributes such as assignable(), coupled() etc

- common patchField types: calculatedType(), zeroGradientType() etc.
  This simplifies reference to these types without actually needing a
  typed patchField version.

ENH: add some basic patchField types to fieldTypes namespace

- allows more general use of the names

ENH: set extrapolated/calculated from patchInternalField directly

- avoids intermediate tmp
2023-04-03 13:33:56 +02:00
25bc7d65f7 STYLE: prefer REGISTER/NO_REGISTER instead of true/false for IOobject
- self-documenting
2023-03-10 14:16:32 +00:00
b17422ef1a ENH: use readValueEntry, readMixedEntries for simpler program control 2023-03-08 15:30:04 +00:00
68bbd8f3a8 Merge remote-tracking branch 'origin/master' into develop 2023-02-21 10:21:31 +01:00