Commit Graph

26828 Commits

Author SHA1 Message Date
b23b09fdbd ENH: added adjoint-based topology optimisation (topO) capabilities
Both porosity-based and level-set-based topO frameworks are included
through the topO and levelSet designVariables, respectively.

Both frameworks work by manipulating an underlying field of design
variables, defined in all cells of the computational domain. That field
is then regularised through a Helmholtz-like filter, before being
processed in a different way from the two topO frameworks (the
porosity-based topO sharpens/projects it while the level-set-based topO
computes signed distances around its zero iso-surface). The result of
this processing is then fed into functions that define source terms to
be added to the mean flow and turbulence model equations, to block
off/solidify parts of the mesh that are counterproductive with respect
to the objective function. These source terms are added through
fvOptions.

Since the designed walls are only simulated through source terms, the
outcome of topO should be re-analyzed on a body-fitted grid, to quantify
the actual gain in the objective function. Both topO frameworks output
the designed wall in STL format which can be used, for instance with
snappyHexMesh, to construct such a body fitted grid.
2023-12-18 18:01:35 +00:00
2b2c78309c ENH: added an optional argument to the constructor of patchWave
This provides a list of faces (can be internal ones) to act as
additional seeds for the wave algorithm. The default argument provides
an empty list, so the behaviour of patchWave should not change.

Useful in topology optimisation, for propagating the active design
variables from the seed faces to the interior, with a given number of
cells at a time.
2023-12-18 18:01:35 +00:00
59bf69b92e ENH: changes in advectionDiffusionPatchDistMethod
- advectionDiffusion is frequently used within optimisation loops since
  it is differentiable. In shape optimisation, the re-computation of
  mesh distances is performed at the very beginning of a new
  optimisation cycle, due to inheriting from MeshObject. If the mesh
  quality is poor enough, the advectionDiffusion PDE might diverge and
  crash the run, before the problematic mesh is written to files for
  inspection. The default behaviour now is to check the mesh before
  solving the advectionDiffusion PDE and write the mesh points if some
  mesh check fails.
- fvOptions can now be included in advectionDiffusion (necessary for
  topology optimisation of turbulent flows for models that include the
  distance field)
- Minor changes in the numerical treatment of the diffusion term, to
  enhance stability
2023-12-18 18:01:35 +00:00
58cfb58b1a ENH: extened fvOptions to support sensitivity derivative
computations necessary in topology optimisation
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
ae8b654a86 BUG: cyclicAMI: missing autoMap,rmap 2023-12-18 16:40:12 +00:00
dbacd7bc95 Merge branch 'feature-fileOperation-nProcs' into 'develop'
ENH: fileOperation: fix fileOperation::nProcs to handle multiple candidates

See merge request Development/openfoam!653
2023-12-18 15:59:31 +00:00
d6ba54bfec ENH: fileOperation: fix fileOperation::nProcs to handle multiple candidates 2023-12-18 15:59:31 +00:00
577f584446 Merge branch 'feature-nonblockingGAMG' into 'develop'
ENH: cyclicAMI: add non-blocking for GAMG

