DAMotionTranslation.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2 
3  DAFoam : Discrete Adjoint with OpenFOAM
4  Version : v3
5 
6 \*---------------------------------------------------------------------------*/
7 
8 #include "DAMotionTranslation.H"
9 
10 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
11 
12 namespace Foam
13 {
14 
15 defineTypeNameAndDebug(DAMotionTranslation, 0);
16 addToRunTimeSelectionTable(DAMotion, DAMotionTranslation, dictionary);
17 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
18 
20  const dynamicFvMesh& mesh,
21  const DAOption& daOption)
22  : DAMotion(
23  mesh,
24  daOption)
25 {
26  amplitude_ = daOption_.getAllOptions().subDict("rigidBodyMotion").getScalar("amplitude");
27  frequency_ = daOption_.getAllOptions().subDict("rigidBodyMotion").getScalar("frequency");
28  phase_ = daOption_.getAllOptions().subDict("rigidBodyMotion").getScalar("phase");
29  scalarList dirList;
30  daOption_.getAllOptions().subDict("rigidBodyMotion").readEntry<scalarList>("direction", dirList);
31  direction_[0] = dirList[0];
32  direction_[1] = dirList[1];
33  direction_[2] = dirList[2];
34  daOption_.getAllOptions().subDict("rigidBodyMotion").readEntry<wordList>("patchNames", patchNames_);
35 }
36 
38 {
39  volVectorField& cellDisp =
40  const_cast<volVectorField&>(mesh_.thisDb().lookupObject<volVectorField>("cellDisplacement"));
41 
42  scalar t = mesh_.time().value();
43 
44  const scalar& pi = Foam::constant::mathematical::pi;
45 
46  scalar y = amplitude_ * sin(2.0 * pi * frequency_ * t + phase_);
47 
48  forAll(patchNames_, idxI)
49  {
50  const word& patchName = patchNames_[idxI];
51  label patchI = mesh_.boundaryMesh().findPatchID(patchName);
52 
53  forAll(cellDisp.boundaryField()[patchI], faceI)
54  {
55  cellDisp.boundaryFieldRef()[patchI][faceI] = y * direction_;
56  }
57  }
58 
59  // print information
60  Info << "Time: " << t << " y: " << y << endl;
61 }
62 
63 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
64 
65 } // End namespace Foam
66 
67 // ************************************************************************* //
Foam::DAMotionTranslation::phase_
scalar phase_
phase of the translation oscillation
Definition: DAMotionTranslation.H:38
forAll
forAll(pseudoP.boundaryField(), patchI)
Definition: solvePseudoPEqn.H:10
Foam::DAMotion::mesh_
const dynamicFvMesh & mesh_
fvMesh
Definition: DAMotion.H:41
Foam::DAMotionTranslation::amplitude_
scalar amplitude_
amplitude of the translation oscillation
Definition: DAMotionTranslation.H:32
Foam::DAOption
Definition: DAOption.H:29
daOption
DAOption daOption(mesh, pyOptions_)
Foam::DAMotionTranslation::frequency_
scalar frequency_
frequency of the translation oscillation
Definition: DAMotionTranslation.H:35
Foam::DAMotion::daOption_
const DAOption & daOption_
DAOption object.
Definition: DAMotion.H:44
Foam::DAOption::getAllOptions
const dictionary & getAllOptions() const
return a reference of allOptions_ dictionary
Definition: DAOption.H:56
mesh
fvMesh & mesh
Definition: createRefsHeatTransfer.H:4
Foam::DAMotion::patchNames_
wordList patchNames_
patch names for the moving body
Definition: DAMotion.H:47
Foam::DAMotion
Definition: DAMotion.H:29
Foam::DAMotionTranslation::direction_
vector direction_
direction of the translation oscillation
Definition: DAMotionTranslation.H:41
Foam
Definition: multiFreqScalarFvPatchField.C:144
Foam::DAMotionTranslation::correct
virtual void correct()
update the cell displacement
Definition: DAMotionTranslation.C:37
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(DAFvSource, 0)
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(DAFvSource, DAFvSourceActuatorDisk, dictionary)
Foam::DAMotionTranslation::DAMotionTranslation
DAMotionTranslation(const dynamicFvMesh &mesh, const DAOption &daOption)
Definition: DAMotionTranslation.C:19
DAMotionTranslation.H