OOFEM 3.0
Loading...
Searching...
No Matches
eleminterpunknownmapper.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 "element.h"
37#include "domain.h"
38#include "engngm.h"
39#include "spatiallocalizer.h"
40#include "node.h"
41#include "dof.h"
42#include "connectivitytable.h"
44
45namespace oofem {
46EIPrimaryUnknownMapper :: EIPrimaryUnknownMapper() : PrimaryUnknownMapper()
47{ }
48
49#define OOFEM_MAPPING_CHECK_REGIONS
50
51int
52EIPrimaryUnknownMapper :: mapAndUpdate(FloatArray &answer, ValueModeType mode,
53 Domain *oldd, Domain *newd, TimeStep *tStep)
54{
55 int inode, nd_nnodes = newd->giveNumberOfDofManagers();
57 FloatArray unknownValues;
58 IntArray dofidMask;
59 IntArray reglist;
60#ifdef OOFEM_MAPPING_CHECK_REGIONS
61 ConnectivityTable *conTable = newd->giveConnectivityTable();
62 const IntArray *nodeConnectivity;
63#endif
64
65 answer.resize(nsize);
66 answer.zero();
67
68 for ( inode = 1; inode <= nd_nnodes; inode++ ) {
69 DofManager *node = newd->giveNode(inode);
70 /* Process local and shared nodes only */
71 if ( (node->giveParallelMode() != DofManager_local ) &&
73 continue;
74 }
75
76#ifdef OOFEM_MAPPING_CHECK_REGIONS
77 // build up region list for node
78 nodeConnectivity = conTable->giveDofManConnectivityArray(inode);
79 reglist.resize( nodeConnectivity->giveSize() );
80 reglist.clear();
81 for ( int indx = 1; indx <= nodeConnectivity->giveSize(); indx++ ) {
82 reglist.insertSortedOnce( newd->giveElement( nodeConnectivity->at(indx) )->giveRegionNumber() );
83 }
84
85#endif
87 if ( this->evaluateAt(unknownValues, dofidMask, mode, oldd, node->giveCoordinates(), reglist, tStep) ) {
89 for ( int ii = 1; ii <= dofidMask.giveSize(); ii++ ) {
90 // exclude slaves; they are determined from masters
91 auto it = node->findDofWithDofId((DofIDItem)dofidMask.at(ii));
92 if ( it != node->end() ) {
93 Dof *dof = *it;
94 if ( dof->isPrimaryDof() ) {
96 if (eq)
97 answer.at( eq ) += unknownValues.at(ii);
98 }
99 }
100 }
101 } else {
102 OOFEM_ERROR("evaluateAt service failed for node %d", inode);
103 }
104 }
105
106 return 1;
107}
108
109
110int
111EIPrimaryUnknownMapper :: evaluateAt(FloatArray &answer, IntArray &dofMask, ValueModeType mode,
112 Domain *oldd, const FloatArray &coords, IntArray &regList, TimeStep *tStep)
113{
114 Element *oelem;
116
117 FloatArray lcoords, closest;
118 if ( regList.isEmpty() ) {
119 oelem = sl->giveElementClosestToPoint(lcoords, closest, coords, 0);
120 } else {
121 // Take the minimum of any region
122 double mindist = 0.0, distance;
123 oelem = nullptr;
124 for ( int i = 1; i <= regList.giveSize(); ++i ) {
125 Element *tmpelem = sl->giveElementClosestToPoint( lcoords, closest, coords, regList.at(i) );
126 if ( tmpelem ) {
127 distance = distance_square(closest, coords);
128 if ( distance < mindist || i == 1 ) {
129 mindist = distance;
130 oelem = tmpelem;
131 if ( distance == 0.0 ) {
132 break;
133 }
134 }
135 }
136 }
137 }
138 if ( !oelem ) {
139 OOFEM_WARNING("Couldn't find any element containing point.");
140 return false;
141 }
142
143 oelem->giveElementDofIDMask(dofMask);
144 oelem->computeField(mode, tStep, lcoords, answer);
145
146 return true;
147}
148} // end namespace oofem
const IntArray * giveDofManConnectivityArray(int dofman)
std::vector< Dof * >::const_iterator findDofWithDofId(DofIDItem dofID) const
Definition dofmanager.C:274
const FloatArray & giveCoordinates() const
Definition dofmanager.h:390
std::vector< Dof * >::iterator end()
Definition dofmanager.h:162
dofManagerParallelMode giveParallelMode() const
Definition dofmanager.h:526
int giveEquationNumber(const UnknownNumberingScheme &s)
Definition dof.C:56
virtual bool isPrimaryDof()
Definition dof.h:287
SpatialLocalizer * giveSpatialLocalizer()
Definition domain.C:1255
ConnectivityTable * giveConnectivityTable()
Definition domain.C:1240
int giveNumber()
Returns domain number.
Definition domain.h:281
int giveNumberOfDofManagers() const
Returns number of dof managers in domain.
Definition domain.h:461
Element * giveElement(int n)
Definition domain.C:165
Node * giveNode(int n)
Definition domain.h:398
EngngModel * giveEngngModel()
Definition domain.C:419
int evaluateAt(FloatArray &answer, IntArray &dofMask, ValueModeType mode, Domain *oldd, const FloatArray &coords, IntArray &regList, TimeStep *tStep) override
virtual void giveElementDofIDMask(IntArray &answer) const
Definition element.h:510
virtual void computeField(ValueModeType mode, TimeStep *tStep, const FloatArray &lcoords, FloatArray &answer)
Definition element.h:520
int giveRegionNumber()
Definition element.C:546
virtual int giveNumberOfDomainEquations(int di, const UnknownNumberingScheme &num)
Definition engngm.C:452
void resize(Index s)
Definition floatarray.C:94
double & at(Index i)
Definition floatarray.h:202
void zero()
Zeroes all coefficients of receiver.
Definition floatarray.C:683
bool insertSortedOnce(int value, int allocChunk=0)
Definition intarray.C:309
void resize(int n)
Definition intarray.C:73
bool isEmpty() const
Definition intarray.h:217
int & at(std::size_t i)
Definition intarray.h:104
int giveSize() const
Definition intarray.h:211
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
@ DofManager_local
Definition dofmanager.h:67
@ DofManager_shared
Definition dofmanager.h:68
double distance(const FloatArray &x, const FloatArray &y)
double distance_square(const FloatArray &x, const FloatArray &y)

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