OOFEM 3.0
Loading...
Searching...
No Matches
AbaqusUserElement.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
35#include "AbaqusUserElement.h"
36#include "gausspoint.h"
37#include "classfactory.h"
38#include "dynamicinputrecord.h"
39#include "dofmanager.h"
40#include "node.h"
41#include "parametermanager.h"
42#include "paramkey.h"
43
44#ifdef _WIN32 //_MSC_VER and __MINGW32__ included
45 #include <Windows.h>
46#else
47 #include <dlfcn.h>
48#endif
49
50#include <cstring>
51
52namespace oofem {
54
62
66
68{
69#ifdef _WIN32
70 if ( this->uelobj ) {
71 FreeLibrary( ( HMODULE ) this->uelobj);
72 }
73#else
74 if ( this->uelobj ) {
75 dlclose(this->uelobj);
76 }
77#endif
78}
79
80
93
94
96{
99
105
106 this->numberOfDofMans = dofManArray.giveSize();
107 if ( this->numSvars < 0 ) {
108 OOFEM_ERROR("'numsvars' field has an invalid value");
109 }
110 if ( this->jtype < 0 ) {
111 OOFEM_ERROR("'type' has an invalid value");
112 }
113
114 #if 0
115 uelname = "uel";
117#endif
118
119#ifdef _WIN32
120 this->uelobj = ( void * ) LoadLibrary(filename.c_str() );
121 if ( !this->uelobj ) {
122 OOFEM_ERROR("couldn't load \"%s\",\ndlerror: %s", filename.c_str() );
123 }
124
125 * ( FARPROC * ) ( & this->uel ) = GetProcAddress( ( HMODULE ) this->uelobj, "uel_"); //works for MinGW 32bit
126 if ( !this->uel ) {
127 // char *dlresult = GetLastError();
128 DWORD dlresult = GetLastError(); //works for MinGW 32bit
129 OOFEM_ERROR("couldn't load symbol uel,\nerror: %s\n", dlresult);
130 }
131#else
132 this->uelobj = dlopen(filename.c_str(), RTLD_NOW);
133 if ( !this->uelobj ) {
134 OOFEM_ERROR("couldn't load \"%s\",\ndlerror: %s", filename.c_str(), dlerror() );
135 }
136
137 * ( void ** ) ( & this->uel ) = dlsym(this->uelobj, "uel_");
138 char *dlresult = dlerror();
139 if ( dlresult ) {
140 OOFEM_ERROR("couldn't load symbol uel,\ndlerror: %s\n", dlresult);
141 }
142#endif
143
144 this->ndofel = this->numberOfDofMans * this->nCoords;
145 this->mlvarx = this->ndofel;
146 this->nrhs = 2;
147 this->rhs.resize(this->ndofel, this->nrhs);
148 this->amatrx.resize(this->ndofel, this->ndofel);
149 this->svars.resize(this->numSvars);
150 this->lFlags.resize(5);
151 this->predef.resize(this->npredef * this->numberOfDofMans * 2);
152 this->energy.resize(8);
153 this->U.resize(this->ndofel);
154 this->V.resize(this->ndofel);
155 this->A.resize(this->ndofel);
156 this->DU.resize(this->ndofel, this->nrhs);
157
158 if ( !this->coords.isNotEmpty() ) {
159 this->coords.resize(this->numberOfDofMans, this->mcrd);
160 for ( int j = 1; j <= numberOfDofMans; j++ ) {
161 Node *dm = this->giveNode(j);
162 for ( int i = 1; i <= mcrd; i++ ) {
163 this->coords.at(i, j) = dm->giveCoordinate(i);
164 }
165 }
166 }
167}
168
169
171{
173
174 input.setField(this->coords, IPK_AbaqusUserElement_numcoords.getNameCStr());
175 input.setField(this->dofs, IPK_AbaqusUserElement_dofs.getNameCStr());
176 input.setField(this->numSvars, IPK_AbaqusUserElement_numsvars.getNameCStr());
177 input.setField(this->props, IPK_AbaqusUserElement_properties.getNameCStr());
178 input.setField(this->jtype, IPK_AbaqusUserElement_type.getNameCStr());
179 input.setField(this->filename, IPK_AbaqusUserElement_userElement.getNameCStr());
180}
181
183{
184 answer = this->dofs;
185}
186
187void AbaqusUserElement::computeStiffnessMatrix(FloatMatrix &answer, MatResponseMode rMode, TimeStep *tStep)
188{
189 if ( !hasTangent() ) {
190 // use uel to calculate the tangent
191 FloatArray forces;
192 giveInternalForcesVector(forces, tStep, U, DU, 0);
193 }
194 // give tangent
195 answer = giveTempTangent();
196 // add stuff to behave differently if mUseNumericalTangent is set?
197}
198
207
209{
210 FloatArray tmp;
211 this->giveInternalForcesVector(tmp, tStep, 0);
212}
213
214void AbaqusUserElement::giveInternalForcesVector(FloatArray &answer, TimeStep *tStep, int useUpdatedGpRecord)
215{
216 // init U vector
217 this->computeVectorOf(VM_Total, tStep, U);
218 FloatArray tempIntVect;
219 // init DU vector
220 computeVectorOf(VM_Incremental, tStep, tempIntVect);
221 this->giveDomain()->giveClassName();
222 DU.zero();
223 DU.setColumn(tempIntVect, 1);
224 //this->computeVectorOf(VM_Total, tStep, DU);
225 this->giveInternalForcesVector(answer, tStep, U, DU, useUpdatedGpRecord);
226}
227
229 FloatArray &U, FloatMatrix &DU, int useUpdatedGpRecord)
230{
231 if ( useUpdatedGpRecord ) {
232 this->rhs.copyColumn(answer, 1);
233 } else {
234 this->lFlags.at(1) = 1; // 1 based access
235 this->lFlags.at(3) = 1; // 1 based access
236 this->lFlags.at(4) = 0; // 1 based access
237
238 int nprops = props.giveSize();
239 int njprops = jprops.giveSize();
240
241 FloatMatrix loc_rhs(this->ndofel, this->nrhs);
242 FloatMatrix loc_amatrx(this->ndofel, this->ndofel);
243 FloatArray loc_svars = this->giveStateVector();
244
245 //this->getSvars();
246 double period = 0., pnewdt = 0.;
247 double dtime = tStep->giveTimeIncrement();
248 double time[] = { tStep->giveTargetTime() - dtime, tStep->giveTargetTime() };
249 this->uel(
250 loc_rhs.givePointer(),
251 loc_amatrx.givePointer(),
252 loc_svars.givePointer(),
253 energy.givePointer(),
254 & ndofel,
255 & nrhs,
256 & numSvars,
257 props.givePointer(),
258 & nprops,
259 coords.givePointer(),
260 & mcrd,
261 & this->numberOfDofMans,
262 U.givePointer(),
263 DU.givePointer(),
264 V.givePointer(),
265 A.givePointer(),
266 & jtype,
267 time,
268 & dtime,
269 & kstep,
270 & kinc,
271 & ( this->number ),
272 params,
273 & ndLoad,
274 jdltype,
275 adlmag.givePointer(),
276 predef.givePointer(),
277 & npredef,
278 lFlags.givePointer(),
279 & mlvarx,
280 ddlmag.givePointer(),
281 & mdLoad,
282 & pnewdt,
283 jprops.givePointer(),
284 & njprops,
285 & period);
286 //FloatArray vout;
287 //vout.resize(12);
288 //for (int i = 1; i <= 3; i++)
289 //{
290 // vout.at(i) = rhs.at(i, 1);
291 // vout.at(i+6) = rhs.at(i+3, 1);
292 //}
293 //answer = vout;
294 //this->rhs.copyColumn(answer, 1);
295 //answer.negated();
296 loc_rhs.negated(); //really needed???
297 loc_rhs.copyColumn(answer, 1);
298 letTempRhsBe(loc_rhs);
299 letTempTangentBe(loc_amatrx);
300 letTempSvarsBe(loc_svars);
301 }
302}
303
304
305void
306AbaqusUserElement::computeConsistentMassMatrix(FloatMatrix &answer, TimeStep *tStep, double &mass, const double *ipDensity)
307{
308 answer.resize(ndofel, ndofel);
309 answer.zero();
310}
311} // namespace oofem
#define _IFT_AbaqusUserElement_name
#define REGISTER_Element(class)
FloatArray svars
Status variables.
static ParamKey IPK_AbaqusUserElement_userElement
virtual FloatMatrix & letTempRhsBe(FloatMatrix &src)
static ParamKey IPK_AbaqusUserElement_type
static ParamKey IPK_AbaqusUserElement_properties
void postInitialize() override
Performs post initialization steps. Called after all components are created and initialized.
virtual const FloatArray & giveStateVector() const
void initializeFrom(InputRecord &ir, int priority) override
void giveDofManDofIDMask(int inode, IntArray &answer) const override
void * uelobj
Dynamically loaded uel.
static ParamKey IPK_AbaqusUserElement_numsvars
FloatArray U
Inputs to element routines. Velocity and Acceleration currently ignored.
void updateYourself(TimeStep *tStep) override
virtual void letTempTangentBe(FloatMatrix &src)
FloatMatrix amatrx
Element amatrx.
std::string filename
File containing the uel function.
bool hasTangentFlag
Keeps track of whether the tangent has been obtained already.
FloatArray props
Element properties.
void giveInternalForcesVector(FloatArray &answer, TimeStep *tStep, int useUpdatedGpRecord=0) override
virtual const FloatMatrix & giveTempTangent()
int numSvars
Number of status variables.
virtual ~AbaqusUserElement()
Destructor.
static ParamKey IPK_AbaqusUserElement_numcoords
AbaqusUserElement(int n, Domain *d)
Constructor.
void(* uel)(double *rhs, double *amatrx, double *svars, double energy[8], int *ndofel, int *nrhs, int *nsvars, double *props, int *nprops, double *coords, int *mcrd, int *nnode, double *u, double *du, double *v, double *a, int *jtype, double time[2], double *dtime, int *kstep, int *kinc, int *jelem, double params[3], int *ndload, int *jdltyp, double *adlmag, double *predef, int *npredef, int *lflags, int *mvarx, double *ddlmag, int *mdload, double *pnewdt, int *jprops, int *njprop, double *period)
Pointer to the dynamically loaded uel-function (translated to C).
void giveInputRecord(DynamicInputRecord &input) override
void computeStiffnessMatrix(FloatMatrix &answer, MatResponseMode rMode, TimeStep *tStep) override
virtual FloatArray & letTempSvarsBe(FloatArray &src)
void computeConsistentMassMatrix(FloatMatrix &answer, TimeStep *tStep, double &mass, const double *ipDensity=NULL) override
void updateInternalState(TimeStep *tStep) override
static ParamKey IPK_AbaqusUserElement_name
static ParamKey IPK_AbaqusUserElement_dofs
double giveCoordinate(int i) const
Definition dofmanager.h:383
ParameterManager elementPPM
Definition domain.h:133
const char * giveClassName() const
Returns class name of the receiver.
Definition domain.h:734
void setField(int item, InputFieldType id)
Node * giveNode(int i) const
Definition element.h:629
IntArray dofManArray
Array containing dofmanager numbers.
Definition element.h:138
void initializeFrom(InputRecord &ir, int priority) override
Definition element.C:687
int numberOfDofMans
Number of dofmanagers.
Definition element.h:136
void computeVectorOf(ValueModeType u, TimeStep *tStep, FloatArray &answer)
Definition element.C:103
void postInitialize() override
Performs post initialization steps.
Definition element.C:797
Domain * giveDomain() const
Definition femcmpnn.h:97
int number
Component number.
Definition femcmpnn.h:77
const double * givePointer() const
Definition floatarray.h:506
const double * givePointer() const
void copyColumn(FloatArray &dest, int c) const
void resize(Index rows, Index cols)
Definition floatmatrix.C:79
void zero()
Zeroes all coefficient of receiver.
void updateYourself(TimeStep *tStep) override
StructuralElement(int n, Domain *d)
void giveInputRecord(DynamicInputRecord &input) override
double giveTimeIncrement()
Returns solution step associated time increment.
Definition timestep.h:168
double giveTargetTime()
Returns target time.
Definition timestep.h:164
#define OOFEM_ERROR(...)
Definition error.h:79
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Definition inputrecord.h:75
#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