Giter Club home page Giter Club logo

modifiedschwarz's Introduction

ModifiedSchwarz

A modified Schwarz problem solver in C++.

License

All work in this repository, unless otherwise specified, is Copyright 2017 Everett Kropf.

This file is part of ModifiedSchwarz.

ModifiedSchwarz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

ModifiedSchwarz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with ModifiedSchwarz. If not, see http://www.gnu.org/licenses/.

Setup

ModifiedSchwarz relies on the following external libraries:

  • cmake build system. At least version 3.5.

  • Armadillo linear algebra template library. Need version 7 or better.

    For best results, Armadillo relies on the following packages:

    • LAPACK, BLAS and ATLAS. On macOS/OS X these are already supplied under the Accelerate Framework.
    • On Linux systems, OpenBLAS is preferred to BLAS, but not required.
    • ARPACK.
    • SuperLU. Armadillo requires version 5 or better.
  • fmmlib2d fast multipole method (2d). After building, copy libhfmm2d.a to somewhere it will be found by cmake (/usr/local/lib is a good example). You can also give cmake the location of the library via CMAKE_LIBRARY_PATH (example cmake -DCMAKE_LIBRARY_PATH=<path to libhfmm2d.a> ..).

  • UnitTest++ (optional) for make check unit testing.

  • Doxygen (optional) for make doc html doc stuff.

Once the auxiliary packages are installed (see below for OS specific notes), this repository is cloned, and you are in the repository base directory (probably <something>/ModifiedSchwarz), the following sequence of commands should build the library. (See the Linux section below if you have installed Armadillo manually.)

mkdir build
cd build
cmake ..
make

