rigidBodyModelState.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2016-2017 OpenFOAM Foundation
9  Copyright (C) 2018-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "rigidBodyModelState.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
34 (
35  const rigidBodyModel& model
36 )
37 :
38  q_(model.nDoF(), Zero),
39  qDot_(model.nDoF(), Zero),
40  qDdot_(model.nDoF(), Zero),
41  t_(-1),
42  deltaT_(0)
43 {}
44 
45 
47 (
48  const rigidBodyModel& model,
49  const dictionary& dict
50 )
51 :
52  q_(dict.getOrDefault("q", scalarField(model.nDoF(), Zero))),
53  qDot_(dict.getOrDefault("qDot", scalarField(model.nDoF(), Zero))),
54  qDdot_(dict.getOrDefault("qDdot", scalarField(model.nDoF(), Zero))),
55  t_(dict.getOrDefault<scalar>("t", -1)),
56  deltaT_(dict.getOrDefault<scalar>("deltaT", 0))
57 {
58  if
59  (
60  q_.size() != model.nDoF()
61  || qDot_.size() != model.nDoF()
62  || qDdot_.size() != model.nDoF()
63  )
64  {
65  FatalErrorInFunction << "State parameters 'q', 'qDot', 'qDdot'"
66  << " do not have the same size as the number of DoF "
67  << model.nDoF()
68  << ". Is your \"rigidBodyMotionState\" state file consistent?"
69  << exit(FatalError);
70  }
71 }
72 
73 
74 // ************************************************************************* //
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::Field< scalar >
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::RBD::rigidBodyModel
Basic rigid-body model representing a system of rigid-bodies connected by 1-6 DoF joints.
Definition: rigidBodyModel.H:83
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
rigidBodyModelState.H
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::RBD::rigidBodyModelState::rigidBodyModelState
rigidBodyModelState(const rigidBodyModel &model)
Construct for the given rigidBodyModel.
Definition: rigidBodyModelState.C:34
Foam::RBD::rigidBodyModel::nDoF
label nDoF() const
Return the number of degrees of freedom of the model.
Definition: rigidBodyModelI.H:64