-
Notifications
You must be signed in to change notification settings - Fork 240
Numerical Jacobian assembly #1352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
8358586
[PL] added Jacobian assembler interface and implementations
chleh 2f0be12
[PL] re-introduced VectorMatrixAssembler
chleh 1175265
[MaL] tools for mapping std::vector -> Eigen::Matrix
chleh 9b47442
[PL] made Process Jacobian-assembly-ready
chleh 0043119
[PL] made specific processes Jacobian-assembly-ready
chleh fff563f
[AppL] ProjectData constructs Jacobian assembler
chleh 469267f
[NL] interface changes
chleh 527a7da
[T] adapted to time integration interface changes
chleh caa581c
[T] added Jacobian assembler tests
chleh e0db088
[App] added Newton-Raphson ctests
chleh e9efbc5
[T] fixed tests for PETSc
chleh cf469b5
fixed compilation errors
chleh feb6b82
[MaL] templated EigenMapTools
chleh 1eb5719
[PL] adapted to changed EigenMapTools
chleh 557a341
[T] adapted to changed EigenMapTools
chleh ade940f
[PL] use EigenMapTools in local assemblers.
chleh a3ba818
[PL] added Jacobian assembler docu
chleh e5e6d5d
[PL] documented VectorMatrixAssembler
chleh 8d0437b
renamed toZeroedMatrix -> createZeroedMatrix
chleh 7ade23e
[NL] improved documentation
chleh dfc4437
[PL] improved error message
chleh 063d004
fixup App/ProjectData
endJunction 5d482e0
fixup GWF
endJunction 358a355
fixup HeatConduction
endJunction d9cd80d
fixup SD
endJunction 2446e04
fixup TES
endJunction ec2f050
[PL] fix compilation errors
chleh 398cac6
[Data] added Newton ctests
chleh 96dee82
[App] marked TES Newton test as large
chleh 07bc9ef
[PL] 0 --> 0.0
chleh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,193 @@ | ||
| /** | ||
| * \copyright | ||
| * Copyright (c) 2012-2016, OpenGeoSys Community (http://www.opengeosys.org) | ||
| * Distributed under a Modified BSD License. | ||
| * See accompanying file LICENSE.txt or | ||
| * http://www.opengeosys.org/project/license | ||
| * | ||
| */ | ||
|
|
||
| #ifndef MATHLIB_EIGENMAPTOOLS_H | ||
| #define MATHLIB_EIGENMAPTOOLS_H | ||
|
|
||
| #include <cassert> | ||
| #include <vector> | ||
| #include <Eigen/Core> | ||
|
|
||
| namespace MathLib | ||
| { | ||
| /*! Creates an Eigen mapped matrix having its entries stored in the given | ||
| * \c data vector. | ||
| * | ||
| * \return An Eigen mapped matrix of the given size. All values of the matrix | ||
| * are set to zero. | ||
| * | ||
| * \pre The passed \c data vector must have zero size. | ||
| * \post The \c data has size \c rows * \c cols. | ||
| * | ||
| * \note The data vector will have the same storage order (row or column major) | ||
| * as the requested matrix type. | ||
| */ | ||
| template <typename Matrix> | ||
| Eigen::Map<Matrix> createZeroedMatrix(std::vector<double>& data, | ||
| Eigen::MatrixXd::Index rows, | ||
| Eigen::MatrixXd::Index cols) | ||
| { | ||
| static_assert(Matrix::IsRowMajor || Matrix::IsVectorAtCompileTime, | ||
| "The default storage order in OGS is row major storage for " | ||
| "dense matrices."); | ||
| assert(Matrix::RowsAtCompileTime == Eigen::Dynamic || | ||
| Matrix::RowsAtCompileTime == rows); | ||
| assert(Matrix::ColsAtCompileTime == Eigen::Dynamic || | ||
| Matrix::ColsAtCompileTime == cols); | ||
| assert(data.empty()); // in order that resize fills the vector with zeros. | ||
|
|
||
| data.resize(rows * cols); | ||
| return {data.data(), rows, cols}; | ||
| } | ||
|
|
||
| /*! Creates an Eigen mapped matrix having its entries stored in the given | ||
| * \c data vector. | ||
| * | ||
| * This is a convienence method which makes the specification of dynamically | ||
| * allocated Eigen matrices as return type easier. | ||
| */ | ||
| inline Eigen::Map< | ||
| Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>> | ||
| createZeroedMatrix(std::vector<double>& data, | ||
| Eigen::MatrixXd::Index rows, | ||
| Eigen::MatrixXd::Index cols) | ||
| { | ||
| return createZeroedMatrix< | ||
| Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>>( | ||
| data, rows, cols); | ||
| } | ||
|
|
||
| /*! Creates an Eigen mapped matrix from the given data vector. | ||
| * | ||
| * \attention The data vector must have the same storage order (row or column | ||
| * major) as the requested matrix type. | ||
| */ | ||
| template <typename Matrix> | ||
| Eigen::Map<const Matrix> toMatrix(std::vector<double> const& data, | ||
| Eigen::MatrixXd::Index rows, | ||
| Eigen::MatrixXd::Index cols) | ||
| { | ||
| static_assert(Matrix::IsRowMajor || Matrix::IsVectorAtCompileTime, | ||
| "The default storage order in OGS is row major storage for " | ||
| "dense matrices."); | ||
| assert(Matrix::RowsAtCompileTime == Eigen::Dynamic || | ||
| Matrix::RowsAtCompileTime == rows); | ||
| assert(Matrix::ColsAtCompileTime == Eigen::Dynamic || | ||
| Matrix::ColsAtCompileTime == cols); | ||
| assert(static_cast<Eigen::MatrixXd::Index>(data.size()) == rows * cols); | ||
|
|
||
| return {data.data(), rows, cols}; | ||
| } | ||
|
|
||
| /*! Creates an Eigen mapped matrix from the given data vector. | ||
| * | ||
| * This is a convienence method which makes the specification of dynamically | ||
| * allocated Eigen matrices as return type easier. | ||
| */ | ||
| inline Eigen::Map< | ||
| const Eigen:: | ||
| Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>> | ||
| toMatrix(std::vector<double> const& data, | ||
| Eigen::MatrixXd::Index rows, | ||
| Eigen::MatrixXd::Index cols) | ||
| { | ||
| return toMatrix< | ||
| Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>>( | ||
| data, rows, cols); | ||
| } | ||
|
|
||
| /*! Creates an Eigen mapped matrix from the given data vector. | ||
| * | ||
| * \attention The data vector must have the same storage order (row or column | ||
| * major) as the requested matrix type. | ||
| */ | ||
| template <typename Matrix> | ||
| Eigen::Map<Matrix> toMatrix(std::vector<double>& data, | ||
| Eigen::MatrixXd::Index rows, | ||
| Eigen::MatrixXd::Index cols) | ||
| { | ||
| static_assert(Matrix::IsRowMajor || Matrix::IsVectorAtCompileTime, | ||
| "The default storage order in OGS is row major storage for " | ||
| "dense matrices."); | ||
| assert(Matrix::RowsAtCompileTime == Eigen::Dynamic || | ||
| Matrix::RowsAtCompileTime == rows); | ||
| assert(Matrix::ColsAtCompileTime == Eigen::Dynamic || | ||
| Matrix::ColsAtCompileTime == cols); | ||
| assert(static_cast<Eigen::MatrixXd::Index>(data.size()) == rows * cols); | ||
|
|
||
| return {data.data(), rows, cols}; | ||
| } | ||
|
|
||
| /*! Creates an Eigen mapped matrix from the given data vector. | ||
| * | ||
| * This is a convienence method which makes the specification of dynamically | ||
| * allocated Eigen matrices as return type easier. | ||
| */ | ||
| inline Eigen::Map< | ||
| Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>> | ||
| toMatrix(std::vector<double>& data, | ||
| Eigen::MatrixXd::Index rows, | ||
| Eigen::MatrixXd::Index cols) | ||
| { | ||
| return toMatrix< | ||
| Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>>( | ||
| data, rows, cols); | ||
| } | ||
|
|
||
| /*! Creates an Eigen mapped vector having its entries stored in the given | ||
| * \c data vector. | ||
| * | ||
| * \return An Eigen mapped vector of the given size. All values of the vector | ||
| * are set to zero. | ||
| * | ||
| * \pre The passed \c data vector must have zero size. | ||
| * \post The \c data has size \c size. | ||
| */ | ||
| template <typename Vector> | ||
| Eigen::Map<Vector> createZeroedVector(std::vector<double>& data, | ||
| Eigen::VectorXd::Index size) | ||
| { | ||
| static_assert(Vector::IsVectorAtCompileTime, "A vector type is required."); | ||
| assert(Vector::SizeAtCompileTime == Eigen::Dynamic || | ||
| Vector::SizeAtCompileTime == size); | ||
| assert(data.empty()); // in order that resize fills the vector with zeros. | ||
|
|
||
| data.resize(size); | ||
| return {data.data(), size}; | ||
| } | ||
|
|
||
| //! Creates an Eigen mapped vector from the given data vector. | ||
| template <typename Vector> | ||
| Eigen::Map<const Vector> toVector(std::vector<double> const& data, | ||
| Eigen::VectorXd::Index size) | ||
| { | ||
| static_assert(Vector::IsVectorAtCompileTime, "A vector type is required."); | ||
| assert(Vector::SizeAtCompileTime == Eigen::Dynamic || | ||
| Vector::SizeAtCompileTime == size); | ||
| assert(static_cast<Eigen::VectorXd::Index>(data.size()) == size); | ||
|
|
||
| return {data.data(), size}; | ||
| } | ||
|
|
||
| //! Creates an Eigen mapped vector from the given data vector. | ||
| template <typename Vector> | ||
| Eigen::Map<Vector> toVector(std::vector<double>& data, | ||
| Eigen::VectorXd::Index size) | ||
| { | ||
| static_assert(Vector::IsVectorAtCompileTime, "A vector type is required."); | ||
| assert(Vector::SizeAtCompileTime == Eigen::Dynamic || | ||
| Vector::SizeAtCompileTime == size); | ||
| assert(static_cast<Eigen::VectorXd::Index>(data.size()) == size); | ||
|
|
||
| return {data.data(), size}; | ||
| } | ||
|
|
||
| } // MathLib | ||
|
|
||
| #endif // MATHLIB_EIGENMAPTOOLS_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For discussion: This problem is linear, why newton? what does it test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other tests of the linear GWFlow use Picard, which also doesn't make sense in a way.
It is tested that the central differences assembly works.