mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
DEFEATURE: remove general objects storage from exprResult
- unused, generally fragile.
This commit is contained in:
@ -213,8 +213,7 @@ Foam::expressions::exprResult::exprResult()
|
||||
needsReset_(false),
|
||||
size_(0),
|
||||
single_(),
|
||||
fieldPtr_(nullptr),
|
||||
objectPtr_(nullptr)
|
||||
fieldPtr_(nullptr)
|
||||
{
|
||||
clear();
|
||||
}
|
||||
@ -251,8 +250,7 @@ Foam::expressions::exprResult::exprResult
|
||||
needsReset_(false),
|
||||
size_(0),
|
||||
single_(),
|
||||
fieldPtr_(nullptr),
|
||||
objectPtr_(nullptr)
|
||||
fieldPtr_(nullptr)
|
||||
{
|
||||
DebugInFunction << nl;
|
||||
|
||||
@ -399,7 +397,6 @@ void Foam::expressions::exprResult::clear()
|
||||
{
|
||||
uglyDelete();
|
||||
valType_.clear();
|
||||
objectPtr_.reset(nullptr);
|
||||
size_ = 0;
|
||||
}
|
||||
|
||||
@ -533,12 +530,6 @@ void Foam::expressions::exprResult::operator=(const exprResult& rhs)
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
else if (objectPtr_)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Assignment with general content not possible" << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -561,8 +552,6 @@ void Foam::expressions::exprResult::operator=(exprResult&& rhs)
|
||||
single_ = rhs.single_;
|
||||
fieldPtr_ = rhs.fieldPtr_;
|
||||
|
||||
objectPtr_.reset(rhs.objectPtr_.release());
|
||||
|
||||
rhs.fieldPtr_ = nullptr; // Took ownership of field pointer
|
||||
rhs.clear();
|
||||
}
|
||||
@ -707,13 +696,6 @@ Foam::expressions::exprResult::operator*=
|
||||
const scalar& b
|
||||
)
|
||||
{
|
||||
if (isObject())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Can only multiply Field-type exprResult. Not "
|
||||
<< valType_ << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
if (!fieldPtr_)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
@ -748,13 +730,6 @@ Foam::expressions::exprResult::operator+=
|
||||
const exprResult& b
|
||||
)
|
||||
{
|
||||
if (isObject())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Can only add Field-type, not type: "
|
||||
<< valType_ << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
if (!fieldPtr_)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
|
||||
@ -149,9 +149,6 @@ class exprResult
|
||||
//- Allocated plain field (eg, scalarField)
|
||||
void *fieldPtr_;
|
||||
|
||||
//- Alternative storage for non-plain fields (eg, volScalarField)
|
||||
autoPtr<regIOobject> objectPtr_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
@ -251,9 +248,6 @@ class exprResult
|
||||
template<class Type>
|
||||
inline void setSingleValueImpl(const Type& val);
|
||||
|
||||
template<class Type>
|
||||
inline void setObjectResultImpl(Type* ptr);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
@ -408,10 +402,7 @@ public:
|
||||
inline Type getValue() const;
|
||||
|
||||
//- True if valueType is a bool
|
||||
inline bool isBool() const;
|
||||
|
||||
//- True if the object pointer is being used
|
||||
inline bool isObject() const;
|
||||
inline bool is_bool() const;
|
||||
|
||||
//- The field or object size
|
||||
inline label size() const;
|
||||
@ -461,10 +452,6 @@ public:
|
||||
template<class Type>
|
||||
inline void setSingleValue(const Type& val);
|
||||
|
||||
//- Set result object
|
||||
template<class Type>
|
||||
inline void setObjectResult(autoPtr<Type>&& obj);
|
||||
|
||||
|
||||
// Access/Get results
|
||||
|
||||
@ -478,7 +465,7 @@ public:
|
||||
|
||||
//- Return non-const reference to the field, casting away constness
|
||||
template<class Type>
|
||||
inline Field<Type>& getRef() const;
|
||||
inline Field<Type>& constCast() const;
|
||||
|
||||
//- Return tmp field of the contents,
|
||||
//- optionally keeping a copy in cache
|
||||
|
||||
@ -213,15 +213,6 @@ Foam::expressions::exprResult::exprResult(Field<Type>&& fld)
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::expressions::exprResult::exprResult(autoPtr<Type>&& obj)
|
||||
:
|
||||
exprResult()
|
||||
{
|
||||
setObjectResult(std::move(obj));
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::expressions::exprResult::exprResult(const dimensioned<Type>& dt)
|
||||
:
|
||||
@ -281,18 +272,12 @@ inline Type Foam::expressions::exprResult::getValue() const
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::expressions::exprResult::isBool() const
|
||||
inline bool Foam::expressions::exprResult::is_bool() const
|
||||
{
|
||||
return valType_ == pTraits<bool>::typeName;
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::expressions::exprResult::isObject() const
|
||||
{
|
||||
return bool(objectPtr_);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::label Foam::expressions::exprResult::size() const
|
||||
{
|
||||
return size_;
|
||||
@ -369,30 +354,6 @@ void Foam::expressions::exprResult::setResultImpl
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::expressions::exprResult::setObjectResult(autoPtr<Type>&& obj)
|
||||
{
|
||||
target().setObjectResultImpl(obj.ptr()); // release()
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void Foam::expressions::exprResult::setObjectResultImpl(T* ptr)
|
||||
{
|
||||
clear();
|
||||
|
||||
isUniform_ = false;
|
||||
isPointData_ = false;
|
||||
|
||||
if (ptr != nullptr)
|
||||
{
|
||||
size_ = ptr->size();
|
||||
valType_ = ptr->typeName;
|
||||
objectPtr_.reset(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::expressions::exprResult::setResult
|
||||
(
|
||||
@ -756,52 +717,12 @@ Foam::expressions::exprResult::ref()
|
||||
|
||||
template<class Type>
|
||||
inline Foam::Field<Type>&
|
||||
Foam::expressions::exprResult::getRef() const
|
||||
Foam::expressions::exprResult::constCast() const
|
||||
{
|
||||
return const_cast<Field<Type>&>(this->cref<Type>());
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline Foam::tmp<Type>
|
||||
Foam::expressions::exprResult::getObjectResult(bool cacheCopy)
|
||||
{
|
||||
DebugInFunction << nl;
|
||||
|
||||
if (!isType<Type>())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "The expected return type " << pTraits<Type>::typeName
|
||||
<< " is different from the stored result type "
|
||||
<< valType_ << nl << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
Type* ptr = dynamic_cast<Type*>(objectPtr_.get());
|
||||
|
||||
if (!ptr)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Cannot cast object pointer to " << pTraits<Type>::typeName
|
||||
<< nl << nl;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (cacheCopy)
|
||||
{
|
||||
// Return duplicated content
|
||||
return tmp<Type>::New(*ptr);
|
||||
}
|
||||
|
||||
objectPtr_.release(); // Take ownership in ptr
|
||||
|
||||
clear();
|
||||
|
||||
return tmp<Type>(ptr);
|
||||
}
|
||||
|
||||
|
||||
template<template<class> class BinaryOp, class Type>
|
||||
inline Type Foam::expressions::exprResult::getReduced
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user