diff --git a/CMakeLists.txt b/CMakeLists.txt index 61f5350..211c737 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -129,7 +129,7 @@ add_subdirectory(src) # includes all third party libraries add_library(allium ${SOURCES} ${HEADERS}) target_link_libraries(allium PUBLIC ${MFEM_LIBRARIES} igraph::igraph - std::mdspan yaml-cpp::yaml-cpp ${LUA_LIBRARIES} sol2::sol2 OpenMP::OpenMP_CXX) + mdspan::mdspan yaml-cpp::yaml-cpp ${LUA_LIBRARIES} sol2::sol2 OpenMP::OpenMP_CXX) target_include_directories(allium PUBLIC ${MFEM_INCLUDE_DIRS} ${CMAKE_BINARY_DIR}/config ${PROJECT_SOURCE_DIR}/src ${LUA_INCLUDE_DIR}) @@ -206,4 +206,4 @@ configure_package_config_file( "${PROJECT_SOURCE_DIR}/data/${PROJECT_NAME}-config.cmake.in" "${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake" INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}-${PROJECT_VERSION} -) \ No newline at end of file +) diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..8a8a704 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,431 @@ +# GNU LIBRARY GENERAL PUBLIC LICENSE + +Version 2, June 1991 + + Copyright (C) 1991 Free Software Foundation, Inc. + + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +## Preamble + +The licenses for most software are designed to take away your freedom +to share and change it. By contrast, the GNU General Public Licenses +are intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. + +This license, the Library General Public License, applies to some +specially designated Free Software Foundation software, and to any +other libraries whose authors decide to use it. You can use it for +your libraries, too. + +When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + +To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if +you distribute copies of the library, or if you modify it. + +For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link a program with the library, you must provide +complete object files to the recipients so that they can relink them +with the library, after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + +Our method of protecting your rights has two steps: (1) copyright the +library, and (2) offer you this license which gives you legal +permission to copy, distribute and/or modify the library. + +Also, for each distributor's protection, we want to make certain that +everyone understands that there is no warranty for this free library. +If the library is modified by someone else and passed on, we want its +recipients to know that what they have is not the original version, so +that any problems introduced by others will not reflect on the +original authors' reputations. + +Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that companies distributing free +software will individually obtain patent licenses, thus in effect +transforming the program into proprietary software. To prevent this, +we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + +Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License, which was designed for utility +programs. This license, the GNU Library General Public License, +applies to certain designated libraries. This license is quite +different from the ordinary one; be sure to read it in full, and don't +assume that anything in it is the same as in the ordinary license. + +The reason we have a separate public license for some libraries is +that they blur the distinction we usually make between modifying or +adding to a program and simply using it. Linking a program with a +library, without changing the library, is in some sense simply using +the library, and is analogous to running a utility program or +application program. However, in a textual and legal sense, the linked +executable is a combined work, a derivative of the original library, +and the ordinary General Public License treats it as such. + +Because of this blurred distinction, using the ordinary General Public +License for libraries did not effectively promote software sharing, +because most developers did not use the libraries. We concluded that +weaker conditions might promote sharing better. + +However, unrestricted linking of non-free programs would deprive the +users of those programs of all benefit from the free status of the +libraries themselves. This Library General Public License is intended +to permit developers of non-free programs to use free libraries, while +preserving your freedom as a user of such programs to change the free +libraries that are incorporated in them. (We have not seen how to +achieve this as regards changes in header files, but we have achieved +it as regards changes in the actual functions of the Library.) The +hope is that this will lead to faster development of free libraries. + +The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, while the latter only +works together with the library. + +Note that it is possible for a library to be covered by the ordinary +General Public License rather than by this special one. + +## TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +**0.** This License Agreement applies to any software library which +contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Library +General Public License (also called "this License"). Each licensee is +addressed as "you". + +A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + +The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + +"Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control +compilation and installation of the library. + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does and +what the program that uses the Library does. + +**1.** You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a +fee. + +**2.** You may modify your copy or copies of the Library or any +portion of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + +- **a)** The modified work must itself be a software library. +- **b)** You must cause the files modified to carry prominent + notices stating that you changed the files and the date of + any change. +- **c)** You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. +- **d)** If a facility in the modified Library refers to a function + or a table of data to be supplied by an application program that + uses the facility, other than as an argument passed when the + facility is invoked, then you must make a good faith effort to + ensure that, in the event an application does not supply such + function or table, the facility still operates, and performs + whatever part of its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of + the application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + +**3.** You may opt to apply the terms of the ordinary GNU General +Public License instead of this License to a given copy of the Library. +To do this, you must alter all the notices that refer to this License, +so that they refer to the ordinary GNU General Public License, version +2, instead of to this License. (If a newer version than version 2 of +the ordinary GNU General Public License has appeared, then you can +specify that version instead if you wish.) Do not make any other +change in these notices. + +Once this change is made in a given copy, it is irreversible for that +copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + +This option is useful when you wish to copy part of the code of the +Library into a program that is not a library. + +**4.** You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + +If distribution of object code is made by offering access to copy from +a designated place, then offering equivalent access to copy the source +code from the same place satisfies the requirement to distribute the +source code, even though third parties are not compelled to copy the +source along with the object code. + +**5.** A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a work, +in isolation, is not a derivative work of the Library, and therefore +falls outside the scope of this License. + +However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. Section +6 states terms for distribution of such executables. + +When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + +If such an object file uses only numerical parameters, data structure +layouts and accessors, and small macros and small inline functions +(ten lines or less in length), then the use of the object file is +unrestricted, regardless of whether it is legally a derivative work. +(Executables containing this object code plus portions of the Library +will still fall under Section 6.) + +Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + +**6.** As an exception to the Sections above, you may also compile or +link a "work that uses the Library" with the Library to produce a work +containing portions of the Library, and distribute that work under +terms of your choice, provided that the terms permit modification of +the work for the customer's own use and reverse engineering for +debugging such modifications. + +You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + +- **a)** Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood that + the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) +- **b)** Accompany the work with a written offer, valid for at least + three years, to give the same user the materials specified in + Subsection 6a, above, for a charge no more than the cost of + performing this distribution. +- **c)** If distribution of the work is made by offering access to + copy from a designated place, offer equivalent access to copy the + above specified materials from the same place. +- **d)** Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + +For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the source code distributed need not include anything that is normally +distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + +It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + +**7.** You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + +- **a)** Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other + library facilities. This must be distributed under the terms of + the Sections above. +- **b)** Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + +**8.** You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + +**9.** You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + +**10.** Each time you redistribute the Library (or any work based on +the Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + +**11.** If, as a consequence of a court judgment or allegation of +patent infringement or for any other reason (not limited to patent +issues), conditions are imposed on you (whether by court order, +agreement or otherwise) that contradict the conditions of this +License, they do not excuse you from the conditions of this License. +If you cannot distribute so as to satisfy simultaneously your +obligations under this License and any other pertinent obligations, +then as a consequence you may not distribute the Library at all. For +example, if a patent license would not permit royalty-free +redistribution of the Library by all those who receive copies directly +or indirectly through you, then the only way you could satisfy both it +and this License would be to refrain entirely from distribution of the +Library. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply, and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + +**12.** If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + +**13.** The Free Software Foundation may publish revised and/or new +versions of the Library General Public License from time to time. Such +new versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + +**14.** If you wish to incorporate parts of the Library into other +free programs whose distribution conditions are incompatible with +these, write to the author to ask for permission. For software which +is copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + +**NO WARRANTY** + +**15.** BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +**16.** IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/README.md b/README.md index ad088c2..fbf27c0 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,73 @@ -# Overview -* `exe/`: - * `chive.cpp`: driver for steady-state, mono-energetic, neutral particle transport supporting - * P1, Local Discontinuous Galerkin, and Modified Interior Penalty diffusion synthetic acceleration preconditioners for fixed-point and Krylov solvers - * Independent Local Discontinuous Galerkin Second Moment Method - * arbitrary material descriptions and mesh composition - * Lua input system - * parallel decomposition with full upwind sweep - * output is YAML-parsable - * `scallion.cpp`: gray thermal radiative transfer - * backward Euler time integration - * Picard, Newton, one Newton algorithms - * `green.cpp`: gray thermal radiative transfer with consistent second moment methods - * `spring.cpp`: gray diffusion thermal radiative transfer - * `garlic.cpp`: Lagrange hydro + radiation diffusion (under development) -* `inputs/`: example inputs for `chive` and `scallion` -* `tests/`: collection of tests using the GoogleTest framework. Run with `ctest`. -* `scripts/`: post-processing python files, build scripts +# allium: a high-performance library for deterministic thermal radiative transfer +*allium* is a software framework designed to facilitate the development and analysis of numerical algorithms relevant to radiation transport. Built on top of the MFEM finite element library, this package integrates a range of third-party dependencies, such as hypre, SUNDIALS, igraph, Lua, YAML, and GoogleTest, to provide an agile environment capable of rapid prototyping. The package is designed to scale well on massively parallel, CPU-based computer architectures through the utilization of MPI, OpenMP, and the high-performance implementations provided by the dependent packages. This allows testing novel algorithms at a computational scale not typically investigated in traditional academic literature. *allium* is comprised of a robust build system, core source code implementing both established and novel numerical methods, a suite of drivers that accept Lua-based input files and exercise the solution algorithms, and python scripts that facilitate the processing of the output from the drivers for publication in journal articles. In addition, a comprehensive set of tests ensures reliability and supports ongoing research and application development. Through its modular design and use of high-quality third party libraries, this package is uniquely suited to support academic research into the mathematical algorithms that underpin the simulation of radiation transport. +
+ +
+ Material temperature of Marshak problem on a star-shaped domain +
+ +# Project Overview +*allium* is a software framework providing +* CMake build system +* suite of unit and integral tests driven by CTest and GoogleTest +* Lua-based input system +* YAML-compatible terminal output system +* upwind Discontinuous Galerkin transport discretization with **MPI-parallel fully upwind sweep** and OpenMP threading +* a variety of diffusion-based acceleration and preconditioning techniques +* support for fixed-point, Krylov solvers, and advanced nonlinear solvers +* thermal radiative transfer physics components such as opacities, Planck emission, etc +* support for arbitrary meshes in 1, 2, and 3 dimensions +* visualization via VisIt, Paraview, and GLVis + +This package has been designed under the following design philosophies: +* separation of concerns: the library is designed so that its components, such as input/output, data structures, and computations, are weakly coupled. +* single responsibility principle: code units (classes, free functions, etc) do only one of input/output, storage of data, or computations, further separating concerns and reducing edge cases. +* dependency injection/inversion: objects accept fully configured dependencies enabling access to low-level configuration without exposing low-level details. +* composition over inheritance: functionality is assembled from small, focused components. Modularity is achieved through shallow inheritance hierarchies from simple and generic base classes. + +These design principles have resulted in a focused core library where the user has the control to compose core capabilities together to achieve a wide spectrum of functionality. +This approach has allowed significant control of and access to low-level details important for academic research while keeping the scope creep of a globally accessible design at bay. +In addition, weakly coupling components has allowed testing components independently and enables the ability to quickly create new physics drivers. +In general, *allium* has been designed to have all input/output, configuration, management of data lifetime, and execution flow within the `main` of the driver allowing the core library to be simple and extensible. +This design allows unexpected and out-of-scope concepts to be implemented with changes primarily restricted to the `main` function, reducing implementation burden. + +## Drivers +Physics capabilities are organized into a suite of drivers in the `exe/` directory. Example inputs and tests for each driver are provided in the correspondingly named directory in `inputs/` and `tests/`, respectively. Drivers are named after members of the allium genus. + +### chive +`chive` is a driver for steady-state, one-group, fixed-source transport problems often used as a proxy application for thermal radiative transfer. `chive` supports a variety of acceleration and preconditioning techniques including +* "fully consistent" P1 diffusion synthetic acceleration (DSA) +* Local Discontinuous Galerkin (LDG) DSA +* Modified Interior Penalty (MIP) DSA +* Interior Penalty and LDG-based Second Moment Methods (SMMs) + +Both fixed-point iteration and Krylov-based solvers are available. + +### scallion +`scallion` is a driver for multigroup, time-dependent thermal radiative transfer. Backward Euler time integration is used. `scallion` implements Picard, linearized, and full Newton solution algorithms. The linearized and Newton algorithms can be solved with Krylov or fixed-point iteration preconditioned with a subset of the algorithms implemented in `chive`. `scallion` supports +* trace plots (output solution at a point in space plotted over time) +* restarting from a previous simulation +* analytic and tabular opacity data +* implicit and explicit treatment of opacities +* variable time steps defined by a function or table + +### green +`green` is a variant of `scallion` that uses the Second Moment Method (SMM) to solve the equations of thermal radiative transfer. Where `scallion` evolves the intensity and material temperature, `green` evolves the intensity, low-order moments, and material temperature. This subtle difference motivated separating the two sets of methods into separate drivers. `green` is intended to parallel `scallion` and is thus compatible with all inputs to `scallion`. + +### ramp +`ramp` is simplification of `green` which only solves the low-order system (e.g. radiation diffusion). + +## Scripts +Post-processing scripts are provided in `scripts/` +* `inspect`: opens a YAML-compatible terminal output file and indexes into the YAML tree +* `gridfunction.py`: class for loading and plotting 1D `mfem::GridFunction` +* `plot_tracer.py`: plots tracers over time +* `plot_visit.py`: uses `gridfunction.py` to plot MFEM's VisIt output format over time +* `darwin/build.sh`: example build script (including all third party libraries) for linux-based systems # Building +An example build script is provided in [scripts/darwin/build.sh](scripts/darwin/build.sh) for linux-based system. MFEM handles the majority of the often troublesome scientific software dependencies. Thus, please use MFEM's documentation as a starting point. + ## Required Dependencies * [MFEM](https://github.com/mfem/mfem) built with * MPI @@ -38,7 +88,19 @@ * [GSLIB](https://github.com/Nek5000/gslib) * [GoogleTest](https://github.com/google/googletest.git) -## Installing -### Darwin -Steps to build on Darwin are documented in `scripts/darwin/build.sh`. From the root directory run `source scripts/darwin/build.sh`. By default this builds all dependencies in the directory `tpl` though this behavior can be changed. -An example module file is provided in `scripts/darwin/module_file.lua`. Change the path to allium's build directory and copy into a place where Lmod knows to look for module files. \ No newline at end of file +# Authors +*allium* was written by [Samuel Olivier](https://samolivier.net) while a Nicholas C. Metropolis postdoctoral fellow at the Los Alamos National Laboratory. + +# Peer-Reviewed Journal Articles that Use allium +1. [Consistent Second Moment Methods with Scalable Linear Solvers for Radiation Transport](https://arxiv.org/abs/2404.17473) +2. [A Comparison of the Consistent and Independent Second Moment Methods Applied to Thermal Radiative Transfer](https://arxiv.org/abs/2504.21784) +3. [Implicit Opacities in Thermal Radiative Transfer](https://samolivier.net/wp-content/uploads/pres/mc25_paper.pdf) +4. [Preconditioning transformations of adjoint systems for evolution equations](https://arxiv.org/abs/2505.21705) + +# Release +* [GPL 2.0 license](LICENSE.md) +* LANL code designation: O5022 + +© 2026. Triad National Security, LLC. All rights reserved. + +This program was produced under U.S. Government contract 89233218CNA000001 for Los Alamos National Laboratory (LANL), which is operated by Triad National Security, LLC for the U.S. Department of Energy/National Nuclear Security Administration. All rights in the program are reserved by Triad National Security, LLC, and the U.S. Department of Energy/National Nuclear Security Administration. The Government is granted for itself and others acting on its behalf a nonexclusive, paid-up, irrevocable worldwide license in this material to reproduce, prepare. derivative works, distribute copies to the public, perform publicly and display publicly, and to permit others to do so. \ No newline at end of file diff --git a/doc/star.png b/doc/star.png new file mode 100644 index 0000000..4fa1836 Binary files /dev/null and b/doc/star.png differ diff --git a/scripts/darwin/build.sh b/scripts/darwin/build.sh index 89256e3..c82cf5d 100644 --- a/scripts/darwin/build.sh +++ b/scripts/darwin/build.sh @@ -6,6 +6,10 @@ # NOTE: compilation is done in parallel so allocate # a node with `salloc` first +## ON OTHER HPC PLATFORMS, COMMENT OUT THE MODULE LOAD COMMAND BELOW AND LOAD +## THE EQUIVALENT MODULES ON YOUR SYSTEM. THIS SCRIPT HAS BEEN TESTED ON +## OTHER NNSA CPU BASED SYSTEMS + # number of processors to use with make nproc=36 ROOT=$(pwd) @@ -35,9 +39,22 @@ git clone https://github.com/google/googletest.git git clone https://github.com/LLNL/sundials.git git clone https://github.com/Nek5000/gslib +# pin all repos to specific SHAs for reproducibility +git -C hypre checkout 7e7fc8ce09153c60ae538a52a5f870f93b9608ca +git -C sundials checkout aaeab8d907c6b7dfca86041401fdc1448f35f826 +git -C igraph checkout beebfcdcd707f50a31cf8eb3568cf09f8b7baf54 +git -C mfem checkout 171eeb403f8d8deadfbd64d547de43c8705e616c +git -C superlu_dist checkout 4ae28e6f6d38f4f1fd3da88bd040f756d1275844 +git -C libunwind checkout c19e28b0e8682155482d937131fd5b1553044a66 +git -C mdspan checkout 80fc772eb812b45097c28fc0a46d8ff006138d69 +git -C yaml-cpp checkout 8bcadb1509e63248e79c6dc09928f95cfae02b74 +git -C sol2 checkout c1f95a773c6f8f4fde8ca3efe872e7286afe4444 +git -C googletest checkout 94be250af7e14c58dcbf476972d2d7141551ff67 +git -C gslib checkout 95acf5b42301d6cb48fda88d662f1d784b863089 +git -C tpls checkout 486dd7171e67629fc85393479f710e821e0e8b77 + # --- build hypre --- cd ${TPL}/hypre/ -git checkout v2.31.0 cd src/cmbuild cmake .. -DCMAKE_BUILD_TYPE=Release # installs into hypre/src/hypre/lib64 @@ -71,7 +88,6 @@ make install -j${nproc} # --- sundials --- cd ${TPL}/sundials -git checkout v6.7.0 mkdir build install cd build cmake .. \ @@ -85,8 +101,7 @@ cd ${TPL}/gslib make CC=mpicc # --- build mfem --- -cd ${TPL}/mfem -git checkout smsolivier/ldg +cd ${TPL}/mfem mkdir build install cd build cmake .. \ @@ -180,4 +195,4 @@ export OMP_NUM_THREADS=1 # run tests in parallel # separating serial vs parallel to not # over prescribe threads -ctest -j ${nproc} -L serial && ctest -j 4 -L parallel +ctest -j ${nproc} -L serial && ctest -j 4 -L parallel diff --git a/scripts/linux/build.sh b/scripts/linux/build.sh new file mode 100644 index 0000000..bf0adec --- /dev/null +++ b/scripts/linux/build.sh @@ -0,0 +1,201 @@ +#!/bin/bash + +# script to download and install all third party libraries (TPLs) +# downloads TPLs into the directory specified by TPL variable +# designed to work on Ubuntu Linux +# NOTE: compilation is done in parallel so allocate +# a node with `salloc` first + +# number of processors to use with make +nproc=1 +ROOT=$(pwd) +# where to download and build all third party libraries +# this location can be external to allium +TPL=${ROOT}/tpl + +# --- install system prerequisites (Ubuntu) --- +# --- install system prerequisites (Ubuntu) --- +sudo apt-get update +sudo apt-get install -y \ + build-essential cmake git \ + mpich libmpich-dev \ + autoconf automake libtool \ + liblapack-dev libblas-dev \ + zlib1g-dev \ + lua5.3 liblua5.3-dev + +# architecture string used in ParMETIS build output paths +ARCH=$(uname -m) + +# create directory for tpls +mkdir -p ${TPL} + +# --- clone dependencies into project source --- +cd ${TPL} + +git clone https://github.com/mfem/mfem.git +git clone https://github.com/hypre-space/hypre.git +git clone https://github.com/mfem/tpls.git +git clone https://github.com/libunwind/libunwind.git +git clone https://github.com/xiaoyeli/superlu_dist.git +git clone https://github.com/igraph/igraph.git +git clone https://github.com/kokkos/mdspan.git +git clone https://github.com/jbeder/yaml-cpp.git +git clone https://github.com/ThePhD/sol2.git +git clone https://github.com/google/googletest.git +git clone https://github.com/LLNL/sundials.git +git clone https://github.com/Nek5000/gslib + +git -C hypre checkout 7e7fc8ce09153c60ae538a52a5f870f93b9608ca +git -C sundials checkout aaeab8d907c6b7dfca86041401fdc1448f35f826 +git -C igraph checkout beebfcdcd707f50a31cf8eb3568cf09f8b7baf54 +git -C mfem checkout 171eeb403f8d8deadfbd64d547de43c8705e616c +git -C superlu_dist checkout 4ae28e6f6d38f4f1fd3da88bd040f756d1275844 +git -C libunwind checkout c19e28b0e8682155482d937131fd5b1553044a66 +git -C mdspan checkout 80fc772eb812b45097c28fc0a46d8ff006138d69 +git -C yaml-cpp checkout 8bcadb1509e63248e79c6dc09928f95cfae02b74 +git -C sol2 checkout c1f95a773c6f8f4fde8ca3efe872e7286afe4444 +git -C googletest checkout 94be250af7e14c58dcbf476972d2d7141551ff67 +git -C gslib checkout 95acf5b42301d6cb48fda88d662f1d784b863089 +git -C tpls checkout 486dd7171e67629fc85393479f710e821e0e8b77 + +# --- build hypre --- +cd ${TPL}/hypre/ +cd src/cmbuild +cmake .. -DCMAKE_BUILD_TYPE=Release +# installs into hypre/src/hypre/lib +make install -j${nproc} + +# --- build parmetis --- +cd ${TPL} +# unpack from mfem tpl repo +tar -xvf tpls/parmetis-4.0.3.tar.gz +PMROOT=${TPL}/parmetis-4.0.3/ +cd ${PMROOT} +make config prefix=install +make install -j${nproc} + +# --- build libunwind --- +cd ${TPL}/libunwind +autoreconf -i +./configure --prefix=$(pwd)/install +make install -j${nproc} + +# --- build superlu --- +cd ${TPL}/superlu_dist +mkdir build install +cd build +cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=../install \ + -DTPL_PARMETIS_INCLUDE_DIRS="${PMROOT}/include;${PMROOT}/metis/include/" \ + -DTPL_PARMETIS_LIBRARIES="${PMROOT}/build/Linux-${ARCH}/libparmetis/libparmetis.a;${PMROOT}/build/Linux-${ARCH}/libmetis/libmetis.a" +make install -j${nproc} + +# --- sundials --- +cd ${TPL}/sundials +mkdir build install +cd build +cmake .. \ + -DENABLE_MPI=ON \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=../install +make install -j${nproc} + +# --- gslib --- +cd ${TPL}/gslib +make CC=mpicc + +# --- build mfem --- +cd ${TPL}/mfem +mkdir build install +cd build +cmake .. \ + -DMFEM_USE_MPI=TRUE \ + -DHYPRE_DIR=${TPL}/hypre/src/hypre/ \ + -DMETIS_DIR=${PMROOT}/build/Linux-${ARCH}/libmetis \ + -DMETIS_INCLUDE_DIR=${PMROOT}/metis/include \ + -DMFEM_USE_LIBUNWIND=TRUE \ + -DLIBUNWIND_DIR=${TPL}/libunwind/install \ + -DMFEM_USE_SUPERLU=TRUE \ + -DSuperLUDist_DIR=${TPL}/superlu_dist/install \ + -DParMETIS_DIR=${PMROOT}/build/Linux-${ARCH}/libparmetis/ \ + -DParMETIS_INCLUDE_DIR=${PMROOT}/include/ \ + -DMFEM_USE_SUNDIALS=TRUE \ + -DSUNDIALS_DIR=${TPL}/sundials/install/ \ + -DMFEM_USE_GSLIB=ON \ + -DGSLIB_DIR=${TPL}/gslib/build \ + -DMFEM_USE_OPENMP=TRUE \ + -DCMAKE_INSTALL_PREFIX=../install \ + -DCMAKE_BUILD_TYPE=Release +make install -j${nproc} +# test linker by building examples +make examples -j${nproc} + +# --- build igraph --- +cd ${TPL}/igraph +mkdir build install +cd build +cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=../install +make install -j${nproc} + +# --- mdspan --- +cd ${TPL}/mdspan +mkdir build install +cd build +cmake .. \ + -DCMAKE_INSTALL_PREFIX=../install +make install + +# --- yaml --- +cd ${TPL}/yaml-cpp +mkdir build install +cd build +cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=../install +make install + +# --- sol2 --- +cd ${TPL}/sol2 +mkdir build install +cd build +cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=../install \ + -DSOL2_BUILD_LUA=FALSE \ + -DSOL2_LUA_VERSION=5.3 +make install + +# --- googletest --- +cd ${TPL}/googletest +mkdir build install +cd build +cmake .. \ + -DCMAKE_INSTALL_PREFIX=../install \ + -DCMAKE_BUILD_TYPE=Release +make install + +# --- finally build allium --- +cd ${ROOT} +mkdir build +cd build +cmake .. \ + -Dmfem_DIR=${TPL}/mfem/install/lib/cmake/mfem \ + -Digraph_DIR=${TPL}/igraph/install/lib/cmake/igraph \ + -Dmdspan_DIR=${TPL}/mdspan/install/lib/cmake/mdspan \ + -Dyaml-cpp_DIR=${TPL}/yaml-cpp/install/lib/cmake/yaml-cpp \ + -Dsol2_DIR=${TPL}/sol2/install/share/cmake/sol2 \ + -DGTest_ROOT=${TPL}/googletest/install/lib/cmake/GTest \ + -DENABLE_UNIT_TESTS=TRUE \ + -DENABLE_CHIVE_TESTS=TRUE \ + -DCMAKE_BUILD_TYPE=Release +make -j${nproc} +# -- run tests -- +# explicitly set threads so SuperLU doesn't slow to a crawl +export OMP_NUM_THREADS=1 +# run tests in parallel +# separating serial vs parallel to not over-prescribe threads +ctest -j ${nproc} -L serial && ctest -j 4 -L parallel \ No newline at end of file diff --git a/scripts/mac/apple_clang.sh b/scripts/mac/apple_clang.sh new file mode 100644 index 0000000..7376714 --- /dev/null +++ b/scripts/mac/apple_clang.sh @@ -0,0 +1,231 @@ +#!/bin/bash + +# build all tpls + allium on M1/M2 mac. The script was tested on a system with strict permissions in place, +# and so not all make & make install commands have -j$(nproc). If your system allows it, +# you can place -j$(nproc) when "make" or "make install" needs to be called. + +# The script should be run from the alllium parent directory, e.g. 'source ./scripts/mac/apple_clang.sh' + +# --- Configuration --- +nproc=$(sysctl -n hw.logicalcpu) +ROOT=$(pwd) +TPL=${ROOT}/tpl +ARCH=$(uname -m) +OS=$(uname -s) + +# install roots +export SUPERLU_INSTALL="${TPL}/superlu_dist/install_dir" +export SUNDIALS_INSTALL="${TPL}/sundials/install_dir" + +# --- 1. System Prerequisites --- +brew install cmake git libomp autoconf automake libtool lua@5.4 open-mpi gcc + +# Prefixes +export OMP_PREFIX=$(brew --prefix libomp) +export LUA_PREFIX=$(brew --prefix lua@5.4) +GCC_PREFIX=$(brew --prefix gcc) +GCC_LIBDIR="${GCC_PREFIX}/lib/gcc/current" +export LDFLAGS="-L${GCC_LIBDIR}" +export DYLD_LIBRARY_PATH="${GCC_LIBDIR}:${DYLD_LIBRARY_PATH}" + +# --- 2. Use Apple Clang as the base compiler --- +export OMPI_CC=/usr/bin/clang +export OMPI_CXX=/usr/bin/clang++ +if command -v gfortran >/dev/null 2>&1; then + export OMPI_FC=gfortran +else + export OMPI_FC=$(basename $(ls ${GCC_PREFIX}/bin/gfortran-* | head -n1)) +fi + +# MPI wrappers used by builds +export CC=mpicc +export CXX=mpicxx +export FC=mpifort + +# --- 3. OpenMP flags --- +export OPENMP_FLAGS="-Xpreprocessor -fopenmp -I${OMP_PREFIX}/include" +export OPENMP_LDFLAGS="-L${OMP_PREFIX}/lib -lomp" + +# --- 4. CMake flags bundle --- +export CMAKE_OPENMP_FLAGS=" +-DOpenMP_C_FLAGS='${OPENMP_FLAGS}' +-DOpenMP_C_LIB_NAMES='omp' +-DOpenMP_CXX_FLAGS='${OPENMP_FLAGS}' +-DOpenMP_CXX_LIB_NAMES='omp' +-DOpenMP_omp_LIBRARY='${OMP_PREFIX}/lib/libomp.dylib' +" + +mkdir -p "${TPL}" + +# --- 2. Clone & Checkout --- +cd "${TPL}" +repos=( "mfem/mfem" + "hypre-space/hypre" + "mfem/tpls" + "libunwind/libunwind" + "xiaoyeli/superlu_dist" + "igraph/igraph" + "kokkos/mdspan" + "jbeder/yaml-cpp" + "ThePhD/sol2" + "google/googletest" + "LLNL/sundials" + "Nek5000/gslib" ) + +for repo in "${repos[@]}"; do + dir=$(basename "$repo") + if [ ! -d "$dir" ]; then + git clone "https://github.com/${repo}.git" + fi +done + +# Checkout specific SHAs +git -C hypre checkout 7e7fc8ce09153c60ae538a52a5f870f93b9608ca +git -C sundials checkout aaeab8d907c6b7dfca86041401fdc1448f35f826 +git -C igraph checkout beebfcdcd707f50a31cf8eb3568cf09f8b7baf54 +git -C mfem checkout 171eeb403f8d8deadfbd64d547de43c8705e616c +git -C superlu_dist checkout 4ae28e6f6d38f4f1fd3da88bd040f756d1275844 +git -C libunwind checkout c19e28b0e8682155482d937131fd5b1553044a66 +git -C mdspan checkout 80fc772eb812b45097c28fc0a46d8ff006138d69 +git -C yaml-cpp checkout 8bcadb1509e63248e79c6dc09928f95cfae02b74 +git -C sol2 checkout c1f95a773c6f8f4fde8ca3efe872e7286afe4444 +git -C googletest checkout 94be250af7e14c58dcbf476972d2d7141551ff67 +git -C gslib checkout 95acf5b42301d6cb48fda88d662f1d784b863089 +git -C tpls checkout 486dd7171e67629fc85393479f710e821e0e8b77 + +# --- 3. Build TPLs --- + +## HYPRE +cd "${TPL}/hypre/src" +rm -rf cmbuild +mkdir cmbuild && cd cmbuild +cmake .. +make && make install + +## ParMETIS +cd "${TPL}" +tar -xf tpls/parmetis-4.0.3.tar.gz +PMROOT="${TPL}/parmetis-4.0.3" +cd "${PMROOT}" +sed -i '' 's/cmake_minimum_required(VERSION 2.8)/cmake_minimum_required(VERSION 3.5)/g' CMakeLists.txt +sed -i '' 's/cmake_minimum_required(VERSION 2.4)/cmake_minimum_required(VERSION 3.5)/g' metis/CMakeLists.txt +make config prefix=install +make install -j${nproc} +PM_INSTALL=${PMROOT}/build/${OS}-${ARCH} + + +## SuperLU_DIST +cd "${TPL}/superlu_dist" +rm -rf build install_dir && mkdir build install_dir && cd build +cmake .. \ + -DCMAKE_INSTALL_PREFIX="${SUPERLU_INSTALL}" \ + -DCMAKE_EXE_LINKER_FLAGS="-L${GCC_LIBDIR} -Wl,-rpath,${GCC_LIBDIR}" \ + -DCMAKE_SHARED_LINKER_FLAGS="-L${GCC_LIBDIR} -Wl,-rpath,${GCC_LIBDIR}" \ + -DTPL_PARMETIS_INCLUDE_DIRS="${PMROOT}/include;${PMROOT}/metis/include" \ + -DTPL_PARMETIS_LIBRARIES="${PM_INSTALL}/libparmetis/libparmetis.a;${PM_INSTALL}/libmetis/libmetis.a" +make install + +## SUNDIALS +cd "${TPL}/sundials" +rm -rf build install_dir && mkdir build install_dir && cd build +cmake .. \ + -DCMAKE_INSTALL_PREFIX="${SUNDIALS_INSTALL}" \ + -DENABLE_MPI=ON \ + -DEXAMPLES_INSTALL=OFF +make install -j${nproc} + +## GSLIB +cd "${TPL}/gslib" +make -j${nproc} + +## MFEM +cd "${TPL}/mfem" +rm -rf build install_dir && mkdir build install_dir && cd build +cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=../install_dir \ + -DMFEM_USE_MPI=ON \ + -DCMAKE_CXX_COMPILER=mpicxx \ + -DMFEM_USE_OPENMP=ON \ + -DOpenMP_C_FLAGS="-Xpreprocessor -fopenmp -I/opt/homebrew/opt/libomp/include" \ + -DOpenMP_C_LIB_NAMES="omp" \ + -DOpenMP_CXX_FLAGS="-Xpreprocessor -fopenmp -I/opt/homebrew/opt/libomp/include" \ + -DOpenMP_CXX_LIB_NAMES="omp" \ + -DOpenMP_omp_LIBRARY="/opt/homebrew/opt/libomp/lib/libomp.dylib" \ + -DHYPRE_DIR="${TPL}/hypre/src/hypre" \ + -DParMETIS_INCLUDE_DIR="${PM_INSTALL}/include" \ + -DParMETIS_LIBRARY="${PM_INSTALL}/libparmetis/libparmetis.a" \ + -DMETIS_LIBRARY="${PM_INSTALL}/libmetis/libmetis.a" \ + -DMFEM_USE_SUPERLU=ON \ + -DSuperLUDist_DIR="${SUPERLU_INSTALL}" \ + -DMFEM_USE_SUNDIALS=ON \ + -DSUNDIALS_DIR="${SUNDIALS_INSTALL}" \ + -DMFEM_USE_GSLIB=ON \ + -DGSLIB_DIR="${TPL}/gslib/build/" \ + -DMFEM_USE_LIBUNWIND=ON +make && make install + +cd "${TPL}/igraph" +rm -rf build install && mkdir build install && cd build +cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=../install \ + -DCMAKE_C_COMPILER=mpicc \ + -DCMAKE_CXX_COMPILER=mpicxx +make install -j${nproc} + +## Remaining C++ dependencies +for dep in mdspan yaml-cpp googletest; do + cd "${TPL}/${dep}" + rm -rf build install && mkdir build install && cd build + cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=../install \ + -DCMAKE_C_COMPILER=mpicc \ + -DCMAKE_CXX_COMPILER=mpicxx + make install -j${nproc} +done + +## Sol2 +cd "${TPL}/sol2" +rm -rf build install && mkdir build install && cd build +cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=../install \ + -DSOL2_BUILD_LUA=FALSE \ + -DSOL2_LUA_VERSION=5.4 \ + -DLUA_INCLUDE_DIR="${LUA_PREFIX}/include/lua5.4" \ + -DLUA_LIBRARIES="${LUA_PREFIX}/lib/liblua5.4.dylib" +make install + +# --- 4. Build Allium --- +cd "${ROOT}" +rm -rf build && mkdir build && cd build +cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_C_COMPILER=mpicc \ + -DCMAKE_CXX_COMPILER=mpicxx \ + -Dmfem_DIR="${TPL}/mfem/install_dir/lib/cmake/mfem" \ + -Digraph_DIR="${TPL}/igraph/install/lib/cmake/igraph" \ + -Dmdspan_DIR="${TPL}/mdspan/install/lib/cmake/mdspan" \ + -Dyaml-cpp_DIR="${TPL}/yaml-cpp/install/lib/cmake/yaml-cpp" \ + -Dsol2_DIR="${TPL}/sol2/install/share/cmake/sol2" \ + -DGTest_ROOT="${TPL}/googletest/install/lib/cmake/GTest" \ + -DOpenMP_C_FLAGS="-Xpreprocessor -fopenmp -I/opt/homebrew/opt/libomp/include" \ + -DOpenMP_C_LIB_NAMES="omp" \ + -DOpenMP_CXX_FLAGS="-Xpreprocessor -fopenmp -I/opt/homebrew/opt/libomp/include" \ + -DOpenMP_CXX_LIB_NAMES="omp" \ + -DOpenMP_omp_LIBRARY="/opt/homebrew/opt/libomp/lib/libomp.dylib" \ + -DENABLE_UNIT_TESTS=TRUE \ + -DENABLE_CHIVE_TESTS=TRUE +make + +# -- run tests -- +# explicitly set threads so SuperLU doesn't slow to a crawl +# darwin default must be to use +# hyper threading +export OMP_NUM_THREADS=1 +# run tests in parallel +# separating serial vs parallel to not +# over prescribe threads +ctest -j ${nproc} -L serial && ctest -j 4 -L parallel diff --git a/scripts/mac/brew_gcc.sh b/scripts/mac/brew_gcc.sh new file mode 100644 index 0000000..9f7b770 --- /dev/null +++ b/scripts/mac/brew_gcc.sh @@ -0,0 +1,219 @@ +#!/bin/bash + +# build all tpls + allium on M1/M2 mac using Homebrew GCC + +# The script should be run from the alllium parent directory, e.g. 'source ./scripts/mac/brew_gcc.sh' + +# --- Configuration --- +nproc=$(sysctl -n hw.logicalcpu) +ROOT=$(pwd) +TPL=${ROOT}/tpl +ARCH=$(uname -m) +OS=$(uname -s) + +mkdir -p "${TPL}" + +# --- Install roots --- +export SUPERLU_INSTALL="${TPL}/superlu_dist/install_dir" +export SUNDIALS_INSTALL="${TPL}/sundials/install_dir" + +# --- 1. System Prerequisites --- +brew install cmake git libomp autoconf automake libtool lua@5.3 open-mpi gcc + +export LUA_PREFIX=$(brew --prefix lua@5.3) + +# --- Detect GCC version dynamically --- +GCC_PREFIX=$(brew --prefix gcc) + +GCC_BIN=$(ls ${GCC_PREFIX}/bin/gcc-* | sort -V | tail -n1) +GXX_BIN=$(echo ${GCC_BIN} | sed 's/gcc/g++/') +GFORTRAN_BIN=$(echo ${GCC_BIN} | sed 's/gcc/gfortran/') + +export OMPI_CC=$(basename ${GCC_BIN}) +export OMPI_CXX=$(basename ${GXX_BIN}) +export OMPI_FC=$(basename ${GFORTRAN_BIN}) + +echo "Using GCC toolchain:" +echo " OMPI_CC = ${OMPI_CC}" +echo " OMPI_CXX = ${OMPI_CXX}" +echo " OMPI_FC = ${OMPI_FC}" + +# MPI wrappers +export CC=mpicc +export CXX=mpicxx +export FC=mpifort + +# --- 2. Clone & Checkout --- +cd "${TPL}" + +repos=( "mfem/mfem" + "hypre-space/hypre" + "mfem/tpls" + "libunwind/libunwind" + "xiaoyeli/superlu_dist" + "igraph/igraph" + "kokkos/mdspan" + "jbeder/yaml-cpp" + "ThePhD/sol2" + "google/googletest" + "LLNL/sundials" + "Nek5000/gslib" ) + +for repo in "${repos[@]}"; do + dir=$(basename "$repo") + if [ ! -d "$dir" ]; then + git clone "https://github.com/${repo}.git" + fi +done + +# Checkout specific SHAs +git -C hypre checkout 7e7fc8ce09153c60ae538a52a5f870f93b9608ca +git -C sundials checkout aaeab8d907c6b7dfca86041401fdc1448f35f826 +git -C igraph checkout beebfcdcd707f50a31cf8eb3568cf09f8b7baf54 +git -C mfem checkout 171eeb403f8d8deadfbd64d547de43c8705e616c +git -C superlu_dist checkout 4ae28e6f6d38f4f1fd3da88bd040f756d1275844 +git -C libunwind checkout c19e28b0e8682155482d937131fd5b1553044a66 +git -C mdspan checkout 80fc772eb812b45097c28fc0a46d8ff006138d69 +git -C yaml-cpp checkout 8bcadb1509e63248e79c6dc09928f95cfae02b74 +git -C sol2 checkout c1f95a773c6f8f4fde8ca3efe872e7286afe4444 +git -C googletest checkout 94be250af7e14c58dcbf476972d2d7141551ff67 +git -C gslib checkout 95acf5b42301d6cb48fda88d662f1d784b863089 +git -C tpls checkout 486dd7171e67629fc85393479f710e821e0e8b77 + +# --- 3. Build TPLs --- + +## HYPRE +cd "${TPL}/hypre/src" +rm -rf cmbuild +mkdir cmbuild && cd cmbuild +cmake .. +make -j${nproc} && make install + +## ParMETIS +cd "${TPL}" +tar -xf tpls/parmetis-4.0.3.tar.gz +PMROOT="${TPL}/parmetis-4.0.3" + +cd "${PMROOT}" +sed -i '' 's/cmake_minimum_required(VERSION 2.8)/cmake_minimum_required(VERSION 3.5)/g' CMakeLists.txt +sed -i '' 's/cmake_minimum_required(VERSION 2.4)/cmake_minimum_required(VERSION 3.5)/g' metis/CMakeLists.txt + +make config prefix=install +make install -j${nproc} + +PM_INSTALL=${PMROOT}/build/${OS}-${ARCH} + +## SuperLU_DIST +cd "${TPL}/superlu_dist" +rm -rf build install_dir && mkdir build install_dir && cd build + +cmake .. \ + -DCMAKE_INSTALL_PREFIX="${SUPERLU_INSTALL}" \ + -DTPL_PARMETIS_INCLUDE_DIRS="${PMROOT}/include;${PMROOT}/metis/include" \ + -DTPL_PARMETIS_LIBRARIES="${PM_INSTALL}/libparmetis/libparmetis.a;${PM_INSTALL}/libmetis/libmetis.a" + +make install -j${nproc} + +## SUNDIALS +cd "${TPL}/sundials" +rm -rf build install_dir && mkdir build install_dir && cd build + +cmake .. \ + -DCMAKE_INSTALL_PREFIX="${SUNDIALS_INSTALL}" \ + -DENABLE_MPI=ON \ + -DEXAMPLES_INSTALL=OFF + +make install -j${nproc} + +## GSLIB +cd "${TPL}/gslib" +make -j${nproc} + +## MFEM +cd "${TPL}/mfem" +rm -rf build install_dir && mkdir build install_dir && cd build + +cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=../install_dir \ + -DMFEM_USE_MPI=ON \ + -DCMAKE_CXX_COMPILER=mpicxx \ + -DMFEM_USE_OPENMP=ON \ + -DHYPRE_DIR="${TPL}/hypre/src/hypre" \ + -DParMETIS_INCLUDE_DIR="${PM_INSTALL}/include" \ + -DParMETIS_LIBRARY="${PM_INSTALL}/libparmetis/libparmetis.a" \ + -DMETIS_LIBRARY="${PM_INSTALL}/libmetis/libmetis.a" \ + -DMFEM_USE_SUPERLU=ON \ + -DSuperLUDist_DIR="${SUPERLU_INSTALL}" \ + -DMFEM_USE_SUNDIALS=ON \ + -DSUNDIALS_DIR="${SUNDIALS_INSTALL}" \ + -DMFEM_USE_GSLIB=ON \ + -DGSLIB_DIR="${TPL}/gslib/build/" \ + -DMFEM_USE_LIBUNWIND=ON + +make -j${nproc} && make install + +## igraph +cd "${TPL}/igraph" +rm -rf build install && mkdir build install && cd build + +cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=../install \ + -DCMAKE_C_COMPILER=mpicc \ + -DCMAKE_CXX_COMPILER=mpicxx + +make install -j${nproc} + +## Remaining C++ dependencies +for dep in mdspan yaml-cpp googletest; do + cd "${TPL}/${dep}" + rm -rf build install && mkdir build install && cd build + + cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=../install \ + -DCMAKE_C_COMPILER=mpicc \ + -DCMAKE_CXX_COMPILER=mpicxx + + make install -j${nproc} +done + +## Sol2 +cd "${TPL}/sol2" +rm -rf build install && mkdir build install && cd build + +cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=../install \ + -DSOL2_BUILD_LUA=FALSE \ + -DSOL2_LUA_VERSION=5.3 \ + -DLUA_INCLUDE_DIR="${LUA_PREFIX}/include/lua5.3" \ + -DLUA_LIBRARIES="${LUA_PREFIX}/lib/liblua5.3.dylib" + +make install + +# --- 4. Build Allium --- +cd "${ROOT}" +rm -rf build && mkdir build && cd build + +cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_C_COMPILER=mpicc \ + -DCMAKE_CXX_COMPILER=mpicxx \ + -Dmfem_DIR="${TPL}/mfem/install_dir/lib/cmake/mfem" \ + -Digraph_DIR="${TPL}/igraph/install/lib/cmake/igraph" \ + -Dmdspan_DIR="${TPL}/mdspan/install/lib/cmake/mdspan" \ + -Dyaml-cpp_DIR="${TPL}/yaml-cpp/install/lib/cmake/yaml-cpp" \ + -Dsol2_DIR="${TPL}/sol2/install/share/cmake/sol2" \ + -DGTest_ROOT="${TPL}/googletest/install/lib/cmake/GTest" \ + -DENABLE_UNIT_TESTS=TRUE \ + -DENABLE_CHIVE_TESTS=TRUE + +make -j${nproc} + +# --- Run tests --- +export OMP_NUM_THREADS=1 + +ctest -j ${nproc} -L serial +ctest -j 4 -L parallel diff --git a/src/constants.hpp b/src/constants.hpp index 92b2399..5b10823 100644 --- a/src/constants.hpp +++ b/src/constants.hpp @@ -1,7 +1,6 @@ #pragma once #include -#include namespace constants { @@ -20,7 +19,7 @@ constexpr double Planck = 6.62607015e-27; // erg s constexpr double Boltzmann = 1.380649e-16; // erg/K // black body thermal emission is StefanBoltzmann * T^4 (includes factor of speed of light) // erg/cm^2/s/eV^4 -constexpr double StefanBoltzmann = 8.0*pow(pi, 5)/(15.0*pow(SpeedOfLight, 2)*pow(Planck, 3))/pow(internal::erg_to_eV,4); +constexpr double StefanBoltzmann = 8.0*(pi*pi*pi*pi*pi)/(15.0*(SpeedOfLight*SpeedOfLight)*(Planck*Planck*Planck))/(internal::erg_to_eV*internal::erg_to_eV*internal::erg_to_eV*internal::erg_to_eV); // the "a" in black body emission ac T^4 constexpr double RadiationConstant = StefanBoltzmann / SpeedOfLight; diff --git a/src/fixup.hpp b/src/fixup.hpp index 1f89749..2eae42d 100644 --- a/src/fixup.hpp +++ b/src/fixup.hpp @@ -8,6 +8,7 @@ class NegativeFluxFixupOperator double minimum_solution = 0.0; public: NegativeFluxFixupOperator() = default; + virtual ~NegativeFluxFixupOperator() = default; NegativeFluxFixupOperator(double min) : minimum_solution(min) { } virtual int Apply(const mfem::DenseMatrix &A, const mfem::Vector &rhs, mfem::Vector &solution) const =0; }; diff --git a/src/io.cpp b/src/io.cpp index 55e52f5..6c5e0ae 100644 --- a/src/io.cpp +++ b/src/io.cpp @@ -259,7 +259,8 @@ mfem::IterativeSolver *CreateIterativeSolver(sol::table &table, std::optionalSetMAA(kdim); + // kn->SetMAA(kdim); + kn->EnableAndersonAcc(kdim); table["kdim"] = kdim; s = kn; #else diff --git a/src/moment_discretization.cpp b/src/moment_discretization.cpp index ceefe50..e4a8330 100644 --- a/src/moment_discretization.cpp +++ b/src/moment_discretization.cpp @@ -158,7 +158,7 @@ mfem::HypreParMatrix *LDGDiscretization::GetOperator() const bfi = new mfem::TransposeIntegrator(new mfem::GradientIntegrator(neg_one)); if (lump_grad) bfi = new QuadratureLumpedIntegrator(bfi); Dform.AddDomainIntegrator(bfi); - bfi = new mfem::LDGTraceIntegrator(&beta); + bfi = new LDGTraceIntegrator(&beta); if (lump_face) bfi = new QuadratureLumpedIntegrator(bfi); Dform.AddInteriorFaceIntegrator(bfi); Dform.Assemble(); @@ -312,7 +312,7 @@ mfem::BlockOperator *BlockLDGDiscretization::GetOperator() const bfi = new mfem::TransposeIntegrator(new mfem::GradientIntegrator(neg_one)); if (lump_grad) bfi = new QuadratureLumpedIntegrator(bfi); Dform.AddDomainIntegrator(bfi); - bfi = new mfem::LDGTraceIntegrator(&beta); + bfi = new LDGTraceIntegrator(&beta); if (lump_face) bfi = new QuadratureLumpedIntegrator(bfi); Dform.AddInteriorFaceIntegrator(bfi); Dform.Assemble(); diff --git a/src/moment_integrators.cpp b/src/moment_integrators.cpp index b1bdf19..c1aa383 100644 --- a/src/moment_integrators.cpp +++ b/src/moment_integrators.cpp @@ -286,8 +286,8 @@ void PenaltyIntegrator::AssembleFaceMatrix(const mfem::FiniteElement &el1, const } } -void DGJumpAverageIntegrator::AssembleFaceMatrix(const mfem::FiniteElement &tr_fe1, const mfem::FiniteElement &tr_fe2, - const mfem::FiniteElement &te_fe1, const mfem::FiniteElement &te_fe2, +void DGJumpAverageIntegrator::AssembleFaceMatrix(const mfem::FiniteElement &tr_fe1, const mfem::FiniteElement &te_fe1, + const mfem::FiniteElement &tr_fe2, const mfem::FiniteElement &te_fe2, mfem::FaceElementTransformations &trans, mfem::DenseMatrix &elmat) { int dim, te_ndof1, te_ndof2, te_ndofs, tr_ndof1, tr_ndof2, tr_ndofs; @@ -389,8 +389,8 @@ void DGJumpAverageIntegrator::AssembleFaceMatrix(const mfem::FiniteElement &tr_f } void DGVectorJumpAverageIntegrator::AssembleFaceMatrix( - const mfem::FiniteElement &tr_fe1, const mfem::FiniteElement &tr_fe2, - const mfem::FiniteElement &te_fe1, const mfem::FiniteElement &te_fe2, + const mfem::FiniteElement &tr_fe1, const mfem::FiniteElement &te_fe1, + const mfem::FiniteElement &tr_fe2, const mfem::FiniteElement &te_fe2, mfem::FaceElementTransformations &trans, mfem::DenseMatrix &elmat) { int dim, te_ndof1, te_ndof2, te_ndofs, tr_ndof1, tr_ndof2, tr_ndofs; @@ -591,115 +591,216 @@ void DGVectorJumpJumpIntegrator::AssembleFaceMatrix(const mfem::FiniteElement &e } void LDGTraceIntegrator::AssembleFaceMatrix(const mfem::FiniteElement &tr_fe1, - const mfem::FiniteElement &tr_fe2, - const mfem::FiniteElement &te_fe1, + const mfem::FiniteElement &te_fe1, + const mfem::FiniteElement &tr_fe2, const mfem::FiniteElement &te_fe2, mfem::FaceElementTransformations &T, mfem::DenseMatrix &elmat) { - int dim = tr_fe1.GetDim(); - nor.SetSize(dim); - int tr_ndof1, te_ndof1, tr_ndof2, te_ndof2, tr_ndofs, te_ndofs; - tr_ndof1 = tr_fe1.GetDof(); - te_ndof1 = te_fe1.GetDof(); - tr_shape1.SetSize(tr_ndof1); - te_shape1.SetSize(te_ndof1); - - if (T.Elem2No >= 0) - { - tr_ndof2 = tr_fe2.GetDof(); - te_ndof2 = te_fe2.GetDof(); - tr_shape2.SetSize(tr_ndof2); - te_shape2.SetSize(te_ndof2); - } - else - { - tr_ndof2 = 0; - te_ndof2 = 0; - } - - tr_ndofs = tr_ndof1 + tr_ndof2; - te_ndofs = te_ndof1 + te_ndof2; - elmat.SetSize(te_ndofs, tr_ndofs*dim); - elmat = 0.0; - - const auto *ir = IntRule; - if (ir == NULL) - { - int order; - if (tr_ndof2) - { - order = std::max(tr_fe1.GetOrder(), tr_fe2.GetOrder()) - + std::max(te_fe1.GetOrder(), te_fe2.GetOrder()); - } - else - { - order = tr_fe1.GetOrder() + te_fe1.GetOrder(); - } - ir = &mfem::IntRules.Get(T.GetGeometryType(), order); - } - - A11.SetSize(te_ndof1, tr_ndof1); - A12.SetSize(te_ndof1, tr_ndof2); - A21.SetSize(tr_ndof2, te_ndof1); - A22.SetSize(te_ndof2, tr_ndof2); - - double w, sign; - for (int n=0; nGetNPoints(); n++) - { - const auto &ip = ir->IntPoint(n); - T.SetAllIntPoints(&ip); - const auto &eip1 = T.GetElement1IntPoint(); - const auto &eip2 = T.GetElement2IntPoint(); - if (dim == 1) { - nor(0) = 2*eip1.x - 1.0; - } else { - mfem::CalcOrtho(T.Jacobian(), nor); - } - w = ip.weight; - if (tr_ndof2) { w /= 2; } - // set sign = sign(beta . normal) - // use factor of half in weight to get sign/2 - if (beta and tr_ndof2) { sign = (*beta * nor >= 0 ? 1.0 : -1.0); } - else { sign = 0.0; } - - if (limit > 0) { - double c = coef->Eval(*T.Elem1, eip1); - if (tr_ndof2) { - c += coef->Eval(*T.Elem2, eip2); - c /= 2; - } - double k = kappa * T.Weight() / T.Elem1->Weight() * c; - if (k < limit) { - sign = 0.0; - } - } - - tr_fe1.CalcShape(eip1, tr_shape1); - te_fe1.CalcShape(eip1, te_shape1); - mfem::MultVWt(te_shape1, tr_shape1, A11); - for (int d=0; d= 0) + { + tr_ndof2 = tr_fe2.GetDof(); + te_ndof2 = te_fe2.GetDof(); + } + else + { + tr_ndof2 = 0; + te_ndof2 = 0; + } + + tr_ndofs = tr_ndof1 + tr_ndof2; + te_ndofs = te_ndof1 + te_ndof2; + elmat.SetSize(te_ndofs, tr_ndofs*dim); + elmat = 0.0; + + Vector ortho(dim), nor(dim); + Vector tr_s1(tr_ndof1); + Vector tr_s2(tr_ndof2); + Vector te_s1(te_ndof1); + Vector te_s2(te_ndof2); + + const IntegrationRule *ir = IntRule; + if (ir == NULL) + { + int order; + if (tr_ndof2) + { + order = std::max(tr_fe1.GetOrder(), tr_fe2.GetOrder()) + std::max(te_fe1.GetOrder(), + te_fe2.GetOrder()); + } + else + { + order = tr_fe1.GetOrder() + te_fe1.GetOrder(); + } + ir = &IntRules.Get(T.GetGeometryType(), order); + } + + DenseMatrix A11(te_ndof1, tr_ndof1); + DenseMatrix A12(te_ndof1, tr_ndof2); + DenseMatrix A21(te_ndof2, tr_ndof1); + DenseMatrix A22(te_ndof2, tr_ndof2); + double w, sign; + for (int n=0; nGetNPoints(); n++) + { + const IntegrationPoint &ip = ir->IntPoint(n); + T.SetAllIntPoints(&ip); + const IntegrationPoint &eip1 = T.GetElement1IntPoint(); + const IntegrationPoint &eip2 = T.GetElement2IntPoint(); + if (dim==1) { + ortho(0) = 2*eip1.x - 1.0; + } else { + CalcOrtho(T.Jacobian(), ortho); + } + w = ip.weight; + if (tr_ndof2) { w /= 2; } + ortho *= w; + // set sign = sign(beta . normal) + // use factor of half in weight to get sign/2 + if (beta and tr_ndof2) { sign = (*beta * ortho >= 0 ? 1.0 : -1.0); } + else { sign = 0.0; } + + tr_fe1.CalcShape(eip1, tr_s1); + te_fe1.CalcShape(eip1, te_s1); + MultVWt(te_s1, tr_s1, A11); + for (int d=0; d= 0) +// { +// tr_ndof2 = tr_fe2.GetDof(); +// te_ndof2 = te_fe2.GetDof(); +// tr_shape2.SetSize(tr_ndof2); +// te_shape2.SetSize(te_ndof2); +// } +// else +// { +// tr_ndof2 = 0; +// te_ndof2 = 0; +// } + +// tr_ndofs = tr_ndof1 + tr_ndof2; +// te_ndofs = te_ndof1 + te_ndof2; +// elmat.SetSize(te_ndofs, tr_ndofs*dim); +// elmat = 0.0; + +// const auto *ir = IntRule; +// if (ir == NULL) +// { +// int order; +// if (tr_ndof2) +// { +// order = std::max(tr_fe1.GetOrder(), tr_fe2.GetOrder()) +// + std::max(te_fe1.GetOrder(), te_fe2.GetOrder()); +// } +// else +// { +// order = tr_fe1.GetOrder() + te_fe1.GetOrder(); +// } +// ir = &mfem::IntRules.Get(T.GetGeometryType(), order); +// } + +// A11.SetSize(te_ndof1, tr_ndof1); +// A12.SetSize(te_ndof1, tr_ndof2); +// A21.SetSize(tr_ndof2, te_ndof1); +// A22.SetSize(te_ndof2, tr_ndof2); + +// double w, sign; +// for (int n=0; nGetNPoints(); n++) +// { +// const auto &ip = ir->IntPoint(n); +// T.SetAllIntPoints(&ip); +// const auto &eip1 = T.GetElement1IntPoint(); +// const auto &eip2 = T.GetElement2IntPoint(); +// if (dim == 1) { +// nor(0) = 2*eip1.x - 1.0; +// } else { +// mfem::CalcOrtho(T.Jacobian(), nor); +// } +// w = ip.weight; +// if (tr_ndof2) { w /= 2; } +// // set sign = sign(beta . normal) +// // use factor of half in weight to get sign/2 +// if (beta and tr_ndof2) { sign = (*beta * nor >= 0 ? 1.0 : -1.0); } +// else { sign = 0.0; } + +// if (limit > 0) { +// double c = coef->Eval(*T.Elem1, eip1); +// if (tr_ndof2) { +// c += coef->Eval(*T.Elem2, eip2); +// c /= 2; +// } +// double k = kappa * T.Weight() / T.Elem1->Weight() * c; +// if (k < limit) { +// sign = 0.0; +// } +// } + +// tr_fe1.CalcShape(eip1, tr_shape1); +// te_fe1.CalcShape(eip1, te_shape1); +// mfem::MultVWt(te_shape1, tr_shape1, A11); +// for (int d=0; d::max(), 0.25); -constexpr double second_deriv_max = std::log(std::numeric_limits::max())-1.0; +constexpr double coef = 15.0/(constants::pi * constants::pi * constants::pi * constants::pi); +const double rosseland_max = pow(std::numeric_limits::max(), 0.25); +const double second_deriv_max = std::log(std::numeric_limits::max())-1.0; inline double PlanckTaylorSeries9(double x) { const double x2 = x*x; diff --git a/src/smm_integrators.cpp b/src/smm_integrators.cpp index ad4cb04..4c172ac 100644 --- a/src/smm_integrators.cpp +++ b/src/smm_integrators.cpp @@ -268,7 +268,7 @@ void CSMMZerothMomentFaceLFIntegrator::AssembleRHSElementVect(const mfem::Finite const auto &tr_fes = *beta.FESpace(); tr_fes.GetElementDofs(trans.Elem1No, beta_dofs1); beta.GetSubVector(beta_dofs1, beta_all1); - const auto &tr_el = *tr_fes.GetTraceElement(face_el_no, trans.GetGeometryType()); + const auto &tr_el = *tr_fes.GetTraceElement(trans.Elem1No, trans.GetGeometryType()); const auto tr_dof = tr_el.GetDof(); auto info = trans.mesh->GetFaceInformation(face_el_no); assert(info.IsBoundary()); @@ -351,7 +351,7 @@ void CSMMZerothMomentFaceLFIntegrator::AssembleRHSElementVect(const mfem::Finite // extract beta data for this face const auto dim = trans.GetSpaceDim(); const auto &tr_fes = *beta.ParFESpace(); - const auto &tr_el = *tr_fes.GetTraceElement(trans.ElementNo, trans.GetGeometryType()); + const auto &tr_el = *tr_fes.GetTraceElement(trans.Elem1No, trans.GetGeometryType()); const auto tr_dof = tr_el.GetDof(); auto info = trans.mesh->GetFaceInformation(trans.ElementNo); assert(trans.Elem1No < trans.mesh->GetNE()); @@ -434,7 +434,7 @@ void CSMMFirstMomentFaceLFIntegrator::AssembleRHSElementVect(const mfem::FiniteE tr_vfes.GetElementVDofs(trans.Elem1No, tr_vdofs1); tensor.GetSubVector(tr_vdofs1, tensor_all1); - const auto &tr_el = *tr_vfes.GetTraceElement(face_el_no, trans.GetGeometryType()); + const auto &tr_el = *tr_vfes.GetTraceElement(trans.Elem1No, trans.GetGeometryType()); const auto tr_dof = tr_el.GetDof(); const auto info = trans.mesh->GetFaceInformation(face_el_no); const auto local_face_id1 = info.element[0].local_face_id; @@ -483,7 +483,7 @@ void CSMMFirstMomentFaceLFIntegrator::AssembleRHSElementVect(const mfem::FiniteE const auto dim = trans.GetSpaceDim(); const auto &tr_vfes = *tensor.ParFESpace(); - const auto &tr_el = *tr_vfes.GetTraceElement(trans.ElementNo, trans.GetGeometryType()); + const auto &tr_el = *tr_vfes.GetTraceElement(trans.Elem1No, trans.GetGeometryType()); const auto tr_dof = tr_el.GetDof(); const auto info = trans.mesh->GetFaceInformation(trans.ElementNo); const auto local_face_id1 = info.element[0].local_face_id; diff --git a/src/smm_source.cpp b/src/smm_source.cpp index 2c23db0..0e6a8cc 100644 --- a/src/smm_source.cpp +++ b/src/smm_source.cpp @@ -58,7 +58,7 @@ void MomentFaceClosuresOperator::Mult(const mfem::Vector &psi, mfem::Vector &clo } bool keep_order = e == trans->Elem1No; const auto local_face_id = info.element[keep_order ? 0 : 1].local_face_id; - const auto &tr_el = *trace_fes.GetTraceElement(face, mesh.GetFaceGeometry(face)); + const auto &tr_el = *trace_fes.GetTraceElement(e, mesh.GetFaceGeometry(face)); const auto &ir = tr_el.GetNodes(); const auto ip = mfem::Geometries.GetCenter(trans->GetGeometryType()); @@ -298,7 +298,7 @@ ConsistentLDGSMMOperator::ConsistentLDGSMMOperator(const BlockLDGDiscretization Ma = HypreParMatrixPtr(Maform.ParallelAssemble()); mfem::ParMixedBilinearForm Dform(&vfes, &fes); - bfi = new mfem::LDGTraceIntegrator(&beta); + bfi = new LDGTraceIntegrator(&beta); if (lump_face) bfi = new QuadratureLumpedIntegrator(bfi); Dform.AddInteriorFaceIntegrator(bfi); Dform.Assemble(); @@ -310,7 +310,7 @@ ConsistentLDGSMMOperator::ConsistentLDGSMMOperator(const BlockLDGDiscretization bfi = new mfem::GradientIntegrator(neg_one); if (lump_grad) bfi = new QuadratureLumpedIntegrator(bfi); Gform.AddDomainIntegrator(bfi); - bfi = new mfem::TransposeIntegrator(new mfem::LDGTraceIntegrator(&beta)); + bfi = new mfem::TransposeIntegrator(new LDGTraceIntegrator(&beta)); if (lump_face) bfi = new QuadratureLumpedIntegrator(bfi); Gform.AddInteriorFaceIntegrator(bfi); Gform.Assemble(); diff --git a/src/tvector.hpp b/src/tvector.hpp index d2bea0c..e99e233 100644 --- a/src/tvector.hpp +++ b/src/tvector.hpp @@ -24,7 +24,7 @@ struct IndexMap Extents ext; public: mapping(const Extents &ext) : ext(ext) { - static_assert(ext.rank()==3); + static_assert(Extents::rank() == 3, "IndexMap requires rank-3 extents"); } template constexpr index_type operator()(Indices... idxs) const noexcept { diff --git a/test/test_diffusion_mms.cpp b/test/test_diffusion_mms.cpp index 9813c8f..dc71464 100644 --- a/test/test_diffusion_mms.cpp +++ b/test/test_diffusion_mms.cpp @@ -137,8 +137,8 @@ double LDGError(mfem::Mesh &smesh, int fe_order, for (auto d=0; dElem2No); mfem::Vector elvec; lfint.AssembleRHSElementVect(fe1, fe2, *trans, elvec); - mfem::Vector ex({0,-.5,0,-.5,0,-1./8,0,-1./8, .5,0,.5,0,1./8,0,1./8,0}); + mfem::Vector ex({0.0,-.5,0.0,-.5,0.0,-1./8,0.0,-1./8, .5,0.0,.5,0.0,1./8,0.0,1./8,0.0}); ex -= elvec; EXPECT_DOUBLE_EQ(ex.Norml2(), 0.0); } @@ -204,7 +204,7 @@ TEST(Integrators, SMMFaceTermBdr) { const auto &fe1 = *vfes.GetFE(trans.Elem1No); mfem::Vector elvec; lfint.AssembleRHSElementVect(fe1, trans, elvec); - mfem::Vector ex({1./16, 1./16, 0, 0, 0.5, 0.5, 0, 0}); + mfem::Vector ex({1./16, 1./16, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0}); ex -= elvec; EXPECT_DOUBLE_EQ(ex.Norml2(), 0.0); } @@ -219,7 +219,7 @@ TEST(Integrators, BoundaryNormalFaceLFIntegrator) { auto &trans = *mesh.GetBdrFaceTransformations(0); mfem::Vector elvec; lfi.AssembleRHSElementVect(*vfes.GetFE(trans.Elem1No), trans, elvec); - mfem::Vector ex({0,0,0,0,-0.5,-0.5,0,0}); + mfem::Vector ex({0.0,0.0,0.0,0.0,-0.5,-0.5,0.0,0.0}); ex -= elvec; EXPECT_DOUBLE_EQ(ex.Norml2(), 0.0); } @@ -281,13 +281,13 @@ TEST(Integrators, SweepFaceIntegrator) { FaceMassMatricesIntegrator bfi; mfem::DenseMatrix M; bfi.AssembleFaceMatrix(*fes.GetFE(trans->Elem1No), *fes.GetFE(trans->Elem2No), *trans, M); - mfem::DenseMatrix ex11({{0,0,0,0}, {0,1./3,0,1./6}, {0,0,0,0}, {0,1./6,0,1./3}}); + mfem::DenseMatrix ex11({{0.0,0.0,0.0,0.0}, {0.0,1./3,0.0,1./6}, {0.0,0.0,0.0,0.0}, {0.0,1./6,0.0,1./3}}); mfem::DenseMatrix M11; M.GetSubMatrix(0,4,M11); ex11 -= M11; EXPECT_NEAR(ex11.FNorm(), 0.0, 1e-14); - mfem::DenseMatrix ex12({{0,0,0,0}, {1./3,0,1./6,0}, {0,0,0,0}, {1./6,0,1./3,0}}); + mfem::DenseMatrix ex12({{0.0,0.0,0.0,0.0}, {1./3,0.0,1./6,0.0}, {0.0,0.0,0.0,0.0}, {1./6,0.0,1./3,0.0}}); mfem::DenseMatrix M12; M.GetSubMatrix(0,4,4,8,M12); ex12 -= M12; @@ -299,7 +299,7 @@ TEST(Integrators, SweepFaceIntegrator) { M21 -= M12; EXPECT_NEAR(M21.FNorm(), 0.0, 1e-14); - mfem::DenseMatrix ex22({{1./3,0,1./6,0}, {0,0,0,0}, {1./6,0,1./3,0}, {0,0,0,0}}); + mfem::DenseMatrix ex22({{1./3,0.0,1./6,0.0}, {0.0,0.0,0.0,0.0}, {1./6,0.0,1./3,0.0}, {0.0,0.0,0.0,0.0}}); mfem::DenseMatrix M22; M.GetSubMatrix(4,8, M22); ex22 -= M22; @@ -321,13 +321,13 @@ TEST(Integrators, SweepFaceIntegratorLumped) { QuadratureLumpedIntegrator bfi(new FaceMassMatricesIntegrator); mfem::DenseMatrix M; bfi.AssembleFaceMatrix(*fes.GetFE(trans->Elem1No), *fes.GetFE(trans->Elem2No), *trans, M); - mfem::DenseMatrix ex11({{0,0,0,0}, {0,1./2,0,0.0}, {0,0,0,0}, {0,0.0,0,1./2}}); + mfem::DenseMatrix ex11({{0.0,0.0,0.0,0.0}, {0.0,1./2,0.0,0.0}, {0.0,0.0,0.0,0.0}, {0.0,0.0,0.0,1./2}}); mfem::DenseMatrix M11; M.GetSubMatrix(0,4,M11); ex11 -= M11; EXPECT_NEAR(ex11.FNorm(), 0.0, 1e-14); - mfem::DenseMatrix ex12({{0,0,0,0}, {1./2,0,0,0}, {0,0,0,0}, {0,0,1./2,0}}); + mfem::DenseMatrix ex12({{0.0,0.0,0.0,0.0}, {1./2,0.0,0.0,0.0}, {0.0,0.0,0.0,0.0}, {0.0,0.0,1./2,0.0}}); mfem::DenseMatrix M12; M.GetSubMatrix(0,4,4,8,M12); ex12 -= M12; @@ -339,7 +339,7 @@ TEST(Integrators, SweepFaceIntegratorLumped) { M21 -= M12; EXPECT_NEAR(M21.FNorm(), 0.0, 1e-14); - mfem::DenseMatrix ex22({{1./2,0,0,0}, {0,0,0,0}, {0,0,1./2,0}, {0,0,0,0}}); + mfem::DenseMatrix ex22({{1./2,0.0,0.0,0.0}, {0.0,0.0,0.0,0.0}, {0.0,0.0,1./2,0.0}, {0.0,0.0,0.0,0.0}}); mfem::DenseMatrix M22; M.GetSubMatrix(4,8, M22); ex22 -= M22;