33 #ifndef MECH_OUTPUT_WRITER_IMPL_H_
34 #define MECH_OUTPUT_WRITER_IMPL_H_
42 namespace SmallStrainMechanics{
44 template <
typename TGr
idFunction>
50 typedef typename TGridFunction::template dim_traits<dim>::grid_base_object grid_base_object;
51 typedef typename TGridFunction::template dim_traits<dim>::const_iterator const_iterator;
56 const_iterator iter = u.template begin<grid_base_object>();
57 const_iterator end = u.template end<grid_base_object>();
60 for(;iter != end; ++iter)
63 grid_base_object* elem = *iter;
85 template <
typename TGr
idFunction>
91 typedef typename TGridFunction::template dim_traits<dim>::grid_base_object grid_base_object;
92 typedef typename TGridFunction::template dim_traits<dim>::const_iterator const_iterator;
97 const_iterator iter = u.template begin<grid_base_object>();
98 const_iterator end = u.template end<grid_base_object>();
101 for(;iter != end; ++iter)
104 grid_base_object* elem = *iter;
107 u.indices(elem, ind);
113 locEqPlastStrain = 0.0;
125 template<
typename TGr
idFunction>
128 TGridFunction& sigma, TGridFunction& epsilon,
129 TGridFunction& stressFunc, TGridFunction& strainFunc, TGridFunction& u)
132 typedef typename TGridFunction::template dim_traits<dim>::grid_base_object grid_base_object;
133 typedef typename TGridFunction::template dim_traits<dim>::const_iterator const_iterator;
136 LocalIndices indU, indEps, indSig, indStressFunc, indStrainFunc;
137 LocalVector locU, locSig, locEps, locStressFunc, locStrainFunc;
139 const_iterator iter = u.template begin<grid_base_object>();
140 const_iterator end = u.template end<grid_base_object>();
143 for(;iter != end; ++iter)
146 grid_base_object* elem = *iter;
149 u.indices(elem, indU); epsilon.indices(elem, indEps);
150 sigma.indices(elem, indSig); stressFunc.indices(elem, indStressFunc);
151 strainFunc.indices(elem, indStrainFunc);
155 locSig.
resize(indSig); locStressFunc.
resize(indStressFunc);
156 locStrainFunc.
resize(indStrainFunc);
159 locStressFunc = 0.0; locStrainFunc = 0.0; locSig = 0.0; locEps = 0.0;
177 template <
typename TGr
idFunction>
183 typedef typename TGridFunction::template dim_traits<dim>::grid_base_object grid_base_object;
184 typedef typename TGridFunction::template dim_traits<dim>::const_iterator const_iterator;
190 const_iterator iter = u.template begin<grid_base_object>();
191 const_iterator end = u.template end<grid_base_object>();
194 for(;iter != end; ++iter)
197 grid_base_object* elem = *iter;
200 u.indices(elem, ind); invarKirchhoffStress.indices(elem, indInvarKirchhoffStress);
203 locU.
resize(ind); locInvarKirchhoffStress.
resize(indInvarKirchhoffStress);
209 locInvarKirchhoffStress = 0.0;
220 template<
typename TDomain>
230 const size_t numVertices = elem->num_vertices();
231 for (
size_t i = 0; i < numVertices; ++i) {
232 coCoord[i] = aaPos[elem->vertex(i)];
238 geo.
update(elem, &(coCoord[0]),
242 " Cannot update Finite Element Geometry.");
246 typedef typename vector<TBaseElem*>::iterator neighborElemIter;
247 vector<TBaseElem*> vNeighborElems;
251 m_spMatLaw->internal_vars(elem);
269 for (
size_t ip = 0; ip < geo.
num_ip(); ++ip)
271 plastStrain = *(m_spMatLaw->inelastic_strain_tensor(ip));
274 if (plastStrainNorm > 0.0)
278 for (
size_t co = 0; co < elem->num_vertices(); ++co)
281 size_t elemsWithCo = 1;
284 for (neighborElemIter it = vNeighborElems.begin();
285 it != vNeighborElems.end(); ++it){
292 size_t scaleFac = elemsWithCo * geo.
num_ip();
294 locPlastIP(0,co) = plasticIP / scaleFac;
299 template<
typename TDomain>
309 const size_t numVertices = elem->num_vertices();
310 for (
size_t i = 0; i < numVertices; ++i) {
311 coCoord[i] = aaPos[elem->vertex(i)];
317 geo.
update(elem, &(coCoord[0]),
321 " Cannot update Finite Element Geometry.");
325 typedef typename vector<TBaseElem*>::iterator neighborElemIter;
326 vector<TBaseElem*> vNeighborElems;
330 m_spMatLaw->internal_vars(elem);
333 number SumEqPlastStrainIP = 0.0;
334 for (
size_t ip = 0; ip < geo.
num_ip(); ++ip)
337 m_spMatLaw->template DisplacementGradient<DimFEGeometry<dim> >(GradU, ip, geo, locU);
339 number gamma = m_spMatLaw->plastic_multiplier(ip, GradU);
342 SumEqPlastStrainIP += gamma * sqrt(2.0/3.0);
345 for (
size_t co = 0; co < elem->num_vertices(); ++co)
348 size_t elemsWithCo = 1;
351 for (neighborElemIter it = vNeighborElems.begin();
352 it != vNeighborElems.end(); ++it){
359 size_t scaleFac = elemsWithCo * geo.
num_ip();
361 locEqPlastStrain(0, co) = SumEqPlastStrainIP / scaleFac;
364 template<
typename TDomain>
373 vector<TBaseElem*> vNeighborElems;
375 typedef typename vector<TBaseElem*>::iterator neighborElemIter;
384 const size_t numVertices = elem->num_vertices();
385 for (
size_t i = 0; i < numVertices; ++i) {
386 coCoord[i] = aaPos[elem->vertex(i)];
392 geo.
update(elem, &(coCoord[0]),
395 UG_CATCH_THROW(
"SmallStrainMechOutput::normal_stress_strain_elem:"
396 " Cannot update Finite Element Geometry.");
399 m_spMatLaw->internal_vars(elem);
401 MathMatrix<dim, dim> GradU, eps, sigma, devSigma, SumEpsIP, SumSigmaIP, inelasticStrainTens, eps_elast;
402 number normDevSig, normSig, normEps, SumNormDevSigIP, SumNormSigIP, SumNormEpsIP,
403 SumVolSigmaIP, normElastStrain, SumNormElastStrainIP, normInelastStrain, SumNormInelastStrainIP;
406 SumEpsIP = 0.0; SumSigmaIP = 0.0; SumNormDevSigIP = 0.0; SumNormSigIP = 0.0;
407 SumNormEpsIP = 0.0; SumVolSigmaIP = 0.0; SumNormElastStrainIP = 0.0; SumNormInelastStrainIP = 0.0;
409 for(
size_t ip = 0; ip < geo.
num_ip(); ++ip)
412 m_spMatLaw->template DisplacementGradient<DimFEGeometry<dim> >(GradU, ip, geo, locU);
414 m_spMatLaw->stressTensor(sigma, ip, GradU);
417 inelasticStrainTens = *(m_spMatLaw->inelastic_strain_tensor(ip));
420 for (
size_t i = 0; i < (size_t)
dim; ++i)
421 for (
size_t J = 0; J < (size_t)
dim; ++J)
423 eps[i][J] = 0.5 * (GradU[i][J] + GradU[J][i]);
424 eps_elast[i][J] = eps[i][J] - inelasticStrainTens[i][J];
428 for (
size_t i = 0; i < (size_t)
dim; ++i)
430 SumEpsIP[i][i] += eps[i][i];
431 SumSigmaIP[i][i] += sigma[i][i];
438 SumVolSigmaIP += 1.0/3.0 * trSigma;
439 SumNormDevSigIP += normDevSig;
440 SumNormSigIP += normSig;
444 SumNormEpsIP += normEps;
447 SumNormElastStrainIP += normElastStrain;
450 SumNormInelastStrainIP += normInelastStrain;
455 for (
size_t co = 0; co < numVertices; ++co)
461 geo.
update(elem, &(coCoord[0]),
465 " Cannot update Finite Element Geometry.");
468 size_t elemsWithCo = 1;
471 for (neighborElemIter it = vNeighborElems.begin();
472 it != vNeighborElems.end(); ++it){
479 size_t scaleFac = elemsWithCo * geo.
num_ip();
482 for (
size_t i = 0; i < (size_t)
dim; ++i)
484 locEps(i, co) += SumEpsIP[i][i] / scaleFac;
485 locSigma(i, co) += SumSigmaIP[i][i] / scaleFac;
488 locStressFunc(0, co) += SumNormSigIP / scaleFac;
489 locStressFunc(1, co) += SumNormDevSigIP / scaleFac;
490 locStressFunc(2, co) += SumVolSigmaIP / scaleFac;
492 locStrainFunc(0, co) += SumNormEpsIP / scaleFac;
493 locStrainFunc(1, co) += SumNormElastStrainIP / scaleFac;
494 locStrainFunc(2, co) += SumNormInelastStrainIP / scaleFac;
499 for (
size_t co = 0; co < numVertices; ++co)
501 if ((coCoord[co][0] == 90.0) && (coCoord[co][1] == 0.0))
503 UG_LOG(
"At 2 (90.0,0.0): \n");
504 for (
size_t i = 0; i < (size_t)
dim; ++i)
505 UG_LOG(
"u("<< i <<
"," << co <<
"): " << locU(i,co) <<
"\n");
509 vector<size_t> vNextIP;
510 next_ips_to_point(vNextIP, coCoord[co], geo);
513 for (vector<size_t>::iterator it = vNextIP.begin();
514 it != vNextIP.end(); ++it)
517 m_spMatLaw->template DisplacementGradient<DimFEGeometry<dim> >(GradU, *it, geo, locU);
519 m_spMatLaw->stressTensor(sigma, *it, GradU);
521 UG_LOG(
"At " << geo.global_ip(*it) <<
": \n");
522 UG_LOG(
"sigma_yy: " << sigma[1][1] <<
"\n");
523 UG_LOG(
"sigma: " << sigma <<
"\n");
527 if ((coCoord[co][0] == 100.0) && (coCoord[co][1] == 100.0))
529 UG_LOG(
"At 4 (100.0,100.0): \n");
530 for (
size_t i = 0; i < (size_t)
dim; ++i)
531 UG_LOG(
"u("<< i <<
"," << co <<
"): " << locU(i,co) <<
"\n");
536 if ((coCoord[co][0] == 0.0) && (coCoord[co][1] == 100.0))
538 UG_LOG(
"At 5 (0.0,100.0): \n");
539 for (
size_t i = 0; i < (size_t)
dim; ++i)
540 UG_LOG(
"u("<< i <<
"," << co <<
"): " << locU(i,co) <<
"\n");
549 template<
typename TDomain>
559 const size_t numVertices = elem->num_vertices();
560 for (
size_t i = 0; i < numVertices; ++i) {
561 coCoord[i] = aaPos[elem->vertex(i)];
567 geo.
update(elem, &(coCoord[0]),
570 UG_CATCH_THROW(
"MechOutputWriterFinite::invariants_kirchhoff_stress_elem:"
571 " Cannot update Finite Element Geometry.");
575 typedef typename vector<TBaseElem*>::iterator neighborElemIter;
576 vector<TBaseElem*> vNeighborElems;
580 m_spMatLaw->internal_vars(elem);
584 for (
size_t co = 0; co < elem->num_vertices(); ++co)
591 vector<size_t> vNextIP;
592 next_ips_to_point(vNextIP, coCoord[co], geo);
594 for (vector<size_t>::iterator it = vNextIP.begin();
595 it != vNextIP.end(); ++it)
598 m_spMatLaw->template DisplacementGradient<DimFEGeometry<dim> >(GradU, *it, geo, u);
601 m_spMatLaw->stressTensor(sigma, *it, GradU);
613 invar1_ip += traceTauTens_ip;
614 invar2_ip += 0.5 * (traceTauTens_ip * traceTauTens_ip - traceTauTens2_ip);
619 size_t elemsWithCo = 1;
622 for (neighborElemIter it = vNeighborElems.begin();
623 it != vNeighborElems.end(); ++it){
630 const size_t scaleFac = elemsWithCo * vNextIP.size();
632 locInvarKirchhoffStress(0, co) = invar1_ip/scaleFac;
633 locInvarKirchhoffStress(1, co) = invar2_ip/scaleFac;
634 locInvarKirchhoffStress(2, co) = invar3_ip/scaleFac;
638 template<
typename TDomain>
655 template<
typename TDomain>
656 template<
typename TFEGeom>
665 if (m_stressEV && (!m_bIP_values_written))
667 stress_eigenvalues_near_point(time, geo, u);
672 normal_stress_near_point(time, geo, u);
675 template<
typename TDomain>
681 m_spMatLaw->write_data_to_console(time);
684 template<
typename TDomain>
701 template<
typename TDomain>
702 template<
typename TFEGeom>
708 vector<size_t> vNextIP;
709 next_ips_to_point(vNextIP, m_evalPointEV, geo);
712 for (vector<size_t>::iterator it = vNextIP.begin();
713 it != vNextIP.end(); ++it)
715 m_spMatLaw->template DisplacementGradient<TFEGeom>(GradU, *it, geo, u);
716 m_spMatLaw->stressTensor(Sig, *it, GradU);
723 for (
size_t a = 0; a < 3; ++a)
724 for (
size_t b = 0; b < 3; ++b){
725 SigTens[a][b] = SYMMSig[a][b];
729 number SiglambdaMin, SiglambdaMed, SiglambdaMax;
732 SiglambdaMed, SiglambdaMax, evMin, evMed,
735 number sqrSigLambdaMin = sqrt(SiglambdaMin);
736 number sqrSigLambdaMed = sqrt(SiglambdaMed);
737 number sqrSigLambdaMax = sqrt(SiglambdaMax);
739 UG_LOG(
"minimal EigenValueSigma: " << sqrSigLambdaMin <<
"\n");
740 UG_LOG(
"medium EigenValueSigma: " << sqrSigLambdaMed <<
"\n");
741 UG_LOG(
"maximal EigenValueSigma: " << sqrSigLambdaMax <<
"\n");
756 m_bIP_values_written =
true;
760 template<
typename TDomain>
761 template<
typename TFEGeom>
766 vector<size_t> vNextIP;
767 next_ips_to_point(vNextIP, m_evalPointNormStress, geo);
770 for (vector<size_t>::iterator it = vNextIP.begin();
771 it != vNextIP.end(); ++it)
773 m_spMatLaw->template DisplacementGradient<TFEGeom>(GradU, *it, geo, u);
774 m_spMatLaw->stressTensor(Sig, *it, GradU);
776 UG_LOG(
"At " << geo.global_ip(*it) <<
": \n");
777 UG_LOG(
"sigma_xx: " << Sig[0][0] <<
"\n");
778 UG_LOG(
"sigma_yy: " << Sig[1][1] <<
"\n");
779 UG_LOG(
"sigma: " << Sig <<
"\n");
787 template<
typename TDomain>
788 template<
typename TFEGeom>
794 number dist = std::numeric_limits<number>::max();
797 for (
size_t ip = 0; ip < geo.num_ip(); ++ip)
805 for (
size_t ip = 0; ip < geo.num_ip(); ++ip)
809 vNextIP.push_back(ip);
void update(GridObject *pElem, const MathVector< worldDim > *vCorner)
void resize(const LocalIndices &ind)
Definition: mech_output_writer.h:52
domain_traits< TDomain::dim >::grid_base_object TBaseElem
base element type of associated domain
Definition: mech_output_writer.h:55
void post_timestep(const number time)
Definition: mech_output_writer_impl.h:678
void preprocess()
Definition: mech_output_writer_impl.h:641
void stress_eigenvalues_near_point(const number time, TFEGeom &geo, const LocalVector &u)
Definition: mech_output_writer_impl.h:705
void postprocess()
Definition: mech_output_writer_impl.h:687
void post_timestep_elem(const number time, SmartPtr< TDomain > dom, TFEGeom &geo, TBaseElem *elem, const LocalVector &u)
Definition: mech_output_writer_impl.h:659
void invariants_kirchhoff_stress_elem(LocalVector &locInvarKirchhoffStress, TBaseElem *elem, const LocalVector &u, SmartPtr< TDomain > dom)
get the invariants of the kirchhoff stress tensor using the vector of unknowns u
Definition: mech_output_writer_impl.h:552
void plastIP_elem(LocalVector &locPlastIP, TBaseElem *elem, const LocalVector &locU, SmartPtr< TDomain > dom)
marks the integration point, where a plastic evolution occurs
Definition: mech_output_writer_impl.h:223
void next_ips_to_point(vector< size_t > &vNextIP, const MathVector< dim > &point, const TFEGeom &geo)
Definition: mech_output_writer_impl.h:791
void normal_stress_strain_elem(LocalVector &locSigma, LocalVector &locEps, LocalVector &locStressFunc, LocalVector &locStrainFunc, TBaseElem *elem, const LocalVector &locU, SmartPtr< TDomain > dom)
get some normalized values of the Cauchy-stress and strain tensor
Definition: mech_output_writer_impl.h:367
void eqPlastStrain_elem(LocalVector &locEqPlastStrain, TBaseElem *elem, const LocalVector &locU, SmartPtr< TDomain > dom)
get the equivalent plastic strain
Definition: mech_output_writer_impl.h:302
void normal_stress_near_point(const number time, TFEGeom &geo, const LocalVector &u)
Definition: mech_output_writer_impl.h:764
Grid::VertexAttachmentAccessor< position_attachment_type > position_accessor_type
UG_API bool ContainsPoint(const EdgeVertices *e, const vector_t &p, TAAPos aaPos)
void CollectNeighbors(std::vector< Edge * > &vNeighborsOut, Edge *e, Grid &grid, NeighborhoodType nbhType=NHT_VERTEX_NEIGHBORS)
matrix_t::value_type MatDeviatorTrace(const matrix_t &m, matrix_t &dev)
MathMatrix< 1, 1, T >::value_type Trace(const MathMatrix< 1, 1, T > &m)
void MatIdentity(matrix_t &mOut)
void MatMultiplyMTM(MathMatrix< N, N, T > &mOut, const MathMatrix< M, N, T > &m)
void MatAdd(matrix_t &mOut, const matrix_t &m, typename matrix_t::value_type s)
void MatScale(matrix_t &mOut, typename matrix_t::value_type s, const matrix_t &m)
matrix_t::value_type MatFrobeniusNorm(matrix_t &m)
void MatMultiply(MathMatrix< N, M, T > &mOut, const MathMatrix< N, L, T > &m1, const MathMatrix< L, M, T > &m2)
void equiv_plast_strain(TGridFunction &eqPlastStrain, MechOutputWriter< typename TGridFunction::domain_type > &mechOut, TGridFunction &u)
Definition: mech_output_writer_impl.h:86
void normal_stresses_strains(MechOutputWriter< typename TGridFunction::domain_type > &mechOut, TGridFunction &sigma, TGridFunction &epsilon, TGridFunction &stressFunc, TGridFunction &strainFunc, TGridFunction &u)
Definition: mech_output_writer_impl.h:127
void invariants_kirchhoff_stress(TGridFunction &invarKirchhoffStress, MechOutputWriter< typename TGridFunction::domain_type > &mechOut, TGridFunction &u)
Definition: mech_output_writer_impl.h:178
void plast_ip(TGridFunction &plastIP, MechOutputWriter< typename TGridFunction::domain_type > &mechOut, TGridFunction &u)
Definition: mech_output_writer_impl.h:45
#define UG_CATCH_THROW(msg)
bool CalculateEigenvalues(const ug::matrix33 &mat, number &lambdaMinOut, number &lambdaMedOut, number &lambdaMaxOut, ug::vector3 &evMinOut, ug::vector3 &evMedOut, ug::vector3 &evMaxOut)
vector_t::value_type VecDistance(const vector_t &v1, const vector_t &v2)
MathMatrix< 0, 0, T >::value_type Determinant(const MathMatrix< 0, 0, T > &m)
void GetLocalVector(LocalVector &lvec, const TVector &vec)
void AddLocalVector(TVector &vec, const LocalVector &lvec)