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
Backofen, Rainer
amdis
Commits
91522c81
Commit
91522c81
authored
Nov 19, 2010
by
Naumann, Andreas
Browse files
removed old demos
parent
eb6e0d38
Changes
6
Hide whitespace changes
Inline
Side-by-side
demo/CMakeLists.txt
View file @
91522c81
...
...
@@ -11,38 +11,9 @@ if(AMDiS_FOUND)
SET
(
BASIS_LIBS
${
AMDiS_LIBRARIES
}
)
endif
(
AMDiS_FOUND
)
option
(
USE_PARALLEL
"check if the parallel demo are also used"
false
)
#option(USE_OPENMP "check if amdis is compiled with openmp" false)
if
(
USE_PARALLEL
)
#Message("look for mpi package")
find_package
(
MPI REQUIRED
)
# if(NOT MPI_FOUND)
# Message(ERROR_FATAL "Mpi not found")
# endif(NOT MPI_FOUND)
INCLUDE
(
CMakeForceCompiler
)
CMAKE_FORCE_CXX_COMPILER
(
mpicxx
"MPI C++ Compiler"
)
CMAKE_FORCE_C_COMPILER
(
mpicc
"MPI C Compiler"
)
SET
(
PARALLEL_ELLIPT_SRC src/parallelellipt.cc
)
SET
(
PARALLEL_HEAT_SRC src/parallelheat.cc
)
add_executable
(
parallelellipt
${
PARALLEL_ELLIPT_SRC
}
)
add_executable
(
parallelheat
${
PARALLEL_HEAT_SRC
}
)
target_link_libraries
(
parallelellipt
${
BASIS_LIBS
}
)
target_link_libraries
(
parallelheat
${
BASIS_LIBS
}
)
endif
(
USE_PARALLEL
)
set
(
DONTBUILD
"couple"
"parallelellipt"
"parallelheat"
)
file
(
GLOB sources src/*.cc
)
foreach
(
s
${
sources
}
)
get_filename_component
(
swe
${
s
}
NAME_WE
)
list
(
FIND DONTBUILD
${
swe
}
DBUILD
)
if
(
${
DBUILD
}
EQUAL -1
)
add_executable
(
${
swe
}
${
s
}
)
target_link_libraries
(
${
swe
}
${
BASIS_LIBS
}
)
endif
()
add_executable
(
${
swe
}
${
s
}
)
target_link_libraries
(
${
swe
}
${
BASIS_LIBS
}
)
endforeach
(
s
)
demo/Makefile
View file @
91522c81
...
...
@@ -96,27 +96,6 @@ PERIODIC_OFILES = periodic.o
periodic
:
$(PERIODIC_OFILES)
$(LINK)
$(CPPFLAGS)
$(LDFLAGS)
-o
periodic
$(INCLUDES)
$(PERIODIC_OFILES)
$(LIBS)
# ===== parallelellipt =======================================================
PARALLELELLIPT_OFILES
=
parallelellipt.o
parallelellipt
:
$(PARALLELELLIPT_OFILES)
$(LINK)
$(CPPFLAGS)
-o
parallelellipt
$(PARALLELELLIPT_OFILES)
$(LIBS)
$(PARMETIS_LIB)
# ===== parallelheat =======================================================
PARALLELHEAT_OFILES
=
parallelheat.o
parallelheat
:
$(PARALLELHEAT_OFILES)
$(LINK)
$(CPPFLAGS)
-o
parallelheat
$(PARALLELHEAT_OFILES)
$(LIBS)
$(PARMETIS_LIB)
# ===== couple ============================================================
COUPLE_OFILES
=
couple.o
couple
:
$(COUPLE_OFILES)
$(LINK)
$(CPPFLAGS)
-o
couple
$(COUPLE_OFILES)
$(LIBS)
# ===== neumann ============================================================
NEUMANN_OFILES
=
neumann.o
...
...
demo/Makefile_libtool
View file @
91522c81
...
...
@@ -96,27 +96,6 @@ PERIODIC_OFILES = periodic.o
periodic: $(PERIODIC_OFILES)
$(LINK) $(CPPFLAGS) $(LDFLAGS) -o periodic $(INCLUDES) $(PERIODIC_OFILES) $(LIBS)
# ===== parallelellipt =======================================================
PARALLELELLIPT_OFILES = parallelellipt.o
parallelellipt: $(PARALLELELLIPT_OFILES)
$(LINK) $(CPPFLAGS) -o parallelellipt $(PARALLELELLIPT_OFILES) $(LIBS) $(PARMETIS_LIB)
# ===== parallelheat =======================================================
PARALLELHEAT_OFILES = parallelheat.o
parallelheat: $(PARALLELHEAT_OFILES)
$(LINK) $(CPPFLAGS) -o parallelheat $(PARALLELHEAT_OFILES) $(LIBS) $(PARMETIS_LIB)
# ===== couple ============================================================
COUPLE_OFILES = couple.o
couple: $(COUPLE_OFILES)
$(LINK) $(CPPFLAGS) -o couple $(COUPLE_OFILES) $(LIBS)
# ===== neumann ============================================================
NEUMANN_OFILES = neumann.o
...
...
demo/src/couple.cc
deleted
100644 → 0
View file @
eb6e0d38
#include
"AMDiS.h"
using
namespace
std
;
using
namespace
AMDiS
;
class
G
:
public
AbstractFunction
<
double
,
WorldVector
<
double
>
>
{
public:
double
operator
()(
const
WorldVector
<
double
>&
x
)
const
{
return
exp
(
-
10.0
*
(
x
*
x
));
}
};
class
F
:
public
AbstractFunction
<
double
,
WorldVector
<
double
>
>
{
public:
F
(
int
degree
)
:
AbstractFunction
<
double
,
WorldVector
<
double
>
>
(
degree
)
{}
double
operator
()(
const
WorldVector
<
double
>&
x
)
const
{
int
dow
=
x
.
getSize
();
double
r2
=
(
x
*
x
);
double
ux
=
exp
(
-
10.0
*
r2
);
return
-
(
400.0
*
r2
-
20.0
*
dow
)
*
ux
;
}
};
class
MyCoupledIteration
:
public
ProblemIterationInterface
{
public:
MyCoupledIteration
(
ProblemStatBase
*
prob1
,
ProblemStatBase
*
prob2
)
:
problem1
(
prob1
),
problem2
(
prob2
),
name
(
"MyCoupledIteration"
)
{}
void
beginIteration
(
AdaptInfo
*
adaptInfo
)
{
FUNCNAME
(
"StandardProblemIteration::beginIteration()"
);
MSG
(
"
\n
"
);
MSG
(
"begin of iteration number: %d
\n
"
,
adaptInfo
->
getSpaceIteration
()
+
1
);
MSG
(
"=============================
\n
"
);
}
void
endIteration
(
AdaptInfo
*
adaptInfo
)
{
FUNCNAME
(
"StandardProblemIteration::endIteration()"
);
MSG
(
"
\n
"
);
MSG
(
"end of iteration number: %d
\n
"
,
adaptInfo
->
getSpaceIteration
()
+
1
);
MSG
(
"=============================
\n
"
);
}
Flag
oneIteration
(
AdaptInfo
*
adaptInfo
,
Flag
toDo
=
FULL_ITERATION
)
{
Flag
flag
,
markFlag
;
if
(
toDo
.
isSet
(
MARK
))
markFlag
=
problem1
->
markElements
(
adaptInfo
);
if
(
toDo
.
isSet
(
ADAPT
)
&&
markFlag
.
isSet
(
MESH_REFINED
))
flag
=
problem1
->
refineMesh
(
adaptInfo
);
if
(
toDo
.
isSet
(
BUILD
))
problem1
->
buildAfterCoarsen
(
adaptInfo
,
markFlag
);
if
(
toDo
.
isSet
(
SOLVE
))
problem1
->
solve
(
adaptInfo
);
if
(
toDo
.
isSet
(
BUILD
))
problem2
->
buildAfterCoarsen
(
adaptInfo
,
markFlag
);
if
(
toDo
.
isSet
(
SOLVE
))
problem2
->
solve
(
adaptInfo
);
if
(
toDo
.
isSet
(
ESTIMATE
))
problem1
->
estimate
(
adaptInfo
);
return
flag
;
}
int
getNumProblems
()
{
return
2
;
}
ProblemStatBase
*
getProblem
(
int
number
=
0
)
{
FUNCNAME
(
"CoupledIteration::getProblem()"
);
if
(
number
==
0
)
return
problem1
;
if
(
number
==
1
)
return
problem2
;
ERROR_EXIT
(
"invalid problem number
\n
"
);
return
NULL
;
}
const
std
::
string
&
getName
()
{
return
name
;
}
void
serialize
(
std
::
ostream
&
)
{}
void
deserialize
(
std
::
istream
&
)
{}
private:
ProblemStatBase
*
problem1
;
ProblemStatBase
*
problem2
;
std
::
string
name
;
};
class
Identity
:
public
AbstractFunction
<
double
,
double
>
{
public:
Identity
(
int
degree
)
:
AbstractFunction
<
double
,
double
>
(
degree
)
{}
double
operator
()(
const
double
&
x
)
const
{
return
x
;
}
};
int
main
(
int
argc
,
char
*
argv
[])
{
FUNCNAME
(
"main"
);
TEST_EXIT
(
argc
==
2
)(
"usage: couple initfile
\n
"
);
Parameters
::
init
(
true
,
argv
[
1
]);
// ===== create and init the first problem =====
ProblemScal
problem1
(
"problem1"
);
problem1
.
initialize
(
INIT_ALL
);
// ===== create and init the second problem =====
Flag
initFlag
=
INIT_FE_SPACE
|
INIT_SYSTEM
|
INIT_SOLVER
|
INIT_FILEWRITER
;
Flag
adoptFlag
=
CREATE_MESH
|
INIT_MESH
;
ProblemScal
problem2
(
"problem2"
);
problem2
.
initialize
(
initFlag
,
&
problem1
,
adoptFlag
);
// ===== create operators for problem1 =====
Operator
matrixOperator1
(
problem1
.
getFeSpace
());
matrixOperator1
.
addSecondOrderTerm
(
new
Laplace_SOT
);
problem1
.
addMatrixOperator
(
&
matrixOperator1
);
int
degree
=
problem1
.
getFeSpace
()
->
getBasisFcts
()
->
getDegree
();
Operator
rhsOperator1
(
problem1
.
getFeSpace
());
rhsOperator1
.
addZeroOrderTerm
(
new
CoordsAtQP_ZOT
(
new
F
(
degree
)));
problem1
.
addVectorOperator
(
&
rhsOperator1
);
// ===== create operators for problem2 =====
Operator
matrixOperator2
(
problem2
.
getFeSpace
());
matrixOperator2
.
addZeroOrderTerm
(
new
Simple_ZOT
);
problem2
.
addMatrixOperator
(
&
matrixOperator2
);
Operator
rhsOperator2
(
problem2
.
getFeSpace
());
rhsOperator2
.
addZeroOrderTerm
(
new
VecAtQP_ZOT
(
problem1
.
getSolution
(),
new
Identity
(
degree
)));
problem2
.
addVectorOperator
(
&
rhsOperator2
);
// ===== add boundary conditions for problem1 =====
problem1
.
addDirichletBC
(
1
,
new
G
);
// ===== add boundary conditions for problem1 =====
//problem2.addDirichletBC(1, new G);
// ===== create adaptation loop and iteration interface =====
AdaptInfo
*
adaptInfo
=
new
AdaptInfo
(
"couple->adapt"
,
1
);
MyCoupledIteration
coupledIteration
(
&
problem1
,
&
problem2
);
AdaptStationary
*
adapt
=
new
AdaptStationary
(
"couple->adapt"
,
&
coupledIteration
,
adaptInfo
);
// ===== start adaptation loop =====
adapt
->
adapt
();
// ===== write solution =====
problem1
.
writeFiles
(
adaptInfo
,
true
);
problem2
.
writeFiles
(
adaptInfo
,
true
);
}
demo/src/parallelellipt.cc
deleted
100644 → 0
View file @
eb6e0d38
#include
"AMDiS.h"
#include
"mpi.h"
#include
"ParallelProblem.h"
using
namespace
std
;
using
namespace
AMDiS
;
/// Dirichlet boundary function
class
G
:
public
AbstractFunction
<
double
,
WorldVector
<
double
>
>
{
public:
/// Implementation of AbstractFunction::operator().
double
operator
()(
const
WorldVector
<
double
>&
x
)
const
{
return
exp
(
-
10.0
*
(
x
*
x
));
}
};
class
GrdG
:
public
AbstractFunction
<
WorldVector
<
double
>
,
WorldVector
<
double
>
>
{
/// Implementation of AbstractFunction::operator().
WorldVector
<
double
>
operator
()(
const
WorldVector
<
double
>&
x
)
const
{
return
x
*
-
20.0
*
exp
(
-
10.0
*
(
x
*
x
));
}
};
/// RHS function
class
F
:
public
AbstractFunction
<
double
,
WorldVector
<
double
>
>
{
public:
F
(
int
degree
)
:
AbstractFunction
<
double
,
WorldVector
<
double
>
>
(
degree
)
{}
/// Implementation of AbstractFunction::operator().
double
operator
()(
const
WorldVector
<
double
>&
x
)
const
{
int
dim
=
x
.
getSize
();
double
r2
=
(
x
*
x
);
double
ux
=
exp
(
-
10.0
*
r2
);
return
-
(
400.0
*
r2
-
20.0
*
dim
)
*
ux
;
}
};
// ===== main program =====
int
main
(
int
argc
,
char
*
argv
[])
{
MPI
::
Init
(
argc
,
argv
);
FUNCNAME
(
"main"
);
// ===== check for init file =====
TEST_EXIT
(
argc
>=
2
)(
"usage: ellipt initfile
\n
"
);
// ===== init parameters =====
Parameters
::
init
(
false
,
argv
[
1
]);
// ===== create and init the scalar problem =====
ProblemScal
ellipt
(
"ellipt"
);
ellipt
.
initialize
(
INIT_ALL
);
// === parallel problem ===
std
::
vector
<
DOFVector
<
double
>*>
vectors
;
ParallelProblemScal
parallelellipt
(
"ellipt->parallel"
,
&
ellipt
,
NULL
,
vectors
);
// === create adapt info ===
AdaptInfo
*
adaptInfo
=
new
AdaptInfo
(
"ellipt->adapt"
,
1
);
// === create adapt ===
AdaptStationary
*
adapt
=
new
AdaptStationary
(
"ellipt->adapt"
,
&
parallelellipt
,
adaptInfo
);
// ===== create matrix operator =====
Operator
matrixOperator
(
ellipt
.
getFeSpace
());
matrixOperator
.
addSecondOrderTerm
(
new
Laplace_SOT
);
ellipt
.
addMatrixOperator
(
&
matrixOperator
);
// ===== create rhs operator =====
int
degree
=
ellipt
.
getFeSpace
()
->
getBasisFcts
()
->
getDegree
();
Operator
rhsOperator
(
ellipt
.
getFeSpace
());
rhsOperator
.
addZeroOrderTerm
(
new
CoordsAtQP_ZOT
(
new
F
(
degree
)));
ellipt
.
addVectorOperator
(
&
rhsOperator
);
// ===== add boundary conditions =====
ellipt
.
addDirichletBC
(
1
,
new
G
);
parallelellipt
.
initParallelization
(
adaptInfo
);
adapt
->
adapt
();
parallelellipt
.
exitParallelization
(
adaptInfo
);
MPI
::
Finalize
();
}
demo/src/parallelheat.cc
deleted
100644 → 0
View file @
eb6e0d38
#include
"AMDiS.h"
#include
"ParallelProblem.h"
#include
"mpi.h"
using
namespace
std
;
using
namespace
AMDiS
;
// ===========================================================================
// ===== function definitions ================================================
// ===========================================================================
/// Dirichlet boundary function
class
G
:
public
AbstractFunction
<
double
,
WorldVector
<
double
>
>
,
public
TimedObject
{
public:
/// Implementation of AbstractFunction::operator().
double
operator
()(
const
WorldVector
<
double
>&
argX
)
const
{
WorldVector
<
double
>
x
=
argX
;
int
dim
=
x
.
getSize
();
for
(
int
i
=
0
;
i
<
dim
;
i
++
)
x
[
i
]
-=
*
timePtr
;
return
sin
(
M_PI
*
(
*
timePtr
))
*
exp
(
-
10.0
*
(
x
*
x
));
}
}
/// RHS function
class
F
:
public
AbstractFunction
<
double
,
WorldVector
<
double
>
>
,
public
TimedObject
{
public:
F
(
int
degree
)
:
AbstractFunction
<
double
,
WorldVector
<
double
>
>
(
degree
)
{}
/// Implementation of AbstractFunction::operator().
double
operator
()(
const
WorldVector
<
double
>&
argX
)
const
{
WorldVector
<
double
>
x
=
argX
;
int
dim
=
x
.
getSize
();
for
(
int
i
=
0
;
i
<
dim
;
i
++
)
x
[
i
]
-=
*
timePtr
;
double
r2
=
(
x
*
x
);
double
ux
=
sin
(
M_PI
*
(
*
timePtr
))
*
exp
(
-
10.0
*
r2
);
double
ut
=
M_PI
*
cos
(
M_PI
*
(
*
timePtr
))
*
exp
(
-
10.0
*
r2
);
return
ut
-
(
400.0
*
r2
-
20.0
*
dim
)
*
ux
;
}
};
// ===========================================================================
// ===== instationary problem ================================================
// ===========================================================================
/// Instationary problem
class
Heat
:
public
ProblemInstatScal
{
public:
/// Constructor
Heat
(
ProblemScal
*
heatSpace
)
:
ProblemInstatScal
(
"heat"
,
heatSpace
)
{}
// ===== ProblemInstatBase methods ===================================
/// set the time in all needed functions!
void
setTime
(
AdaptInfo
*
adaptInfo
)
{
time
=
adaptInfo
->
getTime
();
tau1
=
1.0
/
adaptInfo
->
getTimestep
();
}
// ===== initial problem methods =====================================
/// Used by \ref problemInitial to solve the system of the initial problem
void
solve
(
AdaptInfo
*
adaptInfo
)
{
problemStat
->
getMesh
()
->
dofCompress
();
time
=
adaptInfo
->
getStartTime
();
problemStat
->
getSolution
()
->
interpol
(
boundaryFct
);
}
/// Used by \ref problemInitial to do error estimation for the initial problem.
void
estimate
(
AdaptInfo
*
adaptInfo
)
{
double
errMax
,
errSum
;
time
=
adaptInfo
->
getStartTime
();
errSum
=
Error
<
double
>::
L2Err
(
*
boundaryFct
,
*
(
problemStat
->
getSolution
()),
0
,
&
errMax
,
false
);
adaptInfo
->
setEstSum
(
errSum
,
0
);
}
// ===== setting methods ===============================================
/// Sets \ref boundaryFct;
void
setBoundaryFct
(
AbstractFunction
<
double
,
WorldVector
<
double
>
>
*
fct
)
{
boundaryFct
=
fct
;
}
// ===== getting methods ===============================================
/// Returns pointer to \ref tau1
double
*
getTau1Ptr
()
{
return
&
tau1
;
}
/// Returns pointer to \ref time.
double
*
getTimePtr
()
{
return
&
time
;
}
/// Returns \ref boundaryFct;
AbstractFunction
<
double
,
WorldVector
<
double
>
>
*
getBoundaryFct
()
{
return
boundaryFct
;
}
// void closeTimestep(AdaptInfo *adaptInfo) {
// ParallelProblem::writeRankMacroAndValues(problemStat->getSolution(),
// "output/debug_rank",
// adaptInfo->getTime());
// };
private:
/// 1.0 / timestep
double
tau1
;
/// time
double
time
;
/// Pointer to boundary function. Needed for initial problem.
AbstractFunction
<
double
,
WorldVector
<
double
>
>
*
boundaryFct
;
};
// ===========================================================================
// ===== main program ========================================================
// ===========================================================================
int
main
(
int
argc
,
char
**
argv
)
{
MPI
::
Init
(
argc
,
argv
);
// ===== check for init file =====
TEST_EXIT
(
argc
>=
2
)(
"usage: heat initfile
\n
"
);
// ===== init parameters =====
Parameters
::
init
(
false
,
argv
[
1
]);
// ===== create and init stationary problem =====
ProblemScal
*
heatSpace
=
new
ProblemScal
(
"heat->space"
);
heatSpace
->
initialize
(
INIT_ALL
);
// ===== create instationary problem =====
Heat
*
heat
=
new
Heat
(
heatSpace
);
heat
->
initialize
(
INIT_ALL
);
// create adapt info
AdaptInfo
*
adaptInfo
=
new
AdaptInfo
(
"heat->adapt"
);
// create initial adapt info
AdaptInfo
*
adaptInfoInitial
=
new
AdaptInfo
(
"heat->initial->adapt"
);
// create parallel problem
std
::
vector
<
DOFVector
<
double
>*>
vectors
;
ParallelProblemScal
parallelheat
(
"heat->parallel"
,
heatSpace
,
heat
,
vectors
);
// create instationary adapt
AdaptInstationary
*
adaptInstat
=
new
AdaptInstationary
(
"heat->adapt"
,
&
parallelheat
,
adaptInfo
,
&
parallelheat
,
adaptInfoInitial
);
// ===== create rhs functions =====
int
degree
=
heatSpace
->
getFeSpace
()
->
getBasisFcts
()
->
getDegree
();
F
*
rhsFct
=
new
F
(
degree
);
rhsFct
->
setTimePtr
(
heat
->
getTimePtr
());
// ===== create operators =====
double
one
=
1.0
;
double
zero
=
0.0
;
// create laplace
Operator
*
A
=
new
Operator
(
heatSpace
->
getFeSpace
());
A
->
addSecondOrderTerm
(
new
Laplace_SOT
);
A
->
setUhOld
(
heat
->
getOldSolution
());
heatSpace
->
addMatrixOperator
(
A
,
&
one
,
&
one
);
// create zero order operator
Operator
*
C
=
new
Operator
(
heatSpace
->
getFeSpace
());
C
->
addZeroOrderTerm
(
new
Simple_ZOT
);
C
->
setUhOld
(
heat
->
getOldSolution
());
heatSpace
->
addMatrixOperator
(
C
,
heat
->
getTau1Ptr
(),
heat
->
getTau1Ptr
());
heatSpace
->
addVectorOperator
(
C
,
heat
->
getTau1Ptr
(),
heat
->
getTau1Ptr
());
// create RHS operator
Operator
*
F
=
new
Operator
(
heatSpace
->
getFeSpace
());
F
->
addZeroOrderTerm
(
new
CoordsAtQP_ZOT
(
rhsFct
));
heatSpace
->
addVectorOperator
(
F
);
// ===== create boundary functions =====
G
*
boundaryFct
=
new
G
;
boundaryFct
->
setTimePtr
(
heat
->
getTimePtr
());
heat
->
setBoundaryFct
(
boundaryFct
);
heatSpace
->
addDirichletBC
(
DIRICHLET
,
boundaryFct
);
// // ===== start adaption loop =====
parallelheat
.
initParallelization
(
adaptInfo
);
adaptInstat
->
adapt
();
parallelheat
.
exitParallelization
(
adaptInfo
);
MPI
::
Finalize
();
}
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