mesh.init() computes all connectivity and should almost never be
called, at least not from inside DOLFIN.
Instead, the proper init function for the connectivity that is
actually used should be called, like mesh.init(1, 2) or similar.
Note that calling init functions is not needed when using iterators
since the connectivity is then automatically initialized.
The mesh that comes out of refine() is a clean mesh that only has
cell-vertex connectivity so it's not strange that one needs to call
some init function.
--
Anders
--- Begin Message ---
------------------------------------------------------------
revno: 5663
committer: Marie E. Rognes <m...@simula.no>
branch nick: dolfin-main
timestamp: Sun 2011-02-13 21:50:39 +0100
message:
Add init to child after mesh refinement (why is this needed?!) and
allow more general DirichletBCs in refinement.
modified:
dolfin/adaptivity/AdaptiveVariationalSolver.cpp
dolfin/adaptivity/refine.cpp
--
lp:~dolfin-core/dolfin/rognes
https://code.launchpad.net/~dolfin-core/dolfin/rognes
Your team DOLFIN Core Team is subscribed to branch
lp:~dolfin-core/dolfin/rognes.
To unsubscribe from this branch go to
https://code.launchpad.net/~dolfin-core/dolfin/rognes/+edit-subscription
=== modified file 'dolfin/adaptivity/AdaptiveVariationalSolver.cpp'
--- dolfin/adaptivity/AdaptiveVariationalSolver.cpp 2011-02-09 19:37:05 +0000
+++ dolfin/adaptivity/AdaptiveVariationalSolver.cpp 2011-02-13 20:50:39 +0000
@@ -4,7 +4,7 @@
// Modified by Anders Logg, 2010-2011.
//
// First added: 2010-08-19
-// Last changed: 2011-02-09
+// Last changed: 2011-02-13
#include <dolfin/common/utils.h>
#include <dolfin/common/Variable.h>
@@ -75,10 +75,6 @@
// Extract function space and mesh
const FunctionSpace& V(u.function_space());
const Mesh& mesh(V.mesh());
-
- // FIXME: Init mesh (should only initialize required stuff.)
- // FIXME: Remove this, should not be needed!
- mesh.init();
end();
//--- Stage 1: Estimate error ---
@@ -125,6 +121,7 @@
//--- Stage 4: Refine mesh ---
begin("Stage %d.4: Refining mesh...", i);
refine(mesh, markers);
+ mesh.child().init();
if (parameters["plot_mesh"])
plot(mesh.child(), "Refined mesh");
end();
=== modified file 'dolfin/adaptivity/refine.cpp'
--- dolfin/adaptivity/refine.cpp 2011-02-13 18:51:20 +0000
+++ dolfin/adaptivity/refine.cpp 2011-02-13 20:50:39 +0000
@@ -301,18 +301,28 @@
boost::shared_ptr<const FunctionSpace> V = bc.function_space_ptr();
refine(*V, refined_mesh);
- // Refine value
- const Function& g(dynamic_cast<const Function&>(bc.value()));
- refine(g, refined_mesh);
-
// Extract but keep sub-domain
boost::shared_ptr<const SubDomain> domain = bc.user_sub_domain_ptr();
+
+ // Refine value
+ const Function* g = dynamic_cast<const Function*>(bc.value_ptr().get());
+
+ boost::shared_ptr<DirichletBC> refined_bc;
+
// Create refined boundary condition
- boost::shared_ptr<DirichletBC>
- refined_bc(new DirichletBC(V->child_shared_ptr(), g.child_shared_ptr(),
- domain));
-
+ if (g != 0)
+ {
+ refine(*g, refined_mesh);
+ refined_bc.reset(new DirichletBC(V->child_shared_ptr(),
+ g->child_shared_ptr(),
+ domain));
+ } else
+ {
+ refined_bc.reset(new DirichletBC(V->child_shared_ptr(),
+ bc.value_ptr(),
+ domain));
+ }
// Set parent / child
set_parent_child(bc, refined_bc);
--- End Message ---
_______________________________________________
Mailing list: https://launchpad.net/~dolfin
Post to : dolfin@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dolfin
More help : https://help.launchpad.net/ListHelp