Toggle navigation
Documentation
Big picture
The finite element method
The data structure
Not-so-quick guide
Optimisation
Order of action functions
Example codes and tutorials
List of example codes and tutorials
Meshing
Solvers
MPI parallel processing
Post-processing/visualisation
Other
Change log
Creating documentation
Coding conventions
Index
FAQ
About
People
Contact/Get involved
Publications
Acknowledgements
Copyright
Picture show
Go
src
meshes
backward_step_mesh.template.cc
Go to the documentation of this file.
1
// LIC// ====================================================================
2
// LIC// This file forms part of oomph-lib, the object-oriented,
3
// LIC// multi-physics finite-element library, available
4
// LIC// at http://www.oomph-lib.org.
5
// LIC//
6
// LIC// Copyright (C) 2006-2025 Matthias Heil and Andrew Hazel
7
// LIC//
8
// LIC// This library is free software; you can redistribute it and/or
9
// LIC// modify it under the terms of the GNU Lesser General Public
10
// LIC// License as published by the Free Software Foundation; either
11
// LIC// version 2.1 of the License, or (at your option) any later version.
12
// LIC//
13
// LIC// This library is distributed in the hope that it will be useful,
14
// LIC// but WITHOUT ANY WARRANTY; without even the implied warranty of
15
// LIC// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
// LIC// Lesser General Public License for more details.
17
// LIC//
18
// LIC// You should have received a copy of the GNU Lesser General Public
19
// LIC// License along with this library; if not, write to the Free Software
20
// LIC// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21
// LIC// 02110-1301 USA.
22
// LIC//
23
// LIC// The authors may be contacted at oomph-lib@maths.man.ac.uk.
24
// LIC//
25
// LIC//====================================================================
26
#ifndef OOMPH_BACKWARD_STEP_MESH_TEMPLATE_HEADER
27
#define OOMPH_BACKWARD_STEP_MESH_TEMPLATE_HEADER
28
29
#ifndef OOMPH_BACKWARD_STEP_MESH_HEADER
30
#error __FILE__ should only be included from backward_step_mesh.h.
31
#endif
// OOMPH_BACKWARD_STEP_MESH_HEADER
32
33
#include <set>
34
#include <map>
35
36
namespace
oomph
37
{
38
//=================================================================
39
/// Actual build function. Pass overall number of elements in the
40
/// horizontal and vertical directions, nx and ny, and the corresponding
41
/// dimensions, lx and ly. nx_cut_out and ny_cut_out elements
42
/// are cut out from the lower right corner to create the
43
/// (reversed) backward step geometry. Timestepper defaults
44
/// to Steady.
45
//=================================================================
46
template
<
class
ELEMENT>
47
void
BackwardStepQuadMesh<ELEMENT>::build_mesh
(
const
unsigned
& nx,
48
const
unsigned
& ny,
49
const
unsigned
&
nx_cut_out
,
50
const
unsigned
&
ny_cut_out
,
51
const
double
&
lx
,
52
const
double
&
ly
)
53
{
54
// Mesh can only be built with 2D Qelements.
55
MeshChecker::assert_geometric_element<QElementGeometricBase, ELEMENT>(2);
56
57
// By default nobody's claiming any nodes
58
std::map<Node*, bool>
keep
;
59
60
// Get elements outside lower right block
61
Vector<FiniteElement*>
el_retained_pt
;
62
Vector<FiniteElement*>
el_killed_pt
;
63
for
(
unsigned
i
= 0;
i
< nx;
i
++)
64
{
65
for
(
unsigned
j
= 0;
j
< ny;
j
++)
66
{
67
FiniteElement
*
el_pt
= this->finite_element_pt(
i
+ nx *
j
);
68
if
((
i
> (
nx_cut_out
- 1)) && (
j
<
ny_cut_out
))
69
{
70
el_killed_pt
.push_back(
el_pt
);
71
}
72
else
73
{
74
el_retained_pt
.push_back(
el_pt
);
75
unsigned
nnod_el
=
el_pt
->
nnode
();
76
for
(
unsigned
jj
= 0;
jj
<
nnod_el
;
jj
++)
77
{
78
keep
[
el_pt
->
node_pt
(
jj
)] =
true
;
79
}
80
}
81
}
82
}
83
84
// By default nobody's claiming the nodes; also store old
85
// boundary ids
86
std::map<Node*, std::set<unsigned>>
boundaries
;
87
unsigned
nnod
= this->
nnode
();
88
for
(
unsigned
j
= 0;
j
<
nnod
;
j
++)
89
{
90
std::set<unsigned>*
aux_pt
= 0;
91
this->
node_pt
(
j
)->
get_boundaries_pt
(
aux_pt
);
92
if
(
aux_pt
!= 0)
93
{
94
boundaries
[this->
node_pt
(
j
)] = (*aux_pt);
95
}
96
}
97
98
// Remove information about boundary nodes
99
this->remove_boundary_nodes();
100
101
// Reset number of boundaries
102
this->set_nboundary(6);
103
104
// Kill superfluous nodes
105
Vector<Node*>
node_backup_pt
(this->
Node_pt
);
106
this->
Node_pt
.clear();
107
for
(
unsigned
j
= 0;
j
<
nnod
;
j
++)
108
{
109
Node
*
nod_pt
=
node_backup_pt
[
j
];
110
if
(
keep
[
nod_pt
])
111
{
112
this->
Node_pt
.push_back(nod_pt);
113
std::set<unsigned>
aux
=
boundaries
[
nod_pt
];
114
for
(std::set<unsigned>::iterator
it
=
boundaries
[
nod_pt
].
begin
();
115
it
!=
boundaries
[
nod_pt
].end();
116
it
++)
117
{
118
unsigned
b = (*it);
119
if
(b > 0) b += 2;
120
this->add_boundary_node(b,
nod_pt
);
121
}
122
}
123
else
124
{
125
delete
node_backup_pt
[
j
];
126
}
127
}
128
129
// Add nodes to new boundary 1
130
unsigned
i
=
nx_cut_out
- 1;
131
for
(
unsigned
j
= 0;
j
<
ny_cut_out
;
j
++)
132
{
133
FiniteElement
*
el_pt
= this->finite_element_pt(
i
+ nx *
j
);
134
unsigned
nnod_1d
=
el_pt
->
nnode_1d
();
135
for
(
unsigned
jj
= 0;
jj
<
nnod_1d
;
jj
++)
136
{
137
unsigned
jnod
= (
nnod_1d
- 1) +
jj
*
nnod_1d
;
138
if
(!(
el_pt
->
node_pt
(
jnod
)->
is_on_boundary
()))
139
{
140
Node
*
nod_pt
=
el_pt
->
node_pt
(
jnod
);
141
this->convert_to_boundary_node(
nod_pt
);
142
}
143
this->add_boundary_node(1,
el_pt
->
node_pt
(
jnod
));
144
}
145
}
146
147
// Add nodes to new boundary 2
148
unsigned
j
=
ny_cut_out
;
149
for
(
unsigned
i
=
nx_cut_out
;
i
< nx;
i
++)
150
{
151
FiniteElement
*
el_pt
= this->finite_element_pt(
i
+ nx *
j
);
152
unsigned
nnod_1d
=
el_pt
->
nnode_1d
();
153
for
(
unsigned
jj
= 0;
jj
<
nnod_1d
;
jj
++)
154
{
155
unsigned
jnod
=
jj
;
156
if
(!(
el_pt
->
node_pt
(
jnod
)->
is_on_boundary
()))
157
{
158
Node
*
nod_pt
=
el_pt
->
node_pt
(
jnod
);
159
this->convert_to_boundary_node(
nod_pt
);
160
}
161
this->add_boundary_node(2,
el_pt
->
node_pt
(
jnod
));
162
}
163
}
164
165
// Kill redundant elements
166
this->Element_pt.clear();
167
unsigned
n_retained
=
el_retained_pt
.
size
();
168
for
(
unsigned
e
= 0;
e
<
n_retained
;
e
++)
169
{
170
this->Element_pt.push_back(
el_retained_pt
[
e
]);
171
}
172
unsigned
n_killed
=
el_killed_pt
.
size
();
173
for
(
unsigned
e
= 0;
e
<
n_killed
;
e
++)
174
{
175
delete
el_killed_pt
[
e
];
176
}
177
178
// Re-setup lookup scheme that establishes which elements are located
179
// on the mesh boundaries
180
this->setup_boundary_element_info();
181
}
182
183
}
// namespace oomph
184
185
#endif
e
e
Definition
cfortran.h:571
i
cstr elem_len * i
Definition
cfortran.h:603
oomph::BackwardStepQuadMesh::build_mesh
void build_mesh(const unsigned &nx, const unsigned &ny, const unsigned &nx_cut_out, const unsigned &ny_cut_out, const double &lx, const double &ly)
Actual build function.
Definition
backward_step_mesh.template.cc:47
oomph::FiniteElement
A general Finite Element class.
Definition
elements.h:1317
oomph::FiniteElement::size
double size() const
Calculate the size of the element (length, area, volume,...) in Eulerian computational coordinates....
Definition
elements.cc:4320
oomph::FiniteElement::nnode
unsigned nnode() const
Return the number of nodes.
Definition
elements.h:2214
oomph::FiniteElement::Node_pt
Node ** Node_pt
Storage for pointers to the nodes in the element.
Definition
elements.h:1323
oomph::FiniteElement::node_pt
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
Definition
elements.h:2179
oomph::FiniteElement::nnode_1d
virtual unsigned nnode_1d() const
Return the number of nodes along one edge of the element Default is to return zero — must be overload...
Definition
elements.h:2222
oomph::Node
Nodes are derived from Data, but, in addition, have a definite (Eulerian) position in a space of a gi...
Definition
nodes.h:906
oomph::Node::is_on_boundary
virtual bool is_on_boundary() const
Test whether the Node lies on a boundary. The "bulk" Node cannot lie on a boundary,...
Definition
nodes.h:1373
oomph::Node::get_boundaries_pt
virtual void get_boundaries_pt(std::set< unsigned > *&boundaries_pt)
Return a pointer to set of mesh boundaries that this node occupies; this will be overloaded by Bounda...
Definition
nodes.h:1365
oomph::TAdvectionDiffusionReactionElement
TAdvectionDiffusionReactionElement<NREAGENT,DIM,NNODE_1D> elements are isoparametric triangular DIM-d...
Definition
Tadvection_diffusion_reaction_elements.h:66
oomph::TAdvectionDiffusionReactionElement::TAdvectionDiffusionReactionElement
TAdvectionDiffusionReactionElement()
Constructor: Call constructors for TElement and AdvectionDiffusionReaction equations.
Definition
Tadvection_diffusion_reaction_elements.h:70
oomph
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition
advection_diffusion_elements.cc:30