COMP: BFGS and SR1 failed to compile with SP

- Failed due to double*Matrix<float> multiplication.

Style changes

- use SquareMatrix with Identity on construction

- use Zero in constructors

- remove trailing space and semi-colons
This commit is contained in:
Vaggelis Papoutsis
2019-12-12 11:40:01 -05:00
committed by Mark Olesen
parent 8ece5f7aae
commit db8a840459
146 changed files with 590 additions and 640 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2004-2019 OpenCFD Ltd.
Copyright (C) 2016-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -223,7 +223,7 @@ private:
// Private Member Functions
//- No copy construct and assignment
//- No copy construct
smoothDelta(const smoothDelta&) = delete;
//- No copy assignment

View File

@ -66,10 +66,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
ATCModel(const ATCModel&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const ATCModel&) = delete;

View File

@ -60,10 +60,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
ATCUaGradU(const ATCUaGradU&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const ATCUaGradU&) = delete;

View File

@ -60,10 +60,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
ATCstandard(const ATCstandard&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const ATCstandard&) = delete;

View File

@ -61,10 +61,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
cancelATC(const cancelATC&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const cancelATC&) = delete;

View File

@ -63,10 +63,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
faceCells(const faceCells&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const faceCells&) = delete;

View File

@ -63,10 +63,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
pointCells(const pointCells&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const pointCells&) = delete;

View File

@ -25,7 +25,6 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::zeroATCcells
@ -61,10 +60,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
zeroATCcells(const zeroATCcells&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const zeroATCcells&) = delete;

View File

@ -125,7 +125,7 @@ Foam::adjointInletVelocityFvPatchVectorField::valueBoundaryCoeffs
const tmp<scalarField>&
) const
{
return tmp<Field<vector>>::New(this->size(), pTraits<vector>::zero);
return tmp<Field<vector>>::New(this->size(), Zero);
}

View File

@ -167,7 +167,7 @@ Foam::adjointOutletVelocityFluxFvPatchVectorField::valueInternalCoeffs
const tmp<scalarField>&
) const
{
return tmp<Field<vector>>::New(this->size(), pTraits<vector>::zero);
return tmp<Field<vector>>::New(this->size(), Zero);
}
@ -177,7 +177,7 @@ Foam::adjointOutletVelocityFluxFvPatchVectorField::valueBoundaryCoeffs
const tmp<scalarField>&
) const
{
return tmp<Field<vector>>::New(this->size(), pTraits<vector>::zero);
return tmp<Field<vector>>::New(this->size(), Zero);
}
@ -185,7 +185,7 @@ Foam::tmp<Foam::Field<Foam::vector>>
Foam::adjointOutletVelocityFluxFvPatchVectorField::
gradientBoundaryCoeffs() const
{
return tmp<Field<vector>>::New(this->size(), pTraits<vector>::zero);
return tmp<Field<vector>>::New(this->size(), Zero);
}
@ -193,7 +193,7 @@ Foam::tmp<Foam::Field<Foam::vector>>
Foam::adjointOutletVelocityFluxFvPatchVectorField::
gradientInternalCoeffs() const
{
return tmp<Field<vector>>::New(this->size(), pTraits<vector>::zero);
return tmp<Field<vector>>::New(this->size(), Zero);
}

View File

@ -193,7 +193,7 @@ void Foam::adjointWallVelocityFvPatchVectorField::updateCoeffs()
// Tangential adjoint velocity in the t1 direction depends on the primal
// wall function used
vectorField Uap_t1(patch().size(), vector::zero);
vectorField Uap_t1(patch().size(), Zero);
typedef Foam::nutUSpaldingWallFunctionFvPatchScalarField
SAwallFunctionPatchField;

View File

@ -100,7 +100,7 @@ Foam::adjointZeroInletFvPatchField<Type>::valueBoundaryCoeffs
const tmp<scalarField>&
) const
{
return tmp<Field<Type>>::New(this->size(), pTraits<Type>::zero);
return tmp<Field<Type>>::New(this->size(), Zero);
}

View File

@ -62,13 +62,13 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
boundaryAdjointContribution
(
const boundaryAdjointContribution&
) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const boundaryAdjointContribution&) = delete;

View File

