OOFEM 3.0
Loading...
Searching...
No Matches
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 - 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 "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#include "paramkey.h"
44
45namespace oofem {
47
50
51HangingNode :: HangingNode(int n, Domain *aDomain) : Node(n, aDomain)
52{
53#ifdef __OOFEG
54 initialized = false;
55#endif
56}
57
58void HangingNode :: initializeFrom(InputRecord &ir, int priority)
59{
60 ParameterManager &ppm = this->giveDomain()->dofmanPPM;
61
62 Node :: initializeFrom(ir, priority);
65}
66
67int HangingNode :: checkConsistency()
68{
69 int result = Node :: checkConsistency();
70
71 if (this->masterElement == 0){
72 OOFEM_ERROR("Master element not specified or determined for hanging node %d.\nHas postInitialize() method been called before? ", this->giveNumber());
73 result = 0;
74 }
75 return result;
76
77
78
79#if 0
80 // Check if master is in same mode
82 for ( int i = 1; i <= countOfMasterNodes; i++ ) {
83 if ( e->giveNode(i)->giveParallelMode() != parallel_mode ) {
84 OOFEM_WARNING("Mismatch in parallel mode of HangingNode and master");
85 return false;
86 }
87 }
88 }
89#endif
90
91 Element *e = this->domain->giveGlobalElement(this->masterElement);
92 // Check local coordinate systems
93 for ( int i = 1; i <= e->giveNumberOfNodes(); ++i ) {
94 if ( !this->hasSameLCS( e->giveNode(i) ) ) {
95 OOFEM_WARNING("Different lcs for master/slave nodes.");
96 result = false;
97 }
98 }
99 return result;
100}
101
102void HangingNode :: postInitialize()
103{
104 Node :: postInitialize();
105
106 Element *e;
107 FEInterpolation *fei;
108 FloatArray lcoords, masterContribution;
109
110#ifdef __OOFEG
111 if ( initialized ) {
112 return;
113 }
114 initialized = true;
115#endif
116
117 // First check element and interpolation
118 if ( masterElement == 0 ) { // Then we find it by taking the closest (probably containing element)
119 FloatArray closest;
120 SpatialLocalizer *sp = this->domain->giveSpatialLocalizer();
121 sp->init();
122 // Closest point or containing point? It should be contained, but with numerical errors it might be slightly outside
123 // so the closest point is more robust.
124 if ( !( e = sp->giveElementClosestToPoint(lcoords, closest, coordinates, this->masterRegion) ) ) {
125 OOFEM_ERROR("Couldn't find closest element (automatically).");
126 }
127 this->masterElement = e->giveNumber();
128 # ifdef DEBUG
129 OOFEM_LOG_INFO("Found element %d for hanging node %d\n", e->giveGlobalNumber(), this->giveNumber() );
130 #endif
131 } else if ( !( e = this->giveDomain()->giveGlobalElement(this->masterElement) ) ) {
132 OOFEM_ERROR("Requested element %d doesn't exist.", this->masterElement);
133 }
134 if ( !( fei = e->giveInterpolation() ) ) {
135 OOFEM_ERROR("Requested element %d doesn't have a interpolator.", this->masterElement);
136 }
137
138 if ( lcoords.giveSize() == 0 ) { // we don't need to do this again if the spatial localizer was used.
140 }
141
142 // Initialize slave dofs (inside check of consistency of receiver and master dof)
143 const IntArray &masterNodes = e->giveDofManArray();
144 for ( Dof *dof: *this ) {
145 SlaveDof *sdof = dynamic_cast< SlaveDof * >(dof);
146 if ( sdof ) {
147 DofIDItem id = sdof->giveDofID();
148 fei = e->giveInterpolation(id);
149 if ( !fei ) {
150 OOFEM_ERROR("Requested interpolation for dof id %d doesn't exist in element %d.",
151 id, this->masterElement);
152 }
153#if 0 // This won't work (yet), as it requires some more general FEI classes, or something similar.
154 if ( fei->hasMultiField() ) {
155 FloatMatrix multiContribution;
156 IntArray masterDofIDs, masterNodesDup, dofids;
157 fei->evalMultiN(multiContribution, dofids, lcoords, FEIElementGeometryWrapper(e), 0.0);
158 masterContribution.flatten(multiContribution);
159 masterDofIDs.clear();
160 for ( int i = 0; i <= multiContribution.giveNumberOfColumns(); ++i ) {
161 masterDofIDs.followedBy(dofids);
162 masterNodesDup.followedBy(masterNodes);
163 }
164 sdof->initialize(masterNodesDup, & masterDofIDs, masterContribution);
165 } else { }
166#else
167 // Note: There can be more masterNodes than masterContributions, since all the
168 // FEI classes are based on that the first nodes correspond to the simpler/linear interpolation.
169 // If this assumption is changed in FEIElementGeometryWrapper + friends,
170 // masterNode will also need to be modified for each dof accordingly.
171 fei->evalN( masterContribution, lcoords, FEIElementGeometryWrapper(e) );
172 sdof->initialize(masterNodes, IntArray(), masterContribution);
173#endif
174 }
175 }
176}
177} // end namespace oofem
#define REGISTER_DofManager(class)
dofManagerParallelMode parallel_mode
Definition dofmanager.h:123
FloatArray coordinates
Array storing nodal coordinates.
Definition dofmanager.h:103
DofIDItem giveDofID() const
Definition dof.h:276
int giveGlobalNumber() const
Definition element.h:1129
Node * giveNode(int i) const
Definition element.h:629
virtual FEInterpolation * giveInterpolation() const
Definition element.h:648
virtual int giveNumberOfNodes() const
Definition element.h:703
const IntArray & giveDofManArray() const
Definition element.h:611
virtual int global2local(FloatArray &answer, const FloatArray &gcoords, const FEICellGeometry &cellgeo) const =0
virtual void evalN(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const =0
Domain * giveDomain() const
Definition femcmpnn.h:97
Domain * domain
Link to domain object, useful for communicating with other FEM components.
Definition femcmpnn.h:79
int number
Component number.
Definition femcmpnn.h:77
int giveNumber() const
Definition femcmpnn.h:104
Index giveSize() const
Returns the size of receiver.
Definition floatarray.h:261
int giveNumberOfColumns() const
Returns number of columns of receiver.
int masterElement
Number of the master element.
Definition hangingnode.h:67
bool initialized
Flag whether node is fully initialized already.
Definition hangingnode.h:72
static ParamKey IPK_HangingNode_masterRegion
Definition hangingnode.h:76
static ParamKey IPK_HangingNode_masterElement
Definition hangingnode.h:75
int masterRegion
Region of the master element (used for automatic detection).
Definition hangingnode.h:69
void followedBy(const IntArray &b, int allocChunk=0)
Definition intarray.C:94
Node(int n, Domain *aDomain)
Definition node.C:73
bool hasSameLCS(Node *remote)
Definition node.C:375
void initialize(const IntArray &masterNodes, const IntArray &mstrDofID, const FloatArray &mstrContribution)
Definition slavedof.C:52
virtual int init(bool force=false)
virtual Element * giveElementClosestToPoint(FloatArray &lcoords, FloatArray &closest, const FloatArray &coords, int region=0)=0
#define OOFEM_WARNING(...)
Definition error.h:80
#define OOFEM_ERROR(...)
Definition error.h:79
#define OOFEM_LOG_INFO(...)
Definition logger.h:143
@ DofManager_local
Definition dofmanager.h:67
#define PM_UPDATE_PARAMETER(_val, _pm, _ir, _componentnum, _paramkey, _prio)

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