1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/base/bulk.h,v 1.27 2017/01/12 14:46:09 masarati Exp $ */
2 /*
3  * MBDyn (C) is a multibody analysis code.
4  * http://www.mbdyn.org
5  *
6  * Copyright (C) 1996-2017
7  *
8  * Pierangelo Masarati	<masarati@aero.polimi.it>
9  * Paolo Mantegazza	<mantegazza@aero.polimi.it>
10  *
11  * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
12  * via La Masa, 34 - 20156 Milano, Italy
13  * http://www.aero.polimi.it
14  *
15  * Changing this copyright notice is forbidden.
16  *
17  * This program is free software; you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation (version 2 of the License).
20  *
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
30  */
31 
32 /* Bulk elements */
33 
34 #ifndef BULK_H
35 #define BULK_H
36 
37 #include "elem.h"
38 #include "node.h"
39 #include "drive.h"
40 
41 
42 /* Tipi di bulk */
43 class BulkType {
44  public:
45    enum Type {
46       UNKNOWN = -1,
47 	SPRINGSUPPORT = 0,
48 	SPRING,
49 
50 	LASTBULKTYPE
51    };
52 };
53 
54 extern const char* psBulkNames[];
55 
56 
57 /* Bulk - begin */
58 
59 class Bulk : virtual public Elem {
60  public:
Bulk(unsigned int uLabel,flag fOutput)61    Bulk(unsigned int uLabel, flag fOutput)
62      : Elem(uLabel, fOutput) {
63 	NO_OP;
64      };
65 
~Bulk(void)66    virtual ~Bulk(void) {
67       NO_OP;
68    };
69 
GetElemType(void)70    virtual Elem::Type GetElemType(void) const {
71       return Elem::BULK;
72    };
73 };
74 
75 /* Bulk - end */
76 
77 
78 /* BulkSpringSupport - begin */
79 
80 class BulkSpringSupport
81 : virtual public Elem, public Bulk, public DriveOwner {
82  protected:
83    ScalarDof SD;
84 
85  public:
BulkSpringSupport(unsigned int uLabel,const DriveCaller * pDC,const ScalarDof & sd,flag fOutput)86    BulkSpringSupport(unsigned int uLabel, const DriveCaller* pDC,
87 		     const ScalarDof& sd, flag fOutput)
88      : Elem(uLabel, fOutput), Bulk(uLabel, fOutput),
89      DriveOwner(pDC), SD(sd) {
90       NO_OP;
91    };
92 
~BulkSpringSupport(void)93    virtual ~BulkSpringSupport(void) {
94       NO_OP;
95    };
96 
97    /* Scrive il contributo dell'elemento al file di restart */
Restart(std::ostream & out)98    virtual std::ostream& Restart(std::ostream& out) const {
99       return out;
100    };
101 
102 
103    /* Dimensioni del workspace */
WorkSpaceDim(integer * piNumRows,integer * piNumCols)104    virtual void WorkSpaceDim(integer* piNumRows, integer* piNumCols) const {
105       *piNumRows = 1;
106       *piNumCols = 1;
107    };
108 
109    /* assemblaggio jacobiano */
110    virtual VariableSubMatrixHandler&
AssJac(VariableSubMatrixHandler & WorkMat,doublereal dCoef,const VectorHandler &,const VectorHandler &)111      AssJac(VariableSubMatrixHandler& WorkMat,
112 	    doublereal dCoef,
113 	    const VectorHandler& /* XCurr */ ,
114 	    const VectorHandler& /* XPrimeCurr */ ) {
115 
116 	FullSubMatrixHandler& WM = WorkMat.SetFull();
117 	WM.ResizeReset(1, 1);
118 
119 	integer iRowIndex = SD.pNode->iGetFirstRowIndex()+1;
120 	integer iColIndex = SD.pNode->iGetFirstColIndex()+1;
121 	WM.PutRowIndex(1, iRowIndex);
122 	WM.PutColIndex(1, iColIndex);
123 
124 	doublereal d = dGet();
125 	if (SD.iOrder == 0) {
126 	   d *= dCoef;
127 	}
128 	WM.PutCoef(1, 1, d);
129 
130 	return WorkMat;
131      };
132 
133    /* assemblaggio residuo */
AssRes(SubVectorHandler & WorkVec,doublereal,const VectorHandler &,const VectorHandler &)134    virtual SubVectorHandler& AssRes(SubVectorHandler& WorkVec,
135 				    doublereal /* dCoef */ ,
136 				    const VectorHandler& /* XCurr */ ,
137 				    const VectorHandler& /* XPrimeCurr */ ) {
138       WorkVec.Resize(1);
139       WorkVec.Reset();
140 
141       integer iRowIndex = SD.pNode->iGetFirstRowIndex()+1;
142       doublereal dVal = SD.pNode->dGetDofValue(1, SD.iOrder);
143       WorkVec.PutItem(1, iRowIndex, -dGet()*dVal);
144 
145       return WorkVec;
146    };
147 
148    /* *******PER IL SOLUTORE PARALLELO******** */
149    /* Fornisce il tipo e la label dei nodi che sono connessi all'elemento
150       utile per l'assemblaggio della matrice di connessione fra i dofs */
GetConnectedNodes(std::vector<const Node * > & connectedNodes)151    virtual void GetConnectedNodes(std::vector<const Node *>& connectedNodes) const {
152      connectedNodes.resize(1);
153      connectedNodes[0] = SD.pNode;
154    };
155    /* ************************************************ */
156 };
157 
158 /* BulkSpringSupport - end */
159 
160 class DataManager;
161 class MBDynParser;
162 
163 extern Elem* ReadBulk(DataManager* pDM, MBDynParser& HP, unsigned int uLabel);
164 
165 #endif
166