[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Getfem-commits] r5186 - in /trunk/getfem: interface/tests/python/tutori
From: |
Yves . Renard |
Subject: |
[Getfem-commits] r5186 - in /trunk/getfem: interface/tests/python/tutorial1.py src/getfem/getfem_omp.h src/getfem_models.cc src/getfem_omp.cc |
Date: |
Mon, 14 Dec 2015 20:02:18 -0000 |
Author: renard
Date: Mon Dec 14 21:02:17 2015
New Revision: 5186
URL: http://svn.gna.org/viewcvs/getfem?rev=5186&view=rev
Log:
minor changes
Added:
trunk/getfem/interface/tests/python/tutorial1.py
Modified:
trunk/getfem/src/getfem/getfem_omp.h
trunk/getfem/src/getfem_models.cc
trunk/getfem/src/getfem_omp.cc
Added: trunk/getfem/interface/tests/python/tutorial1.py
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/interface/tests/python/tutorial1.py?rev=5186&view=auto
==============================================================================
--- trunk/getfem/interface/tests/python/tutorial1.py (added)
+++ trunk/getfem/interface/tests/python/tutorial1.py Mon Dec 14 21:02:17 2015
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+# Python GetFEM++ interface
+#
+# Copyright (C) 2015-2015 Julien Pommier.
+#
+# 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.
+#
+############################################################################
+
+import getfem as gf
+import numpy as np
+
+NX = 10
+m = gf.Mesh('cartesian', np.arange(0,1+1./NX,1./NX),
np.arange(0,1+1./NX,1./NX))
+mf = gf.MeshFem(m,1) # create a meshfem of for a field of dimension 1
+mf.set('fem',gf.Fem('FEM_QK(2,2)'))
+
+print (gf.Fem('FEM_QK(2,2)').poly_str())
+
+mim=gf.MeshIm(m, gf.Integ('IM_EXACT_PARALLELEPIPED(2)'));
+# mim=gf.MeshIm(m, gf.Integ('IM_GAUSS_PARALLELEPIPED(2, 4)'));
+
+
+border = m.outer_faces()
+m.set_region(42, border) # create the region B42 (:-
+
+
+md=gf.Model('real')
+md.add_fem_variable('u', mf)
+md.add_Laplacian_brick(mim, 'u')
+R = mf.eval('(x-.5)*(x-.5) + (y-.5)*(y-.5) + x/5 - y/3')
+md.add_initialized_fem_data('DirichletData', mf, R)
+md.add_Dirichlet_condition_with_multipliers(mim, 'u', mf, 42, 'DirichletData')
+
+md.variable_list()
+
+md.solve()
+U = md.variable('u')
Modified: trunk/getfem/src/getfem/getfem_omp.h
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem/getfem_omp.h?rev=5186&r1=5185&r2=5186&view=diff
==============================================================================
--- trunk/getfem/src/getfem/getfem_omp.h (original)
+++ trunk/getfem/src/getfem/getfem_omp.h Mon Dec 14 21:02:17 2015
@@ -342,40 +342,42 @@
size_type thread_local_partition() const;
};
- /**Allows to re-throw exceptions, generated in OpemMP parallel section.
- Collects exceptions from all threads and on destruction re-throws the first
one, so that
- it can be again caught in the master thread*/
- class thread_exception {
- public:
- thread_exception();
-
- /**re-throws the first captured exception*/
- ~thread_exception();
-
- /**run function f in parallel part to capture it's exceptions. Possible
syntax can be:
- thread_exception exception;
- #pragma omp parallel...
- {
- exception.run([&]
- {
- your code that can throw exceptions
- });
- }*/
- template <typename Function, typename... Parameters>
- void run(Function f, Parameters... params)
- {
- try {f(params...);} catch (...){captureException();}
- }
-
- /**vector of pointers to caught exceptions*/
- std::vector<std::exception_ptr> caughtExceptions() const;
-
- private:
- void rethrow();
- void captureException();
-
- std::vector<std::exception_ptr> exceptions_;
- };
+ /** Allows to re-throw exceptions, generated in OpemMP parallel section.
+ Collects exceptions from all threads and on destruction re-throws
+ the first one, so that
+ it can be again caught in the master thread. */
+ class thread_exception {
+ public:
+ thread_exception();
+
+ /**re-throws the first captured exception*/
+ ~thread_exception();
+
+ /** Run function f in parallel part to capture it's exceptions.
+ Possible syntax can be:
+ thread_exception exception;
+ #pragma omp parallel...
+ {
+ exception.run([&]
+ {
+ your code that can throw exceptions
+ });
+ }*/
+ template <typename Function, typename... Parameters>
+ void run(Function f, Parameters... params)
+ {
+ try { f(params...); } catch (...) { captureException(); }
+ }
+
+ /**vector of pointers to caught exceptions*/
+ std::vector<std::exception_ptr> caughtExceptions() const;
+
+ private:
+ void rethrow();
+ void captureException();
+
+ std::vector<std::exception_ptr> exceptions_;
+ };
}
Modified: trunk/getfem/src/getfem_models.cc
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem_models.cc?rev=5186&r1=5185&r2=5186&view=diff
==============================================================================
--- trunk/getfem/src/getfem_models.cc (original)
+++ trunk/getfem/src/getfem_models.cc Mon Dec 14 21:02:17 2015
@@ -1776,19 +1776,19 @@
/*running the assembly in parallel*/
gmm::standard_locale locale;
open_mp_is_running_properly check;
- thread_exception exception;
+ thread_exception exception;
#pragma omp parallel default(shared)
- {
- exception.run([&]
- {
- brick.pbr->asm_real_tangent_terms(*this, ib, brick.vlist,
- brick.dlist, brick.mims,
- rmatlist,
- rveclist,
- rveclist_sym,
- brick.region,
- version);
- });
+ {
+ exception.run([&]
+ {
+ brick.pbr->asm_real_tangent_terms(*this, ib, brick.vlist,
+ brick.dlist, brick.mims,
+ rmatlist,
+ rveclist,
+ rveclist_sym,
+ brick.region,
+ version);
+ } );
}
}
brick.pbr->real_post_assembly_in_serial(*this, ib, brick.vlist,
Modified: trunk/getfem/src/getfem_omp.cc
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem_omp.cc?rev=5186&r1=5185&r2=5186&view=diff
==============================================================================
--- trunk/getfem/src/getfem_omp.cc (original)
+++ trunk/getfem/src/getfem_omp.cc Mon Dec 14 21:02:17 2015
@@ -135,9 +135,9 @@
}
thread_exception::thread_exception(): exceptions_(num_threads(), nullptr)
- {}
+ { }
- thread_exception::~thread_exception() {rethrow();}
+ thread_exception::~thread_exception() { rethrow(); }
std::vector<std::exception_ptr> thread_exception::caughtExceptions() const
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Getfem-commits] r5186 - in /trunk/getfem: interface/tests/python/tutorial1.py src/getfem/getfem_omp.h src/getfem_models.cc src/getfem_omp.cc,
Yves . Renard <=