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
geompack_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_GEOMPACK_MESH_TEMPLATE_HEADER
27
#define OOMPH_GEOMPACK_MESH_TEMPLATE_HEADER
28
29
#ifndef OOMPH_GEOMPACK_MESH_HEADER
30
#error __FILE__ should only be included from geompack_mesh.h.
31
#endif
// OOMPH_GEOMPACK_MESH_HEADER
32
33
namespace
oomph
34
{
35
//========================================================================
36
/// Quadrilateral mesh generator; Uses input from Geompack++.
37
/// See: http://members.shaw.ca/bjoe/
38
/// Currently only for four-noded quads -- extension to higher-order
39
/// quads should be trivial (see the corresponding classes for
40
/// triangular meshes).
41
//========================================================================
42
template
<
class
ELEMENT>
43
void
GeompackQuadMesh<ELEMENT>::build_from_scaffold
(
44
TimeStepper
*
time_stepper_pt
)
45
{
46
// Mesh can only be built with four-noded 2D Qelements.
47
MeshChecker::assert_geometric_element<QElementGeometricBase, ELEMENT>(2, 2);
48
49
// Create space for elements
50
unsigned
nelem
=
Tmp_mesh_pt
->nelement();
51
Element_pt
.resize(
nelem
);
52
53
// Create space for nodes
54
unsigned
nnod
=
Tmp_mesh_pt
->nnode();
55
Node_pt
.resize(
nnod
);
56
57
// Set number of boundaries
58
unsigned
nbound
=
Tmp_mesh_pt
->nboundary();
59
set_nboundary
(
nbound
);
60
61
// Loop over elements in scaffold mesh, visit their nodes
62
for
(
unsigned
e
= 0;
e
<
nelem
;
e
++)
63
{
64
Element_pt
[
e
] =
new
ELEMENT
;
65
}
66
67
// At the moment we can only do four-noded quads
68
if
(
finite_element_pt
(0)->
nnode
() != 4)
69
{
70
std::string
error_message
=
71
"GeompackQuadMesh can currently only deal with\n"
;
72
error_message
+=
"four noded quads! \n"
;
73
error_message
+=
"Generalisation to higher-order elements should be \n"
;
74
error_message
+=
"straightforward but hasn't been done yet.\n"
;
75
error_message
+=
"Do you want to volunteer? \n"
;
76
77
throw
OomphLibError
(
78
error_message
,
OOMPH_CURRENT_FUNCTION
,
OOMPH_EXCEPTION_LOCATION
);
79
}
80
81
// In the first instance build all nodes from within all the elements
82
unsigned
nnod_el
=
Tmp_mesh_pt
->finite_element_pt(0)->nnode();
83
84
// Loop over elements in scaffold mesh, visit their nodes
85
for
(
unsigned
e
= 0;
e
<
nelem
;
e
++)
86
{
87
// Loop over all nodes in element
88
for
(
unsigned
j
= 0;
j
<
nnod_el
;
j
++)
89
{
90
// Create new node, using the NEW element's construct_node
91
// member function
92
finite_element_pt
(
e
)->construct_node(
j
,
time_stepper_pt
);
93
}
94
}
95
96
std::map<Node*, unsigned>
global_number
;
97
unsigned
global_count
= 0;
98
// Loop over elements in scaffold mesh, visit their nodes
99
for
(
unsigned
e
= 0;
e
<
nelem
;
e
++)
100
{
101
// Loop over all nodes in element
102
for
(
unsigned
j
= 0;
j
<
nnod_el
;
j
++)
103
{
104
// Pointer to node in the scaffold mesh
105
Node
*
scaffold_node_pt
=
Tmp_mesh_pt
->finite_element_pt(
e
)->node_pt(
j
);
106
107
// Get the (pseudo-)global node number in scaffold mesh
108
// (It's zero [=default] if not visited this one yet)
109
unsigned
j_global
=
global_number
[
scaffold_node_pt
];
110
111
// Haven't done this one yet
112
if
(
j_global
== 0)
113
{
114
// Give it a number (not necessarily the global node
115
// number in the scaffold mesh -- we just need something
116
// to keep track...)
117
global_count
++;
118
global_number
[
scaffold_node_pt
] =
global_count
;
119
120
// Copy new node, created using the NEW element's construct_node
121
// function into global storage, using the same global
122
// node number that we've just associated with the
123
// corresponding node in the scaffold mesh
124
Node_pt
[
global_count
- 1] =
finite_element_pt
(
e
)->node_pt(
j
);
125
126
// Assign coordinates
127
Node_pt
[
global_count
- 1]->x(0) =
scaffold_node_pt
->x(0);
128
Node_pt
[
global_count
- 1]->x(1) =
scaffold_node_pt
->x(1);
129
130
// Get pointer to set of mesh boundaries that this
131
// scaffold node occupies; NULL if the node is not on any boundary
132
std::set<unsigned>*
boundaries_pt
;
133
scaffold_node_pt
->get_boundaries_pt(
boundaries_pt
);
134
135
// Loop over the mesh boundaries that the node in the scaffold mesh
136
// occupies and assign new node to the same ones.
137
if
(
boundaries_pt
!= 0)
138
{
139
// Convert it to a boundary node
140
this->
convert_to_boundary_node
(
Node_pt
[
global_count
- 1]);
141
// Add the node to the boundaries
142
for
(std::set<unsigned>::iterator
it
=
boundaries_pt
->begin();
143
it
!=
boundaries_pt
->end();
144
++
it
)
145
{
146
add_boundary_node
(*
it
,
Node_pt
[
global_count
- 1]);
147
}
148
}
149
}
150
// This one has already been done: Kill it
151
else
152
{
153
// Kill it
154
delete
finite_element_pt
(
e
)->node_pt(
j
);
155
156
// Overwrite the element's pointer to local node by
157
// pointer to the already existing node -- identified by
158
// the number kept in the map
159
finite_element_pt
(
e
)->node_pt(
j
) =
Node_pt
[
j_global
- 1];
160
}
161
}
162
}
163
}
164
165
}
// namespace oomph
166
#endif
oomph::GeompackQuadMesh::build_from_scaffold
void build_from_scaffold(TimeStepper *time_stepper_pt)
Build mesh from scaffold.
Definition
geompack_mesh.template.cc:43
oomph::RefineableTriangleMesh
Unstructured refineable Triangle Mesh.
Definition
triangle_mesh.h:2225
oomph::TriangleMesh::Tmp_mesh_pt
TriangleScaffoldMesh * Tmp_mesh_pt
Temporary scaffold mesh.
Definition
triangle_mesh.h:1334
oomph
Definition
annular_domain.h:35