mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: improved handling of coordinateSystems
- in continuation of #2565 (rotationCentre for surface output formats) it is helpful to also support READ_IF_PRESENT behaviour for the 'origin' keyword. This can be safely used wherever the coordinate system definition is embedded within a sub-dictionary scope. Eg, dict1 { coordinateSystem { origin (0 0 0); // now optional here rotation ...; } } but remains mandatory if constructed without a sub-dict: dict2 { origin (0 0 0); // still mandatory e1 (1 0 0); e3 (0 0 1); } With this change, the "transform" sub-dictionary can written more naturally: formatOptions { vtk { scale 1000; // m -> mm transform { rotationCentre (1 0 0); rotation axisAngle; axis (0 0 1); angle -45; } } } ENH: simplify handling of "coordinateSystem" dictionary lookups - coordinateSystems::NewIfPresent method for optional entries: coordSysPtr_ = coordinateSystem::NewIfPresent(mesh, dict); Instead of if (dict.found(coordinateSystem::typeName, keyType::LITERAL)) { coordSysPtr_ = coordinateSystem::New ( mesh_, dict, coordinateSystem::typeName ); } else { coordSysPtr_.reset(); } ENH: more consistent handling of priorities for binModels, forces (#2598) - if the dictionaries are overspecified, give a 'coordinateSystem' entry a higher prioriy than the 'CofR' shortcuts. Was previously slightly inconsistent between the different models.
This commit is contained in:
@ -64,27 +64,24 @@ Foam::plane Foam::sampledCuttingPlane::definePlane
|
||||
const dictionary* dictptr = nullptr;
|
||||
coordSystem::cartesian cs;
|
||||
|
||||
if (dict.found(coordinateSystem::typeName_(), keyType::LITERAL))
|
||||
// Create with registry to allow lookup from globally defined
|
||||
// coordinate systems.
|
||||
|
||||
auto csPtr = coordinateSystem::NewIfPresent(mesh, *dictptr);
|
||||
|
||||
if (csPtr)
|
||||
{
|
||||
// Create with registry to allow lookup from globally defined
|
||||
// coordinate systems?
|
||||
|
||||
auto csPtr =
|
||||
coordinateSystem::New(mesh, dict, coordinateSystem::typeName_());
|
||||
|
||||
if (csPtr)
|
||||
{
|
||||
adjust = true;
|
||||
cs = csPtr();
|
||||
}
|
||||
adjust = true;
|
||||
cs = csPtr();
|
||||
}
|
||||
else if
|
||||
(
|
||||
(dictptr = dict.findDict("transform", keyType::LITERAL)) != nullptr
|
||||
)
|
||||
{
|
||||
// 'origin' (READ_IF_PRESENT)
|
||||
adjust = true;
|
||||
cs = coordSystem::cartesian(*dictptr);
|
||||
cs = coordSystem::cartesian(*dictptr, IOobjectOption::READ_IF_PRESENT);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -62,27 +62,24 @@ Foam::plane Foam::sampledPlane::definePlane
|
||||
const dictionary* dictptr = nullptr;
|
||||
coordSystem::cartesian cs;
|
||||
|
||||
if (dict.found(coordinateSystem::typeName_(), keyType::LITERAL))
|
||||
// Create with registry to allow lookup from globally defined
|
||||
// coordinate systems.
|
||||
|
||||
auto csPtr = coordinateSystem::NewIfPresent(mesh, dict);
|
||||
|
||||
if (csPtr)
|
||||
{
|
||||
// Create with registry to allow lookup from globally defined
|
||||
// coordinate systems?
|
||||
|
||||
auto csPtr =
|
||||
coordinateSystem::New(mesh, dict, coordinateSystem::typeName_());
|
||||
|
||||
if (csPtr)
|
||||
{
|
||||
adjust = true;
|
||||
cs = csPtr();
|
||||
}
|
||||
adjust = true;
|
||||
cs = csPtr();
|
||||
}
|
||||
else if
|
||||
(
|
||||
(dictptr = dict.findDict("transform", keyType::LITERAL)) != nullptr
|
||||
)
|
||||
{
|
||||
// 'origin' (READ_IF_PRESENT)
|
||||
adjust = true;
|
||||
cs = coordSystem::cartesian(*dictptr);
|
||||
cs = coordSystem::cartesian(*dictptr, IOobjectOption::READ_IF_PRESENT);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user