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
Snippets
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
iwr
amdis
Commits
013c2859
Commit
013c2859
authored
9 years ago
by
Praetorius, Simon
Browse files
Options
Downloads
Patches
Plain Diff
allow lambda-functions in dirichlet BC
parent
d2aafda1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
AMDiS/src/DirichletBC.hh
+156
-0
156 additions, 0 deletions
AMDiS/src/DirichletBC.hh
with
156 additions
and
0 deletions
AMDiS/src/DirichletBC.hh
0 → 100644
+
156
−
0
View file @
013c2859
/******************************************************************************
*
* 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 Vey, Thomas Witkowski, Andreas Naumann, 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.
*
*
* This file is part of AMDiS
*
* See also license.opensource.txt in the distribution.
*
******************************************************************************/
#include
"ElInfo.h"
#include
"BasisFunction.h"
#include
"DOFVector.h"
#include
"DOFMatrix.h"
namespace
AMDiS
{
template
<
class
Tag
>
DirichletBC
<
Tag
>::
DirichletBC
(
BoundaryType
type
,
AbstractFunction
<
double
,
WorldVector
<
double
>
>
*
fct
,
const
FiniteElemSpace
*
rowFeSpace
,
const
FiniteElemSpace
*
colFeSpace
,
bool
apply
)
:
BoundaryCondition
(
type
,
rowFeSpace
,
colFeSpace
),
container
(
fct
),
applyBC
(
apply
)
{}
#if __cplusplus > 199711L
template
<
class
Tag
>
DirichletBC
<
Tag
>::
DirichletBC
(
BoundaryType
type
,
std
::
function
<
double
(
WorldVector
<
double
>
)
>
fct
,
const
FiniteElemSpace
*
rowFeSpace
,
const
FiniteElemSpace
*
colFeSpace
,
bool
apply
)
:
BoundaryCondition
(
type
,
rowFeSpace
,
colFeSpace
),
container
(
fct
),
applyBC
(
apply
)
{}
#endif
template
<
class
Tag
>
DirichletBC
<
Tag
>::
DirichletBC
(
BoundaryType
type
,
DOFVectorBase
<
double
>
*
vec
,
bool
apply
)
:
BoundaryCondition
(
type
,
vec
->
getFeSpace
(),
vec
->
getFeSpace
()),
container
(
vec
),
applyBC
(
apply
)
{}
template
<
class
Tag
>
void
DirichletBC
<
Tag
>::
fillBoundaryCondition
(
DOFMatrix
*
matrix
,
ElInfo
*
elInfo
,
const
DegreeOfFreedom
*
dofIndices
,
const
BoundaryType
*
localBound
,
int
nBasFcts
)
{
FUNCNAME_DBG
(
"DirichletBC::fillBoundaryCondition()"
);
TEST_EXIT_DBG
(
matrix
->
getRowFeSpace
()
==
rowFeSpace
)(
"invalid row fe space
\n
"
);
}
template
<
class
Tag
>
void
DirichletBC
<
Tag
>::
fillBoundaryCondition
(
DOFVectorBase
<
double
>*
vector
,
ElInfo
*
elInfo
,
const
DegreeOfFreedom
*
dofIndices
,
const
BoundaryType
*
localBound
,
int
nBasFcts
)
{
FUNCNAME_DBG
(
"DirichletBC::fillBoundaryCondition()"
);
TEST_EXIT_DBG
(
vector
->
getFeSpace
()
==
rowFeSpace
)(
"invalid row fe space
\n
"
);
fillBC
(
Tag
(),
vector
,
elInfo
,
dofIndices
,
localBound
,
nBasFcts
);
}
template
<
class
Tag
>
void
DirichletBC
<
Tag
>::
fillBC
(
_value_by_abstractfunction
,
DOFVectorBase
<
double
>*
vector
,
ElInfo
*
elInfo
,
const
DegreeOfFreedom
*
dofIndices
,
const
BoundaryType
*
localBound
,
int
nBasFcts
)
{
WorldVector
<
double
>
worldCoords
;
const
BasisFunction
*
basFcts
=
rowFeSpace
->
getBasisFcts
();
for
(
int
i
=
0
;
i
<
nBasFcts
;
i
++
)
if
(
localBound
[
i
]
==
boundaryType
)
{
elInfo
->
coordToWorld
(
*
(
basFcts
->
getCoords
(
i
)),
worldCoords
);
double
value
=
container
.
value
(
worldCoords
);
vector
->
setDirichletDofValue
(
dofIndices
[
i
],
value
);
(
*
vector
)[
dofIndices
[
i
]]
=
value
;
}
}
// c++11 std::function of lambda-functions
template
<
class
Tag
>
void
DirichletBC
<
Tag
>::
fillBC
(
_value_by_function
,
DOFVectorBase
<
double
>*
vector
,
ElInfo
*
elInfo
,
const
DegreeOfFreedom
*
dofIndices
,
const
BoundaryType
*
localBound
,
int
nBasFcts
)
{
WorldVector
<
double
>
worldCoords
;
const
BasisFunction
*
basFcts
=
rowFeSpace
->
getBasisFcts
();
for
(
int
i
=
0
;
i
<
nBasFcts
;
i
++
)
if
(
localBound
[
i
]
==
boundaryType
)
{
elInfo
->
coordToWorld
(
*
(
basFcts
->
getCoords
(
i
)),
worldCoords
);
double
value
=
container
.
value
(
worldCoords
);
vector
->
setDirichletDofValue
(
dofIndices
[
i
],
value
);
(
*
vector
)[
dofIndices
[
i
]]
=
value
;
}
}
template
<
class
Tag
>
void
DirichletBC
<
Tag
>::
fillBC
(
_value_by_dofvector
,
DOFVectorBase
<
double
>*
vector
,
ElInfo
*
elInfo
,
const
DegreeOfFreedom
*
dofIndices
,
const
BoundaryType
*
localBound
,
int
nBasFcts
)
{
for
(
int
i
=
0
;
i
<
nBasFcts
;
i
++
)
if
(
localBound
[
i
]
==
boundaryType
)
{
double
value
=
(
*
container
.
value
)[
dofIndices
[
i
]];
vector
->
setDirichletDofValue
(
dofIndices
[
i
],
value
);
(
*
vector
)[
dofIndices
[
i
]]
=
value
;
}
}
template
<
class
Tag
>
void
DirichletBC
<
Tag
>::
initVector
(
DOFVectorBase
<
double
>*
vec
)
{
if
(
dynamic_cast
<
DOFVector
<
double
>*>
(
vec
))
dynamic_cast
<
DOFVector
<
double
>*>
(
vec
)
->
getDirichletValues
().
clear
();
}
}
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