OOFEM
3.0
Loading...
Searching...
No Matches
src
core
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
35
#include "
prescribedgradienthomogenization.h
"
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
43
namespace
oofem
{
44
45
void
PrescribedGradientHomogenization :: initializeFrom(
InputRecord
&ir)
46
{
47
IR_GIVE_FIELD
(ir,
mGradient
,
_IFT_PrescribedGradientHomogenization_gradient
);
48
49
mCenterCoord
.resize(
mGradient
.giveNumberOfColumns() );
50
mCenterCoord
.zero();
51
IR_GIVE_OPTIONAL_FIELD
(ir,
mCenterCoord
,
_IFT_PrescribedGradientHomogenization_centercoords
)
52
}
53
54
void
PrescribedGradientHomogenization :: giveInputRecord(
DynamicInputRecord
&input)
55
{
56
input.
setField
(
mGradient
,
_IFT_PrescribedGradientHomogenization_gradient
);
57
input.
setField
(
mCenterCoord
,
_IFT_PrescribedGradientHomogenization_centercoords
);
58
}
59
60
61
void
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
94
void
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
120
double
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);
131
FEInterpolation
*fei = e->
giveInterpolation
();
132
domain_size += fei->
evalNXIntegral
( boundary,
FEIElementGeometryWrapper
(e) );
133
}
134
return
fabs(domain_size / nsd);
135
}
136
}
/* namespace oofem */
oofem::Domain
Definition
domain.h:121
oofem::Domain::giveSet
Set * giveSet(int n)
Definition
domain.C:366
oofem::Domain::giveElement
Element * giveElement(int n)
Definition
domain.C:165
oofem::Domain::giveNumberOfSpatialDimensions
int giveNumberOfSpatialDimensions()
Returns number of spatial dimensions.
Definition
domain.C:1137
oofem::DynamicInputRecord
Definition
dynamicinputrecord.h:60
oofem::DynamicInputRecord::setField
void setField(int item, InputFieldType id)
Definition
dynamicinputrecord.C:302
oofem::Element
Definition
element.h:133
oofem::Element::giveInterpolation
virtual FEInterpolation * giveInterpolation() const
Definition
element.h:648
oofem::FEIElementGeometryWrapper
Definition
feinterpol.h:108
oofem::FEInterpolation
Definition
feinterpol.h:175
oofem::FEInterpolation::evalNXIntegral
virtual double evalNXIntegral(int boundary, const FEICellGeometry &cellgeo) const
Definition
feinterpol.h:477
oofem::FloatArray
Definition
floatarray.h:92
oofem::FloatArray::at
double & at(Index i)
Definition
floatarray.h:202
oofem::FloatArray::giveSize
Index giveSize() const
Returns the size of receiver.
Definition
floatarray.h:261
oofem::InputRecord
Definition
inputrecord.h:98
oofem::IntArray
Definition
intarray.h:63
oofem::IntArray::at
int & at(std::size_t i)
Definition
intarray.h:104
oofem::IntArray::giveSize
int giveSize() const
Definition
intarray.h:211
oofem::PrescribedGradientHomogenization::mGradient
FloatMatrix mGradient
Prescribed gradient .
Definition
prescribedgradienthomogenization.h:66
oofem::PrescribedGradientHomogenization::mCenterCoord
FloatArray mCenterCoord
Center coordinate .
Definition
prescribedgradienthomogenization.h:69
oofem::Set
Definition
set.h:82
oofem::Set::giveBoundaryList
const IntArray & giveBoundaryList()
Definition
set.C:160
domain.h
dynamicinputrecord.h
element.h
OOFEM_ERROR
#define OOFEM_ERROR(...)
Definition
error.h:79
feinterpol.h
IR_GIVE_OPTIONAL_FIELD
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Definition
inputrecord.h:75
IR_GIVE_FIELD
#define IR_GIVE_FIELD(__ir, __value, __id)
Definition
inputrecord.h:67
mathfem.h
oofem
Definition
additivemanufacturingproblem.C:83
oofem::Vec4
static FloatArray Vec4(const double &a, const double &b, const double &c, const double &d)
Definition
floatarray.h:608
oofem::Vec1
static FloatArray Vec1(const double &a)
Definition
floatarray.h:605
prescribedgradienthomogenization.h
_IFT_PrescribedGradientHomogenization_centercoords
#define _IFT_PrescribedGradientHomogenization_centercoords
Definition
prescribedgradienthomogenization.h:47
_IFT_PrescribedGradientHomogenization_gradient
#define _IFT_PrescribedGradientHomogenization_gradient
Definition
prescribedgradienthomogenization.h:48
set.h
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