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
iwr
dune-vtk
Commits
abb1121f
Commit
abb1121f
authored
Jan 26, 2021
by
Praetorius, Simon
Browse files
make grid functions default constructible
parent
847c3e5d
Changes
2
Hide whitespace changes
Inline
Side-by-side
dune/vtk/gridfunctions/continuousgridfunction.hh
View file @
abb1121f
...
...
@@ -48,12 +48,14 @@ namespace Dune
using
Signature
=
Range
(
Domain
);
public:
PointDataLocalFunction
(
Factory
const
&
factory
,
std
::
vector
<
Field
>
const
&
values
,
unsigned
int
comp
)
PointDataLocalFunction
(
Factory
const
*
factory
,
std
::
vector
<
Field
>
const
*
values
,
unsigned
int
comp
)
:
factory_
(
factory
)
,
values_
(
values
)
,
comp_
(
comp
)
{}
PointDataLocalFunction
()
=
default
;
void
bind
(
LocalContext
const
&
element
)
{
lfe_
=
&
cache_
.
get
(
element
.
type
());
...
...
@@ -62,11 +64,11 @@ namespace Dune
// NOTE: assumes, that Lagrange nodes are ordered like element vertices
localValues_
.
resize
(
element
.
subEntities
(
Grid
::
dimension
));
for
(
unsigned
int
i
=
0
;
i
<
element
.
subEntities
(
Grid
::
dimension
);
++
i
)
{
unsigned
int
idx
=
factory_
.
insertionIndex
(
element
.
template
subEntity
<
Grid
::
dimension
>(
i
));
unsigned
int
idx
=
factory_
->
insertionIndex
(
element
.
template
subEntity
<
Grid
::
dimension
>(
i
));
DynamicVector
<
Field
>&
v
=
localValues_
[
i
];
v
.
resize
(
comp_
);
for
(
unsigned
int
j
=
0
;
j
<
comp_
;
++
j
)
v
[
j
]
=
values_
[
comp_
*
idx
+
j
];
v
[
j
]
=
(
*
values_
)
[
comp_
*
idx
+
j
];
}
}
...
...
@@ -90,8 +92,8 @@ namespace Dune
}
private:
Factory
const
&
factory_
;
std
::
vector
<
Field
>
const
&
values_
;
Factory
const
*
factory_
=
nullptr
;
std
::
vector
<
Field
>
const
*
values_
=
nullptr
;
unsigned
int
comp_
;
// Local Finite-Element
...
...
@@ -113,22 +115,24 @@ namespace Dune
using
Signature
=
Range
(
Domain
);
public:
CellDataLocalFunction
(
Factory
const
&
factory
,
std
::
vector
<
Field
>
const
&
values
,
unsigned
int
comp
)
CellDataLocalFunction
(
Factory
const
*
factory
,
std
::
vector
<
Field
>
const
*
values
,
unsigned
int
comp
)
:
factory_
(
factory
)
,
values_
(
values
)
,
comp_
(
comp
)
{}
CellDataLocalFunction
()
=
default
;
void
bind
(
LocalContext
const
&
element
)
{
unsigned
int
idx
=
factory_
.
insertionIndex
(
element
);
unsigned
int
idx
=
factory_
->
insertionIndex
(
element
);
// collect values on cells
DynamicVector
<
Field
>&
v
=
localValue_
;
v
.
resize
(
comp_
);
for
(
unsigned
int
j
=
0
;
j
<
comp_
;
++
j
)
v
[
j
]
=
values_
[
comp_
*
idx
+
j
];
v
[
j
]
=
(
*
values_
)
[
comp_
*
idx
+
j
];
}
void
unbind
()
...
...
@@ -140,8 +144,8 @@ namespace Dune
}
private:
Factory
const
&
factory_
;
std
::
vector
<
Field
>
const
&
values_
;
Factory
const
*
factory_
=
nullptr
;
std
::
vector
<
Field
>
const
*
values_
=
nullptr
;
unsigned
int
comp_
;
// cache of local values
...
...
@@ -159,11 +163,13 @@ namespace Dune
std
::
vector
<
std
::
uint8_t
>
const
&
/*types*/
,
std
::
vector
<
std
::
int64_t
>
const
&
/*offsets*/
,
std
::
vector
<
std
::
int64_t
>
const
&
/*connectivity*/
)
:
factory_
(
creator
.
factory
())
,
values_
(
values
)
:
factory_
(
&
creator
.
factory
())
,
values_
(
&
values
)
,
comp_
(
comp
)
{}
ContinuousGridFunction
()
=
default
;
Range
operator
()
(
Domain
const
&
global
)
const
{
DUNE_THROW
(
Dune
::
NotImplemented
,
"Evaluation in global coordinates not implemented."
);
...
...
@@ -181,9 +187,9 @@ namespace Dune
}
private:
Factory
const
&
factory_
;
std
::
vector
<
Field
>
const
&
values_
;
unsigned
int
comp_
;
Factory
const
*
factory_
;
std
::
vector
<
Field
>
const
*
values_
=
nullptr
;
unsigned
int
comp_
=
0
;
EntitySet
entitySet_
;
};
...
...
dune/vtk/gridfunctions/lagrangegridfunction.hh
View file @
abb1121f
...
...
@@ -56,10 +56,10 @@ namespace Dune
public:
/// Constructor. Stores references to the passed data.
PointDataLocalFunction
(
GridCreator
const
&
creator
,
std
::
vector
<
Field
>
const
&
values
,
unsigned
int
comp
,
std
::
vector
<
std
::
uint8_t
>
const
&
types
,
std
::
vector
<
std
::
int64_t
>
const
&
offsets
,
std
::
vector
<
std
::
int64_t
>
const
&
connectivity
)
PointDataLocalFunction
(
GridCreator
const
*
creator
,
std
::
vector
<
Field
>
const
*
values
,
unsigned
int
comp
,
std
::
vector
<
std
::
uint8_t
>
const
*
types
,
std
::
vector
<
std
::
int64_t
>
const
*
offsets
,
std
::
vector
<
std
::
int64_t
>
const
*
connectivity
)
:
creator_
(
creator
)
,
values_
(
values
)
,
comp_
(
comp
)
...
...
@@ -68,6 +68,8 @@ namespace Dune
,
connectivity_
(
connectivity
)
{}
PointDataLocalFunction
()
=
default
;
/// Binding the local-function to an element.
/**
* Constructs a new local finite-element with a polynomial order given
...
...
@@ -77,29 +79,29 @@ namespace Dune
**/
void
bind
(
LocalContext
const
&
element
)
{
unsigned
int
insertionIndex
=
creator_
.
factory
().
insertionIndex
(
element
);
unsigned
int
insertionIndex
=
creator_
->
factory
().
insertionIndex
(
element
);
std
::
int64_t
shift
=
(
insertionIndex
==
0
?
0
:
offsets_
[
insertionIndex
-
1
]);
std
::
int64_t
numNodes
=
offsets_
[
insertionIndex
]
-
shift
;
std
::
int64_t
shift
=
(
insertionIndex
==
0
?
0
:
(
*
offsets_
)
[
insertionIndex
-
1
]);
std
::
int64_t
numNodes
=
(
*
offsets_
)
[
insertionIndex
]
-
shift
;
[[
maybe_unused
]]
std
::
int64_t
maxNumNodes
=
numLagrangePoints
(
element
.
type
().
id
(),
element
.
type
().
dim
(),
20
);
VTK_ASSERT
(
numNodes
>
0
&&
numNodes
<
maxNumNodes
);
int
order
=
creator_
.
order
(
element
.
type
(),
numNodes
);
int
order
=
creator_
->
order
(
element
.
type
(),
numNodes
);
VTK_ASSERT
(
order
>
0
&&
order
<
20
);
// construct a local finite-element with the corresponding order and Lagrange points
// as stored in the file
lfe_
.
emplace
(
LFE
{
element
.
type
(),
(
unsigned
int
)(
order
)});
lgeo_
.
emplace
(
creator_
.
localGeometry
(
element
));
lgeo_
.
emplace
(
creator_
->
localGeometry
(
element
));
// collect values on lagrange nodes
localValues_
.
resize
(
numNodes
);
for
(
std
::
int64_t
i
=
shift
,
i0
=
0
;
i
<
offsets_
[
insertionIndex
];
++
i
,
++
i0
)
{
std
::
int64_t
idx
=
connectivity_
[
i
];
for
(
std
::
int64_t
i
=
shift
,
i0
=
0
;
i
<
(
*
offsets_
)
[
insertionIndex
];
++
i
,
++
i0
)
{
std
::
int64_t
idx
=
(
*
connectivity_
)
[
i
];
DynamicVector
<
Field
>&
v
=
localValues_
[
i0
];
v
.
resize
(
comp_
);
for
(
unsigned
int
j
=
0
;
j
<
comp_
;
++
j
)
v
[
j
]
=
values_
[
comp_
*
idx
+
j
];
v
[
j
]
=
(
*
values_
)
[
comp_
*
idx
+
j
];
}
}
...
...
@@ -128,12 +130,12 @@ namespace Dune
}
private:
GridCreator
const
&
creator_
;
std
::
vector
<
Field
>
const
&
values_
;
GridCreator
const
*
creator_
=
nullptr
;
std
::
vector
<
Field
>
const
*
values_
=
nullptr
;
unsigned
int
comp_
;
std
::
vector
<
std
::
uint8_t
>
const
&
types_
;
std
::
vector
<
std
::
int64_t
>
const
&
offsets_
;
std
::
vector
<
std
::
int64_t
>
const
&
connectivity_
;
std
::
vector
<
std
::
uint8_t
>
const
*
types_
=
nullptr
;
std
::
vector
<
std
::
int64_t
>
const
*
offsets_
=
nullptr
;
std
::
vector
<
std
::
int64_t
>
const
*
connectivity_
=
nullptr
;
// Local Finite-Element
std
::
optional
<
LFE
>
lfe_
=
std
::
nullopt
;
...
...
@@ -156,27 +158,29 @@ namespace Dune
public:
/// Constructor. Stores references to the passed data.
CellDataLocalFunction
(
GridCreator
const
&
creator
,
std
::
vector
<
Field
>
const
&
values
,
unsigned
int
comp
,
std
::
vector
<
std
::
uint8_t
>
const
&
/*types*/
,
std
::
vector
<
std
::
int64_t
>
const
&
/*offsets*/
,
std
::
vector
<
std
::
int64_t
>
const
&
/*connectivity*/
)
:
fac
tor
y
_
(
creator
.
factory
()
)
CellDataLocalFunction
(
GridCreator
const
*
creator
,
std
::
vector
<
Field
>
const
*
values
,
unsigned
int
comp
,
std
::
vector
<
std
::
uint8_t
>
const
*
/*types*/
,
std
::
vector
<
std
::
int64_t
>
const
*
/*offsets*/
,
std
::
vector
<
std
::
int64_t
>
const
*
/*connectivity*/
)
:
crea
tor_
(
creator
)
,
values_
(
values
)
,
comp_
(
comp
)
{}
CellDataLocalFunction
()
=
default
;
/// Binding the local-function to an element extract the cell-value from the vector
/// of data.
void
bind
(
LocalContext
const
&
element
)
{
unsigned
int
idx
=
factory
_
.
insertionIndex
(
element
);
unsigned
int
idx
=
creator_
->
factory
()
.
insertionIndex
(
element
);
// collect values on cells
DynamicVector
<
Field
>&
v
=
localValue_
;
v
.
resize
(
comp_
);
for
(
unsigned
int
j
=
0
;
j
<
comp_
;
++
j
)
v
[
j
]
=
values_
[
comp_
*
idx
+
j
];
v
[
j
]
=
(
*
values_
)
[
comp_
*
idx
+
j
];
}
/// Unbinds from the bound element. Does nothing
...
...
@@ -191,8 +195,8 @@ namespace Dune
}
private:
Fac
tor
y
const
&
factory_
;
std
::
vector
<
Field
>
const
&
values_
;
GridCrea
tor
const
*
creator_
=
nullptr
;
std
::
vector
<
Field
>
const
*
values_
=
nullptr
;
unsigned
int
comp_
;
// cache of local values
...
...
@@ -212,14 +216,16 @@ namespace Dune
std
::
vector
<
std
::
uint8_t
>
const
&
types
,
std
::
vector
<
std
::
int64_t
>
const
&
offsets
,
std
::
vector
<
std
::
int64_t
>
const
&
connectivity
)
:
creator_
(
creator
)
,
values_
(
values
)
:
creator_
(
&
creator
)
,
values_
(
&
values
)
,
comp_
(
comp
)
,
types_
(
types
)
,
offsets_
(
offsets
)
,
connectivity_
(
connectivity
)
,
types_
(
&
types
)
,
offsets_
(
&
offsets
)
,
connectivity_
(
&
connectivity
)
{}
LagrangeGridFunction
()
=
default
;
/// Global evaluation. Not supported!
Range
operator
()
(
Domain
const
&
global
)
const
{
...
...
@@ -241,12 +247,12 @@ namespace Dune
}
private:
GridCreator
const
&
creator_
;
std
::
vector
<
Field
>
const
&
values_
;
unsigned
int
comp_
;
std
::
vector
<
std
::
uint8_t
>
const
&
types_
;
std
::
vector
<
std
::
int64_t
>
const
&
offsets_
;
std
::
vector
<
std
::
int64_t
>
const
&
connectivity_
;
GridCreator
const
*
creator_
=
nullptr
;
std
::
vector
<
Field
>
const
*
values_
=
nullptr
;
unsigned
int
comp_
=
0
;
std
::
vector
<
std
::
uint8_t
>
const
*
types_
=
nullptr
;
std
::
vector
<
std
::
int64_t
>
const
*
offsets_
=
nullptr
;
std
::
vector
<
std
::
int64_t
>
const
*
connectivity_
=
nullptr
;
EntitySet
entitySet_
;
};
...
...
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