Files
OpenFOAM-12/applications/test/nullObject/Test-nullObject.C
Henry Weller 30eb5e28e6 fvMesh: Generalised the handing of old-time fields during mesh motion and topology change
Topology change occurs before the time-increment and hence the oldest time
field (old-time in the case of 1st order time schemes, old-old-time in the case
of 2nd-order time schemes) is not actually needed as it is replaced by the
current time-field after time-increment so there is no purpose to mapping this
field.  However, it is necessary to keep track of the existence of the
oldest-time field to ensure the correct number of old-time fields are cached for
the time-scheme.  This development allows fvMesh to delete the redundant
oldest-time fields in such a manner that GeometricField can reinstate them
correctly after time-increment which is more efficient and more reliable than
attempting to map them and done previously.

Additionally fvMesh movement, which occurs after time-increment, now ensure all
old-time fields are up-to-date before NCC stitcher mapping so that both fields
and their old-time values are mapped consistently.  This removes the need for
old-time field caching calls in MapGeometricFields, fvMeshAdder and
fvMeshStitcher, thus simplifying the code and improving maintainability.
2022-10-10 14:43:07 +01:00

95 lines
1.7 KiB
C++

#include "nullObject.H"
#include "IOstreams.H"
using namespace Foam;
class SimpleClass
{
public:
//- Null constructor
SimpleClass()
{}
};
int main()
{
// Test pointer and reference to a class
SimpleClass* ptrToClass = new SimpleClass;
SimpleClass& refToClass(*ptrToClass);
if (notNull(ptrToClass))
{
Info<< "Pass: ptrToClass is not null" << endl;
}
else
{
Info<< "FAIL: refToClass is null" << endl;
}
if (notNull(refToClass))
{
Info<< "Pass: refToClass is not null" << endl;
}
else
{
Info<< "FAIL: refToClass is null" << endl;
}
// Test const pointer and const reference to the nullObject
const SimpleClass* constPtrToNull(NullObjectConstPtr<SimpleClass>());
const SimpleClass& constRefToNull(NullObjectRef<SimpleClass>());
if (isNull(constPtrToNull))
{
Info<< "Pass: constPtrToNull is null" << endl;
}
else
{
Info<< "FAIL: constPtrToNull is not null" << endl;
}
if (isNull(constRefToNull))
{
Info<< "Pass: constRefToNull is null" << endl;
}
else
{
Info<< "FAIL: constRefToNull is not null" << endl;
}
// Test pointer and reference to the nullObject
SimpleClass* ptrToNull(NullObjectPtr<SimpleClass>());
SimpleClass& refToNull(*ptrToNull);
if (isNull(ptrToNull))
{
Info<< "Pass: ptrToNull is null" << endl;
}
else
{
Info<< "FAIL: ptrToNull is not null" << endl;
}
if (isNull(refToNull))
{
Info<< "Pass: refToNull is null" << endl;
}
else
{
Info<< "FAIL: refToNull is not null" << endl;
}
// Clean-up
delete ptrToClass;
return 0;
}