├── .gitignore ├── CHANGELOG ├── COPYRIGHT ├── LICENSE ├── Makefile ├── README.md ├── braid ├── Makefile ├── README.md ├── _braid.h ├── access.c ├── adjoint.c ├── adjoint.h ├── base.c ├── base.h ├── braid.c ├── braid.h ├── braid.hpp ├── braid.pyx ├── braid_F90_iface.c ├── braid_defs.h ├── braid_status.c ├── braid_status.h ├── braid_test.c ├── braid_test.h ├── communication.c ├── delta.c ├── delta.h ├── distribution.c ├── drive.c ├── grid.c ├── hierarchy.c ├── interp.c ├── mpistubs.c ├── mpistubs.h ├── norm.c ├── refine.c ├── relax.c ├── residual.c ├── restrict.c ├── space.c ├── status.h ├── step.c ├── tape.c ├── tape.h ├── util.c ├── util.h └── uvector.c ├── docs ├── Abstract.md ├── Examples.md ├── Introduction.md ├── Makefile ├── README.md ├── developer_manual.conf ├── developer_manual_header.tex ├── img │ ├── 3_MG_In_Time_Iterations.pdf │ ├── 3_MG_In_Time_Iterations.png │ ├── 3_MG_In_Time_Iterations.pptx │ ├── 3_levels.pdf │ ├── CrelaxationDetail.pdf │ ├── FCycle.pdf │ ├── FCycle_Vcycle.pptx │ ├── Frelaxation.pdf │ ├── FrelaxationDetail.pdf │ ├── FrelaxationDetail2.pdf │ ├── VCycle.pdf │ ├── data_layout.pdf │ ├── data_layout.pptx │ ├── heat_results.pdf │ ├── heat_results.pptx │ ├── logo_no_subtext.pdf │ ├── logo_with_subtext.pdf │ ├── logo_with_subtext_2_inch.png │ ├── overlap.pdf │ ├── parallel_timeline.pdf │ ├── sequential0.pdf │ ├── sequential1.pdf │ ├── sequential2.pdf │ ├── sequential3.pdf │ ├── spatial_coarsening.pdf │ ├── spatial_coarsening.pptx │ ├── timeline.pdf │ ├── title.pdf │ └── title.pptx ├── user_manual.conf └── user_manual_header.tex ├── drivers ├── Makefile ├── README.md ├── braid_mfem.hpp ├── braid_mfem_block.hpp ├── drive-KS-Delta │ ├── Makefile │ ├── drive-ks.cpp │ ├── ks_lib.cpp │ ├── ks_lib.hpp │ └── vis_ks.py ├── drive-Lorenz-Delta │ ├── Makefile │ ├── drive-lorenz-Delta.cpp │ ├── drive-lorenz-LRDelta.cpp │ ├── lorenz_lib.cpp │ ├── lorenz_lib.hpp │ └── vis_lorenz_LRDelta.py ├── drive-adv-diff-1D-Cython │ ├── README.md │ ├── drive_adv_diff_1D-setup.py │ ├── drive_adv_diff_1D.pyx │ ├── drive_adv_diff_1D_run.py │ ├── drive_adv_diff_1D_scriptrun.py │ ├── invert_sparse_mat_splu.py │ └── viz_drive_adv_diff_1D.py ├── drive-adv-diff-DG.cpp ├── drive-burgers-1D.c ├── drive-diffusion-1D-moving-mesh-serial.cpp ├── drive-diffusion-1D-moving-mesh.cpp ├── drive-diffusion-2D.c ├── drive-diffusion-ben.cpp ├── drive-diffusion.cpp ├── drive-lin-elasticity.cpp ├── drive-nonlin-elasticity.cpp ├── drive-pLaplacian.cpp ├── drive-solve-adjoint-with-xbraid-lib.c ├── drive-solve-adjoint-with-xbraid.c ├── hypre_extra.hpp ├── mfem_arnoldi.hpp └── viz-burgers-1D.py ├── examples ├── Makefile ├── README.md ├── ex-01-adjoint.c ├── ex-01-cython-alt │ ├── README.md │ ├── ex_01_alt-setup.py │ ├── ex_01_alt.pyx │ └── ex_01_alt_run.py ├── ex-01-cython │ ├── README.md │ ├── ex_01-setup.py │ ├── ex_01.pyx │ └── ex_01_run.py ├── ex-01-expanded-bdf2.c ├── ex-01-expanded-f.f90 ├── ex-01-expanded.c ├── ex-01-optimization.c ├── ex-01-pp.cpp ├── ex-01-refinement.c ├── ex-01.c ├── ex-02-lib.c ├── ex-02-serial.c ├── ex-02.c ├── ex-03-lib.c ├── ex-03-serial.c ├── ex-03.c ├── ex-04-lib.c ├── ex-04-serial.c ├── ex-04.c ├── ex-05-cython │ ├── README.md │ ├── ex_05-setup.py │ ├── ex_05.pyx │ ├── ex_05_run.py │ ├── invert_sparse_mat_splu.py │ └── viz_ex_05.py ├── ex-06.c ├── ex-07.c ├── vis.c ├── viz-ex-02.py ├── viz-ex-04.py ├── viz-ex-06.py └── viz-ex-07.py ├── makefile.inc ├── misc ├── README.md ├── sample.emacs ├── sample.vimrc ├── sample_c_code.c ├── user_utils │ ├── cycleplot.gnuplot │ ├── cycleplot.m │ ├── cycleplot.py │ ├── cycleplot2.gnuplot │ └── waitfile.sh ├── zdist1.c └── zdist2.c └── test ├── README.md ├── adjoint.saved ├── adjoint.sh ├── autotest.sh ├── compare_examples_drivers.saved ├── compare_examples_drivers.sh ├── compare_examples_drivers_storage.saved ├── compare_examples_drivers_storage.sh ├── cython_tests.saved ├── cython_tests.sh ├── diffusion1D.saved ├── diffusion1D.sh ├── diffusion1D_check_rnorm.saved ├── diffusion1D_check_rnorm.sh ├── diffusion1D_scaling.saved ├── diffusion1D_scaling.sh ├── diffusion2D.saved ├── diffusion2D.sh ├── diffusion2D_check_rnorm.saved ├── diffusion2D_check_rnorm.sh ├── diffusion2D_check_rnorm_storage.saved ├── diffusion2D_check_rnorm_storage.sh ├── diffusion2D_scaling.saved ├── diffusion2D_scaling.sh ├── diffusion2D_scaling_storage.saved ├── diffusion2D_scaling_storage.sh ├── diffusion2D_storage.saved ├── diffusion2D_storage.sh ├── docs.saved ├── docs.sh ├── lorenz_delta.saved ├── lorenz_delta.sh ├── machine-mac.sh ├── machine-tux.sh ├── memcheck-tux-jacob.saved ├── memcheck-tux-jacob.sh ├── mfem.saved ├── mfem.sh ├── ode1D-refine-periodic.saved ├── ode1D-refine-periodic.sh ├── ode1D.saved ├── ode1D.sh ├── richardson.saved ├── richardson.sh ├── shellvector_bdf2.saved ├── shellvector_bdf2.sh ├── test-checkout-compile.saved ├── test-checkout-compile.sh └── test.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # output files 2 | # these are generated by various examples and drivers, and generally should not be committed. 3 | *.cycle 4 | *.out 5 | *.out.* 6 | *.csv 7 | wrapperTests.txt 8 | 9 | # binaries 10 | # as these are build-dependent, binaries should not be committed 11 | *.o 12 | *.a 13 | ex-01 14 | ex-01-adjoint 15 | ex-01-expanded 16 | ex-01-expanded-bdf2 17 | ex-01-optimization 18 | ex-01-pp 19 | ex-01-refinement 20 | ex-02 21 | ex-03 22 | ex-03-serial 23 | ex-04 24 | ex-04-serial 25 | ex-06 26 | ex-07 27 | drive-lorenz-LRDelta 28 | drive-lorenz-Delta 29 | drive-ks 30 | 31 | # etc. 32 | Eigen 33 | __pycache__ 34 | -------------------------------------------------------------------------------- /COPYRIGHT: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2013, Lawrence Livermore National Security, LLC. 2 | # Produced at the Lawrence Livermore National Laboratory. Written by 3 | # Jacob Schroder, Rob Falgout, Tzanio Kolev, Ulrike Yang, Veselin 4 | # Dobrev, et al. LLNL-CODE-660355. All rights reserved. 5 | # 6 | # This file is part of XBraid. For support, post issues to the XBraid Github page. 7 | # 8 | # This program is free software; you can redistribute it and/or modify it under 9 | # the terms of the GNU General Public License (as published by the Free Software 10 | # Foundation) version 2.1 dated February 1999. 11 | # 12 | # This program is distributed in the hope that it will be useful, but WITHOUT ANY 13 | # WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A 14 | # PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public 15 | # License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public License along 18 | # with this program; if not, write to the Free Software Foundation, Inc., 59 19 | # Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | 21 | 22 | COPYRIGHT 23 | 24 | The following copyright applies to each file in the XBraid distribution, unless 25 | otherwise stated in the file: 26 | 27 | Copyright (c) 2013, Lawrence Livermore National Security, LLC. Produced at the 28 | Lawrence Livermore National Laboratory. Written by Jacob Schroder 29 | schroder2@llnl.gov, Rob Falgout falgout2@llnl.gov, Tzanio Kolev 30 | kolev1@llnl.gov, Ulrike Yang yang11@llnl.gov, Veselin Dobrev dobrev1@llnl.gov, 31 | et al. LLNL-CODE-660355. All rights reserved. 32 | 33 | This file is part of XBraid. 34 | 35 | For more license information, see the LICENSE file. 36 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | #BHEADER********************************************************************** 2 | # 3 | # Copyright (c) 2013, Lawrence Livermore National Security, LLC. 4 | # Produced at the Lawrence Livermore National Laboratory. Written by 5 | # Jacob Schroder, Rob Falgout, Tzanio Kolev, Ulrike Yang, Veselin 6 | # Dobrev, et al. LLNL-CODE-660355. All rights reserved. 7 | # 8 | # This file is part of XBraid. For support, post issues to the XBraid Github page. 9 | # 10 | # This program is free software; you can redistribute it and/or modify it under 11 | # the terms of the GNU General Public License (as published by the Free Software 12 | # Foundation) version 2.1 dated February 1999. 13 | # 14 | # This program is distributed in the hope that it will be useful, but WITHOUT ANY 15 | # WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A 16 | # PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public 17 | # License for more details. 18 | # 19 | # You should have received a copy of the GNU Lesser General Public License along 20 | # with this program; if not, write to the Free Software Foundation, Inc., 59 21 | # Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | # 23 | #EHEADER********************************************************************** 24 | 25 | ################################################################## 26 | # Import machine specific compilers, options, flags, etc.. 27 | ################################################################## 28 | 29 | .PHONY: all braid clean 30 | 31 | all: braid examples 32 | 33 | braid: 34 | cd braid; $(MAKE) 35 | 36 | examples: ./braid/libbraid.a 37 | cd examples; $(MAKE) 38 | 39 | drivers: ./braid/libbraid.a 40 | cd drivers; $(MAKE) 41 | 42 | clean: 43 | cd examples; $(MAKE) clean 44 | cd drivers; $(MAKE) clean 45 | cd braid; $(MAKE) clean 46 | 47 | info: 48 | @echo "MPICC = `which $(MPICC)`" 49 | @echo "MPICXX = `which $(MPICXX)`" 50 | @echo "MPIF90 = `which $(MPIF90)`" 51 | @echo "CFLAGS = $(CFLAGS)" 52 | @echo "CXXFLAGS = $(CXXFLAGS)" 53 | @echo "FORTFLAGS = $(FORTFLAGS)" 54 | @echo "LFLAGS = $(LFLAGS)" 55 | -------------------------------------------------------------------------------- /braid/Makefile: -------------------------------------------------------------------------------- 1 | #BHEADER********************************************************************** 2 | # Copyright (c) 2013, Lawrence Livermore National Security, LLC. 3 | # Produced at the Lawrence Livermore National Laboratory. 4 | # 5 | # This file is part of XBraid. For support, post issues to the XBraid Github page. 6 | # 7 | # This program is free software; you can redistribute it and/or modify it under 8 | # the terms of the GNU General Public License (as published by the Free Software 9 | # Foundation) version 2.1 dated February 1999. 10 | # 11 | # This program is distributed in the hope that it will be useful, but WITHOUT ANY 12 | # WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A 13 | # PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public 14 | # License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License along 17 | # with this program; if not, write to the Free Software Foundation, Inc., 59 18 | # Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | # 20 | #EHEADER********************************************************************** 21 | 22 | ################################################################## 23 | # Import machine specific compilers, options, flags, etc.. 24 | ################################################################## 25 | 26 | include ../makefile.inc 27 | 28 | ################################################################## 29 | # Targets 30 | ################################################################## 31 | 32 | BRAID_HEADERS =\ 33 | _braid.h\ 34 | base.h\ 35 | status.h\ 36 | tape.h\ 37 | util.h\ 38 | braid.h\ 39 | braid_status.h\ 40 | braid_test.h 41 | 42 | BRAID_FILES =\ 43 | access.c\ 44 | adjoint.c\ 45 | base.c\ 46 | braid.c\ 47 | braid_status.c\ 48 | braid_F90_iface.c\ 49 | braid_test.c\ 50 | communication.c\ 51 | delta.c\ 52 | distribution.c\ 53 | drive.c\ 54 | grid.c\ 55 | hierarchy.c\ 56 | interp.c\ 57 | mpistubs.c\ 58 | norm.c\ 59 | refine.c\ 60 | relax.c\ 61 | residual.c\ 62 | restrict.c\ 63 | space.c\ 64 | step.c\ 65 | tape.c\ 66 | util.c\ 67 | uvector.c 68 | 69 | ifeq ($(sequential),yes) 70 | BRAID_HEADERS += mpistubs.h 71 | BRAID_FILES += mpistubs.c 72 | SEQFLAGS = -Dbraid_SEQUENTIAL 73 | else 74 | SEQFLAGS = 75 | endif 76 | 77 | BRAID_OBJ = $(BRAID_FILES:.c=.o) 78 | 79 | .PHONY: all clean 80 | .SUFFIXES: 81 | .SUFFIXES: .c .o 82 | 83 | # Rule for compiling .c files 84 | %.o: %.c $(BRAID_HEADERS) 85 | $(MPICC) $(SEQFLAGS) $(CFLAGS) -c $< -o $@ 86 | 87 | libbraid.a: $(BRAID_HEADERS) $(BRAID_OBJ) 88 | @echo "Building" $@ "..." 89 | ar cruv libbraid.a $(BRAID_OBJ) 90 | ranlib libbraid.a 91 | 92 | all: libbraid.a 93 | 94 | clean: 95 | rm -f *.o libbraid.a 96 | 97 | -------------------------------------------------------------------------------- /braid/README.md: -------------------------------------------------------------------------------- 1 | ## File naming conventions 2 | 21 | 22 | These are the general filenaming conventions for Braid 23 | 24 | User interface routines in braid begin with `braid_` and all other internal 25 | non-user routines begin with `_braid_`. This helps to prevent name clashes when 26 | working with other libraries and helps to clearly distinguish user routines that 27 | are supported and maintained. 28 | 29 | To keep things somewhat organized, all user header files and implementation 30 | files should have names that begin with `braid`, for example, `braid.h`, 31 | `braid.c`, `braid_status.c`, ... There should be no user interface prototypes 32 | or implementations that appear elsewhere. 33 | 34 | Note that it is okay to include internal prototypes and implementations in these 35 | user interface files when it makes sense (say, as supporting routines), but this 36 | should generally be avoided. 37 | 38 | An attempt has been made to simplify header file usage as much as possible by 39 | requiring only one header file for users, `braid.h`, and one header file for 40 | developers, `_braid.h`. 41 | -------------------------------------------------------------------------------- /braid/adjoint.h: -------------------------------------------------------------------------------- 1 | /*BHEADER********************************************************************** 2 | * Copyright (c) 2013, Lawrence Livermore National Security, LLC. 3 | * Produced at the Lawrence Livermore National Laboratory. 4 | * 5 | * This file is part of XBraid. For support, post issues to the XBraid Github page. 6 | * 7 | * This program is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU General Public License (as published by the Free Software 9 | * Foundation) version 2.1 dated February 1999. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public 14 | * License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along 17 | * with this program; if not, write to the Free Software Foundation, Inc., 59 18 | * Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | ***********************************************************************EHEADER*/ 21 | 22 | /** \file adjoint.h 23 | * \brief Define internal XBraid headers for the adjoint feature. 24 | * 25 | * This file contains the internal XBriad headers for the adjoint feature, 26 | * e.g., the functions to wrap and call the users objective function, and 27 | * allocate adjoint (bar) variables. 28 | */ 29 | 30 | #ifndef _braid_adjoint_HEADER 31 | #define _braid_adjoint_HEADER 32 | 33 | #include "_braid.h" 34 | 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /** 40 | * Shallow copy a braid_VectorBar shared pointer, bar_ptr is set to bar 41 | * and the useCount is incremented by one. 42 | */ 43 | braid_Int 44 | _braid_VectorBarCopy(braid_VectorBar bar, 45 | braid_VectorBar *bar_ptr); 46 | 47 | /** 48 | * Reduce the useCount of a braid_VectorBar shared pointer 49 | * Free the pointer memory if useCount is zero. 50 | */ 51 | braid_Int 52 | _braid_VectorBarDelete(braid_Core core, 53 | braid_VectorBar bar); 54 | 55 | /** 56 | * Free memory of the optimization structure 57 | */ 58 | braid_Int 59 | _braid_OptimDestroy( braid_Core core); 60 | 61 | /** 62 | * Update the adjoint variables and compute adjoint residual norm 63 | * Returns the tnorm of adjoint residual 64 | */ 65 | braid_Int 66 | _braid_UpdateAdjoint(braid_Core core, 67 | braid_Real *rnorm_adj_ptr); 68 | 69 | /** 70 | * Set adjoint residual norm 71 | */ 72 | braid_Int 73 | _braid_SetRNormAdjoint(braid_Core core, 74 | braid_Int iter, 75 | braid_Real rnorm_adj); 76 | 77 | /** 78 | * Evaluate the user's local objective function at time *t* and add it to the 79 | * time-averaged objective function 80 | */ 81 | braid_Int 82 | _braid_AddToObjective(braid_Core core, 83 | braid_BaseVector u, 84 | braid_ObjectiveStatus ostatus); 85 | 86 | /** 87 | * Evaluate the objective function: 88 | * MPI_Allreduce the time average and postprocess the objective 89 | */ 90 | braid_Int 91 | _braid_EvalObjective(braid_Core core); 92 | 93 | /** 94 | * Differentiated objective function 95 | */ 96 | braid_Int 97 | _braid_EvalObjective_diff(braid_Core core); 98 | 99 | /** 100 | * Allocate and initialize the adjoint variables 101 | */ 102 | braid_Int 103 | _braid_InitAdjointVars(braid_Core core, 104 | _braid_Grid *fine_grid); 105 | 106 | /** 107 | * Sanity check for non-supported adjoint features 108 | */ 109 | braid_Int 110 | _braid_AdjointFeatureCheck(braid_Core core); 111 | 112 | #ifdef __cplusplus 113 | } 114 | #endif 115 | 116 | #endif 117 | -------------------------------------------------------------------------------- /braid/braid_defs.h: -------------------------------------------------------------------------------- 1 | /*BHEADER********************************************************************** 2 | * Copyright (c) 2013, Lawrence Livermore National Security, LLC. 3 | * Produced at the Lawrence Livermore National Laboratory. 4 | * 5 | * This file is part of XBraid. For support, post issues to the XBraid Github page. 6 | * 7 | * This program is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU General Public License (as published by the Free Software 9 | * Foundation) version 2.1 dated February 1999. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public 14 | * License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along 17 | * with this program; if not, write to the Free Software Foundation, Inc., 59 18 | * Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | ***********************************************************************EHEADER*/ 21 | 22 | 23 | /** \file braid_defs.h 24 | * \brief Definitions of braid types, error flags, etc... 25 | * 26 | */ 27 | 28 | #ifndef braid_defs_HEADER 29 | #define braid_defs_HEADER 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /*-------------------------------------------------------------------------- 41 | * Define basic types 42 | *--------------------------------------------------------------------------*/ 43 | 44 | /** 45 | * Defines integer type 46 | **/ 47 | typedef int braid_Int; 48 | #define braid_Int_Max INT_MAX; 49 | #define braid_Int_Min INT_MIN; 50 | 51 | /** 52 | * Defines byte type 53 | * (can be any type, but sizeof(braid_Byte) MUST be 1) 54 | */ 55 | typedef char braid_Byte; 56 | 57 | /** 58 | * Defines floating point type 59 | * Switch beween single and double precision by un-/commenting lines. 60 | **/ 61 | // typedef float braid_Real; 62 | typedef double braid_Real; 63 | 64 | /*-------------------------------------------------------------------------- 65 | * MPI stuff 66 | *--------------------------------------------------------------------------*/ 67 | 68 | /* Switch beween single and double precision by un-/commenting lines. */ 69 | // #define braid_MPI_REAL MPI_FLOAT 70 | #define braid_MPI_REAL MPI_DOUBLE 71 | #define braid_MPI_INT MPI_INT 72 | #define braid_MPI_Comm MPI_Comm 73 | 74 | 75 | typedef struct _braid_Vector_struct _braid_Vector; 76 | /** 77 | * This defines (roughly) a state vector at a certain time value. 78 | * It could also contain any other information related to this vector which is 79 | * needed to evolve the vector to the next time value, like mesh information. 80 | * *reproduced here from braid.h to give braid_status access to the braid_Vector typedef* 81 | **/ 82 | typedef _braid_Vector *braid_Vector; 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | 88 | #endif 89 | 90 | -------------------------------------------------------------------------------- /braid/delta.h: -------------------------------------------------------------------------------- 1 | /*BHEADER********************************************************************** 2 | * Copyright (c) 2013, Lawrence Livermore National Security, LLC. 3 | * Produced at the Lawrence Livermore National Laboratory. 4 | * 5 | * This file is part of XBraid. For support, post issues to the XBraid Github page. 6 | * 7 | * This program is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU General Public License (as published by the Free Software 9 | * Foundation) version 2.1 dated February 1999. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public 14 | * License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along 17 | * with this program; if not, write to the Free Software Foundation, Inc., 59 18 | * Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | ***********************************************************************EHEADER*/ 21 | 22 | /** \file delta.h 23 | * \brief Define internal XBraid headers for Delta correction. 24 | * 25 | * This file contains the internal XBraid headers for Delta correction, 26 | */ 27 | 28 | #ifndef _braid_DELTA_HEADER 29 | #define _braid_DELTA_HEADER 30 | 31 | #include "_braid.h" 32 | 33 | #ifdef __cplusplus 34 | extern "C" 35 | { 36 | #endif 37 | 38 | /** 39 | * macro for determining when to compute Delta correction 40 | */ 41 | #define _braid_DoDeltaCorrect(core, level, niter) \ 42 | ( _braid_CoreElt(core, delta_correct) && niter >= _braid_CoreElt(core, delta_defer_iter) && level >= _braid_CoreElt(core, delta_defer_lvl) ) 43 | 44 | /** 45 | * macro for determining when we can use computed Delta correction 46 | */ 47 | #define _braid_UseDeltaCorrect(core, level, niter) \ 48 | ( _braid_CoreElt(core, delta_correct) && niter >= _braid_CoreElt(core, delta_defer_iter) && level > _braid_CoreElt(core, delta_defer_lvl) ) 49 | 50 | /** 51 | * Compute the action of the low-rank approximation to Delta on a vector 52 | */ 53 | 54 | braid_Int 55 | _braid_LRDeltaDot(braid_Core core, 56 | braid_App app, 57 | braid_Vector u, 58 | braid_Basis delta, 59 | braid_Basis basis); 60 | 61 | /** 62 | * Compute the action of the low-rank approximation to Delta on a basis 63 | */ 64 | 65 | braid_Int 66 | _braid_LRDeltaDotMat(braid_Core core, 67 | braid_App app, 68 | braid_Basis psi, 69 | braid_Basis delta, 70 | braid_Basis basis); 71 | 72 | 73 | /** 74 | * Perform modified Gram-Schmidt orthonormalization on a basis, while also 75 | * computing local Lyapunov exponents 76 | */ 77 | braid_Int 78 | _braid_GramSchmidt(braid_Core core, 79 | braid_App app, 80 | braid_Basis basis, 81 | braid_Real *exps); 82 | 83 | /** 84 | * Sanity check for non-supported Delta correction features 85 | */ 86 | braid_Int 87 | _braid_DeltaFeatureCheck(braid_Core core); 88 | 89 | #ifdef __cplusplus 90 | } 91 | #endif 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /braid/distribution.c: -------------------------------------------------------------------------------- 1 | /*BHEADER********************************************************************** 2 | * Copyright (c) 2013, Lawrence Livermore National Security, LLC. 3 | * Produced at the Lawrence Livermore National Laboratory. 4 | * 5 | * This file is part of XBraid. For support, post issues to the XBraid Github page. 6 | * 7 | * This program is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU General Public License (as published by the Free Software 9 | * Foundation) version 2.1 dated February 1999. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public 14 | * License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along 17 | * with this program; if not, write to the Free Software Foundation, Inc., 59 18 | * Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | ***********************************************************************EHEADER*/ 21 | 22 | #include "_braid.h" 23 | #include "util.h" 24 | 25 | /*---------------------------------------------------------------------------- 26 | * Returns the index interval for 'proc' in a blocked data distribution 27 | *----------------------------------------------------------------------------*/ 28 | 29 | braid_Int 30 | _braid_GetBlockDistInterval(braid_Int npoints, 31 | braid_Int nprocs, 32 | braid_Int proc, 33 | braid_Int *ilower_ptr, 34 | braid_Int *iupper_ptr) 35 | { 36 | braid_Int ilower, iupper, quo, rem, p; 37 | 38 | quo = npoints/nprocs; 39 | rem = npoints%nprocs; 40 | 41 | p = proc; 42 | ilower = p*quo + (p < rem ? p : rem); 43 | p = proc+1; 44 | iupper = p*quo + (p < rem ? p : rem) - 1; 45 | 46 | *ilower_ptr = ilower; 47 | *iupper_ptr = iupper; 48 | 49 | return _braid_error_flag; 50 | } 51 | 52 | /*---------------------------------------------------------------------------- 53 | * Returns the processor that owns 'index' in a blocked data distribution 54 | * (returns -1 if index is out of range) 55 | *----------------------------------------------------------------------------*/ 56 | 57 | braid_Int 58 | _braid_GetBlockDistProc(braid_Int npoints, 59 | braid_Int nprocs, 60 | braid_Int index, 61 | braid_Int periodic, 62 | braid_Int *proc_ptr) 63 | { 64 | braid_Int proc, quo, rem, p, q; 65 | 66 | /* If periodic, adjust the index based on the periodicity */ 67 | if (periodic) 68 | { 69 | _braid_MapPeriodic(index, npoints); 70 | } 71 | 72 | /* Compute processor number */ 73 | if ((index < 0) || (index > (npoints-1))) 74 | { 75 | proc = -1; 76 | } 77 | else 78 | { 79 | quo = npoints/nprocs; 80 | rem = npoints%nprocs; 81 | 82 | if (quo > 0) 83 | { 84 | p = index/(quo+1); 85 | q = (index - rem*(quo+1))/quo; 86 | proc = (p < rem ? p : rem+q); 87 | } 88 | else 89 | { 90 | proc = index; 91 | } 92 | } 93 | 94 | *proc_ptr = proc; 95 | 96 | return _braid_error_flag; 97 | } 98 | 99 | /*---------------------------------------------------------------------------- 100 | * Returns the index interval for my processor on the finest grid level 101 | *----------------------------------------------------------------------------*/ 102 | 103 | braid_Int 104 | _braid_GetDistribution(braid_Core core, 105 | braid_Int *ilower_ptr, 106 | braid_Int *iupper_ptr) 107 | { 108 | MPI_Comm comm = _braid_CoreElt(core, comm); 109 | braid_Int gupper = _braid_CoreElt(core, gupper); 110 | braid_Int reverted_ranks = _braid_CoreElt(core, reverted_ranks); 111 | braid_Int npoints, nprocs, proc; 112 | braid_Int ilower, iupper; 113 | 114 | npoints = gupper + 1; 115 | MPI_Comm_size(comm, &nprocs); 116 | MPI_Comm_rank(comm, &proc); 117 | 118 | _braid_GetBlockDistInterval(npoints, nprocs, proc, &ilower, &iupper); 119 | 120 | /* revert ranks */ 121 | if (reverted_ranks) 122 | { 123 | *ilower_ptr = npoints-1 - iupper; 124 | *iupper_ptr = npoints-1 - ilower; 125 | } 126 | else 127 | { 128 | *ilower_ptr = ilower; 129 | *iupper_ptr = iupper; 130 | } 131 | 132 | return _braid_error_flag; 133 | 134 | } 135 | 136 | /*---------------------------------------------------------------------------- 137 | * Returns the processor that owns 'index' on the given grid 'level' 138 | * (returns -1 if index is out of range) 139 | *----------------------------------------------------------------------------*/ 140 | 141 | braid_Int 142 | _braid_GetProc(braid_Core core, 143 | braid_Int level, 144 | braid_Int index, 145 | braid_Int *proc_ptr) 146 | { 147 | MPI_Comm comm = _braid_CoreElt(core, comm); 148 | _braid_Grid **grids = _braid_CoreElt(core, grids); 149 | braid_Int gupper = _braid_CoreElt(core, gupper); 150 | braid_Int reverted_ranks = _braid_CoreElt(core, reverted_ranks); 151 | braid_Int npoints, nprocs; 152 | braid_Int l, cfactor; 153 | 154 | npoints = gupper + 1; 155 | MPI_Comm_size(comm, &nprocs); 156 | /* Map index to the finest grid */ 157 | for (l = level-1; l > -1; l--) 158 | { 159 | cfactor = _braid_GridElt(grids[l], cfactor); 160 | _braid_MapCoarseToFine(index, cfactor, index); 161 | } 162 | 163 | if (reverted_ranks) 164 | { 165 | index = npoints -1 - index; 166 | } 167 | 168 | _braid_GetBlockDistProc(npoints, nprocs, index, _braid_CoreElt(core, periodic), proc_ptr); 169 | 170 | return _braid_error_flag; 171 | } 172 | 173 | -------------------------------------------------------------------------------- /braid/grid.c: -------------------------------------------------------------------------------- 1 | /*BHEADER********************************************************************** 2 | * Copyright (c) 2013, Lawrence Livermore National Security, LLC. 3 | * Produced at the Lawrence Livermore National Laboratory. 4 | * 5 | * This file is part of XBraid. For support, post issues to the XBraid Github page. 6 | * 7 | * This program is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU General Public License (as published by the Free Software 9 | * Foundation) version 2.1 dated February 1999. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public 14 | * License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along 17 | * with this program; if not, write to the Free Software Foundation, Inc., 59 18 | * Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | ***********************************************************************EHEADER*/ 21 | 22 | #include "_braid.h" 23 | #include "util.h" 24 | 25 | /*---------------------------------------------------------------------------- 26 | * Create a new grid object 27 | *----------------------------------------------------------------------------*/ 28 | 29 | braid_Int 30 | _braid_GridInit(braid_Core core, 31 | braid_Int level, 32 | braid_Int ilower, 33 | braid_Int iupper, 34 | _braid_Grid **grid_ptr) 35 | { 36 | _braid_Grid *grid; 37 | braid_Real *ta; 38 | 39 | grid = _braid_CTAlloc(_braid_Grid, 1); 40 | 41 | _braid_GridElt(grid, level) = level; 42 | _braid_GridElt(grid, ilower) = ilower; 43 | _braid_GridElt(grid, iupper) = iupper; 44 | _braid_GridElt(grid, recv_index) = _braid_RecvIndexNull; 45 | _braid_GridElt(grid, send_index) = _braid_SendIndexNull; 46 | 47 | /* Store each processor's time slice, plus one time value to the left 48 | * and to the right */ 49 | ta = _braid_CTAlloc(braid_Real, iupper-ilower+3); 50 | _braid_GridElt(grid, ta_alloc) = ta; 51 | _braid_GridElt(grid, ta) = ta+1; /* shift */ 52 | 53 | /* Initialize last time step storage with NULL, only used on finest grid */ 54 | _braid_GridElt(grid, ulast) = NULL; 55 | 56 | *grid_ptr = grid; 57 | 58 | return _braid_error_flag; 59 | } 60 | 61 | /*---------------------------------------------------------------------------- 62 | *----------------------------------------------------------------------------*/ 63 | 64 | braid_Int 65 | _braid_GridClean(braid_Core core, 66 | _braid_Grid *grid) 67 | { 68 | braid_App app = _braid_CoreElt(core, app); 69 | braid_Int ilower = _braid_GridElt(grid, ilower); 70 | braid_Int iupper = _braid_GridElt(grid, iupper); 71 | braid_Int nupoints = _braid_GridElt(grid, nupoints); 72 | braid_BaseVector *ua = _braid_GridElt(grid, ua); 73 | braid_BaseVector *va = _braid_GridElt(grid, va); 74 | braid_BaseVector *fa = _braid_GridElt(grid, fa); 75 | braid_BaseVector *ua_alloc = _braid_GridElt(grid, ua_alloc); 76 | braid_BaseVector *va_alloc = _braid_GridElt(grid, va_alloc); 77 | braid_BaseVector *fa_alloc = _braid_GridElt(grid, fa_alloc); 78 | 79 | braid_Int ii; 80 | 81 | if (ua_alloc) 82 | { 83 | for (ii = 0; ii < nupoints; ii++) 84 | { 85 | if (ua[ii] != NULL) 86 | { 87 | _braid_BaseFree(core, app, ua[ii]); 88 | ua[ii] = NULL; 89 | } 90 | } 91 | } 92 | if (va_alloc) 93 | { 94 | for (ii = -1; ii <= (iupper-ilower); ii++) 95 | { 96 | if (va[ii] != NULL) 97 | { 98 | _braid_BaseFree(core, app, va[ii]); 99 | va[ii] = NULL; 100 | } 101 | } 102 | } 103 | if (fa_alloc) 104 | { 105 | for (ii = -1; ii <= (iupper-ilower); ii++) 106 | { 107 | if (fa[ii] != NULL) 108 | { 109 | _braid_BaseFree(core, app, fa[ii]); 110 | fa[ii] = NULL; 111 | } 112 | } 113 | } 114 | 115 | return _braid_error_flag; 116 | } 117 | 118 | /*---------------------------------------------------------------------------- 119 | *----------------------------------------------------------------------------*/ 120 | 121 | braid_Int 122 | _braid_GridDestroy(braid_Core core, 123 | _braid_Grid *grid) 124 | { 125 | if (grid) 126 | { 127 | braid_BaseVector *ua_alloc = _braid_GridElt(grid, ua_alloc); 128 | braid_Real *ta_alloc = _braid_GridElt(grid, ta_alloc); 129 | braid_BaseVector *va_alloc = _braid_GridElt(grid, va_alloc); 130 | braid_BaseVector *fa_alloc = _braid_GridElt(grid, fa_alloc); 131 | 132 | _braid_GridClean(core, grid); 133 | 134 | if (ua_alloc) 135 | { 136 | _braid_TFree(ua_alloc); 137 | } 138 | if (ta_alloc) 139 | { 140 | _braid_TFree(ta_alloc); 141 | } 142 | if (va_alloc) 143 | { 144 | _braid_TFree(va_alloc); 145 | } 146 | if (fa_alloc) 147 | { 148 | _braid_TFree(fa_alloc); 149 | } 150 | 151 | _braid_TFree(grid); 152 | } 153 | return _braid_error_flag; 154 | } 155 | 156 | -------------------------------------------------------------------------------- /braid/tape.h: -------------------------------------------------------------------------------- 1 | /*BHEADER********************************************************************** 2 | * Copyright (c) 2013, Lawrence Livermore National Security, LLC. 3 | * Produced at the Lawrence Livermore National Laboratory. 4 | * 5 | * This file is part of XBraid. For support, post issues to the XBraid Github page. 6 | * 7 | * This program is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU General Public License (as published by the Free Software 9 | * Foundation) version 2.1 dated February 1999. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public 14 | * License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along 17 | * with this program; if not, write to the Free Software Foundation, Inc., 59 18 | * Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | ***********************************************************************EHEADER*/ 21 | 22 | /** \file tape.h 23 | * \brief Define the XBraid internal headers for the action-tape routines 24 | * (linked list for AD) 25 | * 26 | */ 27 | 28 | #ifndef _braid_tape_HEADER 29 | #define _braid_tape_HEADER 30 | 31 | #include "_braid.h" 32 | #include "util.h" 33 | #include "braid.h" 34 | 35 | /** 36 | * 37 | * C-Implementation of a linked list storing pointers to generic data 38 | * This structure represents one tape element, holding a pointer to data and a pointer to the next element 39 | * int size holds the number of all elements in the tape 40 | **/ 41 | typedef struct _braid_tape_struct 42 | { 43 | int size; 44 | void *data_ptr; 45 | struct _braid_tape_struct *next; 46 | 47 | } _braid_Tape; 48 | 49 | 50 | /** 51 | * Enumerator for identifying performed action 52 | **/ 53 | typedef enum _braid_Call_enum 54 | { 55 | STEP = 1, 56 | INIT = 2, 57 | CLONE = 3, 58 | FREE = 4, 59 | SUM = 5, 60 | BUFPACK = 6, 61 | BUFUNPACK = 7, 62 | ACCESS = 8, 63 | OBJECTIVET = 9 64 | 65 | } _braid_Call; 66 | 67 | /** 68 | * XBraid Action structure 69 | * 70 | * Holds information for the called user routines 71 | **/ 72 | typedef struct _braid_Action_struct 73 | { 74 | _braid_Call braidCall; /**< type of the user routine */ 75 | braid_Core core; /**< pointer to braid's core structure */ 76 | braid_Real inTime; /**< time of the input vector */ 77 | braid_Real outTime; /**< time of the output vector */ 78 | braid_Int inTimeIdx; /**< index of time of input vector */ 79 | braid_Real sum_alpha; /**< first coefficient of my_sum */ 80 | braid_Real sum_beta; /**< second coefficient of my_sum */ 81 | braid_Int send_recv_rank; /**< processor rank of sender / receiver in my_bufpack / my_bufunpack */ 82 | braid_Int braid_iter; /**< iteration number of xBraid */ 83 | braid_Int myid; /**< processors id */ 84 | braid_Int level; /**< current level in Braid */ 85 | braid_Int nrefine; /**< number of refinements done */ 86 | braid_Int gupper; /**< global size of the fine grid */ 87 | braid_Real tol; /**< primal stopping tolerance */ 88 | braid_Int messagetype; /**< message type, 0: for Step(), 1: for load balancing */ 89 | braid_Int size_buffer; /**< if set by user, size of send buffer is "size" bytes */ 90 | 91 | } _braid_Action; 92 | 93 | 94 | /** 95 | * Initialize the tape 96 | * Set head to NULL 97 | **/ 98 | braid_Int 99 | _braid_TapeInit(_braid_Tape* head); 100 | 101 | /** 102 | * Push data on the tape 103 | * Return pointer to head 104 | **/ 105 | _braid_Tape* 106 | _braid_TapePush(_braid_Tape* head, void* ptr); 107 | 108 | /** 109 | * Pop an element from the tape 110 | * Return pointer to head 111 | **/ 112 | _braid_Tape* 113 | _braid_TapePop(_braid_Tape* head); 114 | 115 | /** 116 | * Test if tape is empty 117 | * return 1 if tape is empty, otherwise returns 0 118 | **/ 119 | braid_Int 120 | _braid_TapeIsEmpty(_braid_Tape* head); 121 | 122 | /** 123 | * Returns the number of elements in the tape 124 | */ 125 | braid_Int 126 | _braid_TapeGetSize(_braid_Tape* head); 127 | 128 | /** 129 | * Display the tape in reverse order, calls the display function at each element 130 | * Input: - pointer to the braid core 131 | * - pointer to the display function 132 | */ 133 | braid_Int 134 | _braid_TapeDisplayBackwards(braid_Core core, _braid_Tape* head, void (*fctptr)(braid_Core core, void* data_ptr)); 135 | 136 | /** 137 | * Evaluate the action tape in reverse order. This will clear the action tape! 138 | * Input: - pointer to the braid core 139 | * - pointer to the head of the action tape 140 | */ 141 | braid_Int 142 | _braid_TapeEvaluate(braid_Core core); 143 | 144 | /** 145 | * Call differentiated action 146 | */ 147 | braid_Int 148 | _braid_DiffCall(_braid_Action* action); 149 | 150 | /** 151 | * Set the adjoint seed for tape evaluation, i.e., set u->bar at stored points 152 | * on level 0 to the values contained in core->optim->adjoints 153 | */ 154 | braid_Int 155 | _braid_TapeSetSeed(braid_Core core); 156 | 157 | /** 158 | * Set the pointers in tapeinput to the input of an xbraid iteration (ua). 159 | */ 160 | braid_Int 161 | _braid_TapeResetInput(braid_Core core); 162 | 163 | /** 164 | * Return the name of a _braid_Call (action name) 165 | */ 166 | const char* _braid_CallGetName(_braid_Call call); 167 | 168 | #endif 169 | -------------------------------------------------------------------------------- /braid/util.h: -------------------------------------------------------------------------------- 1 | /*BHEADER********************************************************************** 2 | * Copyright (c) 2013, Lawrence Livermore National Security, LLC. 3 | * Produced at the Lawrence Livermore National Laboratory. 4 | * 5 | * This file is part of XBraid. For support, post issues to the XBraid Github page. 6 | * 7 | * This program is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU General Public License (as published by the Free Software 9 | * Foundation) version 2.1 dated February 1999. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public 14 | * License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along 17 | * with this program; if not, write to the Free Software Foundation, Inc., 59 18 | * Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | ***********************************************************************EHEADER*/ 21 | 22 | /** \file util.h 23 | * \brief Define XBraid internal headers for utility routines. 24 | * 25 | * This file contains the headers for utility routines. Essentially, 26 | * if a routine does not take braid_Core (or other XBraid specific structs) 27 | * as an argument, then it's a utility routine. 28 | */ 29 | 30 | #ifndef _braid_util_HEADER 31 | #define _braid_util_HEADER 32 | 33 | #include "_braid.h" 34 | 35 | /** 36 | * Project an interval onto a strided index space that contains the index 37 | * 'index' and has stride 'stride'. An empty projection is represented by 38 | * ilower > iupper. 39 | **/ 40 | braid_Int 41 | _braid_ProjectInterval( braid_Int ilower, 42 | braid_Int iupper, 43 | braid_Int index, 44 | braid_Int stride, 45 | braid_Int *pilower, 46 | braid_Int *piupper ); 47 | 48 | /** 49 | * Retrieve the time step indices at this *level* corresponding to a local FC 50 | * interval given by *interval_index*. Argument *ci_ptr* is the time step index 51 | * for the C-pt and *flo_ptr* and *fhi_ptr* are the smallest and largest F-pt 52 | * indices in this interval. The C-pt is always to the right of the F-interval, 53 | * but neither a C-pt or an F-interval are guaranteed. If the *ci_ptr* returns 54 | * a -1, there is no C-pt. If the *flo_ptr* is greater than the *fhi_ptr*, 55 | * there is no F-interval. 56 | */ 57 | braid_Int 58 | _braid_GetInterval(braid_Core core, 59 | braid_Int level, 60 | braid_Int interval_index, 61 | braid_Int *flo_ptr, 62 | braid_Int *fhi_ptr, 63 | braid_Int *ci_ptr); 64 | 65 | /** 66 | * Switch for displaying the XBraid actions. Used for debugging only. 67 | */ 68 | braid_Int 69 | _braid_SetVerbosity(braid_Core core, 70 | braid_Int verbose_adj); 71 | 72 | /** 73 | * If set, print to @ref _braid_printfile and then flush. 74 | * Else print to standard out.\n 75 | * 76 | * The string *format* can be multiple parameters 77 | * in the standard * C-format, like\n 78 | * `` format = '%1.2e is a format string', 1.24 `` 79 | **/ 80 | braid_Int 81 | _braid_printf( const char *format, ...); 82 | 83 | /** 84 | * This is a function that allows for "sane" printing 85 | * of information in parallel. Currently, only 86 | * myid = 0 prints, but this can be updated as needs change. 87 | * 88 | * The string *message* is printed and can be multiple parameters 89 | * in the standard * C-format, like\n 90 | * `` message = '%1.2e is a format string', 1.24 `` 91 | **/ 92 | braid_Int 93 | _braid_ParFprintfFlush(FILE * file, 94 | braid_Int myid, 95 | const char * message, 96 | ...); 97 | 98 | /** 99 | * This function finds the maximum value in a braid_Real array 100 | **/ 101 | braid_Int 102 | _braid_Max(braid_Real * array, 103 | braid_Int size, 104 | braid_Real * max_val); 105 | 106 | 107 | /** 108 | * Copy *k* entries from *_array* into *array*. If *k* 109 | * is negative, return the last *k* entries. If 110 | * positive, return the first *k* entries. Upon 111 | * exit, *k* holds the number of residuals actually 112 | * returned (in the case that |k| > array_len.) 113 | * 114 | * If no entries are copied, *k=0*, *array[0] = -1.0* 115 | **/ 116 | braid_Int 117 | _braid_GetNEntries(braid_Real *_array, 118 | braid_Int array_len, 119 | braid_Int *k_ptr, 120 | braid_Real *array); 121 | 122 | /** 123 | * Wrap MPI_Wtime. If core->timings >= timing_level, then 124 | * return MPI_Wtime(), otherwise, return -1. This allows us 125 | * to time Braid more intrusively, as timing_level increases. 126 | **/ 127 | braid_Real 128 | _braid_MPI_Wtime(braid_Core core, braid_Int timing_level); 129 | 130 | 131 | 132 | #endif 133 | -------------------------------------------------------------------------------- /docs/Abstract.md: -------------------------------------------------------------------------------- 1 | 22 | 23 | This package implements an optimal-scaling multigrid solver for the (non)linear 24 | systems that arise from the discretization of problems with evolutionary 25 | behavior. Typically, solution algorithms for evolution equations are based on a 26 | time-marching approach, solving sequentially for one time step after the other. 27 | Parallelism in these traditional time-integration techniques is limited to 28 | spatial parallelism. However, current trends in computer architectures are 29 | leading towards systems with more, but not faster, processors, i.e., clock 30 | speeds are stagnate. Therefore, faster overall runtimes must come from greater 31 | parallelism. One approach to achieve parallelism in time is with multigrid, but 32 | extending classical multigrid methods for elliptic operators to this setting is 33 | a significant achievement. In this software, we implement a non-intrusive, 34 | optimal-scaling time-parallel method based on multigrid reduction techniques. 35 | The examples in the package demonstrate optimality of our 36 | multigrid-reduction-in-time algorithm (MGRIT) for solving a variety of 37 | equations in two and three spatial dimensions. These examples can also be used 38 | to show that MGRIT can achieve significant speedup in comparison to sequential 39 | time marching on modern architectures. 40 | 41 | It is **strongly recommended** that you also read [Parallel Time Integration 42 | with Multigrid](https://github.com/XBraid/xbraid/wiki/papers/mgritPaper-2013-3.pdf) 43 | after reading the @ref braidoverview. It is a more in depth discussion of the algorithm 44 | and associated experiments. 45 | 46 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | #BHEADER********************************************************************** 2 | # 3 | # Copyright (c) 2013, Lawrence Livermore National Security, LLC. 4 | # Produced at the Lawrence Livermore National Laboratory. Written by 5 | # Jacob Schroder, Rob Falgout, Tzanio Kolev, Ulrike Yang, Veselin 6 | # Dobrev, et al. LLNL-CODE-660355. All rights reserved. 7 | # 8 | # This file is part of XBraid. For support, post issues to the XBraid Github page. 9 | # 10 | # This program is free software; you can redistribute it and/or modify it under 11 | # the terms of the GNU General Public License (as published by the Free Software 12 | # Foundation) version 2.1 dated February 1999. 13 | # 14 | # This program is distributed in the hope that it will be useful, but WITHOUT ANY 15 | # WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A 16 | # PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public 17 | # License for more details. 18 | # 19 | # You should have received a copy of the GNU Lesser General Public License along 20 | # with this program; if not, write to the Free Software Foundation, Inc., 59 21 | # Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | # 23 | #EHEADER********************************************************************** 24 | 25 | # Requires doxygen version at least 1.8 26 | DOX=doxygen 27 | DOXVERSION := $(shell expr `doxygen --version | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/'` \>= 10800) 28 | 29 | clean_latex: 30 | # sed command cleans up latex file some 31 | if test -d user_manual; then cd user_manual; sed '/.*8md.*/d' refman.tex > refman.temp.tex; mv refman.temp.tex refman.tex; fi 32 | if test -d developer_manual; then cd developer_manual; sed '/.*8md.*/d' refman.tex > refman.temp.tex; mv refman.temp.tex refman.tex; fi 33 | # sed commands to change XBraid to $\chi$~Braid in Latex files, note use double $$ to keep makefile from expanding the $f 34 | # if test -d user_manual; then cd user_manual; for f in *.tex; do sed 's/X\\-Braid/\\mbox{$$\\chi$$Braid}/g' "$$f" > "$$f.temp"; mv "$$f.temp" "$$f"; done; fi 35 | # if test -d developer_manual; then cd developer_manual; for f in *.tex; do sed 's/X\\-Braid/\\mbox{$$\\chi$$Braid}/g' "$$f" > "$$f.temp"; mv "$$f.temp" "$$f"; done; fi 36 | # sed command changes pdflatex to nonstop mode (important for regression testing) 37 | if test -d user_manual; then cd user_manual; sed 's/pdflatex/pdflatex --interaction=nonstopmode/g' Makefile > Makefile.temp; mv Makefile.temp Makefile; fi 38 | if test -d developer_manual; then cd developer_manual; sed 's/pdflatex/pdflatex --interaction=nonstopmode/g' Makefile > Makefile.temp; mv Makefile.temp Makefile; fi 39 | # sed command changes makeindex to quiet mode (important for regression testing) 40 | if test -d user_manual; then cd user_manual; sed 's/makeindex/makeindex -q/g' Makefile > Makefile.temp; mv Makefile.temp Makefile; fi 41 | if test -d developer_manual; then cd developer_manual; sed 's/makeindex/makeindex -q/g' Makefile > Makefile.temp; mv Makefile.temp Makefile; fi 42 | 43 | user_manual: user_manual.conf 44 | ifeq "$(DOXVERSION)" "1" 45 | $(DOX) user_manual.conf 46 | make clean_latex 47 | cd user_manual; make; cp refman.pdf ../user_manual.pdf 48 | else 49 | @echo "Error: Doxygen version too old" 50 | endif 51 | 52 | developer_manual: developer_manual.conf 53 | ifeq "$(DOXVERSION)" "1" 54 | $(DOX) developer_manual.conf 55 | make clean_latex 56 | cd developer_manual; make; cp refman.pdf ../developer_manual.pdf 57 | else 58 | @echo "Error: Doxygen version too old" 59 | endif 60 | 61 | clean: 62 | rm -rf developer_manual 63 | rm -rf user_manual 64 | rm -f user_manual.pdf 65 | rm -f developer_manual.pdf 66 | 67 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | ## Using Doxygen 2 | 23 | 24 | 25 | To build the documentation, doxygen must be version 1.8 or greater. 26 | XBraid documentation uses a 27 | [markdown](http://www.stack.nl/~dimitri/doxygen/manual/markdown.html) syntax 28 | both in source file comments and in \*.md files. 29 | 30 | To make the documentation, 31 | 32 | $ make user_manual 33 | $ acroread user_manual.pdf 34 | 35 | or to make a more extensive reference manual for developers, 36 | 37 | $ make developer_manual 38 | $ acroread developer_manual.pdf 39 | 40 | Developers can run doxygen from a precompiled binary, 41 | which may or may not work for your machine, 42 | 43 | /usr/casc/hypre/braid/share/doxygen/bin/doxygen 44 | 45 | or build doxygen from 46 | 47 | /usr/casc/hypre/braid/share/doxygen.tgz 48 | 49 | - Compiling doxygen requires a number of dependencies 50 | like Bison, GraphViz and Flex. Configure will tell 51 | you what you're missing 52 | - Unpack doxygen.tgz, then from the doxygen directory 53 | 54 | ./configure --prefix some_dir_in_your_path 55 | make 56 | make install 57 | 58 | ### Documentation Strategy 59 | - The doxygen comments are to be placed in the header files. 60 | - A sample function declaration using the documenation approach 61 | using markdown (including typesetting equations) is in braid.h 62 | for the function braid_Init() 63 | - A sample structure documentation is in _braid.h for _braid_Core_struct 64 | - Descriptors for files can also be added, as at the top of braid.h 65 | - The Doxygen manual is at 66 | http://www.stack.nl/~dimitri/doxygen/manual/index.html 67 | 68 | ### XBraid Doxygen details 69 | 70 | The user and developer manuals are ultimately produced by Latex. The formatting 71 | of the manuals is configured according to the following. 72 | - docs/local_doxygen.sty 73 | + Latex style file used 74 | - docs/user_manual_header.tex 75 | + User manual title page and header info 76 | - docs/developer_manual_header.tex 77 | + Developer manual title page and header info 78 | - *.md 79 | + Any file ending in .md is extra documentation in markdown format, 80 | like Introduction.md or the various Readme.md files in each directory. 81 | This material can be read in plain-text or when it's compiled by Doxygen and Latex. 82 | - docs/user_manual.conf 83 | + Doxygen configure file for the user manual 84 | + The FILE_NAMES tag is a filter to only include the user interface routines in braid.h 85 | + The INPUT tag orders the processing of the files and hence the section ordering 86 | - docs/reference_manual.conf 87 | + Same as user_manual.conf, but the FILE_NAMES tag does not exclude any 88 | file from processing. 89 | - docs/img 90 | + Contains the images 91 | 92 | - To regenerate generic doxygen latex files, type 93 | 94 | $ doxygen -w latex header.tex footer.tex doxygen.sty doxy.conf 95 | 96 | If this is done, then the .conf file must be changed to use the new header file 97 | and to copy the local_doxygen.sty file to the latex directory. 98 | 99 | 100 | -------------------------------------------------------------------------------- /docs/img/3_MG_In_Time_Iterations.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XBraid/xbraid/5ae56b9169689e7bd2521f04941867cfaae690b3/docs/img/3_MG_In_Time_Iterations.pdf -------------------------------------------------------------------------------- /docs/img/3_MG_In_Time_Iterations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XBraid/xbraid/5ae56b9169689e7bd2521f04941867cfaae690b3/docs/img/3_MG_In_Time_Iterations.png -------------------------------------------------------------------------------- /docs/img/3_MG_In_Time_Iterations.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XBraid/xbraid/5ae56b9169689e7bd2521f04941867cfaae690b3/docs/img/3_MG_In_Time_Iterations.pptx -------------------------------------------------------------------------------- /docs/img/3_levels.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XBraid/xbraid/5ae56b9169689e7bd2521f04941867cfaae690b3/docs/img/3_levels.pdf -------------------------------------------------------------------------------- /docs/img/CrelaxationDetail.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XBraid/xbraid/5ae56b9169689e7bd2521f04941867cfaae690b3/docs/img/CrelaxationDetail.pdf -------------------------------------------------------------------------------- /docs/img/FCycle.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XBraid/xbraid/5ae56b9169689e7bd2521f04941867cfaae690b3/docs/img/FCycle.pdf -------------------------------------------------------------------------------- /docs/img/FCycle_Vcycle.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XBraid/xbraid/5ae56b9169689e7bd2521f04941867cfaae690b3/docs/img/FCycle_Vcycle.pptx -------------------------------------------------------------------------------- /docs/img/Frelaxation.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XBraid/xbraid/5ae56b9169689e7bd2521f04941867cfaae690b3/docs/img/Frelaxation.pdf -------------------------------------------------------------------------------- /docs/img/FrelaxationDetail.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XBraid/xbraid/5ae56b9169689e7bd2521f04941867cfaae690b3/docs/img/FrelaxationDetail.pdf -------------------------------------------------------------------------------- /docs/img/FrelaxationDetail2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XBraid/xbraid/5ae56b9169689e7bd2521f04941867cfaae690b3/docs/img/FrelaxationDetail2.pdf -------------------------------------------------------------------------------- /docs/img/VCycle.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XBraid/xbraid/5ae56b9169689e7bd2521f04941867cfaae690b3/docs/img/VCycle.pdf -------------------------------------------------------------------------------- /docs/img/data_layout.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XBraid/xbraid/5ae56b9169689e7bd2521f04941867cfaae690b3/docs/img/data_layout.pdf -------------------------------------------------------------------------------- /docs/img/data_layout.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XBraid/xbraid/5ae56b9169689e7bd2521f04941867cfaae690b3/docs/img/data_layout.pptx -------------------------------------------------------------------------------- /docs/img/heat_results.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XBraid/xbraid/5ae56b9169689e7bd2521f04941867cfaae690b3/docs/img/heat_results.pdf -------------------------------------------------------------------------------- /docs/img/heat_results.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XBraid/xbraid/5ae56b9169689e7bd2521f04941867cfaae690b3/docs/img/heat_results.pptx -------------------------------------------------------------------------------- /docs/img/logo_no_subtext.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XBraid/xbraid/5ae56b9169689e7bd2521f04941867cfaae690b3/docs/img/logo_no_subtext.pdf -------------------------------------------------------------------------------- /docs/img/logo_with_subtext.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XBraid/xbraid/5ae56b9169689e7bd2521f04941867cfaae690b3/docs/img/logo_with_subtext.pdf -------------------------------------------------------------------------------- /docs/img/logo_with_subtext_2_inch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XBraid/xbraid/5ae56b9169689e7bd2521f04941867cfaae690b3/docs/img/logo_with_subtext_2_inch.png -------------------------------------------------------------------------------- /docs/img/overlap.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XBraid/xbraid/5ae56b9169689e7bd2521f04941867cfaae690b3/docs/img/overlap.pdf -------------------------------------------------------------------------------- /docs/img/parallel_timeline.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XBraid/xbraid/5ae56b9169689e7bd2521f04941867cfaae690b3/docs/img/parallel_timeline.pdf -------------------------------------------------------------------------------- /docs/img/sequential0.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XBraid/xbraid/5ae56b9169689e7bd2521f04941867cfaae690b3/docs/img/sequential0.pdf -------------------------------------------------------------------------------- /docs/img/sequential1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XBraid/xbraid/5ae56b9169689e7bd2521f04941867cfaae690b3/docs/img/sequential1.pdf -------------------------------------------------------------------------------- /docs/img/sequential2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XBraid/xbraid/5ae56b9169689e7bd2521f04941867cfaae690b3/docs/img/sequential2.pdf -------------------------------------------------------------------------------- /docs/img/sequential3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XBraid/xbraid/5ae56b9169689e7bd2521f04941867cfaae690b3/docs/img/sequential3.pdf -------------------------------------------------------------------------------- /docs/img/spatial_coarsening.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XBraid/xbraid/5ae56b9169689e7bd2521f04941867cfaae690b3/docs/img/spatial_coarsening.pdf -------------------------------------------------------------------------------- /docs/img/spatial_coarsening.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XBraid/xbraid/5ae56b9169689e7bd2521f04941867cfaae690b3/docs/img/spatial_coarsening.pptx -------------------------------------------------------------------------------- /docs/img/timeline.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XBraid/xbraid/5ae56b9169689e7bd2521f04941867cfaae690b3/docs/img/timeline.pdf -------------------------------------------------------------------------------- /docs/img/title.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XBraid/xbraid/5ae56b9169689e7bd2521f04941867cfaae690b3/docs/img/title.pdf -------------------------------------------------------------------------------- /docs/img/title.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XBraid/xbraid/5ae56b9169689e7bd2521f04941867cfaae690b3/docs/img/title.pptx -------------------------------------------------------------------------------- /drivers/Makefile: -------------------------------------------------------------------------------- 1 | #BHEADER********************************************************************** 2 | # 3 | # Copyright (c) 2013, Lawrence Livermore National Security, LLC. 4 | # Produced at the Lawrence Livermore National Laboratory. Written by 5 | # Jacob Schroder, Rob Falgout, Tzanio Kolev, Ulrike Yang, Veselin 6 | # Dobrev, et al. LLNL-CODE-660355. All rights reserved. 7 | # 8 | # This file is part of XBraid. For support, post issues to the XBraid Github page. 9 | # 10 | # This program is free software; you can redistribute it and/or modify it under 11 | # the terms of the GNU General Public License (as published by the Free Software 12 | # Foundation) version 2.1 dated February 1999. 13 | # 14 | # This program is distributed in the hope that it will be useful, but WITHOUT ANY 15 | # WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A 16 | # PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public 17 | # License for more details. 18 | # 19 | # You should have received a copy of the GNU Lesser General Public License along 20 | # with this program; if not, write to the Free Software Foundation, Inc., 59 21 | # Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | # 23 | #EHEADER********************************************************************** 24 | 25 | ################################################################## 26 | # Import machine specific compilers, options, flags, etc.. 27 | ################################################################## 28 | 29 | BRAID_DIR=../braid 30 | include ../makefile.inc 31 | 32 | 33 | ################################################################## 34 | # Build exmaples 35 | ################################################################## 36 | 37 | HYPRE_DIR = ../../hypre/src/hypre 38 | HYPRE_FLAGS = -I$(HYPRE_DIR)/include 39 | HYPRE_LIB = -L$(HYPRE_DIR)/lib -lHYPRE 40 | SUITE_SPARSE = /usr/include/suitesparse/ 41 | 42 | MFEM_INTERFACE = ./braid_mfem.hpp ./braid_mfem_block.hpp ../braid/braid.hpp 43 | MFEM_DIR = ../../mfem 44 | MFEM_CONFIG_MK = $(MFEM_DIR)/config/config.mk 45 | MFEM_LIB_FILE = mfem_is_not_built 46 | -include $(MFEM_CONFIG_MK) 47 | 48 | BRAID_FLAGS = -I$(BRAID_DIR) -Wno-deprecated-declarations 49 | BRAID_LIB_FILE = $(BRAID_DIR)/libbraid.a 50 | 51 | C_EXAMPLES = drive-burgers-1D drive-diffusion-2D drive-solve-adjoint-with-xbraid 52 | # Note: .cpp examples will be linked with mfem 53 | CXX_EXAMPLES = drive-diffusion-1D-moving-mesh drive-diffusion-1D-moving-mesh-serial \ 54 | drive-diffusion-ben drive-diffusion drive-lin-elasticity \ 55 | drive-pLaplacian drive-adv-diff-DG drive-nonlin-elasticity 56 | 57 | # clean all possible 58 | ALL_EXAMPLES := $(patsubst %.cpp,%,$(wildcard *.c *.cpp)) 59 | ALL_EXAMPLES := $(patsubst %.c,%,$(ALL_EXAMPLES)) 60 | 61 | .PHONY: all clean cleanout 62 | 63 | .SUFFIXES: 64 | .SUFFIXES: .c .cpp 65 | 66 | # put this rule first so it becomes the default 67 | all: $(C_NOHYPRE) $(C_EXAMPLES) $(CXX_EXAMPLES) $(CXX_MFEM_EXAMPLES) 68 | 69 | # Rule for compiling .c files 70 | %: %.c $(BRAID_LIB_FILE) 71 | @echo "Building" $@ "..." 72 | $(MPICC) $(CFLAGS) $(BRAID_FLAGS) $(HYPRE_FLAGS) $< -o $@\ 73 | $(BRAID_LIB_FILE) $(HYPRE_LIB) $(LFLAGS) 74 | 75 | # Rule for compiling .cpp files; links with mfem 76 | %: %.cpp $(BRAID_LIB_FILE) $(MFEM_LIB_FILE) $(MFEM_CONFIG_MK) $(MFEM_INTERFACE) 77 | @echo "Building" $@ "..." 78 | $(MPICXX) $(CXXFLAGS) $(BRAID_FLAGS) $(MFEM_FLAGS) \ 79 | $< -o $@ $(MFEM_LIBS) $(BRAID_LIB_FILE) $(LFLAGS) 80 | 81 | # Generate an error message if the MFEM library is not built and exit 82 | $(MFEM_LIB_FILE): 83 | $(error The MFEM library is not built) 84 | 85 | clean: cleanout 86 | rm -f *.o $(ALL_EXAMPLES) *ror_norm* *_err_* *_sol_* 87 | rm -rf *.dSYM 88 | 89 | cleanout: 90 | rm -f drive*.out.* 91 | -------------------------------------------------------------------------------- /drivers/drive-KS-Delta/Makefile: -------------------------------------------------------------------------------- 1 | #BHEADER********************************************************************** 2 | # 3 | # Copyright (c) 2013, Lawrence Livermore National Security, LLC. 4 | # Produced at the Lawrence Livermore National Laboratory. Written by 5 | # Jacob Schroder, Rob Falgout, Tzanio Kolev, Ulrike Yang, Veselin 6 | # Dobrev, et al. LLNL-CODE-660355. All rights reserved. 7 | # 8 | # This file is part of XBraid. For support, post issues to the XBraid Github page. 9 | # 10 | # This program is free software; you can redistribute it and/or modify it under 11 | # the terms of the GNU General Public License (as published by the Free Software 12 | # Foundation) version 2.1 dated February 1999. 13 | # 14 | # This program is distributed in the hope that it will be useful, but WITHOUT ANY 15 | # WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A 16 | # PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public 17 | # License for more details. 18 | # 19 | # You should have received a copy of the GNU Lesser General Public License along 20 | # with this program; if not, write to the Free Software Foundation, Inc., 59 21 | # Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | # 23 | #EHEADER********************************************************************** 24 | 25 | ################################################################## 26 | # Import machine specific compilers, options, flags, etc.. 27 | ################################################################## 28 | 29 | BRAID_DIR=../../braid 30 | include ../../makefile.inc 31 | 32 | 33 | ################################################################## 34 | # Build 35 | ################################################################## 36 | 37 | SUITE_SPARSE = /usr/include/suitesparse/ 38 | 39 | MFEM_INTERFACE = ./braid_mfem.hpp ./braid_mfem_block.hpp ../braid/braid.hpp 40 | MFEM_DIR = ../../mfem 41 | MFEM_CONFIG_MK = $(MFEM_DIR)/config/config.mk 42 | MFEM_LIB_FILE = mfem_is_not_built 43 | -include $(MFEM_CONFIG_MK) 44 | 45 | BRAID_FLAGS = -I$(BRAID_DIR) -Wno-deprecated-declarations 46 | BRAID_LIB_FILE = $(BRAID_DIR)/libbraid.a 47 | 48 | # clean all possible 49 | ALL_EXAMPLES := $(patsubst %.cpp,%,$(wildcard *.c *.cpp)) 50 | ALL_EXAMPLES := $(patsubst %.c,%,$(ALL_EXAMPLES)) 51 | 52 | .PHONY: all clean cleanout 53 | 54 | .SUFFIXES: 55 | .SUFFIXES: .c .cpp 56 | 57 | drive-ks: drive-ks.cpp $(BRAID_LIB_FILE) 58 | @echo "Building" $@ "..." 59 | $(MPICXX) $(CXXFLAGS) $(BRAID_FLAGS) -Idrive-ks-lib -IEigen -I$(SUITE_SPARSE) \ 60 | $< -o $@ $(BRAID_LIB_FILE) ks_lib.cpp $(LFLAGS) -lumfpack 61 | 62 | clean: cleanout 63 | rm -f *.o $(ALL_EXAMPLES) *ror_norm* *_err_* *_sol_* 64 | rm -rf *.dSYM 65 | 66 | cleanout: 67 | rm -f drive*.out.* 68 | -------------------------------------------------------------------------------- /drivers/drive-KS-Delta/ks_lib.hpp: -------------------------------------------------------------------------------- 1 | #ifndef KS_LIB 2 | #define KS_LIB 3 | 4 | // std lib 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | // linear algebra includes 12 | #include "../Eigen/Dense" 13 | #include "../Eigen/Sparse" 14 | #include "../Eigen/UmfPackSupport" // need to install SuiteSparse 15 | 16 | // want the flexibility of dynamic arrays to change problem size at run-time 17 | using Eigen::ArrayXd; 18 | using Eigen::Index; 19 | typedef Eigen::VectorXd VEC; 20 | typedef Eigen::MatrixXd MAT; 21 | typedef Eigen::SparseMatrix SPMAT; 22 | typedef Eigen::Triplet T; 23 | typedef std::vector Stencil; 24 | 25 | // Lyapunov time 26 | const double T_lyap{log(10) / 0.1}; 27 | 28 | // exported functions 29 | class KSDiscretization 30 | { 31 | public: 32 | SPMAT L; 33 | SPMAT Dx; 34 | int nx; 35 | double len; 36 | double dx; 37 | 38 | // constructor 39 | KSDiscretization() : L(SPMAT()), Dx(SPMAT()), nx(0), len(0.), dx(0.) {} // Never use this. 40 | KSDiscretization(int nx_, double length, Stencil d1, Stencil d2, Stencil d4); 41 | 42 | // implements discretization: 43 | VEC f_ks(const VEC& u) const; 44 | SPMAT f_ks_du(const VEC& u) const; 45 | }; 46 | 47 | // KS helpers 48 | void setup_nxnbmat(SPMAT &out, const std::vector> blocks, const int nx); 49 | SPMAT circulant_from_stencil(std::vector stencil, int n); 50 | SPMAT circulant_from_stencil(ArrayXd stencil, int n); 51 | VEC smoothed_noise(int nx, int width); 52 | VEC FourierMode(int wavenum, const int nx, const double len); 53 | void setFourierMatrix(MAT &A, const int nx, const double len); 54 | void GramSchmidt(MAT& A); 55 | double inf_norm(const VEC &u); 56 | 57 | // time steppers 58 | void getGuessTheta2(VEC &guess, const VEC &u, const VEC &ustop, const KSDiscretization &disc, double dt); 59 | VEC theta2(const VEC &u, VEC &guess, const KSDiscretization& disc, double dt, double th_A = 0., double th_B = 0., double th_C = 0., MAT *P_tan = nullptr, int newton_iters = 10, double tol = 1e-12, double* err_est = nullptr); 60 | VEC theta4(const VEC &u, VEC &guess, const KSDiscretization& disc, double dt, double th_A = 0., double th_B = 0., double th_C = 0., MAT *P_tan = nullptr, int newton_iters = 10, double tol = 1e-12); 61 | 62 | // braid helpers 63 | int intpow(int base, int exp); 64 | void pack_array(std::ofstream &f, const VEC &u); 65 | void pack_darray(std::ofstream &f, const MAT &u); 66 | void bf_pack_help(double *buf, const MAT& u, const size_t obj_size, size_t &bf_size); 67 | void bf_pack_help(double *buf, const VEC& u, const size_t obj_size, size_t &bf_size); 68 | void bf_unpack_help(double *buf, MAT &u, const size_t obj_size, size_t &bf_size); 69 | void bf_unpack_help(double *buf, VEC &u, const size_t obj_size, size_t &bf_size); 70 | 71 | #endif -------------------------------------------------------------------------------- /drivers/drive-KS-Delta/vis_ks.py: -------------------------------------------------------------------------------- 1 | from math import ceil 2 | import numpy as np 3 | import matplotlib.pyplot as plt 4 | from scipy.stats import linregress 5 | 6 | def read_csv(fname): 7 | u = [] 8 | with open(fname, 'r') as f: 9 | for line in f: 10 | u.append(np.array(line.split(','), dtype=np.double)) 11 | return np.stack(u) 12 | 13 | def baseline(u): 14 | v = np.copy(u) 15 | for i in range(len(v)): 16 | v[i] -= np.mean(v[i]) 17 | return v 18 | 19 | def int_v(vec): 20 | out = np.zeros_like(vec) 21 | for i, v in enumerate(vec): 22 | out[i] = out[i-1] + vec[i] 23 | 24 | return out 25 | 26 | def integrate(u): 27 | out = np.zeros_like(u) 28 | for i, vec in enumerate(u): 29 | out[i] = int_v(vec) 30 | 31 | return baseline(out) 32 | 33 | if __name__=="__main__": 34 | u = read_csv("drive-ks.out") 35 | font = {'size' : 16} 36 | plt.rc('font', **font) 37 | 38 | nt, nx = u.shape 39 | cf = ceil(len(u)/nt) 40 | # l = nx 41 | l = 64 42 | T_lyap = np.log(10)/0.1 43 | Tf = 8*T_lyap 44 | 45 | # plot trajectories 46 | ratio = (10, 5) 47 | cmap = "plasma" 48 | # cmap = "cool_r" 49 | stride = max(nt//( nx*ratio[0]//ratio[1] )//cf, 1) 50 | # extent = (0, l, Tf/T_lyap, 0) 51 | extent = (0, Tf/T_lyap, l, 0) 52 | fig, axs = plt.subplots(1, 1, figsize=(ratio[0], ratio[1])) 53 | interp = "bilinear" 54 | # axs.imshow(integrate(u[::cf*stride]), cmap=cmap, extent=extent, aspect="auto", interpolation=interp) 55 | axs.imshow(u[::cf*stride].T, cmap=cmap, extent=extent, aspect="auto", interpolation=interp) 56 | axs.set_xlabel("$T_\lambda$") 57 | axs.set_ylabel("x") 58 | fig.tight_layout() 59 | axs.grid() 60 | plt.savefig("ks_traj.png", dpi=600) 61 | plt.show() 62 | 63 | # error norm + estimate lyapunov exponent 64 | # e_th = np.linalg.norm(u[cf::cf]-v[1:], axis=1) 65 | # # e = np.linalg.norm(u[::cf]-v, axis=1) 66 | # tc = np.linspace(0, Tf, num=len(e_th)) 67 | # res = linregress(tc, np.log(e_th)) 68 | # print(f"lambda_max = {res.slope}") 69 | # print(f"t_lambda = {np.log(10)/res.slope}") 70 | # t_lyap = tc*res.slope 71 | # plt.figure(figsize=(10, 8)) 72 | # plt.semilogy(t_lyap/np.log(10), e_th, label=r"$\theta$ method") 73 | # plt.semilogy(t_lyap/np.log(10), np.exp(t_lyap + res.intercept), linestyle="dashed", label=f"$\lambda = {res.slope}$") 74 | # # plt.semilogy(t, e) 75 | # # plt.semilogy(t, np.exp(res.slope*t + res.intercept), 'r--') 76 | # plt.legend() 77 | # plt.show() -------------------------------------------------------------------------------- /drivers/drive-Lorenz-Delta/Makefile: -------------------------------------------------------------------------------- 1 | #BHEADER********************************************************************** 2 | # 3 | # Copyright (c) 2013, Lawrence Livermore National Security, LLC. 4 | # Produced at the Lawrence Livermore National Laboratory. Written by 5 | # Jacob Schroder, Rob Falgout, Tzanio Kolev, Ulrike Yang, Veselin 6 | # Dobrev, et al. LLNL-CODE-660355. All rights reserved. 7 | # 8 | # This file is part of XBraid. For support, post issues to the XBraid Github page. 9 | # 10 | # This program is free software; you can redistribute it and/or modify it under 11 | # the terms of the GNU General Public License (as published by the Free Software 12 | # Foundation) version 2.1 dated February 1999. 13 | # 14 | # This program is distributed in the hope that it will be useful, but WITHOUT ANY 15 | # WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A 16 | # PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public 17 | # License for more details. 18 | # 19 | # You should have received a copy of the GNU Lesser General Public License along 20 | # with this program; if not, write to the Free Software Foundation, Inc., 59 21 | # Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | # 23 | #EHEADER********************************************************************** 24 | 25 | ################################################################## 26 | # Import machine specific compilers, options, flags, etc.. 27 | ################################################################## 28 | 29 | BRAID_DIR=../../braid 30 | include ../../makefile.inc 31 | 32 | 33 | ################################################################## 34 | # Build 35 | ################################################################## 36 | 37 | SUITE_SPARSE = /usr/include/suitesparse/ 38 | 39 | MFEM_INTERFACE = ./braid_mfem.hpp ./braid_mfem_block.hpp ../braid/braid.hpp 40 | MFEM_DIR = ../../mfem 41 | MFEM_CONFIG_MK = $(MFEM_DIR)/config/config.mk 42 | MFEM_LIB_FILE = mfem_is_not_built 43 | -include $(MFEM_CONFIG_MK) 44 | 45 | BRAID_FLAGS = -I$(BRAID_DIR) -Wno-deprecated-declarations 46 | BRAID_LIB_FILE = $(BRAID_DIR)/libbraid.a 47 | 48 | # clean all possible 49 | ALL_EXAMPLES := $(patsubst %.cpp,%,$(wildcard *.c *.cpp)) 50 | ALL_EXAMPLES := $(patsubst %.c,%,$(ALL_EXAMPLES)) 51 | 52 | .PHONY: all clean cleanout 53 | 54 | .SUFFIXES: 55 | .SUFFIXES: .c .cpp 56 | 57 | drive-lorenz-Delta: drive-lorenz-Delta.cpp $(BRAID_LIB_FILE) 58 | @echo "Building" $@ "..." 59 | $(MPICXX) $(CXXFLAGS) $(BRAID_FLAGS) -Idrive-lorenz-Delta-lib -IEigen \ 60 | $< -o $@ $(BRAID_LIB_FILE) lorenz_lib.cpp $(LFLAGS) 61 | 62 | drive-lorenz-LRDelta: drive-lorenz-LRDelta.cpp $(BRAID_LIB_FILE) 63 | @echo "Building" $@ "..." 64 | $(MPICXX) $(CXXFLAGS) $(BRAID_FLAGS) -Idrive-lorenz-Delta-lib -IEigen \ 65 | $< -o $@ $(BRAID_LIB_FILE) lorenz_lib.cpp $(LFLAGS) 66 | 67 | clean: cleanout 68 | rm -f *.o $(ALL_EXAMPLES) *ror_norm* *_err_* *_sol_* 69 | rm -rf *.dSYM 70 | 71 | cleanout: 72 | rm -f drive*.out.* 73 | -------------------------------------------------------------------------------- /drivers/drive-Lorenz-Delta/lorenz_lib.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LORENZ_LIB 2 | #define LORENZ_LIB 3 | #include 4 | #include 5 | #include 6 | #include "../Eigen/Dense" // expects Eigen library in xbraid/drivers/ 7 | 8 | #define DIM 3 9 | typedef Eigen::Vector3d VEC; 10 | typedef Eigen::Matrix3d MAT; 11 | typedef Eigen::Matrix3Xd COL_MAT; // this is a 3xN matrix with 3d columns 12 | using Eigen::Matrix3d; 13 | 14 | // standard chaotic choices for Lorenz parameters 15 | const double rho{28.}; 16 | const double sigma{10.}; 17 | const double beta{8. / 3.}; 18 | 19 | // Lyapunov time 20 | const double T_lyap{log(10) / 0.9}; 21 | 22 | // functions 23 | VEC f_lorenz(const VEC &u); 24 | MAT f_lorenz_du(const VEC &u); 25 | 26 | // first order 27 | VEC euler(VEC u, double dt); 28 | MAT euler_du(VEC u, double dt); 29 | VEC theta1(const VEC u, const VEC guess, double dt, double theta = 0.5, MAT *P_tan = nullptr, int newton_iters = 10, double tol = 1e-10); 30 | 31 | // second order 32 | VEC crank_nicolson(VEC u, VEC ustop, double dt, MAT *P_tan = nullptr, int newton_iters = 10, double tol = 1e-10); 33 | VEC theta2(VEC u, VEC ustop, double dt, double th_A = 0., double th_B = 0., double th_C = 0., MAT *P_tan = nullptr, int newton_iters = 10, double tol = 1e-10); 34 | 35 | // fourth order 36 | VEC rk4(VEC u, double dt, MAT *P_tan = nullptr); 37 | VEC theta4(VEC u, VEC &uguess, double dt, double theta = .2, MAT *P_tan = nullptr, int newton_iters = 10, double tol = 1e-10); 38 | VEC thetaLobatto3(VEC u, VEC ustop, double dt, double th_A, double th_B, double th_C, MAT *P_tan = nullptr, int newton_iters = 10, double tol = 1e-10, bool linesearch=true); 39 | 40 | void GramSchmidt(COL_MAT &A); 41 | void pack_array(std::ofstream &f, VEC u); 42 | void pack_darray(std::ofstream &f, COL_MAT u); 43 | int intpow(int base, int exp); 44 | 45 | // braid helpers 46 | void bf_pack_help(double *buf, const COL_MAT u, const size_t obj_size, size_t &bf_size); 47 | void bf_pack_help(double *buf, const VEC u, const size_t obj_size, size_t &bf_size); 48 | void bf_pack_help(double *buf, const MAT u, const size_t obj_size, size_t &bf_size); 49 | void bf_unpack_help(double *buf, COL_MAT &u, const size_t obj_size, size_t &bf_size); 50 | void bf_unpack_help(double *buf, VEC &u, const size_t obj_size, size_t &bf_size); 51 | void bf_unpack_help(double *buf, MAT &u, const size_t obj_size, size_t &bf_size); 52 | 53 | #endif -------------------------------------------------------------------------------- /drivers/drive-Lorenz-Delta/vis_lorenz_LRDelta.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | 4 | try: 5 | plt.style.use('https://github.com/dhaitz/matplotlib-stylesheets/raw/master/pacoty.mplstyle') 6 | except: 7 | pass 8 | 9 | def read_csv(fname): 10 | u = [] 11 | with open(fname, 'r') as f: 12 | for line in f: 13 | u.append(np.array(line.split(','), dtype=np.double)) 14 | return np.stack(u) 15 | 16 | if __name__=="__main__": 17 | u = read_csv("lorenz-LRDelta.out") 18 | tan = read_csv("lorenz-LRDelta-lv.out") 19 | 20 | # reshape the tangent vectors 21 | dim = tan.shape[-1] // 3 22 | tan = tan.reshape((tan.shape[0], dim, 3)) 23 | 24 | ax = plt.axes(projection='3d') 25 | ax.plot3D(*u.T) 26 | for d in range(dim): 27 | ax.quiver(*u.T, *tan[:, d, :].T, color=f"C{1+d}", length=2.) 28 | plt.show() -------------------------------------------------------------------------------- /drivers/drive-adv-diff-1D-Cython/README.md: -------------------------------------------------------------------------------- 1 | 22 | 23 | 24 | This is an example using the Braid-Cython interface defined in braid.pyx ( 25 | braid/braid.pyx ). 26 | 27 | It solves the 1D advection-diffusion equation 28 | 29 | u_t = a*u_x + eps*u_xx, 30 | 31 | For instructions on running and compiling, see 32 | 33 | drivers/drive-adv-diff-1D-Cython/drive-adv-diff-1D-setup.py 34 | 35 | and 36 | 37 | drivers/drive-adv-diff-1D-Cython/drive-adv-diff-1D.pyx 38 | 39 | -------------------------------------------------------------------------------- /drivers/drive-adv-diff-1D-Cython/drive_adv_diff_1D-setup.py: -------------------------------------------------------------------------------- 1 | from distutils.core import setup 2 | from distutils.extension import Extension 3 | from Cython.Build import cythonize 4 | import os 5 | import sys 6 | # import numpy 7 | 8 | braid_dir = "../../braid" 9 | 10 | ## 11 | # This setup.py file has been tested on High Sierra with Homebrew, and Ubuntu LTS. 12 | # This example requires Python 3 and the installation of Cython. 13 | # 14 | # To Install, 15 | # 16 | # 1) Make sure that braid_dir (defined above) points to the location of "braid" 17 | # This is used by library_dirs and include_dirs below 18 | # 19 | # 2) Type (using whatever install location you want) 20 | # 21 | # $ python3 drive_adv_diff_1D-setup.py install --prefix=$HOME/.local 22 | # 23 | # Note that you may have to tweak the compilers and flags. 24 | # Some comments on this are below. 25 | # 26 | # To Run, 27 | # 28 | # 1) Make sure that the install directory and the location of MPI4PY 29 | # is in your PYTHONPATH, e.g., 30 | # 31 | # export PYTHONPATH="$HOME/.local/lib/python3.6" 32 | # or perhaps, 33 | # export PYTHONPATH="$HOME/.local/lib/python3.7/site-packages" 34 | # 35 | # 2) Type 36 | # python3 37 | # >>> import drive_adv_diff_1D 38 | # >>> core, app = drive_adv_diff_1D.InitCoreApp() 39 | # >>> drive_adv_diff_1D.run_Braid(core, app) 40 | # 41 | # Output: 42 | # 43 | # Braid: Begin simulation, 60 time steps 44 | # Braid: || r_0 || = 2.449744e+01, conv factor = 1.00e+00, wall time = 3.41e-02 45 | # Braid: || r_1 || = 1.202467e-02, conv factor = 4.91e-04, wall time = 5.34e-02 46 | # Braid: || r_2 || = 4.237590e-04, conv factor = 3.52e-02, wall time = 7.28e-02 47 | # Braid: || r_3 || = 1.693387e-05, conv factor = 4.00e-02, wall time = 9.18e-02 48 | # ... 49 | # ... 50 | # 51 | # 3) For runs where you control various solver and problem parameters and can use 52 | # multiple processors in time, try 53 | # 54 | # $$ mpirun -np K python3 drive_adv_diff_1D_run.py 55 | # 56 | # where you control parameters by editing drive_adv_diff_1D_run.py 57 | ## 58 | 59 | ## 60 | # Other notes: 61 | # 1) Some systems may need to find Numpy headers, which are located in 62 | # include_dirs=["../braid", numpy.get_include()], 63 | # 2) Some compilers may require "-fPIC" to be added to extra_compile_args 64 | # 65 | ## 66 | 67 | 68 | os.environ["CC"] = "mpicc" 69 | if sys.platform != 'darwin': 70 | os.environ["LDSHARED"] = "mpicc -shared" # Needed by Ubuntu LTS, leave out for Mac 71 | 72 | drive_adv_diff_1D_extension = Extension( 73 | name="drive_adv_diff_1D", 74 | sources=["drive_adv_diff_1D.pyx"], 75 | libraries=["braid"], 76 | library_dirs=[braid_dir], 77 | include_dirs=[braid_dir], 78 | extra_compile_args=["-Wno-incompatible-pointer-types", "-Wno-unused-function" ] 79 | ) 80 | setup( 81 | name="drive_adv_diff_1D", 82 | ext_modules=cythonize([drive_adv_diff_1D_extension], language_level = "3") 83 | ) 84 | 85 | -------------------------------------------------------------------------------- /drivers/drive-adv-diff-1D-Cython/drive_adv_diff_1D_run.py: -------------------------------------------------------------------------------- 1 | # Script for MPI runs of Cython code 2 | # 3 | # $ mpirun -np K python3 drive_adv_diff_1D_run.py 4 | # 5 | 6 | import drive_adv_diff_1D 7 | 8 | # Can choose to print help message 9 | print_help = False 10 | 11 | core, app = drive_adv_diff_1D.InitCoreApp(print_help=print_help, ml=2, nu=1, nu0=1, 12 | CWt=1.0, skip=0, nx=16, ntime=60, eps=1.0, 13 | a=1.0, tol=1e-6, cf=2, mi=30, sc=0, fmg=0, 14 | advect_discr='upwind', diff_discr='second_order', 15 | time_discr='BE') 16 | 17 | if print_help == False: 18 | drive_adv_diff_1D.run_Braid(core, app) 19 | 20 | # Uncomment to run simple visualization script 21 | #from viz_drive_adv_diff_1D import viz_drive_adv_diff_1D 22 | #viz_drive_adv_diff_1D() 23 | 24 | 25 | -------------------------------------------------------------------------------- /drivers/drive-adv-diff-1D-Cython/drive_adv_diff_1D_scriptrun.py: -------------------------------------------------------------------------------- 1 | # Script for MPI runs, 2 | # 3 | # $ mpirun -np K python3 drive_adv_diff_1D_scriptrun.py 4 | # 5 | 6 | import drive_adv_diff_1D 7 | from viz_drive_adv_diff_1D import viz_drive_adv_diff_1D 8 | 9 | # Can choose to print help message 10 | print_help = False 11 | 12 | 13 | time_discr = ['BE', 'SDIRK3'] 14 | advect_discr = ['upwind', 'central', 'fourth', 'fourth_diss', 'fourth_diss_sq'] 15 | eps = [0, 1.0] 16 | a = [0, 1.0] 17 | 18 | for td in time_discr: 19 | for ad in advect_discr: 20 | for ee in eps: 21 | for aa in a: 22 | print("\n\n Time, space, eps, a: " + td + " " + ad + " " + str(ee) + " " + str(aa) ) 23 | core, app = drive_adv_diff_1D.InitCoreApp(print_help=print_help, ml=15, nu=1, nu0=1, 24 | CWt=1.0, skip=0, nx=128, ntime=256, eps=ee, 25 | a=aa, tol=1e-6, cf=2, mi=30, sc=0, fmg=0, 26 | advect_discr=ad, time_discr=td) 27 | 28 | if print_help == False: 29 | drive_adv_diff_1D.run_Braid(core, app) 30 | 31 | viz_drive_adv_diff_1D() 32 | 33 | 34 | -------------------------------------------------------------------------------- /drivers/drive-adv-diff-1D-Cython/invert_sparse_mat_splu.py: -------------------------------------------------------------------------------- 1 | import scipy, numpy 2 | from scipy import linalg 3 | from scipy.sparse.linalg.interface import LinearOperator 4 | 5 | __all__ = ['invert_sparse_mat_splu'] 6 | 7 | 8 | def invert_sparse_mat_splu(A, **kwargs): 9 | ''' 10 | given a sparse matrix A, return a LinearOperator whose 11 | application is A-inverse by way of splu 12 | ''' 13 | 14 | Acsc = A.tocsc() 15 | Acsc.eliminate_zeros() 16 | nonzero_cols = ( (Acsc.indptr[:-1] - Acsc.indptr[1:]) != 0).nonzero()[0] 17 | Map = scipy.sparse.eye(Acsc.shape[0], Acsc.shape[1], format='csc') 18 | Map = Map[:,nonzero_cols] 19 | Acsc = Map.T.tocsc()*Acsc*Map 20 | LU = scipy.sparse.linalg.splu(Acsc) 21 | LU_Map = Map 22 | 23 | def matvec(b): 24 | return LU_Map*LU.solve( numpy.ravel(LU_Map.T*b) ) 25 | 26 | Ainv = LinearOperator(A.shape, matvec=matvec, dtype=A.dtype) 27 | 28 | return Ainv 29 | 30 | 31 | -------------------------------------------------------------------------------- /drivers/drive-adv-diff-1D-Cython/viz_drive_adv_diff_1D.py: -------------------------------------------------------------------------------- 1 | from scipy import * 2 | from matplotlib import pyplot as mpl 3 | from os import sys 4 | 5 | ## 6 | # Run like 7 | # $ python viz.py 8 | # 9 | # Vizualize the files from drive_adv_diff_1D. The output is assumed to have 10 | # the following format. The filenames are 11 | # file_stem + '.' step_number + '.' + rank 12 | # So, the filename 13 | # drive_adv_diff_1D.out.0000350.00000 14 | # is the output from step 350 from processor rank 0. Right now, 15 | # there is no parallelism, so it's always rank 0. 16 | # 17 | # Each output file has the format 18 | # 19 | # ntime_steps 20 | # tstart 21 | # tstop 22 | # nspace_points 23 | # xstart 24 | # xstop 25 | # x[0] 26 | # x[1] 27 | # . 28 | # . 29 | # . 30 | # x[k] 31 | ## 32 | 33 | def viz_drive_adv_diff_1D(): 34 | 35 | # Set the braid iteration number and number of steps 36 | file_stem = 'drive_adv_diff_1D.out.' 37 | current_rank = 0 38 | 39 | # Load the initial solution file and extract the problem size in space and time and the grid spacings 40 | step = 0 41 | fname = file_stem + "%05d"%step + '.' + "%04d"%current_rank 42 | data = loadtxt(fname) 43 | nsteps = int(data[0]) 44 | tstart = float(data[1]) 45 | tstop = float(data[2]) 46 | nspace = int(data[3]) 47 | xstart = float(data[4]) 48 | xstop = float(data[5]) 49 | mesh = linspace(xstart, xstop, nspace) 50 | data = zeros((nsteps,data.shape[0]-6)) 51 | 52 | # Load space-time solution, noting that we don't know the MPI ranks ahead of 53 | # time that generated the files, so we guess :-) 54 | for step in range(nsteps): 55 | try: 56 | fname = file_stem + "%05d"%step + '.' + "%04d"%current_rank 57 | data[step,:] = (loadtxt(fname))[6:] 58 | except: 59 | current_rank = current_rank + 1 60 | fname = file_stem + "%05d"%step + '.' + "%04d"%current_rank 61 | data[step,:] = (loadtxt(fname))[6:] 62 | 63 | mpl.figure(0) 64 | mpl.imshow(data,origin='lower',extent=(xstart, xstop, tstart, tstop)) 65 | mpl.colorbar() 66 | mpl.ylabel('time') 67 | mpl.xlabel('space') 68 | mpl.title("Space-time Solution") 69 | 70 | mpl.figure(1) 71 | mpl.plot(mesh, data[0,:], '-o') 72 | mpl.ylabel('u') 73 | mpl.xlabel('space') 74 | mpl.title('Solution at Step 0') 75 | mpl.xlim(xstart, xstop) 76 | 77 | mpl.figure(2) 78 | mpl.plot(mesh, data[nsteps//2,:], '-o') 79 | mpl.ylabel('u') 80 | mpl.xlabel('space') 81 | mpl.title('Solution at Step %d'%(nsteps//2)) 82 | mpl.xlim(xstart, xstop) 83 | 84 | mpl.figure(3) 85 | mpl.plot(mesh, data[nsteps-1,:], '-o') 86 | mpl.ylabel('u') 87 | mpl.xlabel('space') 88 | mpl.title('Solution at Step %d'%(nsteps-1)) 89 | mpl.xlim(xstart, xstop) 90 | 91 | mpl.show() 92 | 93 | if __name__ == '__main__': 94 | # run viz function 95 | viz_drive_adv_diff_1D() 96 | 97 | -------------------------------------------------------------------------------- /drivers/mfem_arnoldi.hpp: -------------------------------------------------------------------------------- 1 | #ifndef mfem_arnoldi_HEADER 2 | #define mfem_arnoldi_HEADER 3 | 4 | #include "mfem.hpp" 5 | 6 | using namespace mfem; 7 | 8 | class DenseMatrixTimeDependentOperator : public TimeDependentOperator 9 | { 10 | public: 11 | DenseMatrixTimeDependentOperator(DenseMatrix & A_) : TimeDependentOperator(A_.Width()), A(A_) {} 12 | 13 | virtual void Mult(const Vector &x, Vector &y) const 14 | { 15 | A.Mult(x,y); 16 | } 17 | 18 | private: 19 | DenseMatrix & A; 20 | }; 21 | 22 | class Arnoldi 23 | { 24 | public: 25 | Arnoldi(int k_max_, MPI_Comm comm_) 26 | : H(k_max_,k_max_), Hop(H), comm(comm_), k_max(k_max_) 27 | { 28 | V = new Vector[k_max_]; 29 | A = NULL; 30 | } 31 | 32 | ~Arnoldi() 33 | { 34 | delete[] V; 35 | } 36 | 37 | void SetOperator(Operator &A_) 38 | { 39 | A = &A_; 40 | int n = A->Width(); 41 | 42 | for(int i = 0; i < k_max; i++) 43 | { 44 | V[i].SetSize(n); 45 | } 46 | } 47 | 48 | void ApplyV(const Vector & ubar, Vector & u) 49 | { 50 | u = 0.0; 51 | int k = H.Width(); 52 | 53 | for(int i = 0; i < k; i++) 54 | { 55 | u.Add(ubar(i), V[i]); 56 | } 57 | 58 | } 59 | 60 | void ApplyVT(const Vector & u, Vector & ubar) 61 | { 62 | int k = H.Width(); 63 | 64 | ubar.SetSize(k); 65 | for(int i = 0; i < k; i++) 66 | { 67 | ubar(i) = Dot(V[i], u); 68 | } 69 | } 70 | 71 | TimeDependentOperator & GetH( ) 72 | { 73 | return Hop; 74 | } 75 | 76 | void GenKrylovSpace(const Vector & u) 77 | { 78 | int k; 79 | double max_norm = 0.0; 80 | double tol = 1e-12; 81 | double norm_u = sqrt(Dot(u,u)); 82 | DenseMatrix F(k_max, k_max); 83 | 84 | if(norm_u > 0.0) 85 | { 86 | V[0].Set( 1.0/norm_u, u ); 87 | } 88 | else 89 | { 90 | MFEM_ABORT("Does Not Support All Zero Seed Vector\n"); 91 | } 92 | 93 | for(k = 0; k < k_max-1; k++) 94 | { 95 | A->Mult(V[k], V[k+1]); 96 | 97 | for(int m = 0; m <=k; m++) 98 | { 99 | F(m,k) = Dot(V[m], V[k+1]); 100 | V[k+1].Add( -F(m,k), V[m] ); 101 | } 102 | 103 | F(k+1,k) = sqrt( Dot(V[k+1], V[k+1]) ); 104 | 105 | max_norm = std::max(F(k+1,k), max_norm); 106 | if (F(k+1,k) <= tol*max_norm) 107 | { 108 | break; 109 | } 110 | 111 | V[k+1] /= F(k+1,k); 112 | } 113 | 114 | H.SetSize(k+1, k+1); 115 | H.CopyMN(F, k+1, k+1, 0, 0); 116 | } 117 | 118 | protected: 119 | Vector *V; 120 | DenseMatrix H; 121 | DenseMatrixTimeDependentOperator Hop; 122 | Operator *A; 123 | MPI_Comm comm; 124 | int k_max; 125 | 126 | double Dot(const Vector &x, const Vector &y) const 127 | { 128 | double local_dot = (x * y); 129 | double global_dot; 130 | 131 | MPI_Allreduce(&local_dot, &global_dot, 1, MPI_DOUBLE, MPI_SUM, comm); 132 | 133 | return global_dot; 134 | } 135 | 136 | 137 | }; 138 | 139 | #endif // mfem_arnoldi_HEADER 140 | 141 | -------------------------------------------------------------------------------- /drivers/viz-burgers-1D.py: -------------------------------------------------------------------------------- 1 | from scipy import * 2 | from matplotlib import pyplot as mpl 3 | from os import sys 4 | 5 | ## 6 | # Run like 7 | # $ python viz.py 8 | # 9 | # Vizualize the files from drive-burgers-1D.c. The output is assumed to have 10 | # the following format. The filenames are 11 | # file_stem + '.' step_number + '.' + rank 12 | # So, the filename 13 | # drive-burgers-1D.out.0000350.00000 14 | # is the output from step 350 from processor rank 0. Right now, 15 | # there is no parallelism, so it's always rank 0. 16 | # 17 | # Each output file has the format 18 | # 19 | # ntime_steps 20 | # tstart 21 | # tstop 22 | # nspace_points 23 | # xstart 24 | # xstop 25 | # x[0] 26 | # x[1] 27 | # . 28 | # . 29 | # . 30 | # x[k] 31 | ## 32 | 33 | # Set the braid iteration number and number of steps 34 | rank = 0 #int(sys.argv[1]) 35 | file_stem = 'drive-burgers-1D.out.' 36 | 37 | # Find out size of problem in space and time, and the 38 | # grid spacings 39 | step = 0 40 | fname = file_stem + "%07d"%step + '.' + "%05d"%rank 41 | data = loadtxt(fname) 42 | nsteps = int(data[0]) 43 | tstart = float(data[1]) 44 | tstop = float(data[2]) 45 | nspace = int(data[3]) 46 | xstart = float(data[4]) 47 | xstop = float(data[5]) 48 | mesh = linspace(xstart, xstop, nspace) 49 | data = zeros((nsteps,data.shape[0]-6)) 50 | 51 | # Load space-time solution 52 | for step in range(nsteps): 53 | fname = file_stem + "%07d"%step + '.' + "%05d"%rank 54 | data[step,:] = (loadtxt(fname))[6:] 55 | 56 | mpl.figure(0) 57 | mpl.imshow(data,origin='lower',extent=(xstart, xstop, tstart, tstop)) 58 | mpl.colorbar() 59 | mpl.ylabel('time') 60 | mpl.xlabel('space') 61 | 62 | mpl.figure(1) 63 | mpl.plot(mesh, data[0,:], '-o') 64 | mpl.ylabel('u') 65 | mpl.xlabel('space') 66 | mpl.title('Step 0') 67 | mpl.ylim(data[0,:].min()-1.0, data[0,:].max()+1.0) 68 | 69 | mpl.figure(2) 70 | mpl.plot(mesh, data[nsteps/2,:], '-o') 71 | mpl.ylabel('u') 72 | mpl.xlabel('space') 73 | mpl.title('Step %d'%(nsteps/2)) 74 | mpl.ylim(data[nsteps/2,:].min()-1.0, data[nsteps/2,:].max()+1.0) 75 | 76 | mpl.figure(3) 77 | mpl.plot(mesh, data[nsteps-1,:], '-o') 78 | mpl.ylabel('u') 79 | mpl.xlabel('space') 80 | mpl.title('Step %d'%(nsteps-1)) 81 | mpl.ylim(data[nsteps-1,:].min()-1.0, data[nsteps-1,:].max()+1.0) 82 | 83 | 84 | mpl.show() 85 | 86 | -------------------------------------------------------------------------------- /examples/ex-01-cython-alt/README.md: -------------------------------------------------------------------------------- 1 | 22 | 23 | 24 | This is an example using the Braid-Cython interface defined in braid.pyx ( 25 | braid/braid.pyx ). This example uses a lower-level C-style syntax than the 26 | other basic Cython example in `examples/ex-01-cython` 27 | 28 | It solves the same scalar ODE equation 29 | 30 | u' = lambda u, 31 | with lambda=-1 and y(0) = 1 32 | 33 | as the ex-01 series in the `examples` directory. 34 | 35 | For instructions on running and compiling, see 36 | 37 | examples/ex-01-cython-alt/ex_01_alt-setup.py 38 | 39 | and 40 | 41 | examples/ex-01-cython-alt/ex_01_alt.pyx 42 | 43 | -------------------------------------------------------------------------------- /examples/ex-01-cython-alt/ex_01_alt-setup.py: -------------------------------------------------------------------------------- 1 | from distutils.core import setup 2 | from distutils.extension import Extension 3 | from Cython.Build import cythonize 4 | import os 5 | import sys 6 | # import numpy 7 | 8 | braid_dir = "../../braid" 9 | 10 | ## 11 | # This setup.py file has been tested on High Sierra with Homebrew, and Ubuntu LTS. 12 | # This example requires Python 3 and the installation of Cython. 13 | # 14 | # To Install, 15 | # 16 | # 1) Make sure that braid_dir (defined above) points to the location of "braid" 17 | # This is used by library_dirs and include_dirs below 18 | # 19 | # 2) Type (using whatever install location you want) 20 | # 21 | # $ python3 ex_01_alt-setup.py install --prefix=$HOME/.local 22 | # 23 | # Note that you may have to tweak the compilers and flags. 24 | # Some comments on this are below. 25 | # 26 | # To Run, 27 | # 28 | # 1) Make sure that the install directory and the location of MPI4PY 29 | # is in your PYTHONPATH, e.g., 30 | # 31 | # export PYTHONPATH="$HOME/.local/lib/python3.6" 32 | # or perhaps, 33 | # export PYTHONPATH="$HOME/.local/lib/python3.7/site-packages" 34 | # 35 | # 2) Type 36 | # python3 37 | # >>> import ex_01_alt 38 | # >>> core, app = ex_01_alt.InitCoreApp() 39 | # >>> ex_01_alt.run_Braid(core, app) 40 | # 41 | # Print output with 42 | # >>> import os; os.system("cat ex-01-alt.out.00*") 43 | # 1.00000000000000e+00 44 | # 6.66666666666667e-01 45 | # 4.44444444444444e-01 46 | # 2.96296296296296e-01 47 | # 1.97530864197531e-01 48 | # 1.31687242798354e-01 49 | # 8.77914951989026e-02 50 | # 5.85276634659351e-02 51 | # 3.90184423106234e-02 52 | # 2.60122948737489e-02 53 | # 1.73415299158326e-02 54 | # 0 55 | # 56 | # 3) For parallel runs, try 57 | # 58 | # $$ mpirun -np K python3 ex_01_alt_run.py 59 | ## 60 | 61 | ## 62 | # Other notes: 63 | # 1) Some systems may need to find Numpy headers, which are located in 64 | # include_dirs=["../braid", numpy.get_include()], 65 | # 2) Some compilers may require "-fPIC" to be added to extra_compile_args 66 | # 67 | ## 68 | 69 | os.environ["CC"] = "mpicc" 70 | if sys.platform != 'darwin': 71 | os.environ["LDSHARED"] = "mpicc -shared" # Needed by Ubuntu LTS, leave out for Mac 72 | 73 | ex_01_alt_extension = Extension( 74 | name="ex_01_alt", 75 | sources=["ex_01_alt.pyx"], 76 | libraries=["braid"], 77 | library_dirs=[braid_dir], 78 | include_dirs=[braid_dir], 79 | extra_compile_args=["-Wno-incompatible-pointer-types", "-Wno-unused-function"] 80 | ) 81 | setup( 82 | name="ex_01_alt", 83 | ext_modules=cythonize([ex_01_alt_extension], language_level = "3") 84 | ) 85 | 86 | -------------------------------------------------------------------------------- /examples/ex-01-cython-alt/ex_01_alt_run.py: -------------------------------------------------------------------------------- 1 | # Script for MPI runs, 2 | # 3 | # $ mpirun -np K python3 ex_01_alt_run.py 4 | # 5 | 6 | 7 | import ex_01_alt 8 | core, app = ex_01_alt.InitCoreApp() 9 | ex_01_alt.run_Braid(core, app) 10 | 11 | -------------------------------------------------------------------------------- /examples/ex-01-cython/README.md: -------------------------------------------------------------------------------- 1 | 22 | 23 | 24 | This is an example using the Braid-Cython interface defined in braid.pyx ( 25 | braid/braid.pyx ). This example uses a higher-level more Python-style syntax 26 | than the other basic Cython example in `examples/ex-01-cython-alt` 27 | 28 | 29 | It solves the same scalar ODE equation 30 | 31 | u' = lambda u, 32 | with lambda=-1 and y(0) = 1 33 | 34 | as the ex-01 series in the `examples` directory. 35 | 36 | For instructions on running and compiling, see 37 | 38 | examples/ex-01-cython/ex_01-setup.py 39 | 40 | and 41 | 42 | examples/ex-01-cython/ex_01.pyx 43 | 44 | -------------------------------------------------------------------------------- /examples/ex-01-cython/ex_01-setup.py: -------------------------------------------------------------------------------- 1 | from distutils.core import setup 2 | from distutils.extension import Extension 3 | from Cython.Build import cythonize 4 | import os 5 | import sys 6 | # import numpy 7 | 8 | braid_dir = "../../braid" 9 | 10 | ## 11 | # This setup.py file has been tested on High Sierra with Homebrew, and Ubuntu LTS. 12 | # This example requires Python 3 and the installation of Cython. 13 | # 14 | # To Install, 15 | # 16 | # 1) Make sure that braid_dir (defined above) points to the location of "braid" 17 | # This is used by library_dirs and include_dirs below 18 | # 19 | # 2) Type (using whatever install location you want) 20 | # 21 | # $ python3 ex_01-setup.py install --prefix=$HOME/.local 22 | # 23 | # Note that you may have to tweak the compilers and flags. 24 | # Some comments on this are below. 25 | # 26 | # To Run, 27 | # 28 | # 1) Make sure that the install directory and the location of MPI4PY 29 | # is in your PYTHONPATH, e.g., 30 | # 31 | # export PYTHONPATH="$HOME/.local/lib/python3.6" 32 | # or perhaps, 33 | # export PYTHONPATH="$HOME/.local/lib/python3.7/site-packages" 34 | # 35 | # 2) Type 36 | # python3 37 | # >>> import ex_01 38 | # >>> core, app = ex_01.InitCoreApp() 39 | # >>> ex_01.run_Braid(core, app) 40 | # 41 | # Print output with 42 | # >>> import os; os.system("cat ex-01.out.00*") 43 | # 1.00000000000000e+00 44 | # 6.66666666666667e-01 45 | # 4.44444444444444e-01 46 | # 2.96296296296296e-01 47 | # 1.97530864197531e-01 48 | # 1.31687242798354e-01 49 | # 8.77914951989026e-02 50 | # 5.85276634659351e-02 51 | # 3.90184423106234e-02 52 | # 2.60122948737489e-02 53 | # 1.73415299158326e-02 54 | # 0 55 | # 56 | ## 3) For parallel runs, try 57 | # 58 | # $$ mpirun -np K python3 ex_01_run.py 59 | ## 60 | 61 | ## 62 | # Other notes: 63 | # 1) Some systems may need to find Numpy headers, which are located in 64 | # include_dirs=["../braid", numpy.get_include()], 65 | # 2) Some compilers may require "-fPIC" to be added to extra_compile_args 66 | # 67 | ## 68 | 69 | 70 | os.environ["CC"] = "mpicc" 71 | if sys.platform != 'darwin': 72 | os.environ["LDSHARED"] = "mpicc -shared" # Needed by Ubuntu LTS, leave out for Mac 73 | 74 | # You may need to add local paths here, if you have local installations of compilers and python 75 | #os.environ["PATH"] = '/home/jbschroder/.local/bin:' + os.environ["PATH"] 76 | #os.environ["PYTHONPATH"] = "/home/jbschroder/.local/lib/python3.6" 77 | 78 | ex_01_extension = Extension( 79 | name="ex_01", 80 | sources=["ex_01.pyx"], 81 | libraries=["braid"], 82 | library_dirs=[braid_dir], #Can append local dirs: , "/home/jbschroder/.local/lib", "/home/jbschroder/.local/lib/openmpi"], 83 | include_dirs=[braid_dir], #Can append local dirs: , "/home/jbschroder/.local/include", "/home/jbschroder/.local/include/openmpi/mpiext"], 84 | extra_compile_args=["-Wno-incompatible-pointer-types", "-Wno-unused-function"] 85 | ) 86 | setup( 87 | name="ex_01", 88 | ext_modules=cythonize([ex_01_extension], language_level = "3") 89 | ) 90 | 91 | -------------------------------------------------------------------------------- /examples/ex-01-cython/ex_01_run.py: -------------------------------------------------------------------------------- 1 | # Script for MPI runs, 2 | # 3 | # $ mpirun -np K python3 ex_01_run.py 4 | # 5 | 6 | import ex_01 7 | core, app = ex_01.InitCoreApp() 8 | ex_01.run_Braid(core, app) 9 | 10 | -------------------------------------------------------------------------------- /examples/ex-05-cython/README.md: -------------------------------------------------------------------------------- 1 | 22 | 23 | 24 | This is an example using the Braid-Cython interface defined in braid.pyx ( 25 | braid/braid.pyx ). 26 | 27 | It solves the 1D heat equation 28 | 29 | u_t = u_xx 30 | 31 | For instructions on running and compiling, see 32 | 33 | examples/ex-05-cython/ex_05-setup.py 34 | 35 | and 36 | 37 | examples/ex-05-cython/ex_05.pyx 38 | 39 | -------------------------------------------------------------------------------- /examples/ex-05-cython/ex_05-setup.py: -------------------------------------------------------------------------------- 1 | from distutils.core import setup 2 | from distutils.extension import Extension 3 | from Cython.Build import cythonize 4 | import os 5 | import sys 6 | # import numpy 7 | 8 | braid_dir = "../../braid" 9 | 10 | ## 11 | # This setup.py file has been tested on High Sierra with Homebrew, and Ubuntu LTS. 12 | # This example requires Python 3 and the installation of Cython. 13 | # 14 | # To Install, 15 | # 16 | # 1) Make sure that braid_dir (defined above) points to the location of "braid" 17 | # This is used by library_dirs and include_dirs below 18 | # 19 | # 2) Type (using whatever install location you want) 20 | # 21 | # $ python3 ex_05-setup.py install --prefix=$HOME/.local 22 | # 23 | # Note that you may have to tweak the compilers and flags. 24 | # Some comments on this are below. 25 | # 26 | # To Run, 27 | # 28 | # 1) Make sure that the install directory and the location of MPI4PY 29 | # is in your PYTHONPATH, e.g., 30 | # 31 | # export PYTHONPATH="$HOME/.local/lib/python3.6" 32 | # or perhaps, 33 | # export PYTHONPATH="$HOME/.local/lib/python3.7/site-packages" 34 | # 35 | # 2) Type 36 | # python3 37 | # >>> import ex_05 38 | # >>> core, app = ex_05.InitCoreApp() 39 | # >>> ex_05.run_Braid(core, app) 40 | # 41 | # Output: 42 | # 43 | # Braid: Begin simulation, 60 time steps 44 | # Braid: || r_0 || = 2.211629e+01, conv factor = 1.00e+00, wall time = 2.43e-02 45 | # Braid: || r_1 || = 6.164662e-03, conv factor = 2.79e-04, wall time = 4.63e-02 46 | # Braid: || r_2 || = 2.174025e-04, conv factor = 3.53e-02, wall time = 6.75e-02 47 | # Braid: || r_3 || = 8.721079e-06, conv factor = 4.01e-02, wall time = 8.80e-02 48 | # ... 49 | # ... 50 | # 51 | # 3) For runs where you control various solver and problem parameters and can use 52 | # multiple processors in time, try 53 | # 54 | # $$ mpirun -np K python3 ex_05_run.py 55 | # 56 | # where you control parameters by editing ex_05_run.py 57 | ## 58 | 59 | ## 60 | # Other notes: 61 | # 1) Some systems may need to find Numpy headers, which are located in 62 | # include_dirs=["../braid", numpy.get_include()], 63 | # 2) Some compilers may require "-fPIC" to be added to extra_compile_args 64 | # 65 | ## 66 | 67 | 68 | os.environ["CC"] = "mpicc" 69 | if sys.platform != 'darwin': 70 | os.environ["LDSHARED"] = "mpicc -shared" # Needed by Ubuntu LTS, leave out for Mac 71 | 72 | ex_05_extension = Extension( 73 | name="ex_05", 74 | sources=["ex_05.pyx"], 75 | libraries=["braid"], 76 | library_dirs=[braid_dir], 77 | include_dirs=[braid_dir], 78 | extra_compile_args=["-Wno-incompatible-pointer-types", "-Wno-unused-function" ] 79 | ) 80 | setup( 81 | name="ex_05", 82 | ext_modules=cythonize([ex_05_extension], language_level = "3") 83 | ) 84 | 85 | -------------------------------------------------------------------------------- /examples/ex-05-cython/ex_05_run.py: -------------------------------------------------------------------------------- 1 | # Script for MPI runs of Cython code 2 | # 3 | # $ mpirun -np K python3 ex_05_run.py 4 | # 5 | 6 | import ex_05 7 | 8 | # Can choose to print help message 9 | print_help = False 10 | 11 | core, app = ex_05.InitCoreApp(print_help=print_help, ml=2, nu=1, nu0=1, 12 | CWt=1.0, skip=0, nx=16, ntime=60, tol=1e-6, cf=2, mi=30, sc=0, fmg=0) 13 | 14 | if print_help == False: 15 | ex_05.run_Braid(core, app) 16 | 17 | # Uncomment to run simple visualization script 18 | #from viz_ex_05 import viz_ex_05 19 | #viz_ex_05() 20 | 21 | 22 | -------------------------------------------------------------------------------- /examples/ex-05-cython/invert_sparse_mat_splu.py: -------------------------------------------------------------------------------- 1 | import scipy, numpy 2 | from scipy import linalg 3 | from scipy.sparse.linalg.interface import LinearOperator 4 | 5 | __all__ = ['invert_sparse_mat_splu'] 6 | 7 | 8 | def invert_sparse_mat_splu(A, **kwargs): 9 | ''' 10 | given a sparse matrix A, return a LinearOperator whose 11 | application is A-inverse by way of splu 12 | ''' 13 | 14 | Acsc = A.tocsc() 15 | Acsc.eliminate_zeros() 16 | nonzero_cols = ( (Acsc.indptr[:-1] - Acsc.indptr[1:]) != 0).nonzero()[0] 17 | Map = scipy.sparse.eye(Acsc.shape[0], Acsc.shape[1], format='csc') 18 | Map = Map[:,nonzero_cols] 19 | Acsc = Map.T.tocsc()*Acsc*Map 20 | LU = scipy.sparse.linalg.splu(Acsc) 21 | LU_Map = Map 22 | 23 | def matvec(b): 24 | return LU_Map*LU.solve( numpy.ravel(LU_Map.T*b) ) 25 | 26 | Ainv = LinearOperator(A.shape, matvec=matvec, dtype=A.dtype) 27 | 28 | return Ainv 29 | 30 | 31 | -------------------------------------------------------------------------------- /examples/ex-05-cython/viz_ex_05.py: -------------------------------------------------------------------------------- 1 | from scipy import * 2 | from matplotlib import pyplot as mpl 3 | from os import sys 4 | 5 | ## 6 | # Run like 7 | # $ python viz.py 8 | # 9 | # Vizualize the files from ex-05. The output is assumed to have 10 | # the following format. The filenames are 11 | # file_stem + '.' step_number + '.' + rank 12 | # So, the filename 13 | # ex-05.out.0000350.00000 14 | # is the output from step 350 from processor rank 0. Right now, 15 | # there is no parallelism, so it's always rank 0. 16 | # 17 | # Each output file has the format 18 | # 19 | # ntime_steps 20 | # tstart 21 | # tstop 22 | # nspace_points 23 | # xstart 24 | # xstop 25 | # x[0] 26 | # x[1] 27 | # . 28 | # . 29 | # . 30 | # x[k] 31 | ## 32 | 33 | def viz_ex_05(): 34 | 35 | # Set the braid iteration number and number of steps 36 | file_stem = 'ex-05.out.' 37 | current_rank = 0 38 | 39 | # Load the initial solution file and extract the problem size in space and time and the grid spacings 40 | step = 0 41 | fname = file_stem + "%05d"%step + '.' + "%04d"%current_rank 42 | data = loadtxt(fname) 43 | nsteps = int(data[0]) 44 | tstart = float(data[1]) 45 | tstop = float(data[2]) 46 | nspace = int(data[3]) 47 | xstart = float(data[4]) 48 | xstop = float(data[5]) 49 | mesh = linspace(xstart, xstop, nspace) 50 | data = zeros((nsteps,data.shape[0]-6)) 51 | 52 | # Load space-time solution, noting that we don't know the MPI ranks ahead of 53 | # time that generated the files, so we guess :-) 54 | for step in range(nsteps): 55 | try: 56 | fname = file_stem + "%05d"%step + '.' + "%04d"%current_rank 57 | data[step,:] = (loadtxt(fname))[6:] 58 | except: 59 | current_rank = current_rank + 1 60 | fname = file_stem + "%05d"%step + '.' + "%04d"%current_rank 61 | data[step,:] = (loadtxt(fname))[6:] 62 | 63 | mpl.figure(0) 64 | mpl.imshow(data,origin='lower',extent=(xstart, xstop, tstart, tstop)) 65 | mpl.colorbar() 66 | mpl.ylabel('time') 67 | mpl.xlabel('space') 68 | mpl.title('Space-Time Solution') 69 | 70 | mpl.figure(1) 71 | mpl.plot(mesh, data[0,:], '-o') 72 | mpl.ylabel('u') 73 | mpl.xlabel('space') 74 | mpl.title('Solution at Step 0') 75 | mpl.xlim(xstart, xstop) 76 | 77 | mpl.figure(2) 78 | mpl.plot(mesh, data[nsteps//2,:], '-o') 79 | mpl.ylabel('u') 80 | mpl.xlabel('space') 81 | mpl.title('Solution at Step %d'%(nsteps//2)) 82 | mpl.xlim(xstart, xstop) 83 | 84 | mpl.figure(3) 85 | mpl.plot(mesh, data[nsteps-1,:], '-o') 86 | mpl.ylabel('u') 87 | mpl.xlabel('space') 88 | mpl.title('Solution at Step %d'%(nsteps-1)) 89 | mpl.xlim(xstart, xstop) 90 | 91 | mpl.show() 92 | 93 | if __name__ == '__main__': 94 | # run viz function 95 | viz_ex_05() 96 | 97 | -------------------------------------------------------------------------------- /examples/viz-ex-02.py: -------------------------------------------------------------------------------- 1 | from __future__ import division 2 | from numpy import * 3 | from matplotlib import pyplot as mpl 4 | from os import sys 5 | 6 | ## 7 | # Run like 8 | # $ python viz.py 9 | # 10 | # Vizualize the files from ex-02.c. The output is assumed to have 11 | # the following format. The filenames are 12 | # file_stem + '.' step_number + '.' + rank 13 | # So, the filename 14 | # ex-02.out.0000350.00000 15 | # is the output from step 350 from processor rank 0. Right now, 16 | # there is no parallelism, so it's always rank 0. 17 | # 18 | # Each output file has the format 19 | # 20 | # ntime_steps 21 | # tstart 22 | # tstop 23 | # current_time 24 | # nspace_points 25 | # xstart 26 | # xstop 27 | # x[0] 28 | # x[1] 29 | # . 30 | # . 31 | # . 32 | # x[k] 33 | ## 34 | 35 | # Set the braid iteration number and number of steps 36 | #file_stem = 'ex-02-serial.out.' 37 | file_stem = 'ex-02.out.' 38 | current_rank = 0 39 | 40 | # Load the initial solution file and extract the problem size in space and time and the grid spacings 41 | step = 0 42 | fname = file_stem + "%07d"%step + '.' + "%05d"%current_rank 43 | data = loadtxt(fname) 44 | nsteps = int(data[0]) 45 | tstart = float(data[1]) 46 | tstop = float(data[2]) 47 | tvalues = zeros((nsteps,)) 48 | nspace = int(data[4]) 49 | xstart = float(data[5]) 50 | xstop = float(data[6]) 51 | mesh = linspace(xstart, xstop, nspace) 52 | data = zeros((nsteps,data.shape[0]-7)) 53 | 54 | # Load space-time solution, noting that we don't know the MPI ranks ahead of 55 | # time that generated the files, so we guess :-) 56 | for step in range(nsteps): 57 | try: 58 | fname = file_stem + "%07d"%step + '.' + "%05d"%current_rank 59 | data[step,:] = (loadtxt(fname))[7:] 60 | tvalues[step] = (loadtxt(fname))[3] 61 | except: 62 | current_rank = current_rank + 1 63 | fname = file_stem + "%07d"%step + '.' + "%05d"%current_rank 64 | data[step,:] = (loadtxt(fname))[7:] 65 | tvalues[step+1] = (loadtxt(fname))[3] 66 | 67 | 68 | # IMSHOW not as useful for adaptive grids, so it's turned off by default 69 | #mpl.figure(0) 70 | #mpl.imshow(data,origin='lower',extent=(xstart, xstop, tstart, tstop)) 71 | #mpl.colorbar() 72 | #mpl.ylabel('time') 73 | #mpl.xlabel('space') 74 | 75 | 76 | for j, idx in enumerate([0, nsteps//5, 2*(nsteps//5), 3*(nsteps//5), 4*(nsteps//5), nsteps-1]): 77 | mpl.figure(j+1) 78 | mpl.plot(mesh, data[idx,:], '-o') 79 | mpl.ylabel('u') 80 | mpl.xlabel('space') 81 | mpl.title('Solution at Time-Step=%d,t=%1.4e'%(idx, tvalues[idx]) ) 82 | mpl.ylim(data[idx,:].min()-1.0, data[idx,:].max()+1.0) 83 | mpl.xlim(xstart, xstop) 84 | 85 | # If Desired, can also plot regularly space time grid 86 | #mpl.figure(0) 87 | #mpl.plot(tvalues, zeros_like(tvalues), 'k.') 88 | #mpl.title("Time Grid") 89 | 90 | mpl.show() 91 | 92 | -------------------------------------------------------------------------------- /examples/viz-ex-04.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | from scipy import * 3 | from matplotlib import pyplot as mpl 4 | from os import sys 5 | 6 | ## 7 | # Run like 8 | # $ python viz-ex-04.py serial|braid 9 | # 10 | # Vizualize the files from ex-04.c or ex-04-serial.c 11 | # - ex-04.out.state [ output from ex-04-serial ] 12 | # - ex-04.out.***.### [ output from ex-04, *** is the step number, and ### is the proc number ] 13 | # - ex-04.out.design [ output by both ex-04 and ex-04-serial ] 14 | # 15 | # The file ex-04.out.design is a file with Ntime lines, and line k has time 16 | # step k's design value. 17 | # 18 | # The file ex-04.out.state is a file with Ntime lines, and line k has time 19 | # step k's two solution values. This is only output from ex-04-serial. 20 | # 21 | # The files ex-04.out.***.### This file contains one value, the two solution 22 | # values at the corresponding step number. This is only output from ex-04. 23 | # 24 | ## 25 | 26 | if len(sys.argv) != 2: 27 | print(" Please run this script with one command line argument, serial|braid, ") 28 | print(" indicating if you want to visualize the output from ex-04-serial or ex-04.") 29 | sys.exit(1) 30 | 31 | ## 32 | # Load design 33 | design = loadtxt('ex-04.out.design') 34 | nsteps = design.shape[0] 35 | tmesh = linspace(0,1.0,nsteps+1) 36 | 37 | ## 38 | # Load State 39 | if sys.argv[1] == "serial": 40 | state_vec = loadtxt('ex-04.out.state') 41 | elif sys.argv[1] == "braid": 42 | current_rank = 0 43 | file_stem = "ex-04.out." 44 | state_vec = zeros((nsteps,2)) 45 | # We don't know the MPI ranks ahead of time that generated the files, so we guess :-) 46 | for step in range(1,nsteps+1): 47 | try: 48 | fname = file_stem + "%04d"%step + '.' + "%03d"%current_rank 49 | state_vec[step-1,:] = loadtxt(fname, delimiter=',') 50 | except: 51 | current_rank = current_rank + 1 52 | fname = file_stem + "%04d"%step + '.' + "%03d"%current_rank 53 | state_vec[step-1,:] = loadtxt(fname, delimiter=',') 54 | 55 | else: 56 | print(" Please run this script with one command line argument, serial|braid, ") 57 | print(" indicating if you want to visualize the output from ex-04-serial or ex-04.") 58 | sys.exit(1) 59 | 60 | mpl.figure(1) 61 | mpl.plot(tmesh[1:], state_vec[:,0], '-b') 62 | mpl.plot(tmesh[1:], state_vec[:,1], '-k') 63 | mpl.ylabel('u') 64 | mpl.xlabel('time') 65 | mpl.title('Solution Values') 66 | mpl.legend(['Component 1', 'Component 2']) 67 | 68 | mpl.figure(2) 69 | mpl.plot(tmesh[1:], design, '-k') 70 | mpl.ylabel('design') 71 | mpl.xlabel('time') 72 | mpl.title('Design Solution') 73 | mpl.show() 74 | 75 | 76 | -------------------------------------------------------------------------------- /examples/viz-ex-06.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | from scipy import * 3 | from matplotlib import pyplot as mpl 4 | from os import sys 5 | 6 | ## 7 | # Run like 8 | # $ python viz-ex-06.py serial|braid 9 | # 10 | # Vizualize the files from ex-06.c 11 | # - ex-04.out.***.### [ output from ex-04, *** is the step number, and ### is the proc number ] 12 | # 13 | # The files ex-04.out.***.### This file contains six lines, 14 | # 15 | # time-value 16 | # time index 17 | # global num time points 18 | # numerical solution value 19 | # Richardson-based error estimate 20 | # True error 21 | # 22 | ## 23 | 24 | if len(sys.argv) != 1: 25 | print(" Please read this script for information on how to run ") 26 | sys.exit(1) 27 | 28 | # Set the braid iteration number and number of steps 29 | file_stem = 'ex-06.out.' 30 | current_rank = 0 31 | 32 | # Load the initial solution file and extract the problem size 33 | tstart = 0 34 | tstop = 0.5 35 | step = 0 36 | fname = file_stem + "%04d"%step + '.' + "%03d"%current_rank 37 | data = loadtxt(fname) 38 | nsteps = int(data[2]) 39 | 40 | # Allocate arrays to plot 41 | soln = zeros((nsteps,)) 42 | tpts = zeros((nsteps,)) 43 | err_est = zeros((nsteps,)) 44 | err = zeros((nsteps,)) 45 | 46 | 47 | # Load data, noting that we don't know the MPI ranks ahead of 48 | # time that generated the files, so we guess :-) 49 | for step in range(nsteps): 50 | try: 51 | fname = file_stem + "%04d"%step + '.' + "%03d"%current_rank 52 | data = loadtxt(fname) 53 | except: 54 | current_rank = current_rank + 1 55 | fname = file_stem + "%04d"%step + '.' + "%03d"%current_rank 56 | data = loadtxt(fname) 57 | ## 58 | tpts[step] = data[0] 59 | soln[step] = data[3] 60 | err_est[step] = data[4] 61 | err[step] = data[5] 62 | 63 | 64 | # Visualize results 65 | mpl.figure(0) 66 | mpl.plot(tpts, soln, '-k+') 67 | mpl.ylabel('Numerical Solution') 68 | mpl.xlabel('time') 69 | mpl.title('Example 6') 70 | 71 | mpl.figure(1) 72 | mpl.semilogy(tpts, err, '-k+') 73 | if(err_est[0] != -1.0): 74 | mpl.semilogy(tpts, err_est, '-r+') 75 | mpl.legend(['True Error', 'Richardson Error Estimate']) 76 | else: 77 | mpl.legend(['True Error', 'Richardson Error Estimate']) 78 | 79 | mpl.ylabel('Error') 80 | mpl.xlabel('time') 81 | mpl.title('Example 6 Error') 82 | 83 | mpl.show() 84 | 85 | -------------------------------------------------------------------------------- /examples/viz-ex-07.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | 4 | def read_data(fname): 5 | u = [] 6 | with open(fname, 'r') as f: 7 | for line in f: 8 | u.append(np.array(line.split(' ')[1:], dtype=np.double)) 9 | return np.stack(u) 10 | 11 | if __name__=="__main__": 12 | u = read_data("ex-07.out") 13 | tan = read_data("ex-07-lv.out") 14 | 15 | # reshape the tangent vectors 16 | dim = tan.shape[-1] // 4 17 | tan = tan.reshape((tan.shape[0], dim, 4)) 18 | 19 | # separate out the exponents 20 | exps = tan[:, :, 0] 21 | tan = tan[:, :, 1:] 22 | 23 | # find the time-average of the exponents 24 | mean_exp = exps.sum(axis=0)/(4*np.log(10.)/0.9) # assuming tstop = 4 T_\lambda. 25 | print(f"average Lyapunov exponents: {mean_exp}") 26 | 27 | # plot the trajectory and tangent vectors in 3D 28 | plt.figure(figsize=(8,8)) 29 | ax = plt.axes(projection='3d') 30 | ax.plot3D(*u.T) 31 | for d in range(dim): 32 | ax.quiver(*u[::16].T, *tan[::16, d, :].T, color=f"C{1+d}", length=1.7, label=fr"$\lambda_{d} = {mean_exp[d]}$") 33 | # ax.quiver(*u.T, *tan[:, d, :].T, color=f"C{1+d}", length=1.1, label=fr"$\lambda_{d} = {exps[d]}$") 34 | plt.legend() 35 | plt.tight_layout() 36 | plt.show() 37 | -------------------------------------------------------------------------------- /makefile.inc: -------------------------------------------------------------------------------- 1 | #BHEADER********************************************************************** 2 | # 3 | # Copyright (c) 2013, Lawrence Livermore National Security, LLC. 4 | # Produced at the Lawrence Livermore National Laboratory. Written by 5 | # Jacob Schroder, Rob Falgout, Tzanio Kolev, Ulrike Yang, Veselin 6 | # Dobrev, et al. LLNL-CODE-660355. All rights reserved. 7 | # 8 | # This file is part of XBraid. Email xbraid-support@llnl.gov for support. 9 | # 10 | # This program is free software; you can redistribute it and/or modify it under 11 | # the terms of the GNU General Public License (as published by the Free Software 12 | # Foundation) version 2.1 dated February 1999. 13 | # 14 | # This program is distributed in the hope that it will be useful, but WITHOUT ANY 15 | # WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A 16 | # PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public 17 | # License for more details. 18 | # 19 | # You should have received a copy of the GNU Lesser General Public License along 20 | # with this program; if not, write to the Free Software Foundation, Inc., 59 21 | # Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | # 23 | #EHEADER********************************************************************** 24 | 25 | # Three compile time options 26 | # make debug=yes|no 27 | # make valgrind=yes|no 28 | # make sequential=yes|no 29 | 30 | # Was DEBUG specified? 31 | ifeq ($(debug),no) 32 | optlevel = OPTIMIZE 33 | else 34 | optlevel = DEBUG 35 | endif 36 | 37 | # Was VALGRIND specified? 38 | ifeq ($(valgrind),yes) 39 | lvalgrind = YES 40 | else 41 | lvalgrind = NO 42 | endif 43 | 44 | # Was MPI use specified? 45 | ifeq ($(sequential),yes) 46 | sequential = YES 47 | else 48 | sequential = NO 49 | endif 50 | 51 | # Default compiler options for different platforms and known machines 52 | # Add an else statement for your machine, if the compile options need adjustment 53 | 54 | HOSTNAME := $(shell hostname) 55 | 56 | ifeq ($(findstring tux408,$(HOSTNAME)),tux408) 57 | # Jacobs old LLNL tux-boxes 58 | CC = mpicc 59 | MPICC = mpicc 60 | MPICXX = mpicxx 61 | MPIF90 = mpif90 62 | LFLAGS = -lm 63 | ifeq ($(optlevel),DEBUG) 64 | CFLAGS = -g -Wall -lm -fPIC 65 | CXXFLAGS = -g -Wall -Wno-reorder -lm -fPIC 66 | FORTFLAGS = -Og -Wall 67 | else 68 | CFLAGS = -O -Wall -lm -fPIC 69 | CXXFLAGS = -O -Wall -Wno-reorder -lm -fPIC 70 | FORTFLAGS = -O1 -Wall 71 | endif 72 | ifeq ($(lvalgrind),YES) 73 | #only needed for openmpi: LFLAGS += /usr/lib64/valgrind/libmpiwrap-amd64-linux.so 74 | endif 75 | else ifeq ($(shell uname -s), Darwin) 76 | # for Jacob's MacBook running Homebrew 77 | # Need to specifically include lstdc++ (!!) 78 | CC = gcc 79 | MPICC = mpicc 80 | MPICXX = mpicxx 81 | MPIF90 = mpif90 82 | LFLAGS = -lm -lstdc++ 83 | ifeq ($(optlevel),DEBUG) 84 | CFLAGS = -g -Wall -fPIC 85 | CXXFLAGS = -g -Wall -fPIC 86 | FORTFLAGS = -Og -Wall 87 | else 88 | CFLAGS = -O3 -Wall -fPIC 89 | CXXFLAGS = -O3 -Wall -fPIC 90 | FORTFLAGS = -O1 -Wall 91 | endif 92 | else ifeq ($(findstring cab,$(HOSTNAME)),cab) 93 | # for Cab 94 | MPICC = mpiicc 95 | MPICXX = mpiicpc 96 | MPIF90 = mpif90 97 | LFLAGS = -lm 98 | ifeq ($(optlevel),DEBUG) 99 | CFLAGS = -g -Wall -fPIC 100 | CXXFLAGS = -g -Wall -fPIC 101 | FORTFLAGS = -Og -Wall 102 | else 103 | CFLAGS = -O -Wall -fPIC 104 | CXXFLAGS = -O -Wall -fPIC 105 | FORTFLAGS = -O1 -Wall 106 | endif 107 | else ifeq ($(findstring vulcan,$(HOSTNAME)),vulcan) 108 | # for Vulcan 109 | MPICC = mpixlc 110 | MPICXX = mpixlcxx 111 | MPIF90 = mpixlf90 112 | LFLAGS = -lm 113 | ifeq ($(optlevel),DEBUG) 114 | CFLAGS = -g -Wall -fPIC 115 | CXXFLAGS = -g -Wall -fPIC 116 | FORTFLAGS = -Og -Wall 117 | else 118 | CFLAGS = -O -Wall -fPIC 119 | CXXFLAGS = -O -Wall -fPIC 120 | FORTFLAGS = -O1 -Wall 121 | endif 122 | else ifeq ($(findstring cadaverous,$(HOSTNAME)),cadaverous) 123 | # David's desktop (specifically need to use system compilers 124 | # since condas are bad) 125 | MPICC = /usr/bin/mpicc 126 | MPICXX = /usr/bin/mpicxx 127 | MPIF90 = /usr/bin/mpif90 128 | LFLAGS = -lm 129 | ifeq ($(optlevel),DEBUG) 130 | CFLAGS = -g -Wall -fPIC 131 | CXXFLAGS = -g -Wall -fPIC 132 | FORTFLAGS = -g -Wall 133 | else 134 | CFLAGS = -O3 -Wall -fPIC 135 | CXXFLAGS = -O3 -Wall -fPIC 136 | FORTFLAGS = -O1 -Wall 137 | endif 138 | else ifeq ($(shell uname -s),Linux) 139 | MPICC = mpicc 140 | MPICXX = mpicxx 141 | MPIF90 = mpif90 142 | LFLAGS = -lm 143 | ifeq ($(optlevel),DEBUG) 144 | CFLAGS = -g -Wall -fPIC 145 | CXXFLAGS = -g -Wall -fPIC 146 | FORTFLAGS = -g -Wall 147 | else 148 | CFLAGS = -O3 -Wall -fPIC 149 | CXXFLAGS = -O3 -Wall -fPIC 150 | FORTFLAGS = -O1 -Wall 151 | endif 152 | ## 153 | # Add your machine name here 154 | ## 155 | else 156 | MPICC = mpicc 157 | MPICXX = mpicxx 158 | MPIF90 = mpif90 159 | LFLAGS = -lm 160 | ifeq ($(optlevel),DEBUG) 161 | CFLAGS = -g -Wall -fPIC 162 | CXXFLAGS = -g -Wall -fPIC 163 | FORTFLAGS = -g -Wall 164 | else 165 | CFLAGS = -O3 -Wall -fPIC 166 | CXXFLAGS = -O3 -Wall -fPIC 167 | FORTFLAGS = -O1 -Wall 168 | endif 169 | endif 170 | 171 | # Compiler options when compiling without MPI 172 | ifeq ($(sequential),YES) 173 | MPICC = gcc 174 | MPICXX = g++ 175 | MPIF90 = gfortran 176 | LFLAGS = -lm 177 | ifeq ($(optlevel),DEBUG) 178 | CFLAGS = -g -Wall -D braid_SEQUENTIAL 179 | CXXFLAGS = -g -Wall -D braid_SEQUENTIAL 180 | FORTFLAGS = -g -Wall -D braid_SEQUENTIAL 181 | else 182 | CFLAGS = -O -Wall -D braid_SEQUENTIAL 183 | CXXFLAGS = -O -Wall -D braid_SEQUENTIAL 184 | FORTFLAGS = -O1 -Wall -D braid_SEQUENTIAL 185 | endif 186 | endif 187 | 188 | -------------------------------------------------------------------------------- /misc/README.md: -------------------------------------------------------------------------------- 1 | ## Coding Style 2 | 23 | 24 | Code should follow the `ellemtel` style. See 25 | braid/misc/sample_c_code.c, and for emacs and vim style files, see 26 | braid/misc/sample.vimrc, and braid/misc/sample.emacs. 27 | 28 | -------------------------------------------------------------------------------- /misc/sample.emacs: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; Copyright (c) 2013, Lawrence Livermore National Security, LLC. 3 | ;;; Produced at the Lawrence Livermore National Laboratory. Written by 4 | ;;; Jacob Schroder, Rob Falgout, Tzanio Kolev, Ulrike Yang, Veselin 5 | ;;; Dobrev, et al. LLNL-CODE-660355. All rights reserved. 6 | ;;; 7 | ;;; This file is part of XBraid. For support, post issues to the XBraid Github page. 8 | ;;; 9 | ;;; This program is free software; you can redistribute it and/or modify it under 10 | ;;; the terms of the GNU General Public License (as published by the Free Software 11 | ;;; Foundation) version 2.1 dated February 1999. 12 | ;;; 13 | ;;; This program is distributed in the hope that it will be useful, but WITHOUT ANY 14 | ;;; WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A 15 | ;;; PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public 16 | ;;; License for more details. 17 | ;;; 18 | ;;; You should have received a copy of the GNU Lesser General Public License along 19 | ;;; with this program; if not, write to the Free Software Foundation, Inc., 59 20 | ;;; Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | ;;; 22 | 23 | ;;;-------------------------------------------------------------------------- 24 | ;;; 25 | ;;; casc customizations for .emacs file. can be used with emacs or xemacs. 26 | ;;; 27 | ;;; to use this file just by itself, do 28 | ;;; emacs -l sample.emacs file_to_edit 29 | ;;; 30 | ;;; to get emacs to automatically use this file on startup, add this to 31 | ;;; your .emacs file. 32 | ;;; 33 | ;;; author: chandrika kamath 34 | ;;; lawrence livermore national laboratory 35 | ;;; livermore, ca 94551 36 | ;;; 37 | ;;; date: october 24, 1997 38 | ;;; 39 | ;;; modified: 1) Added the font lock for c++ mode. 40 | ;;; Added indent-tabs-mode to force indentation with spaces 41 | ;;; chandrika kamath, december 9, 1997. 42 | ;;;-------------------------------------------------------------------------- 43 | 44 | ;;; 45 | ;;; C/C++ mode 46 | ;;; 47 | ;;; c-auto-newline automatically inserts a newline before and after a 48 | ;;; brace, and after a ";". To toggle this on/off, use C-x C-a. To 49 | ;;; turn it off permanently, comment out the line that sets c-auto-newline. 50 | ;;; 51 | ;;; the ellemtel style sets the opening brace on a new line. to set the 52 | ;;; brace at the end of the same line, use the stroustrup style. 53 | ;;; 54 | 55 | (defun my-c-mode-common-hook () 56 | (c-set-style "ellemtel") 57 | (setq c-tab-always-indent t) 58 | (setq c-basic-offset 3) 59 | (c-set-offset 'knr-argdecl-intro 0) 60 | (setq c-auto-newline t) 61 | (setq c-continued-statement-offset 3) 62 | (setq c-brace-offset 0) 63 | (c-set-offset 'inclass '+) 64 | (setq line-number-mode t) 65 | (setq indent-tabs-mode nil) 66 | ) 67 | 68 | (add-hook 'c-mode-common-hook 'my-c-mode-common-hook) 69 | 70 | ;;; 71 | ;;; to turn on color in cc-mode (to set background color, see the manpages for 72 | ;;; emacs or xemacs) 73 | ;;; 74 | 75 | 76 | -------------------------------------------------------------------------------- /misc/sample.vimrc: -------------------------------------------------------------------------------- 1 | "" Copyright (c) 2013, Lawrence Livermore National Security, LLC. 2 | "" Produced at the Lawrence Livermore National Laboratory. Written by 3 | "" Jacob Schroder, Rob Falgout, Tzanio Kolev, Ulrike Yang, Veselin 4 | "" Dobrev, et al. LLNL-CODE-660355. All rights reserved. 5 | "" 6 | "" This file is part of XBraid. For support, post issues to the XBraid Github page. 7 | "" 8 | "" This program is free software; you can redistribute it and/or modify it under 9 | "" the terms of the GNU General Public License (as published by the Free Software 10 | "" Foundation) version 2.1 dated February 1999. 11 | "" 12 | "" This program is distributed in the hope that it will be useful, but WITHOUT ANY 13 | "" WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A 14 | "" PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public 15 | "" License for more details. 16 | "" 17 | "" You should have received a copy of the GNU Lesser General Public License along 18 | "" with this program; if not, write to the Free Software Foundation, Inc., 59 19 | "" Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | "" 21 | 22 | 23 | " Add these lines to your .vimrc file to mimic the ellemtel C style 24 | " given by emacs 25 | 26 | " Syntax highlighting 27 | :syn on 28 | " Show line numbers 29 | :set nu 30 | " Autoindent 31 | :set ai 32 | " Tab and shift settings 33 | :set tabstop=3 34 | :set shiftwidth=3 35 | :set expandtab 36 | " Choose your color scheme 37 | :colorscheme desert 38 | " Automatically do language dependent indenting 39 | filetype plugin indent on 40 | " Set 'textwidth' to 78 characters. 41 | autocmd FileType text setlocal textwidth=78 42 | -------------------------------------------------------------------------------- /misc/sample_c_code.c: -------------------------------------------------------------------------------- 1 | /*BHEADER********************************************************************** 2 | * Copyright (c) 2013, Lawrence Livermore National Security, LLC. 3 | * Produced at the Lawrence Livermore National Laboratory. Written by 4 | * Jacob Schroder, Rob Falgout, Tzanio Kolev, Ulrike Yang, Veselin 5 | * Dobrev, et al. LLNL-CODE-660355. All rights reserved. 6 | * 7 | * This file is part of XBraid. For support, post issues to the XBraid Github page. 8 | * 9 | * This program is free software; you can redistribute it and/or modify it under 10 | * the terms of the GNU General Public License (as published by the Free Software 11 | * Foundation) version 2.1 dated February 1999. 12 | * 13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY 14 | * WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A 15 | * PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public 16 | * License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 59 20 | * Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | * 22 | ***********************************************************************EHEADER*/ 23 | 24 | 25 | /** 26 | * 27 | * This is an example of a C code illustrating the indentation used 28 | * for Braid. This code does not illustrate issues related to 29 | * error handling, efficiency of implementation or naming conventions. 30 | * 31 | * The most important item here is consistent indentation of the following 32 | * structures: 33 | * - for loops 34 | * - if statements 35 | * 36 | * We use the ellemtel style with tab and shift widths of 3. See 37 | * sample.emacs and sample.vimrc for settings you can use. 38 | * 39 | * This example also shows a sample comment block for a function and 40 | * parameters that works well with doxygen. 41 | * 42 | */ 43 | 44 | #include "headers.h" 45 | 46 | /** 47 | * Matvec - matrix-vector function. 48 | * 49 | * Calculates y = alpha * A * x + beta * y 50 | * where A is a matrix stored in compressed sparse row format, x and y 51 | * are n vectors, and alpha and beta are scalars. 52 | * 53 | * Output: 54 | * - *y* will point to the vector 55 | **/ 56 | void 57 | Matvec( double alpha, /**< Describe parameters like this for doxygen*/ 58 | Matrix *A, /**< Matrix for mat-vec operation */ 59 | Vector *x, /**< Vector to be multiplied */ 60 | double beta, /**< scalar */ 61 | Vector *y /**< Vector for addition */ 62 | ) 63 | { 64 | double *a = MatrixData(A); /* element values for matrix A */ 65 | HYPRE_Int *ia = MatrixIA(A); /* pointer to start of each row */ 66 | HYPRE_Int *ja = MatrixJA(A); /* column values for matrix elements */ 67 | HYPRE_Int n = MatrixSize(A); /* size of matrix */ 68 | 69 | double *xp = VectorData(x); 70 | double *yp = VectorData(y); 71 | 72 | double temp; 73 | 74 | HYPRE_Int i, j, jj; 75 | 76 | /* 77 | * Do (alpha == 0.0) computation 78 | */ 79 | 80 | if (alpha == 0.0) 81 | { 82 | for (i = 0; i < n; i++) 83 | yp[i] *= beta; 84 | 85 | return; 86 | } 87 | 88 | /* 89 | * y = (beta/alpha)*y 90 | */ 91 | 92 | temp = beta / alpha; 93 | 94 | if (temp != 1.0) 95 | { 96 | if (temp == 0.0) 97 | { 98 | for (i = 0; i < n; i++) 99 | yp[i] = 0.0; 100 | } 101 | else 102 | { 103 | for (i = 0; i < n; i++) 104 | yp[i] *= temp; 105 | } 106 | } 107 | 108 | /* 109 | * y += A*x 110 | */ 111 | 112 | for (i = 0; i < n; i++) 113 | { 114 | for (jj = ia[i]-1; jj < ia[i+1]-1; jj++) 115 | { 116 | j = ja[jj]-1; 117 | yp[i] += a[jj] * xp[j]; 118 | } 119 | } 120 | 121 | /* 122 | * y = alpha*y 123 | */ 124 | 125 | if (alpha != 1.0) 126 | { 127 | for (i = 0; i < n; i++) 128 | yp[i] *= alpha; 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /misc/user_utils/cycleplot.gnuplot: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2013, Lawrence Livermore National Security, LLC. 2 | # Produced at the Lawrence Livermore National Laboratory. Written by 3 | # Jacob Schroder, Rob Falgout, Tzanio Kolev, Ulrike Yang, Veselin 4 | # Dobrev, et al. LLNL-CODE-660355. All rights reserved. 5 | # 6 | # This file is part of XBraid. For support, post issues to the XBraid Github page. 7 | # 8 | # This program is free software; you can redistribute it and/or modify it under 9 | # the terms of the GNU General Public License (as published by the Free Software 10 | # Foundation) version 2.1 dated February 1999. 11 | # 12 | # This program is distributed in the hope that it will be useful, but WITHOUT ANY 13 | # WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A 14 | # PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public 15 | # License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public License along 18 | # with this program; if not, write to the Free Software Foundation, Inc., 59 19 | # Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | # 21 | # 22 | # Type the following command in the run directory (e.g., in 'examples'): 23 | # gnuplot ../cycleplot.gnuplot 24 | # 25 | set yrange [:] reverse 26 | set offsets 0, 0, 1, 1 27 | plot 'braid.out.cycle' using ($1-$2) with linespoints pt 5 28 | pause -1 "Hit any key to continue" 29 | -------------------------------------------------------------------------------- /misc/user_utils/cycleplot.m: -------------------------------------------------------------------------------- 1 | % Copyright (c) 2013, Lawrence Livermore National Security, LLC. 2 | % Produced at the Lawrence Livermore National Laboratory. Written by 3 | % Jacob Schroder, Rob Falgout, Tzanio Kolev, Ulrike Yang, Veselin 4 | % Dobrev, et al. LLNL-CODE-660355. All rights reserved. 5 | % 6 | % This file is part of XBraid. For support, post issues to the XBraid Github page. 7 | % 8 | % This program is free software; you can redistribute it and/or modify it under 9 | % the terms of the GNU General Public License (as published by the Free Software 10 | % Foundation) version 2.1 dated February 1999. 11 | % 12 | % This program is distributed in the hope that it will be useful, but WITHOUT ANY 13 | % WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A 14 | % PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public 15 | % License for more details. 16 | % 17 | % You should have received a copy of the GNU Lesser General Public License along 18 | % with this program; if not, write to the Free Software Foundation, Inc., 59 19 | % Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | % 21 | 22 | function cycleplot(filename); 23 | 24 | X = load(filename); 25 | Y = X(:,1)-X(:,2); 26 | plot(Y); 27 | view([0,-90]); 28 | -------------------------------------------------------------------------------- /misc/user_utils/cycleplot2.gnuplot: -------------------------------------------------------------------------------- 1 | # 2 | # Type the following command in the run directory (e.g., in 'examples'): 3 | # gnuplot -noraise ../cycleplot2.gnuplot 4 | # The script waitfile.sh MUST be in your PATH variable 5 | # or you have to modify this file to put an absolute path to the script instead 6 | 7 | set yrange [:] reverse 8 | set ytics nomirror 9 | set offsets 0, 0, 1, 1 10 | set y2range [0:] 11 | set y2tics 12 | plot 'braid.out.cycle' using ($1-$2) with linespoints pt 5 axes x1y1 title 'Effective cycles', 'braid.out.cycle' u 4 axes x1y2 title '# points on fine grid' 13 | v=system('waitfile.sh braid.out.cycle 2>/dev/null') 14 | if (v ne '') reread 15 | -------------------------------------------------------------------------------- /misc/user_utils/waitfile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2013, Lawrence Livermore National Security, LLC. 4 | # Produced at the Lawrence Livermore National Laboratory. Written by 5 | # Jacob Schroder, Rob Falgout, Tzanio Kolev, Ulrike Yang, Veselin 6 | # Dobrev, et al. LLNL-CODE-660355. All rights reserved. 7 | # 8 | # This file is part of XBraid. For support, post issues to the XBraid Github page. 9 | # 10 | # This program is free software; you can redistribute it and/or modify it under 11 | # the terms of the GNU General Public License (as published by the Free Software 12 | # Foundation) version 2.1 dated February 1999. 13 | # 14 | # This program is distributed in the hope that it will be useful, but WITHOUT ANY 15 | # WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A 16 | # PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public 17 | # License for more details. 18 | # 19 | # You should have received a copy of the GNU Lesser General Public License along 20 | # with this program; if not, write to the Free Software Foundation, Inc., 59 21 | # Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | file=$1 24 | sz=$(stat --printf="%s" ${file}) 25 | nsz=${sz} 26 | while [[ "${sz}" == "${nsz}" ]] 27 | do 28 | sleep 0.1 29 | nsz=$(stat --printf="%s" ${file}) 30 | done 31 | [[ "${sz}" != "${nsz}" ]] && echo ${file} 32 | -------------------------------------------------------------------------------- /misc/zdist1.c: -------------------------------------------------------------------------------- 1 | /*BHEADER********************************************************************** 2 | * Copyright (c) 2013, Lawrence Livermore National Security, LLC. 3 | * Produced at the Lawrence Livermore National Laboratory. Written by 4 | * Jacob Schroder, Rob Falgout, Tzanio Kolev, Ulrike Yang, Veselin 5 | * Dobrev, et al. LLNL-CODE-660355. All rights reserved. 6 | * 7 | * This file is part of XBraid. For support, post issues to the XBraid Github page. 8 | * 9 | * This program is free software; you can redistribute it and/or modify it under 10 | * the terms of the GNU General Public License (as published by the Free Software 11 | * Foundation) version 2.1 dated February 1999. 12 | * 13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY 14 | * WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A 15 | * PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public 16 | * License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 59 20 | * Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | * 22 | ***********************************************************************EHEADER*/ 23 | 24 | #include 25 | #include 26 | 27 | int 28 | main( int argc, char *argv[] ) 29 | { 30 | int arg_index; 31 | int npoints, nprocs; 32 | int proc, quo,rem, ilower, iupper, i, p, q, last_proc; 33 | 34 | if (argc > 2) 35 | { 36 | arg_index = 1; 37 | npoints = atoi(argv[arg_index++]); 38 | nprocs = atoi(argv[arg_index++]); 39 | } 40 | else 41 | { 42 | printf("Problem with input\n"); 43 | exit(1); 44 | } 45 | 46 | printf("\n npoints = %d, nprocs = %d\n", npoints, nprocs); 47 | 48 | quo = npoints/nprocs; 49 | rem = npoints%nprocs; 50 | 51 | /* GetDistribution */ 52 | 53 | printf("\n GetDistribution:\n\n"); 54 | for (proc = 0; proc < nprocs; proc++) 55 | { 56 | p = proc; 57 | ilower = p*quo + (p < rem ? p : rem); 58 | p = proc+1; 59 | iupper = p*quo + (p < rem ? p : rem) - 1; 60 | 61 | printf(" %2d:", proc); 62 | for (i = ilower; i <= iupper; i++) 63 | { 64 | printf(" %2d", i); 65 | } 66 | printf("\n"); 67 | } 68 | 69 | /* GetProc */ 70 | 71 | printf("\n GetProc:\n"); 72 | last_proc = -1; 73 | for (i = 0; i < npoints; i++) 74 | { 75 | p = i/(quo+1); 76 | q = (i - rem*(quo+1))/quo; 77 | proc = (p < rem ? p : rem+q); 78 | 79 | if (proc > last_proc) 80 | { 81 | printf("\n"); 82 | printf(" %2d:", proc); 83 | } 84 | printf(" %2d", i); 85 | 86 | last_proc = proc; 87 | } 88 | printf("\n\n"); 89 | 90 | return (0); 91 | } 92 | -------------------------------------------------------------------------------- /misc/zdist2.c: -------------------------------------------------------------------------------- 1 | /*BHEADER********************************************************************** 2 | * Copyright (c) 2013, Lawrence Livermore National Security, LLC. 3 | * Produced at the Lawrence Livermore National Laboratory. Written by 4 | * Jacob Schroder, Rob Falgout, Tzanio Kolev, Ulrike Yang, Veselin 5 | * Dobrev, et al. LLNL-CODE-660355. All rights reserved. 6 | * 7 | * This file is part of XBraid. For support, post issues to the XBraid Github page. 8 | * 9 | * This program is free software; you can redistribute it and/or modify it under 10 | * the terms of the GNU General Public License (as published by the Free Software 11 | * Foundation) version 2.1 dated February 1999. 12 | * 13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY 14 | * WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A 15 | * PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public 16 | * License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 59 20 | * Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | * 22 | ***********************************************************************EHEADER*/ 23 | 24 | #include 25 | #include 26 | 27 | int 28 | main( int argc, char *argv[] ) 29 | { 30 | int arg_index; 31 | int npoints, nprocs; 32 | int proc, ilower, iupper, i, p, q, last_proc; 33 | 34 | if (argc > 2) 35 | { 36 | arg_index = 1; 37 | npoints = atoi(argv[arg_index++]); 38 | nprocs = atoi(argv[arg_index++]); 39 | } 40 | else 41 | { 42 | printf("Problem with input\n"); 43 | exit(1); 44 | } 45 | 46 | printf("\n npoints = %d, nprocs = %d\n", npoints, nprocs); 47 | 48 | /* GetDistribution */ 49 | 50 | printf("\n GetDistribution:\n\n"); 51 | for (proc = 0; proc < nprocs; proc++) 52 | { 53 | p = proc; 54 | ilower = npoints - ((nprocs-p)*npoints)/nprocs; 55 | p = proc+1; 56 | iupper = npoints - ((nprocs-p)*npoints)/nprocs - 1; 57 | 58 | printf(" %2d:", proc); 59 | for (i = ilower; i <= iupper; i++) 60 | { 61 | printf(" %2d", i); 62 | } 63 | printf("\n"); 64 | } 65 | 66 | /* GetProc */ 67 | 68 | printf("\n GetProc:\n"); 69 | last_proc = -1; 70 | for (i = 0; i < npoints; i++) 71 | { 72 | proc = (i*nprocs)/npoints; 73 | 74 | if (proc > last_proc) 75 | { 76 | printf("\n"); 77 | printf(" %2d:", proc); 78 | } 79 | printf(" %2d", i); 80 | 81 | last_proc = proc; 82 | } 83 | printf("\n\n"); 84 | 85 | return (0); 86 | } 87 | -------------------------------------------------------------------------------- /test/adjoint.saved: -------------------------------------------------------------------------------- 1 | # Begin Test 0 2 | time steps = 50 3 | iterations = 6 4 | state residual norm = 8.359592e-08 (-> abs. stopping tol. = 1.00e-06) 5 | adjoint residual norm = 4.482596e-07 (-> abs. stopping tol. = 1.00e-06) 6 | number of levels = 2 7 | 8 | # Begin Test 1 9 | Objective function value = 9.97999467e-06 10 | Gradient norm = 1.72042601e-07 11 | optimization iterations = 47 12 | time steps = 50 13 | iterations = 2 14 | state residual norm = 9.168879e-07 (-> abs. stopping tol. = 1.00e-06) 15 | adjoint residual norm = 7.963396e-07 (-> abs. stopping tol. = 1.00e-06) 16 | number of levels = 2 17 | 18 | # Begin Test 2 19 | Objective function value = 5.06187715e-02 20 | Gradient norm = 9.92946109e-07 21 | optimization iterations = 230 22 | time steps = 20 23 | iterations = 1 24 | state residual norm = 4.119131e-07 (-> abs. stopping tol. = 1.00e-06) 25 | adjoint residual norm = 1.137046e-07 (-> abs. stopping tol. = 1.00e-06) 26 | number of levels = 4 27 | 28 | 29 | # Begin Test 3 30 | Objective function value = 6.75005164e-02 31 | Gradient norm = 9.95513188e-07 32 | optimization iterations = 212 33 | time steps = 256 34 | iterations = 2 35 | state residual norm = 2.584512e-10 (-> abs. stopping tol. = 1.00e-06) 36 | adjoint residual norm = 1.911118e-07 (-> abs. stopping tol. = 1.00e-06) 37 | number of levels = 2 38 | 39 | # Begin Test 4 40 | time steps = 256 41 | iterations = 5 42 | state residual norm = 1.527710e-11 (-> abs. stopping tol. = 1.00e-06) 43 | adjoint residual norm = 2.981182e-08 (-> abs. stopping tol. = 1.00e-06) 44 | number of levels = 4 45 | 46 | # Begin Test 5 47 | time steps = 256 48 | iterations = 5 49 | state residual norm = 3.055419e-10 (-> abs. stopping tol. = 1.00e-06) 50 | adjoint residual norm = 5.962363e-07 (-> abs. stopping tol. = 1.00e-06) 51 | number of levels = 4 52 | 53 | # Begin Test 6 54 | time steps = 256 55 | iterations = 5 56 | state residual norm = 3.055423e-10 (-> abs. stopping tol. = 1.00e-06) 57 | adjoint residual norm = 5.962363e-07 (-> abs. stopping tol. = 1.00e-06) 58 | number of levels = 4 59 | 60 | # Begin Test 7 61 | time steps = 256 62 | iterations = 1 63 | state residual norm = 4.132535e-03 (-> abs. stopping tol. = 1.00e-06) 64 | adjoint residual norm = 1.348736e-01 (-> abs. stopping tol. = 1.00e-06) 65 | number of levels = 4 66 | 67 | # Begin Test 8 68 | time steps = 256 69 | iterations = 1 70 | state residual norm = 4.132535e-03 (-> abs. stopping tol. = 1.00e+02) 71 | adjoint residual norm = 1.348736e-01 (-> abs. stopping tol. = 1.00e+01) 72 | number of levels = 4 73 | 74 | # Begin Test 9 75 | time steps = 256 76 | iterations = 6 77 | state residual norm = 7.239535e-13 (-> abs. stopping tol. = 1.00e-06) 78 | adjoint residual norm = 1.749810e-08 (-> abs. stopping tol. = 1.00e-06) 79 | number of levels = 3 80 | 81 | # Begin Test 10 82 | 3 3.59640284796968e-01 1.00164146520641e-02 83 | 255 6.62381806690908e-02 9.89797788690525e-07 84 | 85 | # Begin Test 11 86 | 3 4.47685578622637e-01 1.08521319818560e-03 87 | 88 | # Begin Test 12 89 | 90 | Objective = 3.308521159872e+01 91 | Gradient norm: 6.773588314090e+01 92 | 93 | # Begin Test 13 94 | 95 | Objective = 3.308521159872e+01 96 | Gradient norm: 6.773588314090e+01 97 | 98 | -------------------------------------------------------------------------------- /test/compare_examples_drivers.saved: -------------------------------------------------------------------------------- 1 | # Begin Test 0 -- here we run a comparison of ex-02 and drive-02. The first three tests compare drive-02, ex-02 and ex-02-serial, making sure that all three versions have the same discretization error when run to a very small tolerance. 2 | 3 | my_Access(): Braid iter 9, discr. error at final time: 4.2283e-03 4 | 5 | # Begin Test 1 6 | 7 | my_Access(): Braid iter 9, discr. error at final time: 4.2283e-03 8 | 9 | # Begin Test 2 10 | 11 | Discr. error at final time: 4.2283e-03 12 | 13 | # Begin Test 3 -- All subsequent tests check the discretization error after only 2 iterations, so that we can test various XBraid options. This way the printed discretization error is printed before convergence and hence `unique' to this particular option combination. 14 | 15 | my_Access(): Braid iter 2, discr. error at final time: 9.8328e-03 16 | 17 | # Begin Test 4 18 | 19 | my_Access(): Braid iter 2, discr. error at final time: 9.8328e-03 20 | 21 | # Begin Test 5 22 | 23 | my_Access(): Braid iter 2, discr. error at final time: 9.8634e-03 24 | 25 | # Begin Test 6 26 | 27 | my_Access(): Braid iter 2, discr. error at final time: 9.8634e-03 28 | 29 | # Begin Test 7 30 | 31 | my_Access(): Braid iter 2, discr. error at final time: 9.8588e-03 32 | 33 | # Begin Test 8 34 | 35 | my_Access(): Braid iter 2, discr. error at final time: 9.8588e-03 36 | 37 | # Begin Test 9 38 | 39 | my_Access(): Braid iter 2, discr. error at final time: 1.0127e-02 40 | 41 | # Begin Test 10 42 | 43 | my_Access(): Braid iter 2, discr. error at final time: 1.0127e-02 44 | 45 | # Begin Test 11 46 | 47 | my_Access(): Braid iter 2, discr. error at final time: 1.3734e-02 48 | 49 | # Begin Test 12 50 | 51 | my_Access(): Braid iter 2, discr. error at final time: 1.3734e-02 52 | 53 | # Begin Test 13 54 | 55 | my_Access(): Braid iter 2, discr. error at final time: 4.9203e-03 56 | 57 | # Begin Test 14 58 | 59 | my_Access(): Braid iter 2, discr. error at final time: 4.9203e-03 60 | 61 | # Begin Test 15 62 | 63 | my_Access(): Braid iter 2, discr. error at final time: 6.0854e-03 64 | 65 | # Begin Test 16 66 | 67 | my_Access(): Braid iter 2, discr. error at final time: 6.0854e-03 68 | 69 | # Begin Test 17 70 | 71 | my_Access(): Braid iter 2, discr. error at final time: 4.7629e-03 72 | 73 | # Begin Test 18 74 | 75 | my_Access(): Braid iter 2, discr. error at final time: 4.7629e-03 76 | 77 | # Begin Test 19 78 | 79 | my_Access(): Braid iter 2, discr. error at final time: 5.4690e-03 80 | 81 | # Begin Test 20 82 | 83 | my_Access(): Braid iter 2, discr. error at final time: 5.4690e-03 84 | 85 | # Begin Test 21 86 | 87 | my_Access(): Braid iter 2, discr. error at final time: 1.0063e-02 88 | 89 | # Begin Test 22 90 | 91 | my_Access(): Braid iter 2, discr. error at final time: 1.0063e-02 92 | 93 | # Begin Test 23 94 | 95 | my_Access(): Braid iter 3, discr. error at final time: 4.7980e-03 96 | 97 | # Begin Test 24 98 | 99 | my_Access(): Braid iter 3, discr. error at final time: 4.7980e-03 100 | 101 | # Begin Test 25 102 | 103 | my_Access(): Braid iter 2, discr. error at final time: 1.0063e-02 104 | 105 | # Begin Test 26 106 | 107 | my_Access(): Braid iter 2, discr. error at final time: 1.0063e-02 108 | 109 | # Begin Test 27 110 | 111 | my_Access(): Braid iter 2, discr. error at final time: 4.7462e-03 112 | 113 | # Begin Test 28 114 | 115 | my_Access(): Braid iter 2, discr. error at final time: 4.7462e-03 116 | 117 | # Begin Test 29 118 | 119 | my_Access(): Braid iter 2, discr. error at final time: 4.7462e-03 120 | 121 | # Begin Test 30 122 | 123 | my_Access(): Braid iter 2, discr. error at final time: 4.7462e-03 124 | 125 | # Begin Test 31 126 | 127 | my_Access(): Braid iter 2, discr. error at final time: 1.0599e-02 128 | 129 | # Begin Test 32 130 | 131 | my_Access(): Braid iter 2, discr. error at final time: 1.0599e-02 132 | 133 | # Begin Test 33 134 | 135 | my_Access(): Braid iter 2, discr. error at final time: 8.9867e-03 136 | 137 | # Begin Test 34 138 | 139 | my_Access(): Braid iter 2, discr. error at final time: 8.9867e-03 140 | 141 | # Begin Test 35 142 | 143 | my_Access(): Braid iter 2, discr. error at final time: 3.6568e-03 144 | 145 | # Begin Test 36 146 | 147 | my_Access(): Braid iter 2, discr. error at final time: 3.6568e-03 148 | 149 | # Begin Test 37 150 | 151 | my_Access(): Braid iter 2, discr. error at final time: 4.8938e-03 152 | 153 | # Begin Test 38 154 | 155 | my_Access(): Braid iter 2, discr. error at final time: 4.8938e-03 156 | 157 | # Begin Test 39 158 | 159 | my_Access(): Braid iter 2, discr. error at final time: 4.7462e-03 160 | 161 | # Begin Test 40 162 | 163 | my_Access(): Braid iter 2, discr. error at final time: 4.7462e-03 164 | 165 | -------------------------------------------------------------------------------- /test/compare_examples_drivers_storage.saved: -------------------------------------------------------------------------------- 1 | # Begin Test 0 -- here we run a comparison of ex-02 and drive-02 with storage = -1 2 | 3 | my_Access(): Braid iter 4, discr. error at final time: 4.7465e-03 4 | 5 | # Begin Test 1 6 | 7 | my_Access(): Braid iter 4, discr. error at final time: 4.7465e-03 8 | 9 | # Begin Test 2 10 | 11 | my_Access(): Braid iter 4, discr. error at final time: 4.7461e-03 12 | 13 | # Begin Test 3 14 | 15 | my_Access(): Braid iter 4, discr. error at final time: 4.7461e-03 16 | 17 | # Begin Test 4 18 | 19 | my_Access(): Braid iter 4, discr. error at final time: 4.7462e-03 20 | 21 | # Begin Test 5 22 | 23 | my_Access(): Braid iter 4, discr. error at final time: 4.7462e-03 24 | 25 | # Begin Test 6 -- here we run a comparison of ex-02 and drive-02 with storage = 0 26 | 27 | my_Access(): Braid iter 4, discr. error at final time: 4.7465e-03 28 | 29 | # Begin Test 7 30 | 31 | my_Access(): Braid iter 4, discr. error at final time: 4.7465e-03 32 | 33 | # Begin Test 8 34 | 35 | my_Access(): Braid iter 4, discr. error at final time: 4.7461e-03 36 | 37 | # Begin Test 9 38 | 39 | my_Access(): Braid iter 4, discr. error at final time: 4.7461e-03 40 | 41 | # Begin Test 10 42 | 43 | my_Access(): Braid iter 4, discr. error at final time: 4.7462e-03 44 | 45 | # Begin Test 11 46 | 47 | my_Access(): Braid iter 4, discr. error at final time: 4.7462e-03 48 | 49 | # Begin Test 12 -- here we run a comparison of ex-02 and drive-02 with storage = 1 50 | 51 | my_Access(): Braid iter 4, discr. error at final time: 4.7465e-03 52 | 53 | # Begin Test 13 54 | 55 | my_Access(): Braid iter 4, discr. error at final time: 4.7465e-03 56 | 57 | # Begin Test 14 58 | 59 | my_Access(): Braid iter 4, discr. error at final time: 4.7461e-03 60 | 61 | # Begin Test 15 62 | 63 | my_Access(): Braid iter 4, discr. error at final time: 4.7461e-03 64 | 65 | # Begin Test 16 66 | 67 | my_Access(): Braid iter 4, discr. error at final time: 4.7462e-03 68 | 69 | # Begin Test 17 70 | 71 | my_Access(): Braid iter 4, discr. error at final time: 4.7462e-03 72 | 73 | -------------------------------------------------------------------------------- /test/cython_tests.saved: -------------------------------------------------------------------------------- 1 | # Begin Test 0 2 | time steps = 10 3 | iterations = 4 4 | residual norm = 0.000000e+00 5 | max number of levels = 2 6 | number of levels = 2 7 | # Begin Test 1 8 | time steps = 10 9 | iterations = 4 10 | residual norm = 0.000000e+00 11 | max number of levels = 2 12 | number of levels = 2 13 | # Begin Test 2 14 | time steps = 60 15 | iterations = 4 16 | residual norm = 8.721079e-06 17 | max number of levels = 2 18 | number of levels = 2 19 | # Begin Test 3 20 | time steps = 60 21 | iterations = 4 22 | residual norm = 1.693387e-05 23 | max number of levels = 2 24 | number of levels = 2 25 | # Begin Test 4 26 | time steps = 60 27 | iterations = 4 28 | residual norm = 8.721079e-06 29 | max number of levels = 2 30 | number of levels = 2 31 | # Begin Test 5 32 | time steps = 60 33 | iterations = 4 34 | residual norm = 1.693387e-05 35 | max number of levels = 2 36 | number of levels = 2 37 | # Begin Test 6 38 | time steps = 60 39 | iterations = 4 40 | residual norm = 8.721079e-06 41 | max number of levels = 2 42 | number of levels = 2 43 | # Begin Test 7 44 | time steps = 60 45 | iterations = 4 46 | residual norm = 1.693387e-05 47 | max number of levels = 2 48 | number of levels = 2 49 | -------------------------------------------------------------------------------- /test/diffusion1D_check_rnorm.saved: -------------------------------------------------------------------------------- 1 | # Begin Test 0 -- begin serial tests 2 | 3 | Discretization error at final time: 1.0049e-01 4 | 5 | # Begin Test 1 6 | 7 | Discretization error at final time: 5.5581e-02 8 | 9 | # Begin Test 2 10 | 11 | Discretization error at final time: 2.9214e-02 12 | 13 | # Begin Test 3 -- begin 3-level Braid 14 | 15 | Discretization error at final time: 9.7826e-02 16 | residual norm = 6.805108e-02 17 | 18 | # Begin Test 4 19 | 20 | Discretization error at final time: 9.7826e-02 21 | residual norm = 6.760904e-02 22 | 23 | # Begin Test 5 24 | 25 | Discretization error at final time: 9.8095e-02 26 | residual norm = 6.119744e-02 27 | 28 | # Begin Test 6 -- begin 3-level Braid with FMG 29 | 30 | Discretization error at final time: 9.7817e-02 31 | residual norm = 6.816609e-02 32 | 33 | # Begin Test 7 34 | 35 | Discretization error at final time: 9.7817e-02 36 | residual norm = 6.772471e-02 37 | 38 | # Begin Test 8 39 | 40 | Discretization error at final time: 9.8086e-02 41 | residual norm = 6.130059e-02 42 | 43 | # Begin Test 9 -- begin 3-level Braid with spatial coarsening 44 | 45 | Discretization error at final time: 5.4765e-02 46 | residual norm = 1.243093e-01 47 | 48 | # Begin Test 10 49 | 50 | Discretization error at final time: 5.4976e-02 51 | residual norm = 1.167181e-01 52 | 53 | # Begin Test 11 54 | 55 | Discretization error at final time: 5.4926e-02 56 | residual norm = 1.274759e-01 57 | 58 | # Begin Test 12 -- begin 3-level Braid with sequential time stepping as initial guess 59 | 60 | Discretization error at final time: 2.9214e-02 61 | residual norm = 0.000000e+00 62 | 63 | # Begin Test 13 64 | 65 | Discretization error at final time: 2.9214e-02 66 | residual norm = 0.000000e+00 67 | 68 | # Begin Test 14 69 | 70 | Discretization error at final time: 2.9214e-02 71 | residual norm = 0.000000e+00 72 | 73 | # Begin Test 15 -- begin 3-level Braid with residual option 74 | 75 | Discretization error at final time: 3.3696e-02 76 | residual norm = 2.445729e-01 77 | 78 | # Begin Test 16 79 | 80 | Discretization error at final time: 3.3696e-02 81 | residual norm = 2.445729e-01 82 | 83 | # Begin Test 17 84 | 85 | Discretization error at final time: 3.3696e-02 86 | residual norm = 2.445729e-01 87 | 88 | # Begin Test 18 89 | 90 | Discretization error at final time: 1.0073e-01 91 | residual norm = 7.020537e-02 92 | 93 | # Begin Test 19 94 | 95 | Discretization error at final time: 1.0075e-01 96 | residual norm = 7.825136e-02 97 | 98 | # Begin Test 20 99 | 100 | Discretization error at final time: 1.0151e-01 101 | residual norm = 7.524882e-02 102 | 103 | 104 | -------------------------------------------------------------------------------- /test/diffusion1D_scaling.saved: -------------------------------------------------------------------------------- 1 | # Begin Test 0 -- Begin 2-level FCF-relaxation tests 2 | 3 | time steps = 32 4 | iterations = 6 5 | number of levels = 2 6 | 7 | # Begin Test 1 8 | 9 | time steps = 128 10 | iterations = 6 11 | number of levels = 2 12 | 13 | # Begin Test 2 14 | 15 | time steps = 512 16 | iterations = 6 17 | number of levels = 2 18 | 19 | # Begin Test 3 20 | 21 | time steps = 2048 22 | iterations = 6 23 | number of levels = 2 24 | 25 | # Begin Test 4 -- Begin multilvel-level V-cycle FCF-relaxation tests 26 | 27 | time steps = 32 28 | iterations = 6 29 | number of levels = 4 30 | 31 | # Begin Test 5 32 | 33 | time steps = 128 34 | iterations = 7 35 | number of levels = 6 36 | 37 | # Begin Test 6 38 | 39 | time steps = 512 40 | iterations = 7 41 | number of levels = 8 42 | 43 | # Begin Test 7 44 | 45 | time steps = 2048 46 | iterations = 8 47 | number of levels = 10 48 | 49 | # Begin Test 8 -- Begin multilvel-level F-cycle FCF-relaxation tests 50 | 51 | time steps = 32 52 | iterations = 6 53 | number of levels = 4 54 | 55 | # Begin Test 9 56 | 57 | time steps = 128 58 | iterations = 6 59 | number of levels = 6 60 | 61 | # Begin Test 10 62 | 63 | time steps = 512 64 | iterations = 6 65 | number of levels = 8 66 | 67 | # Begin Test 11 68 | 69 | time steps = 2048 70 | iterations = 6 71 | number of levels = 10 72 | 73 | # Begin Test 12 -- Begin 2-level F-relaxation tests 74 | 75 | time steps = 32 76 | iterations = 9 77 | number of levels = 2 78 | 79 | # Begin Test 13 80 | 81 | time steps = 128 82 | iterations = 9 83 | number of levels = 2 84 | 85 | # Begin Test 14 86 | 87 | time steps = 512 88 | iterations = 8 89 | number of levels = 2 90 | 91 | # Begin Test 15 92 | 93 | time steps = 2048 94 | iterations = 8 95 | number of levels = 2 96 | 97 | # Begin Test 16 -- Begin multilvel-level V-cycle F-relaxation tests 98 | 99 | time steps = 32 100 | iterations = 10 101 | number of levels = 4 102 | 103 | # Begin Test 17 104 | 105 | time steps = 128 106 | iterations = 15 107 | number of levels = 6 108 | 109 | # Begin Test 18 110 | 111 | time steps = 512 112 | iterations = 19 113 | number of levels = 8 114 | 115 | # Begin Test 19 116 | 117 | time steps = 2048 118 | iterations = 23 119 | number of levels = 10 120 | 121 | # Begin Test 20 -- Begin multilvel-level F-cycle F-relaxation tests 122 | 123 | time steps = 32 124 | iterations = 8 125 | number of levels = 4 126 | 127 | # Begin Test 21 128 | 129 | time steps = 128 130 | iterations = 8 131 | number of levels = 6 132 | 133 | # Begin Test 22 134 | 135 | time steps = 512 136 | iterations = 8 137 | number of levels = 8 138 | 139 | # Begin Test 23 140 | 141 | time steps = 2048 142 | iterations = 8 143 | number of levels = 10 144 | 145 | # Begin Test 24 -- Begin multilvel-level V-cycle F-relaxation with Skip tests 146 | 147 | time steps = 32 148 | iterations = 9 149 | number of levels = 4 150 | 151 | # Begin Test 25 152 | 153 | time steps = 128 154 | iterations = 9 155 | number of levels = 6 156 | 157 | # Begin Test 26 158 | 159 | time steps = 512 160 | iterations = 9 161 | number of levels = 8 162 | 163 | # Begin Test 27 164 | 165 | time steps = 2048 166 | iterations = 9 167 | number of levels = 10 168 | 169 | -------------------------------------------------------------------------------- /test/diffusion2D_check_rnorm.saved: -------------------------------------------------------------------------------- 1 | # Begin Test 0 2 | 3 | residual norm = 2.146943e-02 4 | --> 2-norm TemporalNorm 5 | 6 | # Begin Test 1 7 | 8 | residual norm = 2.146943e-02 9 | --> 2-norm TemporalNorm 10 | 11 | # Begin Test 2 12 | 13 | residual norm = 2.146943e-02 14 | --> 2-norm TemporalNorm 15 | 16 | # Begin Test 3 17 | 18 | residual norm = 2.146943e-02 19 | --> 2-norm TemporalNorm 20 | 21 | # Begin Test 4 22 | 23 | residual norm = 2.146943e-02 24 | --> 2-norm TemporalNorm 25 | 26 | # Begin Test 5 -- Next test battery 27 | 28 | residual norm = 1.066077e-02 29 | --> 2-norm TemporalNorm 30 | 31 | # Begin Test 6 32 | 33 | residual norm = 1.066077e-02 34 | --> 2-norm TemporalNorm 35 | 36 | # Begin Test 7 37 | 38 | residual norm = 1.066077e-02 39 | --> 2-norm TemporalNorm 40 | 41 | # Begin Test 8 42 | 43 | residual norm = 1.066077e-02 44 | --> 2-norm TemporalNorm 45 | 46 | # Begin Test 9 47 | 48 | residual norm = 1.066077e-02 49 | --> 2-norm TemporalNorm 50 | 51 | # Begin Test 10 -- Next test battery 52 | 53 | residual norm = 4.078268e-01 54 | --> 1-norm TemporalNorm 55 | 56 | # Begin Test 11 57 | 58 | residual norm = 4.078268e-01 59 | --> 1-norm TemporalNorm 60 | 61 | # Begin Test 12 62 | 63 | residual norm = 4.078268e-01 64 | --> 1-norm TemporalNorm 65 | 66 | # Begin Test 13 67 | 68 | residual norm = 4.078268e-01 69 | --> 1-norm TemporalNorm 70 | 71 | # Begin Test 14 72 | 73 | residual norm = 4.078268e-01 74 | --> 1-norm TemporalNorm 75 | 76 | # Begin Test 15 -- next test battery 77 | 78 | residual norm = 3.885386e-01 79 | --> Inf-norm TemporalNorm 80 | 81 | # Begin Test 16 82 | 83 | residual norm = 3.885386e-01 84 | --> Inf-norm TemporalNorm 85 | 86 | # Begin Test 17 87 | 88 | residual norm = 3.885386e-01 89 | --> Inf-norm TemporalNorm 90 | 91 | # Begin Test 18 92 | 93 | residual norm = 3.885386e-01 94 | --> Inf-norm TemporalNorm 95 | 96 | # Begin Test 19 97 | 98 | residual norm = 3.885386e-01 99 | --> Inf-norm TemporalNorm 100 | 101 | # Begin Test 20 -- next test battery 102 | 103 | residual norm = 0.000000e+00 104 | --> 2-norm TemporalNorm 105 | 106 | # Begin Test 21 107 | 108 | residual norm = 0.000000e+00 109 | --> 2-norm TemporalNorm 110 | 111 | # Begin Test 22 112 | 113 | residual norm = 0.000000e+00 114 | --> 2-norm TemporalNorm 115 | 116 | # Begin Test 23 -- Use Skip 1 117 | 118 | residual norm = 4.234270e-02 119 | --> 2-norm TemporalNorm 120 | # Begin Test 24 121 | 122 | residual norm = 4.234270e-02 123 | --> 2-norm TemporalNorm 124 | 125 | # Begin Test 25 126 | 127 | residual norm = 4.234270e-02 128 | --> 2-norm TemporalNorm 129 | 130 | # Begin Test 26 131 | 132 | residual norm = 4.234270e-02 133 | --> 2-norm TemporalNorm 134 | 135 | # Begin Test 27 136 | 137 | residual norm = 4.234270e-02 138 | --> 2-norm TemporalNorm 139 | 140 | # Begin Test 28 -- Use user residual routine 141 | 142 | residual norm = 4.427659e-02 143 | --> 2-norm TemporalNorm 144 | # Begin Test 29 145 | 146 | residual norm = 4.427659e-02 147 | --> 2-norm TemporalNorm 148 | 149 | # Begin Test 30 150 | 151 | residual norm = 4.427659e-02 152 | --> 2-norm TemporalNorm 153 | 154 | # Begin Test 31 155 | 156 | residual norm = 4.427659e-02 157 | --> 2-norm TemporalNorm 158 | 159 | # Begin Test 32 160 | 161 | residual norm = 4.427659e-02 162 | --> 2-norm TemporalNorm 163 | 164 | # Begin Test 33 -- Use full residual with user routine 165 | 166 | Braid: Full || r_1 || = 4.427659e-02, conv factor = 1.00e+00 167 | residual norm = 3.552895e-04 168 | --> 2-norm TemporalNorm 169 | # Begin Test 34 170 | 171 | Braid: Full || r_1 || = 4.427659e-02, conv factor = 1.00e+00 172 | residual norm = 3.552895e-04 173 | --> 2-norm TemporalNorm 174 | 175 | # Begin Test 35 176 | 177 | Braid: Full || r_1 || = 4.427659e-02, conv factor = 1.00e+00 178 | residual norm = 3.552895e-04 179 | --> 2-norm TemporalNorm 180 | 181 | # Begin Test 36 182 | 183 | Braid: Full || r_1 || = 4.427659e-02, conv factor = 1.00e+00 184 | residual norm = 3.552895e-04 185 | --> 2-norm TemporalNorm 186 | 187 | # Begin Test 37 188 | 189 | Braid: Full || r_1 || = 4.427659e-02, conv factor = 1.00e+00 190 | residual norm = 3.552895e-04 191 | --> 2-norm TemporalNorm 192 | 193 | -------------------------------------------------------------------------------- /test/diffusion2D_check_rnorm_storage.saved: -------------------------------------------------------------------------------- 1 | # Begin Test 0 -- Begin storage = -1 tests 2 | 3 | residual norm = 1.360860e-08 4 | --> 2-norm TemporalNorm 5 | 6 | # Begin Test 1 7 | 8 | residual norm = 1.360860e-08 9 | --> 2-norm TemporalNorm 10 | 11 | # Begin Test 2 12 | 13 | residual norm = 1.360860e-08 14 | --> 2-norm TemporalNorm 15 | 16 | # Begin Test 3 17 | 18 | residual norm = 1.239259e-10 19 | --> 2-norm TemporalNorm 20 | 21 | # Begin Test 4 22 | 23 | residual norm = 1.239259e-10 24 | --> 2-norm TemporalNorm 25 | 26 | # Begin Test 5 27 | 28 | residual norm = 1.239259e-10 29 | --> 2-norm TemporalNorm 30 | 31 | # Begin Test 6 32 | 33 | residual norm = 7.816896e-11 34 | --> 2-norm TemporalNorm 35 | 36 | # Begin Test 9 37 | 38 | residual norm = 2.812678e-09 39 | --> 2-norm TemporalNorm 40 | 41 | # Begin Test 10 42 | 43 | residual norm = 2.812678e-09 44 | --> 2-norm TemporalNorm 45 | 46 | # Begin Test 11 47 | 48 | residual norm = 2.812678e-09 49 | --> 2-norm TemporalNorm 50 | 51 | # Begin Test 12 -- Begin storage = 0 tests 52 | 53 | residual norm = 1.344434e-08 54 | --> 2-norm TemporalNorm 55 | 56 | # Begin Test 13 57 | 58 | residual norm = 1.344434e-08 59 | --> 2-norm TemporalNorm 60 | 61 | # Begin Test 14 62 | 63 | residual norm = 1.344434e-08 64 | --> 2-norm TemporalNorm 65 | 66 | # Begin Test 18 67 | 68 | residual norm = 2.856378e-10 69 | --> 2-norm TemporalNorm 70 | 71 | # Begin Test 19 72 | 73 | residual norm = 2.856376e-10 74 | --> 2-norm TemporalNorm 75 | 76 | # Begin Test 21 77 | 78 | residual norm = 2.440768e-09 79 | --> 2-norm TemporalNorm 80 | 81 | # Begin Test 22 82 | 83 | residual norm = 2.440768e-09 84 | --> 2-norm TemporalNorm 85 | 86 | # Begin Test 23 87 | 88 | residual norm = 2.440768e-09 89 | --> 2-norm TemporalNorm 90 | 91 | # Begin Test 24 -- Begin storage = 1 tests 92 | residual norm = 1.361100e-08 93 | --> 2-norm TemporalNorm 94 | 95 | # Begin Test 25 96 | 97 | residual norm = 1.361100e-08 98 | --> 2-norm TemporalNorm 99 | 100 | # Begin Test 26 101 | 102 | residual norm = 1.361100e-08 103 | --> 2-norm TemporalNorm 104 | # Begin Test 33 105 | 106 | residual norm = 2.329103e-09 107 | --> 2-norm TemporalNorm 108 | 109 | # Begin Test 34 110 | 111 | residual norm = 2.329103e-09 112 | --> 2-norm TemporalNorm 113 | 114 | # Begin Test 35 115 | 116 | residual norm = 2.329103e-09 117 | --> 2-norm TemporalNorm 118 | 119 | -------------------------------------------------------------------------------- /test/diffusion2D_scaling.saved: -------------------------------------------------------------------------------- 1 | # Begin Test 0 -- Begin 2-level FCF-relaxation tests 2 | 3 | my_Access() called, iter= 7, level= 0, calling function= 3 4 | time steps = 32 5 | iterations = 7 6 | number of levels = 2 7 | Fine level spatial problem size : 17 x 17 8 | 9 | # Begin Test 1 10 | 11 | my_Access() called, iter= 7, level= 0, calling function= 3 12 | time steps = 128 13 | iterations = 7 14 | number of levels = 2 15 | Fine level spatial problem size : 33 x 33 16 | 17 | # Begin Test 2 18 | 19 | my_Access() called, iter= 7, level= 0, calling function= 3 20 | time steps = 512 21 | iterations = 7 22 | number of levels = 2 23 | Fine level spatial problem size : 65 x 65 24 | 25 | # Begin Test 3 -- Begin multilvel-level V-cycle FCF-relaxation tests 26 | 27 | my_Access() called, iter= 7, level= 0, calling function= 3 28 | time steps = 32 29 | iterations = 7 30 | number of levels = 4 31 | Fine level spatial problem size : 17 x 17 32 | 33 | # Begin Test 4 34 | 35 | my_Access() called, iter= 8, level= 0, calling function= 3 36 | time steps = 128 37 | iterations = 8 38 | number of levels = 6 39 | Fine level spatial problem size : 33 x 33 40 | 41 | # Begin Test 5 42 | 43 | my_Access() called, iter= 9, level= 0, calling function= 3 44 | time steps = 512 45 | iterations = 9 46 | number of levels = 8 47 | Fine level spatial problem size : 65 x 65 48 | 49 | # Begin Test 6 -- Begin multilvel-level F-cycle FCF-relaxation tests 50 | 51 | my_Access() called, iter= 7, level= 0, calling function= 3 52 | time steps = 32 53 | iterations = 7 54 | number of levels = 4 55 | Fine level spatial problem size : 17 x 17 56 | 57 | # Begin Test 7 58 | 59 | my_Access() called, iter= 7, level= 0, calling function= 3 60 | time steps = 128 61 | iterations = 7 62 | number of levels = 6 63 | Fine level spatial problem size : 33 x 33 64 | 65 | # Begin Test 8 66 | 67 | my_Access() called, iter= 7, level= 0, calling function= 3 68 | time steps = 512 69 | iterations = 7 70 | number of levels = 8 71 | Fine level spatial problem size : 65 x 65 72 | 73 | # Begin Test 9-- Begin 2-level F-relaxation tests 74 | 75 | my_Access() called, iter= 10, level= 0, calling function= 3 76 | time steps = 32 77 | iterations = 10 78 | number of levels = 2 79 | Fine level spatial problem size : 17 x 17 80 | 81 | # Begin Test 10 82 | 83 | my_Access() called, iter= 10, level= 0, calling function= 3 84 | time steps = 128 85 | iterations = 10 86 | number of levels = 2 87 | Fine level spatial problem size : 33 x 33 88 | 89 | # Begin Test 11 90 | 91 | my_Access() called, iter= 10, level= 0, calling function= 3 92 | time steps = 512 93 | iterations = 10 94 | number of levels = 2 95 | Fine level spatial problem size : 65 x 65 96 | 97 | # Begin Test 12-- Begin multilvel-level V-cycle F-relaxation tests 98 | 99 | my_Access() called, iter= 11, level= 0, calling function= 3 100 | time steps = 32 101 | iterations = 11 102 | number of levels = 4 103 | Fine level spatial problem size : 17 x 17 104 | 105 | # Begin Test 13 106 | 107 | my_Access() called, iter= 17, level= 0, calling function= 3 108 | time steps = 128 109 | iterations = 17 110 | number of levels = 6 111 | Fine level spatial problem size : 33 x 33 112 | 113 | # Begin Test 14 114 | 115 | my_Access() called, iter= 22, level= 0, calling function= 3 116 | time steps = 512 117 | iterations = 22 118 | number of levels = 8 119 | Fine level spatial problem size : 65 x 65 120 | 121 | # Begin Test 15 -- Begin multilvel-level F-cycle F-relaxation tests 122 | 123 | my_Access() called, iter= 10, level= 0, calling function= 3 124 | time steps = 32 125 | iterations = 10 126 | number of levels = 4 127 | Fine level spatial problem size : 17 x 17 128 | 129 | # Begin Test 16 130 | 131 | my_Access() called, iter= 10, level= 0, calling function= 3 132 | time steps = 128 133 | iterations = 10 134 | number of levels = 6 135 | Fine level spatial problem size : 33 x 33 136 | 137 | # Begin Test 17 138 | 139 | my_Access() called, iter= 10, level= 0, calling function= 3 140 | time steps = 512 141 | iterations = 10 142 | number of levels = 8 143 | Fine level spatial problem size : 65 x 65 144 | 145 | # Begin Test 18 -- Begin multilvel-level V-cycle, FCF-relaxation Skip=1 tests 146 | 147 | my_Access() called, iter= 5, level= 0, calling function= 3 148 | time steps = 32 149 | iterations = 5 150 | number of levels = 4 151 | Fine level spatial problem size : 17 x 17 152 | 153 | # Begin Test 19 154 | 155 | my_Access() called, iter= 5, level= 0, calling function= 3 156 | time steps = 128 157 | iterations = 5 158 | number of levels = 6 159 | Fine level spatial problem size : 33 x 33 160 | 161 | # Begin Test 20 162 | 163 | my_Access() called, iter= 4, level= 0, calling function= 3 164 | time steps = 512 165 | iterations = 4 166 | number of levels = 8 167 | Fine level spatial problem size : 65 x 65 168 | 169 | -------------------------------------------------------------------------------- /test/diffusion2D_storage.saved: -------------------------------------------------------------------------------- 1 | # Begin Test 0 -- Begin storage = -1 2 | 3 | my_Access() called, iter= 9, level= 0, calling function= 3 4 | time steps = 256 5 | iterations = 9 6 | number of levels = 7 7 | Fine level spatial problem size : 17 x 17 8 | 9 | # Begin Test 1 10 | 11 | my_Access() called, iter= 8, level= 0, calling function= 3 12 | time steps = 256 13 | iterations = 8 14 | number of levels = 7 15 | Fine level spatial problem size : 17 x 17 16 | 17 | # Begin Test 2 18 | 19 | my_Access() called, iter= 7, level= 0, calling function= 3 20 | time steps = 256 21 | iterations = 7 22 | number of levels = 7 23 | Fine level spatial problem size : 17 x 17 24 | 25 | # Begin Test 3 26 | 27 | my_Access() called, iter= 4, level= 0, calling function= 3 28 | time steps = 256 29 | iterations = 4 30 | number of levels = 7 31 | Fine level spatial problem size : 17 x 17 32 | 33 | # Begin Test 4 34 | 35 | my_Access() called, iter= 11, level= 0, calling function= 3 36 | time steps = 256 37 | iterations = 11 38 | number of levels = 7 39 | Fine level spatial problem size : 17 x 17 40 | 41 | # Begin Test 5 42 | 43 | my_Access() called, iter= 11, level= 0, calling function= 3 44 | time steps = 256 45 | iterations = 11 46 | number of levels = 7 47 | Fine level spatial problem size : 17 x 17 48 | 49 | # Begin Test 6 50 | 51 | my_Access() called, iter= 9, level= 0, calling function= 3 52 | time steps = 256 53 | iterations = 9 54 | number of levels = 8 55 | Fine level spatial problem size : 17 x 17 56 | 57 | # Begin Test 7 58 | 59 | my_Access() called, iter= 9, level= 0, calling function= 3 60 | time steps = 256 61 | iterations = 9 62 | number of levels = 4 63 | Fine level spatial problem size : 17 x 17 64 | 65 | # Begin Test 8 -- Begin storage = 0 66 | 67 | my_Access() called, iter= 9, level= 0, calling function= 3 68 | time steps = 256 69 | iterations = 9 70 | number of levels = 7 71 | Fine level spatial problem size : 17 x 17 72 | 73 | # Begin Test 9 74 | 75 | my_Access() called, iter= 8, level= 0, calling function= 3 76 | time steps = 256 77 | iterations = 8 78 | number of levels = 7 79 | Fine level spatial problem size : 17 x 17 80 | 81 | # Begin Test 10 82 | 83 | my_Access() called, iter= 7, level= 0, calling function= 3 84 | time steps = 256 85 | iterations = 7 86 | number of levels = 7 87 | Fine level spatial problem size : 17 x 17 88 | 89 | # Begin Test 11 90 | 91 | my_Access() called, iter= 4, level= 0, calling function= 3 92 | time steps = 256 93 | iterations = 4 94 | number of levels = 7 95 | Fine level spatial problem size : 17 x 17 96 | 97 | # Begin Test 12 98 | 99 | my_Access() called, iter= 11, level= 0, calling function= 3 100 | time steps = 256 101 | iterations = 11 102 | number of levels = 7 103 | Fine level spatial problem size : 17 x 17 104 | 105 | # Begin Test 13 106 | 107 | my_Access() called, iter= 11, level= 0, calling function= 3 108 | time steps = 256 109 | iterations = 11 110 | number of levels = 7 111 | Fine level spatial problem size : 17 x 17 112 | 113 | # Begin Test 14 114 | 115 | my_Access() called, iter= 9, level= 0, calling function= 3 116 | time steps = 256 117 | iterations = 9 118 | number of levels = 8 119 | Fine level spatial problem size : 17 x 17 120 | 121 | # Begin Test 15 122 | 123 | my_Access() called, iter= 9, level= 0, calling function= 3 124 | time steps = 256 125 | iterations = 9 126 | number of levels = 4 127 | Fine level spatial problem size : 17 x 17 128 | 129 | # Begin Test 16 -- Begin storage = 1 tests 130 | 131 | my_Access() called, iter= 9, level= 0, calling function= 3 132 | time steps = 256 133 | iterations = 9 134 | number of levels = 7 135 | Fine level spatial problem size : 17 x 17 136 | 137 | # Begin Test 17 138 | 139 | my_Access() called, iter= 8, level= 0, calling function= 3 140 | time steps = 256 141 | iterations = 8 142 | number of levels = 7 143 | Fine level spatial problem size : 17 x 17 144 | 145 | # Begin Test 18 146 | 147 | my_Access() called, iter= 7, level= 0, calling function= 3 148 | time steps = 256 149 | iterations = 7 150 | number of levels = 7 151 | Fine level spatial problem size : 17 x 17 152 | 153 | # Begin Test 19 154 | 155 | my_Access() called, iter= 4, level= 0, calling function= 3 156 | time steps = 256 157 | iterations = 4 158 | number of levels = 7 159 | Fine level spatial problem size : 17 x 17 160 | 161 | # Begin Test 20 162 | 163 | my_Access() called, iter= 11, level= 0, calling function= 3 164 | time steps = 256 165 | iterations = 11 166 | number of levels = 7 167 | Fine level spatial problem size : 17 x 17 168 | 169 | # Begin Test 21 170 | 171 | my_Access() called, iter= 11, level= 0, calling function= 3 172 | time steps = 256 173 | iterations = 11 174 | number of levels = 7 175 | Fine level spatial problem size : 17 x 17 176 | 177 | # Begin Test 22 178 | 179 | my_Access() called, iter= 9, level= 0, calling function= 3 180 | time steps = 256 181 | iterations = 9 182 | number of levels = 8 183 | Fine level spatial problem size : 17 x 17 184 | 185 | # Begin Test 23 186 | 187 | my_Access() called, iter= 9, level= 0, calling function= 3 188 | time steps = 256 189 | iterations = 9 190 | number of levels = 4 191 | Fine level spatial problem size : 17 x 17 192 | 193 | -------------------------------------------------------------------------------- /test/docs.saved: -------------------------------------------------------------------------------- 1 | # Begin Test 0, this is blank because there should be no lines containing Error or error 2 | 3 | 4 | # Begin Test 1 5 | 6 | docs/developermanual.pdf is appropriately sized 7 | 8 | # Begin Test 2, this is blank because there should be no lines containing Error or error 9 | 10 | 11 | # Begin Test 3 12 | 13 | docs/usermanual.pdf is appropriately sized 14 | 15 | 16 | -------------------------------------------------------------------------------- /test/docs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #BHEADER********************************************************************** 3 | # 4 | # Copyright (c) 2013, Lawrence Livermore National Security, LLC. 5 | # Produced at the Lawrence Livermore National Laboratory. Written by 6 | # Jacob Schroder, Rob Falgout, Tzanio Kolev, Ulrike Yang, Veselin 7 | # Dobrev, et al. LLNL-CODE-660355. All rights reserved. 8 | # 9 | # This file is part of XBraid. For support, post issues to the XBraid Github page. 10 | # 11 | # This program is free software; you can redistribute it and/or modify it under 12 | # the terms of the GNU General Public License (as published by the Free Software 13 | # Foundation) version 2.1 dated February 1999. 14 | # 15 | # This program is distributed in the hope that it will be useful, but WITHOUT ANY 16 | # WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A 17 | # PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public 18 | # License for more details. 19 | # 20 | # You should have received a copy of the GNU Lesser General Public License along 21 | # with this program; if not, write to the Free Software Foundation, Inc., 59 22 | # Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 | # 24 | #EHEADER********************************************************************** 25 | 26 | # scriptname holds the script name, with the .sh removed 27 | scriptname=`basename $0 .sh` 28 | 29 | # Echo usage information 30 | case $1 in 31 | -h|-help) 32 | cat <> $output_dir/unfiltered.std.out.$counter 2>> $output_dir/std.err.$counter 108 | cd $output_dir 109 | egrep -o "$lines_to_check" unfiltered.std.out.$counter | egrep -v "$lines_to_ignore" > std.out.$counter 110 | diff -U3 -B -bI"$TestDelimiter" $scriptname.saved.$counter std.out.$counter >> std.err.$counter 111 | cd $test_dir 112 | counter=$(( $counter + 1 )) 113 | done 114 | 115 | # Echo to stderr all nonempty error files in $output_dir. test.sh 116 | # collects these file names and puts them in the error report 117 | for errfile in $( find $output_dir ! -size 0 -name "*.err.*" ) 118 | do 119 | echo $errfile >&2 120 | done 121 | 122 | -------------------------------------------------------------------------------- /test/lorenz_delta.saved: -------------------------------------------------------------------------------- 1 | # Begin Test 0 2 | 3 | braid_TestSpatialNorm: Test 1 Passed 4 | braid_TestSpatialNorm: Test 2 Passed 5 | braid_TestSpatialNorm: Test 3 Passed 6 | Finished braid_TestSpatialNorm: all tests passed successfully 7 | braid_TestBuf: Test 1 Passed 8 | Finished braid_TestBuf: all tests passed successfully 9 | braid_TestInnerProd: Test 1 Passed 10 | braid_TestInitBasis: Test 2 Passed 11 | braid_TestBufBasis: Test 1 Passed 12 | braid_TestBufBasis: Test 2 Passed 13 | 14 | # Begin Test 1 15 | 16 | residual norm = 1.644808e-05 17 | 18 | # Begin Test 2 19 | 20 | residual norm = 9.050928e-06 21 | Average Lyapunov Exponents: [0.008363] 22 | 23 | # Begin Test 3 24 | 25 | residual norm = 5.292711e-05 26 | Average Lyapunov Exponents: [0.008363, -0.417301] 27 | 28 | # Begin Test 4 29 | 30 | residual norm = 1.881353e-06 31 | Average Lyapunov Exponents: [0.008363, -0.417301, -13.208420] 32 | 33 | # Begin Test 5 34 | 35 | residual norm = 5.667689e-05 36 | Average Lyapunov Exponents: [0.008366] 37 | 38 | # Begin Test 6 39 | 40 | residual norm = 5.161799e-05 41 | Average Lyapunov Exponents: [0.008363, -0.417300] 42 | 43 | # Begin Test 7 44 | 45 | residual norm = 2.395636e-06 46 | Average Lyapunov Exponents: [0.008363, -0.417301, -13.208420] 47 | 48 | # Begin Test 8 49 | 50 | residual norm = 1.317903e-05 51 | 52 | # Begin Test 9 53 | 54 | residual norm = 5.455146e-05 55 | Average Lyapunov Exponents: [0.008367] 56 | 57 | # Begin Test 10 58 | 59 | residual norm = 5.100602e-05 60 | Average Lyapunov Exponents: [0.008362, -0.417300] 61 | 62 | # Begin Test 11 63 | 64 | residual norm = 5.100602e-05 65 | Average Lyapunov Exponents: [0.008362, -0.417300] 66 | 67 | # Begin Test 12 68 | 69 | residual norm = 4.301596e-06 70 | Average Lyapunov Exponents: [0.008363, -0.417301, -13.208420] 71 | 72 | # Begin Test 13 73 | 74 | residual norm = 6.612330e-05 75 | Average Lyapunov Exponents: [0.000000] 76 | 77 | # Begin Test 14 78 | 79 | residual norm = 4.859796e-05 80 | Average Lyapunov Exponents: [0.000000, 0.000000] 81 | 82 | # Begin Test 15 83 | 84 | residual norm = 6.134727e-05 85 | Average Lyapunov Exponents: [0.000000, 0.000000, 0.000000] 86 | 87 | # Begin Test 16 88 | 89 | residual norm = 2.857796e+00 90 | Average Lyapunov Exponents: [-0.715693] 91 | 92 | # Begin Test 17 93 | 94 | residual norm = 3.066251e+00 95 | Average Lyapunov Exponents: [-0.035072, -0.322583] 96 | 97 | # Begin Test 18 98 | 99 | residual norm = 1.478867e+00 100 | Average Lyapunov Exponents: [-0.004943, -0.401681, -13.209429] 101 | 102 | # Begin Test 19 103 | 104 | residual norm = 1.406401e-05 105 | Average Lyapunov Exponents: [0.008355] 106 | 107 | # Begin Test 20 108 | 109 | residual norm = 7.675146e-05 110 | Average Lyapunov Exponents: [0.263353, -3.731620] 111 | 112 | # Begin Test 21 113 | 114 | residual norm = 4.301596e-06 115 | Average Lyapunov Exponents: [0.000000, 0.000000, 0.000000] 116 | 117 | # Begin Test 22 118 | 119 | residual norm = 4.301596e-06 120 | Average Lyapunov Exponents: [-8.416132, -1.601542, -3.599683] 121 | 122 | -------------------------------------------------------------------------------- /test/machine-mac.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #BHEADER********************************************************************** 3 | # 4 | # Copyright (c) 2013, Lawrence Livermore National Security, LLC. 5 | # Produced at the Lawrence Livermore National Laboratory. Written by 6 | # Jacob Schroder, Rob Falgout, Tzanio Kolev, Ulrike Yang, Veselin 7 | # Dobrev, et al. LLNL-CODE-660355. All rights reserved. 8 | # 9 | # This file is part of XBraid. For support, post issues to the XBraid Github page. 10 | # 11 | # This program is free software; you can redistribute it and/or modify it under 12 | # the terms of the GNU General Public License (as published by the Free Software 13 | # Foundation) version 2.1 dated February 1999. 14 | # 15 | # This program is distributed in the hope that it will be useful, but WITHOUT ANY 16 | # WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A 17 | # PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public 18 | # License for more details. 19 | # 20 | # You should have received a copy of the GNU Lesser General Public License along 21 | # with this program; if not, write to the Free Software Foundation, Inc., 59 22 | # Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 | # 24 | #EHEADER********************************************************************** 25 | 26 | testname=`basename $0 .sh` 27 | 28 | # OPENMPI, Mac High Sierra issue fixed by this (regarding max filename lengths) 29 | export TMPDIR=/tmp 30 | 31 | # Echo usage information 32 | case $1 in 33 | -h|-help) 34 | cat <&2 96 | done 97 | 98 | -------------------------------------------------------------------------------- /test/machine-tux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #BHEADER********************************************************************** 3 | # 4 | # Copyright (c) 2013, Lawrence Livermore National Security, LLC. 5 | # Produced at the Lawrence Livermore National Laboratory. Written by 6 | # Jacob Schroder, Rob Falgout, Tzanio Kolev, Ulrike Yang, Veselin 7 | # Dobrev, et al. LLNL-CODE-660355. All rights reserved. 8 | # 9 | # This file is part of XBraid. For support, post issues to the XBraid Github page. 10 | # 11 | # This program is free software; you can redistribute it and/or modify it under 12 | # the terms of the GNU General Public License (as published by the Free Software 13 | # Foundation) version 2.1 dated February 1999. 14 | # 15 | # This program is distributed in the hope that it will be useful, but WITHOUT ANY 16 | # WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A 17 | # PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public 18 | # License for more details. 19 | # 20 | # You should have received a copy of the GNU Lesser General Public License along 21 | # with this program; if not, write to the Free Software Foundation, Inc., 59 22 | # Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 | # 24 | #EHEADER********************************************************************** 25 | 26 | testname=`basename $0 .sh` 27 | 28 | # Echo usage information 29 | case $1 in 30 | -h|-help) 31 | cat <&2 92 | done 93 | 94 | -------------------------------------------------------------------------------- /test/memcheck-tux-jacob.saved: -------------------------------------------------------------------------------- 1 | # Begin Test 0, check iterations to make sure test ran to completion 2 | 3 | time steps = 30 4 | iterations = 7 5 | number of levels = 4 6 | Fine level spatial problem size : 17 x 17 7 | 8 | # Begin Test 1 9 | 10 | time steps = 30 11 | iterations = 4 12 | number of levels = 4 13 | Fine level spatial problem size : 17 x 17 14 | 15 | # Begin Test 2 16 | 17 | time steps = 30 18 | iterations = 4 19 | number of levels = 4 20 | Fine level spatial problem size : 17 x 17 21 | 22 | # Begin Test 3 23 | 24 | time steps = 30 25 | iterations = 7 26 | number of levels = 4 27 | Fine level spatial problem size : 17 x 17 28 | 29 | # Begin Test 4 30 | 31 | time steps = 30 32 | iterations = 6 33 | number of levels = 5 34 | Fine level spatial problem size : 17 x 17 35 | 36 | # Begin Test 5 37 | 38 | time steps = 32 39 | iterations = 16 40 | number of levels = 4 41 | Fine level spatial problem size : 17 x 17 42 | 43 | # Begin Test 6 44 | 45 | time steps = 32 46 | iterations = 17 47 | number of levels = 4 48 | Fine level spatial problem size : 17 x 17 49 | 50 | # Begin Test 7 51 | 52 | time steps = 32 53 | iterations = 17 54 | number of levels = 4 55 | Fine level spatial problem size : 17 x 17 56 | 57 | # Begin Test 8 58 | 59 | time steps = 32 60 | iterations = 17 61 | number of levels = 4 62 | Fine level spatial problem size : 17 x 17 63 | 64 | # Begin Test 9 65 | 66 | time steps = 32 67 | iterations = 5 68 | number of levels = 2 69 | Fine level spatial problem size : 17 x 17 70 | 71 | # Begin Test 10 72 | 73 | time steps = 33 74 | iterations = 4 75 | number of levels = 2 76 | Fine level spatial problem size : 17 x 17 77 | 78 | 79 | # Begin Test 11 80 | 81 | time steps = 33 82 | iterations = 5 83 | number of levels = 2 84 | Fine level spatial problem size : 17 x 17 85 | 86 | # Begin Test 12 87 | 88 | time steps = 33 89 | iterations = 5 90 | number of levels = 2 91 | Fine level spatial problem size : 17 x 17 92 | 93 | # Begin Test 13 94 | 95 | time steps = 33 96 | iterations = 8 97 | number of levels = 2 98 | Fine level spatial problem size : 17 x 17 99 | 100 | # Begin Test 14 101 | 102 | time steps = 33 103 | iterations = 9 104 | number of levels = 2 105 | Fine level spatial problem size : 17 x 17 106 | 107 | # Begin Test 15 108 | 109 | time steps = 33 110 | iterations = 8 111 | number of levels = 2 112 | Fine level spatial problem size : 17 x 17 113 | 114 | # Begin Test 16 115 | 116 | time steps = 33 117 | iterations = 9 118 | number of levels = 2 119 | Fine level spatial problem size : 17 x 17 120 | 121 | # Begin Test 17 122 | 123 | time steps = 33 124 | iterations = 5 125 | number of levels = 2 126 | Fine level spatial problem size : 17 x 17 127 | 128 | 129 | -------------------------------------------------------------------------------- /test/mfem.saved: -------------------------------------------------------------------------------- 1 | # Begin Test 0 -- begin drive-04 tests 2 | 3 | residual norm = 1.883438e-01 4 | --> 2-norm TemporalNorm 5 | 6 | # Begin Test 1 7 | 8 | residual norm = 4.681397e-03 9 | --> 2-norm TemporalNorm 10 | # Begin Test 2 11 | 12 | residual norm = 3.625431e-03 13 | --> 2-norm TemporalNorm 14 | # Begin Test 3 15 | 16 | residual norm = 1.308094e-02 17 | --> 2-norm TemporalNorm 18 | 19 | # Begin Test 4 -- begin drive-05 tests 20 | 21 | residual norm = 2.893465e-09 22 | --> 2-norm TemporalNorm 23 | 24 | # Begin Test 5 25 | 26 | residual norm = 8.063392e-09 27 | --> 2-norm TemporalNorm 28 | # Begin Test 6 29 | 30 | residual norm = 5.510044e-02 31 | --> 2-norm TemporalNorm 32 | # Begin Test 7 33 | 34 | residual norm = 1.780673e-01 35 | --> 2-norm TemporalNorm 36 | 37 | # Begin Test 8 -- begin drive-06 tests 38 | 39 | residual norm = 1.276562e+00 40 | --> 2-norm TemporalNorm 41 | 42 | # Begin Test 9 43 | 44 | residual norm = 1.934515e-04 45 | --> 2-norm TemporalNorm 46 | # Begin Test 10 47 | 48 | residual norm = 1.311035e+01 49 | --> 2-norm TemporalNorm 50 | # Begin Test 11 51 | 52 | residual norm = 1.340509e+01 53 | --> 2-norm TemporalNorm 54 | 55 | # Begin Test 12 -- begin drive-07 tests 56 | 57 | residual norm = 1.719625e+00 58 | --> 2-norm TemporalNorm 59 | 60 | # Begin Test 13 61 | 62 | residual norm = 2.742507e-01 63 | --> 2-norm TemporalNorm 64 | # Begin Test 14 65 | 66 | residual norm = 6.126119e-01 67 | --> 2-norm TemporalNorm 68 | # Begin Test 15 69 | 70 | residual norm = 1.121219e+00 71 | --> 2-norm TemporalNorm 72 | 73 | -------------------------------------------------------------------------------- /test/shellvector_bdf2.saved: -------------------------------------------------------------------------------- 1 | # Begin Test 0 2 | 3 | time steps = 50 4 | iterations = 4 5 | residual norm = 6.064817e-06 6 | number of levels = 2 7 | 8 | # Begin Test 1 9 | 10 | time steps = 50 11 | iterations = 7 12 | residual norm = 4.729810e-11 13 | number of levels = 2 14 | 15 | # Begin Test 2 16 | 17 | time steps = 5000 18 | iterations = 2 19 | residual norm = 4.974946e-06 20 | number of levels = 2 21 | 22 | # Begin Test 3 23 | 24 | time steps = 5000 25 | iterations = 3 26 | residual norm = 3.276738e-11 27 | number of levels = 2 28 | 29 | 30 | -------------------------------------------------------------------------------- /test/shellvector_bdf2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #BHEADER********************************************************************** 3 | # 4 | # Copyright (c) 2013, Lawrence Livermore National Security, LLC. 5 | # Produced at the Lawrence Livermore National Laboratory. Written by 6 | # Jacob Schroder, Rob Falgout, Tzanio Kolev, Ulrike Yang, Veselin 7 | # Dobrev, et al. LLNL-CODE-660355. All rights reserved. 8 | # 9 | # This file is part of XBraid. For support, post issues to the XBraid Github page. 10 | # 11 | # This program is free software; you can redistribute it and/or modify it under 12 | # the terms of the GNU General Public License (as published by the Free Software 13 | # Foundation) version 2.1 dated February 1999. 14 | # 15 | # This program is distributed in the hope that it will be useful, but WITHOUT ANY 16 | # WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A 17 | # PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public 18 | # License for more details. 19 | # 20 | # You should have received a copy of the GNU Lesser General Public License along 21 | # with this program; if not, write to the Free Software Foundation, Inc., 59 22 | # Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 | # 24 | #EHEADER********************************************************************** 25 | 26 | # scriptname holds the script name, with the .sh removed 27 | scriptname=`basename $0 .sh` 28 | 29 | # Echo usage information 30 | case $1 in 31 | -h|-help) 32 | cat < $MACHINES_FILE 56 | fi 57 | RunString="mpirun -machinefile $MACHINES_FILE $*" 58 | csplitcommand="csplit" 59 | ;; 60 | Darwin*) 61 | csplitcommand="gcsplit" 62 | RunString="mpirun --hostfile ~/.machinefile_mac" 63 | ;; 64 | *) 65 | RunString="mpirun" 66 | csplitcommand="csplit" 67 | ;; 68 | esac 69 | 70 | 71 | # Setup 72 | example_dir="../examples" 73 | driver_dir="../drivers" 74 | test_dir=`pwd` 75 | output_dir=`pwd`/$scriptname.dir 76 | rm -fr $output_dir 77 | mkdir -p $output_dir 78 | 79 | 80 | # compile the regression test drivers 81 | echo "Compiling regression test drivers" 82 | cd $example_dir 83 | make clean 84 | make ex-01-expanded-bdf2 85 | cd $test_dir 86 | 87 | 88 | # Run the following regression tests 89 | TESTS=( "$RunString -np 4 $example_dir/ex-01-expanded-bdf2 -cf 2 -ntime 100 -tol 1e-5 -ac 0" \ 90 | "$RunString -np 4 $example_dir/ex-01-expanded-bdf2 -cf 2 -ntime 100 -tol 1e-10 -ac 1" \ 91 | "$RunString -np 4 $example_dir/ex-01-expanded-bdf2 -cf 10 -ntime 10000 -tol 1e-5 -ac 2" \ 92 | "$RunString -np 4 $example_dir/ex-01-expanded-bdf2 -cf 10 -ntime 10000 -tol 1e-10 -ac 3" ) 93 | 94 | # The below commands will then dump each of the tests to the output files 95 | # $output_dir/unfiltered.std.out.0, 96 | # $output_dir/std.out.0, 97 | # $output_dir/std.err.0, 98 | # 99 | # $output_dir/unfiltered.std.out.1, 100 | # $output_dir/std.out.1, 101 | # $output_dir/std.err.1, 102 | # ... 103 | # 104 | # The unfiltered output is the direct output of the script, whereas std.out.* 105 | # is filtered by a grep for the lines that are to be checked. 106 | # 107 | lines_to_check="^ time steps.*|^ number of levels.*|^ iterations.*|^ residual norm.*|^Number of calls to my_Access.*" 108 | # 109 | # Then, each std.out.num is compared against stored correct output in 110 | # $scriptname.saved.num, which is generated by splitting $scriptname.saved 111 | # 112 | TestDelimiter='# Begin Test' 113 | $csplitcommand -n 1 --silent --prefix $output_dir/$scriptname.saved. $scriptname.saved "%$TestDelimiter%" "/$TestDelimiter.*/" {*} 114 | # 115 | # The result of that diff is appended to std.err.num. 116 | 117 | # Run regression tests 118 | counter=0 119 | for test in "${TESTS[@]}" 120 | do 121 | echo "Running Test $counter" 122 | eval "$test" 1>> $output_dir/unfiltered.std.out.$counter 2>> $output_dir/std.out.$counter 123 | cd $output_dir 124 | egrep -o "$lines_to_check" unfiltered.std.out.$counter > std.out.$counter 125 | diff -U3 -B -bI"$TestDelimiter" $scriptname.saved.$counter std.out.$counter >> std.err.$counter 126 | cd $test_dir 127 | counter=$(( $counter + 1 )) 128 | done 129 | 130 | 131 | # Additional tests can go here comparing the output from individual tests, 132 | # e.g., two different std.out.* files from identical runs with different 133 | # processor layouts could be identical ... 134 | 135 | 136 | # Echo to stderr all nonempty error files in $output_dir. test.sh 137 | # collects these file names and puts them in the error report 138 | for errfile in $( find $output_dir ! -size 0 -name "*.err.*" ) 139 | do 140 | echo $errfile >&2 141 | done 142 | 143 | 144 | # remove machinefile, if created, and output files 145 | if [ -n $MACHINES_FILE ] ; then 146 | rm $MACHINES_FILE 2> /dev/null 147 | fi 148 | rm braid.out.cycle 2> /dev/null 149 | rm braid_timings.* 2> /dev/null 150 | rm ex-01*.out.* 2> /dev/null 151 | -------------------------------------------------------------------------------- /test/test-checkout-compile.saved: -------------------------------------------------------------------------------- 1 | # Begin Test 0, check that the git pull returned 0 2 | Git return status is 0 3 | 4 | # Begin Test 1, this is blank because make error messages should be found 5 | 6 | # Begin Test 2, this is blank because make error messages should be found 7 | 8 | -------------------------------------------------------------------------------- /test/test-checkout-compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #BHEADER********************************************************************** 3 | # 4 | # Copyright (c) 2013, Lawrence Livermore National Security, LLC. 5 | # Produced at the Lawrence Livermore National Laboratory. Written by 6 | # Jacob Schroder, Rob Falgout, Tzanio Kolev, Ulrike Yang, Veselin 7 | # Dobrev, et al. LLNL-CODE-660355. All rights reserved. 8 | # 9 | # This file is part of XBraid. For support, post issues to the XBraid Github page. 10 | # 11 | # This program is free software; you can redistribute it and/or modify it under 12 | # the terms of the GNU General Public License (as published by the Free Software 13 | # Foundation) version 2.1 dated February 1999. 14 | # 15 | # This program is distributed in the hope that it will be useful, but WITHOUT ANY 16 | # WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A 17 | # PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public 18 | # License for more details. 19 | # 20 | # You should have received a copy of the GNU Lesser General Public License along 21 | # with this program; if not, write to the Free Software Foundation, Inc., 59 22 | # Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 | # 24 | #EHEADER********************************************************************** 25 | 26 | # scriptname holds the script name, with the .sh removed 27 | scriptname=`basename $0 .sh` 28 | 29 | # Echo usage information 30 | case $1 in 31 | -h|-help) 32 | cat <> $output_dir/unfiltered.std.out.$counter 2>> $output_dir/std.err.$counter 105 | # git can send non errors to standard error (at least on fedora...annoying) 106 | # So redirect everything to std.out and rely on grepping std.out to find errors. 107 | eval "$test" 1>> $output_dir/unfiltered.std.out.$counter 2>> $output_dir/std.out.$counter 108 | cd $output_dir 109 | egrep -o "$lines_to_check" unfiltered.std.out.$counter > std.out.$counter 110 | diff -U3 -B -bI"$TestDelimiter" $scriptname.saved.$counter std.out.$counter >> std.err.$counter 111 | cd $test_dir 112 | counter=$(( $counter + 1 )) 113 | done 114 | 115 | 116 | # Echo to stderr all nonempty error files in $output_dir. test.sh 117 | # collects these file names and puts them in the error report 118 | for errfile in $( find $output_dir ! -size 0 -name "*.err.*" ) 119 | do 120 | echo $errfile >&2 121 | done 122 | 123 | -------------------------------------------------------------------------------- /test/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #BHEADER********************************************************************** 3 | # 4 | # Copyright (c) 2013, Lawrence Livermore National Security, LLC. 5 | # Produced at the Lawrence Livermore National Laboratory. Written by 6 | # Jacob Schroder, Rob Falgout, Tzanio Kolev, Ulrike Yang, Veselin 7 | # Dobrev, et al. LLNL-CODE-660355. All rights reserved. 8 | # 9 | # This file is part of XBraid. For support, post issues to the XBraid Github page. 10 | # 11 | # This program is free software; you can redistribute it and/or modify it under 12 | # the terms of the GNU General Public License (as published by the Free Software 13 | # Foundation) version 2.1 dated February 1999. 14 | # 15 | # This program is distributed in the hope that it will be useful, but WITHOUT ANY 16 | # WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A 17 | # PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public 18 | # License for more details. 19 | # 20 | # You should have received a copy of the GNU Lesser General Public License along 21 | # with this program; if not, write to the Free Software Foundation, Inc., 59 22 | # Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 | # 24 | #EHEADER********************************************************************** 25 | 26 | 27 | while [ "$*" ] 28 | do 29 | case $1 in 30 | -h|-help) 31 | cat <"$testname.out" 2>"$testname.err" 75 | 76 | --------------------------------------------------------------------------------