Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Backofen, Rainer
amdis
Commits
a57f61e2
Commit
a57f61e2
authored
Feb 26, 2009
by
Thomas Witkowski
Browse files
* Refinement bugfix (thanks to Florian :) )
parent
807e9d57
Changes
2
Hide whitespace changes
Inline
Side-by-side
AMDiS/src/Element.cc
View file @
a57f61e2
...
...
@@ -40,6 +40,7 @@ namespace AMDiS {
child
[
1
]
=
NULL
;
newCoord
=
NULL
;
elementData
=
NULL
;
mark
=
0
;
if
(
mesh
)
{
setDOFPtrs
();
...
...
AMDiS/src/RefinementManager1d.cc
View file @
a57f61e2
...
...
@@ -13,21 +13,21 @@
namespace
AMDiS
{
int
RefinementManager1d
::
recursiveRefineFunction
(
ElInfo
*
el
_i
nfo
)
int
RefinementManager1d
::
recursiveRefineFunction
(
ElInfo
*
el
I
nfo
)
{
Line
*
el
=
dynamic_cast
<
Line
*>
(
const_cast
<
Element
*>
(
el
_i
nfo
->
getElement
())),
*
child
[
2
];
Line
*
el
=
dynamic_cast
<
Line
*>
(
const_cast
<
Element
*>
(
el
I
nfo
->
getElement
())),
*
child
[
2
];
Mesh
*
mesh
=
el
_i
nfo
->
getMesh
();
Mesh
*
mesh
=
el
I
nfo
->
getMesh
();
if
(
el
_i
nfo
->
getProjection
(
0
))
{
if
(
el
I
nfo
->
getProjection
(
0
))
{
traversePtr
->
newCoord
(
true
);
}
if
(
el
->
getMark
()
<=
0
)
return
0
;
child
[
0
]
=
dynamic_cast
<
Line
*>
(
mesh
->
createNewElement
(
el
));
child
[
1
]
=
dynamic_cast
<
Line
*>
(
mesh
->
createNewElement
(
el
));
child
[
0
]
=
dynamic_cast
<
Line
*>
(
mesh
->
createNewElement
(
el
));
child
[
1
]
=
dynamic_cast
<
Line
*>
(
mesh
->
createNewElement
(
el
));
int
mark
=
max
(
0
,
el
->
getMark
()
-
1
);
child
[
0
]
->
setMark
(
mark
);
...
...
@@ -52,8 +52,8 @@ namespace AMDiS {
/*--------------------------------------------------------------------------*/
/* the other vertices are handed on from the parent */
/*--------------------------------------------------------------------------*/
child
[
0
]
->
setDOF
(
0
,
const_cast
<
int
*>
(
el
->
getDOF
(
0
)));
child
[
1
]
->
setDOF
(
1
,
const_cast
<
int
*>
(
el
->
getDOF
(
1
)));
child
[
0
]
->
setDOF
(
0
,
const_cast
<
int
*>
(
el
->
getDOF
(
0
)));
child
[
1
]
->
setDOF
(
1
,
const_cast
<
int
*>
(
el
->
getDOF
(
1
)));
/*--------------------------------------------------------------------------*/
/* there is one more leaf element, two hierachical elements, */
...
...
@@ -64,14 +64,13 @@ namespace AMDiS {
mesh
->
incrementNumberOfVertices
(
1
);
mesh
->
incrementNumberOfElements
(
2
);
if
(
mesh
->
getNumberOfDOFs
(
CENTER
))
{
/*--------------------------------------------------------------------------*/
/* there are dofs at the barycenter of the triangles */
/*--------------------------------------------------------------------------*/
child
[
0
]
->
setDOF
(
mesh
->
getNode
(
CENTER
),
const_cast
<
int
*>
(
mesh
->
getDOF
(
CENTER
)));
child
[
1
]
->
setDOF
(
mesh
->
getNode
(
CENTER
),
const_cast
<
int
*>
(
mesh
->
getDOF
(
CENTER
)));
}
if
(
mesh
->
getNumberOfDOFs
(
CENTER
))
{
/*--------------------------------------------------------------------------*/
/* there are dofs at the barycenter of the triangles */
/*--------------------------------------------------------------------------*/
child
[
0
]
->
setDOF
(
mesh
->
getNode
(
CENTER
),
const_cast
<
int
*>
(
mesh
->
getDOF
(
CENTER
)));
child
[
1
]
->
setDOF
(
mesh
->
getNode
(
CENTER
),
const_cast
<
int
*>
(
mesh
->
getDOF
(
CENTER
)));
}
/*--------------------------------------------------------------------------*/
/* if there are functions to interpolate data to the finer grid, do so */
...
...
@@ -80,82 +79,69 @@ namespace AMDiS {
RCNeighbourList
ref_list
(
1
);
// = {{nil, 0, 0}};
ref_list
.
setElement
(
0
,
el
);
int
iadmin
;
int
nrAdmin
=
mesh
->
getNumberOfDOFAdmin
();
for
(
iadmin
=
0
;
iadmin
<
nrAdmin
;
iadmin
++
)
{
for
(
int
iadmin
=
0
;
iadmin
<
nrAdmin
;
iadmin
++
)
{
std
::
list
<
DOFIndexedBase
*>::
iterator
it
;
DOFAdmin
*
admin
=
const_cast
<
DOFAdmin
*>
(
&
mesh
->
getDOFAdmin
(
iadmin
));
std
::
list
<
DOFIndexedBase
*>::
iterator
end
=
admin
->
endDOFIndexed
();
for
(
it
=
admin
->
beginDOFIndexed
();
it
!=
end
;
it
++
)
for
(
it
=
admin
->
beginDOFIndexed
();
it
!=
end
;
it
++
)
(
*
it
)
->
refineInterpol
(
ref_list
,
1
);
}
if
(
!
mesh
->
queryCoarseDOFs
()
&&
mesh
->
getNumberOfDOFs
(
CENTER
))
{
mesh
->
freeDOF
(
const_cast
<
int
*>
(
el
->
getDOF
(
mesh
->
getNode
(
CENTER
))),
CENTER
);
el
->
setDOF
(
mesh
->
getNode
(
CENTER
),
NULL
);
}
if
(
!
mesh
->
queryCoarseDOFs
()
&&
mesh
->
getNumberOfDOFs
(
CENTER
))
{
mesh
->
freeDOF
(
const_cast
<
int
*>
(
el
->
getDOF
(
mesh
->
getNode
(
CENTER
))),
CENTER
);
el
->
setDOF
(
mesh
->
getNode
(
CENTER
),
NULL
);
}
return
0
;
}
Flag
RefinementManager1d
::
refineMesh
(
Mesh
*
aMesh
)
{
int
n_elements
;
mesh
=
aMesh
;
n_elements
=
mesh
->
getNumberOfLeaves
();
int
nElements
=
mesh
->
getNumberOfLeaves
();
doMoreRecursiveRefine
=
true
;
while
(
doMoreRecursiveRefine
)
{
doMoreRecursiveRefine
=
false
;
traversePtr
=
this
;
mesh
->
traverse
(
-
1
,
Mesh
::
CALL_LEAF_EL
|
Mesh
::
FILL_BOUND
|
Mesh
::
FILL_COORDS
,
recursiveRefineFunction
);
}
while
(
doMoreRecursiveRefine
)
{
doMoreRecursiveRefine
=
false
;
traversePtr
=
this
;
mesh
->
traverse
(
-
1
,
Mesh
::
CALL_LEAF_EL
|
Mesh
::
FILL_BOUND
|
Mesh
::
FILL_COORDS
,
recursiveRefineFunction
);
WAIT_REALLY
;
}
n
_e
lements
=
mesh
->
getNumberOfLeaves
()
-
n
_e
lements
;
n
E
lements
=
mesh
->
getNumberOfLeaves
()
-
n
E
lements
;
if
(
newCoords
)
{
if
(
newCoords
)
{
setNewCoords
();
// call of sub-class method
}
return
(
n
_e
lements
?
MESH_REFINED
:
Flag
(
0
));
return
(
n
E
lements
?
MESH_REFINED
:
Flag
(
0
));
}
int
RefinementManager1d
::
newCoordsFct
(
ElInfo
*
el
_i
nfo
)
int
RefinementManager1d
::
newCoordsFct
(
ElInfo
*
el
I
nfo
)
{
Element
*
el
=
el_info
->
getElement
();
int
j
;
Element
*
el
=
elInfo
->
getElement
();
int
dow
=
Global
::
getGeo
(
WORLD
);
Projection
*
projector
=
el
_i
nfo
->
getProjection
(
0
);
Projection
*
projector
=
el
I
nfo
->
getProjection
(
0
);
if
(
el
->
getFirstChild
()
&&
projector
&&
(
!
el
->
isNewCoordSet
()))
{
WorldVector
<
double
>
*
new_coord
=
NEW
WorldVector
<
double
>
;
for
(
j
=
0
;
j
<
dow
;
j
++
)
(
*
new_coord
)[
j
]
=
(
el_info
->
getCoord
(
0
)[
j
]
+
el_info
->
getCoord
(
1
)[
j
])
*
0.5
;
projector
->
project
(
*
new_coord
);
el
->
setNewCoord
(
new_coord
);
}
if
(
el
->
getFirstChild
()
&&
projector
&&
(
!
el
->
isNewCoordSet
()))
{
WorldVector
<
double
>
*
new_coord
=
NEW
WorldVector
<
double
>
;
for
(
int
j
=
0
;
j
<
dow
;
j
++
)
(
*
new_coord
)[
j
]
=
(
elInfo
->
getCoord
(
0
)[
j
]
+
elInfo
->
getCoord
(
1
)[
j
])
*
0.5
;
projector
->
project
(
*
new_coord
);
el
->
setNewCoord
(
new_coord
);
}
return
0
;
}
void
RefinementManager1d
::
setNewCoords
()
{
Flag
fillFlag
=
Mesh
::
CALL_EVERY_EL_PREORDER
|
Mesh
::
FILL_BOUND
|
Mesh
::
FILL_COORDS
;
Flag
fillFlag
=
Mesh
::
CALL_EVERY_EL_PREORDER
|
Mesh
::
FILL_BOUND
|
Mesh
::
FILL_COORDS
;
mesh
->
traverse
(
-
1
,
fillFlag
,
newCoordsFct
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment