/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see .
\*---------------------------------------------------------------------------*/
#include "PrimitiveOldTimePatch.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template
Foam::PrimitiveOldTimePatch::PrimitiveOldTimePatch
(
const FaceList& faces,
const Field& points,
const Field& points0
)
:
PrimitivePatch(faces, points),
points0Ptr_(isRef ? nullptr : new Field(points0)),
points0_(isRef ? points0 : points0Ptr_()),
patch0Ptr_(new patch0Type(faces, points0_)),
localPoints0Ptr_(nullptr)
{}
template
Foam::PrimitiveOldTimePatch::PrimitiveOldTimePatch
(
const PrimitivePatch& patch,
const Field& points0
)
:
PrimitivePatch(patch),
points0_(points0),
patch0Ptr_(new patch0Type(patch, points0_)),
localPoints0Ptr_(nullptr)
{}
template
Foam::PrimitiveOldTimePatch::PrimitiveOldTimePatch
(
const FaceList& faces,
const Field& points
)
:
PrimitivePatch(faces, points),
points0Ptr_(nullptr),
points0_(NullObjectRef>()),
patch0Ptr_(nullptr),
localPoints0Ptr_(nullptr)
{}
template
Foam::PrimitiveOldTimePatch::PrimitiveOldTimePatch
(
const PrimitivePatch& patch
)
:
PrimitivePatch(patch),
points0_(NullObjectRef>()),
patch0Ptr_(nullptr),
localPoints0Ptr_(nullptr)
{}
template
Foam::PrimitiveOldTimePatch::PrimitiveOldTimePatch
(
const PrimitiveOldTimePatch& patch
)
:
PrimitivePatch(patch),
points0_(patch.points0_),
patch0Ptr_(patch.patch0Ptr_, false),
localPoints0Ptr_(nullptr)
{}
template
Foam::PrimitiveOldTimePatch::PrimitiveOldTimePatch
(
PrimitiveOldTimePatch&& patch
)
:
PrimitivePatch(move(patch)),
points0_(move(patch.points0_)),
patch0Ptr_(patch.patch0Ptr_),
localPoints0Ptr_(nullptr)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template
Foam::PrimitiveOldTimePatch::~PrimitiveOldTimePatch()
{
clearOut();
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
template
const Foam::Field
<
typename Foam::PrimitiveOldTimePatch::PointType
>& Foam::PrimitiveOldTimePatch::localPoints0() const
{
// !!! Cannot just call patch0Ptr_->localPoints() as this would generate
// topology in patch0Ptr_() that is already available in the base class.
// For now, we just duplicate the implementation in PrimitivePatch.
if (!localPoints0Ptr_)
{
const labelList& meshPts = this->meshPoints();
localPoints0Ptr_ = new Field(meshPts.size());
Field& locPts = *localPoints0Ptr_;
forAll(meshPts, pointi)
{
locPts[pointi] = points0_[meshPts[pointi]];
}
}
// But, it would be preferable to add a method to PrimitivePatch which
// calculates the local points given a list of points different to those
// that are stored. Then the implementations could be shared and we could
// do this:
/*
if (!localPoints0Ptr_)
{
localPoints0Ptr_ = this->calcLocalPoints(points0_);
}
*/
return *localPoints0Ptr_;
}
template
const Foam::Field
<
typename Foam::PrimitiveOldTimePatch::PointType
>& Foam::PrimitiveOldTimePatch::faceCentres0() const
{
return patch0Ptr_->faceCentres();
}
template
const Foam::Field
<
typename Foam::PrimitiveOldTimePatch::PointType
>& Foam::PrimitiveOldTimePatch::faceAreas0() const
{
return patch0Ptr_->faceAreas();
}
template
const Foam::Field
<
typename Foam::PrimitiveOldTimePatch::PointType
>& Foam::PrimitiveOldTimePatch::faceNormals0() const
{
return patch0Ptr_->faceNormals();
}
template
const Foam::Field
<
typename Foam::PrimitiveOldTimePatch::PointType
>& Foam::PrimitiveOldTimePatch::pointNormals0() const
{
// !!! See comments in localPoints0. This isn't needed for now.
NotImplemented;
return NullObjectRef>();
}
template
void Foam::PrimitiveOldTimePatch::clearOut()
{
PrimitivePatch::clearOut();
if (has0()) patch0Ptr_->clearOut();
deleteDemandDrivenData(localPoints0Ptr_);
}
template
void Foam::PrimitiveOldTimePatch::clearGeom()
{
PrimitivePatch::clearGeom();
if (has0()) patch0Ptr_->clearGeom();
deleteDemandDrivenData(localPoints0Ptr_);
}
template
void Foam::PrimitiveOldTimePatch::movePoints0
(
const Field&
)
{
if (has0()) patch0Ptr_->clearGeom();
}
// ************************************************************************* //