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
6059fd73
Commit
6059fd73
authored
Aug 26, 2013
by
Praetorius, Simon
Browse files
cahnHilliard and cahnHilliard-NavierStokes demo added
parent
8e8cc8ec
Changes
4
Hide whitespace changes
Inline
Side-by-side
extensions/demo/other/CMakeLists.txt
View file @
6059fd73
...
...
@@ -52,10 +52,17 @@ endif(AMDIS_FOUND)
target_link_libraries
(
"navierStokesDd2"
${
BASIS_LIBS
}
)
set
(
navierStokesDd3 src/navierStokes_diffuseDomain3.cc
)
add_executable
(
"navierStokesDd3"
${
navierStokesDd3
}
)
target_link_libraries
(
"navierStokesDd3"
${
BASIS_LIBS
}
)
#
set(navierStokesDd3 src/navierStokes_diffuseDomain3.cc)
#
add_executable("navierStokesDd3" ${navierStokesDd3})
#
target_link_libraries("navierStokesDd3" ${BASIS_LIBS})
set
(
ch src/cahnHilliard.cc
)
add_executable
(
"ch"
${
ch
}
)
target_link_libraries
(
"ch"
${
BASIS_LIBS
}
)
set
(
chns src/cahnHilliard_navierStokes.cc
)
add_executable
(
"chns"
${
chns
}
)
target_link_libraries
(
"chns"
${
BASIS_LIBS
}
)
#create the output dir
# file(MAKE_DIRECTORY output)
extensions/demo/other/init/cahnHilliard.dat.2d
0 → 100644
View file @
6059fd73
dimension of world: 2
% =================== MESH ================================
mesh_name: mesh
mesh->macro file name: ./macro/macro.square.2d
mesh->global refinements: 0
mesh->refinement->level in outer domain: 3
mesh->refinement->level in inner domain: 3
mesh->refinement->level on interface: 11
mesh->refinement->initial level: 7
mesh->check: 0
% ============== USER-PARAMETER ==========================
ch->epsilon: 0.01
ch->gamma: 1
ch->double-well type: 0
ch->initial interface: 2
ch->ellipse->a: 0.3
ch->ellipse->b: 0.5
% =========== OUTPUT ==============================================
ch->space->output->filename: ./output/ch_
% ==================== TIMESTEPS ===============================
adapt->timestep: 1.e-2
adapt->max timestep: 1e+10
adapt->min timestep: 1e-10
adapt->start time: 0.0
adapt->end time: 100.0
% ============= PROBLEM-SPACES ==================================
ch->space->components: 2
ch->space->polynomial degree[0]: 1
ch->space->polynomial degree[1]: 1
ch->space->dim: 2
ch->space->mesh: mesh
% ================== SOLVER ======================================
ch->space->solver: direct
ch->space->solver->backend: mtl
ch->space->solver->petsc prefix: ch
ch->space->solver->symmetric strategy: 0
ch->space->solver->store symbolic: 0
ch->space->solver->max iteration: 200
ch->space->solver->tolerance: 1.e-8
ch->space->solver->info: 1
% =================== OUTPUT =========================================
ch->space->output->ParaView animation: 1
ch->space->output->ParaView format: 1
ch->space->output->write every i-th timestep: 10
ch->space->output->append index: 1
ch->space->output->index length: 9
ch->space->output->index decimals: 7
extensions/demo/other/src/cahnHilliard.cc
0 → 100644
View file @
6059fd73
/******************************************************************************
*
* Extension of AMDiS - Adaptive multidimensional simulations
*
* Copyright (C) 2013 Dresden University of Technology. All Rights Reserved.
* Web: https://fusionforge.zih.tu-dresden.de/projects/amdis
*
* Authors: Simon Praetorius et al.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
*
* See also license.opensource.txt in the distribution.
*
******************************************************************************/
#include
"AMDiS.h"
#include
"CahnHilliard.h"
#include
"Refinement.h"
#include
"MeshFunction_Level.h"
using
namespace
AMDiS
;
class
RefinementTimeInterface
:
public
CouplingTimeInterface
{
public:
// typedefs
typedef
CouplingTimeInterface
super
;
public:
// methods
/// Constructor
RefinementTimeInterface
(
CahnHilliard
*
chProb_
)
:
chProb
(
chProb_
),
refFunction
(
NULL
),
refinement
(
NULL
)
{
addTimeInterface
(
chProb
);
}
/// Destructor
~
RefinementTimeInterface
()
{
if
(
refFunction
)
{
delete
refFunction
;
refFunction
=
NULL
;
}
if
(
refinement
)
{
delete
refinement
;
refinement
=
NULL
;
}
}
/// Called before first adaption loop
virtual
void
initTimeInterface
()
{
refFunction
=
new
PhaseFieldRefinement
(
chProb
->
getMesh
());
refinement
=
new
RefinementLevelDOF
(
chProb
->
getFeSpace
(
0
),
refFunction
,
chProb
->
getSolution
()
->
getDOFVector
(
0
));
chProb
->
initTimeInterface
();
}
/// Called at the end of each timestep.
virtual
void
closeTimestep
(
AdaptInfo
*
adaptInfo
)
{
super
::
closeTimestep
(
adaptInfo
);
refinement
->
refine
(
1
);
}
/// Set initial condition and perform initial refinement
virtual
void
solveInitialProblem
(
AdaptInfo
*
adaptInfo
)
{
// initial refinement
refinement
->
refine
(
0
);
// refine until interfaces is resolved
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
chProb
->
solveInitialProblem
(
adaptInfo
);
refinement
->
refine
(
5
);
}
super
::
solveInitialProblem
(
adaptInfo
);
}
protected:
// variables
CahnHilliard
*
chProb
;
PhaseFieldRefinement
*
refFunction
;
RefinementLevelDOF
*
refinement
;
};
int
main
(
int
argc
,
char
**
argv
)
{
FUNCNAME
(
"main"
);
AMDiS
::
init
(
argc
,
argv
);
Timer
t
;
CahnHilliard
chProb
(
"ch"
);
chProb
.
initialize
(
INIT_ALL
);
RefinementTimeInterface
timeInterface
(
&
chProb
);
timeInterface
.
initTimeInterface
();
// Adapt-Infos
AdaptInfo
adaptInfo
(
"adapt"
,
chProb
.
getNumComponents
());
AdaptInstationary
adaptInstat
(
"adapt"
,
chProb
,
adaptInfo
,
timeInterface
,
adaptInfo
);
int
error_code
=
adaptInstat
.
adapt
();
MSG
(
"elapsed time= %d sec
\n
"
,
t
.
elapsed
());
AMDiS
::
finalize
();
return
error_code
;
}
extensions/demo/other/src/cahnHilliard_navierStokes.cc
0 → 100644
View file @
6059fd73
/******************************************************************************
*
* Extension of AMDiS - Adaptive multidimensional simulations
*
* Copyright (C) 2013 Dresden University of Technology. All Rights Reserved.
* Web: https://fusionforge.zih.tu-dresden.de/projects/amdis
*
* Authors: Simon Praetorius et al.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
*
* See also license.opensource.txt in the distribution.
*
******************************************************************************/
#include
"AMDiS.h"
#include
"CoupledBaseProblem.h"
#include
"CahnHilliard.h"
#include
"NavierStokes_TaylorHood.h"
#include
"Refinement.h"
#include
"MeshFunction_Level.h"
using
namespace
AMDiS
;
class
CahnHilliardNavierStokes
:
public
CoupledBaseProblem
<
ProblemStat
>
{
public:
// typedefs
typedef
CoupledBaseProblem
<
ProblemStat
>
super
;
public:
// methods
/// Constructor
CahnHilliardNavierStokes
(
std
::
string
name
,
CahnHilliard
*
chProb_
,
NavierStokes_TaylorHood
*
nsProb_
)
:
super
(
name
,
chProb_
,
nsProb_
),
chProb
(
chProb_
),
nsProb
(
nsProb_
),
refFunction
(
NULL
),
refinement
(
NULL
)
{
}
/// Destructor
~
CahnHilliardNavierStokes
()
{
if
(
refFunction
)
{
delete
refFunction
;
refFunction
=
NULL
;
}
if
(
refinement
)
{
delete
refinement
;
refinement
=
NULL
;
}
}
/// Called before first adaption loop
virtual
void
initData
()
{
refFunction
=
new
PhaseFieldRefinement
(
chProb
->
getMesh
());
refinement
=
new
RefinementLevelDOF
(
chProb
->
getFeSpace
(
0
),
refFunction
,
chProb
->
getSolution
()
->
getDOFVector
(
0
));
}
/// Called at the end of each timestep.
virtual
void
closeTimestep
(
AdaptInfo
*
adaptInfo
)
{
super
::
closeTimestep
(
adaptInfo
);
refinement
->
refine
(
1
);
}
/// Set initial condition and perform initial refinement
virtual
void
solveInitialProblem
(
AdaptInfo
*
adaptInfo
)
{
// initial refinement
refinement
->
refine
(
0
);
// refine until interfaces is resolved
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
chProb
->
solveInitialProblem
(
adaptInfo
);
refinement
->
refine
(
5
);
}
super
::
solveInitialProblem
(
adaptInfo
);
}
virtual
void
fillCouplingOperators
()
{
double
M0
=
1.0
;
Parameters
::
get
(
name
+
"->M0"
,
M0
);
// < grad(mu) * c , theta >
for
(
size_t
i
=
0
;
i
<
dow
;
i
++
)
{
Operator
*
opCGradMu
=
new
Operator
(
nsProb
->
getFeSpace
(
i
),
chProb
->
getFeSpace
(
0
));
opCGradMu
->
addTerm
(
new
VecAndPartialDerivative_ZOT
(
chProb
->
getSolution
()
->
getDOFVector
(
1
),
chProb
->
getSolution
()
->
getDOFVector
(
0
),
i
,
M0
));
nsProb
->
getProblem
(
0
)
->
addVectorOperator
(
opCGradMu
,
i
);
}
// < u * grad(c) , theta >
for
(
size_t
i
=
0
;
i
<
dow
;
i
++
)
{
Operator
*
opUGradC
=
new
Operator
(
chProb
->
getFeSpace
(
1
),
chProb
->
getFeSpace
(
0
));
opUGradC
->
addTerm
(
new
VecAndPartialDerivative_FOT
(
nsProb
->
getSolution
()
->
getDOFVector
(
i
),
i
),
GRD_PHI
);
chProb
->
getProblem
()
->
addMatrixOperator
(
opUGradC
,
1
,
0
);
}
}
protected:
// variables
CahnHilliard
*
chProb
;
NavierStokes_TaylorHood
*
nsProb
;
PhaseFieldRefinement
*
refFunction
;
RefinementLevelDOF
*
refinement
;
};
int
main
(
int
argc
,
char
**
argv
)
{
FUNCNAME
(
"main"
);
AMDiS
::
init
(
argc
,
argv
);
Timer
t
;
CahnHilliard
chProb
(
"ch"
);
NavierStokes_TaylorHood
nsProb
(
"ns"
);
CahnHilliardNavierStokes
chns
(
"chns"
,
&
chProb
,
&
nsProb
);
chns
.
initialize
(
INIT_ALL
);
chns
.
initTimeInterface
();
// Adapt-Infos
AdaptInfo
adaptInfo
(
"adapt"
,
chns
.
getNumComponents
());
AdaptInstationary
adaptInstat
(
"adapt"
,
chns
,
adaptInfo
,
chns
,
adaptInfo
);
int
error_code
=
adaptInstat
.
adapt
();
MSG
(
"elapsed time= %d sec
\n
"
,
t
.
elapsed
());
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