Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
iwr
amdis
Commits
986197b6
Commit
986197b6
authored
Oct 15, 2008
by
Thomas Witkowski
Browse files
* Copy operator for meshes implemented
parent
68275e39
Changes
16
Hide whitespace changes
Inline
Side-by-side
AMDiS/src/DOFAdmin.cc
View file @
986197b6
...
...
@@ -23,7 +23,7 @@ namespace AMDiS {
init
();
}
DOFAdmin
::
DOFAdmin
(
Mesh
*
m
,
std
::
string
aName
)
DOFAdmin
::
DOFAdmin
(
Mesh
*
m
,
std
::
string
aName
)
:
name
(
aName
),
mesh
(
m
),
nrDOF
(
mesh
->
getDim
(),
NO_INIT
),
...
...
@@ -34,7 +34,11 @@ namespace AMDiS {
void
DOFAdmin
::
init
()
{
firstHole
=
size
=
usedCount
=
holeCount
=
sizeUsed
=
0
;
firstHole
=
0
;
size
=
0
;
usedCount
=
0
;
holeCount
=
0
;
sizeUsed
=
0
;
dofFree
.
clear
();
}
...
...
@@ -75,6 +79,9 @@ namespace AMDiS {
DOFAdmin
::
DOFAdmin
(
const
DOFAdmin
&
)
{
FUNCNAME
(
"DOFAdmin::DOFAdmin()"
);
ERROR_EXIT
(
"TODO
\n
"
);
}
void
DOFAdmin
::
freeDOFIndex
(
int
dof
)
{
...
...
AMDiS/src/DOFAdmin.h
View file @
986197b6
...
...
@@ -152,14 +152,14 @@ namespace AMDiS {
*/
std
::
list
<
DOFIndexedBase
*>::
iterator
beginDOFIndexed
()
{
return
dofIndexedList
.
begin
();
}
;
}
/** \brief
* Returns an iterator to the end of \ref dofIndexedList
*/
std
::
list
<
DOFIndexedBase
*>::
iterator
endDOFIndexed
()
{
return
dofIndexedList
.
end
();
}
;
}
// ===== getting methods ======================================================
...
...
@@ -172,38 +172,39 @@ namespace AMDiS {
*/
inline
const
int
getUsedSize
()
const
{
return
sizeUsed
;
}
;
}
/** \brief
* Returns \ref size
*/
inline
const
int
getSize
()
const
{
return
size
;
}
;
}
/** \brief
* Returns \ref usedCount
*/
inline
const
int
getUsedDOFs
()
const
{
return
usedCount
;
}
;
}
/** \brief
* Returns \ref holeCount
*/
inline
const
int
getHoleCount
()
const
{
return
holeCount
;
}
;
}
/** \brief
* Returns \ref name
*/
inline
const
std
::
string
&
getName
()
const
{
return
name
;
}
;
}
/** \brief
* Returns \ref nrDOF[i]
* Returns \ref nrDOF[i], i.e., the number of dofs for the
* position i.
*/
inline
const
int
getNumberOfDOFs
(
int
i
)
const
{
return
nrDOF
[
i
];
...
...
@@ -214,7 +215,7 @@ namespace AMDiS {
*/
inline
const
DimVec
<
int
>&
getNumberOfDOFs
()
const
{
return
nrDOF
;
}
;
}
/** \brief
* Returns \ref nr0DOF[i]
...
...
@@ -228,28 +229,28 @@ namespace AMDiS {
*/
inline
const
DimVec
<
int
>&
getNumberOfPreDOFs
()
const
{
return
nr0DOF
;
}
;
}
/** \brief
* Returns \ref mesh
*/
inline
const
Mesh
*
getMesh
()
const
{
return
mesh
;
}
;
}
/** \brief
* Returns \ref dofFree, the array denoting DOFs to be either free or used.
*/
inline
const
std
::
vector
<
bool
>&
getDOFFree
()
const
{
return
dofFree
;
}
;
}
/** \brief
* Returns if the given DOF is free.
*/
inline
const
bool
isDOFFree
(
int
i
)
const
{
return
dofFree
[
i
];
}
;
}
/** \} */
...
...
@@ -262,7 +263,7 @@ namespace AMDiS {
/** \brief
* Sets \ref nrDOF[i] = v
*/
void
setNumberOfDOFs
(
int
i
,
int
v
);
void
setNumberOfDOFs
(
int
i
,
int
v
);
/** \brief
* Sets \ref nr0DOF[i] = v
...
...
@@ -274,14 +275,14 @@ namespace AMDiS {
*/
inline
void
setName
(
const
std
::
string
&
n
)
{
name
=
n
;
}
;
}
/** \brief
* Sets \ref mesh = m
*/
inline
void
setMesh
(
Mesh
*
m
)
{
mesh
=
m
;
}
;
}
/** \} */
...
...
@@ -350,7 +351,8 @@ namespace AMDiS {
int
sizeUsed
;
/** \brief
* dofs from THIS DOFAdmin
* Number of dofs for each position, i.e., vertex,
* edge, ..., center, for this DOFAdmin.
*/
DimVec
<
int
>
nrDOF
;
...
...
AMDiS/src/Element.cc
View file @
986197b6
...
...
@@ -64,6 +64,72 @@ namespace AMDiS {
}
}
Element
*
Element
::
cloneWithDOFs
()
{
Element
*
el
;
if
(
isLine
())
{
el
=
NEW
Line
(
mesh
);
}
else
if
(
isTriangle
())
{
el
=
NEW
Triangle
(
mesh
);
}
else
{
el
=
NEW
Tetrahedron
(
mesh
);
}
el
->
index
=
index
;
el
->
mark
=
mark
;
if
(
newCoord
)
{
WorldVector
<
double
>
*
nc
=
NEW
WorldVector
<
double
>
();
*
nc
=
*
newCoord
;
el
->
newCoord
=
nc
;
}
/* =========== And here we clone the DOFs =========== */
el
->
dof
=
GET_MEMORY
(
DegreeOfFreedom
*
,
mesh
->
getNumberOfNodes
());
int
dim
=
mesh
->
getDim
();
int
j
=
0
;
for
(
int
pos
=
0
;
pos
<=
dim
;
pos
++
)
{
GeoIndex
position
=
INDEX_OF_DIM
(
pos
,
dim
);
int
ndof
=
0
;
for
(
int
i
=
0
;
i
<
mesh
->
getNumberOfDOFAdmin
();
i
++
)
{
ndof
+=
mesh
->
getDOFAdmin
(
i
).
getNumberOfDOFs
(
position
);
}
if
(
ndof
>
0
)
{
for
(
int
i
=
0
;
i
<
mesh
->
getGeo
(
position
);
i
++
)
{
if
(
dof
[
j
]
!=
NULL
)
{
if
(
Mesh
::
serializedDOFs
[
dof
[
j
][
0
]]
==
NULL
)
{
el
->
dof
[
j
]
=
GET_MEMORY
(
DegreeOfFreedom
,
ndof
);
for
(
int
k
=
0
;
k
<
ndof
;
k
++
)
{
el
->
dof
[
j
][
k
]
=
dof
[
j
][
k
];
}
Mesh
::
serializedDOFs
[
dof
[
j
][
0
]]
=
el
->
dof
[
j
];
}
else
{
el
->
dof
[
j
]
=
Mesh
::
serializedDOFs
[
dof
[
j
][
0
]];
}
}
else
{
el
->
dof
[
j
]
=
NULL
;
}
j
++
;
}
}
}
/* =========== And clone the children ============= */
if
(
child
[
0
])
{
el
->
child
[
0
]
=
child
[
0
]
->
clone
();
}
if
(
child
[
1
])
{
el
->
child
[
1
]
=
child
[
1
]
->
clone
();
}
return
el
;
}
/****************************************************************************/
/* ATTENTION: */
/* new_dof_fct() destroys new_dof !!!!!!!!!! */
...
...
@@ -92,9 +158,8 @@ namespace AMDiS {
void
Element
::
newDOFFct1
(
const
DOFAdmin
*
admin
)
{
int
i
,
j
,
k
,
n0
,
nd
,
nd0
;
DegreeOfFreedom
*
ldof
;
int
j
,
k
,
n0
,
nd
,
nd0
;
DegreeOfFreedom
*
ldof
;
int
vertices
=
mesh
->
getGeo
(
VERTEX
);
int
edges
=
mesh
->
getGeo
(
EDGE
);
int
faces
=
mesh
->
getGeo
(
FACE
);
...
...
@@ -102,7 +167,7 @@ namespace AMDiS {
if
((
nd
=
admin
->
getNumberOfDOFs
(
VERTEX
)))
{
nd0
=
admin
->
getNumberOfPreDOFs
(
VERTEX
);
n0
=
admin
->
getMesh
()
->
getNode
(
VERTEX
);
for
(
i
=
0
;
i
<
vertices
;
i
++
)
{
for
(
int
i
=
0
;
i
<
vertices
;
i
++
)
{
CHANGE_DOFS_1
(
this
);
}
}
...
...
@@ -111,7 +176,7 @@ namespace AMDiS {
if
((
nd
=
admin
->
getNumberOfDOFs
(
EDGE
)))
{
nd0
=
admin
->
getNumberOfPreDOFs
(
EDGE
);
n0
=
admin
->
getMesh
()
->
getNode
(
EDGE
);
for
(
i
=
0
;
i
<
edges
;
i
++
)
{
for
(
int
i
=
0
;
i
<
edges
;
i
++
)
{
CHANGE_DOFS_1
(
this
);
}
}
...
...
@@ -121,7 +186,7 @@ namespace AMDiS {
if
((
nd
=
admin
->
getNumberOfDOFs
(
FACE
)))
{
nd0
=
admin
->
getNumberOfPreDOFs
(
FACE
);
n0
=
admin
->
getMesh
()
->
getNode
(
FACE
);
for
(
i
=
0
;
i
<
faces
;
i
++
)
{
for
(
int
i
=
0
;
i
<
faces
;
i
++
)
{
CHANGE_DOFS_1
(
this
);
}
}
...
...
@@ -130,7 +195,7 @@ namespace AMDiS {
if
((
nd
=
admin
->
getNumberOfDOFs
(
CENTER
)))
{
nd0
=
admin
->
getNumberOfPreDOFs
(
CENTER
);
n0
=
admin
->
getMesh
()
->
getNode
(
CENTER
);
i
=
0
;
/* only one center */
int
i
=
0
;
/* only one center */
CHANGE_DOFS_1
(
this
);
}
}
...
...
@@ -138,9 +203,8 @@ namespace AMDiS {
void
Element
::
newDOFFct2
(
const
DOFAdmin
*
admin
)
{
int
i
,
j
,
k
,
n0
,
nd
,
nd0
;
DegreeOfFreedom
*
ldof
;
int
i
,
j
,
k
,
n0
,
nd
,
nd0
;
DegreeOfFreedom
*
ldof
;
int
vertices
=
mesh
->
getGeo
(
VERTEX
);
int
edges
=
mesh
->
getGeo
(
EDGE
);
int
faces
=
mesh
->
getGeo
(
FACE
);
...
...
@@ -191,13 +255,13 @@ namespace AMDiS {
int
Element
::
oppVertex
(
FixVec
<
DegreeOfFreedom
*
,
DIMEN
>
pdof
)
const
{
int
nv
=
0
,
ov
=
0
;
int
nv
=
0
;
int
ov
=
0
;
int
vertices
=
mesh
->
getGeo
(
VERTEX
);
int
dim
=
mesh
->
getDim
();
for
(
int
i
=
0
;
i
<
vertices
;
i
++
)
{
if
(
nv
<
i
-
1
)
if
(
nv
<
i
-
1
)
return
(
-
1
);
for
(
int
j
=
0
;
j
<
dim
;
j
++
)
{
...
...
@@ -225,10 +289,10 @@ namespace AMDiS {
return
ov
;
break
;
case
2
:
return
3
-
ov
;
return
3
-
ov
;
break
;
case
3
:
return
6
-
ov
;
return
6
-
ov
;
break
;
default:
ERROR_EXIT
(
"invalid dim
\n
"
);
...
...
@@ -237,19 +301,19 @@ namespace AMDiS {
}
double
Element
::
getNewCoord
(
int
j
)
const
{
if
(
j
>=
0
)
{
if
(
j
>=
0
)
{
TEST_EXIT_DBG
(
newCoord
)(
"newCoord = NULL
\n
"
);
return
(
*
newCoord
)[
j
];
}
else
{
return
(
newCoord
!=
NULL
);
return
(
newCoord
!=
NULL
);
}
}
void
Element
::
eraseNewCoord
()
{
if
(
newCoord
!=
NULL
)
{
if
(
newCoord
!=
NULL
)
{
DELETE
newCoord
;
newCoord
=
NULL
;
}
;
newCoord
=
NULL
;
}
}
void
Element
::
serialize
(
std
::
ostream
&
out
)
...
...
@@ -270,13 +334,11 @@ namespace AMDiS {
out
.
write
(
reinterpret_cast
<
const
char
*>
(
&
nodes
),
sizeof
(
int
));
for
(
int
pos
=
0
;
pos
<=
dim
;
pos
++
)
{
GeoIndex
position
=
INDEX_OF_DIM
(
pos
,
dim
);
GeoIndex
position
=
INDEX_OF_DIM
(
pos
,
dim
);
int
ndof
=
0
;
for
(
int
i
=
0
;
i
<
mesh
->
getNumberOfDOFAdmin
();
i
++
)
{
const
DOFAdmin
*
localAdmin
=
&
mesh
->
getDOFAdmin
(
i
);
TEST_EXIT_DBG
(
localAdmin
)(
"no admin[%d]
\n
"
,
i
);
ndof
+=
localAdmin
->
getNumberOfDOFs
(
position
);
ndof
+=
mesh
->
getDOFAdmin
(
i
).
getNumberOfDOFs
(
position
);
}
if
(
ndof
>
0
)
{
...
...
@@ -285,8 +347,7 @@ namespace AMDiS {
if
(
Mesh
::
serializedDOFs
[
dof
[
j
][
0
]]
==
NULL
)
{
Mesh
::
serializedDOFs
[
dof
[
j
][
0
]]
=
dof
[
j
];
out
.
write
(
reinterpret_cast
<
const
char
*>
(
&
ndof
),
sizeof
(
int
));
out
.
write
(
reinterpret_cast
<
const
char
*>
(
dof
[
j
]),
ndof
*
sizeof
(
DegreeOfFreedom
));
out
.
write
(
reinterpret_cast
<
const
char
*>
(
dof
[
j
]),
ndof
*
sizeof
(
DegreeOfFreedom
));
}
else
{
int
minusOne
=
-
1
;
out
.
write
(
reinterpret_cast
<
const
char
*>
(
&
minusOne
),
sizeof
(
int
));
...
...
@@ -334,17 +395,17 @@ namespace AMDiS {
if
(
typeName
!=
"NULL"
)
{
if
(
typeName
==
"Line"
)
{
child
[
0
]
=
new
Line
(
NULL
);
child
[
1
]
=
new
Line
(
NULL
);
}
;
child
[
0
]
=
NEW
Line
(
NULL
);
child
[
1
]
=
NEW
Line
(
NULL
);
}
if
(
typeName
==
"Triangle"
)
{
child
[
0
]
=
new
Triangle
(
NULL
);
child
[
1
]
=
new
Triangle
(
NULL
);
}
;
child
[
0
]
=
NEW
Triangle
(
NULL
);
child
[
1
]
=
NEW
Triangle
(
NULL
);
}
if
(
typeName
==
"Tetrahedron"
)
{
child
[
0
]
=
new
Tetrahedron
(
NULL
);
child
[
1
]
=
new
Tetrahedron
(
NULL
);
}
;
child
[
0
]
=
NEW
Tetrahedron
(
NULL
);
child
[
1
]
=
NEW
Tetrahedron
(
NULL
);
}
child
[
0
]
->
deserialize
(
in
);
child
[
1
]
->
deserialize
(
in
);
}
else
{
...
...
@@ -357,22 +418,21 @@ namespace AMDiS {
dof
=
GET_MEMORY
(
DegreeOfFreedom
*
,
nodes
);
int
i
;
for
(
i
=
0
;
i
<
nodes
;
i
++
)
{
for
(
int
i
=
0
;
i
<
nodes
;
i
++
)
{
int
dofs
;
in
.
read
(
reinterpret_cast
<
char
*>
(
&
dofs
),
sizeof
(
int
));
if
(
dofs
)
{
if
(
dofs
!=
-
1
)
{
if
(
dofs
)
{
if
(
dofs
!=
-
1
)
{
dof
[
i
]
=
GET_MEMORY
(
DegreeOfFreedom
,
dofs
);
in
.
read
(
reinterpret_cast
<
char
*>
(
dof
[
i
]),
dofs
*
sizeof
(
DegreeOfFreedom
));
if
(
Mesh
::
serializedDOFs
[
dof
[
i
][
0
]]
!=
NULL
)
{
//WARNING("christina -> dofs already deserialized\n");
if
(
Mesh
::
serializedDOFs
[
dof
[
i
][
0
]]
!=
NULL
)
{
DegreeOfFreedom
*
dofPtr
=
Mesh
::
serializedDOFs
[
dof
[
i
][
0
]];
FREE_MEMORY
(
dof
[
i
],
DegreeOfFreedom
,
dofs
);
dof
[
i
]
=
dofPtr
;
}
else
{
Mesh
::
serializedDOFs
[
dof
[
i
][
0
]]
=
dof
[
i
];
}
Mesh
::
serializedDOFs
[
dof
[
i
][
0
]]
=
dof
[
i
];
}
else
{
DegreeOfFreedom
index
;
in
.
read
(
reinterpret_cast
<
char
*>
(
&
index
),
sizeof
(
DegreeOfFreedom
));
...
...
@@ -393,8 +453,8 @@ namespace AMDiS {
in
>>
typeName
;
in
.
get
();
if
(
typeName
!=
"NULL"
)
{
if
(
typeName
==
"WorldVector"
)
{
if
(
typeName
!=
"NULL"
)
{
if
(
typeName
==
"WorldVector"
)
{
newCoord
=
NEW
WorldVector
<
double
>
;
newCoord
->
deserialize
(
in
);
}
else
{
...
...
@@ -408,9 +468,9 @@ namespace AMDiS {
in
>>
typeName
;
in
.
get
();
if
(
typeName
!=
"NULL"
)
{
if
(
typeName
!=
"NULL"
)
{
elementData
=
CreatorMap
<
ElementData
>::
getCreator
(
typeName
)
->
create
();
if
(
elementData
)
{
if
(
elementData
)
{
elementData
->
deserialize
(
in
);
}
else
{
ERROR_EXIT
(
"unexpected type name
\n
"
);
...
...
AMDiS/src/Element.h
View file @
986197b6
...
...
@@ -101,6 +101,12 @@ namespace AMDiS {
*/
virtual
~
Element
();
/** \brief
* Clone this Element and return a reference to it. Because also the DOFs
* are cloned, \ref Mesh::serializedDOfs must be used.
*/
Element
*
cloneWithDOFs
();
// ===== getting methods ======================================================
/** \name getting methods
...
...
@@ -213,8 +219,8 @@ namespace AMDiS {
* positionIndex-th part of type position (vertex, edge, face)
*/
virtual
int
getVertexOfPosition
(
GeoIndex
position
,
int
positionIndex
,
int
vertexIndex
)
const
=
0
;
int
positionIndex
,
int
vertexIndex
)
const
=
0
;
/** \brief
*
...
...
@@ -431,7 +437,7 @@ namespace AMDiS {
/** \brief
* assignment operator
*/
Element
&
operator
=
(
const
Element
&
old
);
Element
&
operator
=
(
const
Element
&
el
);
/** \brief
* Checks whether the face with vertices dof[0],..,dof[DIM-1] is
...
...
@@ -571,10 +577,9 @@ namespace AMDiS {
* Vector of pointers to DOFs. These pointers must be available for elements
* vertices (for the geometric description of the mesh). There my be pointers
* for the edges, for faces and for the center of an element. They are
* ordered
* the following way: The first N_VERTICES entries correspond to the DOFs at
* the vertices of the element. The next ones are those at the edges, if
* present, then those at the faces, if present, and then those at the
* ordered the following way: The first N_VERTICES entries correspond to the
* DOFs at the vertices of the element. The next ones are those at the edges,
* if present, then those at the faces, if present, and then those at the
* barycenter, if present.
*/
DegreeOfFreedom
**
dof
;
...
...
@@ -597,9 +602,8 @@ namespace AMDiS {
* If the element has a boundary edge on a curved boundary, this is a pointer
* to the coordinates of the new vertex that is created due to the refinement
* of the element, otherwise it is a NULL pointer. Thus coordinate
* information
* can be also produced by the traversal routines in the case of curved
* boundary.
* information can be also produced by the traversal routines in the case of
* curved boundary.
*/
WorldVector
<
double
>
*
newCoord
;
...
...
AMDiS/src/ElementData.h
View file @
986197b6
...
...
@@ -51,12 +51,12 @@ namespace AMDiS {
*/
ElementData
(
ElementData
*
decorated
=
NULL
)
:
decorated_
(
decorated
)
{}
;
{}
/** \brief
* destructor
*/
virtual
~
ElementData
()
{}
;
virtual
~
ElementData
()
{}
/** \brief
* Refinement of parent to child1 and child2.
...
...
@@ -66,18 +66,18 @@ namespace AMDiS {
Element
*
child2
,
int
elType
)
{
if
(
decorated_
)
{
if
(
decorated_
)
{
bool
remove
=
decorated_
->
refineElementData
(
parent
,
child1
,
child2
,
elType
);
if
(
remove
)
{
if
(
remove
)
{
ElementData
*
tmp
=
decorated_
->
decorated_
;
delete
decorated_
;
decorated_
=
tmp
;
}
}
return
false
;
}
;
}
/** \brief
*
...
...
@@ -95,7 +95,7 @@ namespace AMDiS {
delete
decorated_
;
decorated_
=
NULL
;
}
}
;
}
/** \brief
* Returns a copy of this ElementData object including all decorated data.
...
...
@@ -105,7 +105,7 @@ namespace AMDiS {
return
decorated_
->
clone
();
}
return
NULL
;
}
;
}
/** \brief
* Returns the name of element data type.
...
...
@@ -140,14 +140,14 @@ namespace AMDiS {
}
}
return
NULL
;
}
;
}
inline
ElementData
*
getDecorated
(
int
typeID
)
{
if
(
decorated_
)
{
return
decorated_
->
getElementData
(
typeID
);
}
return
NULL
;
}
;
}
inline
bool
deleteDecorated
(
int
typeID
)
{
if
(
decorated_
)
{
...
...
@@ -161,9 +161,15 @@ namespace AMDiS {
}
}
return
false
;
};
}
inline
ElementData
*
getDecorated
()
{
return
decorated_
;
}
inline
ElementData
*
getDecorated
()
{
return
decorated_
;
};
inline
void
setDecorated
(
ElementData
*
d
)
{
decorated_
=
d
;
}
protected:
/** \brief
...
...
AMDiS/src/FiniteElemSpace.cc
View file @
986197b6
...
...
@@ -45,10 +45,10 @@ namespace AMDiS {
feSpaces
.
push_back
(
this
);
}
FiniteElemSpace
*
FiniteElemSpace
::
provideFESpace
(
DOFAdmin
*
admin
,
FiniteElemSpace
*
FiniteElemSpace
::
provideFESpace
(
DOFAdmin
*
admin
,
const
BasisFunction
*
basFcts
,
Mesh
*
mesh
,
const
std
::
string
&
name_
)
Mesh
*
mesh
,
const
std
::
string
&
name_
)
{
int
numSpaces
=
static_cast
<
int
>
(
feSpaces
.
size
());
...
...
AMDiS/src/FixVec.h
View file @
986197b6
...
...
@@ -95,7 +95,7 @@ namespace AMDiS {
{
TEST_EXIT_DBG
(
initType
==
VALUE_LIST
)(
"wrong initType or wrong initializer
\n
"
);
setValues
(
ini
);
}
;
}
/** \brief
* constructor with default value initialisation. initType must be
...
...
@@ -114,7 +114,7 @@ namespace AMDiS {
inline
void
init
(
int
dim
)
{
this
->
resize
(
calcSize
(
dim
));
}
;