@ -67,13 +67,13 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
boundaryAdjointContributionIncompressible
(
const boundaryAdjointContributionIncompressible&
) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=
(
const boundaryAdjointContributionIncompressible&

View File

@ -38,9 +38,8 @@ Foam::boundaryAdjointContributionIncompressible::sumContributions
)
{
// Objective function contribution
tmp<Field<returnType>> tdJtotdvar
(new Field<returnType>(patch_.size(), pTraits<returnType>::zero));
Field<returnType>& dJtotdvar = tdJtotdvar.ref();
auto tdJtotdvar = tmp<Field<returnType>>::New(patch_.size(), Zero);
auto& dJtotdvar = tdJtotdvar.ref();
// Get weighthed contribution
for (sourceType& funcI : sourceList)

View File

@ -41,7 +41,7 @@ namespace Foam
tensor deltaBoundary::tensorCrossVector(const tensor& T, const vector& v)
{
// The correct approach when T is not a diagonal tensor
tensor res(tensor::zero);
tensor res(Zero);
vector vec1(T.xx(), T.yx(), T.zx());
vector res1(vec1 ^ v);
res.xx() = res1.x(); res.yx() = res1.y(); res.zx() = res1.z();
@ -74,12 +74,12 @@ vectorField deltaBoundary::makeFaceCentresAndAreas_d
const pointField& p_d
)
{
vector fCtrs_d(vector::zero);
vector fAreas_d(vector::zero);
vector unitVector_d(vector::zero);
vector fCtrs_d(Zero);
vector fAreas_d(Zero);
vector unitVector_d(Zero);
// Container field to return results
vectorField deltaVecs(3, vector::zero);
vectorField deltaVecs(3, Zero);
label nPoints = p.size();
@ -103,12 +103,12 @@ vectorField deltaBoundary::makeFaceCentresAndAreas_d
}
else
{
vector sumN(vector::zero);
vector sumN_d(vector::zero);
scalar sumA = Zero;
scalar sumA_d = Zero;
vector sumAc = vector::zero;
vector sumAc_d = vector::zero;
vector sumN(Zero);
vector sumN_d(Zero);
scalar sumA(0);
scalar sumA_d(0);
vector sumAc(Zero);
vector sumAc_d(Zero);
point fCentre = p[0];
point fCentre_d = p_d[0];
@ -182,12 +182,12 @@ tensorField deltaBoundary::makeFaceCentresAndAreas_d
)
{
label nPoints = p.size();
tensor fCtrs_d(tensor::zero);
tensor fAreas_d(tensor::zero);
tensor unitVector_d(tensor::zero);
tensor fCtrs_d(Zero);
tensor fAreas_d(Zero);
tensor unitVector_d(Zero);
// Container field to return results
tensorField deltaVecs(3, tensor::zero);
tensorField deltaVecs(3, Zero);
// If the face is a triangle, do a direct calculation for efficiency
// and to avoid round-off error-related problems
@ -209,12 +209,12 @@ tensorField deltaBoundary::makeFaceCentresAndAreas_d
}
else
{
vector sumN(vector::zero);
tensor sumN_d(tensor::zero);
scalar sumA = Zero;
vector sumA_d(vector::zero);
vector sumAc(vector::zero);
tensor sumAc_d(tensor::zero);
vector sumN(Zero);
tensor sumN_d(Zero);
scalar sumA(0);
vector sumA_d(Zero);
vector sumAc(Zero);
tensor sumAc_d(Zero);
point fCentre = p[0];
tensor fCentre_d = p_d[0];
@ -287,18 +287,18 @@ tmp<tensorField> deltaBoundary::cellCenters_d(const label pointI)
const labelListList& pointCells(mesh_.pointCells());
const labelList& pointCellsI(pointCells[pointI]);
const pointField& points(mesh_.points());
tmp<tensorField> tC_d(new tensorField(pointCellsI.size(), tensor::zero));
tensorField& C_d(tC_d.ref());
auto tC_d = tmp<tensorField>::New(pointCellsI.size(), Zero);
auto& C_d = tC_d.ref();
const labelList& pointFaces(mesh_.pointFaces()[pointI]);
tensorField Cf_d(pointFaces.size(), tensor::zero);
tensorField Sf_d(pointFaces.size(), tensor::zero);
tensorField Cf_d(pointFaces.size(), Zero);
tensorField Sf_d(pointFaces.size(), Zero);
forAll(pointFaces, pfI)
{
const label pointFaceI = pointFaces[pfI];
const face& faceI = mesh_.faces()[pointFaceI];
tensorField p_d(faceI.size(), tensor::zero);
tensorField p_d(faceI.size(), Zero);
forAll(faceI, pI)
{
if (faceI[pI] == pointI)
@ -321,10 +321,10 @@ tmp<tensorField> deltaBoundary::cellCenters_d(const label pointI)
{
const label pointCellI = pointCellsI[pcI];
const cell& cellI(mesh_.cells()[pointCellI]);
vectorField fAreas(cellI.size(), vector::zero);
vectorField fCtrs(cellI.size(), vector::zero);
tensorField fAreas_d(cellI.size(), tensor::zero);
tensorField fCtrs_d(cellI.size(), tensor::zero);
vectorField fAreas(cellI.size(), Zero);
vectorField fCtrs(cellI.size(), Zero);
tensorField fAreas_d(cellI.size(), Zero);
tensorField fCtrs_d(cellI.size(), Zero);
forAll(cellI, fI)
{
const label globalFaceI = cellI[fI];

View File

@ -70,10 +70,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
deltaBoundary(const deltaBoundary&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const deltaBoundary&) = delete;
//- Compute tensor-vector products

View File

@ -51,8 +51,8 @@ pT deltaBoundary::makeCellCentres_d
// First estimate the approximate cell centre as the average of
// face centres
vector cEst(vector::zero);
vector cellCtrs(vector::zero);
vector cEst(Zero);
vector cellCtrs(Zero);
scalar cellVols(Zero);
pT cEst_d(pTraits<pT>::zero);
pT cellCtrs_d(pTraits<pT>::zero);

View File

@ -77,10 +77,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
displacementMethod(const displacementMethod&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const displacementMethod&) = delete;

View File

@ -69,13 +69,13 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
displacementMethoddisplacementLaplacian
(
const displacementMethoddisplacementLaplacian&
) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const displacementMethoddisplacementLaplacian&) = delete;

View File

@ -70,13 +70,13 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
displacementMethodelasticityMotionSolver
(
const displacementMethodelasticityMotionSolver&
) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=
(
const displacementMethodelasticityMotionSolver&

View File

@ -70,13 +70,13 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
displacementMethodlaplacianMotionSolver
(
const displacementMethodlaplacianMotionSolver&
) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const displacementMethodlaplacianMotionSolver&) = delete;

View File

@ -71,13 +71,13 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
displacementMethodvelocityLaplacian
(
const displacementMethodvelocityLaplacian&
) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const displacementMethodvelocityLaplacian&) = delete;

View File

@ -61,13 +61,13 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
displacementMethodvolumetricBSplinesMotionSolver
(
const displacementMethodvolumetricBSplinesMotionSolver&
) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=
(
const displacementMethodvolumetricBSplinesMotionSolver&

View File

@ -64,7 +64,7 @@ void Foam::elasticityMotionSolver::setBoundaryConditions()
pointMotionU_.boundaryFieldRef()[patchI];
if (isA<fixedValuePointPatchVectorField>(pointBCs))
{
auto& fixedValueBCs =
auto& fixedValueBCs =
refCast<fixedValuePointPatchVectorField>(pointBCs);
fixedValueBCs == fixedValueBCs/scalar(nSteps_);
}
@ -132,12 +132,7 @@ Foam::elasticityMotionSolver::elasticityMotionSolver
IOobject::AUTO_WRITE
),
fvMesh_,
dimensionedVector
(
"cellMotionU",
pointMotionU_.dimensions(),
vector::zero
),
dimensionedVector(pointMotionU_.dimensions(), Zero),
pointMotionU_.boundaryField().types()
),
interpolationPtr_

View File

@ -25,7 +25,6 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::elasticityMotionSolver
@ -75,8 +74,8 @@ protected:
// Protected data
//- Since the mesh deformation is broken down to multiple steps,
//- mesh points need to be moved here.
//- Since the mesh deformation is broken down to multiple steps,
//- mesh points need to be moved here.
//- Hence, the non-const mesh reference
fvMesh& fvMesh_;
pointVectorField pointMotionU_;
@ -155,8 +154,8 @@ public:
//- Return point location. Mesh is actually moved in solve()
virtual tmp<pointField> curPoints() const;
//- Solve for motion.
// Does the actual mesh displacement here, since it is broken down
//- Solve for motion.
// Does the actual mesh displacement here, since it is broken down
// into multiple steps
virtual void solve();

View File

@ -25,7 +25,6 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -36,7 +35,7 @@ inline Foam::pointVectorField& Foam::elasticityMotionSolver::pointMotionU()
}
inline const Foam::pointVectorField&
inline const Foam::pointVectorField&
Foam::elasticityMotionSolver::pointMotionU() const
{
return pointMotionU_;
@ -49,7 +48,7 @@ inline Foam::volVectorField& Foam::elasticityMotionSolver::cellMotionU()
}
inline const Foam::volVectorField&
inline const Foam::volVectorField&
Foam::elasticityMotionSolver::cellMotionU() const
{
return cellMotionU_;

View File

@ -105,12 +105,7 @@ Foam::laplacianMotionSolver::laplacianMotionSolver
IOobject::AUTO_WRITE
),
fvMesh_,
dimensionedVector
(
"cellMotionU",
pointMotionU_.dimensions(),
vector::zero
),
dimensionedVector(pointMotionU_.dimensions(), Zero),
pointMotionU_.boundaryField().types()
),
interpolationPtr_

View File

@ -102,10 +102,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
laplacianMotionSolver(const laplacianMotionSolver&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const laplacianMotionSolver&) = delete;
public:

View File

@ -25,7 +25,6 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -36,7 +35,7 @@ inline Foam::pointVectorField& Foam::laplacianMotionSolver::pointMotionU()
}
inline const Foam::pointVectorField&
inline const Foam::pointVectorField&
Foam::laplacianMotionSolver::pointMotionU() const
{
return pointMotionU_;
@ -49,7 +48,7 @@ inline Foam::volVectorField& Foam::laplacianMotionSolver::cellMotionU()
}
inline const Foam::volVectorField&
inline const Foam::volVectorField&
Foam::laplacianMotionSolver::cellMotionU() const
{
return cellMotionU_;

View File

@ -64,7 +64,7 @@ Foam::volumetricBSplinesMotionSolver::volumetricBSplinesMotionSolver
controlPointsMovement_
(
volBSplinesBase_.getTotalControlPointsNumber(),
vector::zero
Zero
)
{}
@ -82,7 +82,7 @@ Foam::volumetricBSplinesMotionSolver::curPoints() const
forAll(boxes, iNURB)
{
const label nb = boxes[iNURB].getControlPoints().size();
vectorField localControlPointsMovement(nb, vector::zero);
vectorField localControlPointsMovement(nb, Zero);
forAll(localControlPointsMovement, iCP)
{

View File

@ -82,13 +82,13 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
volumetricBSplinesMotionSolver
(
const volumetricBSplinesMotionSolver&
) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const volumetricBSplinesMotionSolver&) = delete;

View File

@ -55,7 +55,7 @@ Foam::linearUpwindNormal<Type>::correction
false
),
mesh,
dimensioned<Type>(vf.name(), vf.dimensions(), pTraits<Type>::zero)
dimensioned<Type>(vf.dimensions(), Zero)
)
);

View File

@ -67,10 +67,10 @@ class linearUpwindNormal
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
linearUpwindNormal(const linearUpwindNormal&);
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const linearUpwindNormal&);

View File

@ -68,10 +68,10 @@ private:
//- Create IO object if dictionary is present
IOobject createIOobject(const fvMesh& mesh) const;
//- Disallow default bitwise copy construct
//- No copy construct
IOoptionListAdjoint(const IOoptionListAdjoint&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const IOoptionListAdjoint&) = delete;

