Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Dmitri Naumov
ogs
Commits
4311fd6c
Commit
4311fd6c
authored
8 years ago
by
Christoph Lehmann
Browse files
Options
Downloads
Patches
Plain Diff
[PL] multi-component secondary variable output
parent
a9111fbc
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ProcessLib/ProcessOutput.cpp
+54
-7
54 additions, 7 deletions
ProcessLib/ProcessOutput.cpp
with
54 additions
and
7 deletions
ProcessLib/ProcessOutput.cpp
+
54
−
7
View file @
4311fd6c
...
@@ -41,7 +41,6 @@ ProcessOutput::ProcessOutput(BaseLib::ConfigTree const& output_config)
...
@@ -41,7 +41,6 @@ ProcessOutput::ProcessOutput(BaseLib::ConfigTree const& output_config)
}
}
void
doProcessOutput
(
std
::
string
const
&
file_name
,
void
doProcessOutput
(
std
::
string
const
&
file_name
,
bool
const
compress_output
,
GlobalVector
const
&
x
,
GlobalVector
const
&
x
,
MeshLib
::
Mesh
&
mesh
,
MeshLib
::
Mesh
&
mesh
,
NumLib
::
LocalToGlobalIndexMap
const
&
dof_table
,
NumLib
::
LocalToGlobalIndexMap
const
&
dof_table
,
...
@@ -119,6 +118,45 @@ void doProcessOutput(std::string const& file_name,
...
@@ -119,6 +118,45 @@ void doProcessOutput(std::string const& file_name,
#ifndef USE_PETSC
#ifndef USE_PETSC
// the following section is for the output of secondary variables
// the following section is for the output of secondary variables
auto
count_mesh_items
=
[](
MeshLib
::
Mesh
const
&
mesh
,
MeshLib
::
MeshItemType
type
)
->
std
::
size_t
{
switch
(
type
)
{
case
MeshLib
::
MeshItemType
::
Cell
:
return
mesh
.
getNumberOfElements
();
case
MeshLib
::
MeshItemType
::
Node
:
return
mesh
.
getNumberOfNodes
();
default:
break
;
// avoid compiler warning
}
return
0
;
};
auto
get_or_create_mesh_property
=
[
&
mesh
,
&
count_mesh_items
](
std
::
string
const
&
property_name
,
MeshLib
::
MeshItemType
type
,
unsigned
const
num_components
)
{
// Get or create a property vector for results.
MeshLib
::
PropertyVector
<
double
>*
result
=
nullptr
;
auto
const
N
=
count_mesh_items
(
mesh
,
type
)
*
num_components
;
if
(
mesh
.
getProperties
().
hasPropertyVector
(
property_name
))
{
result
=
mesh
.
getProperties
().
template
getPropertyVector
<
double
>(
property_name
);
}
else
{
result
=
mesh
.
getProperties
().
template
createNewPropertyVector
<
double
>(
property_name
,
type
,
num_components
);
result
->
resize
(
N
);
}
assert
(
result
&&
result
->
size
()
==
N
);
return
result
;
};
auto
add_secondary_var
=
[
&
](
SecondaryVariable
const
&
var
,
auto
add_secondary_var
=
[
&
](
SecondaryVariable
const
&
var
,
std
::
string
const
&
output_name
)
{
std
::
string
const
&
output_name
)
{
assert
(
var
.
fcts
.
num_components
==
1
);
// TODO implement other cases
assert
(
var
.
fcts
.
num_components
==
1
);
// TODO implement other cases
...
@@ -126,18 +164,22 @@ void doProcessOutput(std::string const& file_name,
...
@@ -126,18 +164,22 @@ void doProcessOutput(std::string const& file_name,
{
{
DBUG
(
" secondary variable %s"
,
output_name
.
c_str
());
DBUG
(
" secondary variable %s"
,
output_name
.
c_str
());
auto
result
=
MeshLib
::
getOrCreateMeshProperty
<
double
>
(
auto
&
result
=
*
get_or_create_mesh_property
(
mesh
,
output_name
,
MeshLib
::
MeshItemType
::
Node
,
1
);
output_name
,
MeshLib
::
MeshItemType
::
Node
,
var
.
fcts
.
num_components
);
assert
(
result
.
size
()
==
mesh
.
getNumberOfNodes
()
*
var
.
fcts
.
num_components
);
std
::
unique_ptr
<
GlobalVector
>
result_cache
;
std
::
unique_ptr
<
GlobalVector
>
result_cache
;
auto
const
&
nodal_values
=
auto
const
&
nodal_values
=
var
.
fcts
.
eval_field
(
x
,
dof_table
,
result_cache
);
var
.
fcts
.
eval_field
(
x
,
dof_table
,
result_cache
);
assert
(
nodal_values
.
size
()
==
result
.
size
());
// Copy result
// Copy result
for
(
GlobalIndexType
i
=
0
;
i
<
nodal_values
.
size
();
++
i
)
for
(
GlobalIndexType
i
=
0
;
i
<
nodal_values
.
size
();
++
i
)
{
{
assert
(
!
std
::
isnan
(
nodal_values
[
i
]));
assert
(
!
std
::
isnan
(
nodal_values
[
i
]));
(
*
result
)
[
i
]
=
nodal_values
[
i
];
result
[
i
]
=
nodal_values
[
i
];
}
}
}
}
...
@@ -146,18 +188,23 @@ void doProcessOutput(std::string const& file_name,
...
@@ -146,18 +188,23 @@ void doProcessOutput(std::string const& file_name,
DBUG
(
" secondary variable %s residual"
,
output_name
.
c_str
());
DBUG
(
" secondary variable %s residual"
,
output_name
.
c_str
());
auto
const
&
property_name_res
=
output_name
+
"_residual"
;
auto
const
&
property_name_res
=
output_name
+
"_residual"
;
auto
result
=
MeshLib
::
getOrCreateMeshProperty
<
double
>
(
auto
&
result
=
*
get_or_create_mesh_property
(
mesh
,
property_name_res
,
MeshLib
::
MeshItemType
::
Cell
,
1
);
property_name_res
,
MeshLib
::
MeshItemType
::
Cell
,
var
.
fcts
.
num_components
);
assert
(
result
.
size
()
==
mesh
.
getNumberOfElements
()
*
var
.
fcts
.
num_components
);
std
::
unique_ptr
<
GlobalVector
>
result_cache
;
std
::
unique_ptr
<
GlobalVector
>
result_cache
;
auto
const
&
residuals
=
auto
const
&
residuals
=
var
.
fcts
.
eval_residuals
(
x
,
dof_table
,
result_cache
);
var
.
fcts
.
eval_residuals
(
x
,
dof_table
,
result_cache
);
assert
(
residuals
.
size
()
==
result
.
size
());
// Copy result
// Copy result
for
(
GlobalIndexType
i
=
0
;
i
<
residuals
.
size
();
++
i
)
for
(
GlobalIndexType
i
=
0
;
i
<
residuals
.
size
();
++
i
)
{
{
assert
(
!
std
::
isnan
(
residuals
[
i
]));
assert
(
!
std
::
isnan
(
residuals
[
i
]));
(
*
result
)
[
i
]
=
residuals
[
i
];
result
[
i
]
=
residuals
[
i
];
}
}
}
}
};
};
...
...
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