See merge request Development/openfoam!651
2023-12-18 12:56:33 +00:00
7a9dd4c0c2 ENH: cyclicAMI: add non-blocking for GAMG 2023-12-18 12:56:33 +00:00
80d7227c3a SUBMODULE: update all the submodules 2023-12-18 11:39:20 +00:00
88b3fb7c2d ENH: foamMonitor: modernise and refactor the script (fixes #2104)
- enhance POSIX compliance
- apply distinct colours and dash type for each line
- standardize the frame size to 1200x627
- dynamically replace the title with <function-object-name>/<file-name>
- address underscore character issues
- introduce legend components for tensors
- resolve a bug caused by parentheses in tensor files

BUG: particleTrackProperties: correct the typo (fixes #3050)
2023-12-15 22:20:27 +00:00
7e0acfa4ed ENH: handle 64-bit memory information (#3060)
- on large memory systems (eg, 6TB) the process information
  exceeds an 'int' range, so adjust parsing of the /proc/..
  to use int64

ENH: update/modernize OSspecific system information

ENH: minor update of profiling code

- std::string, noexcept, lazier evaluations

STYLE: use direct call of memInfo
2023-12-15 17:21:38 +01:00
2045de8345 CONFIG: foamPackRelease handling of recursive submodules 2023-12-15 16:17:16 +01:00
432d65475c ENH: preserve origId in foamFormatConvert (fixes# #3051)
- previously read the cloud directly without any of the
  passiveParticle fields (origProcId, origId), which meant they would
  not actually be converted.
2023-12-15 16:17:16 +01: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
0352a224b7 COMP: access transformedElements by reference, not copy
- better code style and seems to avoid triggering a gcc warning about
  possibly uninitialized values

COMP: JSONformatter writeEntry missing a return value

STYLE: accept 'json' for checkMesh write format

- consistent with caseInfo functionObject
2023-12-15 16:17:15 +01:00
79993bba43 CONFIG: support explicit selection of 'ld' linker
- for clang-based compilers the default linker may be lld or simply ld.
  Support '+link-ld' to explicitly select use of the ld linker.

- consolidate linker rules into single files

STYLE: adjust SPDX Identifier
2023-12-15 16:17:12 +01:00
5cdc8c6fde BUG: redistributePar: Differing communicator. See #3053.
redistributePar -decompose switches communicator when
reading on master. However other processors still get
constructed with the worldComm. >v2306 AMI stores the communicator
from construction time there was a mismatch
2023-12-13 12:56:59 +00:00
f99bcd1f6c BUG: solver performance updates overwrite pimple controls (fixes #3054)
- regression introduced by commit 0ff86ee2
  (only affects recent develop).

- now split off first/final iterations into a separate
  "controls" dictionary (instead of lumping them into "solver") to
  make them persistent between iterations.
2023-12-13 12:34:43 +01:00
35c884971a BUG: redistributePar blocks with -ioRanks (#3005) 2023-12-12 20:35:09 +01:00
a0e4ee0b3e BUG: masterUncollated readStream causes checkOut/checkIn (#2952)
- updating the header information (by copying) was closing the stream,
  removing all watches and doing a checkOut/checkIn, which could lead to
  dangling references.
  Now just close the stream and simply copy the IOobject header
  information directly.

STYLE: mark regIOobject assignment operator as possibly deprecated

- will revisit to revise or remove in the future
2023-12-12 20:06:50 +01:00
c647e68e1f BUG: mismatch in watch file indices (see !605) 2023-12-12 20:06:50 +01:00
56a0f80863 BUG: copy construct of faSchemes/faSolution ignored (see !605)
- the faMesh/fvMesh copy constructors were using the readOption from
  the base-mesh schemes/solution instead of copying their contents.

  This would not really affect fvMesh (since it has its own IOobject
  for the constructor), but did affect faMesh. However, the problem
  only shows up with collated + redistribute, since that is where
  the ranks can be doing uncoordinated IO.

  Only consider as a bug for recent develop since previous versions
  had other problems with collated+redistribute with finite-area
  anyhow.
2023-12-12 20:06:50 +01:00
5b177b44f3 STYLE: update README to v2312 2023-12-12 20:06:50 +01:00
4612238eff BUG: multiWorld: switch to inter-world communicator. Fixes #3053. 2023-12-12 17:26:59 +00:00
3339f25992 Merge branch 'update-registry-handling0' into 'develop'
Improved DimensionedField/GeometricField factory methods

See merge request Development/openfoam!650
2023-12-12 11:57:57 +00:00
7cc6d52345 CONFIG: increment API level to 2310 2023-12-11 15:56:00 +01:00
4cf1691cdd ENH: update DimensionedField and GeometricField New factory methods
- allow separate specification of the registerObject (no/yes/auto)
  to improve the flexibility of the factory methods.
2023-12-11 15:56:00 +01:00
6ea4328ea1 SUBMODULE: update avalanche, visualization 2023-12-11 15:56:00 +01:00
28b6a5b85a ENH: allow modification of tmp state (cached or uncached)
- simplifies handling.
  * enables unprotecting to avoid accidentally cloning.
  * removes the need for dedicated constructor or factory forms.
  * simplfies DimensionedField and GeometricField New factory methods

- update objectRegistry management method (internal use)

  old:  bool cacheTemporaryObject(...)
  new:  bool is_cacheTemporaryObject(...)

  to clarify that it is a query, not a request for caching etc.
2023-12-11 15:56:00 +01:00
d086cc5a0e COMP: stricter handling of openmp vs no-openmp
- give precedence to ~openmp (-no-openmp) over +openmp (-openmp)
  in the general rules and in the Makefile. This makes it robuster
  when specifying +openmp in general, but ~openmp for specific build
  components.

- disable openmp for OSspecific and Pstream components.
  Neither should contain any openmp code anyhow.

  Additionally, since OSspecific is generally built as a static
  object, it can become problematic (eg, with AMD ROCm) if the
  compiler generates information that openmp is required but then uses
  static linkage.
2023-12-11 15:56:00 +01:00
cd493897d3 CONFIG: update ADIOS version. From 2.8.3 to 2.9.2 2023-12-11 15:56:00 +01:00
2fa0c7520c ENH: provide faMesh static accessors for registry and single-region
- the fields for finite-area are currently stored directly on the
  polyMesh registry, but for future relocation to a sub-registry
  provide a uniform accessor.

ENH: use thisDb() for faMatrix access and extrapolatedCalculated
2023-12-11 15:56:00 +01:00
05f2d54979 ENH: masterCoarsest: demo case for processorAgglom. See !645 2023-12-11 12:28:08 +00:00
cf4af229b6 ENH: shm: more layer printing. Fixes #3049 2023-12-11 10:26:09 +00:00
ca80affe60 COMP: MapLagrangian: unused reference 2023-12-11 09:06:19 +00:00
d2b2b9fa0f TUT: redistributePar: use instead of decomposePar 2023-12-11 08:54:41 +00:00
bc5aafa0d9 TUT: fileOperation: bit more testing. See #2952 2023-12-08 15:58:12 +00:00
1844f87a0d COMP: pass as labelList as List<int> for MPI 2023-12-08 13:33:30 +00:00
b4f150b095 Merge branch 'feature-patchSeedSet' into 'develop'
Extended patchSeedSet to generate seed points more uniformly

See merge request Development/openfoam!647
2023-12-08 11:42:22 +00:00
ec48e2f309 ENH: Extended patchSeedSet to generate seed points more uniformly 2023-12-08 11:41:55 +00:00
df71026509 ENH: Added triangulatedPatch class to triangulate pacthes for searching
- Provides random local and global points, optionally perturbed away from the
  boundary faces
2023-12-08 11:41:55 +00:00
863dbc68cb Merge branch '2770-wall-functions' into 'develop'
ENH: wall functions: swap the order of switch statements and for loops

See merge request Development/openfoam!635
2023-12-08 11:21:04 +00:00
330bd16390 ENH: wall functions: swap the order of switch statements and for loops 2023-12-08 11:20:24 +00:00
612d9d3431 ENH: omegaWallFunction: change the scope of corner weights
The 'w' factor is factored out to improve consistency with the
'epsilonWallFunction', enhancing uniformity in these wall functions.
2023-12-08 11:20:24 +00:00
64aee19823 BUG: omegaWallFunction: add missing corner weight (fixes #3003) 2023-12-08 11:20:24 +00:00
a737240e13 BUG: wallFunctions: correct blending terms (fixes #2770) 2023-12-08 11:20:24 +00:00
db29d535c8 Merge branch 'feature-cyclicAMI-processorAgglomeration' into 'develop'
ENH: GAMG: processor agglomeration extended for all interfaces

See merge request Development/openfoam!645
2023-12-07 17:33:29 +00:00
8ae0056edd ENH: GAMG: processor agglomeration extended for all interfaces 2023-12-07 17:33:29 +00:00