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_)
|
||||
{
|
||||
|
||||
@ -107,27 +107,23 @@ Usage
|
||||
// Cartesian coordinate system specification when evaluating
|
||||
// force and moment coefficients, either of the below
|
||||
|
||||
// Option-1, i.e. the centre of rotation
|
||||
// by inherently using e3=(0 0 1) and e1=(1 0 0)
|
||||
CofR (0 0 0); // Centre of rotation
|
||||
dragDir (1 0 0);
|
||||
liftDir (0 0 1);
|
||||
// Define the centre of rotation
|
||||
// with implicit directions e1=(1 0 0) and e3=(0 0 1)
|
||||
CofR (0 0 0); // Centre of rotation
|
||||
|
||||
// Option-2, i.e. local coordinate system specification
|
||||
origin (0 0 0);
|
||||
e1 (1 0 0);
|
||||
e3 (0 0 1); // (e1, e2) or (e2, e3) or (e3, e1)
|
||||
// Define local coordinate system by origin + axes
|
||||
origin (0 0 0);
|
||||
e1 (1 0 0);
|
||||
e3 (0 0 1); // (e1, e2) or (e2, e3) or (e3, e1)
|
||||
|
||||
// Option-3, i.e. general coordinate system specification
|
||||
// General coordinate system specification (always cartesian)
|
||||
coordinateSystem
|
||||
{
|
||||
type cartesian;
|
||||
origin (0 0 0);
|
||||
origin (0 0 0);
|
||||
rotation
|
||||
{
|
||||
type axes;
|
||||
e3 (0 0 1);
|
||||
e1 (1 0 0); // (e1, e2) or (e2, e3) or (e3, e1)
|
||||
type ...;
|
||||
...
|
||||
}
|
||||
}
|
||||
|
||||
@ -221,6 +217,8 @@ Note
|
||||
yawAxis | Yaw axis | e3 | (0 0 1)
|
||||
\endtable
|
||||
|
||||
- If a \c coordinateSystem entry exists, it is taken in favour of \c CofR.
|
||||
|
||||
SourceFiles
|
||||
forceCoeffs.C
|
||||
|
||||
|
||||
@ -55,38 +55,34 @@ void Foam::functionObjects::forces::setCoordinateSystem
|
||||
const word& e1Name
|
||||
)
|
||||
{
|
||||
coordSysPtr_.clear();
|
||||
|
||||
point origin(Zero);
|
||||
if (dict.readIfPresent<point>("CofR", origin))
|
||||
|
||||
// With objectRegistry for access to indirect (global) coordinate systems
|
||||
coordSysPtr_ = coordinateSystem::NewIfPresent(obr_, dict);
|
||||
|
||||
if (coordSysPtr_)
|
||||
{
|
||||
const vector e3 = e3Name == word::null ?
|
||||
vector(0, 0, 1) : dict.get<vector>(e3Name);
|
||||
const vector e1 = e1Name == word::null ?
|
||||
vector(1, 0, 0) : dict.get<vector>(e1Name);
|
||||
// Report ...
|
||||
}
|
||||
else if (dict.readIfPresent("CofR", origin))
|
||||
{
|
||||
const vector e3
|
||||
(
|
||||
e3Name.empty() ? vector(0, 0, 1) : dict.get<vector>(e3Name)
|
||||
);
|
||||
const vector e1
|
||||
(
|
||||
e1Name.empty() ? vector(1, 0, 0) : dict.get<vector>(e1Name)
|
||||
);
|
||||
|
||||
coordSysPtr_.reset(new coordSystem::cartesian(origin, e3, e1));
|
||||
}
|
||||
else
|
||||
{
|
||||
// The 'coordinateSystem' sub-dictionary is optional,
|
||||
// but enforce use of a cartesian system if not found.
|
||||
// No 'coordinateSystem' or 'CofR'
|
||||
// - enforce a cartesian system
|
||||
|
||||
if (dict.found(coordinateSystem::typeName_()))
|
||||
{
|
||||
// New() for access to indirect (global) coordinate system
|
||||
coordSysPtr_ =
|
||||
coordinateSystem::New
|
||||
(
|
||||
obr_,
|
||||
dict,
|
||||
coordinateSystem::typeName_()
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
coordSysPtr_.reset(new coordSystem::cartesian(dict));
|
||||
}
|
||||
coordSysPtr_.reset(new coordSystem::cartesian(dict));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -90,19 +90,18 @@ Usage
|
||||
// Cartesian coordinate system specification when
|
||||
// evaluating forces and moments, either of the below
|
||||
|
||||
// Option-1, i.e. the centre of rotation
|
||||
// by inherently using e3=(0 0 1) and e1=(1 0 0)
|
||||
// Define the centre of rotation
|
||||
// with implicit directions e1=(1 0 0) and e3=(0 0 1)
|
||||
CofR (0 0 0); // Centre of rotation
|
||||
|
||||
// Option-2, i.e. local coordinate system specification
|
||||
// Define local coordinate system by origin + axes
|
||||
origin (0 0 0);
|
||||
e1 (1 0 0);
|
||||
e3 (0 0 1); // (e1, e2) or (e2, e3) or (e3, e1)
|
||||
|
||||
// Option-3, i.e. general coordinate system specification
|
||||
// General coordinate system specification (always cartesian)
|
||||
coordinateSystem
|
||||
{
|
||||
type cartesian;
|
||||
origin (0 0 0);
|
||||
rotation
|
||||
{
|
||||
@ -137,11 +136,11 @@ Usage
|
||||
porosity | Flag to include porosity contributions | bool | no | false
|
||||
writeFields | Flag to write force and moment fields | bool | no | false
|
||||
useNamePrefix | Flag to include prefix for field names | bool | no | false
|
||||
coordinateSystem | Coordinate system specifier | dictionary | cndtnl | -
|
||||
CofR | Centre of rotation | vector | cndtnl | -
|
||||
origin | Origin of coordinate system | vector | cndtnl | -
|
||||
e3 | e3 coordinate axis | vector | cndtnl | -
|
||||
e1 | e1 coordinate axis | vector | cndtnl | -
|
||||
coordinateSystem | Coordinate system specifier | dictionary | cndtnl | -
|
||||
fD | Name of force density field | word | cndtnl | -
|
||||
p | Name of pressure field | word | cndtnl | p
|
||||
U | Name of velocity field | word | cndtnl | U
|
||||
@ -161,6 +160,7 @@ Note
|
||||
value corresponding to the constant freestream density.
|
||||
- \c writeControl and \c writeInterval entries of function
|
||||
object do control when to output force and moment files and fields.
|
||||
- If a \c coordinateSystem entry exists, it is taken in favour of \c CofR.
|
||||
|
||||
SourceFiles
|
||||
forces.C
|
||||
|
||||
Reference in New Issue
Block a user