View File

@ -65,10 +65,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
optionAdjointList(const optionAdjointList&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const optionAdjointList&) = delete;

View File

@ -190,7 +190,7 @@ void objectiveManager::updateOrNullify()
void objectiveManager::incrementIntegrationTimes(const scalar timeSpan)
{
// Update start and end integration times by adding the timeSpan
// Update start and end integration times by adding the timeSpan
// of the optimisation cycle
for (objective& obj : objectives_)
{

View File

@ -25,7 +25,6 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::objectiveManager
@ -72,10 +71,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
objectiveManager(const objectiveManager&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const objectiveManager&) = delete;
@ -139,7 +138,7 @@ public:
//- Update contributions to adjoint if true, otherwise return nulls
void updateOrNullify();
//- Increment integration times by the optimisation cycle time-span
//- Increment integration times by the optimisation cycle time-span
void incrementIntegrationTimes(const scalar timeSpan);
//- Print to screen

View File

@ -61,13 +61,13 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
objectiveManagerIncompressible
(
const objectiveManagerIncompressible&
) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const objectiveManagerIncompressible&) = delete;

View File

@ -91,7 +91,7 @@ void objectiveForceTarget::write() const
<< setw(width) << "J" << " "
<< setw(width) << "Force" << " "
<< setw(width) << "Target" << endl;
};
}
objFunctionFilePtr_()
<< setw(3) << mesh_.time().value() << " "

View File

@ -439,7 +439,7 @@ void objectiveIncompressible::nullify()
}
if (hasdJdTMVar1())
{
dJdTMvar1Ptr_() ==
dJdTMvar1Ptr_() ==
dimensionedScalar(dJdTMvar1Ptr_().dimensions(), Zero);
}
if (hasdJdTMVar2())

View File

@ -102,10 +102,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
objectiveIncompressible(const objectiveIncompressible&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const objectiveIncompressible&) = delete;

View File

@ -142,7 +142,7 @@ objective::objective
meanValueFilePtr_(nullptr)
{
makeFolder();
// Read integration start and end times, if present.
// Read integration start and end times, if present.
// For unsteady runs only
if (dict.found("integrationStartTime"))
{
@ -225,9 +225,9 @@ bool objective::readDict(const dictionary& dict)
scalar objective::JCycle() const
{
scalar J(J_);
if
if
(
computeMeanFields_
computeMeanFields_
|| (hasIntegrationStartTime() && hasIntegrationEndTime())
)
{
@ -293,9 +293,9 @@ bool objective::isWithinIntegrationTime() const
if (hasIntegrationStartTime() && hasIntegrationEndTime())
{
const scalar time = mesh_.time().value();
return
return
(
time >= integrationStartTimePtr_()
time >= integrationStartTimePtr_()
&& time <= integrationEndTimePtr_()
);
}
@ -313,8 +313,8 @@ void objective::incrementIntegrationTimes(const scalar timeSpan)
{
if (hasIntegrationStartTime() && hasIntegrationEndTime())
{
integrationStartTimePtr_() += timeSpan;
integrationEndTimePtr_() += timeSpan;
integrationStartTimePtr_() += timeSpan;
integrationEndTimePtr_() += timeSpan;
}
else
{
@ -576,12 +576,12 @@ void objective::nullify()
}
if (hasDivDxDbMult())
{
divDxDbMultPtr_() ==
divDxDbMultPtr_() ==
dimensionedScalar(divDxDbMultPtr_().dimensions(), Zero);
}
if (hasGradDxDbMult())
{
gradDxDbMultPtr_() ==
gradDxDbMultPtr_() ==
dimensionedTensor(gradDxDbMultPtr_().dimensions(), Zero);
}
@ -630,9 +630,9 @@ void objective::writeMeanValue() const
{
// Write mean value if necessary
// Covers both steady and unsteady runs
if
if
(
computeMeanFields_
computeMeanFields_
|| (hasIntegrationStartTime() && hasIntegrationEndTime())
)
{

View File

@ -25,7 +25,6 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::objective
@ -158,10 +157,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
objective(const objective&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const objective&) = delete;
//- Make objective Function Folder
@ -227,7 +226,7 @@ public:
//- Return the instantaneous objective function value
virtual scalar J() = 0;
//- Return the mean objective function value, if it exists,
//- Return the mean objective function value, if it exists,
//- otherwise the mean one
scalar JCycle() const;

View File

@ -108,7 +108,7 @@ FIBase::FIBase
dimensionedTensor(sqr(dimLength)/pow3(dimTime), Zero)
),
divDxDbMult_(mesh_.nCells(), Zero),
optionsDxDbMult_(mesh_.nCells(), vector::zero),
optionsDxDbMult_(mesh_.nCells(), Zero),
dSfdbMult_(createZeroBoundaryPtr<vector>(mesh_)),
dnfdbMult_(createZeroBoundaryPtr<vector>(mesh_)),
dxdbDirectMult_(createZeroBoundaryPtr<vector>(mesh_)),
@ -117,7 +117,7 @@ FIBase::FIBase
eikonalSolver_(nullptr)
{
read();
};
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -147,7 +147,7 @@ void FIBase::accumulateIntegrand(const scalar dt)
PtrList<objective>& functions(objectiveManager_.getObjectiveFunctions());
for (objective& func : functions)
{
divDxDbMult_ +=
divDxDbMult_ +=
func.weight()*func.divDxDbMultiplier().primitiveField()*dt;
}
@ -173,7 +173,7 @@ void FIBase::accumulateIntegrand(const scalar dt)
const scalar wei = func.weight();
dSfdbMult_()[patchI] += wei*func.dSdbMultiplier(patchI)*dt;
dnfdbMult_()[patchI] += wei*func.dndbMultiplier(patchI)*magSfDt;
dxdbDirectMult_()[patchI] +=
dxdbDirectMult_()[patchI] +=
wei*func.dxdbDirectMultiplier(patchI)*magSfDt;
}
}
@ -193,7 +193,7 @@ void FIBase::clearSensitivities()
{
eikonalSolver_->reset();
}
adjointSensitivity::clearSensitivities();
shapeSensitivitiesBase::clear();
}

View File

@ -25,7 +25,6 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::incompressible::FIBase
@ -66,13 +65,13 @@ protected:
// Protected data
//- grad(dx/db) multiplier
volTensorField gradDxDbMult_;
volTensorField gradDxDbMult_;
//- div(dx/db) multiplier
scalarField divDxDbMult_;
scalarField divDxDbMult_;
//- dx/db multiplier coming from fvOptions
vectorField optionsDxDbMult_;
vectorField optionsDxDbMult_;
//- Fields related to direct sensitivities
autoPtr<boundaryVectorField> dSfdbMult_;
@ -96,10 +95,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
FIBase(const FIBase&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const FIBase&) = delete;
@ -131,11 +130,11 @@ public:
//- Read dict if changed
virtual bool readDict(const dictionary& dict);
//- Accumulate sensitivity integrands
virtual void accumulateIntegrand(const scalar dt);
//- Assemble sensitivities
//- Assemble sensitivities
virtual void assembleSensitivities() = 0;
//- Zero sensitivity fields and their constituents

View File

@ -51,8 +51,8 @@ void SIBase::read()
includeObjective_ =
dict().lookupOrDefault<bool>("includeObjectiveContribution", true);
// If includeObjective is set to true both here and in the surface
// sensitivities, set the one in the latter to false to avoid double
// If includeObjective is set to true both here and in the surface
// sensitivities, set the one in the latter to false to avoid double
// contributions
bool surfSensIncludeObjective(surfaceSensitivity_.getIncludeObjective());
if (includeObjective_ && surfSensIncludeObjective)
@ -96,9 +96,9 @@ SIBase::SIBase
surfaceSensitivity_
(
mesh,
// Ideally, subOrEmptyDict would be used.
// Ideally, subOrEmptyDict would be used.
// Since we need a recursive search in shapeSensitivitiesBase though
// and the dict returned by subOrEmptyDict (if found)
// and the dict returned by subOrEmptyDict (if found)
// does not know its parent, optionalSubDict is used
dict.optionalSubDict("surfaceSensitivities"),
primalVars,
@ -112,7 +112,7 @@ SIBase::SIBase
includeObjective_(true)
{
read();
};
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -153,7 +153,7 @@ void SIBase::accumulateIntegrand(const scalar dt)
const scalar wei = func.weight();
dSfdbMult_()[patchI] += wei*func.dSdbMultiplier(patchI)*dt;
dnfdbMult_()[patchI] += wei*func.dndbMultiplier(patchI)*magSfDt;
dxdbDirectMult_()[patchI] +=
dxdbDirectMult_()[patchI] +=
wei*func.dxdbDirectMultiplier(patchI)*magSfDt;
}
}
@ -167,7 +167,7 @@ void SIBase::clearSensitivities()
dSfdbMult_() = vector::zero;
dnfdbMult_() = vector::zero;
dxdbDirectMult_() = vector::zero;
adjointSensitivity::clearSensitivities();
shapeSensitivitiesBase::clear();
}

View File

@ -77,7 +77,7 @@ protected:
// Protected Member Fuctions
//- Read options from dict
void read();
@ -86,10 +86,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
SIBase(const SIBase&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const SIBase&) = delete;
@ -121,11 +121,11 @@ public:
//- Read dict if changed
virtual bool readDict(const dictionary& dict);
//- Accumulate sensitivity integrands
virtual void accumulateIntegrand(const scalar dt);
//- Assemble sensitivities
//- Assemble sensitivities
virtual void assembleSensitivities() = 0;
//- Zero sensitivity fields and their constituents

View File

@ -157,7 +157,7 @@ adjointEikonalSolver::adjointEikonalSolver
distanceSensPtr_(createZeroBoundaryPtr<vector>(mesh_))
{
read();
};
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

View File

@ -94,7 +94,7 @@ adjointMeshMovementSolver::adjointMeshMovementSolver
adjointEikonalSolverPtr_(adjointEikonalSolverPtr)
{
read();
};
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

View File

@ -93,10 +93,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
adjointMeshMovementSolver(const adjointMeshMovementSolver&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const adjointMeshMovementSolver&) = delete;

View File

@ -126,7 +126,7 @@ void adjointSensitivity::clearSensitivities()
derivatives_ = scalar(0);
if (fieldSensPtr_.valid())
{
fieldSensPtr_().primitiveFieldRef() = scalar(0);
fieldSensPtr_().primitiveFieldRef() = scalar(0);
}
}

