OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
hangingnode.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 
35 #include "hangingnode.h"
36 #include "slavedof.h"
37 #include "floatarray.h"
38 #include "intarray.h"
39 #include "element.h"
40 #include "feinterpol.h"
41 #include "spatiallocalizer.h"
42 #include "classfactory.h"
43 
44 namespace oofem {
45 REGISTER_DofManager(HangingNode);
46 
47 HangingNode :: HangingNode(int n, Domain *aDomain) : Node(n, aDomain)
48 {
49 #ifdef __OOFEG
50  initialized = false;
51 #endif
52 }
53 
55 {
56  IRResultType result; // Required by IR_GIVE_FIELD macro
57 
58  this->masterElement = -1;
60  this->masterRegion = 0;
62  return Node :: initializeFrom(ir);
63 }
64 
66 {
67  Element *e = this->domain->giveElement(this->masterElement);
68  int result = Node :: checkConsistency();
69 
70 #if 0
71  // Check if master is in same mode
73  for ( int i = 1; i <= countOfMasterNodes; i++ ) {
74  if ( e->giveNode(i)->giveParallelMode() != parallel_mode ) {
75  OOFEM_WARNING("Mismatch in parallel mode of HangingNode and master");
76  return false;
77  }
78  }
79  }
80 #endif
81 
82  // Check local coordinate systems
83  for ( int i = 1; i <= e->giveNumberOfNodes(); ++i ) {
84  if ( !this->hasSameLCS( e->giveNode(i) ) ) {
85  OOFEM_WARNING("Different lcs for master/slave nodes.");
86  result = false;
87  }
88  }
89  return result;
90 }
91 
93 {
95 
96  Element *e;
97  FEInterpolation *fei;
98  FloatArray lcoords, masterContribution;
99 
100 #ifdef __OOFEG
101  if ( initialized ) {
102  return;
103  }
104  initialized = true;
105 #endif
106 
107  // First check element and interpolation
108  if ( masterElement == -1 ) { // Then we find it by taking the closest (probably containing element)
109  FloatArray closest;
111  sp->init();
112  // Closest point or containing point? It should be contained, but with numerical errors it might be slightly outside
113  // so the closest point is more robust.
114  if ( !( e = sp->giveElementClosestToPoint(lcoords, closest, coordinates, this->masterRegion) ) ) {
115  OOFEM_ERROR("Couldn't find closest element (automatically).");
116  }
117  this->masterElement = e->giveNumber();
118  } else if ( !( e = this->giveDomain()->giveElement(this->masterElement) ) ) {
119  OOFEM_ERROR("Requested element %d doesn't exist.", this->masterElement);
120  }
121  if ( !( fei = e->giveInterpolation() ) ) {
122  OOFEM_ERROR("Requested element %d doesn't have a interpolator.", this->masterElement);
123  }
124 
125  if ( lcoords.giveSize() == 0 ) { // we don't need to do this again if the spatial localizer was used.
127  }
128 
129  // Initialize slave dofs (inside check of consistency of receiver and master dof)
130  const IntArray &masterNodes = e->giveDofManArray();
131  for ( Dof *dof: *this ) {
132  SlaveDof *sdof = dynamic_cast< SlaveDof * >(dof);
133  if ( sdof ) {
134  DofIDItem id = sdof->giveDofID();
135  fei = e->giveInterpolation(id);
136  if ( !fei ) {
137  OOFEM_ERROR("Requested interpolation for dof id %d doesn't exist in element %d.",
138  id, this->masterElement);
139  }
140 #if 0 // This won't work (yet), as it requires some more general FEI classes, or something similar.
141  if ( fei->hasMultiField() ) {
142  FloatMatrix multiContribution;
143  IntArray masterDofIDs, masterNodesDup, dofids;
144  fei->evalMultiN(multiContribution, dofids, lcoords, FEIElementGeometryWrapper(e), 0.0);
145  masterContribution.flatten(multiContribution);
146  masterDofIDs.clear();
147  for ( int i = 0; i <= multiContribution.giveNumberOfColumns(); ++i ) {
148  masterDofIDs.followedBy(dofids);
149  masterNodesDup.followedBy(masterNodes);
150  }
151  sdof->initialize(masterNodesDup, & masterDofIDs, masterContribution);
152  } else { }
153 #else
154  // Note: There can be more masterNodes than masterContributions, since all the
155  // FEI classes are based on that the first nodes correspond to the simpler/linear interpolation.
156  // If this assumption is changed in FEIElementGeometryWrapper + friends,
157  // masterNode will also need to be modified for each dof accordingly.
158  fei->evalN( masterContribution, lcoords, FEIElementGeometryWrapper(e) );
159  sdof->initialize(masterNodes, IntArray(), masterContribution);
160 #endif
161  }
162  }
163 }
164 } // end namespace oofem
The base class for all spatial localizers.
int giveNumberOfColumns() const
Returns number of columns of receiver.
Definition: floatmatrix.h:158
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
Domain * domain
Link to domain object, useful for communicating with other FEM components.
Definition: femcmpnn.h:82
virtual void postInitialize()
Performs post-initialization such like checking if there are any slave dofs etc.
Definition: dofmanager.C:862
virtual int checkConsistency()
Allows programmer to test some internal data, before computation begins.
Definition: node.C:325
Abstract base class for all finite elements.
Definition: element.h:145
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
Definition: node.C:93
Class implementing an array of integers.
Definition: intarray.h:61
virtual FEInterpolation * giveInterpolation() const
Definition: element.h:629
int masterRegion
Region of the master element (used for automatic detection).
Definition: hangingnode.h:70
bool hasSameLCS(Node *remote)
Returns true, if the local coordinate systems of receiver and given node are the same.
Definition: node.C:387
#define _IFT_HangingNode_masterElement
Definition: hangingnode.h:43
virtual int giveNumberOfNodes() const
Returns number of nodes of receiver.
Definition: element.h:662
Class representing a general abstraction for finite element interpolation class.
Definition: feinterpol.h:132
const IntArray & giveDofManArray() const
Definition: element.h:592
Element * giveElement(int n)
Service for accessing particular domain fe element.
Definition: domain.C:160
REGISTER_DofManager(ElementSide)
#define OOFEM_ERROR(...)
Definition: error.h:61
void initialize(const IntArray &masterNodes, const IntArray &mstrDofID, const FloatArray &mstrContribution)
Definition: slavedof.C:52
void clear()
Clears the array (zero size).
Definition: intarray.h:177
DofIDItem
Type representing particular dof type.
Definition: dofiditem.h:86
SpatialLocalizer * giveSpatialLocalizer()
Returns receiver&#39;s associated spatial localizer.
Definition: domain.C:1184
DofIDItem giveDofID() const
Returns DofID value of receiver, which determines type of of unknown connected to receiver (e...
Definition: dof.h:276
Wrapper around element definition to provide FEICellGeometry interface.
Definition: feinterpol.h:95
virtual int global2local(FloatArray &answer, const FloatArray &gcoords, const FEICellGeometry &cellgeo)=0
Evaluates local coordinates from given global ones.
virtual void postInitialize()
Performs post-initialization such like checking if there are any slave dofs etc.
Definition: hangingnode.C:92
FloatArray coordinates
Array storing nodal coordinates.
Definition: node.h:91
Class representing vector of real numbers.
Definition: floatarray.h:82
virtual int init(bool force=false)
Initialize receiver data structure if not done previously If force is set to true, the initialization is enforced (useful if domain geometry has changed)
dofManagerParallelMode parallel_mode
Definition: dofmanager.h:134
Implementation of matrix containing floating point numbers.
Definition: floatmatrix.h:94
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
virtual int checkConsistency()
Allows programmer to test some internal data, before computation begins.
Definition: hangingnode.C:65
virtual Element * giveElementClosestToPoint(FloatArray &lcoords, FloatArray &closest, const FloatArray &coords, int region=0)=0
Returns the element closest to a given point.
Class representing the general Input Record.
Definition: inputrecord.h:101
void followedBy(const IntArray &b, int allocChunk=0)
Appends array b at the end of receiver.
Definition: intarray.C:145
HangingNode(int n, Domain *aDomain)
Constructor.
Definition: hangingnode.C:47
#define _IFT_HangingNode_masterRegion
Definition: hangingnode.h:44
Domain * giveDomain() const
Definition: femcmpnn.h:100
bool initialized
Flag whether node is fully initialized already.
Definition: hangingnode.h:73
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:78
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.
Class implementing node in finite element mesh.
Definition: node.h:87
Abstract class Dof represents Degree Of Freedom in finite element mesh.
Definition: dof.h:93
int giveNumber() const
Definition: femcmpnn.h:107
Node * giveNode(int i) const
Returns reference to the i-th node of element.
Definition: element.h:610
DofManager is local, there are no contribution from other domains to this DofManager.
Definition: dofmanager.h:81
#define OOFEM_WARNING(...)
Definition: error.h:62
Class representing "slave" degree of freedom.
Definition: slavedof.h:47
dofManagerParallelMode giveParallelMode() const
Return dofManagerParallelMode of receiver.
Definition: dofmanager.h:512
int masterElement
Number of the master element.
Definition: hangingnode.h:68
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
Definition: hangingnode.C:54

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:29 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011