29 bool operator < (
const constituant &m,
const constituant &n) {
30 if (m.t < n.t)
return true;
31 if (m.t > n.t)
return false;
32 if (m.t == GETFEM_NONLINEAR_) {
33 if (m.nlt < n.nlt)
return true;
34 if (n.nlt < m.nlt)
return false;
35 if (m.nl_part < n.nl_part)
return true;
36 if (m.nl_part > n.nl_part)
return false;
38 if (m.pfi < n.pfi)
return true;
42 bool operator == (
const constituant &m,
const constituant &n) {
43 if (&m == &n)
return true;
44 if (m.t != n.t)
return false;
45 if (m.t == GETFEM_NONLINEAR_) {
46 if (m.nlt != n.nlt)
return false;
47 if (m.nl_part != n.nl_part)
return false;
49 if (m.pfi == n.pfi)
return true;
50 auto pmfi_key = dal::key_of_stored_object(m.pfi);
51 auto pnfi_key = dal::key_of_stored_object(n.pfi);
52 if (*pmfi_key != *pnfi_key)
return false;
57 struct mat_elem_type_key :
virtual public dal::static_stored_object_key {
58 const mat_elem_type *pmet;
60 bool compare(
const static_stored_object_key &oo)
const override{
61 auto &o =
dynamic_cast<const mat_elem_type_key &
>(oo);
62 if (gmm::lexicographical_less<mat_elem_type>()(*pmet, *(o.pmet)) < 0)
66 bool equal(
const static_stored_object_key &oo)
const override{
67 auto &o =
dynamic_cast<const mat_elem_type_key &
>(oo);
68 return *o.pmet == *pmet;
70 mat_elem_type_key(
const mat_elem_type *p) : pmet(p) {}
73 static pmat_elem_type add_to_met_tab(
const mat_elem_type &f) {
74 dal::pstatic_stored_object_key pk = std::make_shared<mat_elem_type_key>(&f);
76 if (o)
return std::dynamic_pointer_cast<const mat_elem_type>(o);
77 pmat_elem_type p = std::make_shared<mat_elem_type>(f);
78 pk = std::make_shared<mat_elem_type_key>(p.get());
82 if (f[i].t == GETFEM_NONLINEAR_ && f[i].nl_part==0)
83 f[i].nlt->register_mat_elem(p);
90 nonlinear_elem_term::~nonlinear_elem_term() {
91 for (std::set<pmat_elem_type>::iterator it=melt_list.begin();
92 it != melt_list.end(); ++it)
97 mat_elem_type f; f.resize(1); f[0].t = GETFEM_BASE_; f[0].pfi = pfi;
99 if (pfi->target_dim() == 1)
100 { f.get_mi().resize(1); f.get_mi()[0] = 1; }
102 f.get_mi().resize(2); f.get_mi()[0] = 1;
103 f.get_mi()[1] = pfi->target_dim();
105 return add_to_met_tab(f);
110 f[0].pfi = 0; f[0].nlt = 0;
111 f.get_mi().resize(1); f.get_mi()[0] = 1;
112 return add_to_met_tab(f);
117 f[0].t = (!inverted) ? GETFEM_GRAD_GEOTRANS_ : GETFEM_GRAD_GEOTRANS_INV_;
118 f[0].pfi = 0; f[0].nlt = 0;
119 f.get_mi().resize(2); f.get_mi()[0] = f.get_mi()[1] = 1;
120 return add_to_met_tab(f);
124 mat_elem_type f; f.resize(1); f[0].t = GETFEM_GRAD_; f[0].pfi = pfi;
126 if (pfi->target_dim() == 1) {
127 f.get_mi().resize(2); f.get_mi()[0] = 1;
128 f.get_mi()[1] = pfi->dim();
131 f.get_mi().resize(3); f.get_mi()[0] = 1;
132 f.get_mi()[1] = pfi->target_dim();
133 f.get_mi()[2] = pfi->dim();
135 return add_to_met_tab(f);
139 mat_elem_type f; f.resize(1); f[0].t = GETFEM_HESSIAN_; f[0].pfi = pfi;
141 if (pfi->target_dim() == 1) {
142 f.get_mi().resize(2); f.get_mi()[0] = 1;
143 f.get_mi()[1] = gmm::sqr(pfi->dim());
146 f.get_mi().resize(3); f.get_mi()[0] = 1;
147 f.get_mi()[1] = pfi->target_dim();
148 f.get_mi()[2] = gmm::sqr(pfi->dim());
150 return add_to_met_tab(f);
153 static pmat_elem_type mat_elem_nonlinear_(pnonlinear_elem_term nlt,
154 pfem pfi,
unsigned nl_part) {
155 mat_elem_type f; f.resize(1);
156 f[0].t = GETFEM_NONLINEAR_; f[0].nl_part = nl_part;
160 f.get_mi().resize(1); f.get_mi()[0] = 1;
161 }
else f.get_mi() = nlt->sizes(
size_type(-1));
162 pmat_elem_type ret = add_to_met_tab(f);
167 std::vector<pfem> pfi) {
168 GMM_ASSERT1(pfi.size() != 0,
"mat_elem_nonlinear with no pfem!");
169 pmat_elem_type me = mat_elem_nonlinear_(nlt, pfi[0], 0);
170 for (
unsigned i=1; i < pfi.size(); ++i)
177 f.get_mi().reserve(a->get_mi().size() + b->get_mi().size());
178 f.insert(f.end(), (*a).begin(), (*a).end());
179 f.insert(f.end(), (*b).begin(), (*b).end());
180 f.get_mi().insert(f.get_mi().end(), (*a).get_mi().begin(),
181 (*a).get_mi().end());
182 f.get_mi().insert(f.get_mi().end(), (*b).get_mi().begin(),
183 (*b).get_mi().end());
184 return add_to_met_tab(f);
187 pmat_elem_type mat_elem_empty() {
188 return add_to_met_tab(mat_elem_type());
191 bgeot::multi_index mat_elem_type::sizes(
size_type cv)
const {
192 bgeot::multi_index mii = mi;
193 for (
size_type i = 0, j = 0; i < size(); ++i, ++j) {
194 switch ((*
this)[i].t) {
196 mii[j] =
short_type((*
this)[i].pfi->nb_base(cv));
197 if ((*
this)[i].pfi->target_dim() != 1) ++j;
200 mii[j] =
short_type((*
this)[i].pfi->nb_base(cv)); ++j;
201 if ((*
this)[i].pfi->target_dim() != 1) ++j;
203 case GETFEM_HESSIAN_ :
204 mii[j] =
short_type((*
this)[i].pfi->nb_base(cv)); ++j;
205 if ((*
this)[i].pfi->target_dim() != 1) ++j;
207 case GETFEM_UNIT_NORMAL_ :
209 case GETFEM_NONLINEAR_ :
210 if ((*
this)[i].nl_part == 0)
211 { j+=(*this)[i].nlt->sizes(
size_type(-1)).size(); --j; }
213 case GETFEM_GRAD_GEOTRANS_:
214 case GETFEM_GRAD_GEOTRANS_INV_:
Description of an elementary matrix.
abstract class for integration of non-linear terms into the mat_elem computations the nonlinear term ...
A simple singleton implementation.
a balanced tree stored in a dal::dynamic_array
elementary computations (used by the generic assembly).
Build elementary tensors descriptors, used by generic assembly.
std::shared_ptr< const getfem::virtual_fem > pfem
type of pointer on a fem description
gmm::uint16_type short_type
used as the common short type integer in the library
size_t size_type
used as the common size type in the library
void add_stored_object(pstatic_stored_object_key k, pstatic_stored_object o, permanence perm)
Add an object with two optional dependencies.
void add_dependency(pstatic_stored_object o1, pstatic_stored_object o2)
Add a dependency, object o1 will depend on object o2.
void del_stored_object(const pstatic_stored_object &o, bool ignore_unstored)
Delete an object and the object which depend on it.
pstatic_stored_object search_stored_object(pstatic_stored_object_key k)
Gives a pointer to an object from a key pointer.
bool exists_stored_object(pstatic_stored_object o)
Test if an object is stored.
GEneric Tool for Finite Element Methods.
pmat_elem_type mat_elem_unit_normal(void)
Give a pointer to the structure describing the elementary matrix which compute the unit normal on the...
pmat_elem_type mat_elem_hessian(pfem pfi)
Give a pointer to the structure describing the elementary matrix which compute the integral of the he...
pmat_elem_type mat_elem_nonlinear(pnonlinear_elem_term, std::vector< pfem > pfi)
Give a pointer to the structure describing the elementary matrix which compute the integral of a nonl...
pmat_elem_type mat_elem_base(pfem pfi)
Give a pointer to the structure describing the elementary matrix which compute the integral of the ba...
pmat_elem_type mat_elem_grad_geotrans(bool inverted)
Return the gradient of the geometrical transformation ("K" in the getfem++ kernel doc....
pmat_elem_type mat_elem_product(pmat_elem_type a, pmat_elem_type b)
Give a pointer to the structure describing the elementary matrix which computes the integral of produ...
pmat_elem_type mat_elem_grad(pfem pfi)
Give a pointer to the structure describing the elementary matrix which compute the integral of the gr...