Skip to content
Snippets Groups Projects
Commit 598e7390 authored by Christoph Lehmann's avatar Christoph Lehmann
Browse files

[NL] removed vec mat asm

parent c2bf5190
No related branches found
No related tags found
No related merge requests found
......@@ -52,150 +52,7 @@ getLocalNodalDOFs(GlobalVector const& x,
return local_x;
}
} // namespace detail
/*! Calls the local assemblers of FEM processes and assembles
* \c GlobalMatrix'es and \c GlobalVector's.
*
* It optionally gets the local d.o.f. from a GlobalVector using
* a LocalToGlobalIndexMap and passes them on to the local assembler.
*
* Each type of equation as flagged by the \c ODETag will have a different
* VectorMatrixAssembler type.
*/
template<typename LocalAssembler,
NumLib::ODESystemTag ODETag>
class VectorMatrixAssembler;
//! Specialization for first-order implicit quasi-linear systems.
template<typename LocalAssembler>
class VectorMatrixAssembler<LocalAssembler,
NumLib::ODESystemTag::FirstOrderImplicitQuasilinear> final
{
public:
VectorMatrixAssembler(
LocalToGlobalIndexMap const& data_pos)
: _data_pos(data_pos)
{}
/// Executes local assembler for the given mesh item and adds the result
/// into the global matrix and vector.
/// The positions in the global matrix/vector are taken from
/// the LocalToGlobalIndexMap provided in the constructor at index \c id.
/// \attention The index \c id is not necessarily the mesh item's id.
void assemble(std::size_t const id,
LocalAssembler& local_assembler,
const double t, GlobalVector const& x,
GlobalMatrix& M, GlobalMatrix& K, GlobalVector& b) const
{
auto const indices = detail::getIndices(id, _data_pos);
auto const local_x = detail::getLocalNodalDOFs(x, indices);
auto const r_c_indices =
NumLib::LocalToGlobalIndexMap::RowColumnIndices(indices, indices);
local_assembler.assemble(t, local_x);
local_assembler.addToGlobal(r_c_indices, M, K, b);
}
/// Executes assembleJacobian() of the local assembler for the
/// given mesh item passing the mesh item's nodal d.o.f.
/// \attention The index \c id is not necessarily the mesh item's id.
void assembleJacobian(std::size_t const id,
LocalAssembler& local_assembler,
const double t,
GlobalVector const& x,
GlobalMatrix& Jac) const
{
auto const indices = detail::getIndices(id, _data_pos);
auto const local_x = detail::getLocalNodalDOFs(x, indices);
auto const r_c_indices =
NumLib::LocalToGlobalIndexMap::RowColumnIndices(indices, indices);
local_assembler.assembleJacobian(t, local_x);
local_assembler.addJacobianToGlobal(r_c_indices, Jac);
}
/// Executes the preTimestep() method of the local assembler for the
/// given mesh item passing the mesh item's nodal d.o.f.
/// \attention The index \c id is not necessarily the mesh item's id.
void preTimestep(std::size_t const id,
LocalAssembler& local_assembler,
GlobalVector const& x,
double const t,
double const delta_t) const
{
auto const indices = detail::getIndices(id, _data_pos);
auto const local_x = detail::getLocalNodalDOFs(x, indices);
local_assembler.preTimestep(local_x, t, delta_t);
}
/// Executes the postTimestep() method of the local assembler for the
/// given mesh item passing the mesh item's nodal d.o.f.
/// \attention The index \c id is not necessarily the mesh item's id.
void postTimestep(std::size_t const id,
LocalAssembler& local_assembler,
GlobalVector const& x) const
{
auto const indices = detail::getIndices(id, _data_pos);
auto const local_x = detail::getLocalNodalDOFs(x, indices);
local_assembler.postTimestep(local_x);
}
/// Executes the given callback function for the given mesh item
/// passing the mesh item's nodal d.o.f.
/// \attention The index \c id is not necessarily the mesh item's id.
template <typename Callback, typename... Args>
void passLocalVector(Callback& cb, std::size_t const id,
GlobalVector const& x, Args&&... args)
{
auto const indices = detail::getIndices(id, _data_pos);
auto const local_x = detail::getLocalNodalDOFs(x, indices);
auto const r_c_indices =
NumLib::LocalToGlobalIndexMap::RowColumnIndices(indices, indices);
cb(local_x, r_c_indices, std::forward<Args>(args)...);
}
private:
LocalToGlobalIndexMap const& _data_pos;
};
//! Specialization used to add Neumann boundary conditions.
template<typename LocalAssembler>
class VectorMatrixAssembler<LocalAssembler,
NumLib::ODESystemTag::NeumannBC> final
{
public:
VectorMatrixAssembler(
LocalToGlobalIndexMap const& data_pos)
: _data_pos(data_pos)
{}
/// Executes local assembler for the given mesh item and adds the result
/// into the global matrix and vector.
/// The positions in the global matrix/vector are taken from
/// the LocalToGlobalIndexMap provided in the constructor at index \c id.
/// \attention The index \c id is not necessarily the mesh item's id.
void assemble(std::size_t const id,
LocalAssembler& local_assembler,
const double t, GlobalVector& b) const
{
auto const indices = detail::getIndices(id, _data_pos);
auto const r_c_indices =
NumLib::LocalToGlobalIndexMap::RowColumnIndices(indices, indices);
local_assembler.assemble(t);
local_assembler.addToGlobal(r_c_indices, b);
}
private:
LocalToGlobalIndexMap const& _data_pos;
};
} // namespace NumLib
} // namespace detail
} // namespace NumLib
#endif // NUMLIB_VECTORMATRIXASSEMBLER_H_
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment