Definition of a local coordinate system in function 'forces' causes crash of the calculation
Here after is the definition of a forces function with the declaration of a local coordinate system instead of CofR, like described here: https://www.openfoam.com/documentation/cpp-guide/html/classFoam_1_1functionObjects_1_1forces.html
{ type forces;
functionObjectLibs ( "libforces.so" );
writeControl timeStep;
writeInterval 1;
log yes;
patches ( "blade.*" );
pName p;
UName U;
rho rhoInf; // Indicates incompressible
log true;
rhoInf 1; // Redundant for incompressible
coordinateSystem
{
type cartesian;
origin (1.524 0 0);
coordinateRotation
{
type axesRotation;
e1 (-0.98480498 -0.17364769 0.00237365);
e2 (-1.73648178e-01 9.84807753e-01 0.0);
}
}
}
It causes a crash of the calculation with the error here below:
--> FOAM FATAL IO ERROR: keyword origin is undefined in dictionary "/home/etudes/etudes_NP/ETR180036_NavalGroup_GrandChallengeIrene/01_helice_E779A/E779A_cyclic_MovingMesh/system/controlDict.functions.forces"
From function const Foam::entry& Foam::dictionary::lookupEntry(const Foam::word&, bool, bool) const
in file db/dictionary/dictionary.C at line 277.
Looks like a bug.
No child items are currently assigned. Use child items to break down this issue into smaller parts.
Link issues together to show that they're related. Learn more.
Activity
- Mark OLESEN assigned to @mark
assigned to @mark
- Maintainer
Yes - it's a bug. I'll make the fix.
- Maintainer
In the meantime, you can also manage without the
coordinateSystem
sub-dictionary since you don't need the type (cartesian by default). Eg,patches ( "blade.*" ); pName p; UName U; rho rhoInf; // Indicates incompressible log true; rhoInf 1; // Redundant for incompressible origin (1.524 0 0); coordinateRotation { type axesRotation; e1 (-0.98480498 -0.17364769 0.00237365); e2 (-1.73648178e-01 9.84807753e-01 0.0); }
I personally prefer the style of encapsulated version that you originally used, however.
- Mark OLESEN closed via commit 19a01a62bb7d4b7da93d0b52a5280d46f7ffc68a
closed via commit 19a01a62bb7d4b7da93d0b52a5280d46f7ffc68a
- Mark OLESEN mentioned in commit 41525f25655568b5e0c3c65599c4743ed62a671d
mentioned in commit 41525f25655568b5e0c3c65599c4743ed62a671d
- Mark OLESEN mentioned in commit 6d78d49e456be049cd8ceaa7825b4008d7a3aa02
mentioned in commit 6d78d49e456be049cd8ceaa7825b4008d7a3aa02
- Maintainer
This regression came into OpenFOAM-2.3, so I've patched the last three versions (1612, 1706, 1712).
- Author Maintainer
Great! Thank you very much.
I have a subsidiary question: Is it possible to make this coordinate system time-dependent? For example, that it evolves with the rotation speed of a rotor?
By Poirier on 2018-06-18T08:12:51 (imported from GitLab project)
- Maintainer
At the moment the
CofR
is defined entirely via the dictionary file - either directly or with thecoordinateSystem
entry. This provides no means of having time-dependent changes in the origin other than physically changing the file and forcing an update, which would be a really horrible solution.To have a time-dependent coordinate, we'd need to expose write access to the coordinateSystem, which is easily doable. But how/where would you want to change this value? And how would we resolve inconsistencies in the values? Eg, You specify
coordinateSystem
in the dictionary. During the calculation you modify its location, but then (for some reason) you have a re-read from the dictionary. The coordinateSystem would be that from the dictionary and not what you last specified yourself?/mark
- Author Maintainer
Well, the solution you propose, such that:
origin (1.524 0 0); coordinateRotation { type axesRotation; e1 (-0.98480498 -0.17364769 0.00237365); e2 (-1.73648178e-01 9.84807753e-01 0.0); }
is not working. The origin is well taken into account, but not the axes as indicated. The global coordinate system is still used. This is annoying..
About the time-dependent coordinate system, this latter changes only concerns postprocessing. I guess I can do something relatively clean and efficient using systemCall, and a command using sed and such.
By Poirier on 2018-06-19T12:52:42 (imported from GitLab project)
- Admin reopened
reopened
By Poirier on 2018-06-19T12:53:09 (imported from GitLab project)
- Maintainer
Sounds strange that origin is working, but you do not generate a
postProcessing/forces/*/localForce.dat
file. Which branch are you using?Regarding time-variation: if you have reasonable idea of what you'd like to change, you can derived your own
timeForces
function object by inheriting from theforces
function object. I checked and the coordinate system is a protected member, which means you should be able to manipulate it as desired.If you get something that looks reasonable, and fairly generalizable, we can see about integrating it.
- Author Maintainer
A localForce.dat is generated, but its content is exactly the same as in force.dat, no matter how the axes are defined. I'm using the v1712 version.
By Poirier on 2018-06-19T13:18:24 (imported from GitLab project)
- Maintainer
I did my non-exhaustive test with the 1712 master (last commit 73a83bf41ba0d, includes commit 19a01a62bb7d4).
Changed
tutorials/incompressible/pimpleFoam/RAS/wingMotion/wingMotion2D_simpleFoam/system/ControlDict
and ran.The first entry of force:
(1.972338e+03 5.371971e+03 1.059305e-15)
The first entry of localForce:
(-5.371971e+03 -1.059305e-15 1.972338e+03)
So sign and directions flipped as expected. If I change the rotations again
e1 (1 1 0); e3 (0 0 1);
The localForces rotate again. I don't know what is going wrong in your case.
- Author Maintainer
Well, I have performed the same tests and I get the results results as you.
I realize that the coordinate system initially defined (which coincided with the global reference) remains taken into account throughout the simulation, despite the changes I make in the force function.
I thought this function was reloaded with every change I made to it.
By Poirier on 2018-06-19T14:00:58 (imported from GitLab project)
- Maintainer
system/controlDict entry
runTimeModifiable true;
should normally do it.
- Author Maintainer
runTimeModifiable was set to true.
But my forces function is defined outside the controlDict, and called through a "#include"
OpenFoam seems to see that the forces function changes since this is displayed at every time step:
Re-reading object controlDict from file "/home/etudes/etudes_NP/ETR180036_NavalGroup_GrandChallengeIrene/01_helice_E779A/E779A_cyclic_MovingMesh_new/system/controlDict" because of modified file "/home/etudes/etudes_NP/ETR180036_NavalGroup_GrandChallengeIrene/01_helice_E779A/E779A_cyclic_MovingMesh_new/system/forces"
Maybe do I need to write the force function explicitly in the controlDict?
By Poirier on 2018-06-19T14:11:44 (imported from GitLab project)
- Maintainer
Sure, if your forces file is included, the file watch mechanism tracks it too. From what you report, it looks like you are either modifying it every time-step (eg, with a shell script), or your file-system is sticky and having issues. Presumably it is working as you wish, however the file header with the CofR will only be output once I think.
As you may figure, using the runTime modification mechanism will have a performance penalty if you are forcing disk access every iteration. There may also be some lag between when you make the change and it gets noticed. I would really encourage you to derive your own function object from forces and change the coordinate system there.
... Could also get a small support contract and get us to put it in, if that works for you too.
- Maintainer
I think we've exhausted the original topic. Please open another issue for working through the time-varying coordinate systems.
- Mark OLESEN closed
closed
- Author Maintainer
Yes, it's OK for me.
Thank you very much for your answers.
By Poirier on 2018-06-20T09:29:37 (imported from GitLab project)
- Mark OLESEN mentioned in commit 8a9db156924ccfcb7170f61a9b4ceddcf37a5cfa
mentioned in commit 8a9db156924ccfcb7170f61a9b4ceddcf37a5cfa
- Mark OLESEN mentioned in commit f34edc6280631bb7519a8ac19f1e2264f2904377
mentioned in commit f34edc6280631bb7519a8ac19f1e2264f2904377
- Mark OLESEN mentioned in commit 1a7cc7144665322f64bf193dba13f1a4c2665931
mentioned in commit 1a7cc7144665322f64bf193dba13f1a4c2665931
- Mark OLESEN mentioned in commit 3c3cf51f6977dd110d9932e10e5a0d6b45190342
mentioned in commit 3c3cf51f6977dd110d9932e10e5a0d6b45190342
- Mark OLESEN mentioned in commit fb13c6afcd570036be510b0ac846f6e3019fc60f
mentioned in commit fb13c6afcd570036be510b0ac846f6e3019fc60f
- Mark OLESEN mentioned in commit c75d511858946aa9874dcfe228efc55c2707da74
mentioned in commit c75d511858946aa9874dcfe228efc55c2707da74
- Mark OLESEN mentioned in commit b833ffec
mentioned in commit b833ffec
- Mark OLESEN mentioned in commit 71404067
mentioned in commit 71404067
- Mark OLESEN mentioned in commit 1f0bc692
mentioned in commit 1f0bc692