Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tnl-dev
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor 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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
TNL
tnl-dev
Commits
845b91de
There was an error fetching the commit references. Please try again later.
Commit
845b91de
authored
10 years ago
by
Tomáš Oberhuber
Browse files
Options
Downloads
Patches
Plain Diff
Fixing the approximation test.
parent
bce97df1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/unit-tests/tnlApproximationError.h
+32
-2
32 additions, 2 deletions
tests/unit-tests/tnlApproximationError.h
tests/unit-tests/tnlApproximationError_impl.h
+52
-0
52 additions, 0 deletions
tests/unit-tests/tnlApproximationError_impl.h
with
84 additions
and
2 deletions
tests/unit-tests/tnlApproximationError.h
+
32
−
2
View file @
845b91de
...
@@ -18,19 +18,20 @@
...
@@ -18,19 +18,20 @@
#ifndef TNLAPPROXIMATIONERROR_H_
#ifndef TNLAPPROXIMATIONERROR_H_
#define TNLAPPROXIMATIONERROR_H_
#define TNLAPPROXIMATIONERROR_H_
#include
<mesh/tnlGrid.h>
template
<
typename
Mesh
,
template
<
typename
Mesh
,
typename
ExactOperator
,
typename
ExactOperator
,
typename
ApproximateOperator
,
typename
ApproximateOperator
,
typename
Function
>
typename
Function
>
class
tnlApproximationError
class
tnlApproximationError
{
{
public:
public:
typedef
typename
ApproximateOperator
::
RealType
RealType
;
typedef
typename
ApproximateOperator
::
RealType
RealType
;
typedef
Mesh
MeshType
;
typedef
Mesh
MeshType
;
typedef
typename
MeshType
::
DeviceType
DeviceType
;
typedef
typename
MeshType
::
DeviceType
DeviceType
;
typedef
typename
MeshType
::
IndexType
IndexType
;
typedef
typename
MeshType
::
IndexType
IndexType
;
typedef
typename
MeshType
::
CoordinatesType
CoordinatesType
;
typedef
typename
MeshType
::
VertexType
VertexType
;
typedef
typename
MeshType
::
VertexType
VertexType
;
static
void
getError
(
const
Mesh
&
mesh
,
static
void
getError
(
const
Mesh
&
mesh
,
...
@@ -42,6 +43,35 @@ class tnlApproximationError
...
@@ -42,6 +43,35 @@ class tnlApproximationError
RealType
&
maxErr
);
RealType
&
maxErr
);
};
};
template
<
int
Dimensions
,
typename
Real
,
typename
Device
,
typename
Index
,
typename
ExactOperator
,
typename
ApproximateOperator
,
typename
Function
>
class
tnlApproximationError
<
tnlGrid
<
Dimensions
,
Real
,
Device
,
Index
>
,
ExactOperator
,
ApproximateOperator
,
Function
>
{
public:
typedef
typename
ApproximateOperator
::
RealType
RealType
;
typedef
tnlGrid
<
Dimensions
,
Real
,
Device
,
Index
>
MeshType
;
typedef
typename
MeshType
::
DeviceType
DeviceType
;
typedef
typename
MeshType
::
IndexType
IndexType
;
typedef
typename
MeshType
::
CoordinatesType
CoordinatesType
;
typedef
typename
MeshType
::
VertexType
VertexType
;
static
void
getError
(
const
MeshType
&
mesh
,
const
ExactOperator
&
exactOperator
,
const
ApproximateOperator
&
approximateOperator
,
const
Function
&
function
,
RealType
&
l1Err
,
RealType
&
l2Err
,
RealType
&
maxErr
);
};
#include
"tnlApproximationError_impl.h"
#include
"tnlApproximationError_impl.h"
#endif
/* TNLAPPROXIMATIONERROR_H_ */
#endif
/* TNLAPPROXIMATIONERROR_H_ */
This diff is collapsed.
Click to expand it.
tests/unit-tests/tnlApproximationError_impl.h
+
52
−
0
View file @
845b91de
...
@@ -69,4 +69,56 @@ getError( const Mesh& mesh,
...
@@ -69,4 +69,56 @@ getError( const Mesh& mesh,
maxErr
=
mesh
.
getDifferenceAbsMax
(
exactData
,
approximateData
);
maxErr
=
mesh
.
getDifferenceAbsMax
(
exactData
,
approximateData
);
}
}
template
<
int
Dimensions
,
typename
Real
,
typename
Device
,
typename
Index
,
typename
ExactOperator
,
typename
ApproximateOperator
,
typename
Function
>
void
tnlApproximationError
<
tnlGrid
<
Dimensions
,
Real
,
Device
,
Index
>
,
ExactOperator
,
ApproximateOperator
,
Function
>::
getError
(
const
MeshType
&
mesh
,
const
ExactOperator
&
exactOperator
,
const
ApproximateOperator
&
approximateOperator
,
const
Function
&
function
,
RealType
&
l1Err
,
RealType
&
l2Err
,
RealType
&
maxErr
)
{
typedef
tnlVector
<
RealType
,
DeviceType
,
IndexType
>
Vector
;
Vector
functionData
,
exactData
,
approximateData
;
const
IndexType
entities
=
mesh
.
getNumberOfCells
();
if
(
!
functionData
.
setSize
(
entities
)
||
!
exactData
.
setSize
(
entities
)
||
!
approximateData
.
setSize
(
entities
)
)
return
;
tnlFunctionDiscretizer
<
MeshType
,
Function
,
Vector
>::
template
discretize
<
0
,
0
,
0
>(
mesh
,
function
,
functionData
);
if
(
DeviceType
::
DeviceType
==
(
int
)
tnlHostDevice
)
{
for
(
IndexType
i
=
0
;
i
<
entities
;
i
++
)
{
if
(
!
mesh
.
isBoundaryCell
(
i
)
)
{
VertexType
v
=
mesh
.
getCellCenter
(
i
);
CoordinatesType
c
=
mesh
.
getCellCoordinates
(
i
);
exactData
[
i
]
=
exactOperator
.
getValue
(
function
,
v
);
approximateData
[
i
]
=
approximateOperator
.
getValue
(
mesh
,
i
,
c
,
functionData
,
0.0
);
}
else
exactData
[
i
]
=
approximateData
[
i
];
}
}
if
(
DeviceType
::
DeviceType
==
(
int
)
tnlCudaDevice
)
{
// TODO
}
l1Err
=
mesh
.
getDifferenceLpNorm
(
exactData
,
approximateData
,
(
RealType
)
1.0
);
l2Err
=
mesh
.
getDifferenceLpNorm
(
exactData
,
approximateData
,
(
RealType
)
2.0
);
maxErr
=
mesh
.
getDifferenceAbsMax
(
exactData
,
approximateData
);
}
#endif
/* TNLAPPROXIMATIONERROR_IMPL_H_ */
#endif
/* TNLAPPROXIMATIONERROR_IMPL_H_ */
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