45 namespace SmallStrainMechanics{
49 template <
class TDomain>
50 number MaxEdgeLength(TDomain& dom, MathVector<TDomain::dim>& ndir)
59 MultiGrid& mg = *dom.grid();
62 typedef MathVector<TDomain::dim> vector_t;
66 for(iter_t e_iter = mg.begin<elem_t>(); e_iter != mg.end<elem_t>(); ++e_iter){
67 elem_t* elem = *e_iter;
68 if(mg.has_children(elem))
71 mg.associated_elements(edges, elem);
73 for(
size_t i = 0; i < edges.size(); ++i){
75 VecSubtract(edgeDir, aaPos[edges[i]->vertex(0)], aaPos[edges[i]->vertex(1)]);
90 template <
class TDomain>
91 void MarkAnisotropic_Along_Normal(TDomain& dom, IRefiner& refiner, MathVector<TDomain::dim>& ndir)
93 UG_ASSERT(dom.grid().get() == refiner.get_associated_grid(),
94 "Grids in domain and in refiner have to match!");
102 MultiGrid& mg = *dom.grid();
105 typedef MathVector<TDomain::dim> vector_t;
107 for(iter_t e_iter = mg.begin<elem_t>(); e_iter != mg.end<elem_t>(); ++e_iter){
108 elem_t* elem = *e_iter;
109 if(mg.has_children(elem))
116 mg.associated_elements(edges, elem);
118 for(
size_t i = 0; i < edges.size(); ++i){
120 VecSubtract(edgeDir, aaPos[edges[i]->vertex(0)], aaPos[edges[i]->vertex(1)]);
124 if((dot +
SMALL >= 1) || (dot -
SMALL <= -1)){
125 refiner.mark(edges[i]);
132 template <
class TDomain>
133 void MarkAnisotropic_Longest_Scaled_Normal(TDomain& dom, IRefiner& refiner,
number Ex,
number Ey,
number Ez)
135 UG_ASSERT(dom.grid().get() == refiner.get_associated_grid(),
136 "Grids in domain and in refiner have to match!");
140 typedef MathVector<TDomain::dim> vector_t;
146 ndirX[0] = 1; ndirX[1] = 0; ndirX[2] = 0;
147 ndirY[0] = 0; ndirY[1] = 1; ndirY[2] = 0;
148 ndirZ[0] = 0; ndirZ[1] = 0; ndirZ[2] = 1;
151 number maxX = MaxEdgeLength(dom, ndirX);
152 number maxY = MaxEdgeLength(dom, ndirY);
153 number maxZ = MaxEdgeLength(dom, ndirZ);
155 number scaleXsqrt = sqrt(maxX/Ex);
156 number scaleYsqrt = sqrt(maxY/Ey);
157 number scaleZsqrt = sqrt(maxZ/Ez);
159 number scaleXYZmin = min(scaleXsqrt, min(scaleYsqrt, scaleZsqrt));
161 scaleXsqrt /= scaleXYZmin;
162 scaleYsqrt /= scaleXYZmin;
163 scaleZsqrt /= scaleXYZmin;
165 std::cout <<
"scale normed x: " << scaleXsqrt << std::endl;
166 std::cout <<
"scale normed y: " << scaleYsqrt << std::endl;
167 std::cout <<
"scale normed z: " << scaleZsqrt << std::endl;
169 if(scaleXsqrt > scaleYsqrt){
170 if(scaleXsqrt > scaleZsqrt){
171 UG_LOG(
"[MarkAnisotropic_Longest_Scaled_Normal] refine in X direction");
172 MarkAnisotropic_Along_Normal(dom, refiner, ndirX);
175 UG_LOG(
"[MarkAnisotropic_Longest_Scaled_Normal] refine in Z direction");
176 MarkAnisotropic_Along_Normal(dom, refiner, ndirZ);
181 if(scaleZsqrt > scaleYsqrt){
182 UG_LOG(
"[MarkAnisotropic_Longest_Scaled_Normal] refine in Z direction");
183 MarkAnisotropic_Along_Normal(dom, refiner, ndirZ);
186 UG_LOG(
"[MarkAnisotropic_Longest_Scaled_Normal] refine in Y direction");
187 MarkAnisotropic_Along_Normal(dom, refiner, ndirY);
Grid::VertexAttachmentAccessor< position_attachment_type > position_accessor_type
UG_API number EdgeLengthSq(const EdgeVertices *e, TAAPosVRT &aaPos)
#define UG_ASSERT(expr, msg)
void VecNormalize(vector_t &vOut, const vector_t &v)
void VecSubtract(vector_t &vOut, const vector_t &v, typename vector_t::value_type s)
vector_t::value_type VecDot(const vector_t &v1, const vector_t &v2)
geometry_traits< TElem >::iterator iterator
PointerConstArray< TElem * > secure_container