View Issue Details

IDProjectCategoryView StatusLast Update
0003308OpenFOAMPatchpublic2019-07-23 16:48
Reporterhandrake0724Assigned Tohenry 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platformx86_64OSArchOS Version(please specify)
Product Version7 
Fixed in Versiondev 
Summary0003308: generalize sixDoFRigidBodyState functionObject
DescriptionI found that sixDoFRigidBodyState is coupled with sixDoFRigidBodyMotionSolver.
If I want to use only sixDoFRigidBodyMotion class and develop a new motionsolver class like solid body motion,
I have to rewrite another sixDoFRigidBodyState functionObject with almost same code.
It just work with modifying the following statement in sixDoFRigidBodyState::motion()

     const sixDoFRigidBodyMotionSolver& motionSolver_ =
         refCast<const sixDoFRigidBodyMotionSolver>(mesh.motion());

 into
     const sixDoFRigidBodyMotionSolver& motionSolver_ =
         refCast<const someMotionSolver>(mesh.motion());

Instead, it would more general if sixDoFRigidBodyState's motion member function goes as follows:

    sixDoFRigidBodyState::motion()
    {
         const dynamicMotionSolverFvMesh& mesh =
             refCast<const dynamicMotionSolverFvMesh>(obr_);
        return (refCast<const sixDoFRigidBodyMotion>(mesh.motion()));
    }

To this end, sixDoFRigidBodyMotionSolver should be inherited from both displacementMotionSolver and sixDoFRigidBodyMotion.
this class structure is following rigidBodyMotionState and rigidBodyMeshMotion and found it is working.

It would be helpful to review the attached patch and reflect to of7 and above.
TagsNo tags attached.

Activities

handrake0724

2019-07-18 12:01

reporter  

sixDoFRigidBodyState.diff (6,035 bytes)
diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.C
index 1e2ef3d31..adf803591 100644
--- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.C
+++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.C
@@ -27,6 +27,13 @@ License
 #include "sixDoFSolver.H"
 #include "septernion.H"
 
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+namespace Foam
+{
+    defineTypeNameAndDebug(sixDoFRigidBodyMotion, 0);
+}
+
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
 void Foam::sixDoFRigidBodyMotion::applyRestraints()
diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.H b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.H
index a70883ad8..10f9a8f3a 100644
--- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.H
+++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.H
@@ -204,6 +204,8 @@ class sixDoFRigidBodyMotion
 
 
 public:
+    //- Runtime type information
+    TypeName("sixDoFRigidBodyMotion");
 
     // Constructors
 
@@ -222,7 +224,7 @@ public:
 
 
     //- Destructor
-    ~sixDoFRigidBodyMotion();
+    virtual ~sixDoFRigidBodyMotion();
 
 
     // Member Functions
diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionSolver/sixDoFRigidBodyMotionSolver.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionSolver/sixDoFRigidBodyMotionSolver.C
index d75207e2d..19f87a94a 100644
--- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionSolver/sixDoFRigidBodyMotionSolver.C
+++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionSolver/sixDoFRigidBodyMotionSolver.C
@@ -56,7 +56,7 @@ Foam::sixDoFRigidBodyMotionSolver::sixDoFRigidBodyMotionSolver
 )
 :
     displacementMotionSolver(mesh, dict, typeName),
-    motion_
+    sixDoFRigidBodyMotion
     (
         coeffDict(),
         IOobject
@@ -158,13 +158,6 @@ Foam::sixDoFRigidBodyMotionSolver::~sixDoFRigidBodyMotionSolver()
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-const Foam::sixDoFRigidBodyMotion&
-Foam::sixDoFRigidBodyMotionSolver::motion() const
-{
-    return motion_;
-}
-
-
 Foam::tmp<Foam::pointField>
 Foam::sixDoFRigidBodyMotionSolver::curPoints() const
 {
@@ -189,7 +182,7 @@ void Foam::sixDoFRigidBodyMotionSolver::solve()
     bool firstIter = false;
     if (curTimeIndex_ != t.timeIndex())
     {
-        motion_.newTime();
+        newTime();
         curTimeIndex_ = t.timeIndex();
         firstIter = true;
     }
@@ -210,11 +203,11 @@ void Foam::sixDoFRigidBodyMotionSolver::solve()
 
     if (test_)
     {
-        motion_.update
+        update
         (
             firstIter,
-            ramp*(motion_.mass()*g.value()),
-            ramp*(motion_.mass()*(motion_.momentArm() ^ g.value())),
+            ramp*(mass()*g.value()),
+            ramp*(mass()*(momentArm() ^ g.value())),
             t.deltaTValue(),
             t.deltaT0Value()
         );
@@ -227,20 +220,20 @@ void Foam::sixDoFRigidBodyMotionSolver::solve()
         forcesDict.add("patches", patches_);
         forcesDict.add("rhoInf", rhoInf_);
         forcesDict.add("rho", rhoName_);
-        forcesDict.add("CofR", motion_.centreOfRotation());
+        forcesDict.add("CofR", centreOfRotation());
 
         functionObjects::forces f("forces", t, forcesDict);
 
         f.calcForcesMoment();
 
-        motion_.update
+        update
         (
             firstIter,
-            ramp*(f.forceEff() + motion_.mass()*g.value()),
+            ramp*(f.forceEff() + mass()*g.value()),
             ramp
            *(
                f.momentEff()
-             + motion_.mass()*(motion_.momentArm() ^ g.value())
+             + mass()*(momentArm() ^ g.value())
             ),
             t.deltaTValue(),
             t.deltaT0Value()
@@ -249,7 +242,7 @@ void Foam::sixDoFRigidBodyMotionSolver::solve()
 
     // Update the displacements
     pointDisplacement_.primitiveFieldRef() =
-        motion_.transform(points0(), scale_) - points0();
+        transform(points0(), scale_) - points0();
 
     // Displacement has changed. Update boundary conditions
     pointConstraints::New
@@ -275,7 +268,7 @@ bool Foam::sixDoFRigidBodyMotionSolver::write() const
         )
     );
 
-    motion_.state().write(dict);
+    state().write(dict);
 
     return
         dict.regIOobject::writeObject
diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionSolver/sixDoFRigidBodyMotionSolver.H b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionSolver/sixDoFRigidBodyMotionSolver.H
index 6317510e8..957121179 100644
--- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionSolver/sixDoFRigidBodyMotionSolver.H
+++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionSolver/sixDoFRigidBodyMotionSolver.H
@@ -52,12 +52,13 @@ namespace Foam
 
 class sixDoFRigidBodyMotionSolver
 :
-    public displacementMotionSolver
+    public displacementMotionSolver,
+    public sixDoFRigidBodyMotion
 {
     // Private Data
 
         //- Six DoF motion object
-        sixDoFRigidBodyMotion motion_;
+        //sixDoFRigidBodyMotion motion_;
 
         wordReList patches_;
 
diff --git a/src/sixDoFRigidBodyState/sixDoFRigidBodyState/sixDoFRigidBodyState.C b/src/sixDoFRigidBodyState/sixDoFRigidBodyState/sixDoFRigidBodyState.C
index 07dcb167a..21b65e731 100644
--- a/src/sixDoFRigidBodyState/sixDoFRigidBodyState/sixDoFRigidBodyState.C
+++ b/src/sixDoFRigidBodyState/sixDoFRigidBodyState/sixDoFRigidBodyState.C
@@ -110,10 +110,7 @@ Foam::functionObjects::sixDoFRigidBodyState::motion() const
     const dynamicMotionSolverFvMesh& mesh =
         refCast<const dynamicMotionSolverFvMesh>(obr_);
 
-    const sixDoFRigidBodyMotionSolver& motionSolver_ =
-        refCast<const sixDoFRigidBodyMotionSolver>(mesh.motion());
-
-    return motionSolver_.motion();
+    return  (refCast<const sixDoFRigidBodyMotion>(mesh.motion()));
 }
 
 

henry

2019-07-18 12:12

manager   ~0010610

> To this end, sixDoFRigidBodyMotionSolver should be inherited from both displacementMotionSolver and sixDoFRigidBodyMotion.

This makes sense and is consistent with

class rigidBodyMeshMotion
:
    public displacementMotionSolver,
    public RBD::rigidBodyMotion
.
.
.

I will study the changes in more detail later today.

henry

2019-07-23 16:48

manager   ~0010643

Resolved by commit eecd590eb6db654a21d726b68c7f881fb77c59a2

Issue History

Date Modified Username Field Change
2019-07-18 12:01 handrake0724 New Issue
2019-07-18 12:01 handrake0724 File Added: sixDoFRigidBodyState.diff
2019-07-18 12:12 henry Note Added: 0010610
2019-07-23 16:48 henry Assigned To => henry
2019-07-23 16:48 henry Status new => resolved
2019-07-23 16:48 henry Resolution open => fixed
2019-07-23 16:48 henry Fixed in Version => dev
2019-07-23 16:48 henry Note Added: 0010643