[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Getfem-commits] (no subject)
From: |
Yves Renard |
Subject: |
[Getfem-commits] (no subject) |
Date: |
Fri, 22 Sep 2017 03:40:31 -0400 (EDT) |
branch: devel-yves-fix-matlab-pb
commit 203a16fc1519afa9d4f7691c24679c9b1274f1f3
Author: Yves Renard <address@hidden>
Date: Fri Sep 22 09:30:53 2017 +0200
fix copy_node problem
---
configure.ac | 4 +++-
src/getfem_generic_assembly.cc | 46 ++++++++++++++++++++----------------------
2 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/configure.ac b/configure.ac
index 55a704a..ac0014d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -872,7 +872,9 @@ if test "$usematlab" != NO; then
fi;
AC_CHECK_PROGS(MEXEXT, mexext)
# MATLAB_ROOT=`$MEX -v 2>&1 | grep "MATLAB " | awk '{print $4}'|sed -e
'2,$d'`
- MATLAB_ROOT=`which $MEX | sed -e 's/bin.*$//'`
+ MEX_EXE=`which $MEX`
+ MEX_EXE=`readlink -e $MEX_EXE`
+ MATLAB_ROOT=`echo $MEX_EXE | sed -e 's/bin.*$//'`
Matlab_INC_DIR=$MATLAB_ROOT/extern/include
echo "checking for matlab path... " $MATLAB_ROOT
MATLAB_COM_EXT=.`$MEXEXT`
diff --git a/src/getfem_generic_assembly.cc b/src/getfem_generic_assembly.cc
index cec2231..7ed1767 100644
--- a/src/getfem_generic_assembly.cc
+++ b/src/getfem_generic_assembly.cc
@@ -28,6 +28,9 @@
#include "getfem/bgeot_rtree.h"
#include "getfem/bgeot_geotrans_inv.h"
#include "getfem/getfem_copyable_ptr.h"
+extern "C"{
+#include <unistd.h>
+}
/**
Providing for special Math functions unavailable on Intel or MSVS C++
@@ -1128,6 +1131,7 @@ namespace getfem {
static void ga_print_node(const pga_tree_node pnode,
std::ostream &str) {
+ if (!pnode) return;
long prec = str.precision(16);
bool is_interpolate(false), is_elementary(false);
@@ -9952,7 +9956,6 @@ namespace getfem {
//=========================================================================
static void ga_extract_factor(ga_tree &result_tree, pga_tree_node pnode,
pga_tree_node &new_pnode) {
-
result_tree.clear();
result_tree.copy_node(pnode, 0, result_tree.root);
new_pnode = result_tree.root;
@@ -9968,10 +9971,8 @@ namespace getfem {
pga_tree_node child0 = (nbch > 0) ? pnode->children[0] : 0;
pga_tree_node child1 = (nbch > 1) ? pnode->children[1] : 0;
-
switch (pnode->node_type) {
-
case GA_NODE_OP:
switch(pnode->op_type) {
case GA_PLUS:
@@ -9995,11 +9996,12 @@ namespace getfem {
result_tree.root->op_type = pnode->op_type;
result_tree.root->pos = pnode->pos;
result_tree.root->children.resize(2, nullptr);
- if (child0 == pnode_child) {
- result_tree.copy_node(child1, result_tree.root,
+ if (child0 == pnode_child) {
+ result_tree.copy_node(child1, result_tree.root,
result_tree.root->children[1]);
} else if (child1 == pnode_child) {
- result_tree.root->children[1] = result_tree.root->children[0];
+ std::swap(result_tree.root->children[1],
+ result_tree.root->children[0]);
result_tree.copy_node(child0, result_tree.root,
result_tree.root->children[0]);
} else GMM_ASSERT1(false, "Corrupted tree");
@@ -10018,7 +10020,7 @@ namespace getfem {
result_tree.insert_node(result_tree.root, pnode->node_type);
result_tree.root->pos = pnode->pos;
result_tree.root->children.resize(pnode->children.size(), nullptr);
- result_tree.root->children[1] = result_tree.root->children[0];
+ std::swap(result_tree.root->children[1], result_tree.root->children[0]);
for (size_type i = 0; i < pnode->children.size(); ++i)
if (i != 1)
result_tree.copy_node(pnode->children[i], result_tree.root,
@@ -10272,13 +10274,12 @@ namespace getfem {
static std::string ga_extract_one_Neumann_term
(const std::string &varname,
ga_workspace &workspace, pga_tree_node pnode) {
-
size_type N = workspace.qdim(varname);
const mesh_fem *mf = workspace.associated_mf(varname);
GMM_ASSERT1(mf, "Works only with fem variables.");
size_type meshdim = mf->linked_mesh().dim();
ga_tree factor;
- pga_tree_node new_pnode;
+ pga_tree_node new_pnode = nullptr;
ga_extract_factor(factor, pnode, new_pnode);
std::string result;
pga_tree_node nnew_pnode = new_pnode;
@@ -10427,6 +10428,7 @@ namespace getfem {
ga_extract_Neumann_term_rec(tree, varname, workspace,
pnode->children[i], result);
+
switch (pnode->node_type) {
case GA_NODE_DIVERG_TEST: case GA_NODE_GRAD_TEST:
case GA_NODE_ELEMENTARY_GRAD_TEST: case GA_NODE_ELEMENTARY_DIVERG_TEST:
@@ -13252,17 +13254,17 @@ namespace getfem {
const ga_instruction_list &gilb = instr.second.begin_instructions;
const ga_instruction_list &gile = instr.second.elt_instructions;
const ga_instruction_list &gil = instr.second.instructions;
-#if 0
- if (gilb.size()) cout << "Begin instructions\n";
- for (size_type j = 0; j < gilb.size(); ++j)
- cout << typeid(*(gilb[j])).name() << endl;
- if (gile.size()) cout << "\nElement instructions\n";
- for (size_type j = 0; j < gile.size(); ++j)
- cout << typeid(*(gile[j])).name() << endl;
- cout << "\nGauss pt instructions\n";
- for (size_type j = 0; j < gil.size(); ++j)
- cout << typeid(*(gil[j])).name() << endl;
-#endif
+
+ // if (gilb.size()) cout << "Begin instructions\n";
+ // for (size_type j = 0; j < gilb.size(); ++j)
+ // cout << typeid(*(gilb[j])).name() << endl;
+ // if (gile.size()) cout << "\nElement instructions\n";
+ // for (size_type j = 0; j < gile.size(); ++j)
+ // cout << typeid(*(gile[j])).name() << endl;
+ // cout << "\nGauss pt instructions\n";
+ // for (size_type j = 0; j < gil.size(); ++j)
+ // cout << typeid(*(gil[j])).name() << endl;
+
const mesh_region ®ion = *(instr.first.region());
// iteration on elements (or faces of elements)
@@ -13860,11 +13862,7 @@ namespace getfem {
loc_M.base_resize(nd, nd); gmm::resize(loc_U, nd);
gmm::sub_index J(mf.ind_basic_dof_of_element(v.cv()));
gmm::copy(gmm::sub_matrix(M, J, J), loc_M);
- cout << "will loch lu_solve" << endl;
- cout << "loc_M = " << loc_M << endl;
- cout << "sub_F = " << gmm::sub_vector(F, J) << endl;
gmm::lu_solve(loc_M, loc_U, gmm::sub_vector(F, J));
- cout << "result : " << vref(loc_U) << endl;
gmm::copy(loc_U, gmm::sub_vector(result, J));
}
}