OOFEM 3.0
Loading...
Searching...
No Matches
nodalspringelement.C
Go to the documentation of this file.
1/*
2 *
3 * ##### ##### ###### ###### ### ###
4 * ## ## ## ## ## ## ## ### ##
5 * ## ## ## ## #### #### ## # ##
6 * ## ## ## ## ## ## ## ##
7 * ## ## ## ## ## ## ## ##
8 * ##### ##### ## ###### ## ##
9 *
10 *
11 * OOFEM : Object Oriented Finite Element Code
12 *
13 * Copyright (C) 1993 - 2025 Borek Patzak
14 *
15 *
16 *
17 * Czech Technical University, Faculty of Civil Engineering,
18 * Department of Structural Mechanics, 166 29 Prague, Czech Republic
19 *
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License as published by the Free Software Foundation; either
23 * version 2.1 of the License, or (at your option) any later version.
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28 * Lesser General Public License for more details.
29 *
30 * You should have received a copy of the GNU Lesser General Public
31 * License along with this library; if not, write to the Free Software
32 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33 */
34
36#include "floatmatrix.h"
37#include "intarray.h"
38#include "floatarray.h"
39#include "classfactory.h"
40#include "parametermanager.h"
41#include "paramkey.h"
42
43#ifdef __OOFEG
44 #include "oofeggraphiccontext.h"
45#endif
46
47namespace oofem {
49
53
54NodalSpringElement :: NodalSpringElement(int n, Domain *aDomain) : StructuralElement(n, aDomain)
55{
57}
58
59void
60NodalSpringElement :: computeStiffnessMatrix(FloatMatrix &answer, MatResponseMode rMode, TimeStep *tStep)
61{
62 answer.beDiagonal(this->springConstants);
63}
64
65
66void
67NodalSpringElement :: giveInternalForcesVector(FloatArray &answer, TimeStep *tStep, int useUpdatedGpRecord)
68{
69 int ndofs = computeNumberOfDofs();
70 FloatArray u;
71 this->computeVectorOf(VM_Total, tStep, u);
72
73 answer.resize(ndofs);
74
75 for (int i = 1; i<=ndofs; i++) {
76 answer.at(i) = this->springConstants.at(i)*u.at(i);
77 }
78}
79
80
81bool
82NodalSpringElement :: computeGtoLRotationMatrix(FloatMatrix &answer)
83{
84 return false;
85}
86
87
88void
89NodalSpringElement :: giveDofManDofIDMask(int inode, IntArray &answer) const
90{
91 answer= this->dofMask;
92}
93
94void
96{
97 if (this->masses.isNotEmpty()) {
98 answer.beDiagonal(masses);
99 } else {
100 int ndofs = this->computeNumberOfDofs();
101 answer.resize(ndofs, ndofs);
102 answer.zero();
103 }
104}
105
106int
107NodalSpringElement :: computeNumberOfGlobalDofs()
108{
109 return this->computeNumberOfDofs();
110}
111
112
113void
114NodalSpringElement :: initializeFrom(InputRecord &ir, int priority)
115{
116 ParameterManager &ppm = this->giveDomain()->elementPPM;
117 //StructuralElement::initializeFrom(ir, priority);
118
123 PM_UPDATE_PARAMETER(dofManArray, ppm, ir, this->number, IPK_Element_nodes, priority) ;
124}
125
126void
127NodalSpringElement :: initializeFinish()
128{
129 ParameterManager &ppm = this->giveDomain()->elementPPM;
133
134 if (!ppm.checkIfSet(this->number, IPK_NodalSpringElement_masses.getIndex())) {
135 this->masses.resize(this->dofMask.giveSize());
136 this->masses.zero();
137 }
138 int ndofs = dofMask.giveSize();
139 if (ndofs != springConstants.giveSize()) {
140 OOFEM_ERROR ("Spring constants size not equal to number of DOFs");
141 }
142
143 if (ndofs != masses.giveSize()) {
144 OOFEM_ERROR ("Masses array size not equal to number of DOFs");
145 }
146}
147
148
149void
150NodalSpringElement :: postInitialize()
151{}
152
153void NodalSpringElement :: printOutputAt(FILE *File, TimeStep *tStep)
154{
155 FloatArray F;
156 this->giveInternalForcesVector(F, tStep);
157
158 fprintf(File, "NodalSpring element %d (%8d) :\n", this->giveLabel(), this->giveNumber() );
159 fprintf(File, " Force/Moment ");
160 for (int i = 1; i<= F.giveSize(); i++) {
161 fprintf(File, "%.4e ", F.at(i));
162 }
163 fprintf(File, "\n");
164}
165} // end namespace oofem
#define REGISTER_Element(class)
IntArray dofManArray
Array containing dofmanager numbers.
Definition element.h:138
static ParamKey IPK_Element_nodes
Definition element.h:200
static ParamKey IPK_Element_activityTimeFunction
Definition element.h:206
int numberOfDofMans
Number of dofmanagers.
Definition element.h:136
int activityTimeFunction
Element activity time function. If defined, nonzero value indicates active receiver,...
Definition element.h:163
void computeVectorOf(ValueModeType u, TimeStep *tStep, FloatArray &answer)
Definition element.C:103
int giveLabel() const
Definition element.h:1125
Domain * giveDomain() const
Definition femcmpnn.h:97
int number
Component number.
Definition femcmpnn.h:77
int giveNumber() const
Definition femcmpnn.h:104
void resize(Index s)
Definition floatarray.C:94
double & at(Index i)
Definition floatarray.h:202
Index giveSize() const
Returns the size of receiver.
Definition floatarray.h:261
void resize(Index rows, Index cols)
Definition floatmatrix.C:79
void beDiagonal(const FloatArray &diag)
void zero()
Zeroes all coefficient of receiver.
FloatArray masses
total mass of the spring; to be distributed to nodes
static ParamKey IPK_NodalSpringElement_springConstants
void computeLumpedMassMatrix(FloatMatrix &answer, TimeStep *tStep) override
static ParamKey IPK_NodalSpringElement_masses
static ParamKey IPK_NodalSpringElement_dofmask
FloatArray springConstants
Spring constants.
void giveInternalForcesVector(FloatArray &answer, TimeStep *tStep, int useUpdatedGpRecord=0) override
bool checkIfSet(size_t componentIndex, size_t paramIndex)
StructuralElement(int n, Domain *d)
#define OOFEM_ERROR(...)
Definition error.h:79
#define PM_ELEMENT_ERROR_IFNOTSET(_pm, _componentnum, _paramkey)
#define PM_UPDATE_PARAMETER(_val, _pm, _ir, _componentnum, _paramkey, _prio)

This page is part of the OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak Bořek Patzák
Project e-mail: oofem@fsv.cvut.cz
Generated at for OOFEM by doxygen 1.15.0 written by Dimitri van Heesch, © 1997-2011