OGS
ProcessLib::AssemblyMixinBase Class Reference

Detailed Description

Provides basic functionality for the AssemblyMixin that does not require template parameters.

Definition at line 22 of file AssemblyMixin.h.

#include <AssemblyMixin.h>

Inheritance diagram for ProcessLib::AssemblyMixinBase:
[legend]
Collaboration diagram for ProcessLib::AssemblyMixinBase:
[legend]

Protected Member Functions

 AssemblyMixinBase (AbstractJacobianAssembler &jacobian_assembler, bool const is_linear, bool const use_monolithic_scheme)
void initializeAssemblyOnSubmeshes (MeshLib::Mesh &bulk_mesh, std::vector< std::reference_wrapper< MeshLib::Mesh > > const &submeshes, std::vector< std::vector< std::string > > const &residuum_names, std::vector< std::vector< std::reference_wrapper< ProcessVariable > > > const &pvs)
void updateActiveElements (ProcessLib::Process const &process)
bool isLinear () const

Static Protected Member Functions

static void copyResiduumVectorsToBulkMesh (GlobalVector const &rhs, NumLib::LocalToGlobalIndexMap const &local_to_global_index_map, std::vector< std::reference_wrapper< MeshLib::PropertyVector< double > > > residuum_vectors)
static void copyResiduumVectorsToSubmesh (int const process_id, GlobalVector const &rhs, NumLib::LocalToGlobalIndexMap const &local_to_global_index_map, ProcessLib::Assembly::SubmeshAssemblyData const &sad)

Protected Attributes

std::vector< ProcessLib::Assembly::SubmeshAssemblyDatasubmesh_assembly_data_
 SubmeshAssemblyData for each submesh.
std::vector< AssembledMatrixCachesubmesh_matrix_cache_
 AssembledMatrixCache for each submesh.
std::optional< ProcessLib::Assembly::BulkMeshAssemblyDatabulk_mesh_assembly_data_
 Empty if submesh assembly is used.
AssembledMatrixCache bulk_mesh_matrix_cache_
Assembly::ParallelVectorMatrixAssembler pvma_
bool is_linear_
std::optional< NumLib::NonlinearSolverTaglast_assembly_was_

Private Types

enum class  ActiveElementIDsState { UNINITIALIZED , HAS_DEACTIVATED_SUBDOMAINS , NO_DEACTIVATED_SUBDOMAINS }

Private Member Functions

void updateActiveElementsImpl (Process const &process)

Private Attributes

ActiveElementIDsState ids_state_ = ActiveElementIDsState::UNINITIALIZED

Member Enumeration Documentation

◆ ActiveElementIDsState

Enumerator
UNINITIALIZED 
HAS_DEACTIVATED_SUBDOMAINS 
NO_DEACTIVATED_SUBDOMAINS 

Definition at line 24 of file AssemblyMixin.h.

25 {
26 UNINITIALIZED,
27 HAS_DEACTIVATED_SUBDOMAINS,
28 NO_DEACTIVATED_SUBDOMAINS
29 };

Constructor & Destructor Documentation

◆ AssemblyMixinBase()

ProcessLib::AssemblyMixinBase::AssemblyMixinBase ( AbstractJacobianAssembler & jacobian_assembler,
bool const is_linear,
bool const use_monolithic_scheme )
explicitprotected

Definition at line 97 of file AssemblyMixin.cpp.

101 : pvma_{jacobian_assembler}, is_linear_{is_linear}
102{
103 if (is_linear && !use_monolithic_scheme)
104 {
105 OGS_FATAL(
106 "You requested to assemble only once in combination with staggered "
107 "coupling. This use case is not yet implemented.");
108 }
109
110 if (is_linear_)
111 {
112 WARN(
113 "You specified that the process simulated by OGS is linear. With "
114 "this optimization, the system is assembled only once, and the "
115 "non-linear solver performs a single iteration per time step. No "
116 "non-linearities will be resolved, and OGS will not detect whether "
117 "any exist. It is your responsibility to ensure that the assembled "
118 "systems are indeed linear; there is no safety net.\n"
119 "\n"
120 "Be aware that non-linearities may arise in subtle ways. For "
121 "example, in an HT problem with a steady-state velocity field, if "
122 "the initial pressure field does not match the steady-state "
123 "condition (e.g., initialized to zero), then the steady-state "
124 "velocity field only emerges during the first iteration—making the "
125 "system effectively non-linear under this optimization.");
126 }
127}
#define OGS_FATAL(...)
Definition Error.h:19
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:34
Assembly::ParallelVectorMatrixAssembler pvma_

