76 patchDistMethod::patchTypes<scalar>(
mesh_, wallPatchIDs)
84 vars =
y.primitiveField();
101 betaIf[IOcell] =
Zero;
109 for (
const label zoneID : fixedZeroPorousZones)
112 for (
const label cellI : zone)
114 betaIf[cellI] =
Zero;
119 forAll(fixedPorousZones, zI)
121 const label zoneID = fixedPorousZones[zI];
122 const scalar value = fixedPorousValues[zI];
124 for (
const label cellI : zone)
126 betaIf[cellI] = value >= 0 ? 0 : 1;
143 for (
const label zoneID : fixedZeroPorousZones)
146 for (
const label cellI : zone)
148 isActiveVar[cellI] =
false;
153 for (
const label zoneID : fixedPorousZones)
156 for (
const label cellI : zone)
158 isActiveVar[cellI] =
false;
166 isActiveVar[cellI] =
false;
185 for (
const label
cellZoneID : adjointPorousZoneIDs)
189 for (
const label cellI : zone)
216 Info<<
"Re-initilising the level-set distance field" <<
nl <<
endl;
223 mesh_.time().timeName(),
232 y.primitiveFieldRef() = aTilda_.primitiveFieldRef();
233 y.correctBoundaryConditions();
235 changedFaces_.clear();
236 changedFaces_.setSize(mesh_.nFaces(), -1);
238 changedFacesInfo_.clear();
239 changedFacesInfo_.setSize(mesh_.nFaces());
241 writeFluidSolidInterface(aTilda_, 0, changedFaces_, changedFacesInfo_);
244 allCellInfo_.clear();
245 allCellInfo_.setSize(mesh_.nCells());
254 mesh_.globalData().nTotalCells() + 1
258 forAll(allCellInfo_, celli)
260 if (allCellInfo_[celli].valid(wave.data()))
262 signedDistances_[celli] =
266 signedDistances_.correctBoundaryConditions();
272 levelSetDesignVariables::levelSetDesignVariables
329 fixATildaValues_(
dict.getOrDefault<bool>(
"fixATildaValues", true)),
330 writeAllDistanceFields_
331 (
dict.getOrDefault<bool>(
"writeAllDistanceFields", false)),
341 scalar maxDist =
gMax(*
this);
343 localIOdictionary::getOrDefault<scalar>(
"lowerBound", -maxDist - SMALL);
345 localIOdictionary::getOrDefault<scalar>(
"upperBound", maxDist + SMALL);
352 <<
"Using lower/upper bounds " 428 Info<<
"maxInitChange/maxChange \t" 462 regularise(
aTilda_, objectiveSens, objectiveSens,
false,
radius_());
464 objectiveSens *=
mesh_.
V();
485 return tobjectiveSens;
506 alpha.primitiveFieldRef() = *
this;
static const word & zeroGradientType() noexcept
The type name for zeroGradient patch fields.
Base class for selecting the regulatisation radius.
labelList activeDesignVariables_
Which of the design variables will be updated.
List< scalar > scalarList
List of scalar.
dimensionedScalar sign(const dimensionedScalar &ds)
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Return the correction form of the given matrix by subtracting the matrix multiplied by the current fi...
void size(const label n)
Older name for setAddressableSize.
const word zeroGradientType
A zeroGradient patch field type.
const Internal::FieldType & primitiveField() const noexcept
Return a const-reference to the internal field values.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Abstract base class for adjoint-based sensitivities.
autoPtr< regularisationPDE > regularisation_
Regularisation mechanism.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
virtual bool globalSum() const
Whether to use global sum when computing matrix-vector products in update methods.
volScalarField aTilda_
The regularised field.
void updateSignedDistances()
Make aTilda a signed distance field based on the zero iso-surface of the current aTilda field...
topOZones zones_
Cell zones useful for defining the constant and changing parts of the domain in topO.
constexpr char nl
The newline '\n' character (0x0a)
bool empty() const noexcept
True if List is empty (ie, size() is zero)
void applyFixedPorosityValues()
Apply fixed values in certain zones.
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
const scalarList & fixedPorousValues() const
Values of alpha for each fixed porous zone.
Wave propagation of information through grid. Every iteration information goes through one layer of c...
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
void writeEntry(const word &keyword, Ostream &os) const
Write the field as a dictionary entry.
Template invariant parts for fvPatchField.
Base class for selecting the regulatisation PDE.
autoPtr< regularisationRadius > radius_
The regularisation radius.
Ignore writing from objectRegistry::writeObject()
bool writeTime() const noexcept
True if this is a write interval.
const dimensionSet dimless
Dimensionless.
const Time & time() const
Return the top-level database.
virtual void update(scalarField &correction)
Update design variables based on a given correction.
const DimensionedField< scalar, volMesh > & V() const
Return cell volumes.
const adjointSolver & getAdjointSolver() const
Const access to adjoint solver.
volScalarField signedDistances_
The signed distances field.
const cellZone & IOCells() const
Cells next to IO boundaries.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Macros for easy insertion into run-time selection tables.
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
#define forAll(list, i)
Loop across all elements in list.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
static autoPtr< levelSetDesignVariables > New(fvMesh &mesh, const dictionary &dict)
Return a reference to the selected turbulence model.
void setSize(const label n)
Alias for resize()
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const labelList & fixedZeroPorousZoneIDs() const
Cell zone IDs with fixed zero porosity values.
autoPtr< topOInterpolationFunction > interpolation_
Function to transorm signed distances to the indicator field beta_.
virtual bool write(const bool writeOnProc=true) const
Write using setting from DB.
virtual const volScalarField & beta() const
Const reference to the beta field.
Signed distance field design variables for level-set based topology optimization (topO).
autoPtr< scalar > maxInitChange_
Maximum design variables' change in the first optimisation cycle.
void readBounds(autoPtr< scalar > lowerBoundPtr=nullptr, autoPtr< scalar > upperBoundPtr=nullptr)
Read bounds for design variables, if present.
void readField()
Read the design variables field.
bool writeAllDistanceFields_
Write all fields related to the distance calculation (debugging)
#define DebugInfo
Report an information message using Foam::Info.
volScalarField beta_
The indicator field.
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
label size() const noexcept
The number of elements in the container.
int debug
Static debugging option.
Type gMax(const FieldField< Field, Type > &f)
Info<< "Predicted p max-min : "<< max(p).value()<< " "<< min(p).value()<< endl;rho==max(psi *p+alphal *rhol0+((alphav *psiv+alphal *psil) - psi) *pSat, rhoMin);# 1 "/home/chef2/andy/OpenFOAM/release/v2406/OpenFOAM-v2406/applications/solvers/multiphase/cavitatingFoam/alphavPsi.H" 1{ alphav=clamp((rho - rholSat)/(rhovSat - rholSat), zero_one{});alphal=1.0 - alphav;Info<< "max-min alphav: "<< max(alphav).value()<< " "<< min(alphav).value()<< endl;psiModel-> correct()
OBJstream os(runTime.globalPath()/outputName)
defineTypeNameAndDebug(combustionModel, 0)
static bool try_movePoints(const fvMesh &mesh)
Trigger update of y-field for the "wallDist" MeshObject on the given mesh. A no-op if the wallDist is...
DynamicID< cellZoneMesh > cellZoneID
Foam::cellZoneID.
autoPtr< scalarField > lowerBounds_
Lower bounds of the design variables.
virtual tmp< scalarField > assembleSensitivities(adjointSensitivity &adjointSens)
Add contributions from the adjoint to the regularization PDE, the derivative of the interpolation fun...
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field values.
Abstract base class for defining design variables.
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
label nCells() const noexcept
Number of mesh cells.
const word & solverName() const
Return the solver name.
Mesh data needed to do the Finite Volume discretisation.
Automatically write from objectRegistry::writeObject()
autoPtr< scalarField > upperBounds_
Upper bounds of the design variables.
const labelList & adjointPorousZoneIDs() const
Cell zone IDs in which porosity is allowed to change.
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
void correctBoundaryConditions()
Correct boundary field.
messageStream Info
Information stream (stdout output on master, null elsewhere)
void updateBeta()
Update the beta field.
void operator+=(const UList< scalar > &)
virtual scalar computeEta(scalarField &correction)
Compute eta if not set in the first step.
List< label > labelList
A List of labels.
A class for managing temporary objects.
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
void setActiveDesignVariables(bool activeIO=false)
Determine which design variables are active.
Base class for all design variables related to topology optimisation (topO). Provides the lookup func...
Defines the attributes of an object for which implicit objectRegistry management is supported...
static autoPtr< patchDistMethod > New(const dictionary &dict, const fvMesh &mesh, const labelHashSet &patchIDs, const word &defaultPatchDistMethod=word::null)
List< bool > boolList
A List of bools.
const labelList & fixedPorousZoneIDs() const
Cell zone IDs with fixed porosity values.
List< wallPoints > allFaceInfo(mesh_.nFaces())
labelHashSet findPatchIDs() const
Find patch indices for a given polyPatch type.
bool fixATildaValues_
Fix aTilda values in fixed{Zero}PorousZones and IOcells.
const autoPtr< volScalarField > & fieldSensPtr() const
Get the fieldSensPtr.
virtual void writeDesignVars()
Write useful quantities to files.
virtual bool writeData(Ostream &) const
The writeData function required by the regIOobject write operation.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)
static constexpr const zero Zero
Global zero (0)