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
Özgür Ozan Sen
ogs
Commits
4ef94798
Commit
4ef94798
authored
1 year ago
by
Christoph Lehmann
Committed by
Dmitri Naumov
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
[PL] Extracted preOutputInitialConditions() method
parent
f6a32cda
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ProcessLib/TimeLoop.cpp
+67
-57
67 additions, 57 deletions
ProcessLib/TimeLoop.cpp
ProcessLib/TimeLoop.h
+3
-2
3 additions, 2 deletions
ProcessLib/TimeLoop.h
with
70 additions
and
59 deletions
ProcessLib/TimeLoop.cpp
+
67
−
57
View file @
4ef94798
...
@@ -474,9 +474,8 @@ void TimeLoop::initialize()
...
@@ -474,9 +474,8 @@ void TimeLoop::initialize()
// Output initial conditions
// Output initial conditions
{
{
const
bool
output_initial_condition
=
true
;
preOutputInitialConditions
(
_start_time
);
outputSolutions
(
output_initial_condition
,
0
,
_start_time
,
outputSolutions
(
0
,
_start_time
,
&
Output
::
doOutput
);
&
Output
::
doOutput
);
}
}
auto
const
time_step_constraints
=
generateOutputTimeStepConstraints
(
auto
const
time_step_constraints
=
generateOutputTimeStepConstraints
(
...
@@ -530,9 +529,7 @@ bool TimeLoop::calculateNextTimeStep()
...
@@ -530,9 +529,7 @@ bool TimeLoop::calculateNextTimeStep()
if
(
!
_last_step_rejected
)
if
(
!
_last_step_rejected
)
{
{
const
bool
output_initial_condition
=
false
;
outputSolutions
(
timesteps
,
current_time
,
&
Output
::
doOutput
);
outputSolutions
(
output_initial_condition
,
timesteps
,
current_time
,
&
Output
::
doOutput
);
}
}
if
(
std
::
abs
(
_current_time
-
_end_time
)
<
if
(
std
::
abs
(
_current_time
-
_end_time
)
<
...
@@ -564,9 +561,7 @@ void TimeLoop::outputLastTimeStep() const
...
@@ -564,9 +561,7 @@ void TimeLoop::outputLastTimeStep() const
// output last time step
// output last time step
if
(
successful_time_step
)
if
(
successful_time_step
)
{
{
const
bool
output_initial_condition
=
false
;
outputSolutions
(
_accepted_steps
+
_rejected_steps
,
_current_time
,
outputSolutions
(
output_initial_condition
,
_accepted_steps
+
_rejected_steps
,
_current_time
,
&
Output
::
doOutputLastTimestep
);
&
Output
::
doOutputLastTimestep
);
}
}
}
}
...
@@ -784,22 +779,16 @@ TimeLoop::solveCoupledEquationSystemsByStaggeredScheme(
...
@@ -784,22 +779,16 @@ TimeLoop::solveCoupledEquationSystemsByStaggeredScheme(
return
nonlinear_solver_status
;
return
nonlinear_solver_status
;
}
}
void
TimeLoop
::
outputSolutions
(
bool
const
output_initial_condition
)
const
void
TimeLoop
::
outputSolutions
()
const
{
{
const
std
::
size_t
timesteps
=
_accepted_steps
+
1
;
const
std
::
size_t
timesteps
=
_accepted_steps
+
1
;
outputSolutions
(
output_initial_condition
,
timesteps
,
_current_time
,
outputSolutions
(
timesteps
,
_current_time
,
&
Output
::
doOutput
);
&
Output
::
doOutput
);
}
}
template
<
typename
OutputClassMember
>
template
<
typename
OutputClassMember
>
void
TimeLoop
::
outputSolutions
(
bool
const
output_initial_condition
,
void
TimeLoop
::
outputSolutions
(
unsigned
timestep
,
const
double
t
,
unsigned
timestep
,
const
double
t
,
OutputClassMember
output_class_member
)
const
OutputClassMember
output_class_member
)
const
{
{
// All _per_process_data share the first process.
bool
const
is_staggered_coupling
=
!
isMonolithicProcess
(
*
_per_process_data
[
0
]);
for
(
auto
const
&
process_data
:
_per_process_data
)
for
(
auto
const
&
process_data
:
_per_process_data
)
{
{
// If nonlinear solver diverged, the solution has already been
// If nonlinear solver diverged, the solution has already been
...
@@ -810,45 +799,8 @@ void TimeLoop::outputSolutions(bool const output_initial_condition,
...
@@ -810,45 +799,8 @@ void TimeLoop::outputSolutions(bool const output_initial_condition,
}
}
auto
const
process_id
=
process_data
->
process_id
;
auto
const
process_id
=
process_data
->
process_id
;
auto
&
pcs
=
process_data
->
process
;
auto
const
&
pcs
=
process_data
->
process
;
if
(
!
is_staggered_coupling
&&
output_initial_condition
)
{
// dummy value to handle the time derivative terms more or less
// correctly, i.e. to ignore them.
double
const
dt
=
1
;
process_data
->
time_disc
->
nextTimestep
(
t
,
dt
);
pcs
.
preTimestep
(
_process_solutions
,
_start_time
,
dt
,
process_id
);
// Update secondary variables, which might be uninitialized, before
// output.
pcs
.
computeSecondaryVariable
(
_start_time
,
dt
,
_process_solutions
,
*
_process_solutions_prev
[
process_id
],
process_id
);
}
if
(
is_staggered_coupling
&&
output_initial_condition
)
{
CoupledSolutionsForStaggeredScheme
coupled_solutions
(
_process_solutions
);
process_data
->
process
.
setCoupledSolutionsForStaggeredScheme
(
&
coupled_solutions
);
process_data
->
process
.
setCoupledTermForTheStaggeredSchemeToLocalAssemblers
(
process_id
);
// dummy value to handle the time derivative terms more or less
// correctly, i.e. to ignore them.
double
const
dt
=
1
;
process_data
->
time_disc
->
nextTimestep
(
t
,
dt
);
pcs
.
preTimestep
(
_process_solutions
,
_start_time
,
dt
,
process_id
);
// Update secondary variables, which might be uninitialized, before
// output.
pcs
.
computeSecondaryVariable
(
_start_time
,
dt
,
_process_solutions
,
*
_process_solutions_prev
[
process_id
],
process_id
);
}
for
(
auto
const
&
output_object
:
_outputs
)
for
(
auto
const
&
output_object
:
_outputs
)
{
{
(
output_object
.
*
output_class_member
)(
(
output_object
.
*
output_class_member
)(
...
@@ -902,5 +854,63 @@ double TimeLoop::computeRelativeSolutionChangeFromPreviousTimestep(
...
@@ -902,5 +854,63 @@ double TimeLoop::computeRelativeSolutionChangeFromPreviousTimestep(
const
double
solution_error
=
const
double
solution_error
=
NumLib
::
computeRelativeChangeFromPreviousTimestep
(
x
,
x_prev
,
norm_type
);
NumLib
::
computeRelativeChangeFromPreviousTimestep
(
x
,
x_prev
,
norm_type
);
return
solution_error
;
return
solution_error
;
};
}
void
TimeLoop
::
preOutputInitialConditions
(
const
double
t
)
const
{
// All _per_process_data share the first process.
bool
const
is_staggered_coupling
=
!
isMonolithicProcess
(
*
_per_process_data
[
0
]);
for
(
auto
const
&
process_data
:
_per_process_data
)
{
// If nonlinear solver diverged, the solution has already been
// saved.
if
(
!
process_data
->
nonlinear_solver_status
.
error_norms_met
)
{
continue
;
}
auto
const
process_id
=
process_data
->
process_id
;
auto
&
pcs
=
process_data
->
process
;
if
(
!
is_staggered_coupling
)
{
// dummy value to handle the time derivative terms more or less
// correctly, i.e. to ignore them.
double
const
dt
=
1
;
process_data
->
time_disc
->
nextTimestep
(
t
,
dt
);
pcs
.
preTimestep
(
_process_solutions
,
_start_time
,
dt
,
process_id
);
// Update secondary variables, which might be uninitialized, before
// output.
pcs
.
computeSecondaryVariable
(
_start_time
,
dt
,
_process_solutions
,
*
_process_solutions_prev
[
process_id
],
process_id
);
}
else
{
CoupledSolutionsForStaggeredScheme
coupled_solutions
(
_process_solutions
);
process_data
->
process
.
setCoupledSolutionsForStaggeredScheme
(
&
coupled_solutions
);
process_data
->
process
.
setCoupledTermForTheStaggeredSchemeToLocalAssemblers
(
process_id
);
// dummy value to handle the time derivative terms more or less
// correctly, i.e. to ignore them.
double
const
dt
=
1
;
process_data
->
time_disc
->
nextTimestep
(
t
,
dt
);
pcs
.
preTimestep
(
_process_solutions
,
_start_time
,
dt
,
process_id
);
// Update secondary variables, which might be uninitialized, before
// output.
pcs
.
computeSecondaryVariable
(
_start_time
,
dt
,
_process_solutions
,
*
_process_solutions_prev
[
process_id
],
process_id
);
}
}
}
}
// namespace ProcessLib
}
// namespace ProcessLib
This diff is collapsed.
Click to expand it.
ProcessLib/TimeLoop.h
+
3
−
2
View file @
4ef94798
...
@@ -62,7 +62,7 @@ public:
...
@@ -62,7 +62,7 @@ public:
double
endTime
()
const
{
return
_end_time
;
}
double
endTime
()
const
{
return
_end_time
;
}
double
currentTime
()
const
{
return
_current_time
;
}
double
currentTime
()
const
{
return
_current_time
;
}
bool
successful_time_step
=
false
;
bool
successful_time_step
=
false
;
void
outputSolutions
(
bool
const
output_initial_condition
)
const
;
void
outputSolutions
()
const
;
private
:
private
:
bool
preTsNonlinearSolvePostTs
(
double
const
t
,
double
const
dt
,
bool
preTsNonlinearSolvePostTs
(
double
const
t
,
double
const
dt
,
...
@@ -124,7 +124,7 @@ private:
...
@@ -124,7 +124,7 @@ private:
time_step_constraints
);
time_step_constraints
);
template
<
typename
OutputClassMember
>
template
<
typename
OutputClassMember
>
void
outputSolutions
(
bool
const
output_initial_condition
,
unsigned
timestep
,
void
outputSolutions
(
unsigned
timestep
,
const
double
t
,
const
double
t
,
OutputClassMember
output_class_member
)
const
;
OutputClassMember
output_class_member
)
const
;
...
@@ -133,6 +133,7 @@ private:
...
@@ -133,6 +133,7 @@ private:
generateOutputTimeStepConstraints
(
std
::
vector
<
double
>&&
fixed_times
)
const
;
generateOutputTimeStepConstraints
(
std
::
vector
<
double
>&&
fixed_times
)
const
;
double
computeRelativeSolutionChangeFromPreviousTimestep
(
double
computeRelativeSolutionChangeFromPreviousTimestep
(
double
const
t
,
std
::
size_t
process_index
)
const
;
double
const
t
,
std
::
size_t
process_index
)
const
;
void
preOutputInitialConditions
(
const
double
t
)
const
;
std
::
vector
<
GlobalVector
*>
_process_solutions
;
std
::
vector
<
GlobalVector
*>
_process_solutions
;
std
::
vector
<
GlobalVector
*>
_process_solutions_prev
;
std
::
vector
<
GlobalVector
*>
_process_solutions_prev
;
std
::
vector
<
Output
>
_outputs
;
std
::
vector
<
Output
>
_outputs
;
...
...
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