Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
field_concept.h
Go to the documentation of this file.
1# ifndef _RHEOLEF_FIELD_CONCEPT_H
2# define _RHEOLEF_FIELD_CONCEPT_H
3//
4// This file is part of Rheolef.
5//
6// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
7//
8// Rheolef is free software; you can redistribute it and/or modify
9// it under the terms of the GNU General Public License as published by
10// the Free Software Foundation; either version 2 of the License, or
11// (at your option) any later version.
12//
13// Rheolef is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License
19// along with Rheolef; if not, write to the Free Software
20// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21//
22// =========================================================================
23// field_wdof concept: field with read & write accessors at the dof level
24// terminals: field_basic, field_wdof_sliced, field_indirect
25// AUTHOR: Pierre.Saramito@imag.fr
26// DATE: 21 april 2020
27
28#include "rheolef/space_constant.h"
29
30namespace rheolef { namespace details {
31
32// define concept: for filtering the field_basic class:
33template<class FieldWdof, class Sfinae = void>
34struct is_field: std::false_type {};
35
36// define concept: is_field_wdof
37template<class FieldWdof, class Sfinae = void>
38struct is_field_wdof: std::false_type {};
39
40// define concept: has_field_wdof_interface
41template<class FieldWdof, class Sfinae = void>
42struct has_field_wdof_interface: std::false_type {};
43
44template<class FieldWdof>
45struct has_field_wdof_interface <FieldWdof, typename std::enable_if<
46 is_field_wdof<FieldWdof>::value>::type> : std::true_type {};
47
48template<class FieldWdof>
49struct has_field_wdof_interface <FieldWdof, typename std::enable_if<
50 is_field<FieldWdof>::value>::type> : std::true_type {};
51
52// define concept: is_field_rdof
53template<class FieldRdof, class Sfinae = void>
54struct is_field_rdof: std::false_type {};
55
56// define concept: has_field_rdof_interface
57template<class FieldRdof, class Sfinae = void>
58struct has_field_rdof_interface: std::false_type {};
59
60template<class FieldRdof>
61struct has_field_rdof_interface <FieldRdof, typename std::enable_if<
62 is_field_rdof<FieldRdof>::value>::type> : std::true_type {};
63
64template<class FieldRdof>
65struct has_field_rdof_interface<FieldRdof, typename std::enable_if<
66 has_field_wdof_interface<FieldRdof>::value>::type> : std::true_type {};
67
68// define concept: is_field_lazy
69template<class FieldLazy, class Sfinae = void>
70struct is_field_lazy: std::false_type {};
71
72// define concept: has_field_lazy_interface
73template<class FieldLazy, class Sfinae = void>
74struct has_field_lazy_interface: std::false_type {};
75
76template<class FieldLazy>
77struct has_field_lazy_interface <FieldLazy, typename std::enable_if<
78 is_field_lazy<FieldLazy>::value>::type> : std::true_type {};
79
80template<class FieldLazy>
81struct has_field_lazy_interface<FieldLazy, typename std::enable_if<
82 has_field_rdof_interface<FieldLazy>::value>::type> : std::true_type {};
83
84// define concept: field expression valid arguments
85// -> constant and field_convertible are valid terminals:
86// TODO: merge with has_field_lazy_interface ?
87template<class Expr, class Sfinae = void>
88struct is_field_expr_v2_nonlinear_arg : std::false_type {};
89template<class Expr>
90struct is_field_expr_v2_nonlinear_arg <Expr, typename std::enable_if<
91 is_field_expr_v2_constant<Expr>::value>::type> : std::true_type {};
92template<class Expr>
93struct is_field_expr_v2_nonlinear_arg <Expr, typename std::enable_if<
94 has_field_rdof_interface<Expr>::value>::type> : std::true_type {};
95
96// define concept: linear & homogeneous expressions
97// -> these expressions should act homogeneously in the same finite element space
98// TODO: rename as is_field_piecewise_polynomial<FieldLazy>
99template<class FieldLazy, class Sfinae = void>
100struct is_field_expr_affine_homogeneous: std::false_type {};
101template<class Expr>
102struct is_field_expr_affine_homogeneous <Expr, typename std::enable_if<
103 is_field_expr_v2_constant<Expr>::value>::type> : std::true_type {};
104template<class Expr>
105struct is_field_expr_affine_homogeneous <Expr, typename std::enable_if<
106 has_field_rdof_interface<Expr>::value>::type> : std::true_type {};
107
108// ---------------------------------------------------------------------------
109// class F is field_functor or field_true_function ?
110//
111// is_field_true_function : F = R (const point_basic<T>&)
112// is_field_functor : F have R (F::*) (const point_basic<T>&) const
113// with some T = some float type and R = any result_type
114// ---------------------------------------------------------------------------
115// is_field_true_function
116template<class F> struct is_field_true_function : std::false_type {};
117template<class R, class T> struct is_field_true_function <R(const point_basic<T>&)> : std::true_type {};
118template<class R, class T> struct is_field_true_function <R(*)(const point_basic<T>&)> : std::true_type {};
119
120// is_field_functor
121template<class F, class Sfinae = void> struct is_field_functor : std::false_type {};
122template<class F> struct is_field_functor<F,typename std::enable_if<
123 std::conjunction<
124 std::negation<has_field_lazy_interface<F>>
125 ,std::is_class<F>
126 ,is_functor<F>
127 ,std::disjunction<
128 // TODO: arg = basic_point<T> with any T instead of T=Float
129 is_callable<F, Float (const point&) const>
130 ,is_callable<F, point (const point&) const>
131 ,is_callable<F, tensor (const point&) const>
132 ,is_callable<F, tensor3(const point&) const>
133 ,is_callable<F, tensor4(const point&) const>
134 >
135#ifdef TODO
136 // TODO: result from functor F instead of any one ?
137 ,is_callable<F,typename get_functor_result<F>::type (const point&) const>
138#endif // TODO
139 >::value
140 >::type
141> : std::true_type {};
142
143// is_field_function = is_field_true_function || is_field_functor
144template<class F, class Sfinae = void> struct is_field_function : std::false_type {};
145template<class F> struct is_field_function<F,
146 typename std::enable_if<
147 std::disjunction<
148 is_field_true_function<F>
149 ,is_field_functor<F>
150 >::value
151 >::type
152> : std::true_type {};
153
154template<class F, class Sfinae = void> struct field_function_traits {};
155#ifdef TO_CLEAN
156template<class R, class T> struct field_function_traits <R(*)(const point_basic<T>&)> :
158#endif // TO_CLEAN
159template<class F> struct field_function_traits<F,
160 typename std::enable_if<
161 is_field_true_function<F>::value
162 >::type
163> {
165};
166template<class F> struct field_function_traits<F,
167 typename std::enable_if<
168 is_field_functor<F>::value
169 >::type
170> {
172};
173
174}}// namespace rheolef::details
175# endif /* _RHEOLEF_FIELD_CONCEPT_H */
Expr1::float_type T
Definition field_expr.h:230
This file is part of Rheolef.
STL namespace.