diff --git a/.gitlab/jobs/dane.yml b/.gitlab/jobs/dane.yml index 466bf2280f..387c763447 100644 --- a/.gitlab/jobs/dane.yml +++ b/.gitlab/jobs/dane.yml @@ -85,3 +85,8 @@ opt_par_gcc_10_pumi: extends: .mfem_job_on_dane variables: SPEC: "%gcc@10.3.1 +pumi" + +opt_par_gcc_10_gslib: + extends: .mfem_job_on_dane + variables: + SPEC: "%gcc@10.3.1 +gslib" diff --git a/.gitlab/jobs/matrix.yml b/.gitlab/jobs/matrix.yml index c21ce76b83..2b4cbbc951 100644 --- a/.gitlab/jobs/matrix.yml +++ b/.gitlab/jobs/matrix.yml @@ -63,3 +63,8 @@ opt_mpi_cuda_hypre_cuda_gcc: extends: .mfem_job_on_matrix variables: SPEC: "%gcc@10.3.1 +mpi +cuda cuda_arch=90 ^hypre+cuda" + +opt_mpi_cuda_gcc_gslib: + extends: .mfem_job_on_matrix + variables: + SPEC: "%gcc@10.3.1 +mpi +cuda +gslib cuda_arch=90 ^hypre+cuda" diff --git a/.gitlab/scripts/baseline b/.gitlab/scripts/baseline index 0922656b99..c96d0b70c7 100755 --- a/.gitlab/scripts/baseline +++ b/.gitlab/scripts/baseline @@ -32,9 +32,9 @@ mkdir _${BASELINE_TEST} && cd _${BASELINE_TEST} # run if [[ "${MACHINE_NAME}" == "dane" ]]; then - salloc --nodes=1 -t 60 --exclusive --reservation=ci ../runtest ../../mfem "${BASELINE_TEST} ${TPLS_DIR}" + srun --nodes=1 -t 60 --exclusive --reservation=ci ../runtest ../../mfem "${BASELINE_TEST} ${TPLS_DIR}" elif [[ ${MACHINE_NAME} == "corona" ]]; then - salloc --nodes=1 -t 60 -p pbatch ../runtest ../../mfem "${BASELINE_TEST} ${TPLS_DIR}" + srun --nodes=1 -t 60 -p pbatch ../runtest ../../mfem "${BASELINE_TEST} ${TPLS_DIR}" else echo "Unknown machine: MACHINE_NAME=$MACHINE_NAME" exit 1 diff --git a/CHANGELOG b/CHANGELOG index 646c238124..84fa128b71 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,8 +8,10 @@ https://mfem.org -Version 4.10 (development) -========================== +Version 4.9.1 (development) +=========================== + +- Policy for AI-assisted contribution added to CONTRIBUTING.md Discretization improvements --------------------------- @@ -23,12 +25,6 @@ Discretization improvements Tet rules (d=14-20): Chuluunbaatar et al., Comput. Math. Appl. 124:89-97, 2022. - -Version 4.9.1 (development) -=========================== - -Discretization improvements ---------------------------- - Improved the gridfunction projection routines. Projections work for Scalar, Vector and VectorFE, also NURBS versions. Optionally different types of projections can be selected, default behaviour has not changed. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3126a28f63..a3d2c17eac 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,6 +24,14 @@ must be made under this license. Note also that MFEM has a [Code of Conduct](CODE_OF_CONDUCT.md). By participating in the MFEM community, you agree to abide by its rules. +## AI Policy +- Use of AI code generation in MFEM is allowed but must be disclosed, e.g. by + selecting the `AI-assisted` label on the PR. +- By submitting a PR, the author acknowledges that they have reviewed and + understand the changes they are proposing. +- PR authors are still responsible for correctness, licensing, and attribution + of all changes. + If you plan on contributing to MFEM, consider reviewing the [issue tracker](https://github.com/mfem/mfem/issues) first to check if a thread already exists for your desired feature or the bug you ran into. Use a pull diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index a15beb6b4d..07ae762066 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -215,7 +215,7 @@ if (MFEM_ENABLE_TESTING) add_test(NAME ex1p_ceed_np=${MFEM_MPI_NP} COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${MFEM_MPI_NP} ${MPIEXEC_PREFLAGS} - $ "-no-vis" "-d ceed-cpu" "-pa" "-a" + $ "-no-vis" "-d" "ceed-cpu" "-pa" "-a" ${MPIEXEC_POSTFLAGS}) endif() endif() diff --git a/examples/amgx/makefile b/examples/amgx/makefile index 127b647d1e..6afb84baa7 100644 --- a/examples/amgx/makefile +++ b/examples/amgx/makefile @@ -64,7 +64,7 @@ PARALLEL_NAME := Parallel AMGX example $(MFEM_LIB_FILE): $(error The MFEM library is not build) -clean: clean-build +clean: clean-build clean-exec clean-build: rm -f *.o *~ $(SEQ_EXAMPLES) $(PAR_EXAMPLES) diff --git a/examples/caliper/makefile b/examples/caliper/makefile index ad6d805d7b..ffe20df7f4 100644 --- a/examples/caliper/makefile +++ b/examples/caliper/makefile @@ -64,12 +64,12 @@ ex1p-test-par: ex1p $(MFEM_LIB_FILE): $(error The MFEM library is not built) -clean: clean-build clean-exec $(SUBDIRS_CLEAN) +clean: clean-build clean-exec clean-build: rm -f *.o *~ $(SEQ_EXAMPLES) $(PAR_EXAMPLES) rm -rf *.dSYM *.TVD.*breakpoints clean-exec: - @rm -f refined.mesh displaced.mesh mesh.* ex5.mesh - @rm -f sphere_refined.* sol.* sol_u.* sol_p.* sol_r.* sol_i.* + @rm -f refined.mesh mesh.* + @rm -f sol.* diff --git a/examples/ginkgo/makefile b/examples/ginkgo/makefile index 22c593f8ee..d6634ffa42 100644 --- a/examples/ginkgo/makefile +++ b/examples/ginkgo/makefile @@ -76,4 +76,4 @@ clean-build: rm -rf *.dSYM *.TVD.*breakpoints clean-exec: - @rm -f refined.mesh sol.gf + @rm -f refined.mesh sol.gf mesh.* sol.* diff --git a/examples/makefile b/examples/makefile index 5cd6debc42..db7d73f4cb 100644 --- a/examples/makefile +++ b/examples/makefile @@ -71,6 +71,7 @@ endif SUBDIRS_ALL = $(addsuffix /all,$(SUBDIRS)) SUBDIRS_TEST = $(addsuffix /test,$(SUBDIRS)) +SUBDIRS_TEST_NOCLEAN = $(addsuffix /test-noclean,$(SUBDIRS)) SUBDIRS_CLEAN = $(addsuffix /clean,$(SUBDIRS)) SUBDIRS_TPRINT = $(addsuffix /test-print,$(SUBDIRS)) @@ -87,8 +88,9 @@ SUBDIRS_TPRINT = $(addsuffix /test-print,$(SUBDIRS)) all: $(EXAMPLES) $(SUBDIRS_ALL) -.PHONY: $(SUBDIRS_ALL) $(SUBDIRS_TEST) $(SUBDIRS_CLEAN) $(SUBDIRS_TPRINT) -$(SUBDIRS_ALL) $(SUBDIRS_TEST) $(SUBDIRS_CLEAN): +.PHONY: $(SUBDIRS_ALL) $(SUBDIRS_TEST) $(SUBDIRS_TEST_NOCLEAN) \ + $(SUBDIRS_CLEAN) $(SUBDIRS_TPRINT) +$(SUBDIRS_ALL) $(SUBDIRS_TEST) $(SUBDIRS_TEST_NOCLEAN) $(SUBDIRS_CLEAN): $(MAKE) -C $(@D) $(@F) $(SUBDIRS_TPRINT): @$(MAKE) -C $(@D) $(@F) @@ -107,6 +109,7 @@ endif MFEM_TESTS = EXAMPLES include $(MFEM_TEST_MK) test: $(SUBDIRS_TEST) +test-noclean: $(SUBDIRS_TEST_NOCLEAN) test-print: $(SUBDIRS_TPRINT) # Testing: Parallel vs. serial runs diff --git a/fem/datacollection.cpp b/fem/datacollection.cpp index a7abd160fa..c0d1fbd21e 100644 --- a/fem/datacollection.cpp +++ b/fem/datacollection.cpp @@ -492,6 +492,8 @@ void VisItDataCollection::SaveRootFile() to_padded_string(cycle, pad_digits_cycle) + ".mfem_root"; std::ofstream root_file(root_name); + MFEM_VERIFY(root_file.is_open(), + "Failed to open ofstream " << root_name); root_file << GetVisItRootString(); if (!root_file) { @@ -977,7 +979,10 @@ void ParaViewDataCollection::Save() // Save the local part of the mesh and grid functions fields to the local // VTU file. Also save coefficient fields. { - std::ofstream os(vtu_prefix + GenerateVTUFileName("proc", myid)); + std::string os_str = vtu_prefix + GenerateVTUFileName("proc", myid); + std::ofstream os(os_str); + MFEM_VERIFY(os.is_open(), + "Failed to open ofstream " << os_str); os.precision(precision); SaveDataVTU(os, levels_of_detail); } @@ -989,7 +994,10 @@ void ParaViewDataCollection::Save() "QuadratureFunction output is not supported for " "ParaViewDataCollection on domain boundary!"); const std::string &field_name = qfield.first; - std::ofstream os(vtu_prefix + GenerateVTUFileName(field_name, myid)); + std::string os_str = vtu_prefix + GenerateVTUFileName(field_name, myid); + std::ofstream os(os_str); + MFEM_VERIFY(os.is_open(), + "Failed to open ofstream " << os_str); qfield.second->SaveVTU(os, pv_data_format, GetCompressionLevel(), field_name); } @@ -1000,7 +1008,10 @@ void ParaViewDataCollection::Save() { // Create the main PVTU file { - std::ofstream pvtu_out(vtu_prefix + GeneratePVTUFileName("data")); + std::string os_str = vtu_prefix + GeneratePVTUFileName("data"); + std::ofstream pvtu_out(os_str); + MFEM_VERIFY(pvtu_out.is_open(), + "Failed to open ofstream " << os_str); WritePVTUHeader(pvtu_out); // Grid function fields and coefficient fields @@ -1055,8 +1066,10 @@ void ParaViewDataCollection::Save() const std::string &q_field_name = q_field.first; std::string q_fname = GeneratePVTUPath() + "/" + GeneratePVTUFileName(q_field_name); - - std::ofstream pvtu_out(col_path + "/" + q_fname); + std::string os_str = col_path + "/" + q_fname; + std::ofstream pvtu_out(os_str); + MFEM_VERIFY(pvtu_out.is_open(), + "Failed to open ofstream " << os_str); WritePVTUHeader(pvtu_out); int vec_dim = q_field.second->GetVDim(); pvtu_out << "\n"; diff --git a/fem/gslib.cpp b/fem/gslib.cpp index 176a356fbe..26de2864a3 100644 --- a/fem/gslib.cpp +++ b/fem/gslib.cpp @@ -106,9 +106,7 @@ FindPointsGSLIB::FindPointsGSLIB() gsl_comm = new gslib::comm; cr = new gslib::crystal; #ifdef MFEM_USE_MPI - int initialized = 0; - MPI_Initialized(&initialized); - if (!initialized) { MPI_Init(NULL, NULL); } + if (!Mpi::IsInitialized()) { Mpi::Init(); } MPI_Comm comm = MPI_COMM_WORLD; comm_init(gsl_comm, comm); #else @@ -490,7 +488,7 @@ void FindPointsGSLIB::FindPointsOnDevice(const Vector &point_pos, } DEV.find_device = true; - const int id = gsl_comm->id, np = gsl_comm->np; + const unsigned int id = gsl_comm->id, np = gsl_comm->np; gsl_mfem_ref.SetSize(points_cnt * dim); gsl_mfem_elem.SetSize(points_cnt); @@ -652,7 +650,7 @@ void FindPointsGSLIB::FindPointsOnDevice(const Vector &point_pos, { const int pp = hash_offset[i]; /* don't send back to where it just came from */ - if (pp == p->proc) + if (static_cast(pp) == p->proc) { continue; } @@ -1068,7 +1066,7 @@ void FindPointsGSLIB::InterpolateOnDevice(const Vector &field_in_evec, sarray_transfer(struct evalOutPt_t, &outpt, proc, 1, cr); opt = (evalOutPt_t *)outpt.ptr; - for (int index = 0; index < outpt.n; index++) + for (size_t index = 0; index < outpt.n; index++) { int idx = ordering == Ordering::byNODES ? opt->index + i*points_cnt : @@ -1413,7 +1411,7 @@ void FindPointsGSLIB::SetupSplitMeshesAndIntegrationRules(const int order) { MFEM_VERIFY(mesh, "Setup FindPointsGSLIB with mesh first."); const int dof1D = order+1; - const int dim = mesh->Dimension(); + dim = mesh->Dimension(); SetupSplitMeshes(); if (dim == 2) @@ -2254,7 +2252,8 @@ void FindPointsGSLIB::DistributeInterpolatedValues(const Vector &int_vals, sarray_transfer(struct out_pt, outpt, proc, 1, cr); // Store received data - MFEM_VERIFY(outpt->n == points_cnt, "Incompatible size. Number of points " + MFEM_VERIFY(outpt->n == static_cast(points_cnt), + "Incompatible size. Number of points " "received does not match the number of points originally " "found using FindPoints."); @@ -2623,9 +2622,7 @@ GSOPGSLIB::GSOPGSLIB(Array &ids) gsl_comm = new gslib::comm; cr = new gslib::crystal; #ifdef MFEM_USE_MPI - int initialized; - MPI_Initialized(&initialized); - if (!initialized) { MPI_Init(NULL, NULL); } + if (!Mpi::IsInitialized()) { Mpi::Init(); } MPI_Comm comm = MPI_COMM_WORLD; comm_init(gsl_comm, comm); #else diff --git a/fem/gslib/findpts_local_2.cpp b/fem/gslib/findpts_local_2.cpp index 492e92c44a..5c4524b2c0 100644 --- a/fem/gslib/findpts_local_2.cpp +++ b/fem/gslib/findpts_local_2.cpp @@ -254,7 +254,7 @@ get_edge(const double *elx[2], const double *wtend, int ei, edge.dxdn[d] = workspace + (2 + d) * pN; //dxdn and dydn at DOFs along edge } - if (side_init != (1u << ei)) + if (static_cast(side_init) != (1u << ei)) { #define ELX(d, j, k) elx[d][j + k * pN] // assumes lexicographic ordering for (int d = 0; d < 2; ++d) diff --git a/fem/gslib/findpts_local_3.cpp b/fem/gslib/findpts_local_3.cpp index 089b494792..db0f69909d 100644 --- a/fem/gslib/findpts_local_3.cpp +++ b/fem/gslib/findpts_local_3.cpp @@ -294,7 +294,7 @@ get_face(const double *elx[3], const double *wtend, int fi, double *workspace, face.dxdn[d] = workspace+(3+d)*p_Nfr; } - if (side_init != (1u << fi)) + if (static_cast(side_init) != (1u << fi)) { const int e_stride[3] = {1, pN, pN*pN}; #define ELX(d, j, k, l) elx[d][j*e_stride[d1]+k*e_stride[d2]+l*e_stride[dn]] @@ -342,7 +342,7 @@ get_edge(const double *elx[3], const double *wtend, int ei, double *workspace, if (jidx >= 3*pN) { return edge; } - if (side_init != (64u << ei)) + if (static_cast(side_init) != (64u << ei)) { const int e_stride[3] = {1, pN, pN*pN}; #define ELX(d, j, k, l) elx[d][j*e_stride[de]+k*e_stride[dn1]+l*e_stride[dn2]] diff --git a/makefile b/makefile index 0486c1917c..9c4397201d 100644 --- a/makefile +++ b/makefile @@ -123,15 +123,20 @@ EXAMPLE_SUBDIRS = amgx caliper ginkgo hiop petsc pumi sundials superlu moonolith EXAMPLE_DIRS := examples $(addprefix examples/,$(EXAMPLE_SUBDIRS)) EXAMPLE_TEST_DIRS := examples -MINIAPP_SUBDIRS = common electromagnetics meshing performance tools \ +MINIAPP_ALL_SUBDIRS = common electromagnetics meshing performance tools \ toys nurbs gslib adjoint solvers shifted mtop parelag tribol autodiff dfem \ hooke multidomain dpg hdiv-linear-solver spde diag-smoothers contact \ fluids/navier fluids/schrodinger-flow plasma plasma/pic +MINIAPP_RECURSIVE_SUBDIRS = plasma/pic +MINIAPP_SUBDIRS := $(filter-out \ + $(MINIAPP_RECURSIVE_SUBDIRS),$(MINIAPP_ALL_SUBDIRS)) +MINIAPP_ALL_DIRS := $(addprefix miniapps/,$(MINIAPP_ALL_SUBDIRS)) MINIAPP_DIRS := $(addprefix miniapps/,$(MINIAPP_SUBDIRS)) MINIAPP_TEST_DIRS := $(filter-out %/common,$(MINIAPP_DIRS)) MINIAPP_USE_COMMON := $(addprefix miniapps/,electromagnetics meshing tools \ - toys shifted dpg diag-smoothers fluids/navier plasma plasma/pic) + toys gslib shifted dpg diag-smoothers fluids/navier plasma plasma/pic) +EM_ALL_DIRS = $(EXAMPLE_DIRS) $(MINIAPP_ALL_DIRS) EM_DIRS = $(EXAMPLE_DIRS) $(MINIAPP_DIRS) TEST_SUBDIRS = unit @@ -146,7 +151,7 @@ MFEM_BUILD_DIR ?= . BUILD_DIR := $(MFEM_BUILD_DIR) BUILD_REAL_DIR := $(abspath $(BUILD_DIR)) ifneq ($(BUILD_REAL_DIR),$(MFEM_REAL_DIR)) - BUILD_SUBDIRS = $(DIRS) config $(EM_DIRS) doc $(TEST_DIRS) + BUILD_SUBDIRS = $(DIRS) config $(EM_ALL_DIRS) doc $(TEST_DIRS) CONFIG_FILE_DEF = -DMFEM_CONFIG_FILE='"$(BUILD_REAL_DIR)/config/_config.hpp"' BLD := $(if $(BUILD_REAL_DIR:$(CURDIR)=),$(BUILD_DIR)/,) $(if $(word 2,$(BLD)),$(error Spaces in BLD = "$(BLD)" are not supported)) @@ -483,10 +488,10 @@ $(OBJECT_FILES): $(BLD)%.o: $(SRC)%.cpp $(CONFIG_MK) all: examples miniapps $(TEST_DIRS) -.PHONY: miniapps $(EM_DIRS) $(TEST_DIRS) +.PHONY: miniapps $(EM_ALL_DIRS) $(TEST_DIRS) miniapps: $(MINIAPP_DIRS) $(MINIAPP_USE_COMMON): miniapps/common -$(EM_DIRS) $(TEST_DIRS): lib +$(EM_ALL_DIRS) $(TEST_DIRS): lib $(MAKE) -C $(BLD)$(@) .PHONY: doc @@ -694,7 +699,7 @@ local-config: .PHONY: build-config build-config: for d in $(BUILD_SUBDIRS); do mkdir -p $(BLD)$${d}; done - for dir in "" $(addsuffix /,config $(EM_DIRS) doc $(TEST_DIRS)); do \ + for dir in "" $(addsuffix /,config $(EM_ALL_DIRS) doc $(TEST_DIRS)); do\ printf "# Auto-generated file.\n%s\n%s\n" \ "MFEM_DIR = $(MFEM_REAL_DIR)" \ "include \$$(MFEM_DIR)/$${dir}makefile" \ @@ -796,13 +801,15 @@ status info: ASTYLE = $(ASTYLE_BIN) --options=$(SRC)config/mfem.astylerc ASTYLE_VER = "Artistic Style Version 3.1" -FORMAT_FILES = $(foreach dir,$(DIRS) $(EM_DIRS) config,$(dir)/*.?pp) +FORMAT_FILES = $(foreach dir,$(DIRS) $(EM_ALL_DIRS) config,$(dir)/*.?pp) TESTS_SUBDIRS = unit benchmarks convergence mem_manager par-mesh-format -UNIT_TESTS_SUBDIRS = general linalg mesh fem miniapps ceed enzyme -MINIAPPS_SUBDIRS = dpg/util hooke/operators hooke/preconditioners hooke/materials hooke/kernels +UNIT_TESTS_SUBDIRS = general linalg mesh fem miniapps ceed enzyme dfem +MINIAPPS_SUBDIRS = dpg/util hooke/operators hooke/preconditioners \ + hooke/materials hooke/kernels FORMAT_FILES += $(foreach dir,$(TESTS_SUBDIRS),tests/$(dir)/*.?pp) FORMAT_FILES += $(foreach dir,$(UNIT_TESTS_SUBDIRS),tests/unit/$(dir)/*.?pp) FORMAT_FILES += $(foreach dir,$(MINIAPPS_SUBDIRS),miniapps/$(dir)/*.?pp) +FORMAT_FILES += config/cmake/config.hpp.in config/config.hpp.in mfem*.hpp FORMAT_EXCLUDE = general/tinyxml2.cpp tests/unit/catch.hpp FORMAT_LIST = $(filter-out $(FORMAT_EXCLUDE),$(wildcard $(FORMAT_FILES))) @@ -833,14 +840,29 @@ mfem_check_command = \ # Verify the C++ code styling in MFEM and check that std::cout and std::cerr are # not used in the library (use mfem::out and mfem::err instead). style: - @echo "Applying C++ code style..." @astyle_version="$$($(ASTYLE_BIN) --version)";\ if [ "$$astyle_version" != $(ASTYLE_VER) ]; then\ printf "%s\n" "Invalid astyle version: '$$astyle_version'"\ "Please use: '"$(ASTYLE_VER)"'";\ exit 1;\ fi - @err_code=0;\ + @err_code=0; \ + if command -v git 2>&1 > /dev/null && [ -d $(MFEM_DIR)/.git ]; then \ + echo "Checking if all git files are selected for formatting ..."; \ + ls -1 $(FORMAT_FILES) | sort > format-files-make.txt; \ + git -C $(MFEM_DIR) ls-files '*.[ch]pp*' | sort \ + > format-files-git.txt; \ + cat format-files-make.txt format-files-git.txt | sort | uniq \ + > format-files-make-plus-git.txt; \ + rm -f format-files-git.txt; \ + $(call mfem_check_command,\ + diff format-files-make.txt format-files-make-plus-git.txt | \ + grep "^> ",\ + "All git files are selected for formatting",\ + "The above git files are NOT selected for formatting"); \ + rm -f format-files-make.txt format-files-make-plus-git.txt; \ + fi; \ + echo "Applying C++ code style...";\ $(call mfem_check_command,\ $(ASTYLE) $(FORMAT_LIST) | grep Formatted,\ "No source files were changed",\ diff --git a/miniapps/electromagnetics/CMakeLists.txt b/miniapps/electromagnetics/CMakeLists.txt index 809673c61c..56fa569c49 100644 --- a/miniapps/electromagnetics/CMakeLists.txt +++ b/miniapps/electromagnetics/CMakeLists.txt @@ -48,19 +48,39 @@ endif() # Add the corresponding tests to the "test" target if (MFEM_ENABLE_TESTING) - add_test(NAME tesla_np=4 + add_test(NAME tesla_1_np=${MFEM_MPI_NP} COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${MFEM_MPI_NP} ${MPIEXEC_PREFLAGS} $ -no-vis -maxit 2 -cr "0 0 -0.2 0 0 0.2 0.2 0.4 1" ${MPIEXEC_POSTFLAGS}) - - add_test(NAME volta_np=4 + add_test(NAME tesla_2_np=${MFEM_MPI_NP} COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${MFEM_MPI_NP} ${MPIEXEC_PREFLAGS} - $ -no-vis -maxit 2 -dbcs 1 -dbcg -ds "0.0 0.0 0.0 0.2 8.0" + $ + -no-vis -maxit 2 -m ../../data/inline-hex.mesh -ubbc "0 0 1" ${MPIEXEC_POSTFLAGS}) - add_test(NAME joule_np=4 + add_test(NAME volta_1_np=${MFEM_MPI_NP} + COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${MFEM_MPI_NP} + ${MPIEXEC_PREFLAGS} + $ + -no-vis -maxit 2 -dbcs 1 -dbcg -ds "0.0 0.0 0.0 0.2 8.0" + ${MPIEXEC_POSTFLAGS}) + add_test(NAME volta_2_np=${MFEM_MPI_NP} + COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${MFEM_MPI_NP} + ${MPIEXEC_PREFLAGS} + $ + -no-vis -maxit 2 -m ../../data/square-disc.mesh -dbcs "1 2 3 4 5 6 7 8" + -dbcv "0 0 0 0 1 1 1 1" + ${MPIEXEC_POSTFLAGS}) + add_test(NAME volta_3_np=${MFEM_MPI_NP} + COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${MFEM_MPI_NP} + ${MPIEXEC_PREFLAGS} + $ + -no-vis -maxit 2 -m ../../data/inline-hex.mesh -dbcs "1 6" -dbcv "0 1" + ${MPIEXEC_POSTFLAGS}) + + add_test(NAME joule_np=${MFEM_MPI_NP} COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${MFEM_MPI_NP} ${MPIEXEC_PREFLAGS} $ @@ -68,12 +88,41 @@ endif() ${MPIEXEC_POSTFLAGS}) if (MFEM_USE_DOUBLE) # otherwise returns MFEM_SKIP_RETURN_VALUE - add_test(NAME maxwell_np=4 + add_test(NAME maxwell_np=${MFEM_MPI_NP} COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${MFEM_MPI_NP} ${MPIEXEC_PREFLAGS} $ -no-vis -abcs "-1" -dp "-0.3 0.0 0.0 0.3 0.0 0.0 0.1 1 .5 .5" ${MPIEXEC_POSTFLAGS}) endif() + + if (MFEM_USE_GSLIB) + add_test(NAME lorentz_1_np=${MFEM_MPI_NP} + COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${MFEM_MPI_NP} + ${MPIEXEC_PREFLAGS} + $ + -no-vis -er Volta-AMR-Parallel -ec 2 -npt 100 -xmin "0.0 0.0 0.0" + -xmax "1.0 1.0 1.0" -pmin "1 0 0" -pmax "1 0 0" -rdf 0 -vt 0 -nt 100 + ${MPIEXEC_POSTFLAGS}) + # Setup dependency on volta_3_np= + set_tests_properties(volta_3_np=${MFEM_MPI_NP} + PROPERTIES FIXTURES_SETUP Volta3) + set_tests_properties(lorentz_1_np=${MFEM_MPI_NP} + PROPERTIES FIXTURES_REQUIRED Volta3) + + add_test(NAME lorentz_2_np=${MFEM_MPI_NP} + COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${MFEM_MPI_NP} + ${MPIEXEC_PREFLAGS} + $ + -no-vis -br Tesla-AMR-Parallel -bc 2 -npt 10 -xmin "0.0 0.0 0.0" + -xmax "1.0 1.0 1.0" -pmin "0 0.1 0.05" -pmax "0 0.4 0.1" -nt 1000 -rdf 0 + -vt 0 + ${MPIEXEC_POSTFLAGS}) + # Setup dependency on tesla_2_np= + set_tests_properties(tesla_2_np=${MFEM_MPI_NP} + PROPERTIES FIXTURES_SETUP Tesla2) + set_tests_properties(lorentz_2_np=${MFEM_MPI_NP} + PROPERTIES FIXTURES_REQUIRED Tesla2) + endif() endif() endif() diff --git a/miniapps/electromagnetics/makefile b/miniapps/electromagnetics/makefile index daea936647..2fa9e155d0 100644 --- a/miniapps/electromagnetics/makefile +++ b/miniapps/electromagnetics/makefile @@ -117,10 +117,10 @@ joule-test-par: joule lorentz-test-par: lorentz-test-1 lorentz-test-2 lorentz-test-1: lorentz volta-test-3 @$(call mfem-test,$<, $(RUN_MPI), Electromagnetic miniapp,\ - -er Volta-AMR-Parallel -ec 2 -npt 100 -xmin '0.0 0.0 0.0' -xmax '1.0 1.0 1.0' -pmin '1 0 0' -pmax '1 0 0' -rdf 0 -vt 0 -nt 100') + -er Volta-AMR-Parallel -ec 2 -npt 100 -xmin '0.0 0.0 0.0' -xmax '1.0 1.0 1.0' -pmin '1 0 0' -pmax '1 0 0' -rdf 0 -vt 0 -nt 100) lorentz-test-2: lorentz tesla-test-2 @$(call mfem-test,$<, $(RUN_MPI), Electromagnetic miniapp,\ - -br Tesla-AMR-Parallel -bc 2 -br Tesla-AMR-Parallel -npt 10 -xmin '0.0 0.0 0.0' -xmax '1.0 1.0 1.0' -pmin '0 0.1 0.05' -pmax '0 0.4 0.1' -nt 1000 -rdf 0 -vt 0) + -br Tesla-AMR-Parallel -bc 2 -npt 10 -xmin '0.0 0.0 0.0' -xmax '1.0 1.0 1.0' -pmin '0 0.1 0.05' -pmax '0 0.4 0.1' -nt 1000 -rdf 0 -vt 0) # Testing: "test" target and mfem-test* variables are defined in config/test.mk diff --git a/miniapps/gslib/CMakeLists.txt b/miniapps/gslib/CMakeLists.txt index 8ee75a440e..c939be18c1 100644 --- a/miniapps/gslib/CMakeLists.txt +++ b/miniapps/gslib/CMakeLists.txt @@ -46,8 +46,16 @@ if (MFEM_USE_GSLIB) if (MFEM_ENABLE_TESTING) foreach (test "schwarz_ex1" "field-diff" "findpts" "field-interp") - add_test(NAME ${test} - COMMAND $ -no-vis) + if (MFEM_USE_MPI) + add_test(NAME ${test} + COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 1 + ${MPIEXEC_PREFLAGS} + $ -no-vis + ${MPIEXEC_POSTFLAGS}) + else() + add_test(NAME ${test} + COMMAND $ -no-vis) + endif() endforeach() endif() diff --git a/miniapps/gslib/makefile b/miniapps/gslib/makefile index a234deb1fd..834d8c28d2 100644 --- a/miniapps/gslib/makefile +++ b/miniapps/gslib/makefile @@ -83,11 +83,16 @@ include $(MFEM_TEST_MK) # Testing: Parallel vs. serial runs RUN_MPI = $(MFEM_MPIEXEC) $(MFEM_MPIEXEC_NP) $(MFEM_MPI_NP) +ifeq ($(MFEM_USE_MPI),YES) + RUN_MPI_SER = $(MFEM_MPIEXEC) $(MFEM_MPIEXEC_NP) 1 +else + RUN_MPI_SER = +endif TEST_NAME := GSLIB miniapp %-test-par: % @$(call mfem-test,$<, $(RUN_MPI), $(TEST_NAME)) %-test-seq: % - @$(call mfem-test,$<,, $(TEST_NAME)) + @$(call mfem-test,$<, $(RUN_MPI_SER), $(TEST_NAME)) # Testing: "test" target and mfem-test* variables are defined in config/test.mk diff --git a/miniapps/plasma/makefile b/miniapps/plasma/makefile index 9d06843c90..9a8f7d65aa 100644 --- a/miniapps/plasma/makefile +++ b/miniapps/plasma/makefile @@ -28,6 +28,12 @@ endif PLASMA_SUBDIRS = pic +SUBDIRS_ALL = $(addsuffix /all,$(PLASMA_SUBDIRS)) +SUBDIRS_TEST = $(addsuffix /test,$(PLASMA_SUBDIRS)) +SUBDIRS_TEST_NOCLEAN = $(addsuffix /test-noclean,$(PLASMA_SUBDIRS)) +SUBDIRS_CLEAN = $(addsuffix /clean,$(PLASMA_SUBDIRS)) +SUBDIRS_TPRINT = $(addsuffix /test-print,$(PLASMA_SUBDIRS)) + .SUFFIXES: .SUFFIXES: .o .cpp .mk .PHONY: all lib-common clean clean-build clean-exec @@ -37,31 +43,24 @@ COMMON_LIB = -L$(MFEM_BUILD_DIR)/miniapps/common -lmfem-common # If MFEM_SHARED is set, add the ../common rpath COMMON_LIB += $(if $(MFEM_SHARED:YES=),,\ - $(if $(MFEM_USE_CUDA:YES=),$(CXX_XLINKER),$(CUDA_XLINKER))-rpath,$(abspath\ - $(MFEM_BUILD_DIR)/miniapps/common)) - -COMMON_O= + $(MFEM_XLINKER)-rpath,$(abspath $(MFEM_BUILD_DIR)/miniapps/common)) # Remove built-in rules %: %.cpp %.o: %.cpp -all: $(MINIAPPS) subdirs +all: $(MINIAPPS) $(SUBDIRS_ALL) -.PHONY: subdirs $(PLASMA_SUBDIRS) -subdirs: $(PLASMA_SUBDIRS) -$(PLASMA_SUBDIRS): lib-common - $(MAKE) -C $(BLD)$(@) +.PHONY: $(SUBDIRS_ALL) $(SUBDIRS_TEST) $(SUBDIRS_TEST_NOCLEAN) \ + $(SUBDIRS_CLEAN) $(SUBDIRS_TPRINT) +$(SUBDIRS_ALL) $(SUBDIRS_TEST) $(SUBDIRS_TEST_NOCLEAN) $(SUBDIRS_CLEAN): + $(MAKE) -C $(@D) $(@F) +$(SUBDIRS_TPRINT): + @$(MAKE) -C $(@D) $(@F) # Rules for building the miniapps -%: $(SRC)%.cpp $(COMMON_O) $(MFEM_LIB_FILE) $(CONFIG_MK) | lib-common - $(MFEM_CXX) $(MFEM_LINK_FLAGS) $< -o $@ $(COMMON_O) $(COMMON_LIB) \ - $(MFEM_LIBS) - -# Rules for compiling miniapp dependencies -$(COMMON_O) $(addsuffix _solver.o,$(MINIAPPS)): \ -%.o: $(SRC)%.cpp $(SRC)%.hpp $(CONFIG_MK) - $(MFEM_CXX) $(MFEM_FLAGS) -c $(<) -o $(@) +%: $(SRC)%.cpp $(MFEM_LIB_FILE) $(CONFIG_MK) | lib-common + $(MFEM_CXX) $(MFEM_LINK_FLAGS) $< -o $@ $(COMMON_LIB) $(MFEM_LIBS) # Rule for building lib-common lib-common: @@ -69,6 +68,9 @@ lib-common: MFEM_TESTS = MINIAPPS include $(MFEM_TEST_MK) +test: $(SUBDIRS_TEST) +test-noclean: $(SUBDIRS_TEST_NOCLEAN) +test-print: $(SUBDIRS_TPRINT) # Testing: Specific execution options RUN_MPI = $(MFEM_MPIEXEC) $(MFEM_MPIEXEC_NP) $(MFEM_MPI_NP) @@ -79,14 +81,9 @@ RUN_MPI = $(MFEM_MPIEXEC) $(MFEM_MPIEXEC_NP) $(MFEM_MPI_NP) $(MFEM_LIB_FILE): $(error The MFEM library is not built) -ALL_CLEAN_SUBDIRS = $(addsuffix /clean,$(PLASMA_SUBDIRS)) -.PHONY: $(ALL_CLEAN_SUBDIRS) -$(ALL_CLEAN_SUBDIRS): - $(MAKE) -C $(BLD)$(@D) $(@F) +clean: clean-build clean-exec $(SUBDIRS_CLEAN) -clean: clean-build clean-exec - -clean-build: $(addsuffix /clean,$(PLASMA_SUBDIRS)) +clean-build: rm -f *.o *~ $(SEQ_MINIAPPS) $(PAR_MINIAPPS) rm -rf *.dSYM *.TVD.*breakpoints diff --git a/miniapps/plasma/pic/makefile b/miniapps/plasma/pic/makefile index fb0804519b..dae795e827 100644 --- a/miniapps/plasma/pic/makefile +++ b/miniapps/plasma/pic/makefile @@ -20,6 +20,7 @@ CONFIG_MK = $(or $(wildcard $(MFEM_BUILD_DIR)/config/config.mk),\ MFEM_LIB_FILE = mfem_is_not_built -include $(CONFIG_MK) +SEQ_MINIAPPS = PAR_MINIAPPS = ifeq ($(MFEM_USE_GSLIB),YES) @@ -27,9 +28,9 @@ ifeq ($(MFEM_USE_GSLIB),YES) endif ifeq ($(MFEM_USE_MPI),NO) - MINIAPPS = + MINIAPPS = $(SEQ_MINIAPPS) else - MINIAPPS = $(PAR_MINIAPPS) + MINIAPPS = $(PAR_MINIAPPS) $(SEQ_MINIAPPS) endif .SUFFIXES: @@ -50,7 +51,7 @@ COMMON_LIB += $(if $(MFEM_SHARED:YES=),,\ all: $(MINIAPPS) # Rules for building the miniapps -electrostatic-pic: electrostatic-pic.cpp $(MFEM_LIB_FILE) $(CONFIG_MK) | lib-common +%: $(SRC)%.cpp $(MFEM_LIB_FILE) $(CONFIG_MK) | lib-common $(MFEM_CXX) $(MFEM_FLAGS) -c $< $(MFEM_CXX) $(MFEM_LINK_FLAGS) -o $@ $@.o $(COMMON_LIB) $(MFEM_LIBS) diff --git a/tests/unit/fem/test_particleset.cpp b/tests/unit/fem/test_particleset.cpp index a6a11c0901..2ad6422d35 100644 --- a/tests/unit/fem/test_particleset.cpp +++ b/tests/unit/fem/test_particleset.cpp @@ -296,7 +296,7 @@ void TestRedistribute(Ordering::Type ordering) int wrong_proc_count = 0; for (int i = 0; i < procs.Size(); i++) { - if (rank != procs[i]) + if (static_cast(rank) != procs[i]) { wrong_proc_count++; }