DOLFIN

committed ac3378c

Add new class CCFEMFunction for storing CCFEM function with parts
on different meshes

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

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

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

` // along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.`
` //`
` // First added:  2013-06-26`
`-// Last changed: 2013-09-24`
`+// Last changed: 2013-09-25`
` //`
` // This demo program solves Poisson's equation using a Cut and`
` // Composite Finite Element Method (CCFEM) on a domain defined by`
`   assembler.assemble(A, a);`
`   assembler.assemble(b, L);`
` `
`-  //info(A, true);`
`-  //info(b, true);`
`+  // Compute solution`
`+  CCFEMFunction u(V);`
`+  solve(A, *u.vector(), b);`
`+`
`+  cout << "A = " << endl; info(A, true);`
`+  cout << "b = " << endl; info(b, true);`
`+  cout << "x = " << endl; info(*u.vector(), true);`
` `
`   return 0;`
` }`

dolfin/fem/CCFEMAssembler.cpp

` // along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.`
` //`
` // First added:  2013-09-12`
`-// Last changed: 2013-09-24`
`+// Last changed: 2013-09-25`
` `
` #include <dolfin/log/log.h>`
` #include <dolfin/la/GenericTensor.h>`
`   {`
`     GenericSparsityPattern& pattern = *tensor_layout->sparsity_pattern();`
`     SparsityPatternBuilder::build_ccfem(pattern, a);`
`-`
`-    // FIXME: debugging`
`-    cout << tensor_layout->str() << endl;`
`   }`
` `
`   // Initialize tensor`

dolfin/function/CCFEMFunction.cpp

`+// Copyright (C) 2013 Anders Logg`
`+//`
`+// This file is part of DOLFIN.`
`+//`
`+// DOLFIN 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.`
`+//`
`+// DOLFIN 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 for more details.`
`+//`
`+// You should have received a copy of the GNU Lesser General Public License`
`+// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.`
`+//`
`+// First added:  2013-09-25`
`+// Last changed: 2013-09-25`
`+`
`+#include <dolfin/common/NoDeleter.h>`
`+#include <dolfin/la/GenericVector.h>`
`+#include <dolfin/la/DefaultFactory.h>`
`+#include <dolfin/fem/CCFEMDofMap.h>`
`+#include "CCFEMFunctionSpace.h"`
`+#include "CCFEMFunction.h"`
`+`
`+using namespace dolfin;`
`+`
`+//-----------------------------------------------------------------------------`
`+CCFEMFunction::CCFEMFunction(const CCFEMFunctionSpace& V)`
`+  : _function_space(reference_to_no_delete_pointer(V))`
`+{`
`+  // Initialize vector`
`+  init_vector();`
`+}`
`+//-----------------------------------------------------------------------------`
`+CCFEMFunction::CCFEMFunction(boost::shared_ptr<const CCFEMFunctionSpace> V)`
`+  : _function_space(V)`
`+{`
`+  // Initialize vector`
`+  init_vector();`
`+}`
`+//-----------------------------------------------------------------------------`
`+CCFEMFunction::~CCFEMFunction()`
`+{`
`+  // Do nothing`
`+}`
`+//-----------------------------------------------------------------------------`
`+boost::shared_ptr<GenericVector> CCFEMFunction::vector()`
`+{`
`+  dolfin_assert(_vector);`
`+  return _vector;`
`+}`
`+//-----------------------------------------------------------------------------`
`+boost::shared_ptr<const GenericVector> CCFEMFunction::vector() const`
`+{`
`+  dolfin_assert(_vector);`
`+  return _vector;`
`+}`
`+//-----------------------------------------------------------------------------`
`+void CCFEMFunction::init_vector()`
`+{`
`+  // Get global size`
`+  //const std::size_t N = _function_space->dofmap()->global_dimension();`
`+`
`+  // Get local range`
`+  const std::pair<std::size_t, std::size_t> range`
`+    = _function_space->dofmap()->ownership_range();`
`+  //const std::size_t local_size = range.second - range.first;`
`+`
`+  // Determine ghost vertices if dof map is distributed`
`+  std::vector<la_index> ghost_indices;`
`+  // FIXME: Does not work in parallel`
`+  //if (N > local_size)`
`+  //  compute_ghost_indices(range, ghost_indices);`
`+`
`+  // Create vector of dofs`
`+  if (!_vector)`
`+  {`
`+    DefaultFactory factory;`
`+    _vector = factory.create_vector();`
`+  }`
`+  dolfin_assert(_vector);`
`+`
`+  // Initialize vector of dofs`
`+  _vector->resize(range, ghost_indices);`
`+  _vector->zero();`
`+}`
`+//-----------------------------------------------------------------------------`

