32 #ifndef _GENERIC_ELEMENT_2_H_
33 #define _GENERIC_ELEMENT_2_H_
66 template <
class Field>
130 template <
class Field,
class Value>
132 const Nat_coor &nc, Value *
v)
const throw(
int);
135 template <
class Field>
141 template <
class Field,
class Value>
143 const Real xi, Value *
v)
const throw(
int);
146 template <
class Field>
152 template <
class Field>
161 template <
class Field>
170 template <
class Field,
class Value>
174 template <
class Field>
185 template <
class Field>
190 template <
class Field>
194 template <
class Pnts>
198 template <
class Field>
203 template <
class Field>
226 template <
class Field,
class Value>
228 const Nat_coor &nc, Value *
v)
const throw(
int);
231 template <
class Field,
class Value>
233 const Real xi, Value *
v)
const throw(
int);
241 template <
class Field,
class Value>
244 Value *
v)
const throw(
int) {
245 const Real xi = nc[0], eta = nc[1];
248 { interpolate( f, xi,
v);
return; }
254 *
v += ((f[1]-f[0])*=xi) += ((f[2]-f[0])*=eta);
259 *
v += ((f[1]-f[0]) *= (xi * (1.-eta)))
260 += ((f[3]-f[0]) *= eta)
261 += ((f[2]-f[3]) *= xi*eta);
265 const Real zeta=1.-xi-eta;
270 *
v += ((f[1]-f[0]) *= xi * (2.*xi-1.))
271 += ((f[3]-f[0]) *= 4.* xi * zeta)
272 += ((f[2]-f[0]) *= eta * (2.*eta-1.))
273 += ((f[5]-f[0]) *= 4. * eta * zeta)
274 += ((f[4]-f[0]) *= 4.*xi*eta);
278 const Real xi_minus = 1. - xi;
279 const Real eta_minus = 1. - eta;
288 *
v += ((f[1]-f[0]) *= eta * (2.*eta-1.))
289 += ((f[3]-f[0]) *= eta)
290 += ((f[2]-f[3]) *= xi * eta)
291 -= ((((f[0]-f[4])+=(f[1]-f[4])) *= 2.*xi*xi_minus*eta_minus)
292 += (((f[2]-f[6])+=(f[3]-f[6])) *= 2.*xi*xi_minus*eta)
293 += (((f[1]-f[5])+=(f[2]-f[5])) *= 2.*xi*eta*eta_minus)
294 += (((f[0]-f[7])+=(f[3]-f[7])) *= 2.*xi_minus*eta*eta_minus));
302 template <
class Field,
class Value>
305 Value *
v)
const throw(
int) {
306 const Real xi = nc[0], eta = nc[1];
309 { interpolate_nopt( f, xi,
v);
return; }
314 *
v += ((f[1]-f[0])*xi) + ((f[2]-f[0])*eta);
317 *
v += ((f[1]-f[0]) * (xi * (1.-eta)))
318 + ((f[3]-f[0]) * eta)
319 + ((f[2]-f[3]) * xi*eta);
323 const Real zeta=1.-xi-eta;
325 *
v += ((f[1]-f[0]) * xi * (2.*xi-1.))
326 + ((f[3]-f[0]) * 4.* xi * zeta)
327 + ((f[2]-f[0]) * eta * (2.*eta-1.))
328 + ((f[5]-f[0]) * 4. * eta * zeta)
329 + ((f[4]-f[0]) * 4.*xi*eta);
333 const Real xi_minus = 1. - xi;
334 const Real eta_minus = 1. - eta;
336 *
v += ((f[1]-f[0]) * eta * (2.*eta-1.))
337 + ((f[3]-f[0]) * eta)
338 + ((f[2]-f[3]) * xi * eta)
339 - ((((f[0]-f[4])+(f[1]-f[4])) * 2.*xi*xi_minus*eta_minus)
340 + (((f[2]-f[6])+(f[3]-f[6])) * 2.*xi*xi_minus*eta)
341 + (((f[1]-f[5])+(f[2]-f[5])) * 2.*xi*eta*eta_minus)
342 + (((f[0]-f[7])+(f[3]-f[7])) * 2.*xi_minus*eta*eta_minus));
350 template <
class Field,
class Value>
353 Value *
v)
const throw(
int) {
359 *
v += ((f[1]-f[0]) *= xi);
363 *
v += ((f[1]-f[0]) *= xi*(2.*xi-1.))
364 += ((f[3]-f[0]) *= 4.*xi*(1.-xi));
369 *
v += ((f[1]-f[0]) *= xi)
370 -= (((f[0]-f[4])+=(f[1]-f[4])) *= 2.*xi*(1.-xi));
378 template <
class Field,
class Value>
381 Value *
v)
const throw(
int) {
386 *
v += ((f[1]-f[0]) * xi);
389 *
v += ((f[1]-f[0]) * xi*(2.*xi-1.))
390 + ((f[3]-f[0]) * 4.*xi*(1.-xi));
394 *
v += ((f[1]-f[0]) * xi)
395 - (((f[0]-f[4])+(f[1]-f[4])) * 2.*xi*(1.-xi));
403 template <
class Field,
class Value>
408 for (
Size i=1;
i<_nnodes; ++
i) *
v += f[
i];
412 Real x = size_of_edges()==3 ? 1./3. : 1./2.;
418 template <
class Field>
424 J[0] = f[1]-f[0]; J[1] = f[2]-f[0];
427 const Real xi = nc[0], xi_minus = 1. - xi;
428 const Real eta = nc[1], eta_minus = 1. - eta;
431 J[0] = ((f[1]-f[0]) *= eta_minus) += (( f[2]-f[3]) *= eta );
433 J[1] = ((f[3]-f[0]) *= xi_minus) += (( f[2]-f[1]) *= xi);
437 const Real xi=nc[0], eta=nc[1], zeta=1.-xi-eta;
441 J[0] = ((f[1]-f[0]) *= 4.*xi -1.)
442 += ((f[3]-f[0]) *= 4.*zeta-4*xi)
443 += ((f[4]-f[5]) *= 4.*eta);
446 J[1] = ((f[2]-f[0]) *= 4.*eta -1.)
447 += ((f[5]-f[0]) *= 4*zeta-4*eta)
448 += ((f[4]-f[3]) *= 4.*xi);
452 const Real xi = nc[0], xi_minus = 1. - xi;
453 const Real eta = nc[1], eta_minus = 1. - eta;
459 J[0] = ((f[1]-f[0]) *= eta_minus) += ((f[2]-f[3]) *= eta)
460 -= ((((f[0]-f[4])+=(f[1]-f[4])) *= 2.*eta_minus*(xi_minus-xi))
461 += (((f[2]-f[6])+=(f[3]-f[6])) *= 2.*eta*(xi_minus-xi))
462 += (((f[1]-f[5])+=(f[2]-f[5])-=((f[0]-f[7])+=(f[3]-f[7])))
463 *= 2.*eta*eta_minus));
469 ((J[1] = f[3]-f[0]) *= xi_minus) += ((f[2]-f[1]) *= xi)
470 -= ((((f[1]-f[5])+=(f[2]-f[5])) *= 2.*xi*(eta_minus-eta))
471 += (((f[0]-f[7])+=(f[3]-f[7])) *= 2.*xi_minus*(eta_minus-eta))
472 += (((f[2]-f[6])+=(f[1]-f[4])-=((f[3]-f[6])+=(f[0]-f[4])))
482 template <
class Field>
490 v = f[1] - f[0];
return;
493 v = (((f[1]-f[0]) *= 4.*xi -1.) += ((f[3]-f[0]) *= 4.-8.*xi));
return;
496 v = ((f[1]-f[0]) -= (((f[0]-f[4])+=(f[1]-f[4])) *= 2.-4*xi));
return;
505 template <
class Pnts>
515 solve( J, grads, deriv);
519 template <
class Field>
531 template <
class Field>
543 J2[0] = (1-alpha)*J1[0]+alpha*J2[0];
544 J2[1] = (1-alpha)*J1[1]+alpha*J2[1];
548 J2[0] = J1[0]; J2[1] = J1[1];
SURF::Vector_2< Real > Vector_2
void shape_func_deriv(const Nat_coor &nc, Vector_2 Np[]) const
Evaluates the derivatives of the shape functions.
#define SURF_END_NAMESPACE
Adpator for element-wise data container.
Definition of Generic_element_2, which supports linear/quadratic triangle/quadrilateral elements...
void interpolate(const Field &f, const Nat_coor &nc, Real *v) const
Customized interpolation for primitive data types.
Size order() const
Degree of the element. 1 for linear and 2 for quadratic.
void get_gp_nat_coor(const Size i, Nat_coor &nc, const Size doa=0) const
Get the natrual coordinate associated with a Gauss point.
SURF::Vector_3< Real > Vector_3
Encapsulation of the element-wise computations for two-dimensional elements.
Real get_gp_weight(const Size i, const Size doa=0) const
Get the weight associated with a Gauss point.
Field_traits< Field >::Value interpolate(const Field &f, const Nat_coor &nc) const
Interpolates the field data at a given point and return the result.
void interpolate(const Field &f, const Nat_coor &nc, Value *v) const
Interpolates the field data at a given point.
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
#define SURF_BEGIN_NAMESPACE
void interpolate(const Field &f, const Real xi, Real *v) const
Customized interpolation for primitive data types.
Real Jacobian_det(const Field &f, const Nat_coor &nc) const
Evaluates the determinant of the Jacobian (dx/dxi,dx/deta).
Generic_element_2(Size ne, Size nn=0)
Constructor.
void solve(const Vector_3 M[2], Vector_3 x[], const Vector_2 b[]) const
void shape_func(const Nat_coor &nc, Real N[]) const
Evaluates the shape functions of the element and output the barycentric coordinates into the array N...
Field_traits< Field >::Value interpolate_to_center(const Field &f) const
Interpolates the field data to the center and return the value.
Size size_of_edges() const
Number of edges.
static Vector_3 cross_product(const Vector_3 &v, const Vector_3 &w)
Size size_of_nodes() const
Number of nodes.
Size get_num_gp(const Size doa=0) const
Get the number of Gauss points.
Field_traits< Field >::Value interpolate(const Field &f, const Real xi) const
Interpolates the field data at a given point on an edge and return the result.
void interpolate_nopt(const Field &f, const Nat_coor &nc, Value *v) const
Nonoptimized version of interpolation.
void gradients(const Pnts &ps, const Nat_coor &nc, Vector_3 grads[3]) const
Evaluates the gradient of the shape functions.
void Jacobian(const Field &f, const Nat_coor &nc, Vector_3 J[2]) const
Evaluates the Jacobian at a given point.
Some basic geometric data types.
void interpolate_to_center(const Field &f, Value *v) const
Interpolates the field data to the center of the element.