Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dynamic
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
MostafaMollaali
dynamic
Commits
40c68328
Commit
40c68328
authored
7 years ago
by
Dmitri Naumov
Browse files
Options
Downloads
Patches
Plain Diff
[PL] Split add_secondary_var lambda into two fcts.
parent
4cd8d1e5
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
ProcessLib/ProcessOutput.cpp
+103
-82
103 additions, 82 deletions
ProcessLib/ProcessOutput.cpp
with
103 additions
and
82 deletions
ProcessLib/ProcessOutput.cpp
+
103
−
82
View file @
40c68328
...
@@ -12,6 +12,98 @@
...
@@ -12,6 +12,98 @@
#include
"MeshLib/IO/VtkIO/VtuInterface.h"
#include
"MeshLib/IO/VtkIO/VtuInterface.h"
#include
"NumLib/DOF/LocalToGlobalIndexMap.h"
#include
"NumLib/DOF/LocalToGlobalIndexMap.h"
static
void
addSecondaryVariableNodes
(
double
const
t
,
GlobalVector
const
&
x
,
NumLib
::
LocalToGlobalIndexMap
const
&
dof_table
,
ProcessLib
::
SecondaryVariable
const
&
var
,
std
::
string
const
&
output_name
,
MeshLib
::
Mesh
&
mesh
)
{
DBUG
(
" secondary variable %s"
,
output_name
.
c_str
());
auto
&
nodal_values_mesh
=
*
MeshLib
::
getOrCreateMeshProperty
<
double
>
(
mesh
,
output_name
,
MeshLib
::
MeshItemType
::
Node
,
var
.
fcts
.
num_components
);
if
(
nodal_values_mesh
.
size
()
!=
mesh
.
getNumberOfNodes
()
*
var
.
fcts
.
num_components
)
{
OGS_FATAL
(
"Nodal property `%s' does not have the right number of "
"components. Expected: %d, actual: %d"
,
output_name
.
c_str
(),
mesh
.
getNumberOfNodes
()
*
var
.
fcts
.
num_components
,
nodal_values_mesh
.
size
());
}
std
::
unique_ptr
<
GlobalVector
>
result_cache
;
auto
const
&
nodal_values
=
var
.
fcts
.
eval_field
(
t
,
x
,
dof_table
,
result_cache
);
if
(
nodal_values_mesh
.
size
()
!=
static_cast
<
std
::
size_t
>
(
nodal_values
.
size
()))
{
OGS_FATAL
(
"Secondary variable `%s' did not evaluate to the right "
"number of components. Expected: %d, actual: %d."
,
var
.
name
.
c_str
(),
nodal_values_mesh
.
size
(),
nodal_values
.
size
());
}
// Copy result
for
(
GlobalIndexType
i
=
0
;
i
<
nodal_values
.
size
();
++
i
)
{
assert
(
!
std
::
isnan
(
nodal_values
[
i
]));
nodal_values_mesh
[
i
]
=
nodal_values
[
i
];
}
}
static
void
addSecondaryVariableResiduals
(
double
const
t
,
GlobalVector
const
&
x
,
NumLib
::
LocalToGlobalIndexMap
const
&
dof_table
,
ProcessLib
::
SecondaryVariable
const
&
var
,
std
::
string
const
&
output_name
,
MeshLib
::
Mesh
&
mesh
)
{
if
(
!
var
.
fcts
.
eval_residuals
)
return
;
DBUG
(
" secondary variable %s residual"
,
output_name
.
c_str
());
auto
const
&
property_name_res
=
output_name
+
"_residual"
;
auto
&
residuals_mesh
=
*
MeshLib
::
getOrCreateMeshProperty
<
double
>
(
mesh
,
property_name_res
,
MeshLib
::
MeshItemType
::
Cell
,
var
.
fcts
.
num_components
);
if
(
residuals_mesh
.
size
()
!=
mesh
.
getNumberOfElements
()
*
var
.
fcts
.
num_components
)
{
OGS_FATAL
(
"Cell property `%s' does not have the right number of "
"components. Expected: %d, actual: %d"
,
property_name_res
.
c_str
(),
mesh
.
getNumberOfElements
()
*
var
.
fcts
.
num_components
,
residuals_mesh
.
size
());
}
std
::
unique_ptr
<
GlobalVector
>
result_cache
;
auto
const
&
residuals
=
var
.
fcts
.
eval_residuals
(
t
,
x
,
dof_table
,
result_cache
);
if
(
residuals_mesh
.
size
()
!=
static_cast
<
std
::
size_t
>
(
residuals
.
size
()))
{
OGS_FATAL
(
"Thee residual of secondary variable `%s' did not evaluate "
"to the right number of components. Expected: %d, actual: "
"%d."
,
var
.
name
.
c_str
(),
residuals_mesh
.
size
(),
residuals
.
size
());
}
// Copy result
for
(
GlobalIndexType
i
=
0
;
i
<
residuals
.
size
();
++
i
)
{
assert
(
!
std
::
isnan
(
residuals
[
i
]));
residuals_mesh
[
i
]
=
residuals
[
i
];
}
}
namespace
ProcessLib
namespace
ProcessLib
{
{
void
processOutputData
(
void
processOutputData
(
...
@@ -101,87 +193,8 @@ void processOutputData(
...
@@ -101,87 +193,8 @@ void processOutputData(
}
}
#ifndef USE_PETSC
#ifndef USE_PETSC
auto
add_secondary_var
=
[
&
](
SecondaryVariable
const
&
var
,
std
::
string
const
&
output_name
)
{
{
DBUG
(
" secondary variable %s"
,
output_name
.
c_str
());
auto
&
nodal_values_mesh
=
*
MeshLib
::
getOrCreateMeshProperty
<
double
>
(
mesh
,
output_name
,
MeshLib
::
MeshItemType
::
Node
,
var
.
fcts
.
num_components
);
if
(
nodal_values_mesh
.
size
()
!=
mesh
.
getNumberOfNodes
()
*
var
.
fcts
.
num_components
)
{
OGS_FATAL
(
"Nodal property `%s' does not have the right number of "
"components. Expected: %d, actual: %d"
,
output_name
.
c_str
(),
mesh
.
getNumberOfNodes
()
*
var
.
fcts
.
num_components
,
nodal_values_mesh
.
size
());
}
std
::
unique_ptr
<
GlobalVector
>
result_cache
;
auto
const
&
nodal_values
=
var
.
fcts
.
eval_field
(
t
,
x
,
dof_table
,
result_cache
);
if
(
nodal_values_mesh
.
size
()
!=
static_cast
<
std
::
size_t
>
(
nodal_values
.
size
()))
{
OGS_FATAL
(
"Secondary variable `%s' did not evaluate to the right "
"number of components. Expected: %d, actual: %d."
,
var
.
name
.
c_str
(),
nodal_values_mesh
.
size
(),
nodal_values
.
size
());
}
// Copy result
for
(
GlobalIndexType
i
=
0
;
i
<
nodal_values
.
size
();
++
i
)
{
assert
(
!
std
::
isnan
(
nodal_values
[
i
]));
nodal_values_mesh
[
i
]
=
nodal_values
[
i
];
}
}
if
(
process_output
.
output_residuals
&&
var
.
fcts
.
eval_residuals
)
{
DBUG
(
" secondary variable %s residual"
,
output_name
.
c_str
());
auto
const
&
property_name_res
=
output_name
+
"_residual"
;
auto
&
residuals_mesh
=
*
MeshLib
::
getOrCreateMeshProperty
<
double
>
(
mesh
,
property_name_res
,
MeshLib
::
MeshItemType
::
Cell
,
var
.
fcts
.
num_components
);
if
(
residuals_mesh
.
size
()
!=
mesh
.
getNumberOfElements
()
*
var
.
fcts
.
num_components
)
{
OGS_FATAL
(
"Cell property `%s' does not have the right number of "
"components. Expected: %d, actual: %d"
,
property_name_res
.
c_str
(),
mesh
.
getNumberOfElements
()
*
var
.
fcts
.
num_components
,
residuals_mesh
.
size
());
}
std
::
unique_ptr
<
GlobalVector
>
result_cache
;
auto
const
&
residuals
=
var
.
fcts
.
eval_residuals
(
t
,
x
,
dof_table
,
result_cache
);
if
(
residuals_mesh
.
size
()
!=
static_cast
<
std
::
size_t
>
(
residuals
.
size
()))
{
OGS_FATAL
(
"Thee residual of secondary variable `%s' did not evaluate "
"to the right number of components. Expected: %d, actual: "
"%d."
,
var
.
name
.
c_str
(),
residuals_mesh
.
size
(),
residuals
.
size
());
}
// Copy result
for
(
GlobalIndexType
i
=
0
;
i
<
residuals
.
size
();
++
i
)
{
assert
(
!
std
::
isnan
(
residuals
[
i
]));
residuals_mesh
[
i
]
=
residuals
[
i
];
}
}
};
// Secondary variables output
for
(
auto
const
&
external_variable_name
:
output_variables
)
for
(
auto
const
&
external_variable_name
:
output_variables
)
{
{
if
(
!
already_output
.
insert
(
external_variable_name
).
second
)
{
if
(
!
already_output
.
insert
(
external_variable_name
).
second
)
{
...
@@ -189,8 +202,16 @@ void processOutputData(
...
@@ -189,8 +202,16 @@ void processOutputData(
continue
;
continue
;
}
}
add_secondary_var
(
secondary_variables
.
get
(
external_variable_name
),
addSecondaryVariableNodes
(
external_variable_name
);
t
,
x
,
dof_table
,
secondary_variables
.
get
(
external_variable_name
),
external_variable_name
,
mesh
);
if
(
process_output
.
output_residuals
)
{
addSecondaryVariableResiduals
(
t
,
x
,
dof_table
,
secondary_variables
.
get
(
external_variable_name
),
external_variable_name
,
mesh
);
}
}
}
#else
#else
(
void
)
secondary_variables
;
(
void
)
secondary_variables
;
...
...
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