Loading...
Searching...
No Matches
MultiMeshDirichletBC.h
// Copyright (C) 2014-2016 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 4 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: 2014-05-12
// Last changed: 2016-03-02
#ifndef __MULTI_MESH_DIRICHLET_BC_H
#define __MULTI_MESH_DIRICHLET_BC_H
#include <vector>
#include <memory>
#include <dolfin/mesh/SubDomain.h>
namespace dolfin
{
// Forward declarations
class MultiMeshFunctionSpace;
class GenericFunction;
class SubDomain;
class GenericMatrix;
class GenericVector;
class DirichletBC;
class MultiMeshDirichletBC
{
public:
MultiMeshDirichletBC(std::shared_ptr<const MultiMeshFunctionSpace> V,
std::shared_ptr<const GenericFunction> g,
std::shared_ptr<const SubDomain> sub_domain,
std::string method="topological",
bool check_midpoint=true,
bool exclude_overlapped_boundaries=true);
MultiMeshDirichletBC(std::shared_ptr<const MultiMeshFunctionSpace> V,
std::shared_ptr<const GenericFunction> g,
std::shared_ptr<const SubDomain> sub_domain,
std::size_t part,
std::string method="topological",
bool check_midpoint=true,
bool exclude_overlapped_boundaries=true);
MultiMeshDirichletBC(std::shared_ptr<const MultiMeshFunctionSpace> V,
std::shared_ptr<const GenericFunction> g,
std::shared_ptr<const MeshFunction<std::size_t>> sub_domains,
std::size_t sub_domain,
std::size_t part,
std::string method="topological");
MultiMeshDirichletBC(const MultiMeshDirichletBC& bc);
~MultiMeshDirichletBC();
std::shared_ptr<const MultiMeshFunctionSpace> function_space() const
{ return _function_space; }
std::shared_ptr<DirichletBC> view(std::size_t part) const
{
return _bcs.at(part);
}
void apply(GenericMatrix& A) const;
void apply(GenericVector& b) const;
void apply(GenericMatrix& A,
GenericVector& b) const;
void apply(GenericVector& b,
const GenericVector& x) const;
void apply(GenericMatrix& A,
GenericVector& b,
const GenericVector& x) const;
void zero(GenericMatrix& A) const;
void homogenize();
private:
// Subclass of SubDomain wrapping user-defined subdomain
class MultiMeshSubDomain : public SubDomain
{
public:
// Constructor
MultiMeshSubDomain(std::shared_ptr<const SubDomain> sub_domain,
std::shared_ptr<const MultiMesh> multimesh,
bool exclude_overlapped_boundaries);
// Destructor
~MultiMeshSubDomain();
// Callback for checking whether point is in domain
bool inside(const Array<double>& x, bool on_boundary) const;
// Set current part
void set_current_part(std::size_t current_part);
private:
// User-defined subdomain
std::shared_ptr<const SubDomain> _user_sub_domain;
// Multimesh
std::shared_ptr<const MultiMesh> _multimesh;
// Current part
std::size_t _current_part;
// Check whether to exclude boundaries overlapped by other meshes
bool _exclude_overlapped_boundaries;
};
// Multimesh function space
std::shared_ptr<const MultiMeshFunctionSpace> _function_space;
// Map from parts to boundary conditions
std::map<std::size_t, std::shared_ptr<DirichletBC>> _bcs;
// Wrapper of user-defined subdomain
mutable std::shared_ptr<MultiMeshSubDomain> _sub_domain;
// Check whether to exclude boundaries overlapped by other meshes
bool _exclude_overlapped_boundaries;
};
}
#endif
dolfin::Array
Definition Array.h:42
dolfin::DirichletBC
Interface for setting (strong) Dirichlet boundary conditions.
Definition DirichletBC.h:125
dolfin::GenericFunction
Definition GenericFunction.h:54
dolfin::GenericMatrix
This class defines a common interface for matrices.
Definition GenericMatrix.h:47
dolfin::GenericVector
This class defines a common interface for vectors.
Definition GenericVector.h:48
dolfin::MeshFunction
Definition MeshFunction.h:58
dolfin::MultiMeshDirichletBC::MultiMeshDirichletBC
MultiMeshDirichletBC(std::shared_ptr< const MultiMeshFunctionSpace > V, std::shared_ptr< const GenericFunction > g, std::shared_ptr< const SubDomain > sub_domain, std::string method="topological", bool check_midpoint=true, bool exclude_overlapped_boundaries=true)
Definition MultiMeshDirichletBC.cpp:35
dolfin::MultiMeshDirichletBC::function_space
std::shared_ptr< const MultiMeshFunctionSpace > function_space() const
Definition MultiMeshDirichletBC.h:133
dolfin::MultiMeshDirichletBC::apply
void apply(GenericMatrix &A) const
Definition MultiMeshDirichletBC.cpp:164
dolfin::MultiMeshDirichletBC::view
std::shared_ptr< DirichletBC > view(std::size_t part) const
Definition MultiMeshDirichletBC.h:140
dolfin::MultiMeshDirichletBC::homogenize
void homogenize()
Set value to 0.0.
Definition MultiMeshDirichletBC.cpp:252
dolfin::MultiMeshDirichletBC::~MultiMeshDirichletBC
~MultiMeshDirichletBC()
Destructor.
Definition MultiMeshDirichletBC.cpp:159
dolfin::MultiMeshDirichletBC::zero
void zero(GenericMatrix &A) const
Definition MultiMeshDirichletBC.cpp:238
dolfin::MultiMeshFunctionSpace
Definition MultiMeshFunctionSpace.h:48
dolfin::SubDomain
Definition SubDomain.h:43
dolfin
Definition adapt.h:30