# Custom boundary condition rotation angle access

 Register Blogs Members List Search Today's Posts Mark Forums Read

 February 11, 2022, 13:23 Custom boundary condition rotation angle access #1 New Member   Adrian del Ser Join Date: Oct 2021 Posts: 15 Rep Power: 4 Hi everyone, I'm trying to create a custom codedFixedValue boundary condition that depends on the angle of rotation and angular velocity of a rotating rigid body. The motion solver is sixDoFRigidBodyMotion. Inside controlDict, one can add the following code to print out this data: Code: ```functions { sixDoFRigidBodyState { type sixDoFRigidBodyState; libs ("libsixDoFRigidBodyState.so"); angleFormat degrees; } }``` How could I access (during runtime of course) the rotation rate/rotation angle or other data contained in sixDoFRigidBodyState as variables to code into the codedFixedValue boundary condition? I have tried to follow the class tree without success. I have found this code which gets access to db() or patch() to set a sinusoidal boundary condition in space, but I am not sure how to get to sixDoFRigidBodyState and the values it contains: Code: ```codedPatch { type codedFixedValue; value uniform 0; name codedPatchBC; // name of generated BC code #{ //const scalar t = this -> db().time().value(); const scalar pi = constant::mathematical::pi; const fvPatch& patch = this -> patch(); const vectorField& cf = patch.Cf(); const scalar l = 0.1; scalarField& field = *this; forAll(cf, i) { field[i] = 273+100*sin((2*pi/l)*cf[i].x()); } #};``` Thanks, Adrian

 February 12, 2022, 03:11 #2 Senior Member   Michael Alletto Join Date: Jun 2018 Location: Bremen Posts: 615 Rep Power: 15 From this file it seems you have to access the motion solver https://develop.openfoam.com/Develop...gidBodyState.C The the function motion() returns the motion state Best Michael

 February 12, 2022, 03:17 #3 Senior Member   Michael Alletto Join Date: Jun 2018 Location: Bremen Posts: 615 Rep Power: 15 Probably you have to write this lines in your function object Code: ```. const sixDoFRigidBodyMotionSolver& motionSolver_ = refCast(mesh.motion()); const sixDoFRigidBodyMotion& motion = motionSolver_.motion();```

February 17, 2022, 04:11
#4
New Member

Join Date: Oct 2021
Posts: 15
Rep Power: 4
Quote:
 Originally Posted by mAlletto Probably you have to write this lines in your function object Code: ```. const sixDoFRigidBodyMotionSolver& motionSolver_ = refCast(mesh.motion()); const sixDoFRigidBodyMotion& motion = motionSolver_.motion();```

Thanks! I'll be testing this soon, is this something you can put directly in the code block of the custom boundary condition?

 February 17, 2022, 12:09 #5 Senior Member   Michael Alletto Join Date: Jun 2018 Location: Bremen Posts: 615 Rep Power: 15 Yes yes. You have to access the value at the boundary