OOFEM 3.0
Loading...
Searching...
No Matches
prescribedgradienthomogenization.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 "domain.h"
37#include "dynamicinputrecord.h"
38#include "set.h"
39#include "feinterpol.h"
40#include "element.h"
41#include "mathfem.h"
42
43namespace oofem {
44
45void PrescribedGradientHomogenization :: initializeFrom(InputRecord &ir)
46{
48
49 mCenterCoord.resize( mGradient.giveNumberOfColumns() );
50 mCenterCoord.zero();
52}
53
54void PrescribedGradientHomogenization :: giveInputRecord(DynamicInputRecord &input)
55{
58}
59
60
61void PrescribedGradientHomogenization :: setPrescribedGradientVoigt(const FloatArray &t)
62{
63 int n = t.giveSize();
64 if ( n == 3 ) { // Then 2D
65 this->mGradient.resize(2, 2);
66 this->mGradient.at(1, 1) = t.at(1);
67 this->mGradient.at(2, 2) = t.at(2);
68 // In voigt form, assuming the use of gamma_12 instead of eps_12
69 this->mGradient.at(1, 2) = this->mGradient.at(2, 1) = t.at(3) * 0.5;
70 } else if ( n == 4 ) { // Then 2D
71 this->mGradient.resize(2, 2);
72 this->mGradient.at(1, 1) = t.at(1);
73 this->mGradient.at(2, 2) = t.at(2);
74 // In voigt form, assuming the use of gamma_12 instead of eps_12
75 this->mGradient.at(1, 2) = this->mGradient.at(2, 1) = t.at(4) * 0.5;
76 } else if ( n == 6 ) { // Then 3D
77 this->mGradient.resize(3, 3);
78 this->mGradient.at(1, 1) = t.at(1);
79 this->mGradient.at(2, 2) = t.at(2);
80 this->mGradient.at(3, 3) = t.at(3);
81 // In voigt form, assuming the use of gamma_12 instead of eps_12
82 this->mGradient.at(1, 2) = this->mGradient.at(2, 1) = t.at(6) * 0.5;
83 this->mGradient.at(1, 3) = this->mGradient.at(3, 1) = t.at(5) * 0.5;
84 this->mGradient.at(2, 3) = this->mGradient.at(3, 2) = t.at(4) * 0.5;
85 } else if ( n == 1 ) {
86 this->mGradient.resize(1, 1);
87 this->mGradient.at(1, 1) = t.at(1);
88 } else {
89 OOFEM_ERROR("Tensor is in strange voigt format. Should be 3 or 6. Use setPrescribedGradient directly if needed.");
90 }
91}
92
93
94void PrescribedGradientHomogenization :: giveGradientVoigt(FloatArray &oGradient) const
95{
96 int numRows = mGradient.giveNumberOfRows();
97 switch ( numRows ) {
98 case 1:
99 oGradient = Vec1(
100 mGradient.at(1, 1)
101 );
102 break;
103 case 2:
104 // Do not assume symmetry
105 oGradient = Vec4(
106 mGradient.at(1, 1), mGradient.at(2, 2), mGradient.at(1, 2), mGradient.at(2, 1)
107 );
108 break;
109 case 3:
110 // TODO: Fix this properly.
111 oGradient = Vec4(
112 mGradient.at(1, 1), mGradient.at(2, 2), mGradient.at(1, 2), mGradient.at(2, 1)
113 );
114// OOFEM_ERROR("PrescribedGradientHomogenization :: giveGradientVoigt() not implemented for 3 rows.\n")
115 break;
116 }
117}
118
119
120double PrescribedGradientHomogenization :: domainSize(Domain *d, int setNum)
121{
122 int nsd = d->giveNumberOfSpatialDimensions();
123 double domain_size = 0.0;
124 // This requires the boundary to be consistent and ordered correctly.
125 Set *set = d->giveSet(setNum);
126 const IntArray &boundaries = set->giveBoundaryList();
127
128 for ( int pos = 1; pos <= boundaries.giveSize() / 2; ++pos ) {
129 Element *e = d->giveElement( boundaries.at(pos * 2 - 1) );
130 int boundary = boundaries.at(pos * 2);
132 domain_size += fei->evalNXIntegral( boundary, FEIElementGeometryWrapper(e) );
133 }
134 return fabs(domain_size / nsd);
135}
136} /* namespace oofem */
Set * giveSet(int n)
Definition domain.C:366
Element * giveElement(int n)
Definition domain.C:165
int giveNumberOfSpatialDimensions()
Returns number of spatial dimensions.
Definition domain.C:1137
void setField(int item, InputFieldType id)
virtual FEInterpolation * giveInterpolation() const
Definition element.h:648
virtual double evalNXIntegral(int boundary, const FEICellGeometry &cellgeo) const
Definition feinterpol.h:477
double & at(Index i)
Definition floatarray.h:202
Index giveSize() const
Returns the size of receiver.
Definition floatarray.h:261
int & at(std::size_t i)
Definition intarray.h:104
int giveSize() const
Definition intarray.h:211
const IntArray & giveBoundaryList()
Definition set.C:160
#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
static FloatArray Vec4(const double &a, const double &b, const double &c, const double &d)
Definition floatarray.h:608
static FloatArray Vec1(const double &a)
Definition floatarray.h:605
#define _IFT_PrescribedGradientHomogenization_centercoords
#define _IFT_PrescribedGradientHomogenization_gradient

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