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
70789436
Commit
70789436
authored
Jun 22, 2009
by
Thomas Witkowski
Browse files
Work on periodic boundary conditions.
parent
085e86f9
Changes
2
Hide whitespace changes
Inline
Side-by-side
AMDiS/src/PeriodicBC.cc
View file @
70789436
...
@@ -51,15 +51,13 @@ namespace AMDiS {
...
@@ -51,15 +51,13 @@ namespace AMDiS {
{
{
FUNCNAME
(
"PeriodicDOFMapping::getDOFPermutation()"
);
FUNCNAME
(
"PeriodicDOFMapping::getDOFPermutation()"
);
if
(
dofPermutation_
[
vertexPermutation
]
==
NULL
)
{
if
(
dofPermutation_
[
vertexPermutation
]
==
NULL
)
{
//MSG("new dof permutation needed\n");
//MSG("new dof permutation needed\n");
int
i
,
j
;
int
dim
=
basFcts_
->
getDim
();
int
dim
=
basFcts_
->
getDim
();
int
num
=
basFcts_
->
getNumber
();
int
num
=
basFcts_
->
getNumber
();
int
sum
=
0
;
int
sum
=
0
;
for
(
i
=
0
;
i
<
dim
+
1
;
i
++
)
{
for
(
int
i
=
0
;
i
<
dim
+
1
;
i
++
)
{
sum
+=
i
-
vertexPermutation
[
i
];
sum
+=
i
-
vertexPermutation
[
i
];
TEST_EXIT
(
vertexPermutation
[
i
]
<
dim
+
1
)
TEST_EXIT
(
vertexPermutation
[
i
]
<
dim
+
1
)
(
"invalid vertexPermuation
\n
"
);
(
"invalid vertexPermuation
\n
"
);
...
@@ -72,11 +70,11 @@ namespace AMDiS {
...
@@ -72,11 +70,11 @@ namespace AMDiS {
DegreeOfFreedom
*
mapping
=
new
DegreeOfFreedom
[
num
];
DegreeOfFreedom
*
mapping
=
new
DegreeOfFreedom
[
num
];
for
(
i
=
0
;
i
<
num
;
i
++
)
{
for
(
int
i
=
0
;
i
<
num
;
i
++
)
{
lambda
=
basFcts_
->
getCoords
(
i
);
lambda
=
basFcts_
->
getCoords
(
i
);
for
(
j
=
0
;
j
<
dim
+
1
;
j
++
)
{
for
(
int
j
=
0
;
j
<
dim
+
1
;
j
++
)
newLambda
[
vertexPermutation
[
j
]]
=
(
*
lambda
)[
j
];
newLambda
[
vertexPermutation
[
j
]]
=
(
*
lambda
)[
j
];
}
mapping
[
i
]
=
indexOfCoords_
[
newLambda
];
mapping
[
i
]
=
indexOfCoords_
[
newLambda
];
}
}
...
@@ -91,7 +89,7 @@ namespace AMDiS {
...
@@ -91,7 +89,7 @@ namespace AMDiS {
:
BoundaryCondition
(
type
,
rowFESpace_
,
NULL
),
:
BoundaryCondition
(
type
,
rowFESpace_
,
NULL
),
masterMatrix_
(
NULL
)
masterMatrix_
(
NULL
)
{
{
if
(
rowFESpace
->
getMesh
()
->
getDim
()
>
1
)
{
if
(
rowFESpace
->
getMesh
()
->
getDim
()
>
1
)
{
periodicDOFMapping_
=
periodicDOFMapping_
=
PeriodicDOFMapping
::
providePeriodicDOFMapping
(
rowFESpace_
->
getBasisFcts
());
PeriodicDOFMapping
::
providePeriodicDOFMapping
(
rowFESpace_
->
getBasisFcts
());
}
else
{
}
else
{
...
@@ -111,10 +109,10 @@ namespace AMDiS {
...
@@ -111,10 +109,10 @@ namespace AMDiS {
Mesh
*
mesh
=
matrix
->
getRowFESpace
()
->
getMesh
();
Mesh
*
mesh
=
matrix
->
getRowFESpace
()
->
getMesh
();
associated
_
=
mesh
->
getPeriodicAssociations
()[
boundaryType
];
associated
=
mesh
->
getPeriodicAssociations
()[
boundaryType
];
TEST_EXIT
(
associated
_
)(
"
n
o associations for periodic boundary condition %d
\n
"
,
TEST_EXIT
(
associated
)(
"
N
o associations for periodic boundary condition %d
!
\n
"
,
boundaryType
);
boundaryType
);
const
BasisFunction
*
basFcts
=
rowFESpace
->
getBasisFcts
();
const
BasisFunction
*
basFcts
=
rowFESpace
->
getBasisFcts
();
neighIndices_
=
new
DegreeOfFreedom
[
basFcts
->
getNumber
()];
neighIndices_
=
new
DegreeOfFreedom
[
basFcts
->
getNumber
()];
...
@@ -131,7 +129,6 @@ namespace AMDiS {
...
@@ -131,7 +129,6 @@ namespace AMDiS {
int
dim
=
rowFESpace
->
getMesh
()
->
getDim
();
int
dim
=
rowFESpace
->
getMesh
()
->
getDim
();
if
(
dim
>
1
)
{
if
(
dim
>
1
)
{
int
i
,
j
;
DOFAdmin
*
admin
=
rowFESpace
->
getAdmin
();
DOFAdmin
*
admin
=
rowFESpace
->
getAdmin
();
FixVec
<
int
,
WORLD
>
elFace
(
dim
,
NO_INIT
);
FixVec
<
int
,
WORLD
>
elFace
(
dim
,
NO_INIT
);
...
@@ -157,24 +154,25 @@ namespace AMDiS {
...
@@ -157,24 +154,25 @@ namespace AMDiS {
index
=
element
->
getVertexOfPosition
(
sideGeoIndex
,
index
=
element
->
getVertexOfPosition
(
sideGeoIndex
,
side
,
side
,
vertex
);
vertex
);
periodicDOFs
[
vertex
]
=
(
*
associated
_
)[
dofIndices
[
index
]];
periodicDOFs
[
vertex
]
=
(
*
associated
)[
dofIndices
[
index
]];
}
}
Element
*
neigh
=
elInfo
->
getNeighbour
(
side
);
Element
*
neigh
=
elInfo
->
getNeighbour
(
side
);
basFcts
->
getLocalIndices
(
neigh
,
admin
,
neighIndices_
);
basFcts
->
getLocalIndices
(
neigh
,
admin
,
neighIndices_
);
int
oppVertex
=
0
;
int
oppVertex
=
0
;
for
(
i
=
0
;
i
<
dim
+
1
;
i
++
)
{
for
(
int
i
=
0
;
i
<
dim
+
1
;
i
++
)
{
// get vertex permutation
// get vertex permutation
if
(
i
==
side
)
{
if
(
i
==
side
)
{
vertexPermutation
[
i
]
=
0
;
vertexPermutation
[
i
]
=
0
;
}
else
{
}
else
{
DegreeOfFreedom
periodicDOF
=
DegreeOfFreedom
periodicDOF
=
periodicDOFs
[
element
->
getPositionOfVertex
(
side
,
i
)];
periodicDOFs
[
element
->
getPositionOfVertex
(
side
,
i
)];
for
(
j
=
0
;
j
<
dim
+
1
;
j
++
)
{
for
(
int
j
=
0
;
j
<
dim
+
1
;
j
++
)
if
(
neigh
->
getDOF
(
j
,
0
)
==
periodicDOF
)
break
;
if
(
neigh
->
getDOF
(
j
,
0
)
==
periodicDOF
)
}
break
;
vertexPermutation
[
i
]
=
j
;
vertexPermutation
[
i
]
=
j
;
}
}
oppVertex
+=
i
-
vertexPermutation
[
i
];
oppVertex
+=
i
-
vertexPermutation
[
i
];
...
@@ -186,11 +184,9 @@ namespace AMDiS {
...
@@ -186,11 +184,9 @@ namespace AMDiS {
periodicDOFMapping_
->
getDOFPermutation
(
vertexPermutation
);
periodicDOFMapping_
->
getDOFPermutation
(
vertexPermutation
);
// set associated dofs
// set associated dofs
for
(
i
=
0
;
i
<
num
;
i
++
)
{
for
(
int
i
=
0
;
i
<
num
;
i
++
)
if
((
*
(
basFcts
->
getCoords
(
i
)))[
side
]
==
0
)
{
if
((
*
(
basFcts
->
getCoords
(
i
)))[
side
]
==
0
)
(
*
associated_
)[
dofIndices
[
i
]]
=
neighIndices_
[
dofPermutation
[
i
]];
(
*
associated
)[
dofIndices
[
i
]]
=
neighIndices_
[
dofPermutation
[
i
]];
}
}
}
}
}
}
}
}
...
@@ -201,8 +197,6 @@ namespace AMDiS {
...
@@ -201,8 +197,6 @@ namespace AMDiS {
{
{
FUNCNAME
(
"PeriodicBC::exitMatrix()"
);
FUNCNAME
(
"PeriodicBC::exitMatrix()"
);
ERROR_EXIT
(
"Not yet implemented, if you have an idea how to do it, than make it!!!
\n
"
);
TEST_EXIT
(
matrix
)(
"no matrix
\n
"
);
TEST_EXIT
(
matrix
)(
"no matrix
\n
"
);
if
(
matrix
==
masterMatrix_
)
{
if
(
matrix
==
masterMatrix_
)
{
...
@@ -212,10 +206,12 @@ namespace AMDiS {
...
@@ -212,10 +206,12 @@ namespace AMDiS {
using
namespace
mtl
;
using
namespace
mtl
;
associated_
->
print
();
std
::
cout
<<
"ASSOC = "
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
10
;
i
++
)
std
::
cout
<<
i
<<
" = "
<<
(
*
associated
)[
i
]
<<
std
::
endl
;
// Compute reorder matrix (newRow and newCol yields transposed!!!)
// Compute reorder matrix (newRow and newCol yields transposed!!!)
matrix
::
traits
::
reorder
<>::
type
R
=
matrix
::
reorder
(
*
associated
_
);
matrix
::
traits
::
reorder
<>::
type
R
=
matrix
::
reorder
(
*
associated
);
DOFMatrix
::
base_matrix_type
&
A
=
matrix
->
getBaseMatrix
(),
B
,
D
,
E
,
TR
;
DOFMatrix
::
base_matrix_type
&
A
=
matrix
->
getBaseMatrix
(),
B
,
D
,
E
,
TR
;
A
*=
0.5
;
A
*=
0.5
;
...
@@ -243,12 +239,12 @@ namespace AMDiS {
...
@@ -243,12 +239,12 @@ namespace AMDiS {
DOFIterator
<
double
>
vecIt
(
vector
,
USED_DOFS
);
DOFIterator
<
double
>
vecIt
(
vector
,
USED_DOFS
);
Mesh
*
mesh
=
vector
->
getFESpace
()
->
getMesh
();
Mesh
*
mesh
=
vector
->
getFESpace
()
->
getMesh
();
VertexVector
*
associated
_
=
mesh
->
getPeriodicAssociations
()[
boundaryType
];
VertexVector
*
associated
=
mesh
->
getPeriodicAssociations
()[
boundaryType
];
for
(
vecIt
.
reset
();
!
vecIt
.
end
();
++
vecIt
)
{
for
(
vecIt
.
reset
();
!
vecIt
.
end
();
++
vecIt
)
{
dof
=
vecIt
.
getDOFIndex
();
dof
=
vecIt
.
getDOFIndex
();
newDOF
=
(
*
associated
_
)[
dof
];
newDOF
=
(
*
associated
)[
dof
];
if
(
dof
<
newDOF
)
{
if
(
dof
<
newDOF
)
{
entry
=
((
*
vector
)[
dof
]
+
(
*
vector
)[
newDOF
])
*
0.5
;
entry
=
((
*
vector
)[
dof
]
+
(
*
vector
)[
newDOF
])
*
0.5
;
...
...
AMDiS/src/PeriodicBC.h
View file @
70789436
...
@@ -34,7 +34,8 @@ namespace AMDiS {
...
@@ -34,7 +34,8 @@ namespace AMDiS {
class
DimVecLess
class
DimVecLess
{
{
public:
public:
bool
operator
()(
const
DimVec
<
T
>
&
v1
,
const
DimVec
<
T
>
&
v2
)
{
bool
operator
()(
const
DimVec
<
T
>
&
v1
,
const
DimVec
<
T
>
&
v2
)
{
int
size
=
v1
.
getSize
();
int
size
=
v1
.
getSize
();
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
if
(
v1
[
i
]
<
v2
[
i
])
if
(
v1
[
i
]
<
v2
[
i
])
...
@@ -43,7 +44,7 @@ namespace AMDiS {
...
@@ -43,7 +44,7 @@ namespace AMDiS {
return
false
;
return
false
;
}
}
return
false
;
return
false
;
}
;
}
};
};
class
PeriodicDOFMapping
class
PeriodicDOFMapping
...
@@ -60,7 +61,9 @@ namespace AMDiS {
...
@@ -60,7 +61,9 @@ namespace AMDiS {
protected:
protected:
const
BasisFunction
*
basFcts_
;
const
BasisFunction
*
basFcts_
;
std
::
map
<
DimVec
<
int
>
,
DegreeOfFreedom
*
,
DimVecLess
<
int
>
>
dofPermutation_
;
std
::
map
<
DimVec
<
int
>
,
DegreeOfFreedom
*
,
DimVecLess
<
int
>
>
dofPermutation_
;
std
::
map
<
DimVec
<
double
>
,
int
,
DimVecLess
<
double
>
>
indexOfCoords_
;
std
::
map
<
DimVec
<
double
>
,
int
,
DimVecLess
<
double
>
>
indexOfCoords_
;
static
std
::
vector
<
PeriodicDOFMapping
*>
mappings_
;
static
std
::
vector
<
PeriodicDOFMapping
*>
mappings_
;
...
@@ -83,18 +86,18 @@ namespace AMDiS {
...
@@ -83,18 +86,18 @@ namespace AMDiS {
void
initMatrix
(
DOFMatrix
*
matrix
);
void
initMatrix
(
DOFMatrix
*
matrix
);
void
fillBoundaryCondition
(
DOFMatrix
*
matrix
,
void
fillBoundaryCondition
(
DOFMatrix
*
matrix
,
ElInfo
*
elInfo
,
ElInfo
*
elInfo
,
const
DegreeOfFreedom
*
dofIndices
,
const
DegreeOfFreedom
*
dofIndices
,
const
BoundaryType
*
localBound
,
const
BoundaryType
*
localBound
,
int
nBasFcts
);
int
nBasFcts
);
void
exitMatrix
(
DOFMatrix
*
matrix
);
void
exitMatrix
(
DOFMatrix
*
matrix
);
void
exitVector
(
DOFVectorBase
<
double
>*
vector
);
void
exitVector
(
DOFVectorBase
<
double
>*
vector
);
protected:
protected:
VertexVector
*
associated
_
;
VertexVector
*
associated
;
PeriodicDOFMapping
*
periodicDOFMapping_
;
PeriodicDOFMapping
*
periodicDOFMapping_
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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