forked from geodynamics/aspect
-
Notifications
You must be signed in to change notification settings - Fork 3
/
simulator.h
1453 lines (1282 loc) · 57.8 KB
/
simulator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Copyright (C) 2011 - 2016 by the authors of the ASPECT code.
This file is part of ASPECT.
ASPECT is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
ASPECT is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ASPECT; see the file doc/COPYING. If not see
<http://www.gnu.org/licenses/>.
*/
#ifndef __aspect__simulator_h
#define __aspect__simulator_h
#include <deal.II/base/timer.h>
#include <deal.II/base/parameter_handler.h>
#include <deal.II/base/conditional_ostream.h>
#include <deal.II/base/symmetric_tensor.h>
#include <deal.II/lac/trilinos_block_vector.h>
#include <deal.II/lac/trilinos_block_sparse_matrix.h>
#include <deal.II/lac/trilinos_precondition.h>
#include <deal.II/distributed/tria.h>
#include <deal.II/dofs/dof_handler.h>
#include <deal.II/fe/fe_system.h>
#include <deal.II/fe/mapping_q.h>
#include <deal.II/base/tensor_function.h>
#include <aspect/global.h>
#include <aspect/simulator_access.h>
#include <aspect/lateral_averaging.h>
#include <aspect/simulator_signals.h>
#include <aspect/material_model/interface.h>
#include <aspect/heating_model/interface.h>
#include <aspect/geometry_model/interface.h>
#include <aspect/gravity_model/interface.h>
#include <aspect/boundary_temperature/interface.h>
#include <aspect/boundary_composition/interface.h>
#include <aspect/initial_conditions/interface.h>
#include <aspect/compositional_initial_conditions/interface.h>
#include <aspect/prescribed_stokes_solution/interface.h>
#include <aspect/velocity_boundary_conditions/interface.h>
#include <aspect/traction_boundary_conditions/interface.h>
#include <aspect/mesh_refinement/interface.h>
#include <aspect/termination_criteria/interface.h>
#include <aspect/postprocess/interface.h>
#include <aspect/adiabatic_conditions/interface.h>
#include <boost/iostreams/tee.hpp>
#include <boost/iostreams/stream.hpp>
#include <deal.II/base/std_cxx11/shared_ptr.h>
namespace aspect
{
using namespace dealii;
namespace internal
{
namespace Assembly
{
namespace Scratch
{
template <int dim> struct StokesPreconditioner;
template <int dim> struct StokesSystem;
template <int dim> struct AdvectionSystem;
}
namespace CopyData
{
template <int dim> struct StokesPreconditioner;
template <int dim> struct StokesSystem;
template <int dim> struct AdvectionSystem;
}
namespace Assemblers
{
template <int dim> class AssemblerBase;
}
template <int dim> struct AssemblerLists;
}
}
/**
* This is the main class of ASPECT. It implements the overall simulation
* algorithm using the numerical methods discussed in the papers and manuals
* that accompany ASPECT.
*
* @ingroup Simulator
*/
template <int dim>
class Simulator
{
public:
/**
* Constructor.
*
* @param mpi_communicator The MPI communicator on which this class is
* to work. The class creates a clone of the actual communicator to make
* its communications private from the rest of the world.
*
* @param prm The run-time parameter object from which this class
* obtains its settings.
*
* This function is implemented in
* <code>source/simulator/core.cc</code>.
*/
Simulator (const MPI_Comm mpi_communicator,
ParameterHandler &prm);
/**
* Destructor. Destroy what needs to be destroyed after waiting for all
* threads that may still be doing something in the background.
*/
~Simulator ();
/**
* Declare the run-time parameters this class takes, and call the
* respective <code>declare_parameters</code> functions of the
* namespaces that describe geometries, material models, etc.
*
* @param prm The object in which the run-time parameters are to be
* declared.
*
* This function is implemented in
* <code>source/simulator/parameters.cc</code>.
*/
static
void declare_parameters (ParameterHandler &prm);
/**
* The function that runs the overall algorithm. It contains the loop
* over all time steps as well as the logic of what to do when before
* the loop starts and within the time loop.
*
* This function is implemented in
* <code>source/simulator/core.cc</code>.
*/
void run ();
/**
* Import Nonlinear Solver type.
*/
typedef typename Parameters<dim>::NonlinearSolver NonlinearSolver;
/**
* Import nullspace removal type.
*/
typedef typename Parameters<dim>::NullspaceRemoval NullspaceRemoval;
private:
/**
* A structure that is used as an argument to functions that can work on
* both the temperature and the compositional variables and that need to
* be told which one of the two, as well as on which of the
* compositional variables.
*/
struct AdvectionField
{
/**
* An enum indicating whether the identified variable is the
* temperature or one of the compositional fields.
*/
enum FieldType { temperature_field, compositional_field };
/**
* A variable indicating whether the identified variable is the
* temperature or one of the compositional fields.
*/
const FieldType field_type;
/**
* A variable identifying which of the compositional fields is
* selected. This variable is meaningless if the temperature is
* selected.
*/
const unsigned int compositional_variable;
/**
* Constructor.
* @param field_type Determines whether this variable should select
* the temperature field or a compositional field.
* @param compositional_variable The number of the compositional field
* if the first argument in fact chooses a compositional variable.
* Meaningless if the first argument equals temperature.
*
* This function is implemented in
* <code>source/simulator/helper_functions.cc</code>.
*/
AdvectionField (const FieldType field_type,
const unsigned int compositional_variable = numbers::invalid_unsigned_int);
/**
* A static function that creates an object identifying the
* temperature.
*
* This function is implemented in
* <code>source/simulator/helper_functions.cc</code>.
*/
static
AdvectionField temperature ();
/**
* A static function that creates an object identifying given
* compositional field.
*
* This function is implemented in
* <code>source/simulator/helper_functions.cc</code>.
*/
static
AdvectionField composition (const unsigned int compositional_variable);
/**
* Return whether this object refers to the temperature field.
*/
bool
is_temperature () const;
/**
* Look up the component index for this temperature or compositional
* field. See Introspection::component_indices for more information.
*/
unsigned int component_index(const Introspection<dim> &introspection) const;
/**
* Look up the block index for this temperature or compositional
* field. See Introspection::block_indices for more information.
*/
unsigned int block_index(const Introspection<dim> &introspection) const;
/**
* Look up the base element within the larger composite finite element
* we used for everything, for this temperature or compositional field
* See Introspection::base_elements for more information.
*/
unsigned int base_element(const Introspection<dim> &introspection) const;
};
/**
* A class that is empty but that can be used as a member variable and
* whose constructor will be run in the order in which the member
* variables are initialized. Because this class has a constructor that
* takes a function object that it will execute whenever the member
* variable is initialized, this allows running arbitrary actions in
* between member variable initializers, for example if some member
* variable is partially initialized at point A within the member
* variable initializer list, its initialization can only be finalized
* after point B (because it depends on what another member variable
* decides to do), but needs to be finished by point C within the member
* initialization. In such a case, one may have a member variable of the
* current time placed in the list of member variables such that it is
* initialized at point B, and then initialize it using a function
* object that performs the finalization of initialization.
*/
struct IntermediaryConstructorAction
{
IntermediaryConstructorAction (std_cxx11::function<void ()> action);
};
/**
* @name Top-level functions in the overall flow of the numerical
* algorithm
* @{
*/
/**
* The function that sets up the DoFHandler objects, It also sets up the
* various partitioners and computes those constraints on the Stokes
* variable and temperature that are the same between all time steps.
*
* This function is implemented in
* <code>source/simulator/core.cc</code>.
*/
void setup_dofs ();
/**
* This function initializes the variables of the introspection object.
* It is called by setup_dofs() right after distributing degrees of
* freedom since this is when all of the information is available.
*
* This function is implemented in
* <code>source/simulator/core.cc</code>.
*/
void setup_introspection ();
/**
* A function that is responsible for initializing the
* temperature/compositional field before the first time step. The
* temperature field then serves as the temperature from which the
* velocity is computed during the first time step, and is subsequently
* overwritten by the temperature field one gets by advancing by one
* time step.
*
* This function is implemented in
* <code>source/simulator/initial_conditions.cc</code>.
*/
void set_initial_temperature_and_compositional_fields ();
/**
* A function that is responsible for initializing the
* tracers and their properties before the first time step. We want this
* to happen before the first timestep in case other properties depend
* on them, but it can only happen after the other initial conditions
* have been set up, because tracer properties likely depend on the
* initial conditions. If the tracer postprocessor has not been selected
* this function simply does nothing.
*
* This function is implemented in
* <code>source/simulator/initial_conditions.cc</code>.
*/
void initialize_tracers ();
/**
* A function that initializes the pressure variable before the first
* time step. It does so by either interpolating (for continuous
* pressure finite elements) or projecting (for discontinuous elements)
* the adiabatic pressure computed from the material model.
*
* Note that the pressure so set is overwritten by the pressure in fact
* computed during the first time step. We need this function, however,
* so that the evaluation of pressure-dependent coefficients (e.g.
* pressure dependent densities or thermal coefficients) during the
* first time step has some useful pressure to start with.
*
* This function is implemented in
* <code>source/simulator/initial_conditions.cc</code>.
*/
void compute_initial_pressure_field ();
/**
* Given the 'constraints' member that contains all constraints that are
* independent of the time (e.g., hanging node constraints, tangential
* flow constraints, etc), copy it over to 'current_constraints' and add
* to the latter all constraints that do depend on time such as
* temperature or velocity Dirichlet boundary conditions. This function
* is therefore called at the beginning of every time step in
* start_timestep(), but also when setting up the initial values.
*
* This function is implemented in
* <code>source/simulator/core.cc</code>.
*/
void compute_current_constraints ();
/**
* Do some housekeeping at the beginning of each time step. This
* includes generating some screen output, adding some information to
* the statistics file, and interpolating time-dependent boundary
* conditions specific to this particular time step (the time
* independent boundary conditions, for example for hanging nodes or for
* tangential flow, are computed only once per mesh in setup_dofs()).
*
* This function is implemented in
* <code>source/simulator/core.cc</code>.
*/
void start_timestep ();
/**
* Do the various steps necessary to assemble and solve the things
* necessary in each time step.
*
* This function is implemented in
* <code>source/simulator/core.cc</code>.
*/
void solve_timestep ();
/**
* Initiate the assembly of the Stokes preconditioner matrix via
* assemble_stokes_preconditoner(), then set up the data structures to
* actually build a preconditioner from this matrix.
*
* This function is implemented in
* <code>source/simulator/assembly.cc</code>.
*/
void build_stokes_preconditioner ();
/**
* Initialize the preconditioner for the advection equation of field
* index.
*
* This function is implemented in
* <code>source/simulator/assembly.cc</code>.
*/
void build_advection_preconditioner (const AdvectionField &advection_field,
std_cxx11::shared_ptr<aspect::LinearAlgebra::PreconditionILU> &preconditioner);
/**
* Initiate the assembly of the Stokes matrix and right hand side.
*
* This function is implemented in
* <code>source/simulator/assembly.cc</code>.
*/
void assemble_stokes_system ();
/**
* Initiate the assembly of one advection matrix and right hand side and
* build a preconditioner for the matrix.
*
* This function is implemented in
* <code>source/simulator/assembly.cc</code>.
*/
void assemble_advection_system (const AdvectionField &advection_field);
/**
* Solve one block of the the temperature/composition linear system.
* Return the initial nonlinear residual, i.e., if the linear system to
* be solved is $Ax=b$, then return $\|Ax_0-b\|$ where $x_0$ is the
* initial guess for the solution variable and is taken from the
* current_linearization_point member variable.
*
* This function is implemented in
* <code>source/simulator/solver.cc</code>.
*/
double solve_advection (const AdvectionField &advection_field);
/**
* Solve the Stokes linear system. Return the initial nonlinear
* residual, i.e., if the linear system to be solved is $Ax=b$, then
* return $\|Ax_0-b\|$ where $x_0$ is the initial guess for the solution
* variable and is taken from the current_linearization_point member
* variable. For the purpose of this function, this residual is computed
* only the velocity and pressure equations (i.e., for the 2x2 block
* system involving the velocity and pressure variables).
*
* This function is implemented in
* <code>source/simulator/solver.cc</code>.
*/
double solve_stokes ();
/**
* This function is called at the end of every time step. It runs all
* the postprocessors that have been listed in the input parameter file
* (see the manual) in turn. In particular, this usually includes
* generating graphical output every few time steps.
*
* The function also updates the statistics output file at the end of
* each time step.
*
* This function is implemented in
* <code>source/simulator/core.cc</code>.
*/
void postprocess ();
/**
* Refine the mesh according to error indicators calculated by
* compute_refinement_criterion(), set up all necessary data structures
* on this new mesh, and interpolate the old solutions onto the new
* mesh.
*
* @param[in] max_grid_level The maximum refinement level of the mesh.
* This is the sum of the initial global refinement and the initial
* adaptive refinement (as provided by the user in the input file) and
* in addition it gets increased by one at each additional refinement
* time.
*
* This function is implemented in
* <code>source/simulator/core.cc</code>.
*/
void refine_mesh (const unsigned int max_grid_level);
/**
* @}
*/
/**
* @name Functions used in saving the state of the program and
* restarting from a saved state
* @{
*/
/**
* Save the state of this program to a set of files in the output
* directory. In reality, however, only some variables are stored (in
* particular the mesh, the solution vectors, etc) whereas others can
* either be re-generated (matrices, DoFHandler objects, etc) or are
* read from the input parameter file. See the manual for more
* information.
*
* This function is implemented in
* <code>source/simulator/checkpoint_restart.cc</code>.
*/
void create_snapshot();
/**
* Restore the state of this program from a set of files in the output
* directory. In reality, however, only some variables are stored (in
* particular the mesh, the solution vectors, etc) whereas others can
* either be re-generated (matrices, DoFHandler objects, etc) or are
* read from the input parameter file. See the manual for more
* information. This function only restores those variables that can
* neither be re-generated from other information nor are read from the
* input parameter file.
*
* This function is implemented in
* <code>source/simulator/checkpoint_restart.cc</code>.
*/
void resume_from_snapshot();
/**
* Save a number of variables using BOOST serialization mechanism.
*
* This function is implemented in
* <code>source/simulator/checkpoint_restart.cc</code>.
*/
template <class Archive>
void serialize (Archive &ar, const unsigned int version);
/**
* @}
*/
/**
* @name Functions used in setting up linear systems
* @{
*/
/**
* Set up the size and structure of the matrix used to store the
* elements of the linear system.
*
* This function is implemented in
* <code>source/simulator/core.cc</code>.
*/
void setup_system_matrix (const std::vector<IndexSet> &system_partitioning);
/**
* Set up the size and structure of the matrix used to store the
* elements of the matrix that is used to build the preconditioner for
* the system.
*
* This function is implemented in
* <code>source/simulator/core.cc</code>.
*/
void setup_system_preconditioner (const std::vector<IndexSet> &system_partitioning);
/**
* @}
*/
/**
* @name Functions, classes, and variables used in the assembly of linear systems
* @{
*/
/**
* A member variable that stores, for the current simulation, what
* functions need to be called in order to assemble linear systems,
* matrices, and right hand side vectors.
*
* One would probably want this variable to just be a member of type
* internal::Assembly::AssemblerLists<dim>, but this requires that
* this type is declared in the current scope, and that would require
* including <assembly.h> which we don't want because it's big.
* Consequently, we just store a pointer to such an object, and create
* the object pointed to at the top of set_assemblers().
*/
std_cxx11::unique_ptr<internal::Assembly::AssemblerLists<dim> > assemblers;
/**
* A collection of objects that implement member functions that may
* appear in the assembler signal lists. What the objects do is not
* actually important, but individual assembler objects may encapsulate
* data that is used by concrete assemblers.
*
* The objects pointed to by this vector are created in
* set_assemblers(), and are later destroyed by the destructor
* of the current class.
*/
std::vector<std_cxx11::shared_ptr<internal::Assembly::Assemblers::AssemblerBase<dim> > > assembler_objects;
/**
* Will call create_additional_material_model_outputs() functions from
* each object in assembler_objects.
*/
void create_additional_material_model_outputs(MaterialModel::MaterialModelOutputs<dim> &);
/**
* Determine, based on the run-time parameters of the current simulation,
* which functions need to be called in order to assemble linear systems,
* matrices, and right hand side vectors.
*
* This function is implemented in
* <code>source/simulator/assembly.cc</code>.
*/
void set_assemblers ();
/**
* Initiate the assembly of the preconditioner for the Stokes system.
*
* This function is implemented in
* <code>source/simulator/assembly.cc</code>.
*/
void assemble_stokes_preconditioner ();
/**
* Compute the integrals for the preconditioner for the Stokes system on
* a single cell.
*
* This function is implemented in
* <code>source/simulator/assembly.cc</code>.
*/
void
local_assemble_stokes_preconditioner (const typename DoFHandler<dim>::active_cell_iterator &cell,
internal::Assembly::Scratch::StokesPreconditioner<dim> &scratch,
internal::Assembly::CopyData::StokesPreconditioner<dim> &data);
/**
* Copy the contribution to the preconditioner for the Stokes system
* from a single cell into the global matrix that stores these elements.
*
* This function is implemented in
* <code>source/simulator/assembly.cc</code>.
*/
void
copy_local_to_global_stokes_preconditioner (const internal::Assembly::CopyData::StokesPreconditioner<dim> &data);
/**
* Compute the integrals for the Stokes matrix and right hand side on a
* single cell.
*
* This function is implemented in
* <code>source/simulator/assembly.cc</code>.
*/
void
local_assemble_stokes_system (const typename DoFHandler<dim>::active_cell_iterator &cell,
internal::Assembly::Scratch::StokesSystem<dim> &scratch,
internal::Assembly::CopyData::StokesSystem<dim> &data);
/**
* Copy the contribution to the Stokes system from a single cell into
* the global matrix that stores these elements.
*
* This function is implemented in
* <code>source/simulator/assembly.cc</code>.
*/
void
copy_local_to_global_stokes_system (const internal::Assembly::CopyData::StokesSystem<dim> &data);
/**
* Compute the integrals for one advection matrix and right hand side on
* a single cell.
*
* This function is implemented in
* <code>source/simulator/assembly.cc</code>.
*/
void
local_assemble_advection_system (const AdvectionField &advection_field,
const Vector<double> &viscosity_per_cell,
const typename DoFHandler<dim>::active_cell_iterator &cell,
internal::Assembly::Scratch::AdvectionSystem<dim> &scratch,
internal::Assembly::CopyData::AdvectionSystem<dim> &data);
/**
* Copy the contribution to the advection system from a single cell into
* the global matrix that stores these elements.
*
* This function is implemented in
* <code>source/simulator/assembly.cc</code>.
*/
void
copy_local_to_global_advection_system (const internal::Assembly::CopyData::AdvectionSystem<dim> &data);
/**
* @}
*/
/**
* @name Helper functions
* @{
*/
/**
* This routine adjusts the second block of the right hand side of a
* Stokes system (containing the term that comes from compressibility,
* so that the system becomes compatible: $0=\int div u = \int g$. The
* vector to adjust is given as the argument of this function. This
* function makes use of the helper vector
* pressure_shape_function_integrals that contains $h_i=(q_i,1)$ with
* the pressure functions $q_i$ and we adjust the right hand side $g$ by
* $h_i \int g / |\Omega|$.
*
* The purpose of this function is described in the second paper on the
* numerical methods in Aspect.
*
* This function is implemented in
* <code>source/simulator/helper_functions.cc</code>.
*/
void make_pressure_rhs_compatible(LinearAlgebra::BlockVector &vector);
/**
* Fills a vector with the artificial viscosity for the temperature or
* composition on each local cell.
* @param viscosity_per_cell Output vector
* @param advection_field Determines whether this variable should select
* the temperature field or a compositional field.
*/
template <typename T>
void get_artificial_viscosity (Vector<T> &viscosity_per_cell,
const AdvectionField &advection_field) const;
/**
* Compute the seismic shear wave speed, Vs anomaly per element. we
* compute the anomaly by computing a smoothed (over 200 km or so)
* laterally averaged temperature profile and associated seismic
* velocity that is then subtracted from the seismic velocity at the
* current pressure temperature conditions
*
* @param values The output vector of depth averaged values. The
* function takes the pre-existing size of this vector as the number of
* depth slices.
*/
void compute_Vs_anomaly(Vector<float> &values) const;
/**
* Compute the seismic pressure wave speed, Vp anomaly per element. we
* compute the anomaly by computing a smoothed (over 200 km or so)
* laterally averaged temperature profile and associated seismic
* velocity that is then subtracted from the seismic velocity at the
* current pressure temperature conditions
*
* This function is implemented in
* <code>source/simulator/helper_functions.cc</code>.
*
* @param values The output vector of depth averaged values. The
* function takes the pre-existing size of this vector as the number of
* depth slices.
*/
void compute_Vp_anomaly(Vector<float> &values) const;
/**
* Adjust the pressure variable (which is only determined up to a
* constant) by adding a constant to it in such a way that the pressure
* on the surface has a known average value. Whether a face is part of
* the surface is determined by asking whether its depth of its midpoint
* (as determined by the geometry model) is less than
* 1/3*1/sqrt(dim-1)*diameter of the face. For reasonably curved
* boundaries, this rules out side faces that are perpendicular ot the
* surface boundary but includes those faces that are along the boundary
* even if the real boundary is curved.
*
* This function is implemented in
* <code>source/simulator/helper_functions.cc</code>.
*/
void normalize_pressure(LinearAlgebra::BlockVector &vector);
/**
* Invert the action of the function above.
*
* This function is implemented in
* <code>source/simulator/helper_functions.cc</code>.
*/
void denormalize_pressure(LinearAlgebra::BlockVector &vector);
/**
* Interpolate the given function onto the velocity FE space and write
* it into the given vector.
*
* This function is implemented in
* <code>source/simulator/helper_functions.cc</code>.
*/
void interpolate_onto_velocity_system(const TensorFunction<1,dim> &func,
LinearAlgebra::Vector &vec);
/**
* Add constraints to the given @p constraints object that are required
* for unique solvability of the velocity block based on the nullspace
* removal settings.
*
* This method will add a zero Dirichlet constraint for the first
* velocity unknown in the domain for each velocity component, which is
* later being processed for translational or linear momentum removal.
* This avoids breakdowns of the linear solvers that otherwise occured
* in some instances.
*
* @note: Rotational modes are currently not handled and don't appear to
* require constraints so far.
*/
void setup_nullspace_constraints(ConstraintMatrix &constraints);
/**
* Eliminate the nullspace of the velocity in the given vector. Both
* vectors are expected to contain the up to date data.
*
* @param relevant_dst locally relevant vector for the whole FE, will be
* filled at the end.
* @param tmp_distributed_stokes only contains velocity and pressure.
*
* This function is implemented in
* <code>source/simulator/nullspace.cc</code>.
*/
void remove_nullspace(LinearAlgebra::BlockVector &relevant_dst,
LinearAlgebra::BlockVector &tmp_distributed_stokes);
/**
* Remove the angular momentum of the given vector
*
* @param use_constant_density determines whether to use a constant
* density (which corresponds to removing a net rotation instead of net
* angular momentum).
* @param relevant_dst locally relevant vector for the whole FE, will be
* filled at the end.
* @param tmp_distributed_stokes only contains velocity and pressure.
*
* This function is implemented in
* <code>source/simulator/nullspace.cc</code>.
*/
void remove_net_angular_momentum( const bool use_constant_density,
LinearAlgebra::BlockVector &relevant_dst,
LinearAlgebra::BlockVector &tmp_distributed_stokes);
/**
* Remove the linear momentum of the given vector
*
* @param use_constant_density determines whether to use a constant
* density (which corresponds to removing a net translation instead of
* net linear momentum).
* @param relevant_dst locally relevant vector for the whole FE, will be
* filled at the end.
* @param tmp_distributed_stokes only contains velocity and pressure.
*
* This function is implemented in
* <code>source/simulator/nullspace.cc</code>.
*/
void remove_net_linear_momentum( const bool use_constant_density,
LinearAlgebra::BlockVector &relevant_dst,
LinearAlgebra::BlockVector &tmp_distributed_stokes);
/**
* Compute the maximal velocity throughout the domain. This is needed to
* compute the size of the time step.
*
* This function is implemented in
* <code>source/simulator/helper_functions.cc</code>.
*/
double get_maximal_velocity (const LinearAlgebra::BlockVector &solution) const;
/**
* Compute the variation (i.e., the difference between maximal and
* minimal value) of the entropy $(T-\bar T)^2$ where $\bar T$ is the
* average temperature throughout the domain given as argument to this
* function.
*
* This function is used in computing the artificial diffusion
* stabilization term.
*
* This function is implemented in
* <code>source/simulator/assembly.cc</code>.
*/
double get_entropy_variation (const double average_value,
const AdvectionField &advection_field) const;
/**
* Compute the minimal and maximal temperature througout the domain from
* a solution vector extrapolated from the previous time steps. This is
* needed to compute the artificial diffusion stabilization terms.
*
* This function is implemented in
* <code>source/simulator/helper_functions.cc</code>.
*/
std::pair<double,double>
get_extrapolated_advection_field_range (const AdvectionField &advection_field) const;
/**
* Compute the size of the next time step from the mesh size and the
* velocity on each cell. The computed time step has to satisfy the CFL
* number chosen in the input parameter file on each cell of the mesh.
* If specified in the parameter file, the time step will be the minimum
* of the convection *and* conduction time steps. Also returns whether
* the timestep is dominated by convection (true) or conduction (false).
*
* This function is implemented in
* <code>source/simulator/helper_functions.cc</code>.
*/
std::pair<double,bool> compute_time_step () const;
/**
* Compute the artificial diffusion coefficient value on a cell given
* the values and gradients of the solution passed as arguments.
*
* This function is implemented in
* <code>source/simulator/assembly.cc</code>.
*/
double
compute_viscosity(internal::Assembly::Scratch::AdvectionSystem<dim> &scratch,
const double global_u_infty,
const double global_T_variation,
const double average_temperature,
const double global_entropy_variation,
const double cell_diameter,
const AdvectionField &advection_field) const;
/**
* Compute the residual of one advection equation to be used for the
* artificial diffusion coefficient value on a cell given the values and
* gradients of the solution passed as arguments.
*
* This function is implemented in
* <code>source/simulator/assembly.cc</code>.
*/
void
compute_advection_system_residual(internal::Assembly::Scratch::AdvectionSystem<dim> &scratch,
const double average_field,
const AdvectionField &advection_field,
double &max_residual,
double &max_velocity,
double &max_density,
double &max_specific_heat,
double &conductivity) const;
/**
* Extract the values of temperature, pressure, composition and optional
* strain rate for the current linearization point. These values are
* stored as input arguments for the material model. The compositional
* fields are extracted with the individual compositional fields as
* outer vectors and the values at each quadrature point as inner
* vectors, but the material model needs it the other way round. Hence,
* this vector of vectors is transposed.
*
* @param[in] input_solution A solution vector (or linear combination of
* such vectors) with as many entries as there are degrees of freedom in
* the mesh. It will be evaluated on the cell with which the FEValues
* object was last re-initialized.
* @param[in] input_finite_element_values The FEValues object that
* describes the finite element space in use and that is used to
* evaluate the solution values at the quadrature points of the current
* cell.
* @param[in] cell The cell on which we are currently evaluating
* the material model.
* @param[in] compute_strainrate A flag determining whether the strain
* rate should be computed or not in the output structure.
* @param[out] material_model_inputs The output structure that contains
* the solution values evaluated at the quadrature points.
*
* This function is implemented in
* <code>source/simulator/assembly.cc</code>.
*/
void
compute_material_model_input_values (const LinearAlgebra::BlockVector &input_solution,
const FEValuesBase<dim,dim> &input_finite_element_values,
const typename DoFHandler<dim>::active_cell_iterator &cell,
const bool compute_strainrate,
MaterialModel::MaterialModelInputs<dim> &material_model_inputs) const;
/**
* Return whether the Stokes matrix depends on the values of the
* solution at the previous time step. This is the case is the
* coefficients that appear in the matrix (i.e., the viscosity and, in
* the case of a compressible model, the density) depend on the
* solution.
*
* This function exists to ensure that the Stokes matrix is rebuilt in
* time steps where it may have changed, while we want to save the
* effort of rebuilding it whenever we don't need to.
*
* This function is implemented in
* <code>source/simulator/helper_functions.cc</code>.
*/
bool
stokes_matrix_depends_on_solution () const;
/**
* Generate and output some statistics like timing information and
* memory consumption. Whether this function does anything or not is
* controlled through the variable aspect::output_parallel_statistics.
*
* This function is implemented in
* <code>source/simulator/helper_functions.cc</code>.
*/
void output_program_stats();
/**
* This function is called at the end of each time step and writes the
* statistics object that contains data like the current time, the
* number of linear solver iterations, and whatever the postprocessors
* have generated, to disk.
*
* This function is implemented in
* <code>source/simulator/helper_functions.cc</code>.
*/
void output_statistics();
/**
* This routine computes the initial Stokes residual that is needed as a
* convergence criterion in models with the iterated IMPES solver. We