View File

@ -25,7 +25,6 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::incompressible::adjointSensitivity
@ -94,10 +93,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
adjointSensitivity(const adjointSensitivity&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const adjointSensitivity&) = delete;
@ -170,7 +169,7 @@ public:
// Corresponds to the flow and adjoint part of the sensitivities
virtual void accumulateIntegrand(const scalar dt) = 0;
//- Assemble sensitivities
//- Assemble sensitivities
// Adds the geometric part of the sensitivities
virtual void assembleSensitivities() = 0;

View File

@ -72,17 +72,17 @@ sensitivityBezier::sensitivityBezier
),
//Bezier_(mesh, dict), // AJH Read locally?
Bezier_(mesh, mesh.lookupObject<IOdictionary>("optimisationDict")),
sens_(Bezier_.nBezier(), vector::zero),
flowSens_(Bezier_.nBezier(), vector::zero),
dSdbSens_(Bezier_.nBezier(), vector::zero),
dndbSens_(Bezier_.nBezier(), vector::zero),
dxdbDirectSens_(Bezier_.nBezier(), vector::zero),
sens_(Bezier_.nBezier(), Zero),
flowSens_(Bezier_.nBezier(), Zero),
dSdbSens_(Bezier_.nBezier(), Zero),
dndbSens_(Bezier_.nBezier(), Zero),
dxdbDirectSens_(Bezier_.nBezier(), Zero),
derivativesFolder_("optimisation"/type() + "Derivatives")
{
derivatives_ = scalarField(3*Bezier_.nBezier(), Zero);
// Create folder to store sensitivities
mkDir(derivativesFolder_);
};
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -90,7 +90,7 @@ sensitivityBezier::sensitivityBezier
void sensitivityBezier::assembleSensitivities()
{
// Assemble the sensitivity map
// Solves for the post-processing equations and adds their contribution to
// Solves for the post-processing equations and adds their contribution to
// the sensitivity map
surfaceSensitivity_.assembleSensitivities();
@ -182,12 +182,12 @@ void sensitivityBezier::assembleSensitivities()
void sensitivityBezier::clearSensitivities()
{
sens_ = vector::zero;
flowSens_ = vector::zero;
dSdbSens_ = vector::zero;
dndbSens_ = vector::zero;
dxdbDirectSens_ = vector::zero;
sens_ = Zero;
flowSens_ = Zero;
dSdbSens_ = Zero;
dndbSens_ = Zero;
dxdbDirectSens_ = Zero;
SIBase::clearSensitivities();
}

View File

@ -86,10 +86,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
sensitivityBezier(const sensitivityBezier&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const sensitivityBezier&) = delete;
@ -118,8 +118,8 @@ public:
// Member Functions
//- Assemble sensitivities
//- Assemble sensitivities
virtual void assembleSensitivities();
//- Zero sensitivity fields and their constituents

View File

@ -57,7 +57,7 @@ void sensitivityBezierFI::read()
meshMovementIters_ = dxdbDict.lookupOrDefault<label>("iters", 1000);
meshMovementResidualLimit_ =
dxdbDict.lookupOrDefault<scalar>("tolerance", 1.e-07);
// Read variables related to the adjoint eikonal solver
FIBase::read();
}
@ -166,7 +166,7 @@ sensitivityBezierFI::sensitivityBezierFI
derivatives_ = scalarField(3*Bezier_.nBezier(), Zero),
// Create folder to store sensitivities
mkDir(derivativesFolder_);
};
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -247,7 +247,7 @@ void sensitivityBezierFI::assembleSensitivities()
tmp<vectorField> tdxdbFace =
Bezier_.dxdbFace(patchI, iCP, idir);
const vectorField& dxdbFace = tdxdbFace();
dxdbDirectSens_[iDV] +=
dxdbDirectSens_[iDV] +=
gSum(dxdbDirectMult_()[patchI] & dxdbFace);
}

View File

@ -25,7 +25,6 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::incompressible::sensitivityBezierFI
@ -104,7 +103,7 @@ protected:
tmp<volVectorField> solveMeshMovementEqn
(
const label iCP,
const label iCP,
const label idir
);
@ -113,10 +112,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
sensitivityBezierFI(const sensitivityBezierFI&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const sensitivityBezierFI&) = delete;
@ -146,7 +145,7 @@ public:
// Member Functions
//- Assemble sensitivities
//- Assemble sensitivities
virtual void assembleSensitivities();
//- Zero sensitivity fields and their constituents

View File

@ -88,7 +88,7 @@ sensitivityMultiple::sensitivityMultiple
)
);
}
};
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

View File

@ -25,7 +25,6 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::incompressible::sensitivityMultiple
@ -71,10 +70,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
sensitivityMultiple(const sensitivityMultiple&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const sensitivityMultiple&) = delete;
@ -110,7 +109,7 @@ public:
//- Accumulate sensitivity integrands
virtual void accumulateIntegrand(const scalar dt);
//- Assemble sensitivities
//- Assemble sensitivities
virtual void assembleSensitivities();
//- Calculates sensitivities at wall surface points

View File

