Commit 681ab507 authored by Benoît LÉ's avatar Benoît LÉ

[xFEM] Added xAssemblerLumpedInVector

Does the same thing as xAssemblerLumped, but assemble the terms of the
lumped matrix in a vector.
parent 89c57a55
......@@ -325,6 +325,61 @@ class xAssemblerLumped : public xAssemblerBaseData<M, V, S>
}
};
/// same as xAssemblerLumped, but coeffcients of lumped matrix are assembled in vector
template <class M = xlinalg::xCSRMatrix, class V = xlinalg::xCSRVector, class S = double>
class xAssemblerLumpedInVector : public xAssemblerBaseData<M, V, S>
{
public:
xAssemblerLumpedInVector(M& A) : xAssemblerBaseData<M, V, S>(&A, nullptr, nullptr) {}
xAssemblerLumpedInVector(V& b) : xAssemblerBaseData<M, V, S>(0, &b, 0) {}
xAssemblerLumpedInVector() : xAssemblerBaseData<M, V, S>(0, 0, 0) {}
template <typename LOCALMATRIX, typename ITERDOF>
void assemble_matrix(ITERDOF firsti, ITERDOF lasti, ITERDOF firstj, ITERDOF lastj, const LOCALMATRIX& matr)
{
ITERDOF firstj_bak = firstj;
for (int i = 0; firsti != lasti; ++firsti, ++i)
{
firstj = firstj_bak;
for (int j = 0; firstj != lastj; ++firstj, ++j)
{
S val = this->coeff * matr(i, j);
if (!xPolicyAssemblerOnZero<typename M::matrix_assembly_on_zero>::isNull(val))
xMatVecScaAssembler<M, V, S>::assemble((*firsti)->getState(), (*firstj)->getState(), val, this->mat, this->vec,
this->sca);
}
}
}
template <typename LOCALMATRIX, typename ITERDOF>
void assemble_matrix(ITERDOF first, ITERDOF last, const LOCALMATRIX& matr)
{
ITERDOF firsti = first, firstj, lastj;
int j;
for (int i = 0; firsti != last; ++firsti, ++i)
{
xPolicyAssemblerLoop<typename M::matrix_pattern>::firstForLoop(first, firsti, firstj, i, j);
lastj = xPolicyAssemblerLoop<typename M::matrix_pattern>::lastForLoop(last, firsti);
for (; firstj != lastj; ++firstj, ++j)
{
S val = this->coeff * matr(i, j);
if (!xPolicyAssemblerOnZero<typename M::matrix_assembly_on_zero>::isNull(val))
xMatVecScaAssembler<M, V, S>::assemble((*firsti)->getState(), val, this->vec, this->sca);
}
}
}
template <typename LOCALVECTOR, typename ITERDOF>
void assemble_vector(ITERDOF first, ITERDOF last, const LOCALVECTOR& vect)
{
std::cout << "xAssemblerLumpedInVector is not supposed to be used to assemble vectors !!! " << std::endl;
throw -1;
}
template <typename LOCALSCALAR>
void assemble_scalar(const LOCALSCALAR& scal)
{
S val = scal * this->coeff;
if (val != xtool::xDataType<S>::zero()) xMatVecScaAssembler<M, V, S>::assemble(val, this->sca);
}
};
/// special lumped assembler, it assembles the same thing at each node.
/// It does the same job as xAssemblerLumped except when the element
/// has a void part
......
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