OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
contactdefinition.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 "contact/contactmanager.h"
37 #include "contact/contactelement.h"
38 #include "intarray.h"
39 #include "domain.h"
40 #include "floatmatrix.h"
41 #include "sparsemtrx.h"
42 #include "masterdof.h"
43 #include "classfactory.h"
44 
45 namespace oofem {
47 
48 
50 {
51  this->cMan = cMan;
52  this->numberOfConstraintEq = 0;
53 }
54 
55 
57 {
58 }
59 
60 
61 int
63 {
64  for ( auto cEl : this->masterElementList ) {
65  cEl->instanciateYourself(dr);
66  cEl->setupIntegrationPoints();
67  }
68 
69  return 1;
70 }
71 
72 
73 void
75 {
76  // Creates new dofs due associated with the contact (Lagrange multipliers) and appends them to the dof managers
77  // Creates new dofs due associated with the contact (Lagrange multipliers) and appends them to the dof managers
78 
79  //TODO This is a bit ugly, find a better solution than asking the contact el
80  if ( int numDofs = this->giveNumberOfConstraintEqToAdd() ) {
81 
82  // get an array with dof ids' to append to
83  IntArray dofIdArray(numDofs), dofMans;
84  for ( int i = 1; i <= numDofs; i++ ) {
85  dofIdArray.at(i) = this->cMan->giveDomain()->giveNextFreeDofID();
86  }
87 
88  for ( ContactElement *cEl : this->masterElementList ) {
89 
90  cEl->giveDofManagersToAppendTo(dofMans);
91  if ( dofMans.giveSize() ) { // if the contact element adds extra dofs, store them. Maybe just store in cDef?
92  cEl->setDofIdArray(dofIdArray);
93  }
94 
95  for ( int i = 1; i <= dofMans.giveSize(); i++ ) {
96  DofManager *dMan = this->cMan->giveDomain()->giveDofManager(dofMans.at(i));
97  for ( auto &dofid: dofIdArray ) {
98  if ( !dMan->hasDofID( ( DofIDItem ) ( dofid ) ) ) {
99 
100  dMan->appendDof( new MasterDof( dMan, ( DofIDItem ) dofid ) );
101  }
102  }
103  }
104  }
105  }
106 }
107 
108 
109 void
111  const UnknownNumberingScheme &s, Domain *domain, FloatArray *eNorms)
112 {
113  //Loop through all the contact elements and let them return their internal forces vector
114  FloatArray Fc;
115  IntArray locArray;
116 
117  // TODO ask masters that are potentially in contact and not everyone
118  for ( auto &master : this->masterElementList ) {
119 
120  // These acts as external forces so move them to the lhs
121  master->computeContactForces(Fc, tStep, mode, s, domain, eNorms);
122  Fc.negated();
123 
124  if ( Fc.giveSize() ) {
125  master->giveLocationArray(locArray, s);
126  answer.assemble(Fc, locArray);
127 
128  if ( eNorms ) {
129  eNorms->assembleSquared( Fc, locArray );
130  }
131  }
132  }
133 }
134 
135 
136 void
138  const UnknownNumberingScheme &r_s, const UnknownNumberingScheme &c_s)
139 {
140 
141  FloatMatrix Kc;
142  IntArray locArrayR, locArrayC;
143 
144  for ( auto &master : this->masterElementList ) {
145 
146  //if ( master->isInContact() ) { // tangent becomes singular with this
147  //printf("node in contact: computeContactTangent\n\n");
148  master->computeContactTangent(Kc, tStep);
149  // do this in contact element?
150  Kc.negated(); // should be negated!
151 
152  master->giveLocationArray(locArrayR, r_s);
153  master->giveLocationArray(locArrayC, c_s);
154 
155  answer.assemble(locArrayR, locArrayC, Kc);
156  //}
157  }
158 }
159 
160 
161 }
virtual void computeContactForces(FloatArray &answer, TimeStep *tStep, ValueModeType mode, const UnknownNumberingScheme &s, Domain *domain, FloatArray *eNorms)
Class and object Domain.
Definition: domain.h:115
virtual int assemble(const IntArray &loc, const FloatMatrix &mat)=0
Assembles sparse matrix from contribution of local elements.
virtual ~ContactDefinition()
Destructor.
Base class for all matrices stored in sparse format.
Definition: sparsemtrx.h:60
ValueModeType
Type representing the mode of UnknownType or CharType, or similar types.
Definition: valuemodetype.h:78
Base class for dof managers.
Definition: dofmanager.h:113
void negated()
Changes sign of receiver values.
Definition: floatmatrix.C:1605
Class representing the abstraction for input data source.
Definition: datareader.h:50
Class implementing an array of integers.
Definition: intarray.h:61
int & at(int i)
Coefficient access function.
Definition: intarray.h:103
Class representing "master" degree of freedom.
Definition: masterdof.h:92
virtual void computeContactTangent(SparseMtrx &answer, TimeStep *tStep, const UnknownNumberingScheme &r_s, const UnknownNumberingScheme &c_s)
virtual void createContactDofs()
DofIDItem
Type representing particular dof type.
Definition: dofiditem.h:86
REGISTER_ContactDefinition(ContactDefinition)
std::vector< ContactElement * > masterElementList
virtual int instanciateYourself(DataReader &dr)
Abstract base class allowing to control the way, how equations are assigned to individual DOFs...
This class manages all the contacts in a domain.
void appendDof(Dof *dof)
Adds the given Dof into the receiver.
Definition: dofmanager.C:134
int giveNextFreeDofID(int increment=1)
Gives the next free dof ID.
Definition: domain.C:1411
Class representing vector of real numbers.
Definition: floatarray.h:82
bool hasDofID(DofIDItem id) const
Checks if receiver contains dof with given ID.
Definition: dofmanager.C:166
Implementation of matrix containing floating point numbers.
Definition: floatmatrix.h:94
void assemble(const FloatArray &fe, const IntArray &loc)
Assembles the array fe (typically, the load vector of a finite element) into the receiver, using loc as location array.
Definition: floatarray.C:551
void assembleSquared(const FloatArray &fe, const IntArray &loc)
Assembles the array fe with each component squared.
Definition: floatarray.C:572
This class manages a particular contact definition.
int giveSize() const
Definition: intarray.h:203
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.
DofManager * giveDofManager(int n)
Service for accessing particular domain dof manager.
Definition: domain.C:314
void negated()
Switches the sign of every coefficient of receiver.
Definition: floatarray.C:739
virtual int giveNumberOfConstraintEqToAdd()
Class representing solution step.
Definition: timestep.h:80

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