[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Getfem-commits] (no subject)
From: |
Liang Jin Lim |
Subject: |
[Getfem-commits] (no subject) |
Date: |
Thu, 8 Jun 2017 02:08:33 -0400 (EDT) |
branch: improve_deformable_mesh
commit 54147b9ef097879fc25b2e066e4fcfd1e6a757e3
Author: lj <address@hidden>
Date: Thu Jun 8 14:08:15 2017 +0800
Improve the undeform function of mesh by restoring the mesh directly using
its original location.
---
src/getfem/getfem_deformable_mesh.h | 73 ++++++++++++++++++++-----------------
1 file changed, 40 insertions(+), 33 deletions(-)
diff --git a/src/getfem/getfem_deformable_mesh.h
b/src/getfem/getfem_deformable_mesh.h
index 6a74f90..511bdff 100644
--- a/src/getfem/getfem_deformable_mesh.h
+++ b/src/getfem/getfem_deformable_mesh.h
@@ -1,33 +1,33 @@
-/* -*- c++ -*- (enables emacs c++ mode) */
-/*===========================================================================
-
- Copyright (C) 2012-2017 Andriy Andreykiv
-
- This file is a part of GetFEM++
-
- GetFEM++ is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version along with the GCC Runtime Library
- Exception either version 3.1 or (at your option) any later version.
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- License and GCC Runtime Library Exception for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
-
- As a special exception, you may use this file as it is a part of a free
- software library without restriction. Specifically, if other files
- instantiate templates or use macros or inline functions from this file,
- or you compile this file and link it with other files to produce an
- executable, this file does not by itself cause the resulting executable
- to be covered by the GNU Lesser General Public License. This exception
- does not however invalidate any other reasons why the executable file
- might be covered by the GNU Lesser General Public License.
-
-===========================================================================*/
+/* -*- c++ -*- (enables emacs c++ mode) */
+/*===========================================================================
+
+ Copyright (C) 2012-2017 Andriy Andreykiv
+
+ This file is a part of GetFEM++
+
+ GetFEM++ is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version along with the GCC Runtime Library
+ Exception either version 3.1 or (at your option) any later version.
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License and GCC Runtime Library Exception for more details.
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, you may use this file as it is a part of a free
+ software library without restriction. Specifically, if other files
+ instantiate templates or use macros or inline functions from this file,
+ or you compile this file and link it with other files to produce an
+ executable, this file does not by itself cause the resulting executable
+ to be covered by the GNU Lesser General Public License. This exception
+ does not however invalidate any other reasons why the executable file
+ might be covered by the GNU Lesser General Public License.
+
+===========================================================================*/
/** @file getfem_deformable_mesh.h
@author "Andriy Andreykiv" <address@hidden>
@@ -71,15 +71,14 @@ namespace getfem {
void deform(){
if (is_deformed_) return;
+ initial_nodes_ = mf_.linked_mesh().points();
deforming_mesh_(dU_);
is_deformed_ = true;
}
void undeform(){
if (!is_deformed_) return;
- VECTOR dU_inverted(dU_);
- gmm::scale(dU_inverted, scalar_type(-1.0));
- deforming_mesh_(dU_inverted);
+ restore_();
is_deformed_ = false;
}
@@ -129,8 +128,16 @@ namespace getfem {
"Error, after deforming the mesh, number of nodes are
different.");
}
+ void restore_()
+ {
+ auto &pts = const_cast<getfem::mesh &>(mf_.linked_mesh()).points();
+ GMM_ASSERT1(pts.size() == initial_nodes_.size(), "Internal error,
incorrect number of points.");
+ for (size_type i = 0; i < pts.size(); ++i) gmm::copy(initial_nodes_[i],
pts[i]);
+ }
+
VECTOR dU_;
const mesh_fem &mf_;
+ getfem::mesh::PT_TAB initial_nodes_;
bool deform_on_construct_;
bool is_deformed_;
bool to_be_restored_;