-
Notifications
You must be signed in to change notification settings - Fork 1
Mesh for anisotropic particles #52
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
6 commits
Select commit
Hold shift + click to select a range
58fa042
Extend center, lower_bound, upper_bound, shape, step and bin to highe…
mayukh33 e3dabd9
Fix multi-dimensional indexing
mayukh33 f374be9
Apply fix and add documentation
mayukh33 1ece6ab
Minor fix
mayukh33 fc8090e
Apply review suggestions and minor fixes
mayukh33 361bd9c
Revert .pre-commit-config.yaml
mayukh33 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,90 +8,177 @@ | |
|
|
||
| namespace flyft | ||
| { | ||
|
|
||
| //! Multidimensional mesh | ||
| /*! | ||
| * Multidimensional mesh maps N-dimensional indexing for | ||
| * the anistropic particles into one-dimensional flux. | ||
| */ | ||
| class Mesh | ||
| { | ||
| public: | ||
| //! No default constructor | ||
| Mesh() = delete; | ||
|
|
||
| //! Constructor | ||
| /*! | ||
| * \param lower_bound Lower bound of the N-dimensional mesh. | ||
| * \param upper_bound Upper bound of the N-dimensional mesh. | ||
| * \param shape Shape of the index array. | ||
| * \param lower_bc Boundary condition of the lower bound. | ||
| * \param upper_bc Boundary condition of the upper bound. | ||
| */ | ||
| Mesh(double lower_bound, | ||
| double upper_bound, | ||
| int shape, | ||
| BoundaryType lower_bc, | ||
| BoundaryType upper_bc); | ||
|
|
||
| std::shared_ptr<Mesh> slice(int start, int end) const; | ||
| //! Slice multidimensional index | ||
| /*! | ||
| * \param start Multidimensional start index. | ||
| * \param end Multidimensional end index. | ||
| * \return One-dimensional index. | ||
| * | ||
| */ | ||
| std::shared_ptr<Mesh> slice(const std::vector<int>& start, const std::vector<int>& end) const; | ||
|
|
||
| //! Get position on the mesh, defined as center of bin | ||
| double center(int i) const; | ||
| /*! | ||
| * \param i Multidimensional bin index | ||
| * \return Center of the multidimensional bin | ||
| */ | ||
| std::vector<double> center(const std::vector<int>& i) const; | ||
|
|
||
| //! Lower bound of entire mesh | ||
| double lower_bound() const; | ||
| /*! | ||
| * \return Lower bound of the multidimensional mesh | ||
| */ | ||
| std::vector<double> lower_bound() const; | ||
|
|
||
| //! Get lower bound of bin | ||
| double lower_bound(int i) const; | ||
| /*! | ||
| * \param i Multidimensional bin index | ||
| * \return Lower bound of the multidimensional bin | ||
| */ | ||
| std::vector<double> lower_bound(const std::vector<int>& i) const; | ||
|
|
||
| //! Upper bound of entire mesh | ||
| double upper_bound() const; | ||
| /*! | ||
| * \return Upper bound of the multidimensional mesh | ||
| */ | ||
| std::vector<double> upper_bound() const; | ||
|
|
||
| //! Get upper bound of bin | ||
| double upper_bound(int i) const; | ||
| /*! | ||
| * \param i Multidimensional bin index | ||
| * \return Upper bound of the multidimensional bin | ||
| */ | ||
| std::vector<double> upper_bound(const std::vector<int>& i) const; | ||
|
|
||
| //! Get surface area of lower edge of bin | ||
| /*! | ||
| * \param i Multidimensional bin index | ||
| * \return Upper bound of the multidimensional bin | ||
| */ | ||
| virtual double area(int i) const = 0; | ||
|
|
||
| //! Get volume of mesh | ||
| /*! | ||
| * \return Volume of the mesh | ||
| */ | ||
| virtual double volume() const = 0; | ||
|
|
||
| //! Get volume of bin | ||
| virtual double volume(int i) const = 0; | ||
| /*! | ||
| * \param i Multidimensional bin index | ||
| * \return Volume of the bin | ||
| */ | ||
| virtual std::vector<double> volume(int i) const = 0; | ||
|
|
||
| //! Get the bin for a coordinate | ||
| int bin(double x) const; | ||
| /*! | ||
| * \param x Coordinate position of the bin | ||
| * \return Bin index | ||
| */ | ||
| std::vector<int> bin(const std::vector<double>& x) const; | ||
|
|
||
| //! Length of the mesh | ||
| double L() const; | ||
| /*! | ||
| * \return Length of the mesh | ||
| */ | ||
| std::vector<double> L() const; | ||
|
|
||
| //! Shape of the mesh | ||
| int shape() const; | ||
| std::vector<int> shape() const; | ||
|
|
||
| //! Step size of the mesh | ||
| double step() const; | ||
| std::vector<double> step() const; | ||
|
|
||
| //! Boundary condition on lower bound of mesh | ||
| BoundaryType lower_boundary_condition() const; | ||
|
|
||
| //! Boundary condition on upper bound of mesh | ||
| BoundaryType upper_boundary_condition() const; | ||
|
|
||
| int asShape(double dx) const; | ||
|
|
||
| double asLength(int shape) const; | ||
|
|
||
| double integrateSurface(int idx, double j_lo, double j_hi) const; | ||
| double integrateSurface(int idx, const DataView<double>& j) const; | ||
| double integrateSurface(int idx, const DataView<const double>& j) const; | ||
|
|
||
| double integrateVolume(int idx, double f) const; | ||
| double integrateVolume(int idx, const DataView<double>& f) const; | ||
| double integrateVolume(int idx, const DataView<const double>& f) const; | ||
|
|
||
| //! Get the start index of the mesh | ||
| /*! | ||
| * \param dx Step size of the mesh | ||
| * \return Start index of the mesh | ||
| */ | ||
| std::vector<int> asShape(const std::vector<double>& dx) const; | ||
|
|
||
| //! Get the length of the mesh | ||
| /*! | ||
| * \param shape Shape of the mesh | ||
| * \return Length of the mesh | ||
| */ | ||
| std::vector<double> asLength(const std::vector<int>& shape) const; | ||
|
|
||
| //! Get the integral of the surface over the mesh | ||
| /*! | ||
| * \param shape Shape of the mesh | ||
| * \return Length of the mesh | ||
| */ | ||
| double integrateSurface(const std::vector<int>& idx, double j_lo, double j_hi) const; | ||
| double integrateSurface(const std::vector<int>& idx, const DataView<double>& j) const; | ||
| double integrateSurface(const std::vector<int>& idx, const DataView<const double>& j) const; | ||
|
Comment on lines
+137
to
+144
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you think about how these are going to work in the new code? Is it going to integrate over a specific face, or all of them? And what will it integrate? |
||
|
|
||
| //! Get the integral of the volume over the mesh | ||
| /*! | ||
| * \param idx Multidimensional index | ||
| * \param f Function to integrate | ||
| * \return Integral of the function over the mesh | ||
| */ | ||
| double integrateVolume(const std::vector<int>& idx, double f) const; | ||
| double integrateVolume(const std::vector<int>& idx, const DataView<double>& f) const; | ||
| double integrateVolume(const std::vector<int>& idx, const DataView<const double>& f) const; | ||
|
|
||
| //! Interpolate a function on the mesh | ||
| /*! | ||
| * \param x Coordinate position of the bin | ||
| * \param f Function to interpolate | ||
| * \return Interpolated function value | ||
| * | ||
| * The function is interpolated using linear interpolation. | ||
| */ | ||
| template<typename T> | ||
| typename std::remove_const<T>::type interpolate(double x, const DataView<T>& f) const; | ||
|
|
||
| virtual double gradient(int idx, double f_lo, double f_hi) const = 0; | ||
| double gradient(int idx, const DataView<const double>& f) const; | ||
| double gradient(int idx, const DataView<double>& f) const; | ||
| //! Get the gradient of the mesh | ||
| virtual double gradient(const std::vector<int>& idx, double f_lo, double f_hi) const = 0; | ||
| double gradient(const std::vector<int>& idx, const DataView<const double>& f) const; | ||
| double gradient(const std::vector<int>& idx, const DataView<double>& f) const; | ||
|
|
||
| bool operator==(const Mesh& other) const; | ||
| bool operator!=(const Mesh& other) const; | ||
|
|
||
| protected: | ||
| double lower_; | ||
| int shape_; //!< Shape of the mesh | ||
| BoundaryType lower_bc_; | ||
| BoundaryType upper_bc_; | ||
| double step_; //!< Spacing between mesh points | ||
| int start_; | ||
| std::vector<double> lower_; | ||
| std::vector<int> shape_; //!< Shape of the mesh | ||
| BoundaryType lower_bc_; //!< Boundary condition of the lower bound | ||
| BoundaryType upper_bc_; //!< Boundary condition of the upper bound | ||
| std::vector<double> step_; //!< Spacing between mesh points | ||
| std::vector<int> start_; | ||
|
|
||
| void validateBoundaryCondition() const; | ||
|
|
||
|
|
||
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 this method, what area is this going to return? Should it return the areas of all lower faces in some defined order? Or, should it take both an index to a bin and an index to a dimension and return the area of that lower face?
Or perhaps, it needs three arguments: bin, face, and +/- direction?