-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVectorMatrixAssembler.h
82 lines (70 loc) · 2.92 KB
/
VectorMatrixAssembler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/**
* \file
* \copyright
* Copyright (c) 2012-2020, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#pragma once
#include <vector>
#include "NumLib/NumericsConfig.h"
#include "AbstractJacobianAssembler.h"
#include "CoupledSolutionsForStaggeredScheme.h"
namespace NumLib
{
class LocalToGlobalIndexMap;
} // NumLib
namespace ProcessLib
{
struct CoupledSolutionsForStaggeredScheme;
class LocalAssemblerInterface;
//! Utility class used to assemble global matrices and vectors.
//!
//! The methods of this class get the global matrices and vectors as input and
//! pass only local data on to the local assemblers.
class VectorMatrixAssembler final
{
public:
explicit VectorMatrixAssembler(
std::unique_ptr<AbstractJacobianAssembler>&& jacobian_assembler);
void preAssemble(const std::size_t mesh_item_id,
LocalAssemblerInterface& local_assembler,
const NumLib::LocalToGlobalIndexMap& dof_table,
const double t, double const dt, const GlobalVector& x);
//! Assembles\c M, \c K, and \c b.
//! \remark Jacobian is not assembled here, see assembleWithJacobian().
void assemble(std::size_t const mesh_item_id,
LocalAssemblerInterface& local_assembler,
std::vector<std::reference_wrapper<
NumLib::LocalToGlobalIndexMap>> const& dof_tables,
double const t, double const dt,
std::vector<GlobalVector*> const& x,
std::vector<GlobalVector*> const& xdot, int const process_id,
GlobalMatrix& M, GlobalMatrix& K, GlobalVector& b,
CoupledSolutionsForStaggeredScheme const* const cpl_xs);
//! Assembles \c M, \c K, \c b, and the Jacobian \c Jac of the residual.
//! \note The Jacobian must be assembled.
void assembleWithJacobian(
std::size_t const mesh_item_id,
LocalAssemblerInterface& local_assembler,
std::vector<
std::reference_wrapper<NumLib::LocalToGlobalIndexMap>> const&
dof_tables,
const double t, double const dt, std::vector<GlobalVector*> const& x,
GlobalVector const& xdot, const double dxdot_dx, const double dx_dx,
int const process_id, GlobalMatrix& M, GlobalMatrix& K, GlobalVector& b,
GlobalMatrix& Jac,
CoupledSolutionsForStaggeredScheme const* const cpl_xs);
private:
// temporary data only stored here in order to avoid frequent memory
// reallocations.
std::vector<double> _local_M_data;
std::vector<double> _local_K_data;
std::vector<double> _local_b_data;
std::vector<double> _local_Jac_data;
//! Used to assemble the Jacobian.
std::unique_ptr<AbstractJacobianAssembler> _jacobian_assembler;
};
} // namespace ProcessLib