OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
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 - 2013 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 
43 namespace oofem {
44 
46 {
47  IRResultType result; // Required by IR_GIVE_FIELD macro
48 
50 
54 
55  return IRRT_OK;
56 }
57 
59 {
62 }
63 
64 
66 {
67  int n = t.giveSize();
68  if ( n == 3 ) { // Then 2D
69  this->mGradient.resize(2, 2);
70  this->mGradient.at(1, 1) = t.at(1);
71  this->mGradient.at(2, 2) = t.at(2);
72  // In voigt form, assuming the use of gamma_12 instead of eps_12
73  this->mGradient.at(1, 2) = this->mGradient.at(2, 1) = t.at(3) * 0.5;
74  } else if ( n == 6 ) { // Then 3D
75  this->mGradient.resize(3, 3);
76  this->mGradient.at(1, 1) = t.at(1);
77  this->mGradient.at(2, 2) = t.at(2);
78  this->mGradient.at(3, 3) = t.at(3);
79  // In voigt form, assuming the use of gamma_12 instead of eps_12
80  this->mGradient.at(1, 2) = this->mGradient.at(2, 1) = t.at(6) * 0.5;
81  this->mGradient.at(1, 3) = this->mGradient.at(3, 1) = t.at(5) * 0.5;
82  this->mGradient.at(2, 3) = this->mGradient.at(3, 2) = t.at(4) * 0.5;
83  } else if ( n == 1 ) {
84  this->mGradient.resize(1, 1);
85  this->mGradient.at(1, 1) = t.at(1);
86  } else {
87  OOFEM_ERROR("Tensor is in strange voigt format. Should be 3 or 6. Use setPrescribedGradient directly if needed.");
88  }
89 }
90 
91 
93 {
94  int numRows = mGradient.giveNumberOfRows();
95  switch ( numRows ) {
96  case 1:
97  oGradient = FloatArray {
98  mGradient.at(1, 1)
99  };
100  break;
101  case 2:
102  // Do not assume symmetry
103  oGradient = {
104  mGradient.at(1, 1), mGradient.at(2, 2), mGradient.at(1, 2), mGradient.at(2, 1)
105  };
106  break;
107  case 3:
108  // TODO: Fix this properly.
109  oGradient = {
110  mGradient.at(1, 1), mGradient.at(2, 2), mGradient.at(1, 2), mGradient.at(2, 1)
111  };
112 // OOFEM_ERROR("PrescribedGradientHomogenization :: giveGradientVoigt() not implemented for 3 rows.\n")
113  break;
114  }
115 }
116 
117 
119 {
120  int nsd = d->giveNumberOfSpatialDimensions();
121  double domain_size = 0.0;
122  // This requires the boundary to be consistent and ordered correctly.
123  Set *set = d->giveSet(setNum);
124  const IntArray &boundaries = set->giveBoundaryList();
125 
126  for ( int pos = 1; pos <= boundaries.giveSize() / 2; ++pos ) {
127  Element *e = d->giveElement( boundaries.at(pos * 2 - 1) );
128  int boundary = boundaries.at(pos * 2);
130  domain_size += fei->evalNXIntegral( boundary, FEIElementGeometryWrapper(e) );
131  }
132  return fabs(domain_size / nsd);
133 }
134 } /* namespace oofem */
void setField(int item, InputFieldType id)
int giveNumberOfColumns() const
Returns number of columns of receiver.
Definition: floatmatrix.h:158
Class and object Domain.
Definition: domain.h:115
virtual void giveInputRecord(DynamicInputRecord &input)
void setPrescribedGradientVoigt(const FloatArray &t)
Sets the prescribed gradient from the matrix from given voigt notation.
double & at(int i)
Coefficient access function.
Definition: floatarray.h:131
#define _IFT_PrescribedGradientHomogenization_centercoords
Abstract base class for all finite elements.
Definition: element.h:145
virtual double evalNXIntegral(int boundary, const FEICellGeometry &cellgeo)
Computes the integral .
Definition: feinterpol.h:420
int giveNumberOfSpatialDimensions()
Returns number of spatial dimensions.
Definition: domain.C:1067
Class implementing an array of integers.
Definition: intarray.h:61
int & at(int i)
Coefficient access function.
Definition: intarray.h:103
virtual FEInterpolation * giveInterpolation() const
Definition: element.h:629
Class representing a general abstraction for finite element interpolation class.
Definition: feinterpol.h:132
Element * giveElement(int n)
Service for accessing particular domain fe element.
Definition: domain.C:160
#define OOFEM_ERROR(...)
Definition: error.h:61
Set of elements, boundaries, edges and/or nodes.
Definition: set.h:66
Wrapper around element definition to provide FEICellGeometry interface.
Definition: feinterpol.h:95
Set * giveSet(int n)
Service for accessing particular domain set.
Definition: domain.C:363
double at(int i, int j) const
Coefficient access function.
Definition: floatmatrix.h:176
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
Class representing vector of real numbers.
Definition: floatarray.h:82
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
void resize(int rows, int cols)
Checks size of receiver towards requested bounds.
Definition: floatmatrix.C:1358
Class representing the general Input Record.
Definition: inputrecord.h:101
void zero()
Zeroes all coefficients of receiver.
Definition: floatarray.C:658
Class representing the a dynamic Input Record.
void giveGradientVoigt(FloatArray &oGradient) const
Gives back the applied gradient in Voigt form.
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:78
int giveSize() const
Definition: intarray.h:203
int giveSize() const
Returns the size of receiver.
Definition: floatarray.h:218
#define _IFT_PrescribedGradientHomogenization_gradient
the oofem namespace is to define a context or scope in which all oofem names are defined.
#define IR_GIVE_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:69
int giveNumberOfRows() const
Returns number of rows of receiver.
Definition: floatmatrix.h:156
void resize(int s)
Resizes receiver towards requested size.
Definition: floatarray.C:631

This page is part of the OOFEM documentation. Copyright (c) 2011 Borek Patzak
Project e-mail: info@oofem.org
Generated at Tue Jan 2 2018 20:07:30 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011