diff inst/private/generate_lhs.m @ 263:a61fc34334ca

Use meshfunction to mark subdomains
author Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
date Thu, 07 Aug 2014 19:21:36 +0200
parents 5e9b5bbdc56b
children 61830a4f9ab9
line wrap: on
line diff
--- a/inst/private/generate_lhs.m	Thu Aug 07 14:56:35 2014 +0200
+++ b/inst/private/generate_lhs.m	Thu Aug 07 19:21:36 2014 +0200
@@ -25,6 +25,7 @@
 #include <fem-fenics/coefficient.h>\n\
 #include <fem-fenics/function.h>\n\
 #include <fem-fenics/functionspace.h>\n\
+#include <fem-fenics/meshfunction.h>\n\
 #include <fem-fenics/dolfin_compat.h>\n\
 \n\
 DEFUN_DLD (@@UFL_NAME@@_LinearForm, args, , "" b = fem_lhs_@@UFL_NAME@@ (FUNCTIONAL SPACE, COEFF)"")\n\
@@ -75,6 +76,13 @@
                   mlock ();\n\
                 }\n\
 \n\
+              if (! meshfunction_type_loaded)\n\
+                {\n\
+                  meshfunction::register_type ();\n\
+                  meshfunction_type_loaded = true;\n\
+                  mlock ();\n\
+                }\n\
+\n\
               for (std::size_t i = 1; i < nargin; ++i)\n\
                 {\n\
                   if (args(i).type_id () == coefficient::static_type_id ())\n\
@@ -98,6 +106,22 @@
                       L.set_coefficient (n, pfun);\n\
                       ++nc;\n\
                     }\n\
+\n\
+                  if (args(i).type_id () == meshfunction::static_type_id ())\n\
+                    {\n\
+                      meshfunction const & mf_arg\n\
+                        = static_cast <meshfunction const &> (args(i).get_rep ());\n\
+\n\
+                      std::string type = mf_arg.get_str ();\n\
+                      dolfin::MeshFunction <std::size_t> const &\n\
+                        mf = mf_arg.get_mf ();\n\
+                      if (type == ""dx"")\n\
+                        L.dx = mf;\n\
+                      else if (type == ""ds"")\n\
+                        L.ds = mf;\n\
+                      else if (type == ""dS"")\n\
+                        L.dS = mf;\n\
+                    }\n\
                  }\n\
 \n\
               if (nc != ncoef)\n\