CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   Using forces in other classes (http://www.cfd-online.com/Forums/openfoam/101552-using-forces-other-classes.html)

flowris May 7, 2012 10:49

Using forces in other classes
 
Hello,

I have a mesh motion class that works very well for prescribed motion. I would like to use this class to do rigid body displacements, under the influence of the fluid forces. I can also calculate the forces using the standard forces function.

How can I take the results from this force calculation at each time step, and bring them into my mesh motion class for further use?

boger May 8, 2012 07:14

One way would be to instantiate a forces object from within your class and use the calcForcesMoment() method to get the forces and moments acting on your object.

flowris May 8, 2012 07:40

Excellent! I saw that in the sixDoFRigidBodyDisplacement class, but was not sure if this was what I was looking for. I'll try and learn to use it.

Many thanks!

flowris May 8, 2012 10:22

Do you know more about objectRegistry? I am trying to instantiate a forces object, as you suggested:
Code:

    dictionary forcesDict;

    forcesDict.add("patches", "block");
    forcesDict.add("rhoName", "rhoInf");
    forcesDict.add("rhoInf", 1000);
    vector centreOfMass_(0.0,0.0,0.0);
    forcesDict.add("CofR", centreOfMass_);

    forces f("forces", db(), forcesDict);

But in the last line, where is written "db()", I should put a reference to the objectRegistry. What is this, and how do I reference to it?

flowris June 5, 2012 10:38

Can anybody tell me how to instantiate a forces object in a new class, or give an example where it is done?

flowris June 5, 2012 12:56

Simply writing
Code:

    forces f("forces", db(), forcesDict);
results in the compiling error
Code:

hppGgiFvMesh.C: In member function ‘void Foam::hppGgiFvMesh::getMoment()’:
hppGgiFvMesh.C:358: error: reference to ‘db’ is ambiguous
/home/jmatthei/OpenFOAM/OpenFOAM-1.6-ext/src/OpenFOAM/lnInclude/IOobject.H:236: error: candidates are: const Foam::objectRegistry& Foam::IOobject::db() const
/home/jmatthei/OpenFOAM/OpenFOAM-1.6-ext/src/OpenFOAM/lnInclude/IOobject.H:236: error:                const Foam::objectRegistry& Foam::IOobject::db() const
/home/jmatthei/OpenFOAM/OpenFOAM-1.6-ext/src/OpenFOAM/lnInclude/IOobject.H:236: error:                const Foam::objectRegistry& Foam::IOobject::db() const
hppGgiFvMesh.C:358: error: reference to ‘db’ is ambiguous
/home/jmatthei/OpenFOAM/OpenFOAM-1.6-ext/src/OpenFOAM/lnInclude/IOobject.H:236: error: candidates are: const Foam::objectRegistry& Foam::IOobject::db() const
/home/jmatthei/OpenFOAM/OpenFOAM-1.6-ext/src/OpenFOAM/lnInclude/IOobject.H:236: error:                const Foam::objectRegistry& Foam::IOobject::db() const



All times are GMT -4. The time now is 07:18.