OOFEM 3.0
Loading...
Searching...
No Matches
load.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 "load.h"
36#include "verbose.h"
37#include "timestep.h"
38#include "function.h"
39#include "dynamicinputrecord.h"
40#include "datastream.h"
41#include "contextioerr.h"
42
43namespace oofem {
44Load :: Load(int i, Domain *aDomain) :
46{
47 timeFunction = 0;
48}
49
50
51const FloatArray &
52Load :: giveComponentArray() const
53{
54 return componentArray;
55}
56
57
58void
59Load :: computeValues(FloatArray &answer, TimeStep *tStep, const FloatArray &coords, const IntArray &dofids, ValueModeType mode)
60{
62#if 1
63 if ( this->dofs.giveSize() == 0 ) {
64 this->computeValueAt(answer, tStep, coords, mode);
65 return;
66 }
67#endif
68
69 FloatArray loaded_dofs;
70 this->computeValueAt(loaded_dofs, tStep, coords, mode);
71
72 answer.resize(dofids.giveSize());
73 answer.zero();
74 for ( int i = 0; i < dofids.giveSize(); ++i ) {
75 int index = this->dofs.findFirstIndexOf(dofids[i]);
76 if ( index > 0 ) {
77 answer[i] = loaded_dofs.at(index);
78 }
79 }
80}
81
82
83void
84Load :: computeComponentArrayAt(FloatArray &answer, TimeStep *tStep, ValueModeType mode)
85// Returns an array, the load induced at tStep by the receiver.
86{
87 double factor;
88
89 factor = this->giveTimeFunction()->evaluate(tStep, mode);
90 answer = componentArray;
91 answer.times(factor);
92
93 if ( !isImposed(tStep) ) {
94 answer.zero();
95 }
96}
97
98
99void
100Load :: initializeFrom(InputRecord &ir)
101{
102 GeneralBoundaryCondition :: initializeFrom(ir);
103
105
106 int size = componentArray.giveSize();
107 dofExcludeMask.resize(size);
108 dofExcludeMask.zero();
110 if ( dofExcludeMask.giveSize() != size ) {
111 throw ValueInputException(ir, _IFT_Load_dofexcludemask, "dofExcludeMask and componentArray size mismatch");
112 } else {
113 for ( int i = 1; i <= size; i++ ) {
114 if ( dofExcludeMask.at(i) ) {
115 componentArray.at(i) = 0.0;
116 }
117 }
118 }
119
121}
122
123
124void Load :: giveInputRecord(DynamicInputRecord &input)
125{
126 GeneralBoundaryCondition :: giveInputRecord(input);
128 if ( !this->dofExcludeMask.containsOnlyZeroes() ) {
130 }
131 if ( this->reference ) input.setField(_IFT_Load_reference);
132}
133
134
135int
136Load :: isDofExcluded(int indx)
137{
138 if ( ( indx > 0 ) && ( indx <= dofExcludeMask.giveSize() ) ) {
139 return dofExcludeMask.at(indx);
140 } else {
141 OOFEM_ERROR("dof index out of range");
142 }
143
144 //return 0;
145}
146
147
148void
149Load :: scale(double s)
150{
151 this->componentArray.times(s);
152 this->reference = false;
153}
154
155
156void
157Load :: saveContext(DataStream &stream, ContextMode mode)
158{
159 GeneralBoundaryCondition :: saveContext(stream, mode);
160
161 if ( mode & CM_Definition ) {
163 if ( ( iores = componentArray.storeYourself(stream) ) != CIO_OK ) {
164 THROW_CIOERR(iores);
165 }
166 if ( ( iores = dofExcludeMask.storeYourself(stream) ) != CIO_OK ) {
167 THROW_CIOERR(iores);
168 }
169 if ( !stream.write(reference) ) {
171 }
172 }
173}
174
175
176void
177Load :: restoreContext(DataStream &stream, ContextMode mode)
178{
179 GeneralBoundaryCondition :: restoreContext(stream, mode);
180
181 if ( mode & CM_Definition ) {
183 if ( ( iores = componentArray.restoreYourself(stream) ) != CIO_OK ) {
184 THROW_CIOERR(iores);
185 }
186 if ( ( iores = dofExcludeMask.restoreYourself(stream) ) != CIO_OK ) {
187 THROW_CIOERR(iores);
188 }
189 if ( !stream.read(reference) ) {
191 }
192 }
193}
194
195
196} // end namespace oofem
virtual int read(int *data, std::size_t count)=0
Reads count integer values into array pointed by data.
virtual int write(const int *data, std::size_t count)=0
Writes count integer values from array pointed by data.
void setField(int item, InputFieldType id)
void resize(Index s)
Definition floatarray.C:94
double & at(Index i)
Definition floatarray.h:202
void zero()
Zeroes all coefficients of receiver.
Definition floatarray.C:683
void times(double s)
Definition floatarray.C:834
IntArray dofs
Dofs that b.c. is applied to (relevant for Dirichlet type b.c.s).
virtual bool isImposed(TimeStep *tStep)
int timeFunction
Associated load time function.
virtual bool hasField(InputFieldType id)=0
Returns true if record contains field identified by idString keyword.
int giveSize() const
Definition intarray.h:211
FloatArray componentArray
Components of boundary condition.
Definition load.h:86
virtual void computeValueAt(FloatArray &answer, TimeStep *tStep, const FloatArray &coords, ValueModeType mode)=0
bool reference
Definition load.h:101
IntArray dofExcludeMask
Definition load.h:97
#define THROW_CIOERR(e)
#define CM_Definition
Definition contextmode.h:47
#define OOFEM_ERROR(...)
Definition error.h:79
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Definition inputrecord.h:75
#define IR_GIVE_FIELD(__ir, __value, __id)
Definition inputrecord.h:67
#define _IFT_Load_components
Definition load.h:47
#define _IFT_Load_dofexcludemask
Definition load.h:48
#define _IFT_Load_reference
Definition load.h:49
long ContextMode
Definition contextmode.h:43
@ CIO_IOERR
General IO error.

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