@ -80,8 +80,8 @@ void sensitivitySurface::addGeometricSens()
vectorField& patchdSdb = pointSensdSdb()[patchI];
vectorField& patchdndb = pointSensdndb()[patchI];
vectorField dSdbMultiplierTot(patch.size(), vector::zero);
vectorField dndbMultiplierTot(patch.size(), vector::zero);
vectorField dSdbMultiplierTot(patch.size(), Zero);
vectorField dndbMultiplierTot(patch.size(), Zero);
forAll(functions, funcI)
{
dSdbMultiplierTot +=
@ -116,7 +116,7 @@ void sensitivitySurface::addGeometricSens()
const face& faceI = faces[globalFaceIndex];
// Point coordinates. All indices in global numbering
pointField p(faceI.points(mesh_.points()));
tensorField p_d(faceI.size(), tensor::zero);
tensorField p_d(faceI.size(), Zero);
forAll(faceI, facePointI)
{
if (faceI[facePointI] == meshPoints[ppI])
@ -141,8 +141,8 @@ void sensitivitySurface::addGeometricSens()
}
// Do parallel communications to avoid wrong values at processor
// boundaries
vectorField dSdbGlobal(mesh_.nPoints(), vector::zero);
vectorField dndbGlobal(mesh_.nPoints(), vector::zero);
vectorField dSdbGlobal(mesh_.nPoints(), Zero);
vectorField dndbGlobal(mesh_.nPoints(), Zero);
for (const label patchI : sensitivityPatchIDs_)
{
const labelList& meshPoints =
@ -310,7 +310,7 @@ sensitivitySurface::sensitivitySurface
// Allocate appropriate space for the sensitivity field
computeDerivativesSize();
};
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -544,7 +544,7 @@ void sensitivitySurface::accumulateIntegrand(const scalar dt)
* nf;
}
vectorField gradStressTerm(patch.size(), vector::zero);
vectorField gradStressTerm(patch.size(), Zero);
if (includeGradStressTerm_)
{
// Terms corresponding to contributions from converting delta to
@ -563,7 +563,7 @@ void sensitivitySurface::accumulateIntegrand(const scalar dt)
}
// Adjoint pressure terms
vectorField pressureTerm(patch.size(), vector::zero);
vectorField pressureTerm(patch.size(), Zero);
if (includePressureTerm_)
{
pressureTerm =
@ -577,7 +577,7 @@ void sensitivitySurface::accumulateIntegrand(const scalar dt)
(objectiveManager_.getObjectiveFunctions());
// Term from objectives including x directly (e.g. moments)
vectorField dxdbMultiplierTot(pressureTerm.size(), vector::zero);
vectorField dxdbMultiplierTot(pressureTerm.size(), Zero);
if (includeObjective_)
{
forAll(functions, funcI)

View File

@ -25,7 +25,6 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::incompressible::sensitivitySurface
@ -119,10 +118,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
sensitivitySurface(const sensitivitySurface&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const sensitivitySurface&) = delete;
@ -164,7 +163,7 @@ public:
//- Accumulate sensitivity integrands
virtual void accumulateIntegrand(const scalar dt);
//- Assemble sensitivities
//- Assemble sensitivities
virtual void assembleSensitivities();
//- Zero sensitivity fields and their constituents

View File

@ -2,11 +2,12 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2007-2019 PCOpt/NTUA
| Copyright (C) 2013-2019 FOSS GP
Copyright (C) 2013-2019 FOSS GP
Copyright (C) 2007-2019 PCOpt/NTUA
Copyright (C) 2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -24,7 +25,6 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
namespace Foam
@ -69,3 +69,5 @@ inline void sensitivitySurface::setIncludeSurfaceArea
} // End namespace incompressible
} // End namespace Foam
// ************************************************************************* //

View File

@ -110,7 +110,7 @@ void sensitivitySurfacePoints::read()
void sensitivitySurfacePoints::finaliseFaceMultiplier()
{
// Solve extra equations if necessary
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
autoPtr<boundaryVectorField> distanceSensPtr(nullptr);
if (includeDistance_)
{
@ -157,7 +157,7 @@ void sensitivitySurfacePoints::finaliseFaceMultiplier()
}
// Add local face area
//~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~
// Sensitivities DO include locale surface area, to get
// the correct weighting from the contributions of various faces.
// Normalized at the end.
@ -216,7 +216,7 @@ void sensitivitySurfacePoints::finalisePointSensitivities()
// Point coordinates. All indices in global numbering
pointField p(faceI.points(mesh_.points()));
tensorField p_d(faceI.size(), tensor::zero);
tensorField p_d(faceI.size(), Zero);
forAll(faceI, facePointI)
{
if (faceI[facePointI] == meshPoints[ppI])
@ -378,7 +378,7 @@ sensitivitySurfacePoints::sensitivitySurfacePoints
// Derivatives for all (x,y,z) components of the displacement are kept
derivatives_ = scalarField(3*nTotalPoints, Zero);
};
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -492,7 +492,7 @@ void sensitivitySurfacePoints::accumulateIntegrand(const scalar dt)
<< " Calculating adjoint sensitivity. " << endl;
// The face-based part of the sensitivities, i.e. terms that multiply
// dxFace/dxPoint.
// dxFace/dxPoint.
for (const label patchI : sensitivityPatchIDs_)
{
const fvPatch& patch = mesh_.boundary()[patchI];
@ -517,7 +517,7 @@ void sensitivitySurfacePoints::accumulateIntegrand(const scalar dt)
* nf
);
vectorField gradStressTerm(patch.size(), vector::zero);
vectorField gradStressTerm(patch.size(), Zero);
if (includeGradStressTerm_)
{
// Terms corresponding to contributions from converting delta to
@ -561,7 +561,7 @@ void sensitivitySurfacePoints::accumulateIntegrand(const scalar dt)
}
// Adjoint pressure terms
vectorField pressureTerm(patch.size(), vector::zero);
vectorField pressureTerm(patch.size(), Zero);
if (includePressureTerm_)
{
pressureTerm =
@ -572,7 +572,7 @@ void sensitivitySurfacePoints::accumulateIntegrand(const scalar dt)
*nf;
}
vectorField dxdbMultiplierTot(patch.size(), vector::zero);
vectorField dxdbMultiplierTot(patch.size(), Zero);
if (includeObjective_)
{
// Term from objectives multiplying dxdb
@ -584,9 +584,9 @@ void sensitivitySurfacePoints::accumulateIntegrand(const scalar dt)
wei*functions[funcI].dxdbDirectMultiplier(patchI);
// Fill in multipliers of d(Sf)/db and d(nf)/db
dSfdbMult_()[patchI] +=
dSfdbMult_()[patchI] +=
wei*dt*functions[funcI].dSdbMultiplier(patchI);
dnfdbMult_()[patchI] +=
dnfdbMult_()[patchI] +=
wei*dt*functions[funcI].dndbMultiplier(patchI);
}
}
@ -620,13 +620,13 @@ void sensitivitySurfacePoints::assembleSensitivities()
// belonging to multiple patches or patch-processorPatch intersections.
// Keeping a mesh-wide field to allow easy reduction using syncTools.
// A bit expensive? Better way?
vectorField pointNormals(mesh_.nPoints(), vector::zero);
vectorField pointNormals(mesh_.nPoints(), Zero);
scalarField pointMagSf(mesh_.nPoints(), Zero);
constructGlobalPointNormalsAndAreas(pointNormals, pointMagSf);
// Do parallel communications to avoid wrong values at processor boundaries
// Global field for accumulation
vectorField pointSensGlobal(mesh_.nPoints(), vector::zero);
vectorField pointSensGlobal(mesh_.nPoints(), Zero);
for (const label patchI : sensitivityPatchIDs_)
{
const labelList& meshPoints = mesh_.boundaryMesh()[patchI].meshPoints();
@ -736,7 +736,7 @@ void sensitivitySurfacePoints::clearSensitivities()
meshMovementSolver_->reset();
}
// Reset local fields to zero
// Reset local fields to zero
wallFaceSens_() = vector::zero;
dSfdbMult_() = vector::zero;
dnfdbMult_() = vector::zero;

View File

@ -25,7 +25,6 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::incompressible::sensitivitySurfacePoints
@ -97,7 +96,7 @@ protected:
autoPtr<adjointMeshMovementSolver> meshMovementSolver_;
//- The face-based part of the sensitivities
// i.e. terms that multiply dxFace/dxPoint.
// i.e. terms that multiply dxFace/dxPoint.
// Sensitivities DO include locale surface area, to get
// the correct weighting from the contributions of various faces.
// Normalized at the end.
@ -114,12 +113,12 @@ protected:
void read();
//- Add terms related to post-processing PDEs
//- (i.e. adjoint Eikonal, adjoint mesh movement)
//- (i.e. adjoint Eikonal, adjoint mesh movement)
//- and add local face area
void finaliseFaceMultiplier();
//- Converts face sensitivities to point sensitivities and adds the
//- ones directly computed in points (i.e. dSf/db and dnf/db).
//- Converts face sensitivities to point sensitivities and adds the
//- ones directly computed in points (i.e. dSf/db and dnf/db).
void finalisePointSensitivities();
//- Construct globally correct point normals and point areas
@ -137,10 +136,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
sensitivitySurfacePoints(const sensitivitySurfacePoints&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const sensitivitySurfacePoints&) = delete;
@ -176,7 +175,7 @@ public:
//- Accumulate sensitivity integrands
virtual void accumulateIntegrand(const scalar dt);
//- Assemble sensitivities
//- Assemble sensitivities
virtual void assembleSensitivities();
//- Zero sensitivity fields and their constituents

