OOFEM 3.0
Loading...
Searching...
No Matches
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 - 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 "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
48namespace oofem {
50
51MMAShapeFunctProjection :: MMAShapeFunctProjection() : MaterialMappingAlgorithm()
52{
53 stateCounter = 0;
54 domain = NULL;
55}
56
57MMAShapeFunctProjection :: ~MMAShapeFunctProjection()
58{ }
59
60void
61MMAShapeFunctProjection :: __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
91void
92MMAShapeFunctProjection :: finish(TimeStep *tStep)
93{
94 this->smootherList.clear();
95 stateCounter = -1;
96}
97
98int
99MMAShapeFunctProjection :: mapVariable(FloatArray &answer, GaussPoint *gp, InternalStateType type, TimeStep *tStep)
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
124int
125MMAShapeFunctProjection :: __mapVariable(FloatArray &answer, const FloatArray &coords,
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-1)->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
155int
156MMAShapeFunctProjection :: mapStatus(MaterialStatus &oStatus) const
157{
158 OOFEM_ERROR("not implemented yet.")
159
160}
161
162
163void
164MMAShapeFunctProjection :: interpolateIntVarAt(FloatArray &answer, Element *elem, const FloatArray &lcoords,
165 std :: vector< FloatArray > &list, InternalStateType type, TimeStep *tStep) const
166{
167 FloatArray n;
168
169 elem->giveInterpolation()->evalN( n, lcoords, FEIElementGeometryWrapper(elem) );
170
171 answer.resize(0);
172 for ( int i = 0; i < n.giveSize(); ++i ) {
173 answer.add(n[i], list[i]);
174 }
175}
176
177} // end namespace oofem
#define REGISTER_MaterialMappingAlgorithm(class, type)
virtual FEInterpolation * giveInterpolation() const
Definition element.h:648
virtual int giveNumberOfDofManagers() const
Definition element.h:695
DofManager * giveDofManager(int i) const
Definition element.C:553
virtual void evalN(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const =0
int giveNumber() const
Definition femcmpnn.h:104
void resize(Index s)
Definition floatarray.C:94
Index giveSize() const
Returns the size of receiver.
Definition floatarray.h:261
void add(const FloatArray &src)
Definition floatarray.C:218
const FloatArray & giveNaturalCoordinates() const
Returns coordinate array of receiver.
Definition gausspoint.h:138
Element * giveElement()
Returns corresponding element to receiver.
Definition gausspoint.h:187
int & at(std::size_t i)
Definition intarray.h:104
int giveSize() const
Definition intarray.h:211
void interpolateIntVarAt(FloatArray &answer, Element *elem, const FloatArray &lcoords, std ::vector< FloatArray > &list, InternalStateType type, TimeStep *tStep) const
std ::vector< std ::unique_ptr< NodalRecoveryModel > > smootherList
Smoothers.
StateCounterType stateCounter
Solution state counter.
IntArray intVarTypes
Internal variables in list.
StateCounterType giveSolutionStateCounter()
Definition timestep.h:211
#define OOFEM_ERROR(...)
Definition error.h:79

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