dune数值计算算法库

dune数值计算算法库目录1、Dune简介2、Dune安装3、第一个Dune实例应用helloworld本文对dune进行了简单介绍,说明了安装方法(只能在linux或win10下的wsl中安装),以及通过helloworld的简单例子进行

目录

1、Dune简介

2、Dune安装

3 、第一个Dune实例应用helloworld


本文对dune进行了简单介绍,说明了安装方法(只能在linux或win10下的wsl中安装),以及通过helloworld的简单例子进行了环境验证,下次根据教程演习如果进行泊松方程创建和求解。

1、Dune简介

DUNE (Distributed and Unified Numerics Environment),分布和统一数值解环境,是一种求解偏微分方程的基于网格的方法(PDE)的模块化的工具箱。DUNE是所有这些体现了科学计算的概念从抽象的接口设置第一次。现代C + +编程技术使同样的概念非常不同的实现使用一个非常低的开销一个共同的接口。因此,DUNE确保在科学计算的效率,并支持高性能计算应用。

DUNE(分布式统一数字环境)是一个模块化工具箱,用于使用基于网格的方法求解偏微分方程(PDE)。 它支持轻松实现有限元素(FE),有限体积(FV)和有限差异(FD)之类的方法。

DUNE是根据GPL(第2版)许可的免费软件。 该许可证类似于分发libstdc ++库的许可证。 因此,即使在专有软件中也可以使用DUNE。

DUNE的基本思想是创建紧凑的接口,以允许有效使用旧的和/或新的库。 现代C ++编程技术可以使用公共接口以非常低的开销实现同一概念的不同实现。 因此,DUNE确保科学计算的效率并支持高性能计算应用程序。

dune数值计算算法库

特殊的亮点是:

通用网格接口,该接口允许将各种非常不同的网格实现;

迭代求解器模板库接口,具有代数多网格作为预处理器;

用于试验和测试功能的高级接口,以及通用离散化模块

Python绑定用于完整的网格接口,并且灵活为用户模块提供绑定的概念。

2、Dune安装

    Dune是用于用C ++编写的偏微分方程(PDE)数值解的软件框架。 这意味着它提供了一组类,可帮助您编写自己的PDE求解器。 它不是具有精美图形用户界面的应用程序,您只能运行它,输入PDE并查看结果。 相反,您编写了一个C ++程序,其中包括框架中的各个部分,并将它们粘合在一起,从而使用特定的方法来解决特定的PDE。 但是,它可以非常灵活地让您实施各种不同的解决方案过程。  Dune确实还为其大部分核心功能提供了Python绑定,这可以帮助快速构建新代码的原型或进行预处理和后处理任务。

    有多种方法可以在计算机上安装和使用Dune(单击链接以按照说明进行操作):

http://www.math.tu-dresden.de/~osander/research/sander-getting-started-with-dune.pdf

Dune中常用的模块有7个,分别是dune-geometry, dune-grid, dune-istl, dune-localfunctios, dune-typetree, 和dune-functions。在debian类系统上安装方法是:

apt-get install libdune-functions-dev libdune-istl-dev

也可以从源码安装, 不过比较麻烦,这里不详细介绍。

3 、第一个Dune实例应用helloworld

Dune以模块的方法组织,其中每个表示模块大致上为一个带有预定义结构的文件夹。因为初次学习,这里先建议自己写一个模块形式的Dune程序,后边将不需要这么做。所以,要做的第一件事是创建空白的Dune模块。

这里首先假设Dune安装到了默认位置,或者环境变量DUNE_CONTROL_PATH指定了dune的安装位置。为了创建空白的模块,Dune提供了一个特殊的程序,成为duneproject,在命令行界面,直接输入duneproject,它会问一些问题,然后创建相应的模块。

== Dune project/module generator ==



duneproject will assist you in the creation of a new Dune application.

During this process a new directory with the name of your project will be

created. This directory will hold all configuration and Makefiles and a

simple example application.



