-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstep-23-variant_01a.cc
150 lines (124 loc) · 4.38 KB
/
step-23-variant_01a.cc
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
// ---------------------------------------------------------------------
//
// Copyright (C) 2020 - 2021 by the deal.II authors
//
// This file is part of the deal.II library.
//
// The deal.II library is free software; you can use it, redistribute
// it, and/or modify it under the terms of the GNU Lesser General
// Public License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// The full text of the license can be found in the file LICENSE.md at
// the top level directory of deal.II.
//
// ---------------------------------------------------------------------
// ---------------------------------------------------------------------
//
// Copyright (C) 2021 - 2022 by Jean-Paul Pelteret
//
// This file is part of the Weak forms for deal.II library.
//
// The Weak forms for deal.II library is free software; you can use it,
// redistribute it, and/or modify it under the terms of the GNU Lesser
// General Public License as published by the Free Software Foundation;
// either version 3.0 of the License, or (at your option) any later
// version. The full text of the license can be found in the file LICENSE
// at the top level of the Weak forms for deal.II distribution.
//
// ---------------------------------------------------------------------
// This test replicates step-23.
// It is used as a baseline for the weak form tests.
#include "../weak_forms_tests.h"
#include "wf_common_tests/step-23.h"
namespace Step23
{
using namespace dealii;
template <int dim>
class Step23 : public Step23_Base<dim>
{
public:
Step23()
: Step23_Base<dim>()
{}
protected:
void
assemble_u() override;
void
assemble_v() override;
};
template <int dim>
void
Step23<dim>::assemble_u()
{
this->mass_matrix.vmult(this->system_rhs, this->old_solution_u);
Vector<double> tmp(this->solution_u.size());
this->mass_matrix.vmult(tmp, this->old_solution_v);
this->system_rhs.add(this->time_step, tmp);
this->laplace_matrix.vmult(tmp, this->old_solution_u);
this->system_rhs.add(-this->theta * (1 - this->theta) * this->time_step *
this->time_step,
tmp);
Vector<double> forcing_terms(this->solution_u.size());
this->assemble_forcing_terms(forcing_terms);
this->system_rhs.add(this->theta * this->time_step, forcing_terms);
this->matrix_u.copy_from(this->mass_matrix);
this->matrix_u.add(this->theta * this->theta * this->time_step *
this->time_step,
this->laplace_matrix);
}
template <int dim>
void
Step23<dim>::assemble_v()
{
this->laplace_matrix.vmult(this->system_rhs, this->solution_u);
this->system_rhs *= -this->theta * this->time_step;
Vector<double> tmp(this->solution_u.size());
this->mass_matrix.vmult(tmp, this->old_solution_v);
this->system_rhs += tmp;
this->laplace_matrix.vmult(tmp, this->old_solution_u);
this->system_rhs.add(-this->time_step * (1 - this->theta), tmp);
Vector<double> forcing_terms(this->solution_u.size());
this->assemble_forcing_terms(forcing_terms);
this->system_rhs += forcing_terms;
this->matrix_v.copy_from(this->mass_matrix);
}
} // namespace Step23
int
main(int argc, char **argv)
{
initlog();
deallog.depth_file(1);
Utilities::MPI::MPI_InitFinalize mpi_initialization(
argc, argv, testing_max_num_threads());
try
{
Step23::Step23<2> wave_equation_solver;
wave_equation_solver.run();
}
catch (std::exception &exc)
{
std::cerr << std::endl
<< std::endl
<< "----------------------------------------------------"
<< std::endl;
std::cerr << "Exception on processing: " << std::endl
<< exc.what() << std::endl
<< "Aborting!" << std::endl
<< "----------------------------------------------------"
<< std::endl;
return 1;
}
catch (...)
{
std::cerr << std::endl
<< std::endl
<< "----------------------------------------------------"
<< std::endl;
std::cerr << "Unknown exception!" << std::endl
<< "Aborting!" << std::endl
<< "----------------------------------------------------"
<< std::endl;
return 1;
}
return 0;
}