(Yes, the two dots are required following cmake.) Note there is no valid install target currently. (It hasn't been configured.)

Code documentation

If you've installed Doxygen, you can make the HTML docs via make doc.

Example

Example usage is provided. Use make example to compile and run. Requires you have Python 3 installed in your path to generate an image.

Unit tests

If you've installed UnitTest++, tests can be run with make check.

OS X/macOS

All of the auxilary packages, with the excepiton of fmmlib2d, may be installed via MacPorts. I haven't tried with Homebrew, but this would probably be fine.

Linux

I have only tested this on Ubuntu 16.04 LTS. Your mileage will vary with other distributions. The basic stuff (cmake, LAPACK, BLAS, etc.) can be installed via the normal apt install route. Note you MUST check the version of Armadillo and SuperLU that comes with the distribution; both packages were behind in 16.04.

As an example involving out-of-band packages, I'll show installing SuperLU and Armadillo, since it's what needed done on 16.04.

SuperLU

By default SuperLU builds as a static library; we'll build it as shared. In addition it tries to use supplied BLAS routines; we'll give the option to use the system libraries. Finally I'll show how to use an alternate install location. So once the package is downloaded and unzipped, and you are in the directory, the following commands will build and install the package:

mkdir build
cd build
cmake -DBUILD_SHARED_LIBS=ON -Denable_blaslib=OFF -DCMAKE_INSTALL_PREFIX=/opt/local ..
make
make test
sudo make install

Armadillo

As before, once the package is downloaded, unzipped, and you are in the directory, give the following commands:

mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH=/opt/local -DCMAKE_INSTALL_PREFIX=/opt/local ..
make
sudo make install

Note that when you configure ModifiedSchwarz, you will need to modify the cmake command to be

cmake -DCMAKE_PREFIX_PATH=/opt/local ..

modifiedschwarz's People

Contributors

ehkropf avatar rhodrin avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

rhodrin

modifiedschwarz's Issues

Issue with abs/fabs in Ubuntu 18.04

I changed this as g++ 7.2.0 (with wasn't the case with 5.4) was returning abs(-ve number) as zero and hence solutions for points inside the domain were being returned as NaN.

I think in the current code, the standard abs is being called, not arma::abs? Using arma::abs returns a type error since the expression contains doubles. I'll re-look at the details sometime this week anyway.

(OS tested on = Ubuntu 18.04).

Originally posted by @rhodrin in ce66f93#commitcomment-31084877

Unify test output

Various test files use various output. Create macros to unify them all.

Add auto point evaluation to solution

Solution should provide operator to evaluate points with automatic closure checking. Any points outside closure of domain have value NaN.

Note it should be the job of each sub-interpolant to check the points that need evaluated. Thus

  • solution should initialise all result points to NaN,
  • Cauchy interpolant should fill in domain values, and
  • boundary interpolant should just fill in domain values.

Add domain point checking

Need methods to check points

  • in domain and
  • on boundary of domain.

Combinations of these give us

  • in domain closure and
  • not in domain closure.

Redesign solution point evaluation

Current idea was to have each interpolant pick the points to evaluate, and just return those point values. The problem is that the different interpolants need to write different points to the result, along with the fact we'd like values outside the domain closure to be nan, indicating they are undefined.

For example, the boundary value interpolant will return a matrix of values with boundary point values set, and the Cauchy interpolant will return it's own set of filled values. How do we combine these? Isn't it terribly wasteful to have different matrices of values to combine?

But on the other hand, passing the result matrix to the evaluations seems to break orthogonality somehow. (Does it really?)

Not designed for proper threaded use -- fix

src/UnitCircleDomain.cpp:49:    // FIXME: Need threaded speedup?
src/UnitCircleDomain.cpp:68:    // FIXME: This is really bad if parallelized. Who incremented the iterator!?
src/SpectralConstants.h:23:// FIXME: This is NOT a thread safe way to do this.

Make a proper example

Should be some example usage code. In example subtree preferably. Graphics would be snazzy.

Tests fail in CMake debug profile

When using

cmake .. -DCMAKE_BUILD_TYPE=debug

the unit tests fail. It appears to be an Armadillo issue, but needs investigated.

[100%] Built target testRunner
-----========== Polynomial ==========-----
  --> Polynomial values ... 
      DONE
  --> Unit Circle Domain check ... 
  --> Points ... 
      DONE
  --> Inside domain ... 
      DONE
  --> On boundary ... 
      DONE
-----========== BoundaryValue check ==========-----
  --> Size check ... 
/Users/ehkropf/Source/ModifiedSchwarz/test/checkBoundaryValues.cpp:58:1: error: Failure in BValSizeCheck: Expected 0 but was 3
/Users/ehkropf/Source/ModifiedSchwarz/test/checkBoundaryValues.cpp:59:1: error: Failure in BValSizeCheck: Expected 140732857750800 but was 3
/Users/ehkropf/Source/ModifiedSchwarz/test/checkBoundaryValues.cpp:60:1: error: Failure in BValSizeCheck: Expected 140732857750240 but was 0
/Users/ehkropf/Source/ModifiedSchwarz/test/checkBoundaryValues.cpp:62:1: error: Failure in BValSizeCheck: Expected 140732857750904 but was 3
/Users/ehkropf/Source/ModifiedSchwarz/test/checkBoundaryValues.cpp:63:1: error: Failure in BValSizeCheck: Expected 4357981967 but was 3
/Users/ehkropf/Source/ModifiedSchwarz/test/checkBoundaryValues.cpp:64:1: error: Failure in BValSizeCheck: Expected 140732857751264 but was 0
      DONE
  --> Value check ... 

error: arma::memory::acquire(): requested size is too large
/Users/ehkropf/Source/ModifiedSchwarz/test/checkBoundaryValues.cpp:73:1: error: Failure in BValValueCheck: Unhandled exception (arma::memory::acquire(): requested size is too large) in CHECK(approx_equal(vectorise(cbvals.values()), g(cbvals.points().vector()), "absdiff", 1e-10))
testRunner(32496,0x7fff91532380) malloc: *** mach_vm_map(size=2251725724016640) failed (error code=3)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug

error: arma::memory::acquire(): out of memory
/Users/ehkropf/Source/ModifiedSchwarz/test/checkBoundaryValues.cpp:74:1: error: Failure in BValValueCheck: Unhandled exception (std::bad_alloc) in CHECK(approx_equal(vectorise(rbvals.values()), h(rbvals.points().vector()), "absdiff", 1e-10))
      DONE
-----========== Real Interpolant ==========-----
  --> Real interpolation ... 
/Users/ehkropf/Source/ModifiedSchwarz/test/checkInterpolant.cpp:64:1: error: Failure in RealInterp: approx_equal(gi(zb), h(zb), "absdiff", 10.*eps2pi)
      DONE
  --> Complex interpolation ... 
      DONE
-----========== FMM evaluation ==========-----
  --> Result check ... 
      DONE
-----========== Cauchy interpolation ==========-----
  --> Check interpolation ... 
      DONE
-----========== Closure interpolant ==========-----
  --> Points on the boundary ... 
      DONE
  --> Points in the interior ... 
      DONE
  --> Points on boundary and interior ... 
      DONE
-----========== Spectral Constants ==========-----
  --> Trapezoidal rule points ... 
      DONE
  --> Truncation ... 
      DONE
-----========== Spectral data check ==========-----
  --> Matrix ... 
      DONE
  --> Data sharing ... 
      DONE
-----========== Spectral method check ==========-----
  --> Right hand side ... 
/Users/ehkropf/Source/ModifiedSchwarz/test/checkSpectralMethod.cpp:69:1: error: Failure in TestRHS: approx_equal(rhs.head_rows(rhs.n_rows/2), refRHS, "absdiff", 1e-4)
      DONE
  --> Residual ... 
      DONE
  --> Solution ... 
/Users/ehkropf/Source/ModifiedSchwarz/test/checkSpectralMethod.cpp:101:1: error: Failure in TestSolution: approx_equal(polesInHoles(cx_vec(vectorise(bv)), domain), sol(vectorise(bv)), "absdiff", 1e-6)
      DONE
-----========== Problem check ==========-----
  --> Basic solve ... 
      DONE
-----========== Solution check ==========-----
  --> Evaluate solution ... 
/Users/ehkropf/Source/ModifiedSchwarz/test/checkSolution.cpp:63:1: error: Failure in EvalSolution: approx_equal(polesInHoles(cx_vec(vectorise(zb)), domain), sol(vectorise(zb)), "reldiff", 10*eps2pi)
      DONE
FAILURE: 6 out of 34 tests failed (12 failures).
Test time: 0.36 seconds.
make[3]: *** [CMakeFiles/check] Error 12
make[2]: *** [CMakeFiles/check.dir/all] Error 2
make[1]: *** [CMakeFiles/check.dir/rule] Error 2
make: *** [check] Error 2

Implementation of the DFT derivative

In another branch I've added derivative functionality but the implementation is currently horrible.

I think the interface (Solution dsol = sol.diff(n);) is fine but diff being a member function of Class Solution leads to some nasty stuff. Currently dsol is computed in Solution.cpp which it shouldn't be, but introducing a new, i.e., DFTDerivative class leads to some circular dependencies.

From some Fixme comments I gather you were thinking of doing some restructuring of the Solution class anyway? If you've got any suggestions on how you think the derivative code should be structured please let me know!

Spectral constants is ugly -- redo

src/SpectralConstants.h:23:// FIXME: This is NOT a thread safe way to do this.
src/SpectralConstants.h:24:// FIXME: No way to query non-default values.
src/SpectralConstants.h:25:// FIXME: "k" names are horrible and not-intuitive of function.

Multiple tests fail on Ubuntu 18.04

[100%] Built target testRunner
Scanning dependencies of target check
-----========== Polynomial ==========-----
  --> Polynomial values ... 
      DONE
  --> Unit Circle Domain check ... 
  --> Points ... 
      DONE
  --> Inside domain ... 
      DONE
  --> On boundary ... 
      DONE
-----========== BoundaryValue check ==========-----
  --> Size check ... 
      DONE
  --> Value check ... 
      DONE
-----========== Real Interpolant ==========-----
  --> Real interpolation ... 
/home/ehkropf/src/ModifiedSchwarz/test/checkInterpolant.cpp:64:1: error: Failure in RealInterp: approx_equal(gi(zb), h(zb), "absdiff", 10.*eps2pi)
      DONE
  --> Real interp derivatives ... 
Test needs written.
/home/ehkropf/src/ModifiedSchwarz/test/checkInterpolant.cpp:76:1: error: Failure in RealInterpD: 0
  --> Complex interpolation ... 
      DONE
  --> Complex interp derivatives ... 
Test needs written.
/home/ehkropf/src/ModifiedSchwarz/test/checkInterpolant.cpp:97:1: error: Failure in ComplexInterpD: 0
-----========== FMM evaluation ==========-----
  --> Result check ... 
      DONE
-----========== Cauchy interpolation ==========-----
  --> Check interpolation ... 
      DONE
-----========== Closure interpolant ==========-----
  --> Points on the boundary ... 
      DONE
  --> Points in the interior ... 
/home/ehkropf/src/ModifiedSchwarz/test/checkClosureInterpolant.cpp:69:1: error: Failure in InteriorInterp: arma::approx_equal(f(interior_points), g(interior_points), "absdiff", 1e-10)
      DONE
  --> Points on boundary and interior ... 
/home/ehkropf/src/ModifiedSchwarz/test/checkClosureInterpolant.cpp:82:1: error: Failure in CombinedInterp: arma::approx_equal(f(zz), g(zz), "absdiff", 1e-10)
      DONE
-----========== Spectral Constants ==========-----
  --> Trapezoidal rule points ... 
      DONE
  --> Truncation ... 
      DONE
-----========== Spectral data check ==========-----
  --> Matrix ... 
      DONE
  --> Data sharing ... 
      DONE
-----========== Spectral method check ==========-----
  --> Right hand side ... 
/home/ehkropf/src/ModifiedSchwarz/test/checkSpectralMethod.cpp:69:1: error: Failure in TestRHS: approx_equal(rhs.head_rows(rhs.n_rows/2), refRHS, "absdiff", 1e-4)
      DONE
  --> Residual ... 
/home/ehkropf/src/ModifiedSchwarz/test/checkSpectralMethod.cpp:85:1: error: Failure in TestResidual: max(abs(res)/abs(rhs)) < 100*eps2pi
      DONE
  --> Solution ... 
/home/ehkropf/src/ModifiedSchwarz/test/checkSpectralMethod.cpp:101:1: error: Failure in TestSolution: approx_equal(polesInHoles(cx_vec(vectorise(bv)), domain), sol(vectorise(bv)), "absdiff", 1e-6)
      DONE
-----========== Problem check ==========-----
  --> Basic solve ... 
      DONE
-----========== Solution check ==========-----
  --> Evaluate solution ... 
/home/ehkropf/src/ModifiedSchwarz/test/checkSolution.cpp:63:1: error: Failure in EvalSolution: approx_equal(polesInHoles(cx_vec(vectorise(zb)), domain), sol(vectorise(zb)), "reldiff", 10*eps2pi)
      DONE
FAILURE: 9 out of 36 tests failed (9 failures).

Some classes store domain unnecessarily

src/Problem.h:48:    // FIXME: BoundaryValues contians domain; domain arg not needed.
src/RealInterpolant.h:52:    // FIXME: Domain is now stored in boundary values.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.