From f0cada17e22aacbb037e5485dcd851883f2a8f95 Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 27 Aug 2018 09:21:38 +0100 Subject: [PATCH] ENH: rigidBody: added error checking. --- .../rigidBodyModelState/rigidBodyModelState.C | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/rigidBodyDynamics/rigidBodyModelState/rigidBodyModelState.C b/src/rigidBodyDynamics/rigidBodyModelState/rigidBodyModelState.C index b3ee98eeff..92fe0e9116 100644 --- a/src/rigidBodyDynamics/rigidBodyModelState/rigidBodyModelState.C +++ b/src/rigidBodyDynamics/rigidBodyModelState/rigidBodyModelState.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -51,7 +51,21 @@ Foam::RBD::rigidBodyModelState::rigidBodyModelState qDdot_(dict.lookupOrDefault("qDdot", scalarField(model.nDoF(), Zero))), t_(dict.lookupOrDefault("t", -1)), deltaT_(dict.lookupOrDefault("deltaT", 0)) -{} +{ + if + ( + q_.size() != model.nDoF() + || qDot_.size() != model.nDoF() + || qDdot_.size() != model.nDoF() + ) + { + FatalErrorInFunction << "State parameters 'q', 'qDot', 'qDdot'" + << " do not have the same size as the number of DoF " + << model.nDoF() + << ". Is your \"rigidBodyMotionState\" state file consistent?" + << exit(FatalError); + } +} // ************************************************************************* //