Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
amdis
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Backofen, Rainer
amdis
Commits
3df2f6cc
Commit
3df2f6cc
authored
12 years ago
by
Praetorius, Simon
Browse files
Options
Downloads
Patches
Plain Diff
cahn-hilliard demo
parent
042e5dfb
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
demo/src/cahn_hilliard.cc
+99
-0
99 additions, 0 deletions
demo/src/cahn_hilliard.cc
with
99 additions
and
0 deletions
demo/src/cahn_hilliard.cc
0 → 100644
+
99
−
0
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
;
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment