Smith  0.1
Smith is an implicit thermal structural mechanics simulation code.
coupled_system_solver.hpp
1 // Copyright (c) Lawrence Livermore National Security, LLC and
2 // other Smith Project Developers. See the top-level LICENSE file for
3 // details.
4 //
5 // SPDX-License-Identifier: (BSD-3-Clause)
6 
7 #pragma once
8 
9 #include <vector>
10 #include <memory>
11 #include <mpi.h>
14 #include "smith/physics/common.hpp"
15 
16 namespace smith {
17 
18 class WeakForm;
19 class NonlinearBlockSolverBase;
20 class BoundaryConditionManager;
21 
24  public:
26  struct Stage {
27  std::vector<size_t> block_indices;
28  std::shared_ptr<NonlinearBlockSolverBase> solver;
29  double relaxation_factor = 1.0;
32  };
33 
36  CoupledSystemSolver(std::shared_ptr<NonlinearBlockSolverBase> single_solver);
37 
45  CoupledSystemSolver(int max_staggered_iterations, bool exact_staggered_steps = false);
46 
51  void addSubsystemSolver(const std::vector<size_t>& block_indices, std::shared_ptr<NonlinearBlockSolverBase> solver,
52  double relaxation_factor = 1.0);
53 
63  std::vector<FieldState> solve(const std::vector<WeakForm*>& residual_evals,
64  const std::vector<std::vector<size_t>>& block_indices, const FieldState& shape_disp,
65  const std::vector<std::vector<FieldState>>& states,
66  const std::vector<std::vector<FieldState>>& params, const TimeInfo& time_info,
67  const std::vector<const BoundaryConditionManager*>& bc_managers) const;
68 
71  std::shared_ptr<CoupledSystemSolver> singleBlockSolver(size_t block_index) const;
72 
73  private:
74  int max_staggered_iterations_;
75  bool exact_staggered_steps_;
76  std::vector<Stage> stages_;
77 };
78 
79 } // namespace smith
Orchestrates staggered solution for multiphysics systems.
std::vector< FieldState > solve(const std::vector< WeakForm * > &residual_evals, const std::vector< std::vector< size_t >> &block_indices, const FieldState &shape_disp, const std::vector< std::vector< FieldState >> &states, const std::vector< std::vector< FieldState >> &params, const TimeInfo &time_info, const std::vector< const BoundaryConditionManager * > &bc_managers) const
Solves the multiphysics system using staggered iterations.
CoupledSystemSolver(std::shared_ptr< NonlinearBlockSolverBase > single_solver)
Construct a monolithic CoupledSystemSolver from a single block solver.
std::shared_ptr< CoupledSystemSolver > singleBlockSolver(size_t block_index) const
Build a single-block solver from the stage responsible for block_index. Prefers constructing a fresh ...
void addSubsystemSolver(const std::vector< size_t > &block_indices, std::shared_ptr< NonlinearBlockSolverBase > solver, double relaxation_factor=1.0)
Convenience method to add a solver stage.
A file defining some enums and structs that are used by the different physics modules.
Accelerator functionality.
Definition: smith.cpp:36
gretl::State< FEFieldPtr, FEDualPtr > FieldState
typedef
Definition: field_state.hpp:22
This file contains enumerations and record types for physics solver configuration.
Represents a single stage in a staggered iteration.
std::vector< size_t > block_indices
Which blocks (residuals) to solve in this stage.
std::shared_ptr< NonlinearBlockSolverBase > solver
Solver to use for this stage.
struct storing time and timestep information
Definition: common.hpp:18