References is_linear_, OGS_FATAL, pvma_, and WARN().

Member Function Documentation

◆ copyResiduumVectorsToBulkMesh()

void ProcessLib::AssemblyMixinBase::copyResiduumVectorsToBulkMesh ( GlobalVector const & rhs,
NumLib::LocalToGlobalIndexMap const & local_to_global_index_map,
std::vector< std::reference_wrapper< MeshLib::PropertyVector< double > > > residuum_vectors )
staticprotected

Definition at line 235 of file AssemblyMixin.cpp.

240{
241 for (std::size_t variable_id = 0; variable_id < residuum_vectors.size();
242 ++variable_id)
243 {
245 rhs, variable_id, local_to_global_index_map,
246 residuum_vectors[variable_id].get(), std::negate<double>());
247 }
248}
void transformVariableFromGlobalVector(GlobalVector const &input_vector, int const variable_id, NumLib::LocalToGlobalIndexMap const &local_to_global_index_map, MeshLib::PropertyVector< double > &output_vector, Functor map_function)
auto & get(Tuples &... ts)
Definition Get.h:53

Referenced by ProcessLib::AssemblyMixin< Process >::assemble(), and ProcessLib::AssemblyMixin< Process >::assembleWithJacobian().

◆ copyResiduumVectorsToSubmesh()

void ProcessLib::AssemblyMixinBase::copyResiduumVectorsToSubmesh ( int const process_id,
GlobalVector const & rhs,
NumLib::LocalToGlobalIndexMap const & local_to_global_index_map,
ProcessLib::Assembly::SubmeshAssemblyData const & sad )
staticprotected

Definition at line 250 of file AssemblyMixin.cpp.

255{
256 auto const& residuum_vectors = sad.residuum_vectors[process_id];
257 for (std::size_t variable_id = 0; variable_id < residuum_vectors.size();
258 ++variable_id)
259 {
261 rhs, variable_id, local_to_global_index_map,
262 residuum_vectors[variable_id].get(),
263 std::span<std::size_t const>{sad.bulk_node_ids},
264 std::negate<double>());
265 }
266}

References ProcessLib::Assembly::SubmeshAssemblyData::bulk_node_ids, and ProcessLib::Assembly::CommonAssemblyData::residuum_vectors.

Referenced by ProcessLib::AssemblyMixin< Process >::assembleOnSubmeshes(), and ProcessLib::AssemblyMixin< Process >::assembleWithJacobianOnSubmeshes().

◆ initializeAssemblyOnSubmeshes()

void ProcessLib::AssemblyMixinBase::initializeAssemblyOnSubmeshes ( MeshLib::Mesh & bulk_mesh,
std::vector< std::reference_wrapper< MeshLib::Mesh > > const & submeshes,
std::vector< std::vector< std::string > > const & residuum_names,
std::vector< std::vector< std::reference_wrapper< ProcessVariable > > > const & pvs )
protected

Definition at line 129 of file AssemblyMixin.cpp.

135{
136 DBUG("AssemblyMixinBase initializeSubmeshOutput().");
137
138 auto const num_submeshes = submeshes.size();
139
140 if (num_submeshes == 0)
141 {
143 createResiduumVectors(bulk_mesh, residuum_names, pvs));
144 return;
145 }
146
147 submesh_assembly_data_.reserve(num_submeshes);
148 for (auto& submesh_ref : submeshes)
149 {
150 auto& submesh = submesh_ref.get();
151
152 submesh_assembly_data_.emplace_back(
153 submesh, createResiduumVectors(submesh, residuum_names, pvs));
154 }
155
156 submesh_matrix_cache_.resize(num_submeshes);
157}
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:22
std::vector< AssembledMatrixCache > submesh_matrix_cache_
AssembledMatrixCache for each submesh.
std::vector< ProcessLib::Assembly::SubmeshAssemblyData > submesh_assembly_data_
SubmeshAssemblyData for each submesh.
std::optional< ProcessLib::Assembly::BulkMeshAssemblyData > bulk_mesh_assembly_data_
Empty if submesh assembly is used.
std::vector< std::vector< std::reference_wrapper< MeshLib::PropertyVector< double > > > > createResiduumVectors(MeshLib::Mesh &mesh, std::vector< std::vector< std::string > > const &per_process_residuum_names, std::vector< std::vector< std::reference_wrapper< ProcessLib::ProcessVariable > > > const &per_process_pvs)

