OOFEM 3.0
Loading...
Searching...
No Matches
stressstrainbasevector.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 "intarray.h"
37#include "floatmatrix.h"
38#include "error.h"
39#include "datastream.h"
40#include "materialmode.h"
42#include "datastream.h"
43
44namespace oofem {
45StressStrainBaseVector :: StressStrainBaseVector(MaterialMode m) : FloatArray()
46{
47 this->resize( StructuralMaterial :: giveSizeOfVoigtSymVector(m) );
48 this->zero();
49 this->mode = m;
50}
51
52StressStrainBaseVector :: StressStrainBaseVector(const FloatArray &src, MaterialMode m) : FloatArray(src)
53{
54 if ( StructuralMaterial :: giveSizeOfVoigtSymVector(m) != src.giveSize() ) {
55 OOFEM_ERROR( "The source has size %d and a new MaterialMode %s has reduced size %d", (int)src.giveSize(), __MaterialModeToString(m), (int)StructuralMaterial :: giveSizeOfVoigtSymVector(m) );
56 }
57
58 this->mode = m;
59}
60
62StressStrainBaseVector :: operator = ( const StressStrainBaseVector & src )
63{
64 if ( this != & src ) { // beware of s=s;
65 this->resize(src.size()); // FIXME: useless zero-assignment
66 for(Index i=0; i<this->size(); i++) (*this)[i]=src[i];
67 }
68
69 this->mode = src.mode;
70 return * this;
71}
72
73void
74StressStrainBaseVector :: convertToFullForm(FloatArray &answer) const
75{
76 IntArray indx;
77 int answerSize = 6;
78
79 if ( mode == _3dMat ) {
80 answer = * this;
81 return;
82 }
83
84 answer.resize(answerSize);
85 answer.zero();
86
87 StructuralMaterial :: giveVoigtSymVectorMask(indx, ( MaterialMode ) mode);
88 answer.assemble(* this, indx);
89}
90
91void
92StressStrainBaseVector :: convertFromFullForm(const FloatArray &vector, MaterialMode mode)
93{
94 IntArray indx;
95
96 if ( mode == _3dMat ) {
97 if ( this->giveSize() != 6 ) {
98 OOFEM_ERROR("full vector size mismatch");
99 }
100
101 this->resize(6);
102 for ( int i = 1; i <= 6; i++ ) {
103 this->at(i) = vector.at(i);
104 }
105 } else {
106 StructuralMaterial :: giveVoigtSymVectorMask(indx, mode);
107 this->resize( StructuralMaterial :: giveSizeOfVoigtSymVector(mode) );
108 this->zero();
109
110 for ( int i = 1; i <= indx.giveSize(); i++ ) {
111 int j;
112 if ( ( j = indx.at(i) ) ) {
113 this->at(i) = vector.at(j);
114 }
115 }
116 }
117}
118
119
121StressStrainBaseVector :: storeYourself(DataStream &stream)
122{
124 if ( ( iores = FloatArray :: storeYourself(stream) ) != CIO_OK ) {
125 return CIO_OK;
126 }
127
128 // write material mode
129 if ( !stream.write((int)mode) ) {
130 return CIO_IOERR;
131 }
132
133 return CIO_OK;
134}
135
137StressStrainBaseVector :: restoreYourself(DataStream &stream)
138{
140 if ( ( iores = FloatArray :: restoreYourself(stream) ) != CIO_OK ) {
141 return iores;
142 }
143
144 // read material mode
145 int val;
146 if ( !stream.read(val) ) {
147 return CIO_IOERR;
148 }
150
151 return CIO_OK;
152}
153
154
155void
156StressStrainBaseVector :: letStressStrainModeBe(const MaterialMode newMode)
157{
158 this->mode = ( StressStrainMatMode ) newMode;
159 this->resize( StructuralMaterial :: giveSizeOfVoigtSymVector(newMode) );
160 this->zero();
161}
162
163void
164StressStrainBaseVector :: transformTo(StressStrainBaseVector &answer, const FloatMatrix &base, int transpose) const
165//
166//
167// performs transformation of given vector to another system of axes,
168// given by base.
169// In base (FloatMatrix[3,3]) there are on each column stored vectors of
170// coordinate system to which we do transformation. These vectors must
171// be expressed in the same coordinate system as strainVector
172// If transpose == 1 we transpose base matrix before transforming
173//
174
175{
176 FloatMatrix tt;
177 FloatArray fullReceiver, fullAnswer;
178
179 this->giveTranformationMtrx(tt, base, transpose);
180 // convert receiver to full mode
181 this->convertToFullForm(fullReceiver);
182 fullAnswer.beProductOf(tt, fullReceiver);
183 // convert back to reduced form
184 answer.convertFromFullForm( fullAnswer, this->giveStressStrainMode() );
185}
186
187double
188StressStrainBaseVector :: computeVolumetricPart() const
189{
190 MaterialMode myMode = this->giveStressStrainMode();
191
192 if ( myMode == _1dMat ) {
193 // 1D model
194 OOFEM_ERROR("No Split for 1D!");
195 } else if ( myMode == _PlaneStress ) {
196 // plane stress problem
197 OOFEM_ERROR("No Split for plane stress!");
198 } else {
199 // 3d, plane strain or axisymmetric problem
200 return ( this->at(1) + this->at(2) + this->at(3) ) / 3.0;
201 }
202}
203} // 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.
Index size() const
Definition floatarray.h:162
void assemble(const FloatArray &fe, const IntArray &loc)
Definition floatarray.C:616
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 zero()
Zeroes all coefficients of receiver.
Definition floatarray.C:683
void beProductOf(const FloatMatrix &aMatrix, const FloatArray &anArray)
Definition floatarray.C:689
friend class FloatMatrix
Definition floatarray.h:551
FloatArray(int n=0)
Constructor for sized array. Data is zeroed.
Definition floatarray.h:117
int & at(std::size_t i)
Definition intarray.h:104
int giveSize() const
Definition intarray.h:211
StressStrainBaseVector(MaterialMode)
Constructor. Creates zero value stress/strain vector for given material mode.
StressStrainMatMode mode
Stress strain mode.
MaterialMode giveStressStrainMode() const
Returns the material mode of receiver.
virtual void giveTranformationMtrx(FloatMatrix &answer, const FloatMatrix &base, int transpose=0) const =0
void convertToFullForm(FloatArray &fullform) const
#define OOFEM_ERROR(...)
Definition error.h:79
FloatMatrixF< M, N > transpose(const FloatMatrixF< N, M > &mat)
Constructs transposed matrix.
MaterialMode StressStrainMatMode
int Index
Definition numerics.h:73
FloatMatrixF< N, M > zero()
Constructs a zero matrix (this is the default behavior when constructing a matrix,...
@ 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