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
e8983bcb
Commit
e8983bcb
authored
Dec 05, 2011
by
Thomas Witkowski
Browse files
Work on FETI-DP, Initfile parses changes due to exception throw problem when debugging.
parent
f582eb49
Changes
6
Hide whitespace changes
Inline
Side-by-side
AMDiS/src/AMDiS.cc
View file @
e8983bcb
...
...
@@ -47,7 +47,7 @@ namespace AMDiS {
if
(
string
(
argv
[
0
])
!=
"ddt"
)
Parameters
::
init
(
string
(
argv
[
1
]));
else
Parameters
::
init
(
string
(
argv
[
2
]));
Parameters
::
init
(
string
(
argv
[
1
]));
Parameters
::
readArgv
(
argc
,
argv
);
}
...
...
AMDiS/src/Initfile.cc
View file @
e8983bcb
...
...
@@ -149,7 +149,8 @@ namespace AMDiS {
posVarBegin
=
posVar
;
}
std
::
string
varName
=
inputSwap
.
substr
(
posVarBegin
+
1
,
posVarEnd
-
posVarBegin
-
1
);
std
::
string
varParam
=
checkedGet
(
varName
);
std
::
string
varParam
=
""
;
int
error_code
=
checkedGet
(
varName
,
varParam
);
// if varname is found in parameter list then replace variable by value
// otherwise throw tagNotFound exception
std
::
string
replaceName
=
inputSwap
.
substr
(
posVar
,
posVarEnd
-
posVar
+
(
posVarBegin
-
posVar
));
...
...
AMDiS/src/Initfile.h
View file @
e8983bcb
...
...
@@ -58,6 +58,12 @@ namespace AMDiS {
{}
};
struct
GetTagError
:
std
::
runtime_error
{
GetTagError
(
std
::
string
m
)
:
std
::
runtime_error
(
m
)
{}
};
template
<
typename
T
>
struct
WrongValueFormat
:
std
::
runtime_error
{
static
std
::
string
name
(
int
)
...
...
@@ -384,6 +390,8 @@ namespace AMDiS {
{
typedef
std
::
map
<
std
::
string
,
std
::
string
>
super
;
static
const
int
TAG_NOT_FOUND
=
1
;
static
const
int
TAG_NOT_FOUND_BREAK
=
2
;
/// Exceptions
struct
TagNotFound
:
std
::
invalid_argument
{
...
...
@@ -409,8 +417,9 @@ namespace AMDiS {
static
void
init
(
int
print
,
string
filename
,
const
char
*
flags
=
NULL
)
{
ERROR_EXIT
(
"Parameters::init(int,std::string,const char*) is depreciated. "
"Use Parameters::init(std::string) instead!
\n
"
);
WARNING
(
"Parameters::init(int,std::string,const char*) is depreciated. "
"Use Parameters::init(std::string) instead!
\n
"
);
init
(
filename
);
}
...
...
@@ -430,17 +439,19 @@ namespace AMDiS {
if
(
debugInfo
==
-
1
)
debugInfo
=
singlett
->
getMsgInfo
();
try
{
std
::
string
valStr
(
singlett
->
checkedGet
(
tag
));
valStr
=
trim
(
valStr
);
convert
(
valStr
,
value
);
if
(
debugInfo
==
2
)
{
std
::
cout
<<
"Parameter '"
<<
tag
<<
"'"
<<
" initialized with: "
<<
value
<<
std
::
endl
;
}
}
catch
(
TagNotFound
ia
)
{
if
(
debugInfo
>=
1
)
std
::
cout
<<
ia
.
what
()
<<
std
::
endl
;
std
::
string
valStr
;
int
error_code
=
singlett
->
checkedGet
(
tag
,
valStr
);
if
(
error_code
==
0
)
{
valStr
=
trim
(
valStr
);
convert
(
valStr
,
value
);
}
else
if
(
error_code
==
TAG_NOT_FOUND_BREAK
)
throw
TagNotFoundBreak
(
"required tag '"
+
tag
+
"' not found"
);
else
if
(
error_code
==
TAG_NOT_FOUND
&&
debugInfo
==
2
)
std
::
cout
<<
"there is no tag '"
+
tag
+
"'"
<<
std
::
endl
;
if
(
debugInfo
==
2
)
{
std
::
cout
<<
"Parameter '"
<<
tag
<<
"'"
<<
" initialized with: "
<<
value
<<
std
::
endl
;
}
}
...
...
@@ -449,16 +460,19 @@ namespace AMDiS {
static
InitEntry
get
(
const
std
::
string
tag
)
{
using
namespace
InitfileInternal
;
int
debugInfo
=
singlett
->
getMsgInfo
();
singlett
->
getMsgInfo
();
InitEntry
result
;
try
{
std
::
string
valStr
(
singlett
->
checkedGet
(
tag
));
valStr
=
trim
(
valStr
);
result
=
InitEntry
(
valStr
);
}
catch
(
TagNotFound
ia
)
{
if
(
debugInfo
>=
1
)
std
::
cout
<<
ia
.
what
()
<<
std
::
endl
;
}
std
::
string
valStr
;
int
error_code
=
singlett
->
checkedGet
(
tag
,
valStr
);
if
(
error_code
==
0
)
{
valStr
=
trim
(
valStr
);
result
=
InitEntry
(
valStr
);
}
else
if
(
error_code
==
TAG_NOT_FOUND_BREAK
)
throw
TagNotFoundBreak
(
"required tag '"
+
tag
+
"' not found"
);
else
if
(
error_code
==
TAG_NOT_FOUND
)
throw
TagNotFound
(
"there is no tag '"
+
tag
+
"'"
);
// exception must be thrown, because an empty object would be return otherwise
return
result
;
}
...
...
@@ -568,16 +582,18 @@ protected:
/// return the value of the given tag or throws an exception if the tag
/// does not exist
std
::
str
in
g
checkedGet
(
const
std
::
string
&
tag
)
const
in
t
checkedGet
(
const
std
::
string
&
tag
,
std
::
string
&
valStr
)
const
{
super
::
const_iterator
it
=
find
(
tag
);
if
(
it
==
end
())
{
if
(
breakOnMissingTag
==
0
||
msgInfo
<=
2
)
throw
TagNotFound
(
"there is no tag '"
+
tag
+
"'"
)
;
return
TAG_NOT_FOUND
;
else
throw
TagNotFoundBreak
(
"required tag '"
+
tag
+
"' not found"
)
;
return
TAG_NOT_FOUND_BREAK
;
}
return
it
->
second
;
valStr
=
it
->
second
;
return
0
;
}
/// replace variables by its value defined as parameter previousely
...
...
AMDiS/src/parallel/MeshDistributor.cc
View file @
e8983bcb
...
...
@@ -168,6 +168,8 @@ namespace AMDiS {
macroElIndexTypeMap
[(
*
it
)
->
getIndex
()]
=
(
*
it
)
->
getElType
();
}
createBoundaryDofs
();
#if (DEBUG != 0)
ParallelDebug
::
writeDebugFile
(
*
this
,
debugOutputDir
+
"mpi-dbg"
,
"dat"
);
#endif
...
...
AMDiS/src/parallel/PetscSolverFeti.cc
View file @
e8983bcb
...
...
@@ -13,6 +13,7 @@
#include
"parallel/PetscSolverFeti.h"
#include
"parallel/StdMpi.h"
#include
"parallel/MpiHelper.h"
#include
"io/VtkWriter.h"
namespace
AMDiS
{
...
...
@@ -203,10 +204,13 @@ namespace AMDiS {
string
preconditionerName
=
""
;
Parameters
::
get
(
"parallel->solver->precon"
,
preconditionerName
);
if
(
preconditionerName
==
""
||
preconditionerName
==
"none"
)
{
MSG
(
"Create FETI-DP solver with no preconditioner!
\n
"
);
fetiPreconditioner
=
FETI_NONE
;
}
else
if
(
preconditionerName
==
"dirichlet"
)
{
MSG
(
"Create FETI-DP solver with Dirichlet preconditioner!
\n
"
);
fetiPreconditioner
=
FETI_DIRICHLET
;
}
else
if
(
preconditionerName
==
"lumped"
)
{
MSG
(
"Create FETI-DP solver with lumped preconditioner!
\n
"
);
fetiPreconditioner
=
FETI_LUMPED
;
}
else
{
ERROR_EXIT
(
"Preconditioner
\"
%s
\"
not available!
\n
"
,
...
...
@@ -244,7 +248,9 @@ namespace AMDiS {
// === Define all vertices on the interior boundaries of the macro mesh ===
// === to be primal variables. ===
primals
.
clear
();
/// Set of DOF indices that are considered to be primal variables.
DofIndexSet
primals
;
DofContainerSet
&
vertices
=
meshDistributor
->
getBoundaryDofInfo
().
geoDofs
[
VERTEX
];
TEST_EXIT_DBG
(
vertices
.
size
())(
"No primal vertices on this rank!
\n
"
);
...
...
@@ -329,10 +335,6 @@ namespace AMDiS {
TEST_EXIT_DBG
(
primals
.
size
()
==
globalPrimalIndex
.
size
())
(
"Number of primals %d, but number of global primals on this rank is %d!
\n
"
,
primals
.
size
(),
globalPrimalIndex
.
size
());
TEST_EXIT_DBG
(
nOverallPrimals
>
0
)
(
"There are zero primal nodes in domain!
\n
"
);
}
...
...
@@ -351,7 +353,7 @@ namespace AMDiS {
for
(
DofContainer
::
iterator
dofIt
=
it
->
second
.
begin
();
dofIt
!=
it
->
second
.
end
();
++
dofIt
)
{
// If DOF is not primal, i.e., its a dual node
if
(
primals
.
count
(
**
dofIt
)
==
0
)
{
if
(
globalPrimalIndex
.
count
(
**
dofIt
)
==
0
)
{
boundaryDofRanks
[
**
dofIt
].
insert
(
mpiRank
);
boundaryDofRanks
[
**
dofIt
].
insert
(
it
->
first
);
}
...
...
@@ -367,7 +369,7 @@ namespace AMDiS {
it
!=
sendDofs
.
end
();
++
it
)
for
(
DofContainer
::
iterator
dofIt
=
it
->
second
.
begin
();
dofIt
!=
it
->
second
.
end
();
++
dofIt
)
if
(
primals
.
count
(
**
dofIt
)
==
0
)
if
(
globalPrimalIndex
.
count
(
**
dofIt
)
==
0
)
stdMpi
.
getSendData
(
it
->
first
).
push_back
(
boundaryDofRanks
[
**
dofIt
]);
stdMpi
.
updateSendDataSize
();
...
...
@@ -378,7 +380,7 @@ namespace AMDiS {
bool
recvFromRank
=
false
;
for
(
DofContainer
::
iterator
dofIt
=
it
->
second
.
begin
();
dofIt
!=
it
->
second
.
end
();
++
dofIt
)
if
(
primals
.
count
(
**
dofIt
)
==
0
)
{
if
(
globalPrimalIndex
.
count
(
**
dofIt
)
==
0
)
{
recvFromRank
=
true
;
break
;
}
...
...
@@ -393,7 +395,7 @@ namespace AMDiS {
int
i
=
0
;
for
(
DofContainer
::
iterator
dofIt
=
it
->
second
.
begin
();
dofIt
!=
it
->
second
.
end
();
++
dofIt
)
if
(
primals
.
count
(
**
dofIt
)
==
0
)
if
(
globalPrimalIndex
.
count
(
**
dofIt
)
==
0
)
boundaryDofRanks
[
**
dofIt
]
=
stdMpi
.
getRecvData
(
it
->
first
)[
i
++
];
}
...
...
@@ -404,7 +406,7 @@ namespace AMDiS {
globalDualIndex
.
clear
();
int
nRankAllDofs
=
meshDistributor
->
getFeSpace
()
->
getAdmin
()
->
getUsedDofs
();
nRankB
=
nRankAllDofs
-
primals
.
size
();
nRankB
=
nRankAllDofs
-
globalPrimalIndex
.
size
();
nOverallB
=
0
;
rStartB
=
0
;
mpi
::
getDofNumbering
(
meshDistributor
->
getMpiComm
(),
...
...
@@ -416,7 +418,7 @@ namespace AMDiS {
int
nRankDuals
=
0
;
for
(
DofContainer
::
iterator
it
=
allBoundaryDofs
.
begin
();
it
!=
allBoundaryDofs
.
end
();
++
it
)
{
if
(
primals
.
count
(
**
it
)
==
0
)
{
if
(
globalPrimalIndex
.
count
(
**
it
)
==
0
)
{
duals
.
insert
(
**
it
);
globalDualIndex
[
**
it
]
=
rStartB
+
nRankInteriorDofs
+
nRankDuals
;
nRankDuals
++
;
...
...
@@ -473,7 +475,7 @@ namespace AMDiS {
it
!=
sendDofs
.
end
();
++
it
)
for
(
DofContainer
::
iterator
dofIt
=
it
->
second
.
begin
();
dofIt
!=
it
->
second
.
end
();
++
dofIt
)
{
if
(
primals
.
count
(
**
dofIt
)
==
0
)
{
if
(
globalPrimalIndex
.
count
(
**
dofIt
)
==
0
)
{
TEST_EXIT_DBG
(
dofFirstLagrange
.
count
(
**
dofIt
))(
"Should not happen!
\n
"
);
stdMpi
.
getSendData
(
it
->
first
).
push_back
(
dofFirstLagrange
[
**
dofIt
]);
}
...
...
@@ -486,7 +488,7 @@ namespace AMDiS {
bool
recvData
=
false
;
for
(
DofContainer
::
iterator
dofIt
=
it
->
second
.
begin
();
dofIt
!=
it
->
second
.
end
();
++
dofIt
)
if
(
primals
.
count
(
**
dofIt
)
==
0
)
{
if
(
globalPrimalIndex
.
count
(
**
dofIt
)
==
0
)
{
recvData
=
true
;
break
;
}
...
...
@@ -501,7 +503,7 @@ namespace AMDiS {
it
!=
recvDofs
.
end
();
++
it
)
{
int
counter
=
0
;
for
(
unsigned
int
i
=
0
;
i
<
it
->
second
.
size
();
i
++
)
if
(
primals
.
count
(
*
(
it
->
second
[
i
]))
==
0
)
if
(
globalPrimalIndex
.
count
(
*
(
it
->
second
[
i
]))
==
0
)
dofFirstLagrange
[
*
(
it
->
second
[
i
])]
=
stdMpi
.
getRecvData
(
it
->
first
)[
counter
++
];
}
}
...
...
@@ -519,8 +521,8 @@ namespace AMDiS {
// === without defining a correct index. ===
for
(
int
i
=
0
;
i
<
admin
->
getUsedSize
();
i
++
)
if
(
admin
->
isDofFree
(
i
)
==
false
&&
primals
.
count
(
i
)
==
0
)
if
(
duals
.
count
(
i
)
==
0
&&
primals
.
count
(
i
)
==
0
)
if
(
admin
->
isDofFree
(
i
)
==
false
&&
globalPrimalIndex
.
count
(
i
)
==
0
)
if
(
duals
.
count
(
i
)
==
0
&&
globalPrimalIndex
.
count
(
i
)
==
0
)
localIndexB
[
i
]
=
-
1
;
...
...
@@ -534,7 +536,7 @@ namespace AMDiS {
}
nLocalDuals
=
duals
.
size
();
TEST_EXIT_DBG
(
nLocalInterior
+
primals
.
size
()
+
duals
.
size
()
==
TEST_EXIT_DBG
(
nLocalInterior
+
globalPrimalIndex
.
size
()
+
duals
.
size
()
==
static_cast
<
unsigned
int
>
(
admin
->
getUsedDofs
()))
(
"Should not happen!
\n
"
);
...
...
@@ -610,6 +612,8 @@ namespace AMDiS {
FUNCNAME
(
"PetscSolverFeti::createSchurPrimal()"
);
if
(
schurPrimalSolver
==
0
)
{
MSG
(
"Create iterative schur primal solver!
\n
"
);
schurPrimalData
.
mat_primal_primal
=
&
mat_primal_primal
;
schurPrimalData
.
mat_primal_b
=
&
mat_primal_b
;
schurPrimalData
.
mat_b_primal
=
&
mat_b_primal
;
...
...
@@ -635,6 +639,8 @@ namespace AMDiS {
KSPSetOptionsPrefix
(
ksp_schur_primal
,
"solver_sp_"
);
KSPSetFromOptions
(
ksp_schur_primal
);
}
else
{
MSG
(
"Create direct schur primal solver!
\n
"
);
TEST_EXIT
(
ksp_b
)(
"No solver object for local problem!
\n
"
);
double
wtime
=
MPI
::
Wtime
();
...
...
@@ -832,6 +838,8 @@ namespace AMDiS {
PCShellSetContext
(
precon_feti
,
static_cast
<
void
*>
(
&
fetiLumpedPreconData
));
PCShellSetApply
(
precon_feti
,
petscApplyFetiLumpedPrecon
);
break
;
default:
break
;
}
}
...
...
@@ -884,6 +892,8 @@ namespace AMDiS {
VecDestroy
(
&
fetiLumpedPreconData
.
tmp_vec_duals0
);
VecDestroy
(
&
fetiLumpedPreconData
.
tmp_vec_duals1
);
break
;
default:
break
;
}
}
...
...
@@ -894,6 +904,12 @@ namespace AMDiS {
{
FUNCNAME
(
"PetscSolverFeti::recoverSolution()"
);
PetscScalar
*
ttt
;
VecGetArray
(
vec_sol_primal
,
&
ttt
);
for
(
int
i
=
0
;
i
<
nRankPrimals
;
i
++
)
MSG
(
"PRIM VAL = %f
\n
"
,
ttt
[
i
*
3
+
1
]);
VecRestoreArray
(
vec_sol_primal
,
&
ttt
);
// === Get local part of the solution for B variables. ===
PetscScalar
*
localSolB
;
...
...
@@ -912,6 +928,8 @@ namespace AMDiS {
for
(
DofMapping
::
iterator
it
=
globalPrimalIndex
.
begin
();
it
!=
globalPrimalIndex
.
end
();
++
it
)
{
for
(
int
i
=
0
;
i
<
nComponents
;
i
++
)
{
MSG
(
"COPY GLOBAL PRIM %d of COMP %d TO LOCAL TMP %d
\n
"
,
it
->
second
,
i
,
counter
);
globalIsIndex
.
push_back
(
it
->
second
*
nComponents
+
i
);
localIsIndex
.
push_back
(
counter
++
);
}
...
...
@@ -948,6 +966,9 @@ namespace AMDiS {
PetscScalar
*
localSolPrimal
;
VecGetArray
(
local_sol_primal
,
&
localSolPrimal
);
for
(
int
i
=
0
;
i
<
globalPrimalIndex
.
size
();
i
++
)
MSG
(
"TEST VAL %f
\n
"
,
localSolPrimal
[
i
*
3
+
1
]);
// === And copy from PETSc local vectors to the DOF vectors. ===
...
...
@@ -963,12 +984,16 @@ namespace AMDiS {
int
counter
=
0
;
for
(
DofMapping
::
iterator
it
=
globalPrimalIndex
.
begin
();
it
!=
globalPrimalIndex
.
end
();
++
it
)
{
if
(
i
==
1
)
MSG
(
"AND SET THE VAL OF DOF %d TO VAL %f
\n
"
,
it
->
first
,
localSolPrimal
[
counter
*
nComponents
+
i
]);
dofVec
[
it
->
first
]
=
localSolPrimal
[
counter
*
nComponents
+
i
];
counter
++
;
}
}
MSG
(
"VAL BOUNDS: %f %f
\n
"
,
vec
.
getDOFVector
(
1
)
->
min
(),
vec
.
getDOFVector
(
1
)
->
max
());
VecRestoreArray
(
vec_sol_b
,
&
localSolB
);
VecRestoreArray
(
local_sol_primal
,
&
localSolPrimal
);
...
...
@@ -1076,7 +1101,7 @@ namespace AMDiS {
for
(
cursor_type
cursor
=
begin
<
row
>
((
*
mat
)[
i
][
j
]
->
getBaseMatrix
()),
cend
=
end
<
row
>
((
*
mat
)[
i
][
j
]
->
getBaseMatrix
());
cursor
!=
cend
;
++
cursor
)
{
bool
rowPrimal
=
primals
.
count
(
*
cursor
)
!=
0
;
bool
rowPrimal
=
globalPrimalIndex
.
count
(
*
cursor
)
!=
0
;
cols
.
clear
();
colsOther
.
clear
();
...
...
@@ -1093,7 +1118,7 @@ namespace AMDiS {
for
(
icursor_type
icursor
=
begin
<
nz
>
(
cursor
),
icend
=
end
<
nz
>
(
cursor
);
icursor
!=
icend
;
++
icursor
)
{
bool
colPrimal
=
primals
.
count
(
col
(
*
icursor
))
!=
0
;
bool
colPrimal
=
globalPrimalIndex
.
count
(
col
(
*
icursor
))
!=
0
;
if
(
colPrimal
)
{
// Column is a primal variable.
...
...
@@ -1242,6 +1267,8 @@ namespace AMDiS {
}
}
break
;
default:
break
;
}
}
}
...
...
@@ -1323,7 +1350,7 @@ namespace AMDiS {
DOFVector
<
double
>::
Iterator
dofIt
(
vec
->
getDOFVector
(
i
),
USED_DOFS
);
for
(
dofIt
.
reset
();
!
dofIt
.
end
();
++
dofIt
)
{
int
index
=
dofIt
.
getDOFIndex
();
if
(
primals
.
count
(
index
))
{
if
(
globalPrimalIndex
.
count
(
index
))
{
TEST_EXIT_DBG
(
globalPrimalIndex
.
count
(
index
))
(
"Should not happen!
\n
"
);
...
...
@@ -1520,7 +1547,9 @@ namespace AMDiS {
solveReducedFetiMatrix
(
vec
);
// printStatistics();
VtkWriter
::
writeFile
(
&
vec
,
"test-before.vtu"
);
MeshDistributor
::
globalMeshDistributor
->
synchVector
(
vec
);
VtkWriter
::
writeFile
(
&
vec
,
"test-after.vtu"
);
}
...
...
AMDiS/src/parallel/PetscSolverFeti.h
View file @
e8983bcb
...
...
@@ -255,9 +255,6 @@ namespace AMDiS {
/// Number of components in the PDE to be solved.
int
nComponents
;
/// Set of DOF indices that are considered to be primal variables.
DofIndexSet
primals
;
/// Mapping from primal DOF indices to a global index of primals.
DofMapping
globalPrimalIndex
;
...
...
Write
Preview
Supports
Markdown
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