Commit 92df573c authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#1292 Use Xtensor for the transient source operator. I used the same trick as...

#1292 Use Xtensor for the transient source operator. I used the same trick as reported in previous commit for matrices.
parent bab35660
......@@ -48,7 +48,7 @@ namespace MoReFEM
ParameterNS::Type TypeT,
template<ParameterNS::Type> class TimeDependencyT
>
class TransientSource final : public LinearLocalVariationalOperator<LocalVector>
class TransientSource final : public LinearLocalVariationalOperator<XtensorVector>
{
public:
......@@ -63,7 +63,7 @@ namespace MoReFEM
using parameter_type = Parameter<TypeT, LocalCoords, TimeDependencyT>;
//! Alias to parent.
using parent = LinearLocalVariationalOperator<LocalVector>;
using parent = LinearLocalVariationalOperator<XtensorVector>;
//! Returns the name of the operator.
static const std::string& ClassName();
......
......@@ -247,12 +247,17 @@ namespace MoReFEM
decltype(auto) local_2_global =
local_felt_space.GetLocal2Global<MpiScale::program_wise>(test_unknown_list);
assert(static_cast<int>(local_2_global.size()) == local_vector.GetSize());
global_vector.SetValues(local_2_global,
local_vector.GetData(),
ADD_VALUES,
__FILE__, __LINE__);
// \todo #1292 assert(static_cast<int>(local_2_global.size()) == local_vector.GetSize());
if constexpr(std::is_same<std::decay_t<decltype(local_vector)>, XtensorVector>())
global_vector.SetValues(local_2_global,
local_vector.data(),
ADD_VALUES,
__FILE__, __LINE__);
else
global_vector.SetValues(local_2_global,
local_vector.GetData(),
ADD_VALUES,
__FILE__, __LINE__);
}
......
......@@ -65,8 +65,19 @@ namespace MoReFEM
::AllocateVector(unsigned int Ndof)
{
assert(Ndof > 0);
vector_.Resize(static_cast<int>(Ndof));
vector_.Zero();
if constexpr(std::is_same<VectorTypeT, XtensorVector>())
{
std::array<size_t, 1> foo { static_cast<std::size_t>(Ndof) };
vector_ = XtensorVector(foo);
vector_.fill(0.);
}
else
{
vector_.Resize(static_cast<int>(Ndof));
vector_.Zero();
}
}
......
......@@ -153,7 +153,10 @@ namespace MoReFEM
>
void ElementaryData<OperatorNS::Nature::linear, std::false_type, VectorTypeT>::Zero()
{
this->GetNonCstVectorResult().Zero();
if constexpr(std::is_same<VectorTypeT, XtensorVector>())
this->GetNonCstVectorResult().fill(0.);
else
this->GetNonCstVectorResult().Zero();
}
......
......@@ -40,6 +40,8 @@ namespace MoReFEM
//! Convenient alias for the local symmetrix matrices, used in some specific operators.
using LocalSymmetricMatrix = ::Seldon::Matrix<double, Seldon::General, Seldon::RowSym, Seldon::MallocAlloc<double>>;
using XtensorVector = xt::xtensor<double, 1, xt::layout_type::row_major>;
//! Convenient enum class.
enum class IsMatrixOrVector
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment