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
Aland, Sebastian
amdis
Commits
3df2f6cc
Commit
3df2f6cc
authored
Apr 17, 2012
by
Praetorius, Simon
Browse files
cahn-hilliard demo
parent
042e5dfb
Changes
1
Hide whitespace changes
Inline
Side-by-side
demo/src/cahn_hilliard.cc
0 → 100644
View file @
3df2f6cc
#include
"AMDiS.h"
#include
"CouplingTimeInterface.h"
#include
"Refinement.h"
#include
"MeshFunction_Level.h"
#include
"CahnHilliard.h"
#include
"Views.h"
#include
"boost/date_time/posix_time/posix_time.hpp"
using
namespace
AMDiS
;
using
namespace
boost
::
posix_time
;
class
RefinementTimeInterface
:
public
CouplingTimeInterface
{
public:
RefinementTimeInterface
(
CahnHilliard
*
chProb_
)
:
chProb
(
chProb_
),
refFunction
(
NULL
),
refinement
(
NULL
)
{
addTimeInterface
(
chProb
);
}
~
RefinementTimeInterface
()
{
if
(
refFunction
)
delete
refFunction
;
if
(
refinement
)
delete
refinement
;
}
virtual
void
initTimeInterface
()
{
chProb
->
initTimeInterface
();
}
/// Called at the end of each timestep.
virtual
void
closeTimestep
(
AdaptInfo
*
adaptInfo
)
{
CouplingTimeInterface
::
closeTimestep
(
adaptInfo
);
refinement
->
refine
(
2
);
}
/// Set initial condition and perform initial refinement
virtual
void
solveInitialProblem
(
AdaptInfo
*
adaptInfo
)
{
refFunction
=
new
PhaseFieldRefinement
(
chProb
->
getMesh
());
refinement
=
new
RefinementLevelDOF
(
chProb
->
getProblem
(
0
)
->
getFeSpace
(),
refFunction
,
new
PhaseDOFView
<
double
>
(
chProb
->
getProblem
(
0
)
->
getSolution
()
->
getDOFVector
(
0
)));
// initial refinement
refinement
->
refine
(
0
);
// refine until interfaces is solved
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
chProb
->
solveInitialProblem
(
adaptInfo
);
refinement
->
refine
((
i
<
4
?
4
:
10
));
}
CouplingTimeInterface
::
solveInitialProblem
(
adaptInfo
);
}
protected:
CahnHilliard
*
chProb
;
PhaseFieldRefinement
*
refFunction
;
RefinementLevelDOF
*
refinement
;
};
int
main
(
int
argc
,
char
**
argv
)
{
FUNCNAME
(
"main"
);
AMDiS
::
init
(
argc
,
argv
);
CahnHilliard
chProb
(
"ch"
);
chProb
.
initialize
(
INIT_ALL
);
RefinementTimeInterface
timeInterface
(
&
chProb
);
// Adapt-Infos
AdaptInfo
adaptInfo
(
"adapt"
,
chProb
.
getNumComponents
());
AdaptInstationary
adaptInstat
(
"adapt"
,
chProb
,
adaptInfo
,
timeInterface
,
adaptInfo
);
ptime
start_time
=
microsec_clock
::
local_time
();
timeInterface
.
initTimeInterface
();
// fill operators and BC
int
error_code
=
adaptInstat
.
adapt
();
time_duration
td
=
microsec_clock
::
local_time
()
-
start_time
;
MSG
(
"elapsed time= %d sec
\n
"
,
td
.
total_seconds
());
AMDiS
::
finalize
();
return
error_code
;
};
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