OGS 6.1.0-1721-g6382411ad
ComponentTransportProcess.cpp
Go to the documentation of this file.
1 
11 
12 #include <cassert>
13 
17 
18 namespace ProcessLib
19 {
20 namespace ComponentTransport
21 {
23  MeshLib::Mesh& mesh,
24  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
25  std::vector<std::unique_ptr<ParameterBase>> const& parameters,
26  unsigned const integration_order,
27  std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>&&
28  process_variables,
29  ComponentTransportProcessData&& process_data,
30  SecondaryVariableCollection&& secondary_variables,
31  NumLib::NamedFunctionCaller&& named_function_caller,
32  bool const use_monolithic_scheme,
33  std::unique_ptr<ProcessLib::SurfaceFluxData>&& surfaceflux)
34  : Process(mesh, std::move(jacobian_assembler), parameters,
35  integration_order, std::move(process_variables),
36  std::move(secondary_variables), std::move(named_function_caller),
37  use_monolithic_scheme),
38  _process_data(std::move(process_data)),
39  _surfaceflux(std::move(surfaceflux))
40 {
41 }
42 
44  NumLib::LocalToGlobalIndexMap const& dof_table,
45  MeshLib::Mesh const& mesh,
46  unsigned const integration_order)
47 {
48  const int process_id = 0;
49  ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
50  ProcessLib::createLocalAssemblers<LocalAssemblerData>(
51  mesh.getDimension(), mesh.getElements(), dof_table,
53  mesh.isAxiallySymmetric(), integration_order, _process_data,
54  _process_variables[process_id]);
55 
57  "darcy_velocity",
61 }
62 
64  const double t,
65  GlobalVector const& x,
66  GlobalMatrix& M,
67  GlobalMatrix& K,
68  GlobalVector& b)
69 {
70  DBUG("Assemble ComponentTransportProcess.");
71 
72  const int process_id = 0;
73  ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
74 
75  std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
76  dof_table = {std::ref(*_local_to_global_index_map)};
77  // Call global assembler for each local assembly item.
80  pv.getActiveElementIDs(), dof_table, t, x, M, K, b,
82 }
83 
85  const double t, GlobalVector const& x, GlobalVector const& xdot,
86  const double dxdot_dx, const double dx_dx, GlobalMatrix& M, GlobalMatrix& K,
87  GlobalVector& b, GlobalMatrix& Jac)
88 {
89  DBUG("AssembleWithJacobian ComponentTransportProcess.");
90 
91  const int process_id = 0;
92  ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
93  std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
94  dof_table = {std::ref(*_local_to_global_index_map)};
95  // Call global assembler for each local assembly item.
98  _local_assemblers, pv.getActiveElementIDs(), dof_table, t, x,
99  xdot, dxdot_dx, dx_dx, M, K, b, Jac, _coupled_solutions);
100 }
101 
102 Eigen::Vector3d ComponentTransportProcess::getFlux(std::size_t const element_id,
103  MathLib::Point3d const& p,
104  double const t,
105  GlobalVector const& x) const
106 {
107  std::vector<GlobalIndexType> indices_cache;
108  auto const r_c_indices = NumLib::getRowColumnIndices(
109  element_id, *_local_to_global_index_map, indices_cache);
110  std::vector<double> local_x(x.get(r_c_indices.rows));
111  return _local_assemblers[element_id]->getFlux(p, t, local_x);
112 }
113 
115  GlobalVector const& x,
116  const double t,
117  const double /*delta_t*/,
118  int const process_id)
119 {
120  // For the monolithic scheme, process_id is always zero.
121  if (_use_monolithic_scheme && process_id != 0)
122  {
123  OGS_FATAL(
124  "The condition of process_id = 0 must be satisfied for "
125  "monolithic ComponentTransportProcess, which is a single process.");
126  }
127  if (!_use_monolithic_scheme && process_id != 1)
128  {
129  DBUG(
130  "This is the transport part of the staggered "
131  "ComponentTransportProcess.");
132  return;
133  }
134  if (!_surfaceflux) // computing the surfaceflux is optional
135  {
136  return;
137  }
138 
139  ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
140 
141  _surfaceflux->integrate(x, t, *this, process_id, _integration_order,
142  _mesh, pv.getActiveElementIDs());
143  _surfaceflux->save(t);
144 }
145 
146 } // namespace ComponentTransport
147 } // namespace ProcessLib
MeshLib::Mesh & _mesh
Definition: Process.h:261
std::vector< std::reference_wrapper< ProcessVariable > > const & getProcessVariables(const int process_id) const
Definition: Process.h:123
SecondaryVariableFunctions makeExtrapolator(const unsigned num_components, NumLib::Extrapolator &extrapolator, LocalAssemblerCollection const &local_assemblers, typename NumLib::ExtrapolatableLocalAssemblerCollection< LocalAssemblerCollection >::IntegrationPointValuesMethod integration_point_values_method)
unsigned const _integration_order
Definition: Process.h:284
std::vector< std::vector< std::reference_wrapper< ProcessVariable > > > _process_variables
Definition: Process.h:300
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, GlobalVector const &x, GlobalMatrix &M, GlobalMatrix &K, GlobalVector &b, CoupledSolutionsForStaggeredScheme const *const cpl_xs)
void initializeConcreteProcess(NumLib::LocalToGlobalIndexMap const &dof_table, MeshLib::Mesh const &mesh, unsigned const integration_order) override
Process specific initialization called by initialize().
NumLib::Extrapolator & getExtrapolator() const
Definition: Process.h:150
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, GlobalVector const &x, GlobalVector const &xdot, const double dxdot_dx, const double dx_dx, GlobalMatrix &M, GlobalMatrix &K, GlobalVector &b, GlobalMatrix &Jac, CoupledSolutionsForStaggeredScheme const *const cpl_xs)
bool isAxiallySymmetric() const
Definition: Mesh.h:137
void assembleConcreteProcess(const double t, GlobalVector const &x, GlobalMatrix &M, GlobalMatrix &K, GlobalVector &b) override
std::unique_ptr< NumLib::LocalToGlobalIndexMap > _local_to_global_index_map
Definition: Process.h:264
Builds expression trees of named functions dynamically at runtime.
static void executeSelectedMemberDereferenced(Object &object, Method method, Container const &container, std::vector< std::size_t > const &active_container_ids, Args &&... args)
SecondaryVariableCollection _secondary_variables
Definition: Process.h:266
Eigen::Vector3d getFlux(std::size_t const element_id, MathLib::Point3d const &p, double const t, GlobalVector const &x) const override
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition: Mesh.h:108
void assembleWithJacobianConcreteProcess(const double t, GlobalVector const &x, GlobalVector const &xdot, const double dxdot_dx, const double dx_dx, GlobalMatrix &M, GlobalMatrix &K, GlobalVector &b, GlobalMatrix &Jac) override
CoupledSolutionsForStaggeredScheme * _coupled_solutions
Definition: Process.h:279
Handles configuration of several secondary variables from the project file.
unsigned getShapeFunctionOrder() const
std::unique_ptr< ProcessLib::SurfaceFluxData > _surfaceflux
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Definition: Mesh.h:81
std::vector< std::unique_ptr< ComponentTransportLocalAssemblerInterface > > _local_assemblers
#define OGS_FATAL(fmt,...)
Definition: Error.h:71
void addSecondaryVariable(std::string const &internal_name, SecondaryVariableFunctions &&fcts)
ComponentTransportProcess(MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< std::unique_ptr< ParameterBase >> const &parameters, unsigned const integration_order, std::vector< std::vector< std::reference_wrapper< ProcessVariable >>> &&process_variables, ComponentTransportProcessData &&process_data, SecondaryVariableCollection &&secondary_variables, NumLib::NamedFunctionCaller &&named_function_caller, bool const use_monolithic_scheme, std::unique_ptr< ProcessLib::SurfaceFluxData > &&surfaceflux)
NumLib::LocalToGlobalIndexMap::RowColumnIndices getRowColumnIndices(std::size_t const id, NumLib::LocalToGlobalIndexMap const &dof_table, std::vector< GlobalIndexType > &indices)
virtual std::vector< double > const & getIntPtDarcyVelocity(const double t, GlobalVector const &current_solution, NumLib::LocalToGlobalIndexMap const &dof_table, std::vector< double > &cache) const =0
const bool _use_monolithic_scheme
Definition: Process.h:275
VectorMatrixAssembler _global_assembler
Definition: Process.h:273
void postTimestepConcreteProcess(GlobalVector const &x, const double t, const double delta_t, int const process_id) override
std::vector< std::size_t > & getActiveElementIDs() const