References bulk_mesh_assembly_data_, DBUG(), submesh_assembly_data_, and submesh_matrix_cache_.

Referenced by ProcessLib::AssemblyMixin< Process >::initializeAssemblyOnSubmeshes().

◆ isLinear()

◆ updateActiveElements()

void ProcessLib::AssemblyMixinBase::updateActiveElements ( ProcessLib::Process const & process)
protected

Definition at line 159 of file AssemblyMixin.cpp.

160{
161 DBUG("AssemblyMixin updateActiveElements().");
162
164 {
166 return;
167 }
168
169 ActiveElementIDsState const new_state =
170 process.getActiveElementIDs().empty()
173
176 {
177 // no update necessary
178 return;
179 }
180
181 // updating the active elements is necessary in all remaining cases, because
182 // of the following transitions between old and new states (deactivated
183 // subdomains present? yes/no; old state -> new state):
184 // * no -> yes - now there are deactivated subdomains
185 // * yes -> no - no deactivated subdomains anymore
186 // * yes -> yes - deactivated subdomains might have changed
188}
void updateActiveElementsImpl(Process const &process)
ActiveElementIDsState ids_state_

References DBUG(), ProcessLib::Process::getActiveElementIDs(), HAS_DEACTIVATED_SUBDOMAINS, ids_state_, NO_DEACTIVATED_SUBDOMAINS, UNINITIALIZED, and updateActiveElementsImpl().

Referenced by ProcessLib::AssemblyMixin< Process >::updateActiveElements().

◆ updateActiveElementsImpl()

void ProcessLib::AssemblyMixinBase::updateActiveElementsImpl ( Process const & process)
private

Definition at line 190 of file AssemblyMixin.cpp.

191{
192 DBUG("AssemblyMixinBase updateActiveElementsImpl().");
193
194 auto const& active_element_ids = process.getActiveElementIDs();
195
196 ActiveElementIDsState const new_state =
197 active_element_ids.empty()
200
202 {
203 // no deactivated subdomains, assemble on all elements as specified
204 // in the bulk_element_ids of the submeshes
205 for (auto& sad : submesh_assembly_data_)
206 {
207 sad.setAllElementsActive();
208 }
210 {
211 bulk_mesh_assembly_data_->setAllElementsActive();
212 }
213 }
214 else
215 {
216 auto active_element_ids_copy{active_element_ids};
217 // assemble each submesh on the intersection of the "global" active
218 // elements and the submesh
219 ranges::sort(active_element_ids_copy);
220
221 for (auto& sad : submesh_assembly_data_)
222 {
223 sad.setElementSelectionActive(active_element_ids_copy);
224 }
226 {
227 bulk_mesh_assembly_data_->setElementSelectionActive(
228 active_element_ids_copy);
229 }
230 }
231
232 ids_state_ = new_state;
233}

References bulk_mesh_assembly_data_, DBUG(), ProcessLib::Process::getActiveElementIDs(), HAS_DEACTIVATED_SUBDOMAINS, ids_state_, NO_DEACTIVATED_SUBDOMAINS, and submesh_assembly_data_.

Referenced by updateActiveElements().

Member Data Documentation

◆ bulk_mesh_assembly_data_

◆ bulk_mesh_matrix_cache_

AssembledMatrixCache ProcessLib::AssemblyMixinBase::bulk_mesh_matrix_cache_
protected

◆ ids_state_

ActiveElementIDsState ProcessLib::AssemblyMixinBase::ids_state_ = ActiveElementIDsState::UNINITIALIZED
private

Definition at line 85 of file AssemblyMixin.h.

Referenced by updateActiveElements(), and updateActiveElementsImpl().

◆ is_linear_

bool ProcessLib::AssemblyMixinBase::is_linear_
protected

If the process/problem being simulated is linear, the assembled global matrices and vectors can be cached and reused.

Definition at line 80 of file AssemblyMixin.h.

Referenced by AssemblyMixinBase(), ProcessLib::AssemblyMixin< Process >::assembleOnBulkMeshOrOnSubmeshCommon(), ProcessLib::AssemblyMixin< Process >::assembleWithJacobian(), and isLinear().

◆ last_assembly_was_

◆ pvma_

◆ submesh_assembly_data_

◆ submesh_matrix_cache_

std::vector<AssembledMatrixCache> ProcessLib::AssemblyMixinBase::submesh_matrix_cache_
protected

The documentation for this class was generated from the following files: