-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstep-8-variant_01b.cc
145 lines (116 loc) · 3.97 KB
/
step-8-variant_01b.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
// ---------------------------------------------------------------------
//
// 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.
//
// ---------------------------------------------------------------------
// Elasticity problem: Assembly using weak forms
// This test replicates step-8 exactly.
#include <deal.II/base/function.h>
#include <weak_forms/weak_forms.h>
#include "../weak_forms_tests.h"
#include "wf_common_tests/step-8.h"
using namespace dealii;
template <int dim>
class Step8 : public Step8_Base<dim>
{
public:
Step8();
protected:
void
assemble_system() override;
};
template <int dim>
Step8<dim>::Step8()
: Step8_Base<dim>()
{}
template <int dim>
void
Step8<dim>::assemble_system()
{
using namespace WeakForms;
// Symbolic types for test function, trial solution and a coefficient.
const TestFunction<dim> test;
const TrialSolution<dim> trial;
const SubSpaceExtractors::Vector subspace_extractor(0, "u", "\\mathbf{u}");
const TensorFunctionFunctor<4, dim> mat_coeff("C", "\\mathcal{C}");
const VectorFunctionFunctor<dim> rhs_coeff("s", "\\mathbf{s}");
const Coefficient<dim> coefficient;
const RightHandSide<dim> rhs;
const auto test_ss = test[subspace_extractor];
const auto trial_ss = trial[subspace_extractor];
const auto test_val = test_ss.value();
const auto test_grad = test_ss.gradient();
const auto trial_grad = trial_ss.gradient();
MatrixBasedAssembler<dim> assembler;
assembler +=
bilinear_form(test_grad, mat_coeff.value(coefficient), trial_grad).dV() -
linear_form(test_val, rhs_coeff.value(rhs)).dV();
// Look at what we're going to compute
const SymbolicDecorations decorator;
static bool output = true;
if (output)
{
std::cout << "Weak form (ascii):\n"
<< assembler.as_ascii(decorator) << std::endl;
std::cout << "Weak form (LaTeX):\n"
<< assembler.as_latex(decorator) << std::endl;
output = false;
}
// Now we pass in concrete objects to get data from
// and assemble into.
const QGauss<dim> qf_cell(this->fe.degree + 1);
assembler.assemble_system(this->system_matrix,
this->system_rhs,
this->constraints,
this->dof_handler,
qf_cell);
}
int
main(int argc, char **argv)
{
initlog();
deallog << std::setprecision(9);
Utilities::MPI::MPI_InitFinalize mpi_initialization(
argc, argv, testing_max_num_threads());
try
{
Step8<2> elastic_problem_2d;
elastic_problem_2d.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;
}
deallog << "OK" << std::endl;
return 0;
}