Commits

Anders Logg committed 6220153

Some work on vector assembly

Comments (0)

Files changed (3)

demo/undocumented/ccfem-poisson/cpp/Poisson.ufl

 # along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
 #
 # First added:  2005
-# Last changed: 2011-03-08
+# Last changed: 2013-09-24
 #
 # The bilinear form a(u, v) and linear form L(v) for
 # Poisson's equation.
 u = TrialFunction(element)
 v = TestFunction(element)
 f = Coefficient(element)
-g = Coefficient(element)
 
 a = inner(grad(u), grad(v))*dx
-L = f*v*dx + g*v*ds
+L = f*v*dx

demo/undocumented/ccfem-poisson/cpp/main.cpp

   Poisson::FunctionSpace V1(circle_1);
   Poisson::FunctionSpace V2(circle_2);
 
+  // Some of this stuff may be wrapped or automated later to avoid
+  // needing to explicitly call add() and build()
+
   // Create forms
   Poisson::BilinearForm a0(V0, V0);
   Poisson::BilinearForm a1(V1, V1);
   Poisson::BilinearForm a2(V2, V2);
+  Poisson::LinearForm L0(V0);
+  Poisson::LinearForm L1(V1);
+  Poisson::LinearForm L2(V2);
+
+  // Set coefficients
+  Source f;
+  L0.f = f;
+  L1.f = f;
+  L2.f = f;
 
   // Build CCFEM function space
   CCFEMFunctionSpace V;
   V.add(V2);
   V.build();
 
-  // Build CCFEM form
+  // Build CCFEM forms
   CCFEMForm a(V, V);
   a.add(a0);
   a.add(a1);
   a.add(a2);
   a.build();
+  CCFEMForm L(V);
+  L.add(L0);
+  L.add(L1);
+  L.add(L2);
+  L.build();
 
   // Assemble linear system
   Matrix A;
+  Vector b;
   CCFEMAssembler assembler;
   assembler.assemble(A, a);
+  assembler.assemble(b, L);
 
-  info(A, true);
+  //info(A, true);
+  //info(b, true);
 
   return 0;
 }

dolfin/fem/UFC.cpp

 // Modified by Garth N. Wells, 2010
 //
 // First added:  2007-01-17
-// Last changed: 2011-02-21
+// Last changed: 2013-09-24
 
 #include <dolfin/common/types.h>
 #include <dolfin/function/FunctionSpace.h>
 
   // Restrict coefficients to cell
   for (std::size_t i = 0; i < coefficients.size(); ++i)
+  {
+    dolfin_assert(coefficients[i]);
     coefficients[i]->restrict(&_w[i][0], coefficient_elements[i], c, cell);
+  }
 }
 //-----------------------------------------------------------------------------
 void UFC::update(const Cell& c, std::size_t local_facet)
 
   // Restrict coefficients to facet
   for (std::size_t i = 0; i < coefficients.size(); ++i)
+  {
+    dolfin_assert(coefficients[i]);
     coefficients[i]->restrict(&_w[i][0], coefficient_elements[i], c, cell);
+  }
 }
 //-----------------------------------------------------------------------------
 void UFC::update(const Cell& c0, std::size_t local_facet0,
   // Restrict coefficients to facet
   for (std::size_t i = 0; i < coefficients.size(); ++i)
   {
+    dolfin_assert(coefficients[i]);
     const std::size_t offset = coefficient_elements[i].space_dimension();
     coefficients[i]->restrict(&_macro_w[i][0], coefficient_elements[i],
                               c0, cell0);