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
Chaofan Chen
ogs
Commits
2058bb6f
Commit
2058bb6f
authored
3 years ago
by
wenqing
Committed by
Dmitri Naumov
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[NumLib] Moved the definitions of two member functions of TimeDiscretization to cpp file
parent
1ce8583f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
NumLib/ODESolver/TimeDiscretization.cpp
+24
-0
24 additions, 0 deletions
NumLib/ODESolver/TimeDiscretization.cpp
NumLib/ODESolver/TimeDiscretization.h
+2
-19
2 additions, 19 deletions
NumLib/ODESolver/TimeDiscretization.h
with
26 additions
and
19 deletions
NumLib/ODESolver/TimeDiscretization.cpp
+
24
−
0
View file @
2058bb6f
...
@@ -47,4 +47,28 @@ double computeRelativeChangeFromPreviousTimestep(GlobalVector const& x,
...
@@ -47,4 +47,28 @@ double computeRelativeChangeFromPreviousTimestep(GlobalVector const& x,
// Only norm_x is close to zero
// Only norm_x is close to zero
return
norm_dx
/
std
::
numeric_limits
<
double
>::
epsilon
();
return
norm_dx
/
std
::
numeric_limits
<
double
>::
epsilon
();
}
}
void
TimeDiscretization
::
getXdot
(
GlobalVector
const
&
x_at_new_timestep
,
GlobalVector
const
&
x_old
,
GlobalVector
&
xdot
)
const
{
namespace
LinAlg
=
MathLib
::
LinAlg
;
double
const
dt
=
getCurrentTimeIncrement
();
// xdot = 1/dt * x_at_new_timestep - x_old
getWeightedOldX
(
xdot
,
x_old
);
LinAlg
::
axpby
(
xdot
,
1.
/
dt
,
-
1.0
,
x_at_new_timestep
);
}
void
BackwardEuler
::
getWeightedOldX
(
GlobalVector
&
y
,
GlobalVector
const
&
x_old
)
const
{
namespace
LinAlg
=
MathLib
::
LinAlg
;
// y = x_old / delta_t
LinAlg
::
copy
(
x_old
,
y
);
LinAlg
::
scale
(
y
,
1.0
/
_delta_t
);
}
}
// end of namespace NumLib
}
// end of namespace NumLib
This diff is collapsed.
Click to expand it.
NumLib/ODESolver/TimeDiscretization.h
+
2
−
19
View file @
2058bb6f
...
@@ -132,16 +132,7 @@ public:
...
@@ -132,16 +132,7 @@ public:
//! \f$.
//! \f$.
void
getXdot
(
GlobalVector
const
&
x_at_new_timestep
,
void
getXdot
(
GlobalVector
const
&
x_at_new_timestep
,
GlobalVector
const
&
x_old
,
GlobalVector
const
&
x_old
,
GlobalVector
&
xdot
)
const
GlobalVector
&
xdot
)
const
;
{
namespace
LinAlg
=
MathLib
::
LinAlg
;
double
const
dt
=
getCurrentTimeIncrement
();
// xdot = 1/dt * x_at_new_timestep - x_old
getWeightedOldX
(
xdot
,
x_old
);
LinAlg
::
axpby
(
xdot
,
1.
/
dt
,
-
1.0
,
x_at_new_timestep
);
}
//! Returns \f$ x_O \f$.
//! Returns \f$ x_O \f$.
virtual
void
getWeightedOldX
(
virtual
void
getWeightedOldX
(
...
@@ -155,7 +146,6 @@ class BackwardEuler final : public TimeDiscretization
...
@@ -155,7 +146,6 @@ class BackwardEuler final : public TimeDiscretization
{
{
public:
public:
void
setInitialState
(
const
double
t0
)
override
{
_t
=
t0
;
}
void
setInitialState
(
const
double
t0
)
override
{
_t
=
t0
;
}
void
nextTimestep
(
const
double
t
,
const
double
delta_t
)
override
void
nextTimestep
(
const
double
t
,
const
double
delta_t
)
override
{
{
_t
=
t
;
_t
=
t
;
...
@@ -165,14 +155,7 @@ public:
...
@@ -165,14 +155,7 @@ public:
double
getCurrentTime
()
const
override
{
return
_t
;
}
double
getCurrentTime
()
const
override
{
return
_t
;
}
double
getCurrentTimeIncrement
()
const
override
{
return
_delta_t
;
}
double
getCurrentTimeIncrement
()
const
override
{
return
_delta_t
;
}
void
getWeightedOldX
(
GlobalVector
&
y
,
void
getWeightedOldX
(
GlobalVector
&
y
,
GlobalVector
const
&
x_old
)
const
override
GlobalVector
const
&
x_old
)
const
override
;
{
namespace
LinAlg
=
MathLib
::
LinAlg
;
// y = x_old / delta_t
LinAlg
::
copy
(
x_old
,
y
);
LinAlg
::
scale
(
y
,
1.0
/
_delta_t
);
}
private
:
private
:
double
_t
=
std
::
numeric_limits
<
double
>::
quiet_NaN
();
//!< \f$ t_C \f$
double
_t
=
std
::
numeric_limits
<
double
>::
quiet_NaN
();
//!< \f$ t_C \f$
...
...
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