[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Getfem-commits] [getfem-commits] branch master updated: Fix regression
From: |
Konstantinos Poulios |
Subject: |
[Getfem-commits] [getfem-commits] branch master updated: Fix regression in the directional differentiation operator |
Date: |
Wed, 22 Mar 2023 19:04:27 -0400 |
This is an automated email from the git hooks/post-receive script.
logari81 pushed a commit to branch master
in repository getfem.
The following commit(s) were added to refs/heads/master by this push:
new b0e8b299 Fix regression in the directional differentiation operator
b0e8b299 is described below
commit b0e8b2992641f91306e8e470ff5b3337815c01a4
Author: Konstantinos Poulios <logari81@gmail.com>
AuthorDate: Thu Mar 23 00:04:10 2023 +0100
Fix regression in the directional differentiation operator
---
interface/tests/python/check_asm.py | 9 +++++++--
src/getfem_generic_assembly_semantic.cc | 35 +++++++++++++--------------------
2 files changed, 21 insertions(+), 23 deletions(-)
diff --git a/interface/tests/python/check_asm.py
b/interface/tests/python/check_asm.py
index fdd05c63..ccec3b15 100644
--- a/interface/tests/python/check_asm.py
+++ b/interface/tests/python/check_asm.py
@@ -244,6 +244,11 @@ if (res != "(Hess_u)"):
print("Should be Hess_u"); exit(1)
str = "Diff(u*Div(w),w,3*w)"; print('\nAssembly string "%s" gives:' % str)
-res = gf.asm_expression_analysis(str, mim, md)
-if (res != "(u*((3*Grad_w):[[1,0],[0,1]]))"):
+res = gf.asm_expression_analysis(str, mim, 0, md)
+if (res != "(u*(Trace((3*Grad_w))))"):
+ print("Wrong Diff result"); exit(1)
+
+str = "Diff((Grad_w+Grad_w'-Id(2)*u):Grad(w),u,Norm(v))"; print('\nAssembly
string "%s" gives:' % str)
+res = gf.asm_expression_analysis(str, mim, 0, md)
+if (res != "((-([[1,0],[0,1]]*Norm(v))):Grad_w)"):
print("Wrong Diff result"); exit(1)
diff --git a/src/getfem_generic_assembly_semantic.cc
b/src/getfem_generic_assembly_semantic.cc
index 3106703e..a770b139 100644
--- a/src/getfem_generic_assembly_semantic.cc
+++ b/src/getfem_generic_assembly_semantic.cc
@@ -233,31 +233,24 @@ namespace getfem {
}
switch(pnode->node_type) {
case GA_NODE_VAL_TEST:
- delete pnode; pnode = nullptr;
- tree.copy_node(pexpr, parent, pnode);
- break;
case GA_NODE_GRAD_TEST:
- delete pnode; pnode = nullptr;
- tree.copy_node(grad_expr.root, parent, pnode);
- break;
case GA_NODE_HESS_TEST:
- delete pnode; pnode = nullptr;
- tree.copy_node(hess_expr.root, parent, pnode);
- break;
case GA_NODE_DIVERG_TEST:
{
- delete pnode; pnode = nullptr;
- tree.copy_node(grad_expr.root, parent, pnode);
- tree.insert_node(pnode, GA_NODE_OP);
- pnode->parent->op_type = GA_COLON;
- tree.add_child(pnode->parent, GA_NODE_PARAMS);
- pga_tree_node pid = pnode->parent->children[1];
- tree.add_child(pid);
- tree.add_child(pid);
- pid->children[0]->node_type = GA_NODE_NAME;
- pid->children[0]->name = "Id";
- pid->children[1]->node_type = GA_NODE_CONSTANT;
- pid->children[1]->init_scalar_tensor(me.dim());
+ pga_tree_node pnode_new = nullptr;
+ if (pnode->node_type == GA_NODE_VAL_TEST)
+ tree.copy_node(pexpr, parent, pnode_new); // allocates
new
+ else if (pnode->node_type == GA_NODE_GRAD_TEST ||
+ pnode->node_type == GA_NODE_DIVERG_TEST)
+ tree.copy_node(grad_expr.root, parent, pnode_new); // allocates
new
+ else if (pnode->node_type == GA_NODE_HESS_TEST)
+ tree.copy_node(hess_expr.root, parent, pnode_new); // allocates
new
+ parent->replace_child(pnode, pnode_new);
+ if (pnode->node_type == GA_NODE_DIVERG_TEST) {
+ tree.insert_node(pnode_new, GA_NODE_OP);
+ pnode_new->parent->op_type = GA_TRACE;
+ }
+ delete pnode; pnode = nullptr; // deallocates
old
}
break;
case GA_NODE_INTERPOLATE_VAL_TEST: case GA_NODE_INTERPOLATE_GRAD_TEST:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Getfem-commits] [getfem-commits] branch master updated: Fix regression in the directional differentiation operator,
Konstantinos Poulios <=