Commit Graph

26868 Commits

Author SHA1 Message Date
Andrew Heather
f8c20963d2 RELEASE: Updated completions cache 2023-12-20 19:42:51 +01:00
Mark Olesen
032a4519ff COMP: adjust link parameters (mingw)
- adjointOptimisation : missing link to fileFormats

- snappyHexMesh : add fvMotionSolvers link (#3058)

STYLE: remove remnant -DFULLDEBUG hints

- now more easily covered with wmake -debug ...
2023-12-20 19:22:19 +01:00
mattijs
cf47600dde ENH: snappyHexMeshDict: some comment 2023-12-20 15:00:40 +00:00
Mark Olesen
de133af526 FIX: redistributePar problems with lagrangian
- the fileHandler changes included setting cacheLevel(0) to avoid
  blocking with redistributePar. However, this meant if clouds
  were not uniformly present on all ranks the fileHandler would follow
  different code paths and lead to blocking.

  Now switch to distributed mode for the lagrangian operations within
  redistributePar based on the cacheLevel information.

FIX: avoid triggering a false processor check in argList

- when redistributing to few ranks
2023-12-20 15:18:55 +01:00
Mark Olesen
88be9ef5c6 FIX: provide default uniform scotch weighting (#3063)
- maintains the same code path within scotch
2023-12-20 13:28:17 +01:00
Andrew Heather
7d9bba67c1 BUG: Fixed keepParticle regression introduced in 8fb148bb 2023-12-20 12:25:37 +00:00
mattijs
2602d08d8a TUT: mergePairs: cleanup 2023-12-20 11:58:53 +00:00
Andrew Heather
af43f9aa24 ENH: caseInfo - use OF dictionary as default writeFormat
STYLE: checkMesh - removed writeChecks uppercase JSON option
2023-12-19 20:31:08 +00:00
Andrew Heather
686f2a3986 Merge branch 'extrae-profiling' into 'develop'
ENH: add profiling hooks for Extrae into the OpenFOAM profiling (#3043)

See merge request Development/openfoam!652
2023-12-19 14:45:43 +00:00
Josep Pocurull Serra
0fbdbb8330 ENH: add profiling hooks for Extrae into the OpenFOAM profiling (#3043)
- the hooks are defined as weak symbols and are compiled into OpenFOAM
  by default. If the library is not loaded (via LD_PRELOAD) the hooks
  have no effect.

    - https://tools.bsc.es/extrae
    - https://tools.bsc.es/paraver
2023-12-19 14:45:32 +00:00
Andrew Heather
e8f0cfb2a5 Merge branch 'feature-topology-optimization' into 'develop'
ENH: update of the adjoint library and introduction of topology optimisation

See merge request Development/openfoam!649
2023-12-18 18:01:56 +00:00
Vaggelis Papoutsis
4c3f9a9772 TUT: added topology optimisation tutorials
using the Borrvall-Petersson method to compute the source terms of the
flow equations.
2023-12-18 18:01:35 +00:00
Vaggelis Papoutsis
7868d9251a TUT: added a topology optimisation tutorial using ISQP
to update the design variables
2023-12-18 18:01:35 +00:00
Vaggelis Papoutsis
0af46becdd ENH: treating issues with the convergence of ISQP
The solution of the QP subproblem can become quite expensive, especially
for cases with many design variables (e.g. topology optimisation).

A (potentially dense) matrix with the size of the design variables is
solved using a matrix-free CG solver. The convergence speed greatly
depends on the used preconditioner. This commit adds
preconditioner-vector products based on the L-BFGS inverse Hessian and,
more importantly, a preconditioner computed using the Sherman-Morrison
formula. The latter is applicable here since the LHS of the QP problem
is computed as the sum of rank-2 L-BFGS updates, a sum of rank-1 updates
(as many as the flow-related constraints) and a diagonal matrix
depending on the bound constraints.

Additionally, the QP subproblem could have no feasible points. To relax
this, constraints can be applied gradually through the
targetConstraintReduction enty (typical value of 0.1 for topology
optimisation).
2023-12-18 18:01:35 +00:00
Vaggelis Papoutsis
0120d7720b BUG: topology optimisation design variables were not written
properly for continuation (written through SubField instead of Field)
2023-12-18 18:01:35 +00:00
Vaggelis Papoutsis
afe9b90d04 STYLE: homogenised the use of "topO" instead of "topo"
whenever refering to topology optimisation.
2023-12-18 18:01:35 +00:00
Vaggelis Papoutsis
a6e9a29f41 TUT: minor updates to the topology optimisation tutorials
Replaced 'convertToMeters' with 'scale' in blockMeshDicts and added the
creation of the triSurface folder in some re-evaluation cases
2023-12-18 18:01:35 +00:00
Vaggelis Papoutsis
634f921831 GIT: removed unused file incompressibleAdjointSolverTemplates.C 2023-12-18 18:01:35 +00:00
Vaggelis Papoutsis
28c538f3e1 ENH: the boundary value of the regularised field of design variables
(aTilda) in topology optimisation can now be provided through the 'wallValue' in the
regularisation dictionary (defaults to 1)
2023-12-18 18:01:35 +00:00
Vaggelis Papoutsis
3cd2b2c692 ENH: The (final) sensitivities involved in topology optimisation
runs can now be written to files using the 'writeAllFields' flag in the
designVariables dictionary (defaults to false)
2023-12-18 18:01:35 +00:00
Vaggelis Papoutsis
c3b212e06c ENH: Input in objectiveFlowRatePartition now reads "targetFractions"
instead of targetPercentages, with a compatibility read on the latter.
Changed corresponding tutorials too.
2023-12-18 18:01:35 +00:00
Vaggelis Papoutsis
eabb821926 TUT: updated the topology optimisation tutorials
Most cases now rely on the nullSpace update method, instead of MMA,
since it has proven more reliable.

Also, added some constrained optimisation cases, including constraints
on the flow rate partition and total pressure losses as well as cases
targeting uniformity as the objective function.

Added a 3D topology optimisation case which also includes constraints.
2023-12-18 18:01:35 +00:00
Vaggelis Papoutsis
46757d12ec ENH: minor update in levelSet-based topology optimisation,
to keep the regularised design variables and the signed distance in
different fields
2023-12-18 18:01:35 +00:00
Vaggelis Papoutsis
1f7fb08060 BUG: wrong numbering when determining the zoneIDs
of the STL written by topology optimisation.

BUG: when determining which mesh faces are cut by iso-surface faces,
only append the latter if it contains more than two points
2023-12-18 18:01:35 +00:00
Vaggelis Papoutsis
e5d5e7b0be ENH: added the option to stop the normalisation
of the objective and constraint gradients in MMA, at a specific
optimisation cycle
2023-12-18 18:01:35 +00:00
Vaggelis Papoutsis
bf18fb758c ENH: nullSpace will now perturb the design variables
by a small amount, if all of them lay on the lower or upper bounds at
the beginning of the optimisation, to avoid singular matrices when
computing the update of the design variables.
2023-12-18 18:01:35 +00:00
Vaggelis Papoutsis
e764f7b573 ENH: flowRate and flowRatePartition objectives are now computed
based on phi, instead of U & Sf
2023-12-18 18:01:35 +00:00
Vaggelis Papoutsis
b5b48b66d1 ENH: enabled the postProcess option in adjointOptimisationFoam 2023-12-18 18:01:35 +00:00
Vaggelis Papoutsis
741520801a STYLE: minor change on the output of max mags of the adjoint fields 2023-12-18 18:01:35 +00:00
Vaggelis Papoutsis
8947735b1d ENH: enable the execution of functions objects in optimisation mode 2023-12-18 18:01:35 +00:00
Vaggelis Papoutsis
2ad6c9f5d2 ENH: adjointRASModel will not crash if set to laminar
and the Jacobian of the objective function wrt the turbulence variables
is called (rare/unorthodox case).

Additionally, objectivePowerDissipation dissipation can now be used in
topology optimisation, adding the necessary blockage dependency to it.
2023-12-18 18:01:35 +00:00
Vaggelis Papoutsis
753a534382 ENH: changes in topOVariablesBase and derived classes
- Building the iso-surface spliting fluid and solid parts in topology
  optimisation has been re-worked to obtain an iso-surface with unique
  point numbering
- The mechanism behind marchingCells for dynamicTopODesignVariables has
  been slightly reworked
2023-12-18 18:01:35 +00:00
Vaggelis Papoutsis
f35b4cc3fb ENH: added a variant of betaMax that computes it
based on the product of the Reynolds and Darcy numbers
2023-12-18 18:01:35 +00:00
Vaggelis Papoutsis
2927015824 ENH: added a null space approach to update the design variables 2023-12-18 18:01:35 +00:00
Vaggelis Papoutsis
6020fabcdd ENH: added a normalisation mechanism in MMA
The derivatives of the objective and constraint functions can optionally
be normalised in each optimisation cycle, so that MMA does not put an
excesive stress on the constraints, which can negatively affect the
course of the optimisation
2023-12-18 18:01:35 +00:00
Andrew Heather
adaac7257f INT: integration updates
- Minor code style
- virtual functions
- added some noexcept
2023-12-18 18:01:35 +00:00
Vaggelis Papoutsis
bd84860e9b ENH: added references to topology optimisation headers 2023-12-18 18:01:35 +00:00
Vaggelis Papoutsis
50d13c6278 ENH: getters in objective are now const 2023-12-18 18:01:35 +00:00
Vaggelis Papoutsis
e0ea0973b1 ENH: replace List<objective*> with UPtrList in incompressiblePrimalSolver (fixes #2946) 2023-12-18 18:01:35 +00:00
Vaggelis Papoutsis
b435feffde TUT: added tutorials for topology optimisation
A 1-Inlet-2-Outlet geometry is showcased for laminar and turbulent
flows, set-up with different variants of porosity-based and
level-set-based topology optimisation
2023-12-18 18:01:35 +00:00
Vaggelis Papoutsis
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
Vaggelis Papoutsis
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
Vaggelis Papoutsis
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
Vaggelis Papoutsis
58cfb58b1a ENH: extened fvOptions to support sensitivity derivative
computations necessary in topology optimisation
2023-12-18 18:01:35 +00:00
Vaggelis Papoutsis
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
mattijs
ae8b654a86 BUG: cyclicAMI: missing autoMap,rmap 2023-12-18 16:40:12 +00:00
Andrew Heather
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
Mattijs Janssens
d6ba54bfec ENH: fileOperation: fix fileOperation::nProcs to handle multiple candidates 2023-12-18 15:59:31 +00:00
Andrew Heather
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
Mattijs Janssens
7a9dd4c0c2 ENH: cyclicAMI: add non-blocking for GAMG 2023-12-18 12:56:33 +00:00