OGS
StokesFlowProcess.cpp
Go to the documentation of this file.
1 
11 #include "StokesFlowProcess.h"
12 
13 #include <cassert>
14 
15 #include "CreateLocalAssemblers.h"
16 #include "MeshLib/Elements/Utils.h"
17 
18 namespace ProcessLib
19 {
20 namespace StokesFlow
21 {
22 template <int GlobalDim>
24  std::string name,
25  MeshLib::Mesh& mesh,
26  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
27  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
28  unsigned const integration_order,
29  std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>&&
30  process_variables,
31  StokesFlowProcessData&& process_data,
32  SecondaryVariableCollection&& secondary_variables,
33  bool const use_monolithic_scheme)
34  : Process(std::move(name), mesh, std::move(jacobian_assembler), parameters,
35  integration_order, std::move(process_variables),
36  std::move(secondary_variables), use_monolithic_scheme),
37  _process_data(std::move(process_data))
38 {
39 }
40 
41 template <int GlobalDim>
43 {
44  // Create single component dof in every of the mesh's nodes.
45  _mesh_subset_all_nodes =
46  std::make_unique<MeshLib::MeshSubset>(_mesh, _mesh.getNodes());
47  // Create single component dof in the mesh's base nodes.
48  _base_nodes = MeshLib::getBaseNodes(_mesh.getElements());
49  _mesh_subset_base_nodes =
50  std::make_unique<MeshLib::MeshSubset>(_mesh, _base_nodes);
51 
52  // TODO move the two data members somewhere else.
53  // for extrapolation of secondary variables
54  std::vector<MeshLib::MeshSubset> all_mesh_subsets_single_component{
55  *_mesh_subset_all_nodes};
56  _local_to_global_index_map_single_component =
57  std::make_unique<NumLib::LocalToGlobalIndexMap>(
58  std::move(all_mesh_subsets_single_component),
59  // by location order is needed for output
61 
62  assert(_use_monolithic_scheme);
63  {
64  // For vector variables, in this case liquid velocity.
65  int const process_id = 0;
66  std::vector<MeshLib::MeshSubset> all_mesh_subsets(
67  getProcessVariables(process_id)[0]
68  .get()
69  .getNumberOfGlobalComponents(),
70  *_mesh_subset_all_nodes);
71 
72  // For scalar variables, in this case pressure.
73  all_mesh_subsets.push_back(*_mesh_subset_base_nodes);
74 
75  std::vector<int> const vec_n_components{GlobalDim, 1};
76 
77  _local_to_global_index_map =
78  std::make_unique<NumLib::LocalToGlobalIndexMap>(
79  std::move(all_mesh_subsets), vec_n_components,
81  assert(_local_to_global_index_map);
82  }
83 }
84 
85 template <int GlobalDim>
87  NumLib::LocalToGlobalIndexMap const& dof_table,
88  MeshLib::Mesh const& mesh,
89  unsigned const integration_order)
90 {
91  int const process_id = 0;
92  ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
93  // Todo: may move LocalDataInitializer.h and CreateLocalAssemblers.h which
94  // are identical to those in such processes as HydroMechanics,
95  // RichardsMechanics, and etc, into a common place.
98  mesh.getDimension(), mesh.getElements(), dof_table,
99  pv.getShapeFunctionOrder(), _local_assemblers,
100  mesh.isAxiallySymmetric(), integration_order, _process_data);
101 
102  _process_data.pressure_interpolated =
103  MeshLib::getOrCreateMeshProperty<double>(
104  const_cast<MeshLib::Mesh&>(mesh), "pressure_interpolated",
106 }
107 
108 template <int GlobalDim>
110 {
111  assert(_use_monolithic_scheme);
112  {
113  int const process_id = 0;
114  initializeProcessBoundaryConditionsAndSourceTerms(
115  *_local_to_global_index_map, process_id);
116  }
117 }
118 
119 template <int GlobalDim>
122  const int /*process_id*/) const
123 {
124  assert(_use_monolithic_scheme);
125  {
126  auto const& l = *_local_to_global_index_map;
127 
128  return {l.dofSizeWithoutGhosts(), l.dofSizeWithoutGhosts(),
129  &l.getGhostIndices(), &this->_sparsity_pattern};
130  }
131 }
132 
133 template <int GlobalDim>
135  const double t, double const dt, std::vector<GlobalVector*> const& x,
136  std::vector<GlobalVector*> const& xdot, int const process_id,
138 {
139  DBUG("Assemble StokesFlowProcess.");
140 
141  std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
142  dof_tables;
143  assert(_use_monolithic_scheme);
144  {
145  dof_tables.push_back(std::ref(*_local_to_global_index_map));
146  }
147 
148  ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
149  // Call global assembler for each local assembly item.
151  _global_assembler, &VectorMatrixAssembler::assemble, _local_assemblers,
152  pv.getActiveElementIDs(), dof_tables, t, dt, x, xdot, process_id, M, K,
153  b);
154 }
155 
156 template <int GlobalDim>
158  const double /*t*/, double const /*dt*/,
159  std::vector<GlobalVector*> const& /*x*/,
160  std::vector<GlobalVector*> const& /*xdot*/, const double /*dxdot_dx*/,
161  const double /*dx_dx*/, int const /*process_id*/, GlobalMatrix& /*M*/,
162  GlobalMatrix& /*K*/, GlobalVector& /*b*/, GlobalMatrix& /*Jac*/)
163 {
164  OGS_FATAL(
165  "Assembly of Jacobian matrix has not yet been implemented for "
166  "StokesFlowProcess.");
167 }
168 
169 template <int GlobalDim>
171  double const t,
172  double const dt,
173  std::vector<GlobalVector*> const& x,
174  GlobalVector const& x_dot,
175  int const process_id)
176 {
177  if (process_id != 0)
178  {
179  return;
180  }
181 
182  std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;
183  dof_tables.reserve(x.size());
184  assert(_use_monolithic_scheme);
185  {
186  dof_tables.push_back(_local_to_global_index_map.get());
187  }
188 
189  ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
192  _local_assemblers, pv.getActiveElementIDs(), dof_tables, t, dt, x,
193  x_dot, process_id);
194 }
195 
196 template <int GlobalDim>
198  std::vector<GlobalVector*> const& x,
199  const double t,
200  const double dt,
201  int const process_id)
202 {
203  if (process_id != 0)
204  {
205  return;
206  }
207 
208  std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;
209  dof_tables.reserve(x.size());
210  assert(_use_monolithic_scheme);
211  {
212  dof_tables.push_back(_local_to_global_index_map.get());
213  }
214 
215  ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
218  pv.getActiveElementIDs(), dof_tables, x, t, dt);
219 }
220 
221 template <int GlobalDim>
223  const int /*process_id*/) const
224 {
225  assert(_use_monolithic_scheme);
226  {
227  return *_local_to_global_index_map;
228  }
229 }
230 
231 template class StokesFlowProcess<2>;
232 } // namespace StokesFlow
233 } // namespace ProcessLib
#define OGS_FATAL(...)
Definition: Error.h:26
void DBUG(char const *fmt, Args const &... args)
Definition: Logging.h:27
Global vector based on Eigen vector.
Definition: EigenVector.h:26
bool isAxiallySymmetric() const
Definition: Mesh.h:126
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Definition: Mesh.h:71
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition: Mesh.h:98
virtual void postTimestep(std::size_t const mesh_item_id, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_tables, std::vector< GlobalVector * > const &x, double const t, double const dt)
virtual void computeSecondaryVariable(std::size_t const mesh_item_id, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_tables, double const t, double const dt, std::vector< GlobalVector * > const &x, GlobalVector const &x_dot, int const process_id)
unsigned getShapeFunctionOrder() const
std::vector< std::size_t > const & getActiveElementIDs() const
Handles configuration of several secondary variables from the project file.
StokesFlowProcess(std::string name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters, unsigned const integration_order, std::vector< std::vector< std::reference_wrapper< ProcessVariable >>> &&process_variables, StokesFlowProcessData &&process_data, SecondaryVariableCollection &&secondary_variables, bool const use_monolithic_scheme)
void initializeConcreteProcess(NumLib::LocalToGlobalIndexMap const &dof_table, MeshLib::Mesh const &mesh, unsigned const integration_order) override
Process specific initialization called by initialize().
void computeSecondaryVariableConcrete(double const, double const, std::vector< GlobalVector * > const &x, GlobalVector const &, int const) override
void assembleConcreteProcess(const double t, double const dt, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &xdot, int const process_id, GlobalMatrix &M, GlobalMatrix &K, GlobalVector &b) override
void assembleWithJacobianConcreteProcess(const double t, double const dt, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &xdot, const double dxdot_dx, const double dx_dx, int const process_id, GlobalMatrix &M, GlobalMatrix &K, GlobalVector &b, GlobalMatrix &Jac) override
NumLib::LocalToGlobalIndexMap const & getDOFTable(const int) const override
void postTimestepConcreteProcess(std::vector< GlobalVector * > const &x, const double t, const double dt, int const process_id) override
MathLib::MatrixSpecifications getMatrixSpecifications(const int) const override
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)
std::vector< Node * > getBaseNodes(std::vector< Element * > const &elements)
Definition: Utils.h:26
@ BY_LOCATION
Ordering data by spatial location.
void createLocalAssemblers(const unsigned, std::vector< MeshLib::Element * > const &mesh_elements, NumLib::LocalToGlobalIndexMap const &dof_table, const unsigned shapefunction_order, std::vector< std::unique_ptr< LocalAssemblerInterface >> &local_assemblers, ExtraCtorArgs &&... extra_ctor_args)
static void executeSelectedMemberOnDereferenced(Method method, Container const &container, std::vector< std::size_t > const &active_container_ids, Args &&... args)
static void executeSelectedMemberDereferenced(Object &object, Method method, Container const &container, std::vector< std::size_t > const &active_container_ids, Args &&... args)