.\" .de Id .. .de Sp .if n .sp .if t .sp 0.4 .. .TH field 2rheolef "rheolef-6.1" "rheolef-6.1" "rheolef-6.1" .\" label: /*Class:field .SH NAME \fBfield\fP - piecewise polynomial finite element field .SH DESCRIPTION Store degrees of freedom associated to a mesh and a piecewise polynomial approximation, with respect to the numbering defined by the underlying space(2). .PP This class contains two vectors, namely unknown and blocked degrees of freedoms, and the associated finite element space. Blocked and unknown degrees of freedom can be set by using domain name indexation: .\" begin_example .Sp .nf geo omega ("circle"); space Vh (omega, "P1"); Vh.block ("boundary"); field uh (Vh); uh ["boundary"] = 0; .Sp .fi .\" end_example .PP .SH INTERPOLATION Interpolation of a function \fBu\fP in a field \fBuh\fP with respect to the interpolation writes: .\" begin_example .Sp .nf Float u (const point& x) { return x[0]*x[1]; } ... field uh = interpolate (Vh, u); .Sp .fi .\" end_example .PP .SH LINEAR ALGEBRA Linear algebra, such as \fBuh+vh\fP, \fBuh-vh\fP, \fBlambda*uh + mu*vh\fP, ...are supported. The Euclidian dot product writes simply \fBdot(uh,vh)\fP. The application of a bilinear form (see form(2)) writes \fBm(uh,vh)\fP and is equivalent to \fBdot(m*uh,vh)\fP. .PP .SH NON-LINEAR ALGEBRA Non-linear operations, such as \fBsqrt(uh)\fP or \fB1/uh\fP are also available. Notice that non-linear operations do not returns in general picewise polynomials: the value returned by \fBsqrt(uh)\fP is the Lagrange interpolant of the square root of \fBuh\fP. These operators applies directly to the set of degrees-of-freedom (dofs, see below). All standard unary and binary math functions \fBabs, cos, sin\fP... are available on fields. Also \fBsqr(uh)\fP, the square of a field, and \fBmin(uh,vh)\fP, \fBmax(uh,vh)\fP are provided. Binary functions can be used also with a scalar, as in .\" begin_example .Sp .nf field wh = max (abs(uh), 0); field zh = pow (abs(uh), 1./3); .Sp .fi .\" end_example For applying a user-provided function to a field, use: .\" begin_example .Sp .nf field vh = compose(f, uh); field wh = compose(f, uh, vh); .Sp .fi .\" end_example The composition supports also general unary and binary class-functions. .PP For convenience, \fBuh.max()\fP, \fBuh.min()\fP and \fBuh.max_abs()\fP retuns respectively the maximum, minimum and maximum of the absolute value. .PP .SH ACCESS BY DOMAIN The restriction of a field to a geometric domain, says \fB"boundary"\fP writes \fBuh["boundary"]\fP: it represents the trace of the field on the boundary: .\" begin_example .Sp .nf space Vh (omega, "P1"); uh["boundary"] = 0; .Sp .fi .\" end_example Extraction of the trace as a field is also possible: .\" begin_example .Sp .nf field wh = uh["boundary"]; .Sp .fi .\" end_example The space associated to the trace writes \fBwh.get_space()\fP and is equivalent to \fBspace(omega["boundary"], "P1")\fP. See see space(2). .PP .SH VECTOR VALUED FIELD A vector-valued field contains several components, as: .\" begin_example .Sp .nf space Vh (omega, "P2", "vector"); field uh (Vh); field vh = uh[0] - uh[1]; field nh = norm (uh); .Sp .fi .\" end_example The \fBnorm\fP function returns the euclidian norm of the vector-valuated field at each degree of freedom: its result is a scalar field. .PP .SH TENSOR VALUED FIELD A tensor-valued field can be constructed and used as: .\" begin_example .Sp .nf space Th (omega, "P1d", "tensor"); field sigma_h (Vh); field trace_h = sigma(0,0) + sigma_h(1,1); field nh = norm (sigma_h); .Sp .fi .\" end_example The \fBnorm\fP function returns the euclidian norm of the tensor-valuated field at each degree of freedom: its result is a scalar field. Notice that, as tensor-valued fields are symmetric, extra-diagonals are counted twice. .PP .SH GENERAL MULTI-COMPONENT INTERFACE A general multi-component field writes: .\" begin_example .Sp .nf space Th (omega, "P1d", "tensor"); space Vh (omega, "P2", "vector"); space Qh (omega, "P1"); space Xh = Th*Vh*Qh; field xh (Xh); field tau_h = xh[0]; // tensor-valued field uh = xh[1]; // vector-valued field qh = xh[2]; // scalar .Sp .fi .\" end_example Remark the hierarchical multi-component field structure: the first-component is tensor-valued and the second-one is vector-valued. There is no limitation upon the hierarchical number of levels in use. .PP For any field \fBxh\fP, the string \fBxh.valued()\fP returns \fB"scalar"\fP for a scalar field and \fB"vector"\fP for a vector-valued one. Other possible valued are \fB"tensor"\fP and \fB"other"\fP. The \fBxh.size()\fP returns the number of field components. When the field is scalar, it returns zero by convention, and \fBxh[0]\fP is undefined. A vector-valued field has \fBd\fP components, where \fBd=omega.dimension()\fP. A tensor-valued field has \fBd*(d+1)/2\fP components, where \fBd=omega.dimension()\fP. .PP .SH BLOCKED AND UNBLOCKED ARRAYS The field class contains two arrays of degrees-of-freedom (dof) associated respectively to blocked and unknown dofs. Blocked dofs corresponds to Dirichlet boundary conditions, as specified by space (See see space(2)). For simpliity, direct public access to these array is allowed, as \fBuh.b\fP and \fBuh.u\fP: see see vec(2). .PP .SH LOW-LEVEL DEGREE-OF-FREEDOM ACCESS The field class provides a STL-like container interface for accessing the degrees-of-freedom (dof) of a finite element field \fBuh\fP. The number of dofs is \fBuh.ndof()\fP and any dof can be accessed via \fBuh.dof(idof)\fP. A non-local dof at the partition interface can be obtain via \fBuh.dis_dof(dis_idof)\fP where \fBdis_idof\fP is the (global) distribued index assoiated to the distribution \fBuh.ownership()\fP. .PP For performances, a STL-like iterator interface is available, with \fBuh.begin_dof()\fP and \fBuh.end_dof()\fP returns iterators to the arrays of dofs on the current processor. See see array(2) for more about distributed arrays. .PP .SH FILE FORMAT TODO .PP .SH IMPLEMENTATION NOTE The field expression use the expression template technics in order to avoid temporaries when evaluating complex expressions. .\" skip start:AUTHOR: .\" skip start:DATE: .\" END .SH IMPLEMENTATION .\" begin_example .Sp .nf template class field_basic : public std::unary_function::type>,T> { public : // typedefs: typedef typename std::size_t size_type; typedef T value_type; typedef typename scalar_traits::type float_type; typedef geo_basic geo_type; typedef space_basic space_type; typedef space_constant::valued_type valued_type; class iterator; class const_iterator; // allocator/deallocator: field_basic(); explicit field_basic ( const space_type& V, const T& init_value = std::numeric_limits::max()); void resize ( const space_type& V, const T& init_value = std::numeric_limits::max()); field_basic (const field_indirect&); field_basic& operator= (const field_indirect&); field_basic (const field_indirect_const&); field_basic& operator= (const field_indirect_const&); field_basic (const field_component&); field_basic& operator= (const field_component&); field_basic (const field_component_const&); field_basic& operator= (const field_component_const&); template field_basic (const field_expr&); template field_basic& operator= (const field_expr&); field_basic& operator= (const T&); // initializer list (c++ 2011): #ifdef _RHEOLEF_HAVE_STD_INITIALIZER_LIST field_basic (const std::initializer_list >& init_list); field_basic& operator= (const std::initializer_list >& init_list); #endif // _RHEOLEF_HAVE_STD_INITIALIZER_LIST // accessors: const space_type& get_space() const { return _V; } const geo_type& get_geo() const { return _V.get_geo(); } std::string stamp() const { return _V.stamp(); } std::string get_approx() const { return _V.get_approx(); } valued_type valued_tag() const { return _V.valued_tag(); } const std::string& valued() const { return _V.valued(); } // accessors & modifiers to unknown & blocked parts: const vec& u() const { dis_dof_update_needed(); return _u; } const vec& b() const { dis_dof_update_needed(); return _b; } vec& set_u() { return _u; } vec& set_b() { return _b; } // accessors to extremas: T min() const; T max() const; T max_abs() const; T min_abs() const; // accessors by domains: field_indirect operator[] (const geo_basic& dom); field_indirect_const operator[] (const geo_basic& dom) const; field_indirect operator[] (std::string dom_name); field_indirect_const operator[] (std::string dom_name) const; // accessors by components: size_type size() const { return _V.size(); } field_component operator[] (size_type i_comp); field_component_const operator[] (size_type i_comp) const; field_component operator() (size_type i_comp, size_type j_comp); field_component_const operator() (size_type i_comp, size_type j_comp) const; // accessors by degrees-of-freedom (dof): const distributor& ownership() const { return get_space().ownership(); } const communicator& comm() const { return ownership().comm(); } size_type ndof() const { return ownership().size(); } size_type dis_ndof() const { return ownership().dis_size(); } T& dof (size_type idof); const T& dof (size_type idof) const; const T& dis_dof (size_type dis_idof) const; iterator begin_dof(); iterator end_dof(); const_iterator begin_dof() const; const_iterator end_dof() const; // input/output: idiststream& get (idiststream& ips); odiststream& put (odiststream& ops) const; odiststream& put_field (odiststream& ops) const; // evaluate uh(x) where x is given locally as hat_x in K: T dis_evaluate (const point_basic& x, size_type i_comp = 0) const; T operator() (const point_basic& x) const { return dis_evaluate (x,0); } // internals: public: // evaluate uh(x) where x is given locally as hat_x in K: // requiers to call field::dis_dof_upgrade() before. T evaluate (const geo_element& K, const point_basic& hat_xq, size_type i_comp = 0) const; // propagate changed values shared at partition boundaries to others procs void dis_dof_update() const; protected: void dis_dof_update_internal() const; void dis_dof_update_needed() const; // data: space_type _V; vec _u; vec _b; mutable bool _dis_dof_update_needed; }; template idiststream& operator >> (odiststream& ips, field_basic& u); template odiststream& operator << (odiststream& ops, const field_basic& uh); template field_basic norm (const field_basic& uh); template field_basic norm2 (const field_basic& uh); typedef field_basic field; typedef field_basic field_sequential; .Sp .fi .\" end_example .\" LENGTH = 6 .SH SEE ALSO space(2), form(2), space(2), space(2), vec(2), array(2)