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:
@ -68,22 +68,21 @@ Usage
|
||||
|
||||
// Conditional optional entries
|
||||
|
||||
// Option-1, i.e. general coordinate system specification
|
||||
// General coordinate system specification
|
||||
coordinateSystem
|
||||
{
|
||||
type cartesian;
|
||||
origin (0 0 0);
|
||||
type cartesian;
|
||||
origin (0 0 0);
|
||||
rotation
|
||||
{
|
||||
type axes;
|
||||
e3 (0 0 1);
|
||||
e1 (1 0 0); // (e1, e2) or (e2, e3) or (e3, e1)
|
||||
type ...
|
||||
...
|
||||
}
|
||||
}
|
||||
|
||||
// Option-2, i.e. the centre of rotation
|
||||
// by inherently using e3=(0 0 1) and e1=(1 0 0)
|
||||
CofR (0 0 0);
|
||||
// Define the centre of rotation
|
||||
// with implicit directions e1=(1 0 0) and e3=(0 0 1)
|
||||
CofR (0 0 0);
|
||||
|
||||
// Inherited entries
|
||||
...
|
||||
@ -102,7 +101,7 @@ Usage
|
||||
decomposePatchValues | Flag to output normal and tangential <!--
|
||||
--> components | bool | no | false
|
||||
cellZones | Names of operand cell zones | wordRes | no | -
|
||||
coordinateSystem | Coordinate system specifier | dict | cndtnl | -
|
||||
coordinateSystem | Coordinate system specifier | dict | cndtnl | -
|
||||
CofR | Centre of rotation | vector | cndtnl | -
|
||||
\endtable
|
||||
|
||||
@ -117,6 +116,9 @@ Usage
|
||||
- \link writeFile.H \endlink
|
||||
- \link coordinateSystem.H \endlink
|
||||
|
||||
Note
|
||||
- If a \c coordinateSystem entry exists, it is taken in favour of \c CofR.
|
||||
|
||||
SourceFiles
|
||||
binField.C
|
||||
|
||||
|
||||
@ -77,40 +77,27 @@ void Foam::binModel::setCoordinateSystem
|
||||
const word& e1Name
|
||||
)
|
||||
{
|
||||
coordSysPtr_.clear();
|
||||
point origin(Zero);
|
||||
|
||||
if (dict.found(coordinateSystem::typeName_()))
|
||||
coordSysPtr_ = coordinateSystem::NewIfPresent(dict);
|
||||
|
||||
if (coordSysPtr_)
|
||||
{
|
||||
coordSysPtr_ =
|
||||
coordinateSystem::New
|
||||
(
|
||||
mesh_,
|
||||
dict,
|
||||
coordinateSystem::typeName_()
|
||||
);
|
||||
|
||||
Info<< "Setting co-ordinate system:" << nl
|
||||
<< " - type : " << coordSysPtr_->name() << nl
|
||||
<< " - origin : " << coordSysPtr_->origin() << nl
|
||||
<< " - e3 : " << coordSysPtr_->e3() << nl
|
||||
<< " - e1 : " << coordSysPtr_->e1() << endl;
|
||||
}
|
||||
else if (dict.found("CofR"))
|
||||
else if (dict.readIfPresent("CofR", origin))
|
||||
{
|
||||
const vector origin(dict.get<point>("CofR"));
|
||||
|
||||
const vector e3
|
||||
(
|
||||
e3Name == word::null
|
||||
? vector(0, 0, 1)
|
||||
: dict.get<vector>(e3Name)
|
||||
e3Name.empty() ? vector(0, 0, 1) : dict.get<vector>(e3Name)
|
||||
);
|
||||
|
||||
const vector e1
|
||||
(
|
||||
e1Name == word::null
|
||||
? vector(1, 0, 0)
|
||||
: dict.get<vector>(e1Name)
|
||||
e1Name.empty() ? vector(1, 0, 0) : dict.get<vector>(e1Name)
|
||||
);
|
||||
|
||||
coordSysPtr_.reset(new coordSystem::cartesian(origin, e3, e1));
|
||||
|
||||
@ -60,7 +60,7 @@ fieldCoordinateSystemTransform
|
||||
fieldSet_(mesh_),
|
||||
csysPtr_
|
||||
(
|
||||
coordinateSystem::New(mesh_, dict, coordinateSystem::typeName_())
|
||||
coordinateSystem::New(mesh_, dict, coordinateSystem::typeName)
|
||||
)
|
||||
{
|
||||
read(dict);
|
||||
|
||||
@ -396,20 +396,13 @@ bool Foam::functionObjects::regionSizeDistribution::read(const dictionary& dict)
|
||||
dict.subOrEmptyDict("formatOptions").optionalSubDict(setFormat)
|
||||
);
|
||||
|
||||
if (dict.found(coordinateSystem::typeName_()))
|
||||
{
|
||||
csysPtr_.reset
|
||||
(
|
||||
coordinateSystem::New(obr_, dict, coordinateSystem::typeName_())
|
||||
);
|
||||
csysPtr_ = coordinateSystem::NewIfPresent(obr_, dict);
|
||||
|
||||
if (csysPtr_)
|
||||
{
|
||||
Info<< "Transforming all vectorFields with coordinate system "
|
||||
<< csysPtr_->name() << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
csysPtr_.clear();
|
||||
}
|
||||
|
||||
if (isoPlanes_)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user