1) Name of your new Project? (e.g.: dune-grid): helloworld

2) Which modules should this module depend on?

   The following modules have been found:

   dune-common dune-geometry dune-localfunctions dune-uggrid dune-grid dune-typetree dune-istl dune-functions

   Enter space-separated list: dune-common dune-geometry dune-localfunctions dune-uggrid dune-grid dune-typetree dune-istl dune-functions

3) Project/Module version? 1

4) Maintainer's email address? lyf000@126.com



creating Project "helloworld", version 1

which depends on "dune-common dune-geometry dune-localfunctions dune-uggrid dune-grid dune-typetree dune-istl dune-functions"

with maintainer "yanfeng1022@126.com"

Are these informations correct? [y/N] y



A sample code helloworld.cc is generated in the "helloworld" directory.

Look at the README and dune.module files there.

Now you can run the dunecontrol script which will setup the new module.

Sometimes you may have to tweak CMakeLists.txt a bit.

------------------------------------------

writing initial files:

- helloworld/README

- helloworld/CMakeLists.txt

- helloworld/helloworld.pc.in

    Please remember to update your helloworld/helloworld.pc.in,

    Description and URL are missing right now.

- helloworld/config.h.cmake

- helloworld/src/CMakeLists.txt

- helloworld/src/helloworld.cc

- helloworld/dune/helloworld

- helloworld/dune/CMakeLists.txt

- helloworld/dune/helloworld/CMakeLists.txt

- helloworld/dune/helloworld/helloworld.hh

- helloworld/doc/CMakeLists.txt

- helloworld/doc/doxygen/Doxylocal

Doxygen is not installed! Your documentation will not work without.

- helloworld/doc/doxygen/CMakeLists.txt

- helloworld/cmake/modules/CMakeLists.txt

- helloworld/cmake/modules/HelloworldMacros.cmake



done.

这些命令生成了上述hellworld文件夹和其中的内容。其中helloworld/src/helloworld.cc是main函数所在的位置,默认生成的内容如下:

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <iostream>
#include <dune/common/parallel/mpihelper.hh> // An initializer of MPI
#include <dune/common/exceptions.hh> // We use exceptions

int main(int argc, char** argv)
{
  try{
    // Maybe initialize MPI
    Dune::MPIHelper& helper = Dune::MPIHelper::instance(argc, argv);
    std::cout << "Hello World! This is helloworld." << std::endl;
    if(Dune::MPIHelper::isFake)
      std::cout<< "This is a sequential program." << std::endl;
    else
      std::cout<<"I am rank "<<helper.rank()<<" of "<<helper.size()
        <<" processes!"<<std::endl;
    return 0;
  }
  catch (Dune::Exception &e){
    std::cerr << "Dune reported error: " << e << std::endl;
  }
  catch (...){
    std::cerr << "Unknown exception thrown!" << std::endl;
  }
}

 

为此,我们需要构建和编译模块。  dunecontrol程序可以完成大部分工作。 如果已经从源头安装了Dune核心模块,您将注意到该过程几乎没有什么不同。 cd helloworld 进入刚才创建的hellowld文件件,然后只需输入dunecontrol all,即可开始编译,

一堆提示,最后几行如下:

-- Configuring done

-- Generating done

-- Build files have been written to: /mnt/d/programming/duneProject/helloworld/build-cmake

--- calling make for helloworld ---

build directory: build-cmake

cmake --build . --

Scanning dependencies of target helloworld

[ 50%] Building CXX object src/CMakeFiles/helloworld.dir/helloworld.cc.o

[100%] Linking CXX executable helloworld

[100%] Built target helloworld

--- helloworld done ---

--- done ---

然后在运行\helloworld\build-cmake\src文件夹下的helloworld即可得到结果

运行结果如下:

Hello World! This is helloworld.

I am rank 0 of 1 processes!

 

今天的文章dune数值计算算法库分享到此就结束了,感谢您的阅读。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/62625.html

(0)
编程小号编程小号

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注