/home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/discretization/FEM/assembler/common.hh Source File#

DiFfRG: /home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/discretization/FEM/assembler/common.hh Source File
DiFfRG
Discretization Framework for functional Renormalization Group flows
common.hh
Go to the documentation of this file.
1#pragma once
2
3// external libraries
4#include <deal.II/base/multithread_info.h>
5#include <deal.II/base/quadrature_lib.h>
6#include <deal.II/base/timer.h>
7#include <deal.II/dofs/dof_handler.h>
8#include <deal.II/dofs/dof_tools.h>
9#include <deal.II/fe/fe_interface_values.h>
10#include <deal.II/fe/fe_values.h>
11#include <deal.II/lac/full_matrix.h>
12#include <deal.II/lac/sparse_matrix.h>
13#include <deal.II/lac/vector.h>
14#include <deal.II/meshworker/mesh_loop.h>
15#include <deal.II/numerics/matrix_tools.h>
16#include <deal.II/numerics/vector_tools.h>
17#include <spdlog/spdlog.h>
18#include <tbb/tbb.h>
19
28
29namespace DiFfRG
30{
31 using namespace dealii;
32 using std::array;
33
39 template <typename Discretization_, typename Model_>
40 class FEMAssembler : public AbstractAssembler<typename Discretization_::VectorType,
41 typename Discretization_::SparseMatrixType, Discretization_::dim>
42 {
43 protected:
44 constexpr static int nothing = 0;
45
46 template <typename... T> static constexpr auto v_tie(T &&...t)
47 {
48 return named_tuple<std::tuple<T &...>, StringSet<"variables", "extractors">>(std::tie(t...));
49 }
50
51 template <typename... T> static constexpr auto e_tie(T &&...t)
52 {
53 return named_tuple<std::tuple<T &...>,
54 StringSet<"fe_functions", "fe_derivatives", "fe_hessians", "extractors", "variables",
55 "potential", "potential_gradient", "potential_hessian">>(std::tie(t...));
56 }
57
58 public:
59 using Discretization = Discretization_;
60 using Model = Model_;
61 using NumberType = typename Discretization::NumberType;
62 using VectorType = typename Discretization::VectorType;
63 using SparseMatrixType = typename Discretization::SparseMatrixType;
64
65 using Components = typename Discretization::Components;
66 static constexpr uint dim = Discretization::dim;
69 fe(discretization.get_fe()), dof_handler(discretization.get_dof_handler()),
71 EoM_cell(*(dof_handler.active_cell_iterators().end())),
72 old_EoM_cell(*(dof_handler.active_cell_iterators().end())),
73 old_extractor_cell(*(dof_handler.active_cell_iterators().end())),
74 EoM_config(DiFfRG::internal::resolve_eom_config(dof_handler, Config::EoMConfig(config)))
75 {
76 // reinit() refreshes this, but a derived assembler is not obliged to call it before its
77 // first mesh_loop, and an unset schedule would be a zero queue length.
79 }
80
81 virtual IndexSet get_differential_indices() const override
82 {
83 ComponentMask component_mask(model.template differential_components<dim>());
84 // Restricted to owned rows under the distributed policy: deal.II writes every index of this
85 // set into a distributed vector and compresses with VectorOperation::insert, so an
86 // unrestricted set has every rank inserting into every entry.
87 return restrict_to_owned<VectorType>(DoFTools::extract_dofs(dof_handler, component_mask),
88 discretization.get_locally_owned_dofs());
89 }
90
91 virtual void attach_data_output(OutputFrame<dim, VectorType> &data_out, const VectorType &solution,
92 const VectorType &variables, const VectorType &dt_solution = VectorType(),
93 const VectorType &residual = VectorType()) override
94 {
95 const auto fe_function_names = Components::FEFunction_Descriptor::get_names_vector();
96 std::vector<std::string> fe_function_names_residual;
97 fe_function_names_residual.reserve(fe_function_names.size());
98 for (const auto &name : fe_function_names)
99 fe_function_names_residual.push_back(name + "_residual");
100 std::vector<std::string> fe_function_names_dot;
101 fe_function_names_dot.reserve(fe_function_names.size());
102 for (const auto &name : fe_function_names)
103 fe_function_names_dot.push_back(name + "_dot");
104
105 auto fe_out = data_out.fields();
106 fe_out.attach(dof_handler, solution, fe_function_names);
107 if (dt_solution.size() > 0) fe_out.attach(dof_handler, dt_solution, fe_function_names_dot);
108 if (residual.size() > 0) fe_out.attach(dof_handler, residual, fe_function_names_residual);
109
110 readouts(data_out, solution, variables);
111 }
112
113 const auto &get_discretization() const { return discretization; }
115
116 virtual void reinit() override
117 {
119 const AffineConstraintContext<Components, dim> context(metadata);
120
121 auto &constraints = discretization.get_constraints();
122 constraints.clear();
123 DoFTools::make_hanging_node_constraints(dof_handler, constraints);
124 internal::apply_model_affine_constraints(model, constraints, context);
125 constraints.close();
126
128 }
129
130 virtual void rebuild_jacobian_sparsity() = 0;
131
132 virtual void set_time(double t) override { model.set_time(t); }
133
134 virtual void refinement_indicator(Vector<double> & /*indicator*/, const VectorType & /*solution*/) = 0;
135
136 virtual void residual_variables(VectorType &residual, const VectorType &variables,
137 const VectorType &spatial_solution) override
138 {
139 Timer timer;
140 std::array<NumberType, Components::count_extractors()> __extracted_data{{}};
141 if constexpr (Components::count_extractors() > 0)
142 extract(__extracted_data, spatial_solution, variables, true, false, false);
143 const auto &extracted_data = __extracted_data;
144 model.dt_variables(residual, v_tie(variables, extracted_data));
145 Kokkos::fence();
146 timings_variable_residual.push_back(timer.wall_time());
147 };
148 virtual void jacobian_variables(FullMatrix<NumberType> &jacobian, const VectorType &variables,
149 const VectorType &spatial_solution) override
150 {
151 Timer timer;
152 std::array<NumberType, Components::count_extractors()> __extracted_data{{}};
153 if constexpr (Components::count_extractors() > 0)
154 extract(__extracted_data, spatial_solution, variables, true, false, false);
155 const auto &extracted_data = __extracted_data;
156 model.template jacobian_variables<0>(jacobian, v_tie(variables, extracted_data));
157 Kokkos::fence();
158 timings_variable_jacobian.push_back(timer.wall_time());
159 };
160
162 template <typename PotentialEvaluation = RawPotentialEvaluation<dim, NumberType>> struct PointEvaluation {
163 std::vector<Vector<NumberType>> values{Vector<NumberType>(Components::count_fe_functions())};
164 std::vector<std::vector<Tensor<1, dim, NumberType>>> gradients{
165 std::vector<Tensor<1, dim, NumberType>>(Components::count_fe_functions())};
166 std::vector<std::vector<Tensor<2, dim, NumberType>>> hessians{
167 std::vector<Tensor<2, dim, NumberType>>(Components::count_fe_functions())};
168 PotentialEvaluation potential;
170 std::shared_ptr<FEValues<dim>> fe_values;
171 };
172
174 template <typename RawPotential>
175 auto evaluate_at(const Point<dim> &x, const typename DoFHandler<dim>::cell_iterator &cell,
176 const VectorType &solution_global, const RawPotential &raw_potential) const
177 {
178 PointEvaluation<decltype(evaluate_raw_potential(raw_potential, mapping, x))> evaluation;
179 evaluation.fe_values = std::make_shared<FEValues<dim>>(
180 mapping, fe, mapping.transform_real_to_unit_cell(cell, x),
181 update_values | update_gradients | update_quadrature_points | update_JxW_values | update_hessians);
182 evaluation.fe_values->reinit(cell);
183 evaluation.fe_values->get_function_values(solution_global, evaluation.values);
184 evaluation.fe_values->get_function_gradients(solution_global, evaluation.gradients);
185 evaluation.fe_values->get_function_hessians(solution_global, evaluation.hessians);
186 evaluation.potential = evaluate_raw_potential(raw_potential, mapping, x);
187 return evaluation;
188 }
189
196 auto extractor_raw_potential(const VectorType &solution_global) const
197 {
198 if constexpr (Model::extract_uses_potential)
200 solution_global, dof_handler, mapping,
201 [&](const auto &p, const auto &values) { return model.raw_potential_gradient(p, values); }, EoM_config,
203 else
204 return UnusedPotential{};
205 }
206
207 void readouts(OutputFrame<dim, VectorType> &data_out, const VectorType &solution_global,
208 const VectorType &variables) const
209 {
210 auto raw_potential = reconstruct_raw_potential(
211 solution_global, dof_handler, mapping,
212 [&](const auto &p, const auto &values) { return model.raw_potential_gradient(p, values); }, EoM_config,
214 auto helper = [&](auto &&...args) {
215 if constexpr (sizeof...(args) == 3) {
216 auto &&[id, EoMfun, outputter] = std::forward_as_tuple(std::forward<decltype(args)>(args)...);
217 data_out.register_readout(id);
218 auto EoM_cell = this->EoM_cell;
219 auto EoM_result = get_EoM_point_with_potential(
220 EoM_cell, solution_global, dof_handler, mapping, EoMfun, [&](const auto &p, const auto &) { return p; },
222 if (EoM_result.potential) EoM_minimum_guess = EoM_result.potential->minimum;
223 const auto EoM = EoM_result.point;
224
225 // The readout is always at this readout's EoM. The extractors may not be: a model that
226 // defines extractor_point reads them elsewhere, and dt_variables must see the same values
227 // here as it does during assembly.
228 const auto readout_solution = evaluate_at(EoM, EoM_cell, solution_global, raw_potential);
229 const auto &potential = readout_solution.potential;
230
231 std::array<NumberType, Components::count_extractors()> __extracted_data{{}};
232 if constexpr (Components::count_extractors() > 0) {
233 const auto [x, cell] = resolve_extractor_point(EoM, EoM_cell, solution_global);
234 const auto extractor_solution = evaluate_at(x, cell, solution_global, raw_potential);
235 model.extract(__extracted_data, x,
236 e_tie(extractor_solution.values[0], extractor_solution.gradients[0],
237 extractor_solution.hessians[0], nothing, variables,
238 extractor_solution.potential.value, extractor_solution.potential.gradient,
239 extractor_solution.potential.mass_hessian));
240 }
241 const auto &extracted_data = __extracted_data;
242
243 outputter(data_out, EoM,
244 e_tie(readout_solution.values[0], readout_solution.gradients[0], readout_solution.hessians[0],
245 extracted_data, variables, potential.value, potential.gradient, potential.mass_hessian));
246 data_out.attach_eom_potential(std::move(EoM_result));
247 } else {
248 internal::validate_readout_helper_arity<decltype(args)...>();
249 }
250 };
251 model.readouts_multiple(helper, data_out);
252 data_out.attach_raw_potential(std::move(raw_potential));
253 }
254
261 std::pair<Point<dim>, typename DoFHandler<dim>::cell_iterator>
262 resolve_extractor_point(const Point<dim> &EoM_point, const typename DoFHandler<dim>::cell_iterator &EoM_cell_,
263 [[maybe_unused]] const VectorType &solution_global) const
264 {
266 const auto sample = make_solution_sample(solution_global, dof_handler, mapping);
267 const auto point = model.template extractor_point<dim, NumberType>(EoM_point, sample);
268 if (point == EoM_point) return {EoM_point, EoM_cell_};
269 return {point, GridTools::find_active_cell_around_point(dof_handler, point)};
270 } else
271 return {EoM_point, EoM_cell_};
272 }
273
274 void extract(std::array<NumberType, Components::count_extractors()> &data, const VectorType &solution_global,
275 const VectorType &variables, bool search_EoM, bool set_EoM, bool postprocess) const
276 {
277 auto EoM = this->EoM;
278 auto EoM_cell = this->EoM_cell;
279 if (search_EoM || EoM_cell == *(dof_handler.active_cell_iterators().end())) {
280 auto EoM_result = get_EoM_point_with_potential(
281 EoM_cell, solution_global, dof_handler, mapping,
282 [&](const auto &p, const auto &values) { return model.EoM(p, values); },
283 [&](const auto &p, const auto &values) { return postprocess ? model.EoM_postprocess(p, values) : p; },
285 EoM = EoM_result.point;
286 if (EoM_result.potential) EoM_minimum_guess = EoM_result.potential->minimum;
287 }
288 if (set_EoM) {
289 this->EoM = EoM;
290 this->EoM_cell = EoM_cell;
291 }
292
293 const auto raw_potential = extractor_raw_potential(solution_global);
294
295 const auto [x, cell] = resolve_extractor_point(EoM, EoM_cell, solution_global);
296 const auto e = evaluate_at(x, cell, solution_global, raw_potential);
297 model.extract(data, x,
298 e_tie(e.values[0], e.gradients[0], e.hessians[0], nothing, variables, e.potential.value,
299 e.potential.gradient, e.potential.mass_hessian));
300 }
301
302 bool jacobian_extractors(FullMatrix<NumberType> &extractor_jacobian, const VectorType &solution_global,
303 const VectorType &variables)
304 {
305 if (extractor_jacobian_u.m() != Components::count_extractors() ||
306 extractor_jacobian_u.n() != Components::count_fe_functions())
307 extractor_jacobian_u = FullMatrix<NumberType>(Components::count_extractors(), Components::count_fe_functions());
308 if (extractor_jacobian_du.m() != Components::count_extractors() ||
309 extractor_jacobian_du.n() != Components::count_fe_functions() * dim)
311 FullMatrix<NumberType>(Components::count_extractors(), Components::count_fe_functions() * dim);
312 if (extractor_jacobian_ddu.m() != Components::count_extractors() ||
313 extractor_jacobian_ddu.n() != Components::count_fe_functions() * dim * dim)
315 FullMatrix<NumberType>(Components::count_extractors(), Components::count_fe_functions() * dim * dim);
316
317 auto EoM_result = get_EoM_point_with_potential(
318 EoM_cell, solution_global, dof_handler, mapping,
319 [&](const auto &p, const auto &values) { return model.EoM(p, values); },
320 [&](const auto &p, const auto &values) { return model.EoM_postprocess(p, values); }, EoM_config,
322 EoM = EoM_result.point;
323 if (EoM_result.potential) EoM_minimum_guess = EoM_result.potential->minimum;
324
325 // The extractor jacobian couples to the dofs of the cell the extractors are actually
326 // evaluated in, which is the extractor point's cell, not the EoM's.
327 const auto [x, cell] = resolve_extractor_point(EoM, EoM_cell, solution_global);
328 // Agreed, not rank-local: new_cell gates rebuild_jacobian_sparsity(), which is now
329 // collective (SparsityTools::distribute_sparsity_pattern). A rank that skipped the rebuild
330 // while another performed it would sit out a collective the others are inside, and the run
331 // would hang rather than fail. any_of, not all_of: if ANY rank needs the rebuild, every rank
332 // must enter it. On a replicated mesh the ranks agree anyway -- this makes that a guarantee
333 // rather than a coincidence, and costs one bool reduction per EoM update.
334 bool new_cell = MPI::any_of(discretization.get_communicator(), old_extractor_cell != cell);
336 old_extractor_cell = cell;
337
338 const auto raw_potential = extractor_raw_potential(solution_global);
339 const auto e = evaluate_at(x, cell, solution_global, raw_potential);
340 const auto &fe_v = *e.fe_values;
341 const auto &potential = e.potential;
342
343 const uint n_dofs = fe_v.get_fe().n_dofs_per_cell();
344 if (new_cell) {
345 extractor_dof_indices.resize(n_dofs);
346 cell->get_dof_indices(extractor_dof_indices);
348 }
349
354 e_tie(e.values[0], e.gradients[0], e.hessians[0], nothing, variables,
355 potential.value, potential.gradient, potential.mass_hessian));
357 e_tie(e.values[0], e.gradients[0], e.hessians[0], nothing, variables,
358 potential.value, potential.gradient, potential.mass_hessian));
360 e_tie(e.values[0], e.gradients[0], e.hessians[0], nothing, variables,
361 potential.value, potential.gradient, potential.mass_hessian));
362
363 if (extractor_jacobian.m() != Components::count_extractors() || extractor_jacobian.n() != n_dofs)
364 extractor_jacobian = FullMatrix<NumberType>(Components::count_extractors(), n_dofs);
365
366 for (uint e = 0; e < Components::count_extractors(); ++e)
367 for (uint i = 0; i < n_dofs; ++i) {
368 const auto component_i = fe_v.get_fe().system_to_component_index(i).first;
369 extractor_jacobian(e, i) =
370 extractor_jacobian_u(e, component_i) * fe_v.shape_value_component(i, 0, component_i);
371 for (uint d1 = 0; d1 < dim; ++d1) {
372 extractor_jacobian(e, i) +=
373 extractor_jacobian_du(e, component_i * dim + d1) * fe_v.shape_grad_component(i, 0, component_i)[d1];
374 for (uint d2 = 0; d2 < dim; ++d2)
375 extractor_jacobian(e, i) += extractor_jacobian_ddu(e, component_i * dim * dim + d1 * dim + d2) *
376 fe_v.shape_hessian_component(i, 0, component_i)[d1][d2];
377 }
378 }
379
380 return new_cell;
381 }
382
384 {
385 double t = 0.;
386 double n = timings_variable_residual.size();
387 for (const auto &t_ : timings_variable_residual)
388 t += t_ / n;
389 return t;
390 }
392
394 {
395 double t = 0.;
396 double n = timings_variable_jacobian.size();
397 for (const auto &t_ : timings_variable_jacobian)
398 t += t_ / n;
399 return t;
400 }
402
403 protected:
407 const FiniteElement<dim> &fe;
408 const DoFHandler<dim> &dof_handler;
409 const Mapping<dim> &mapping;
410
418 AssemblySchedule schedule_for(const double cost_ns) const
419 {
422 }
423
431 {
433 const bool unchanged = n_owned == n_owned_cells;
434 n_owned_cells = n_owned;
435 if (unchanged) return;
436
437 const uint threads = DiFfRG::n_threads();
438 const auto cheap = schedule_for(assembly_cost::local_fe);
439 const auto integral = schedule_for(assembly_cost::momentum_integral);
440 report_port.info("FEM: Assembling {} cells on {} threads -- {}x{} workers/cells for a cheap cell loop, "
441 "{}x{} for an integral one.",
442 n_owned_cells, threads, cheap.queue_length, cheap.chunk_size, integral.queue_length,
443 integral.chunk_size);
444 }
445
449
450 mutable typename DoFHandler<dim>::cell_iterator EoM_cell;
451 typename DoFHandler<dim>::cell_iterator old_EoM_cell;
453 mutable Point<dim> EoM;
454 mutable std::optional<Point<dim>> EoM_minimum_guess;
458 typename DoFHandler<dim>::cell_iterator old_extractor_cell;
459 FullMatrix<NumberType> extractor_jacobian;
460 FullMatrix<NumberType> extractor_jacobian_u;
461 FullMatrix<NumberType> extractor_jacobian_du;
462 FullMatrix<NumberType> extractor_jacobian_ddu;
463 std::vector<types::global_dof_index> extractor_dof_indices;
464
465 std::vector<double> timings_variable_residual;
466 std::vector<double> timings_variable_jacobian;
467 };
468} // namespace DiFfRG
This is the general assembler interface for any kind of discretization. An assembler is responsible f...
Definition abstract_assembler.hh:54
void jacobian(SparseMatrixType &jacobian, const VectorType &solution_global, NumberType weight, NumberType mass_weight, const VectorType &variables=VectorType())
Definition abstract_assembler.hh:298
void residual(VectorType &residual, const VectorType &solution_global, NumberType weight, NumberType weight_mass, const VectorType &variables=VectorType())
Definition abstract_assembler.hh:224
Definition affine_constraint_metadata.hh:24
A hierarchical configuration tree, readable from JSON and TOML files.
Definition config_tree.hh:32
The basic assembler that can be used for any standard CG scheme with flux and source.
Definition common.hh:42
uint num_variable_jacobians() const
Definition common.hh:401
Model & model
Definition common.hh:405
const auto & get_discretization() const
Definition common.hh:113
typename Discretization::NumberType NumberType
Definition common.hh:61
const Mapping< dim > & mapping
Definition common.hh:409
static constexpr auto v_tie(T &&...t)
Definition common.hh:46
virtual void residual_variables(VectorType &residual, const VectorType &variables, const VectorType &spatial_solution) override
Definition common.hh:136
double average_time_variable_jacobian_assembly()
Definition common.hh:393
uint num_variable_residuals() const
Definition common.hh:391
FullMatrix< NumberType > extractor_jacobian
Definition common.hh:459
virtual void set_time(double t) override
Set the current time. The assembler should usually just forward this to the numerical model.
Definition common.hh:132
double average_time_variable_residual_assembly()
Definition common.hh:383
static constexpr uint dim
Definition common.hh:66
void update_assembly_schedules()
Re-count the cells the schedules are sized from.
Definition common.hh:430
const FiniteElement< dim > & fe
Definition common.hh:407
uint n_owned_cells
Cells this rank assembles. Refreshed in reinit(); the per-loop schedules are sized from it.
Definition common.hh:447
void extract(std::array< NumberType, Components::count_extractors()> &data, const VectorType &solution_global, const VectorType &variables, bool search_EoM, bool set_EoM, bool postprocess) const
Definition common.hh:274
typename Discretization::Components Components
Definition common.hh:65
bool jacobian_extractors(FullMatrix< NumberType > &extractor_jacobian, const VectorType &solution_global, const VectorType &variables)
Definition common.hh:302
FullMatrix< NumberType > extractor_jacobian_du
Definition common.hh:461
typename Discretization::SparseMatrixType SparseMatrixType
Definition common.hh:63
DoFHandler< dim >::cell_iterator EoM_cell
Definition common.hh:450
virtual void refinement_indicator(Vector< double > &, const VectorType &)=0
void readouts(OutputFrame< dim, VectorType > &data_out, const VectorType &solution_global, const VectorType &variables) const
Definition common.hh:207
auto evaluate_at(const Point< dim > &x, const typename DoFHandler< dim >::cell_iterator &cell, const VectorType &solution_global, const RawPotential &raw_potential) const
Evaluate the FE solution and the raw potential at x, which lies in cell.
Definition common.hh:175
Point< dim > EoM
Definition common.hh:453
virtual void jacobian_variables(FullMatrix< NumberType > &jacobian, const VectorType &variables, const VectorType &spatial_solution) override
Definition common.hh:148
FullMatrix< NumberType > extractor_jacobian_ddu
Definition common.hh:462
Model_ Model
Definition common.hh:60
DiFfRG::internal::PotentialSystemCache< dim, NumberType > potential_cache
Mesh-dependent half of the potential reconstructions, built once and reused; see PotentialSystemCache...
Definition common.hh:456
std::vector< double > timings_variable_jacobian
Definition common.hh:466
DoFHandler< dim >::cell_iterator old_EoM_cell
Definition common.hh:451
auto extractor_raw_potential(const VectorType &solution_global) const
The raw potential for the extractors, or an inert placeholder if the model does not read it.
Definition common.hh:196
std::vector< double > timings_variable_residual
Definition common.hh:465
const AssemblyScheduleOverrides schedule_overrides
Definition common.hh:448
std::optional< Point< dim > > EoM_minimum_guess
Definition common.hh:454
auto & get_discretization()
Definition common.hh:114
virtual void reinit() override
Reinitialize the assembler. This is necessary if the mesh has changed, e.g. after a mesh refinement.
Definition common.hh:116
const DoFHandler< dim > & dof_handler
Definition common.hh:408
typename Discretization::VectorType VectorType
Definition common.hh:62
FEMAssembler(Discretization &discretization, Model &model, const ConfigTree &config)
Definition common.hh:67
Discretization & discretization
Definition common.hh:404
std::pair< Point< dim >, typename DoFHandler< dim >::cell_iterator > resolve_extractor_point(const Point< dim > &EoM_point, const typename DoFHandler< dim >::cell_iterator &EoM_cell_, const VectorType &solution_global) const
Where the model wants its extractors evaluated, and the cell holding that point.
Definition common.hh:262
const Config::EoMConfig EoM_config
Definition common.hh:452
DoFHandler< dim >::cell_iterator old_extractor_cell
Where the extractors are evaluated. Equal to EoM unless the model defines extractor_point.
Definition common.hh:458
virtual IndexSet get_differential_indices() const override
Obtain the dofs which contain time derivatives.
Definition common.hh:81
static constexpr auto e_tie(T &&...t)
Definition common.hh:51
std::vector< types::global_dof_index > extractor_dof_indices
Definition common.hh:463
virtual void attach_data_output(OutputFrame< dim, VectorType > &data_out, const VectorType &solution, const VectorType &variables, const VectorType &dt_solution=VectorType(), const VectorType &residual=VectorType()) override
Definition common.hh:91
virtual void rebuild_jacobian_sparsity()=0
FullMatrix< NumberType > extractor_jacobian_u
Definition common.hh:460
AssemblySchedule schedule_for(const double cost_ns) const
The mesh_loop schedule for a loop whose cell worker costs cost_ns nanoseconds.
Definition common.hh:418
static constexpr int nothing
Definition common.hh:44
Discretization_ Discretization
Definition common.hh:59
ReportPort report_port
Definition common.hh:406
void attach(const DoFHandler< dim > &dof_handler, const VectorType &solution, const std::string &name)
Definition output_session.hh:47
Definition output_session.hh:42
void attach_raw_potential(ReconstructedRawPotential< dim, typename VectorType::value_type > potential)
Definition output_session.hh:141
FieldCollector fields()
Definition output_session.hh:92
void register_readout(const std::string &id)
Definition output_session.hh:154
void attach_eom_potential(EoMResult< dim, typename VectorType::value_type > result)
Definition output_session.hh:136
Definition run_reporter.hh:96
void info(spdlog::format_string_t< Args... > format, Args &&...args) const
Definition run_reporter.hh:103
The mesh-dependent half of solve_potential, retained across calls.
Definition eom.hh:315
Whether Model chooses its own point at which the extractors are evaluated.
Definition solution_sample.hh:137
bool any_of(MPI_Comm comm, bool value)
Collective agreement on a predicate. Used to turn a rank-local decision (an abort,...
constexpr double local_fe
Local FE work only: mass matrices, refinement indicators. ~0.2-0.3 us/cell for CG p=3.
Definition assembly_schedule.hh:48
constexpr double momentum_integral
Definition assembly_schedule.hh:53
AffineConstraintMetadata< dim > build_affine_constraint_metadata(const Discretization &discretization)
Definition affine_constraint_metadata.hh:99
void apply_model_affine_constraints(Model &model, Constraints &constraints, const Context &context)
Definition affine_constraint_metadata.hh:79
constexpr void validate_readout_helper_arity()
Definition abstract_assembler.hh:17
Definition complex_math.hh:10
ReconstructedRawPotential< dim, typename VectorType::value_type > reconstruct_raw_potential(const VectorType &sol, const dealii::DoFHandler< dim > &dof_handler, const dealii::Mapping< dim > &mapping, const GradientFUN &get_gradient, const Config::EoMConfig &config, internal::PotentialSystemCache< dim, typename VectorType::value_type > *cache=nullptr)
Reconstruct a scalar raw potential without locating its minimum.
Definition eom.hh:1411
AssemblySchedule make_assembly_schedule(const uint n_local_cells, const uint thread_budget, const double cost_ns, const AssemblyScheduleOverrides &overrides={})
Derive one mesh_loop schedule from the cost of a cell.
Definition assembly_schedule.hh:114
uint n_locally_owned_cells(const Discretization &discretization)
How many cells locally_owned_cells() yields.
Definition assembly_schedule.hh:167
dealii::IndexSet restrict_to_owned(const dealii::IndexSet &global_set, const dealii::IndexSet &locally_owned)
Restrict a global index set to what this rank may write.
Definition la_policy.hh:114
@ config
/discretization/threads.
unsigned int n_threads()
The CPU thread budget this process resolved.
UnusedPotentialEvaluation evaluate_raw_potential(const UnusedPotential &, const dealii::Mapping< dim > &, const dealii::Point< dim > &)
Definition eom.hh:149
unsigned int uint
Definition utils.hh:24
EoMResult< dim, typename VectorType::value_type > get_EoM_point_with_potential(typename dealii::DoFHandler< dim >::cell_iterator &EoM_cell, const VectorType &sol, const dealii::DoFHandler< dim > &dof_handler, const dealii::Mapping< dim > &mapping, const EoMFUN &get_EoM, const EoMPFUN &EoM_postprocess, const Config::EoMConfig &config, const std::optional< dealii::Point< dim > > &initial_guess=std::nullopt, internal::PotentialSystemCache< dim, typename VectorType::value_type > *cache=nullptr)
Reconstruct a potential whose gradient approximates the model EoM vector field and return a sampled a...
Definition eom.hh:1486
SolutionSample< dim, NumberType > make_solution_sample(const dealii::DoFHandler< dim > &dof_handler, const dealii::Mapping< dim > &mapping, const uint n_components, const FillFUN &fill)
Build a SolutionSample, taking values and gradients from a callback.
Definition solution_sample.hh:154
Overrides, if really wanted by the user: /discretization/{mesh_workers,batch_size}...
Definition assembly_schedule.hh:82
The two trailing arguments of dealii::MeshWorker::mesh_loop.
Definition assembly_schedule.hh:30
Definition eom_config.hh:10
The FE solution and the reconstructed raw potential at one point.
Definition common.hh:162
std::vector< std::vector< Tensor< 1, dim, NumberType > > > gradients
Definition common.hh:164
PotentialEvaluation potential
Definition common.hh:168
std::shared_ptr< FEValues< dim > > fe_values
Kept for the shape values the extractor jacobian needs.
Definition common.hh:170
std::vector< Vector< NumberType > > values
Definition common.hh:163
std::vector< std::vector< Tensor< 2, dim, NumberType > > > hessians
Definition common.hh:166
Definition tuples.hh:34
Stand-in for a raw potential that a model has declared it does not read.
Definition eom.hh:140
A class to store a tuple with elements that can be accessed by name. The names are stored as FixedStr...
Definition tuples.hh:56