[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Getfem-commits] (no subject)
From: |
Konstantinos Poulios |
Subject: |
[Getfem-commits] (no subject) |
Date: |
Fri, 7 Sep 2018 05:51:40 -0400 (EDT) |
branch: master
commit 7d42374ef9c632a930f8559d8967245f23336d95
Merge: f08de78 703515f
Author: Konstantinos Poulios <address@hidden>
Date: Fri Sep 7 08:49:23 2018 +0200
Merge branch 'code-cleanup'
# Manually resolved conflicts:
# src/getfem_generic_assembly_semantic.cc
interface/src/gf_asm.cc | 39 +-
src/bgeot_convex_ref.cc | 13 +-
src/bgeot_geotrans_inv.cc | 283 ++-
src/bgeot_node_tab.cc | 2 +-
src/getfem/bgeot_convex_ref.h | 2 +-
src/getfem/bgeot_geometric_trans.h | 2 -
src/getfem/bgeot_geotrans_inv.h | 110 +-
src/getfem/getfem_generic_assembly_tree.h | 4 +-
src/getfem/getfem_mesh.h | 2 +-
src/getfem/getfem_models.h | 25 +-
src/getfem_contact_and_friction_common.cc | 2 +-
src/getfem_fem.cc | 30 +-
src/getfem_generic_assembly_compile_and_exec.cc | 708 ++++---
src/getfem_generic_assembly_semantic.cc | 2404 +++++++++++------------
src/getfem_generic_assembly_workspace.cc | 6 +-
src/getfem_global_function.cc | 3 +-
src/getfem_interpolation.cc | 5 +-
src/getfem_mesh.cc | 6 +-
src/getfem_models.cc | 23 +-
src/getfem_projected_fem.cc | 63 +-
20 files changed, 1850 insertions(+), 1882 deletions(-)
diff --cc interface/src/gf_asm.cc
index 1e76be1,20d97d9..d746be6
--- a/interface/src/gf_asm.cc
+++ b/interface/src/gf_asm.cc
@@@ -781,29 -752,23 +781,29 @@@ void gf_asm(getfemint::mexargs_in& m_in
tangent (matrix) (order = 2) is to be computed.
`model` is an optional parameter allowing to take into account
- all variables and data of a model. Optionnally, for the integration
- on the product of two domains, a secondary domain of the model can
- be specified after a 'Secondary_domain' string.
-
- The variables and constant (data) are listed after the
- region number (or optionally the model).
- For each variable/constant, first the variable/constant
- name should be given (as it is referred in the assembly string), then
- 1 if it is a variable or 0 for a constant, then the finite element
- method if it is a fem variable/constant or the mesh_im_data if it is
- data defined on integration points, and the vector representing
- the value of the variable/constant. It is possible to give an arbitrary
- number of variable/constant. The difference between a variable and a
- constant is that automatic differentiation is done with respect to
- variables only (see GetFEM++ user documentation). Test functions are
- only available for variables, not for constants.
+ all variables and data of a model. Note that all enabled variables
+ of the model will occupy space in the returned vector/matrix
+ corresponding to their degrees of freedom in the global system, even
+ if they are not present in `expression`.
+
+ The variables and constants (data) are listed after the region number
+ (or optionally the model).
+ For each variable/constant, a name must be given first (as it is
+ referred in the assembly string), then an integer equal to 1 or 0
+ is expected respectively for declaring a variable or a constant,
+ then the finite element method if it is a fem variable/constant or
+ the mesh_im_data if it is data defined on integration points, and
+ the vector representing the value of the variable/constant.
+ It is possible to give an arbitrary number of variable/constant.
+ The difference between a variable and a constant is that test
+ functions are only available for variables, not for constants.
+ `select_output` is an optional parameter which allows to reduce the
+ output vecotr (for `order` equal to 1) or the matrix (for `order`
+ equal to 2) to the degrees of freedom of the specified variables.
+ One variable has to be specified for a vector ouptut and two for a
+ matrix output.
+
Note that if several variables are given, the assembly of the
tangent matrix/residual vector will be done considering the order
in the call of the function (the degrees of freedom of the first
diff --cc src/getfem_generic_assembly_semantic.cc
index aebe6fb,54be6d9..524e05e
--- a/src/getfem_generic_assembly_semantic.cc
+++ b/src/getfem_generic_assembly_semantic.cc
@@@ -38,9 -38,8 +38,9 @@@ namespace getfem
const std::string &interpolatename, size_type order);
static void ga_node_grad(ga_tree &tree, const ga_workspace &workspace,
- const mesh &m, pga_tree_node pnode);
+ const mesh &m, pga_tree_node pnode);
- static bool ga_node_mark_tree_for_grad(pga_tree_node pnode);
+ static bool ga_node_mark_tree_for_grad(pga_tree_node pnode,
+ const ga_workspace &workspace);
static void ga_node_analysis(ga_tree &tree,
const ga_workspace &workspace,
pga_tree_node pnode, const mesh &me,
@@@ -195,35 -194,35 +195,35 @@@
bool need_hess = (pnode->node_type == GA_NODE_HESS_TEST);
if (need_grad && grad_expr.root == nullptr) {
- tree.copy_node(pexpr, nullptr, grad_expr.root);
- if (ga_node_mark_tree_for_grad(grad_expr.root, workspace)) {
- ga_node_grad(grad_expr, workspace, me, grad_expr.root);
- ga_node_analysis(grad_expr, workspace, grad_expr.root, me,
- ref_elt_dim, eval_fixed_size, ignore_X, option);
- } else {
- bgeot::multi_index mi = grad_expr.root->t.sizes();
- mi.push_back(me.dim());
- grad_expr.root->t.adjust_sizes(mi);
- grad_expr.root->node_type = GA_NODE_ZERO;
- gmm::clear(grad_expr.root->tensor().as_vector());
- grad_expr.clear_children(grad_expr.root);
- }
+ tree.copy_node(pexpr, nullptr, grad_expr.root);
- if (ga_node_mark_tree_for_grad(grad_expr.root)) {
++ if (ga_node_mark_tree_for_grad(grad_expr.root, workspace)) {
+ ga_node_grad(grad_expr, workspace, me, grad_expr.root);
+ ga_node_analysis(grad_expr, workspace, grad_expr.root, me,
+ ref_elt_dim, eval_fixed_size, ignore_X, option);
+ } else {
+ bgeot::multi_index mi = grad_expr.root->t.sizes();
+ mi.push_back(me.dim());
+ grad_expr.root->t.adjust_sizes(mi);
+ grad_expr.root->node_type = GA_NODE_ZERO;
+ gmm::clear(grad_expr.root->tensor().as_vector());
+ grad_expr.clear_children(grad_expr.root);
+ }
}
if (need_hess && hess_expr.root == nullptr) {
- tree.copy_node(grad_expr.root, nullptr, hess_expr.root);
- if (ga_node_mark_tree_for_grad(hess_expr.root, workspace)) {
- ga_node_grad(hess_expr, workspace, me, hess_expr.root);
- ga_node_analysis(hess_expr, workspace, hess_expr.root, me,
- ref_elt_dim, eval_fixed_size, ignore_X, option);
- } else {
- bgeot::multi_index mi = hess_expr.root->t.sizes();
- mi.push_back(me.dim());
- hess_expr.root->t.adjust_sizes(mi);
- hess_expr.root->node_type = GA_NODE_ZERO;
- gmm::clear(hess_expr.root->tensor().as_vector());
- hess_expr.clear_children(grad_expr.root);
- }
+ tree.copy_node(grad_expr.root, nullptr, hess_expr.root);
- if (ga_node_mark_tree_for_grad(hess_expr.root)) {
++ if (ga_node_mark_tree_for_grad(hess_expr.root, workspace)) {
+ ga_node_grad(hess_expr, workspace, me, hess_expr.root);
+ ga_node_analysis(hess_expr, workspace, hess_expr.root, me,
+ ref_elt_dim, eval_fixed_size, ignore_X, option);
+ } else {
+ bgeot::multi_index mi = hess_expr.root->t.sizes();
+ mi.push_back(me.dim());
+ hess_expr.root->t.adjust_sizes(mi);
+ hess_expr.root->node_type = GA_NODE_ZERO;
+ gmm::clear(hess_expr.root->tensor().as_vector());
+ hess_expr.clear_children(grad_expr.root);
+ }
}
switch(pnode->node_type) {
case GA_NODE_VAL_TEST:
@@@ -374,14 -373,14 +374,14 @@@
return c;
}
- # define ga_valid_operand(pnode) \
- { \
- if (pnode && (pnode->node_type == GA_NODE_PREDEF_FUNC || \
- pnode->node_type == GA_NODE_SPEC_FUNC || \
- pnode->node_type == GA_NODE_NAME || \
- pnode->node_type == GA_NODE_OPERATOR || \
- pnode->node_type == GA_NODE_ALLINDICES)) \
- ga_throw_error(pnode->expr, pnode->pos, "Invalid term"); \
+ # define ga_valid_operand(pnode) \
- { \
- if (pnode && (pnode->node_type == GA_NODE_PREDEF_FUNC || \
- pnode->node_type == GA_NODE_SPEC_FUNC || \
- pnode->node_type == GA_NODE_NAME || \
- pnode->node_type == GA_NODE_OPERATOR || \
- pnode->node_type == GA_NODE_ALLINDICES)) \
- ga_throw_error(pnode->expr, pnode->pos, "Invalid term"); \
++ { \
++ if (pnode && (pnode->node_type == GA_NODE_PREDEF_FUNC || \
++ pnode->node_type == GA_NODE_SPEC_FUNC || \
++ pnode->node_type == GA_NODE_NAME || \
++ pnode->node_type == GA_NODE_OPERATOR || \
++ pnode->node_type == GA_NODE_ALLINDICES)) \
++ ga_throw_error(pnode->expr, pnode->pos, "Invalid term"); \
}
static void ga_node_analysis(ga_tree &tree,
@@@ -1860,70 -1860,69 +1860,70 @@@
// Grad and Diff operators
if (child0->node_type == GA_NODE_NAME) {
- if (child0->name.compare("Grad") == 0) {
+ if (child0->name.compare("Grad") == 0) {
+ // cout<<"Compute gradient of
";ga_print_node(child1,cout);cout<<endl;
- if (pnode->children.size() != 2)
- ga_throw_error(pnode->expr, child0->pos,
- "Bad number of parameters for Grad operator");
- if (ga_node_mark_tree_for_grad(child1, workspace)) {
+ if (pnode->children.size() != 2)
+ ga_throw_error(pnode->expr, child0->pos,
+ "Bad number of parameters for Grad operator");
- if (ga_node_mark_tree_for_grad(child1)) {
++ if (ga_node_mark_tree_for_grad(child1, workspace)) {
ga_node_grad(tree, workspace, me, child1);
ga_node_analysis(tree, workspace, pnode->children[1], me,
- ref_elt_dim, eval_fixed_size, ignore_X, option);
- child1 = pnode->children[1];
- } else {
- mi = child1->t.sizes(); mi.push_back(meshdim);
- child1->t.adjust_sizes(mi);
- child1->node_type = GA_NODE_ZERO;
- gmm::clear(child1->tensor().as_vector());
- tree.clear_children(child1);
- }
- tree.replace_node_by_child(pnode, 1);
- pnode = child1;
- } else if (child0->name.compare("Diff") == 0) {
-
- if (pnode->children.size() != 3 && pnode->children.size() != 4)
- ga_throw_error(pnode->expr, child0->pos,
- "Bad number of parameters for Diff operator");
- pga_tree_node child2 = pnode->children[2];
- if (child2->node_type != GA_NODE_VAL)
- ga_throw_error(pnode->expr, child2->pos, "Second parameter of "
- "Diff operator has to be a variable name");
- std::string vardiff = child2->name;
- size_type order = child1->test_function_type;
- if (order > 1)
- ga_throw_error(pnode->expr, child2->pos, "Cannot derive further "
- "this order two expression");
-
- if (ga_node_mark_tree_for_variable(child1,workspace,me,vardiff,"")) {
- ga_node_derivation(tree, workspace, me, child1, vardiff,"",order+1);
- child1 = pnode->children[1];
- ga_node_analysis(tree, workspace, child1, me, ref_elt_dim,
- eval_fixed_size, ignore_X, option);
- child1 = pnode->children[1];
- } else {
- mi = child1->t.sizes(); mi.insert(mi.begin(), 2);
- child1->t.adjust_sizes(mi);
- child1->node_type = GA_NODE_ZERO;
- child1->test_function_type = order ? 3 : 1;
- gmm::clear(child1->tensor().as_vector());
- tree.clear_children(child1);
- }
- if (pnode->children.size() == 4) {
- ga_tree grad_expr, hess_expr;
- ga_node_expand_expression_in_place_of_test
- (tree, workspace, pnode->children[1], vardiff, pnode->children[3],
- grad_expr, hess_expr, order+1, me, ref_elt_dim, eval_fixed_size,
- ignore_X, option);
+ ref_elt_dim, eval_fixed_size, ignore_X, option);
+ child1 = pnode->children[1];
+ } else {
+ mi = child1->t.sizes(); mi.push_back(meshdim);
+ child1->t.adjust_sizes(mi);
+ child1->node_type = GA_NODE_ZERO;
+ gmm::clear(child1->tensor().as_vector());
+ tree.clear_children(child1);
+ }
+ tree.replace_node_by_child(pnode, 1);
+ pnode = child1;
+ } else if (child0->name.compare("Diff") == 0) {
+
+ if (pnode->children.size() != 3 && pnode->children.size() != 4)
+ ga_throw_error(pnode->expr, child0->pos,
+ "Bad number of parameters for Diff operator");
+ pga_tree_node child2 = pnode->children[2];
+ if (child2->node_type != GA_NODE_VAL)
+ ga_throw_error(pnode->expr, child2->pos, "Second parameter of "
+ "Diff operator has to be a variable name");
+ std::string vardiff = child2->name;
+ size_type order = child1->test_function_type;
+ if (order > 1)
+ ga_throw_error(pnode->expr, child2->pos, "Cannot derive further "
+ "this order two expression");
+
+ if (ga_node_mark_tree_for_variable(child1,workspace,me,vardiff,""))
{
+ ga_node_derivation(tree, workspace, me, child1,
vardiff,"",order+1);
+ child1 = pnode->children[1];
+ ga_node_analysis(tree, workspace, child1, me, ref_elt_dim,
+ eval_fixed_size, ignore_X, option);
+ child1 = pnode->children[1];
+ } else {
+ mi = child1->t.sizes(); mi.insert(mi.begin(), 2);
+ child1->t.adjust_sizes(mi);
+ child1->node_type = GA_NODE_ZERO;
+ child1->test_function_type = order ? 3 : 1;
+ gmm::clear(child1->tensor().as_vector());
+ tree.clear_children(child1);
+ }
+ if (pnode->children.size() == 4) {
+ ga_tree grad_expr, hess_expr;
+ ga_node_expand_expression_in_place_of_test
+ (tree, workspace, pnode->children[1], vardiff,
pnode->children[3],
+ grad_expr, hess_expr, order+1, me, ref_elt_dim,
eval_fixed_size,
+ ignore_X, option);
ga_node_analysis(tree, workspace, pnode->children[1], me,
- ref_elt_dim, eval_fixed_size, ignore_X, option);
- }
- child1 = pnode->children[1];
- tree.replace_node_by_child(pnode, 1);
- pnode = child1;
- } else
- ga_throw_error(pnode->expr, child0->pos, "Unknown special operator");
+ ref_elt_dim, eval_fixed_size, ignore_X, option);
+ }
+ child1 = pnode->children[1];
+ tree.replace_node_by_child(pnode, 1);
+ pnode = child1;
+ } else
+ ga_throw_error(pnode->expr, child0->pos, "Unknown special
operator");
}
-
+
// X (current coordinates on the mesh)
else if (child0->node_type == GA_NODE_X) {
child0->init_scalar_tensor(0);
@@@ -3795,26 -3793,22 +3795,26 @@@
pnode->node_type == GA_NODE_INTERPOLATE_HESS_TEST ||
pnode->node_type == GA_NODE_INTERPOLATE_DIVERG_TEST);
- if (plain_node || test_node || interpolate_node ||
- elementary_node || xfem_node ||
- pnode->node_type == GA_NODE_X ||
+ if ((plain_node || test_node || interpolate_node ||
- elementary_node || xfem_node) &&
++ elementary_node || xfem_node) &&
+ (workspace.associated_mf(pnode->name) != 0)) marked = true;
+
+ if (pnode->node_type == GA_NODE_X ||
- pnode->node_type == GA_NODE_NORMAL) marked = true;
+ pnode->node_type == GA_NODE_NORMAL) marked = true;
- if (interpolate_node || interpolate_test_node ||
- pnode->node_type == GA_NODE_INTERPOLATE_X ||
+ if ((interpolate_node || interpolate_test_node) &&
+ (workspace.associated_mf(pnode->name) != 0)) marked = true;
+
+ if (pnode->node_type == GA_NODE_INTERPOLATE_X ||
pnode->node_type == GA_NODE_INTERPOLATE_NORMAL) marked = true;
-
+
pnode->marked = marked;
return marked;
}
static void ga_node_grad(ga_tree &tree, const ga_workspace &workspace,
- const mesh &m, pga_tree_node pnode) {
+ const mesh &m, pga_tree_node pnode) {
-
+ // cout << "Gradient of "; ga_print_node(pnode, cout); cout << endl;
size_type meshdim = (&m == &dummy_mesh()) ? 1 : m.dim();
size_type nbch = pnode->children.size();
pga_tree_node child0 = (nbch > 0) ? pnode->children[0] : 0;
@@@ -4739,10 -4733,9 +4739,10 @@@
default: GMM_ASSERT1(false, "Unexpected node type " << pnode->node_type
<< " in gradient. Internal error.");
}
+ // cout << "End of gradient of "; ga_print_node(pnode, cout); cout <<
endl;
}
-
-
+
+
// The tree is modified. Should be copied first and passed to
// ga_semantic_analysis after for enrichment
void ga_grad(ga_tree &tree, const ga_workspace &workspace, const mesh &m) {