OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
mmashapefunctprojection.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 "dofmanager.h"
37 #include "gausspoint.h"
38 #include "element.h"
39 #include "domain.h"
40 #include "spatiallocalizer.h"
41 #include "timestep.h"
42 #include "feinterpol.h"
44 #include "classfactory.h"
45 
46 #include <cstdlib>
47 
48 namespace oofem {
49 REGISTER_MaterialMappingAlgorithm(MMAShapeFunctProjection, MMA_ShapeFunctionProjection);
50 
52 {
53  stateCounter = 0;
54  domain = NULL;
55 }
56 
58 { }
59 
60 void
61 MMAShapeFunctProjection :: __init(Domain *dold, IntArray &varTypes, const FloatArray &coords, Set &elemSet, TimeStep *tStep, bool iCohesiveZoneGP)
62 //(Domain* dold, IntArray& varTypes, GaussPoint* gp, TimeStep* tStep)
63 {
64  int nvar = varTypes.giveSize();
65  // check time stemp
66  if ( stateCounter == tStep->giveSolutionStateCounter() ) {
67  return;
68  }
69 
70 
71  // Project Gauss point components to nodes on old mesh
72  if ( (int)this->smootherList.size() != nvar ) {
73  this->smootherList.clear();
74  this->smootherList.reserve(nvar);
75  for ( int ivar = 1; ivar <= nvar; ivar++ ) {
76  this->smootherList.emplace_back( new NodalAveragingRecoveryModel(dold) );
77  }
78  }
79 
80  this->intVarTypes = varTypes;
81  for ( int ivar = 1; ivar <= nvar; ivar++ ) {
82  this->smootherList[ivar-1]->recoverValues(elemSet, ( InternalStateType ) varTypes.at(ivar), tStep);
83  }
84 
85  // remember time stemp
87  this->domain = dold;
88 }
89 
90 
91 void
93 {
94  this->smootherList.clear();
95  stateCounter = -1;
96 }
97 
98 int
100 {
101  Element *elem = gp->giveElement();
102  int nnodes = elem->giveNumberOfDofManagers();
103  std::vector< FloatArray > container;
104  const FloatArray *nvec;
105 
106  int indx = this->intVarTypes.findFirstIndexOf( ( int ) type );
107  if ( indx ) {
108  container.reserve(nnodes);
109  for ( int inode = 1; inode <= nnodes; inode++ ) {
110  this->smootherList[indx-1]->giveNodalVector( nvec, elem->giveDofManager(inode)->giveNumber() );
111  container.emplace_back(*nvec);
112  }
113 
114  this->interpolateIntVarAt(answer, elem, gp->giveNaturalCoordinates(),
115  container, type, tStep);
116  } else {
117  OOFEM_ERROR("var not initialized");
118  }
119 
120  return 1;
121 }
122 
123 
124 int
126  InternalStateType type, TimeStep *tStep)
127 {
128  FloatArray lcoords, closest;
129  Element *elem = domain->giveSpatialLocalizer()->giveElementClosestToPoint(lcoords, closest, coords);
130  if ( !elem ) {
131  OOFEM_ERROR("no suitable source found");
132  }
133 
134  int nnodes = elem->giveNumberOfDofManagers();
135  std::vector< FloatArray > container;
136  const FloatArray *nvec;
137 
138  int indx = this->intVarTypes.findFirstIndexOf( ( int ) type );
139  if ( indx ) {
140  container.reserve(nnodes);
141  for ( int inode = 1; inode <= nnodes; inode++ ) {
142  this->smootherList.at(indx)->giveNodalVector( nvec, elem->giveDofManager(inode)->giveNumber() );
143  container.emplace_back(*nvec);
144  }
145 
146  this->interpolateIntVarAt(answer, elem, lcoords, container, type, tStep);
147  } else {
148  OOFEM_ERROR("var not initialized");
149  }
150 
151  return 1;
152 }
153 
154 
155 int
157 {
158  OOFEM_ERROR("not implemented yet.")
159 
160  return 0;
161 }
162 
163 
164 void
166  std :: vector< FloatArray > &list, InternalStateType type, TimeStep *tStep) const
167 {
168  FloatArray n;
169 
170  elem->giveInterpolation()->evalN( n, lcoords, FEIElementGeometryWrapper(elem) );
171 
172  answer.resize(0);
173  for ( int i = 0; i < n.giveSize(); ++i ) {
174  answer.add(n[i], list[i]);
175  }
176 }
177 
178 } // end namespace oofem
InternalStateType
Type representing the physical meaning of element or constitutive model internal variable.
virtual void evalN(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)=0
Evaluates the array of interpolation functions (shape functions) at given point.
Class and object Domain.
Definition: domain.h:115
virtual int mapVariable(FloatArray &answer, GaussPoint *gp, InternalStateType type, TimeStep *tStep)
Maps and update the unknown of given type from old mesh oldd to new mesh to which gp belongs to...
std::vector< std::unique_ptr< NodalRecoveryModel > > smootherList
Smoothers.
IntArray intVarTypes
Internal variables in list.
Abstract base class for all finite elements.
Definition: element.h:145
The class representing the general material model mapping algorithm.
Element * giveElement()
Returns corresponding element to receiver.
Definition: gausspoint.h:188
Class implementing an array of integers.
Definition: intarray.h:61
int & at(int i)
Coefficient access function.
Definition: intarray.h:103
virtual int giveNumberOfDofManagers() const
Definition: element.h:656
virtual FEInterpolation * giveInterpolation() const
Definition: element.h:629
REGISTER_MaterialMappingAlgorithm(MMAClosestIPTransfer, MMA_ClosestPoint)
virtual int mapStatus(MaterialStatus &oStatus) const
Initializes receiver according to object description stored in input record.
virtual ~MMAShapeFunctProjection()
Destructor.
The nodal recovery model based on nodal averaging.
StateCounterType giveSolutionStateCounter()
Returns current solution state counter.
Definition: timestep.h:188
#define OOFEM_ERROR(...)
Definition: error.h:61
Set of elements, boundaries, edges and/or nodes.
Definition: set.h:66
SpatialLocalizer * giveSpatialLocalizer()
Returns receiver&#39;s associated spatial localizer.
Definition: domain.C:1184
Wrapper around element definition to provide FEICellGeometry interface.
Definition: feinterpol.h:95
void interpolateIntVarAt(FloatArray &answer, Element *elem, const FloatArray &lcoords, std::vector< FloatArray > &list, InternalStateType type, TimeStep *tStep) const
Abstract base class representing a material status information.
Definition: matstatus.h:84
Class representing vector of real numbers.
Definition: floatarray.h:82
StateCounterType stateCounter
Solution state counter.
virtual int __mapVariable(FloatArray &answer, const FloatArray &coords, InternalStateType type, TimeStep *tStep)
Maps and update the unknown of given type from old mesh oldd to new mesh to which gp belongs to...
virtual Element * giveElementClosestToPoint(FloatArray &lcoords, FloatArray &closest, const FloatArray &coords, int region=0)=0
Returns the element closest to a given point.
int giveSize() const
Definition: intarray.h:203
int giveSize() const
Returns the size of receiver.
Definition: floatarray.h:218
the oofem namespace is to define a context or scope in which all oofem names are defined.
DofManager * giveDofManager(int i) const
Definition: element.C:514
virtual void finish(TimeStep *tStep)
Finishes the mapping for given time step.
int giveNumber() const
Definition: femcmpnn.h:107
Class representing integration point in finite element program.
Definition: gausspoint.h:93
Class representing solution step.
Definition: timestep.h:80
void add(const FloatArray &src)
Adds array src to receiver.
Definition: floatarray.C:156
virtual void __init(Domain *dold, IntArray &type, const FloatArray &coords, Set &sourceElemSet, TimeStep *tStep, bool iCohesiveZoneGP=false)
Initializes the receiver state before mapping.
int findFirstIndexOf(int value) const
Finds index of first occurrence of given value in array.
Definition: intarray.C:331
const FloatArray & giveNaturalCoordinates()
Returns coordinate array of receiver.
Definition: gausspoint.h:138
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