33 #ifndef CONTACT_IMPL_H_
34 #define CONTACT_IMPL_H_
43 namespace SmallStrainMechanics{
73 template <
typename TDomain>
74 template <
typename TElem>
78 const LocalVector& locU, vector<DoFIndex> vActiveSetLoc)
91 UG_CATCH_THROW(
"SmallStrainMechanicsElemDisc::contact_forces_elem_ips_avg:"
92 " Cannot update local values of finite element geometry.");
97 UG_CATCH_THROW(
"SmallStrainMechanicsElemDisc::contact_forces_elem_ips_avg:"
98 " Cannot update finite element geometry.");
101 if (numElemCorners ==
dim)
102 ElementNormal<face_type0, dim>(
normal, sideCoPos);
104 ElementNormal<face_type1, dim>(
normal, sideCoPos);
110 for(
size_t ip = 0; ip < geo.num_ip(); ++ip)
115 m_spMatLaw->template DisplacementGradient<sideGeo>(GradU, ip, geo, locU);
116 m_spMatLaw->stressTensor(sigma, ip, GradU);
134 for (
size_t i = 0; i < (size_t)
dim; ++i)
135 for (
size_t j = 0; j < (size_t)
dim; ++j)
136 sigma_n += sigma[i][j] * normalizedNormal[i] * normalizedNormal[j];
141 for (vector<DoFIndex>::iterator itActiveInd = vActiveSetLoc.begin();
142 itActiveInd < vActiveSetLoc.end(); ++itActiveInd)
143 locForce((*itActiveInd)[1], (*itActiveInd)[0]) += sigma_n * geo.weight(ip);
152 template <
typename TDomain>
153 template <
typename TS
ide,
typename TElem>
157 const LocalVector& locU, vector<DoFIndex> vActiveSetLoc)
171 vector<MathVector<dim> > vGlobalGrad;
172 vector<MathVector<dim> > vCorner;
183 const size_t numSH = lsfs.num_sh();
184 vLocalGrad.resize(numSH);
185 vGlobalGrad.resize(numSH);
188 if (
dim-1 < 1 ||
dim-1 > 2)
189 UG_THROW(
"SmallStrainMechanicsElemDisc::contact_forces_elem_midpoint:"
190 "side dimension " <<
dim-1 <<
" is not supported!");
193 for (
int i = 0; i <
dim-1; ++i)
197 localIP[0] = 1.0/3.0; localIP[1] = 1.0/3.0;
201 lsfs.grads(&vLocalGrad[0], localIP);
207 refMap.update(&vCorner[0]);
210 refMap.jacobian_transposed_inverse(JTInv, localIP);
217 int numElemCorners = (int)vCorner.size();
218 if (numElemCorners ==
dim)
219 ElementNormal<face_type0, dim>(
normal, sideCoPos);
221 ElementNormal<face_type1, dim>(
normal, sideCoPos);
250 for (
size_t i = 0; i < (size_t)
dim; ++i)
251 for (
size_t j = 0; j < (size_t)
dim; ++j)
252 sigma_n += sigma[i][j] * normalizedNormal[i] * normalizedNormal[j];
260 for (vector<DoFIndex>::iterator itAcvtiveInd = vActiveSetLoc.begin();
261 itAcvtiveInd < vActiveSetLoc.end(); ++itAcvtiveInd)
262 locForce((*itAcvtiveInd)[1], (*itAcvtiveInd)[0]) = sigma_n;
266 template <
typename TDomain,
typename TGr
idFunction>
270 m_spMechElemDisc = spMechElemDisc;
273 template <
typename TDomain,
typename TGr
idFunction>
274 template <
typename TS
ideElem,
typename TIterator>
278 const TGridFunction& u,
279 TGridFunction& contactForce,
280 vector<DoFIndex> vActiveSetGlob)
283 if(iterBegin == iterEnd)
return;
285 typedef typename TGridFunction::domain_type
domain_type;
288 typename grid_type::template traits<element_type>::secure_container associatedElems;
290 = contactForce.domain()->position_accessor();
293 vector<DoFIndex> vActiveSetLoc;
299 for(TIterator iter = iterBegin; iter != iterEnd; ++iter)
301 TSideElem* sideElem = *iter;
304 grid.associated_elements(associatedElems, sideElem);
306 if (associatedElems.size() > 1)
307 UG_THROW(
"Temporarily it is only possible to compute contact Forces "
308 "for an element of dimension " <<
dim-1 <<
" with exactly "
309 "one associated element of dimension " <<
dim <<
" in "
310 "ContactSmallStrainMechanics::contactForcesElem \n");
313 u.indices(*iter, ind);
318 vActiveSetLoc.resize(0);
321 for (vector<DoFIndex>::iterator itActiveInd = vActiveSetGlob.begin();
322 itActiveInd < vActiveSetGlob.end(); ++itActiveInd)
324 for(
size_t fct=0; fct < locU.
num_all_fct(); ++fct){
325 for(
size_t dof=0; dof < locU.
num_all_dof(fct); ++dof)
327 size_t globIndex = ind.
index(fct, dof);
328 size_t globComp = ind.
comp(fct, dof);
331 if ((*itActiveInd)[0] == globIndex &&
332 (*itActiveInd)[1] == globComp)
334 UG_LOG(
"active multiIndex (ind,comp) in "
335 "ContactSmallStrainMechanics::contactForces: ("
336 << globIndex <<
"," << globComp <<
") \n");
340 DoFIndex activeMultiIndexLoc(dof, fct);
342 UG_LOG(
"active locU (dof,fct) in "
343 "ContactSmallStrainMechanics::contactForces: ("
344 << dof <<
"," << fct <<
") \n");
347 vActiveSetLoc.push_back(activeMultiIndexLoc);
353 if (vActiveSetLoc.size() != 0.0)
355 UG_LOG(
"activeDoFs in Elem" << *iter <<
"in "
356 "ContactSmallStrainMechanics::contactForces: "
357 << vActiveSetLoc.size() <<
"\n");
360 locContactForce = 0.0;
366 vector<MathVector<dim> > vCorner;
380 int numElemCorners = (int)vCorner.size();
382 for (
int i = 0; i < numElemCorners; ++i)
383 sideCoPos[i] = vCorner[rRefElem.id(
dim-1, 0, 0, i)];
390 m_spMechElemDisc->contact_forces_elem_midpoint(locContactForce, sideElem,
391 associatedElems[0], sideCoPos, locU, vActiveSetLoc);
411 template <
typename TDomain,
typename TGr
idFunction>
413 TGridFunction& contactForce,
const TGridFunction& u,
414 vector<DoFIndex> vActiveSetGlob,
415 vector<int> vActiveSubsets)
417 if (m_spMechElemDisc.invalid())
418 UG_THROW(
"No element discretization set in "
419 "ContactSmallStrainMechanics:lagrange_multiplier \n");
421 UG_LOG(
"Active subsets: " << vActiveSubsets.size() <<
"\n");
425 for (vector<int>::iterator siContact = vActiveSubsets.begin();
426 siContact != vActiveSubsets.end(); ++siContact)
428 UG_LOG(
"siContact: " << *siContact <<
"\n");
434 contact_forces_elem<RegularEdge>
435 (dd->template begin<RegularEdge>(*siContact), dd->template end<RegularEdge>(*siContact),
436 u, contactForce, vActiveSetGlob);
439 contact_forces_elem<Triangle>
440 (dd->template begin<Triangle>(*siContact), dd->template end<Triangle>(*siContact),
441 u, contactForce, vActiveSetGlob);
442 contact_forces_elem<Quadrilateral>
443 (dd->template begin<Quadrilateral>(*siContact), dd->template end<Quadrilateral>(*siContact),
444 u, contactForce, vActiveSetGlob);
447 UG_THROW(
"ContactSmallStrainMechanics::lagrange_multiplier:"
448 "SubsetDimension "<< subsetDim <<
" (subset="<< *siContact <<
") not supported.");
virtual ReferenceObjectID reference_object_id() const=0
static const LocalShapeFunctionSet< dim, TShape, TGrad > & get(ReferenceObjectID roid, const LFEID &id, bool bCreate=true)
comp_type & comp(size_t fct, size_t dof)
index_type & index(size_t fct, size_t dof)
size_t num_all_fct() const
void resize(const LocalIndices &ind)
size_t num_all_dof(size_t fct) const
static const DimReferenceElement< dim > & get(ReferenceObjectID roid)
static DimReferenceMapping< TDim, TWorldDim > & get(ReferenceObjectID roid)
Definition: small_strain_mech.h:102
void contact_forces_elem_ips_avg(LocalVector &locForce, GridObject *side, TElem *elem, const MathVector< dim > sideCoPos[], int numElemCorners, const LocalVector &locU, std::vector< DoFIndex > vActiveSetLoc)
computing contact forces elementwise by averaging over all integration points
void contact_forces_elem_midpoint(LocalVector &locForce, TSide *side, TElem *elem, const MathVector< dim > sideCoPos[], const LocalVector &locU, std::vector< DoFIndex > vActiveSetLoc)
computing contact forces elementwise at every element midpoint
Grid::VertexAttachmentAccessor< position_attachment_type > position_accessor_type
void CollectCornerCoordinates(int base_object_id, std::vector< typename TDomain::position_type > &vCornerCoordsOut, GridObject &elem, const TDomain &domain, bool clearContainer)
#define UG_CATCH_THROW(msg)
vector_t::value_type VecLength(const vector_t &v)
void VecScale(vector_t &vOut, const vector_t &v, typename vector_t::value_type s)
void GetLocalVector(LocalVector &lvec, const TVector &vec)
int DimensionOfSubset(const ISubsetHandler &sh, int si)
void AddLocalVector(TVector &vec, const LocalVector &lvec)
ReferenceVertex face_type0
Definition: contact_impl.h:54
DimFEGeometry< 1, 1 > DimFEGeo
Definition: contact_impl.h:56
ReferenceVertex face_type1
Definition: contact_impl.h:55
DimFEGeometry< 2, 1 > DimFEGeo
Definition: contact_impl.h:63
ReferenceEdge face_type0
Definition: contact_impl.h:61
ReferenceEdge face_type1
Definition: contact_impl.h:62
ReferenceQuadrilateral face_type1
Definition: contact_impl.h:69
ReferenceTriangle face_type0
Definition: contact_impl.h:68
DimFEGeometry< 3, 2 > DimFEGeo
Definition: contact_impl.h:70
Definition: contact_impl.h:46
void DimFEGeo
Definition: contact_impl.h:49
void face_type1
Definition: contact_impl.h:48
void face_type0
Definition: contact_impl.h:47