View File

@ -62,8 +62,8 @@ void sensitivityVolBSplines::computeObjectiveContributions()
label nb = boxes[iNURB].getControlPoints().size();
for (label cpI = 0; cpI < nb; cpI++)
{
vector dSdbSensCP(vector::zero);
vector dndbSensCP(vector::zero);
vector dSdbSensCP(Zero);
vector dndbSensCP(Zero);
for (const label patchI : sensitivityPatchIDs_)
{
tensorField dSdb
@ -149,14 +149,14 @@ sensitivityVolBSplines::sensitivityVolBSplines
// No boundary field pointers need to be allocated
label nCPs = volBSplinesBase_.getTotalControlPointsNumber();
derivatives_ = scalarField(3*nCPs, Zero);
flowSens_ = vectorField(nCPs, vector::zero);
dSdbSens_ = vectorField(nCPs, vector::zero);
dndbSens_ = vectorField(nCPs, vector::zero);
dxdbDirectSens_ = vectorField(nCPs, vector::zero);
flowSens_ = vectorField(nCPs, Zero);
dSdbSens_ = vectorField(nCPs, Zero);
dndbSens_ = vectorField(nCPs, Zero);
dxdbDirectSens_ = vectorField(nCPs, Zero);
// Create folder to store sensitivities
mkDir(derivativesFolder_);
};
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -164,7 +164,7 @@ sensitivityVolBSplines::sensitivityVolBSplines
void sensitivityVolBSplines::assembleSensitivities()
{
// Assemble the sensitivity map
// Solves for the post-processing equations and adds their contribution to
// Solves for the post-processing equations and adds their contribution to
// the sensitivity map
surfaceSensitivity_.assembleSensitivities();

View File

@ -25,7 +25,6 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::incompressible::sensitivityVolBSplines
@ -92,10 +91,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
sensitivityVolBSplines(const sensitivityVolBSplines&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const sensitivityVolBSplines&) = delete;
@ -125,7 +124,7 @@ public:
// Member Functions
//- Assemble sensitivities
//- Assemble sensitivities
virtual void assembleSensitivities();
//- Zero sensitivity fields and their constituents

View File

@ -90,17 +90,17 @@ sensitivityVolBSplinesFI::sensitivityVolBSplinesFI
label nCPs = volBSplinesBase_.getTotalControlPointsNumber();
derivatives_ = scalarField(3*nCPs, Zero);
flowSens_ = vectorField(nCPs, vector::zero);
dSdbSens_ = vectorField(nCPs, vector::zero);
dndbSens_ = vectorField(nCPs, vector::zero);
dxdbDirectSens_ = vectorField(nCPs, vector::zero);
dVdbSens_ = vectorField(nCPs, vector::zero);
distanceSens_ = vectorField(nCPs, vector::zero);
optionsSens_ = vectorField(nCPs, vector::zero);
flowSens_ = vectorField(nCPs, Zero);
dSdbSens_ = vectorField(nCPs, Zero);
dndbSens_ = vectorField(nCPs, Zero);
dxdbDirectSens_ = vectorField(nCPs, Zero);
dVdbSens_ = vectorField(nCPs, Zero);
distanceSens_ = vectorField(nCPs, Zero);
optionsSens_ = vectorField(nCPs, Zero);
// Create folder to store sensitivities
mkDir(derivativesFolder_);
};
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -138,7 +138,7 @@ void sensitivityVolBSplinesFI::assembleSensitivities()
forAll(boxes, iNURB)
{
label nb = boxes[iNURB].getControlPoints().size();
vectorField boxSensitivities(nb, vector::zero);
vectorField boxSensitivities(nb, Zero);
vectorField dxdbSens = boxes[iNURB].computeControlPointSensitivities
(

View File

@ -25,7 +25,6 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::incompressible::sensitivityVolBSplinesFI
@ -96,10 +95,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
sensitivityVolBSplinesFI(const sensitivityVolBSplinesFI&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const sensitivityVolBSplinesFI&) = delete;
@ -129,7 +128,7 @@ public:
// Member Functions
//- Assemble sensitivities
//- Assemble sensitivities
virtual void assembleSensitivities();
//- Zero sensitivity fields and their constituents

View File

@ -81,10 +81,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
sensitivity(const sensitivity&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const sensitivity&) = delete;

View File

@ -156,7 +156,7 @@ Foam::shapeSensitivitiesBase::shapeSensitivitiesBase
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::labelHashSet&
const Foam::labelHashSet&
Foam::shapeSensitivitiesBase::sensitivityPatchIDs() const
{
return sensitivityPatchIDs_;
@ -226,7 +226,7 @@ void Foam::shapeSensitivitiesBase::setSuffix(const word& suffix)
}
Foam::tmp<Foam::volVectorField>
Foam::tmp<Foam::volVectorField>
Foam::shapeSensitivitiesBase::getWallFaceSensVec()
{
if (wallFaceSensVecPtr_.valid())
@ -257,7 +257,7 @@ Foam::shapeSensitivitiesBase::getWallFaceSensVec()
}
Foam::tmp<Foam::volScalarField>
Foam::tmp<Foam::volScalarField>
Foam::shapeSensitivitiesBase::getWallFaceSensNormal()
{
if (wallFaceSensNormalPtr_.valid())
@ -319,7 +319,7 @@ Foam::shapeSensitivitiesBase::getWallFaceSensNormalVec()
}
Foam::tmp<Foam::pointVectorField>
Foam::tmp<Foam::pointVectorField>
Foam::shapeSensitivitiesBase::getWallPointSensVec()
{
tmp<volVectorField> tWallFaceSensVec = getWallFaceSensVec();
@ -329,7 +329,7 @@ Foam::shapeSensitivitiesBase::getWallPointSensVec()
}
Foam::tmp<Foam::pointScalarField>
Foam::tmp<Foam::pointScalarField>
Foam::shapeSensitivitiesBase::getWallPointSensNormal()
{
tmp<volScalarField> tWallFaceSensNormal = getWallFaceSensNormal();

View File

@ -25,7 +25,6 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::incompressible::shapeSensitivitiesBase
@ -144,10 +143,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
shapeSensitivitiesBase(const shapeSensitivitiesBase&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const shapeSensitivitiesBase&) = delete;
@ -186,7 +185,7 @@ public:
// If valid, copies boundaryFields to volFields and writes them.
void write();
//- Set suffix
//- Set suffix
void setSuffix(const word& suffix);
//- Get wall face sensitivity vectors field

View File

@ -48,7 +48,7 @@ namespace Foam
Foam::ArmijoConditions::ArmijoConditions
(
const dictionary& dict,
const dictionary& dict,
const Time& time
)
:

View File

@ -25,7 +25,6 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::ArmijoConditions
@ -59,7 +58,7 @@ protected:
// Protected data
//- Multiplier of the merit function reduction computed using
//- Multiplier of the merit function reduction computed using
//- a first-order Taylor expansion
scalar c1_;
@ -68,10 +67,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
ArmijoConditions(const ArmijoConditions&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const ArmijoConditions&) = delete;

View File

@ -96,8 +96,8 @@ protected:
//- Maximum line search iterations
label maxIters_;
//- Whether to extrapolate the correction multiplier for
//- this optimisation cycle based on the previous ones.
//- Whether to extrapolate the correction multiplier for
//- this optimisation cycle based on the previous ones.
// Usefull for non-quasi Newton methods
bool extrapolateInitialStep_;
@ -106,7 +106,7 @@ protected:
// Protected Member Functions
//- Optional coeffs dict
const dictionary& coeffsDict();
@ -115,10 +115,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
lineSearch(const lineSearch&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const lineSearch&) = delete;

View File

@ -66,10 +66,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
bisection(const bisection&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const bisection&) = delete;

View File

@ -70,10 +70,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
quadratic(const quadratic&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const quadratic&) = delete;

View File

@ -62,7 +62,7 @@ protected:
// Protected Member Functions
//- Optional coeffs dict
const dictionary& coeffsDict();
@ -71,10 +71,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
stepUpdate(const stepUpdate&);
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const stepUpdate&);

View File

@ -44,7 +44,7 @@ namespace Foam
Foam::scalar Foam::optMeshMovement::getMaxAllowedDisplacement() const
{
if (maxAllowedDisplacement_.empty())
if (maxAllowedDisplacement_.empty())
{
FatalErrorInFunction
<< "maxAllowedDisplacement requested but not set" << nl
@ -106,7 +106,7 @@ Foam::autoPtr<Foam::optMeshMovement> Foam::optMeshMovement::New
{
FatalIOErrorInLookup
(
dict,
dict,
"type",
modelType,
*dictionaryConstructorTablePtr_
@ -138,7 +138,7 @@ void Foam::optMeshMovement::moveMesh()
}
Foam::autoPtr<Foam::displacementMethod>&
Foam::autoPtr<Foam::displacementMethod>&
Foam::optMeshMovement::returnDisplacementMethod()
{
return displMethodPtr_;

View File

@ -64,10 +64,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
optMeshMovement(const optMeshMovement&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const optMeshMovement&) = delete;
@ -87,11 +87,11 @@ protected:
//- Fall back points in case line-search is used
vectorField pointsInit_;
//- Mesh movement engine and interface for applying mesh movement
//- Mesh movement engine and interface for applying mesh movement
//- boundary conditions
autoPtr<displacementMethod> displMethodPtr_;
//- Whether to write the mesh quality metrics to files each time the
//- Whether to write the mesh quality metrics to files each time the
//- mesh is updated
bool writeMeshQualityMetrics_;
@ -184,7 +184,7 @@ public:
//- Whether maxAllowedDisplacement has been set
bool maxAllowedDisplacementSet() const;
//- Return active design variables.
//- Return active design variables.
// Implemented only for certain parametetisations
virtual labelList getActiveDesignVariables() const;
};

View File

@ -59,7 +59,7 @@ void Foam::optMeshMovementBezier::computeBoundaryMovement
const boolList& confineXmovement = Bezier_.confineXmovement();
const boolList& confineYmovement = Bezier_.confineYmovement();
const boolList& confineZmovement = Bezier_.confineZmovement();
vectorField actualMovement(nBezier, vector::zero);
vectorField actualMovement(nBezier, Zero);
for (label iCP = 0; iCP < nBezier; iCP++)
{
// Confine x movement
@ -112,7 +112,7 @@ Foam::optMeshMovementBezier::optMeshMovementBezier
pointMesh::New(mesh),
dimensionedVector(dimless, Zero)
),
cumulativeChange_(Bezier_.nBezier(), vector::zero)
cumulativeChange_(Bezier_.nBezier(), Zero)
{}
@ -131,7 +131,7 @@ void Foam::optMeshMovementBezier::moveMesh()
}
Foam::scalar
Foam::scalar
Foam::optMeshMovementBezier::computeEta(const scalarField& correction)
{
// Set unscaled correction

View File

@ -62,7 +62,7 @@ protected:
//- Parameterization based on NURBS curves
Bezier Bezier_;
//- Boundary movement due to change of NURBS control points
pointVectorField dx_;
@ -79,10 +79,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
optMeshMovementBezier(const optMeshMovementBezier&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const optMeshMovementBezier&) = delete;

View File

@ -65,7 +65,7 @@ void Foam::optMeshMovementNULL::moveMesh()
}
Foam::scalar
Foam::scalar
Foam::optMeshMovementNULL::computeEta(const scalarField& correction)
{
return scalar(0);

View File

@ -58,10 +58,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
optMeshMovementNULL(const optMeshMovementNULL&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const optMeshMovementNULL&) = delete;

View File

@ -53,7 +53,7 @@ Foam::vectorField Foam::optMeshMovementVolumetricBSplines::controlPointMovement
)
{
const label nControlPoints(correction.size()/3);
vectorField cpMovement(nControlPoints, vector::zero);
vectorField cpMovement(nControlPoints, Zero);
for (label iCP = 0; iCP < nControlPoints; ++iCP)
{

View File

@ -76,13 +76,13 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
optMeshMovementVolumetricBSplines
(
const optMeshMovementVolumetricBSplines&
) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const optMeshMovementVolumetricBSplines&) = delete;

View File

@ -37,7 +37,7 @@ namespace Foam
{
defineTypeNameAndDebug
(
optMeshMovementVolumetricBSplinesExternalMotionSolver,
optMeshMovementVolumetricBSplinesExternalMotionSolver,
0
);
addToRunTimeSelectionTable
@ -131,7 +131,7 @@ optMeshMovementVolumetricBSplinesExternalMotionSolver
pointMesh::New(mesh),
dimensionedVector(dimless, Zero)
),
cpMovement_(volBSplinesBase_.getTotalControlPointsNumber(), vector::zero)
cpMovement_(volBSplinesBase_.getTotalControlPointsNumber(), Zero)
{}
@ -146,7 +146,7 @@ void Foam::optMeshMovementVolumetricBSplinesExternalMotionSolver::moveMesh()
displMethodPtr_->setMotionField(dx_);
// Positions of control points have not changed since only the boundary dx
// has been computed.
// has been computed.
// Use correction to update them
volBSplinesBase_.moveControlPoints(cpMovement_);
@ -158,7 +158,7 @@ void Foam::optMeshMovementVolumetricBSplinesExternalMotionSolver::moveMesh()
}
Foam::scalar
Foam::scalar
Foam::optMeshMovementVolumetricBSplinesExternalMotionSolver::computeEta
(
const scalarField& correction
@ -180,7 +180,7 @@ Foam::optMeshMovementVolumetricBSplinesExternalMotionSolver::computeEta
Foam::labelList
Foam::optMeshMovementVolumetricBSplinesExternalMotionSolver::getActiveDesignVariables()
Foam::optMeshMovementVolumetricBSplinesExternalMotionSolver::getActiveDesignVariables()
const
{
return volBSplinesBase_.getActiveDesignVariables();

View File

@ -30,7 +30,7 @@ Class
Description
Converts NURBS volume control points update to actual mesh movement.
Internal points are moved based on a motionSolver other than
Internal points are moved based on a motionSolver other than
volumetricBSplinesExternalMotionSolver.
SourceFiles
@ -80,13 +80,13 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
optMeshMovementVolumetricBSplinesExternalMotionSolver
(
const optMeshMovementVolumetricBSplinesExternalMotionSolver&
) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=
(
const optMeshMovementVolumetricBSplinesExternalMotionSolver&

View File

@ -75,10 +75,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
optimisationManager(const optimisationManager&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const optimisationManager&) = delete;

View File

@ -65,10 +65,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
singleRun(const singleRun&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const singleRun&) = delete;

View File

@ -63,10 +63,10 @@ private:
//- Update optimisationType source for all primal and adjoint solvers
void updateOptTypeSource();
//- Disallow default bitwise copy construct
//- No copy construct
steadyOptimisation(const steadyOptimisation&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const steadyOptimisation&) = delete;

View File

@ -65,7 +65,7 @@ optimisationType::optimisationType
(
lineSearch::New
(
dict_.subDict("updateMethod").subOrEmptyDict("lineSearch"),
dict_.subDict("updateMethod").subOrEmptyDict("lineSearch"),
mesh.time()
)
)

View File

@ -76,10 +76,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
optimisationType(const optimisationType&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const optimisationType&) = delete;

View File

@ -129,9 +129,9 @@ shapeOptimisation::shapeOptimisation
);
// Sanity checks: at least one of eta or maxAllowedDisplacement must be set
if
if
(
!updateMethod_->initialEtaSet()
!updateMethod_->initialEtaSet()
&& !optMeshMovement_().maxAllowedDisplacementSet()
)
{

View File

@ -83,10 +83,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
shapeOptimisation(const shapeOptimisation&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const shapeOptimisation&) = delete;

View File

@ -59,11 +59,7 @@ void Foam::BFGS::allocateMatrices()
}
// Set previous HessianInv to be a diagonal matrix
SquareMatrix<scalar> temp(activeDesignVars_.size(), Zero);
forAll(activeDesignVars_, i)
{
temp[i][i] = 1.;
};
SquareMatrix<scalar> temp(activeDesignVars_.size(), I);
// Allocate correct size and content to HessianInv matrices
// has a max. capability of approximately 34000 variables.
@ -106,7 +102,7 @@ void Foam::BFGS::updateHessian()
HessianInv_ =
HessianInvOld_
+ (ys + globalSum(leftMult(y, HessianInvOld_)*y))/sqr(ys)*outerProd(s, s)
- (1./ys)*
- (scalar(1)/ys)*
(
outerProd(rightMult(HessianInvOld_, y), s)
+ outerProd(s, leftMult(y, HessianInvOld_))
@ -160,8 +156,8 @@ void Foam::BFGS::readFromDict()
optMethodIODict_.readEntry("eta", eta_);
label n = HessianInvOld_.n();
HessianInv_ = SquareMatrix<scalar>(n, scalar(0));
correction_ = scalarField(correctionOld_.size(), scalar(0));
HessianInv_ = SquareMatrix<scalar>(n, Zero);
correction_ = scalarField(correctionOld_.size(), Zero);
}
}
@ -177,7 +173,7 @@ Foam::BFGS::BFGS
updateMethod(mesh, dict),
etaHessian_
(
coeffsDict().lookupOrDefault<scalar>("etaHessian", 1.)
coeffsDict().lookupOrDefault<scalar>("etaHessian", 1)
),
nSteepestDescent_
(
@ -190,7 +186,7 @@ Foam::BFGS::BFGS
),
curvatureThreshold_
(
coeffsDict().lookupOrDefault<scalar>("curvatureThreshold", 1.e-10)
coeffsDict().lookupOrDefault<scalar>("curvatureThreshold", 1e-10)
),
// Construct null matrix since we dont know the dimension yet
HessianInv_(),
@ -206,13 +202,13 @@ Foam::BFGS::BFGS
{
// If not, all available design variables will be used. Number is not
// know at the moment
Info<< "\t Did not find explicit definition of active design variables. "
<< "Treating all available ones as active " << endl;
Info<< "\t Did not find explicit definition of active design variables."
<< " Treating all available ones as active" << endl;
}
// Read old hessian, correction and derivatives, if present
readFromDict();
};
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

View File

@ -60,10 +60,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
BFGS(const BFGS&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const BFGS&) = delete;

View File

@ -59,11 +59,7 @@ void Foam::DBFGS::allocateMatrices()
}
// Set previous Hessian to be a diagonal matrix
SquareMatrix<scalar> temp(activeDesignVars_.size(), Zero);
forAll(activeDesignVars_, i)
{
temp[i][i] = 1.;
};
SquareMatrix<scalar> temp(activeDesignVars_.size(), I);
// Allocate correct size and content to Hessian matrices
// has a max. capability of approximately 34000 variables.
@ -100,13 +96,13 @@ void Foam::DBFGS::updateHessian()
{
WarningInFunction
<< " y*s is below threshold. Using damped form" << endl;
theta = (1.-gamma_)*sBs/(sBs - ys);
theta = (scalar(1)-gamma_)*sBs/(sBs - ys);
}
DebugInfo
<< "Hessian curvature index " << ys << endl;
scalarField r(theta*y + (1.-theta)*rightMult(HessianOld_, s));
scalarField r(theta*y + (scalar(1)-theta)*rightMult(HessianOld_, s));
// Construct the inverse Hessian
Hessian_ =
@ -183,7 +179,7 @@ Foam::DBFGS::DBFGS
// Construct null matrix since we dont know the dimension yet
etaHessian_
(
coeffsDict().lookupOrDefault<scalar>("etaHessian", 1.)
coeffsDict().lookupOrDefault<scalar>("etaHessian", 1)
),
nSteepestDescent_
(
@ -196,7 +192,7 @@ Foam::DBFGS::DBFGS
),
curvatureThreshold_
(
coeffsDict().lookupOrDefault<scalar>("curvatureThreshold", 1.e-10)
coeffsDict().lookupOrDefault<scalar>("curvatureThreshold", 1e-10)
),
Hessian_(),
HessianOld_(),
@ -219,7 +215,7 @@ Foam::DBFGS::DBFGS
// read old hessian, correction and derivatives, if present
readFromDict();
};
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

View File

@ -112,10 +112,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
DBFGS(const DBFGS&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const DBFGS&) = delete;

View File

@ -62,8 +62,8 @@ void Foam::LBFGS::allocateMatrices()
label nVars(activeDesignVars_.size());
for (label i = 0; i < nPrevSteps_; i++)
{
y_.set(i, scalarField(nVars, scalar(0)));
s_.set(i, scalarField(nVars, scalar(0)));
y_.set(i, scalarField(nVars, Zero));
s_.set(i, scalarField(nVars, Zero));
}
}
@ -77,10 +77,10 @@ void Foam::LBFGS::pivotFields(PtrList<scalarField>& list, const scalarField& f)
newOrder[0] = nPrevSteps_ - 1;
for (label i = 1; i < nPrevSteps_; ++i)
{
newOrder[i] = i - 1;
newOrder[i] = i - 1;
}
list.reorder(newOrder);
// Fill in last element with the provided field
list[nPrevSteps_ - 1] = f;
}
@ -93,12 +93,12 @@ void Foam::LBFGS::pivotFields(PtrList<scalarField>& list, const scalarField& f)
void Foam::LBFGS::updateVectors()
{
// Update list of y. Can only be done here since objectiveDerivatives_
// Update list of y. Can only be done here since objectiveDerivatives_
// was not known at the end of the previous loop
scalarField yRecent
(objectiveDerivatives_ - derivativesOld_, activeDesignVars_);
pivotFields(y_, yRecent);
// Update list of s.
// Update list of s.
// correction_ holds the previous correction
scalarField sActive(correctionOld_, activeDesignVars_);
pivotFields(s_, sActive);
@ -129,11 +129,11 @@ void Foam::LBFGS::LBFGSUpdate()
for (label i = nLast; i > -1; --i)
{
r[i] = 1./globalSum(y_[i]*s_[i]);
a[i] = r[i]*globalSum(s_[i]*q);
a[i] = r[i]*globalSum(s_[i]*q);
q -= a[i]*y_[i];
}
scalar gamma =
scalar gamma =
globalSum(y_[nLast]*s_[nLast])/globalSum(y_[nLast]*y_[nLast]);
q *= gamma;
@ -183,7 +183,7 @@ void Foam::LBFGS::readFromDict()
optMethodIODict_.readEntry("eta", eta_);
optMethodIODict_.readEntry("correctionOld", correctionOld_);
correction_ = scalarField(correctionOld_.size(), scalar(0));
correction_ = scalarField(correctionOld_.size(), Zero);
}
}
@ -230,7 +230,7 @@ Foam::LBFGS::LBFGS
// Read old Hessian, correction and derivatives, if present
readFromDict();
};
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

View File

@ -25,12 +25,11 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::LBFGS
Description
The quasi-Newton Limited-memory BFGS formula. Keeps nPrevSteps_ of the
The quasi-Newton Limited-memory BFGS formula. Keeps nPrevSteps_ of the
y and s vectors and approximates the inverse areas through them.
Values of 3 < nPrevSteps_ < 20 are suggested.
@ -62,10 +61,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
LBFGS(const LBFGS&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const LBFGS&) = delete;
@ -103,7 +102,7 @@ protected:
//- Allocate matrices in the first optimisation cycle
void allocateMatrices();
//- Move pointers in PtrList to the left and replace last element with
//- Move pointers in PtrList to the left and replace last element with
//- given field
void pivotFields(PtrList<scalarField>& list, const scalarField& f);

Some files were not shown because too many files have changed in this diff Show More