28 namespace ComponentTransport
33 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
34 std::vector<std::unique_ptr<ParameterLib::ParameterBase>>
const& parameters,
35 unsigned const integration_order,
36 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>&&
40 bool const use_monolithic_scheme,
41 std::unique_ptr<ProcessLib::SurfaceFluxData>&& surfaceflux,
42 std::unique_ptr<ChemistryLib::ChemicalSolverInterface>&&
43 chemical_solver_interface)
44 :
Process(std::move(
name), mesh, std::move(jacobian_assembler), parameters,
45 integration_order, std::move(process_variables),
46 std::move(secondary_variables), use_monolithic_scheme),
47 _process_data(std::move(process_data)),
48 _surfaceflux(std::move(surfaceflux)),
49 _chemical_solver_interface(std::move(chemical_solver_interface))
56 unsigned const integration_order)
62 const int process_id = 0;
65 std::vector<std::reference_wrapper<ProcessLib::ProcessVariable>>
66 transport_process_variables;
73 transport_process_variables.push_back(*pv_iter);
82 transport_process_variables.push_back((*pv_iter)[0]);
86 ProcessLib::createLocalAssemblers<LocalAssemblerData>(
90 transport_process_variables);
109 std::vector<GlobalVector*>& x,
double const t,
int const process_id)
116 if (process_id !=
static_cast<int>(x.size() - 1))
123 std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;
124 dof_tables.reserve(x.size());
125 std::generate_n(std::back_inserter(dof_tables), x.size(),
126 [&]() { return _local_to_global_index_map.get(); });
133 time_phreeqc.
start();
140 INFO(
"[time] Phreeqc took {:g} s.", time_phreeqc.
elapsed());
144 const double t,
double const dt, std::vector<GlobalVector*>
const& x,
145 std::vector<GlobalVector*>
const& xdot,
int const process_id,
148 DBUG(
"Assemble ComponentTransportProcess.");
152 std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
162 [&]() { return std::ref(*_local_to_global_index_map); });
172 const double t,
double const dt, std::vector<GlobalVector*>
const& x,
173 std::vector<GlobalVector*>
const& xdot,
const double dxdot_dx,
177 DBUG(
"AssembleWithJacobian ComponentTransportProcess.");
180 std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
186 dxdot_dx, dx_dx, process_id, M, K, b, Jac);
190 std::size_t
const element_id,
193 std::vector<GlobalVector*>
const& x)
const
195 std::vector<GlobalIndexType> indices_cache;
199 std::vector<std::vector<GlobalIndexType>> indices_of_all_coupled_processes{
200 x.size(), r_c_indices.rows};
201 auto const local_xs =
210 DBUG(
"Set the coupled term for the staggered scheme to local assembers.");
215 setStaggeredCoupledSolutions,
220 std::vector<GlobalVector*>& x, std::vector<GlobalVector*>
const& x_prev,
222 int const process_id)
227 INFO(
"Update process solutions via the look-up table approach");
243 std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;
244 dof_tables.reserve(x.size());
245 std::generate_n(std::back_inserter(dof_tables), x.size(),
246 [&]() { return _local_to_global_index_map.get(); });
255 time_phreeqc.
start();
261 INFO(
"[time] Phreeqc took {:g} s.", time_phreeqc.
elapsed());
265 postSpeciationCalculation,
271 auto const matrix_specification =
274 std::size_t matrix_id = 0u;
276 matrix_specification, matrix_id);
278 matrix_specification, matrix_id);
297 matrix_specification, matrix_id);
314 auto& equation_system =
static_cast<EqSys&
>(ode_sys);
315 equation_system.applyKnownSolutionsPicard(A, rhs, *x[process_id]);
317 auto& linear_solver =
319 linear_solver.
solve(A, rhs, *x[process_id]);
329 std::vector<GlobalVector*>
const& integration_point_values_vectors,
330 std::vector<GlobalVector*>& nodal_values_vectors)
333 auto const extrapolatables =
336 getInterpolatedLocalSolution);
338 for (
unsigned transport_process_id = 0;
339 transport_process_id < integration_point_values_vectors.size();
340 ++transport_process_id)
343 auto const& int_pt_C =
344 integration_point_values_vectors[transport_process_id];
346 extrapolator.extrapolate(pv.getNumberOfGlobalComponents(),
347 extrapolatables, t, {int_pt_C},
348 {_local_to_global_index_map.get()});
350 auto const& nodal_values = extrapolator.getNodalValues();
352 *nodal_values_vectors[transport_process_id + 1]);
354 *nodal_values_vectors[transport_process_id + 1]);
361 std::vector<GlobalVector*>
const& x,
363 int const process_id)
370 std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;
371 dof_tables.reserve(x.size());
372 std::generate_n(std::back_inserter(dof_tables), x.size(),
373 [&]() { return _local_to_global_index_map.get(); });
383 std::vector<GlobalVector*>
const& x,
386 int const process_id)
393 std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;
394 dof_tables.reserve(x.size());
395 std::generate_n(std::back_inserter(dof_tables), x.size(),
396 [&]() { return _local_to_global_index_map.get(); });
void INFO(char const *fmt, Args const &... args)
void DBUG(char const *fmt, Args const &... args)
Definition of the RunTime class.
double elapsed() const
Get the elapsed time in seconds.
void start()
Start the timer.
GlobalLinearSolver & linear_solver
bool solve(EigenMatrix &A, EigenVector &b, EigenVector &x)
Global vector based on Eigen vector.
bool isAxiallySymmetric() const
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
std::size_t getNumberOfNodes() const
Get the number of nodes.
virtual MathLib::MatrixSpecifications getMatrixSpecifications(const int process_id) const =0
virtual GlobalMatrix & getMatrix(std::size_t &id)=0
Get an uninitialized matrix with the given id.
virtual void releaseMatrix(GlobalMatrix const &A)=0
virtual GlobalVector & getVector(std::size_t &id)=0
Get an uninitialized vector with the given id.
virtual void releaseVector(GlobalVector const &x)=0
virtual void setChemicalSystemID(std::size_t const)=0
void initializeChemicalSystem(std::size_t const mesh_item_id, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_tables, std::vector< GlobalVector * > const &x, double const t)
void setChemicalSystem(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)
void assembleReactionEquation(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, GlobalMatrix &M, GlobalMatrix &K, GlobalVector &b, int const process_id)
virtual std::vector< double > const & getIntPtDarcyVelocity(const double t, std::vector< GlobalVector * > const &x, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_table, std::vector< double > &cache) const =0
void setInitialConditionsConcreteProcess(std::vector< GlobalVector * > &x, double const t, int const process_id) override
void initializeConcreteProcess(NumLib::LocalToGlobalIndexMap const &dof_table, MeshLib::Mesh const &mesh, unsigned const integration_order) override
Process specific initialization called by initialize().
std::unique_ptr< ChemistryLib::ChemicalSolverInterface > _chemical_solver_interface
ComponentTransportProcessData _process_data
void extrapolateIntegrationPointValuesToNodes(const double t, std::vector< GlobalVector * > const &integration_point_values_vectors, std::vector< GlobalVector * > &nodal_values_vectors) 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 computeSecondaryVariableConcrete(double const, double const, std::vector< GlobalVector * > const &x, GlobalVector const &, int const) 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
void solveReactionEquation(std::vector< GlobalVector * > &x, std::vector< GlobalVector * > const &x_prev, double const t, double const dt, NumLib::EquationSystem &ode_sys, int const process_id) override
void postTimestepConcreteProcess(std::vector< GlobalVector * > const &x, const double t, const double dt, int const process_id) override
void setCoupledTermForTheStaggeredSchemeToLocalAssemblers(int const process_id) override
std::vector< std::unique_ptr< ComponentTransportLocalAssemblerInterface > > _local_assemblers
std::unique_ptr< ProcessLib::SurfaceFluxData > _surfaceflux
Eigen::Vector3d getFlux(std::size_t const element_id, MathLib::Point3d const &p, double const t, std::vector< GlobalVector * > const &x) const override
ComponentTransportProcess(std::string name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const ¶meters, unsigned const integration_order, std::vector< std::vector< std::reference_wrapper< ProcessVariable >>> &&process_variables, ComponentTransportProcessData &&process_data, SecondaryVariableCollection &&secondary_variables, bool const use_monolithic_scheme, std::unique_ptr< ProcessLib::SurfaceFluxData > &&surfaceflux, std::unique_ptr< ChemistryLib::ChemicalSolverInterface > &&chemical_solver_interface)
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
NumLib::Extrapolator & getExtrapolator() const
std::vector< std::vector< std::reference_wrapper< ProcessVariable > > > _process_variables
SecondaryVariableCollection _secondary_variables
CoupledSolutionsForStaggeredScheme * _coupled_solutions
std::vector< std::reference_wrapper< ProcessVariable > > const & getProcessVariables(const int process_id) const
VectorMatrixAssembler _global_assembler
unsigned const _integration_order
std::unique_ptr< NumLib::LocalToGlobalIndexMap > _local_to_global_index_map
const bool _use_monolithic_scheme
Handles configuration of several secondary variables from the project file.
void addSecondaryVariable(std::string const &internal_name, SecondaryVariableFunctions &&fcts)
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, 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)
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)
NonlinearSolverTag
Tag used to specify which nonlinear solver will be used.
void finalizeAssembly(PETScMatrix &A)
void copy(PETScVector const &x, PETScVector &y)
void matMult(PETScMatrix const &A, PETScVector const &x, PETScVector &y)
void aypx(PETScVector &y, double const a, PETScVector const &x)
void finalizeVectorAssembly(VEC_T &)
General function to finalize the vector assembly.
bool finalizeMatrixAssembly(MAT_T &)
NumLib::LocalToGlobalIndexMap::RowColumnIndices getRowColumnIndices(std::size_t const id, NumLib::LocalToGlobalIndexMap const &dof_table, std::vector< GlobalIndexType > &indices)
ExtrapolatableLocalAssemblerCollection< LocalAssemblerCollection > makeExtrapolatable(LocalAssemblerCollection const &local_assemblers, IntegrationPointValuesMethod integration_point_values_method)
std::vector< double > getCoupledLocalSolutions(std::vector< GlobalVector * > const &global_solutions, std::vector< std::vector< GlobalIndexType >> const &indices)
SecondaryVariableFunctions makeExtrapolator(const unsigned num_components, NumLib::Extrapolator &extrapolator, LocalAssemblerCollection const &local_assemblers, typename NumLib::ExtrapolatableLocalAssemblerCollection< LocalAssemblerCollection >::IntegrationPointValuesMethod integration_point_values_method)
static NUMLIB_EXPORT MatrixProvider & provider
static NUMLIB_EXPORT VectorProvider & provider
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)
std::unique_ptr< LookupTable > lookup_table
ChemistryLib::ChemicalSolverInterface *const chemical_solver_interface
MeshLib::PropertyVector< double > * mesh_prop_velocity