ENH: Allow setting the initial values of the design variables

in topology optimisation, through a volScalarfield named alpha.
The order of precedence is (top to bottom):
- values read from time/uniform/topOVars (used also for continuation)
- values read from 0/alpha (can be easily set with topoSet + setFields)
- uniform zero
This commit is contained in:
Vaggelis Papoutsis
2024-11-22 16:56:43 +02:00
committed by Andrew Heather
parent 9c5ce8e4f2
commit f90c7b17fc

View File

@ -223,27 +223,33 @@ void Foam::topODesignVariables::readField
{ {
SubField<scalar>(*this, mesh_.nCells(), offset) = SubField<scalar>(*this, mesh_.nCells(), offset) =
scalarField(name, *this, mesh_.nCells()); scalarField(name, *this, mesh_.nCells());
}
/* else
// Set values next to IO boundaries if needed
if (setIOValues)
{ {
forAll(mesh_.boundary(), patchI) IOobject header
(
name,
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
);
if (header.typeHeaderOk<volScalarField>())
{ {
const fvPatch& patch = mesh_.boundary()[patchI]; Info<< "Setting design variables based on the alpha field "
if (patch.type() == "patch") << nl << endl;
volScalarField volField
(
header,
mesh_
);
const scalarField& field = volField.primitiveField();
forAll(field, cI)
{ {
const labelList& faceCells = patch.faceCells(); scalarField::operator[](offset + cI) = field[cI];
const scalarField& pf = volField.boundaryField()[patchI];
forAll(faceCells, fI)
{
scalarField::operator[](offset + faceCells[fI]) = pf[fI];
} }
} }
} }
}
*/
}
} }