OOFEM 3.0
Loading...
Searching...
No Matches
latticedirichletcouplingnode.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 program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (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
28 * GNU General Public License for more details.
29 *
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
33 */
34
36#include "dof.h"
37#include "slavedof.h"
38#include "simpleslavedof.h"
39#include "nodalload.h"
40#include "timestep.h"
41
42#include "floatarray.h"
43#include "floatmatrix.h"
44#include "intarray.h"
45#include "verbose.h"
46#include "datastream.h"
47#include "contextioerr.h"
48#include "staggeredproblem.h"
49
50#ifdef __SM_MODULE
52#endif
53
54#include <math.h>
55#include <stdlib.h>
56#include "classfactory.h"
57#include "paramkey.h"
58
59#ifdef __OOFEG
60 #include "oofeggraphiccontext.h"
61#endif
62
63namespace oofem {
64
66
68
69LatticeDirichletCouplingNode :: LatticeDirichletCouplingNode(int n, Domain *aDomain) :
70 Node(n, aDomain)
71{}
72
73LatticeDirichletCouplingNode :: ~LatticeDirichletCouplingNode()
74// Destructor.
75{}
76
77void
78LatticeDirichletCouplingNode :: initializeFrom(InputRecord &ir, int priority)
79// Gets from the source line from the data file all the data of the receiver.
80{
81 ParameterManager &ppm = this->giveDomain()->elementPPM;
82
83
84 Node :: initializeFrom(ir);
86}
87
88void
89LatticeDirichletCouplingNode :: postInitialize()
90{
91 ParameterManager &ppm = this->giveDomain()->elementPPM;
92
93 Node :: postInitialize();
95}
96
97void LatticeDirichletCouplingNode :: printYourself()
98// Prints the receiver on screen.
99{
100 int i;
101 double x, y;
102
103 x = this->giveCoordinate(1);
104 y = this->giveCoordinate(2);
105 printf("LatticeDirichletCouplingNode %d coord : x %f y %f\n", number, x, y);
106 for ( i = 0; i < this->giveNumberOfDofs(); i++ ) {
107 if ( dofArray [ i ] ) {
108 dofArray [ i ]->printYourself();
109 } else {
110 printf("dof %d is nil \n", i + 1);
111 }
112 }
113
114 loadArray.printYourself();
115 printf("\n");
116}
117
118void
119LatticeDirichletCouplingNode :: giveUnknownVector(FloatArray &answer, const IntArray &dofIDArry, ValueModeType mode, TimeStep *tStep, bool padding)
120//giveUnknownVector(FloatArray &answer, const IntArray &dofMask, ValueModeType mode, TimeStep *stepN)
121{
122
123 int size;
125
126 answer.resize( size = dofIDArry.giveSize() );
127
128 for ( int i = 1; i <= size; i++ ) {
129 auto pos = this->findDofWithDofId( ( DofIDItem ) dofIDArry.at(i) );
130#ifdef DEBUG
131 if ( pos == this->end() ) {
132 OOFEM_ERROR("Couldn't find dof with Dof ID %d", dofIDArry.at(i));
133 }
134#endif
135 answer.at(i) = (*pos)->giveUnknown(mode, tStep);
137 answer.at(i) += activedirichletbc;
138
139 }
140
141 // Transform to global c.s.
142 FloatMatrix L2G;
143 if ( this->computeL2GTransformation(L2G, dofIDArry) ) {
144 answer.rotatedWith(L2G, 'n');
145 }
146
147
148 // if ( !hasSlaveDofs ) {
149 // int j, size;
150 // IntArray dofArray;
151 // this->activedirichletbc = 0;
152 // answer.resize( size = dofMask.giveSize() );
153 // this->giveDofArray(dofMask, dofArray);
154
155 // for ( j = 1; j <= size; j++ ) {
156 // answer.at(j) = this->giveDof( dofArray.at(j) )->giveUnknown(mode, stepN);
157
158 // activedirichletbc = computeUnknownCouplingContribution(stepN);
159
160 // answer.at(j) += activedirichletbc;
161 // }
162 // } else {
163 // int i, k, indx;
164 // IntArray dofArray;
165 // FloatArray mstrUnknwns;
166
167 // this->giveDofArray(dofMask, dofArray);
168 // answer.resize( giveNumberOfPrimaryMasterDofs(dofArray) );
169
170 // for ( k = 1, i = 1; i <= dofArray.giveSize(); i++ ) {
171 // indx = dofArray.at(i);
172 // if ( !this->giveDof(indx)->isPrimaryDof() ) { // slave DOF
173 // this->giveDof(indx)->giveUnknowns(mstrUnknwns, mode, stepN);
174 // answer.copySubVector(mstrUnknwns, k);
175 // k += mstrUnknwns.giveSize();
176 // } else {
177 // answer.at(k++) = this->giveDof(indx)->giveUnknown(mode, stepN);
178 // }
179 // }
180 // }
181}
182
183double
184LatticeDirichletCouplingNode :: computeUnknownCouplingContribution(TimeStep *stepN) {
185 double distance = 0.;
186 double result = 0.;
187
188 int nCouplingElements = couplingElements.giveSize();
189
190 FloatArray couplingGpCoords;
191 double normalStress;
192
193 double nominator = 0;
194 double denominator = 0;
195
196#ifdef __SM_MODULE
197 IntArray coupledModels;
198 if ( domain->giveEngngModel()->giveMasterEngngModel() ) {
199 ( static_cast< StaggeredProblem * >( domain->giveEngngModel()->giveMasterEngngModel() ) )->giveCoupledModels(coupledModels);
200 if ( coupledModels.at(1) != 0 && !(stepN->giveNumber()<=domain->giveEngngModel()->giveNumberOfFirstStep()) ) {
201 LatticeStructuralElement *coupledElement;
202 for ( int i = 1; i <= nCouplingElements; i++ ) {
203 couplingGpCoords.zero();
204 coupledElement = static_cast< LatticeStructuralElement * >( domain->giveEngngModel()->giveMasterEngngModel()->giveSlaveProblem( coupledModels.at(1) )->giveDomain(1)->giveElement( couplingElements.at(i) ) );
205
206 coupledElement->giveGpCoordinates(couplingGpCoords);
207 if(coupledElement->hasBeenUpdated() == 1){
208 normalStress = coupledElement->giveOldNormalStress();
209 }
210 else{
211 normalStress = coupledElement->giveNormalStress();
212 }
213
214 if(normalStress > 0.){
215 normalStress = 0.;
216 }
217
218 distance = sqrt( pow(couplingGpCoords.at(1) - coordinates.at(1), 2.) + pow(couplingGpCoords.at(2) - coordinates.at(2), 2.) );
219
220 nominator = nominator + distance * normalStress;
221 denominator = denominator + distance;
222 }
223
224 result = nominator / denominator;
225 }
226 }
227#endif
228
229
230return result;
231}
232
233void LatticeDirichletCouplingNode :: printOutputAt(FILE *stream, TimeStep *stepN)
234{
235 int i;
236
237#if defined( __MPI_PARALLEL_MODE ) || defined( __ENABLE_COMPONENT_LABELS )
238 fprintf( stream, "%-8s%8d (%8d):\n", this->giveClassName(), this->giveLabel(), this->giveNumber() );
239#else
240 fprintf( stream, "%-8s%8d:\n", this->giveClassName(), this->giveGlobalNumber() );
241#endif
242
243 for ( i = 1; i <= this->giveNumberOfDofs(); i++ ) {
244 fprintf(stream, " dof %d f % .16e\n", this->giveGlobalNumber(), activedirichletbc);
245 }
246}
247
248} // end namespace oofem
#define REGISTER_DofManager(class)
int giveGlobalNumber() const
Definition dofmanager.h:515
int giveNumberOfDofs() const
Definition dofmanager.C:287
int giveLabel() const
Definition dofmanager.h:516
IntArray loadArray
List of applied loads.
Definition dofmanager.h:108
std::vector< Dof * >::const_iterator findDofWithDofId(DofIDItem dofID) const
Definition dofmanager.C:274
double giveCoordinate(int i) const
Definition dofmanager.h:383
std::vector< Dof * > dofArray
Array of DOFs.
Definition dofmanager.h:106
std::vector< Dof * >::iterator end()
Definition dofmanager.h:162
FloatArray coordinates
Array storing nodal coordinates.
Definition dofmanager.h:103
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
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
void rotatedWith(FloatMatrix &r, char mode)
Definition floatarray.C:814
int & at(std::size_t i)
Definition intarray.h:104
int giveSize() const
Definition intarray.h:211
IntArray couplingElements
Array storing nodal coordinates.
virtual void giveGpCoordinates(FloatArray &coords)
Node(int n, Domain *aDomain)
Definition node.C:73
bool computeL2GTransformation(FloatMatrix &answer, const IntArray &dofIDArry) override
Definition node.C:412
int giveNumber()
Returns receiver's number.
Definition timestep.h:144
#define OOFEM_ERROR(...)
Definition error.h:79
double distance(const FloatArray &x, const FloatArray &y)
#define PM_ELEMENT_ERROR_IFNOTSET(_pm, _componentnum, _paramkey)
#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