22 #ifndef __LINEAR_ALGEBRA_OBJECT_H 23 #define __LINEAR_ALGEBRA_OBJECT_H 26 #include <dolfin/common/MPI.h> 27 #include <dolfin/common/Variable.h> 50 {
return std::shared_ptr<const LinearAlgebraObject>(); }
54 {
return std::shared_ptr<LinearAlgebraObject>(); }
57 virtual MPI_Comm
mpi_comm()
const = 0;
63 template<
typename Y,
typename X>
68 return dynamic_cast<Y&
>(*x.instance());
70 catch (std::exception& e)
73 "down-cast linear algebra object to requested type",
78 return dynamic_cast<Y&
>(*x.instance());
83 template<
typename Y,
typename X>
84 std::shared_ptr<Y>
as_type(std::shared_ptr<X> x)
87 std::shared_ptr<Y> y = std::dynamic_pointer_cast<Y>(x);
93 if (x->shared_instance())
94 y = std::dynamic_pointer_cast<Y>(x->shared_instance());
101 template<
typename Y,
typename X>
104 return bool(dynamic_cast<const Y*>(x.instance()));
virtual LinearAlgebraObject * instance()
Return concrete instance / unwrap (non-const version)
Definition: LinearAlgebraObject.h:45
Common base class for DOLFIN variables.
Definition: Variable.h:35
Y & as_type(X &x)
Definition: LinearAlgebraObject.h:64
virtual std::shared_ptr< LinearAlgebraObject > shared_instance()
Return concrete shared ptr instance / unwrap (non-const version)
Definition: LinearAlgebraObject.h:53
virtual const LinearAlgebraObject * instance() const
Return concrete instance / unwrap (const version)
Definition: LinearAlgebraObject.h:41
virtual MPI_Comm mpi_comm() const =0
Return MPI communicator.
Definition: LinearAlgebraObject.h:36
bool has_type(const X &x)
Check whether the object matches a specific type.
Definition: LinearAlgebraObject.h:102
void dolfin_error(std::string location, std::string task, std::string reason,...)
Definition: log.cpp:129
virtual std::shared_ptr< const LinearAlgebraObject > shared_instance() const
Return concrete shared ptr instance / unwrap (const version)
Definition: LinearAlgebraObject.h:49