dolfin/function/CCFEMFunction.h

`+// Copyright (C) 2013 Anders Logg`
`+//`
`+// This file is part of DOLFIN.`
`+//`
`+// DOLFIN 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.`
`+//`
`+// DOLFIN 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 for more details.`
`+//`
`+// You should have received a copy of the GNU Lesser General Public License`
`+// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.`
`+//`
`+// First added:  2013-09-25`
`+// Last changed: 2013-09-25`
`+`
`+#ifndef __CCFEM_FUNCTION_H`
`+#define __CCFEM_FUNCTION_H`
`+`
`+#include <boost/shared_ptr.hpp>`
`+`
`+namespace dolfin`
`+{`
`+`
`+  // Forward declacations`
`+  class CCFEMFunctionSpace;`
`+  class GenericVector;`
`+`
`+  /// This class represents a function on a cut and composite finite`
`+  /// element function space (CCFEM) defined on one or more possibly`
`+  /// intersecting meshes.`
`+`
`+  class CCFEMFunction`
`+  {`
`+  public:`
`+`
`+    /// Create CCFEM function on given CCFEM function space`
`+    ///`
`+    /// *Arguments*`
`+    ///     V (_CCFEMFunctionSpace_)`
`+    ///         The CCFEM function space.`
`+    ///`
`+    /// *Example*`
`+    ///     .. code-block:: c++`
`+    ///`
`+    ///         CCFEMFunction u(V);`
`+    ///`
`+    explicit CCFEMFunction(const CCFEMFunctionSpace& V);`
`+`
`+    /// Create CCFEM function on given CCFEM function space (shared`
`+    /// pointer version)`
`+    ///`
`+    /// *Arguments*`
`+    ///     V (_CCFEMFunctionSpace_)`
`+    ///         The CCFEM function space.`
`+    explicit CCFEMFunction(boost::shared_ptr<const CCFEMFunctionSpace> V);`
`+`
`+    /// Destructor`
`+    virtual ~CCFEMFunction();`
`+`
`+    /// Return vector of expansion coefficients (non-const version)`
`+    ///`
`+    /// *Returns*`
`+    ///     _GenericVector_`
`+    ///         The vector of expansion coefficients.`
`+    boost::shared_ptr<GenericVector> vector();`
`+`
`+    /// Return vector of expansion coefficients (const version)`
`+    ///`
`+    /// *Returns*`
`+    ///     _GenericVector_`
`+    ///         The vector of expansion coefficients (const).`
`+    boost::shared_ptr<const GenericVector> vector() const;`
`+`
`+  private:`
`+`
`+    // Initialize vector`
`+    void init_vector();`
`+`
`+    // The function space`
`+    boost::shared_ptr<const CCFEMFunctionSpace> _function_space;`
`+`
`+    // The vector of expansion coefficients (local)`
`+    boost::shared_ptr<GenericVector> _vector;`
`+`
`+  };`
`+`
`+}`
`+`
`+#endif`

dolfin/function/CCFEMFunctionSpace.h

` // along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.`
` //`
` // First added:  2013-08-05`
`-// Last changed: 2013-09-19`
`+// Last changed: 2013-09-25`
` `
` #ifndef __CCFEM_FUNCTION_SPACE_H`
` #define __CCFEM_FUNCTION_SPACE_H`

dolfin/function/Function.cpp

` // Modified by Andre Massing 2009`
` //`
` // First added:  2003-11-28`
`-// Last changed: 2013-09-02`
`+// Last changed: 2013-09-25`
` `
` #include <algorithm>`
` #include <map>`

dolfin/function/Function.h

` // Modified by Andre Massing, 2009.`
` //`
` // First added:  2003-11-28`
`-// Last changed: 2013-06-21`
`+// Last changed: 2013-09-25`
` `
` #ifndef __FUNCTION_H`
` #define __FUNCTION_H`

dolfin/function/dolfin_function.h

` #include <dolfin/function/SpecialFunctions.h>`
` #include <dolfin/function/SpecialFacetFunction.h>`
` #include <dolfin/function/CCFEMFunctionSpace.h>`
`+#include <dolfin/function/CCFEMFunction.h>`
` `
` #endif`
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.