Skip to content
Snippets Groups Projects
Select Git revision
  • 86c652f8ce2e2b2071dbfc9c488ed18dd73964e1
  • master default
  • library-names
  • fix_script_header
  • fix_libdir
  • fix_cmake_hdf5
  • partition
  • cgnsUnstructured
  • partitioning
  • HighOrderBLCurving
  • gmsh_3_0_5
  • gmsh_3_0_4
  • gmsh_3_0_3
  • gmsh_3_0_2
  • gmsh_3_0_1
  • gmsh_3_0_0
  • gmsh_2_16_0
  • gmsh_2_15_0
  • gmsh_2_14_1
  • gmsh_2_14_0
  • gmsh_2_13_2
  • gmsh_2_13_1
  • gmsh_2_12_0
  • gmsh_2_11_0
  • gmsh_2_10_1
  • gmsh_2_10_0
  • gmsh_2_9_3
  • gmsh_2_9_2
  • gmsh_2_9_1
  • gmsh_2_9_0
30 results

Callbacks.cpp

Blame
  • Forked from gmsh / gmsh
    Source project has a limited visibility.
    test_differentiation.cpp 7.23 KiB
    #include <iostream>
    #include <iomanip>
    
    #include <unistd.h>
    
    #include "test.h"
    #include "gmsh_io.h"
    #include "sgr.hpp"
    #include "entity_data.h"
    #include "kernels_cpu.h"
    #include "timecounter.h"
    #include "silo_output.hpp"
    
    using namespace sgr;
    
    static void
    make_geometry(int order, double mesh_h)
    {
        gm::add("difftest");
    
        std::vector<std::pair<int,int>> objects;
    
        objects.push_back(
            std::make_pair(3, gmo::addBox(0.0, 0.0, 0.0, 1.0, 1.0, 0.5) )
            );
        objects.push_back(
            std::make_pair(3, gmo::addBox(0.0, 0.0, 0.5, 0.5, 0.5, 0.5) )
            );
    
        std::vector<std::pair<int, int>> tools;
        gmsh::vectorpair odt;
        std::vector<gmsh::vectorpair> odtm;
        gmo::fragment(objects, tools, odt, odtm);
    
        gmo::synchronize();
    
        gvp_t vp;
        gm::getEntities(vp);
        gmm::setSize(vp, mesh_h);
    }
    
    int test_differentiation_convergence(int geometric_order, int approximation_order)
    {
        std::vector<double> sizes({ 0.32, 0.16, 0.08, 0.04 });
        std::vector<double> errors;
    
        std::cout << cyanfg << "Testing geometric order " << geometric_order;
        std::cout << ", approximation order = " << approximation_order << nofg;
        std::cout << std::endl;
    
        auto f = [](const point_3d& pt) -> double {
            return std::sin(M_PI*pt.x())*std::sin(M_PI*pt.y())*std::sin(M_PI*pt.z()); 
        };
        auto df_dx = [](const point_3d& pt) -> double {
            return M_PI*std::cos(M_PI*pt.x())*std::sin(M_PI*pt.y())*std::sin(M_PI*pt.z()); 
        };
        auto df_dy = [](const point_3d& pt) -> double {
            return M_PI*std::sin(M_PI*pt.x())*std::cos(M_PI*pt.y())*std::sin(M_PI*pt.z()); 
        };
        auto df_dz = [](const point_3d& pt) -> double {
            return M_PI*std::sin(M_PI*pt.x())*std::sin(M_PI*pt.y())*std::cos(M_PI*pt.z()); 
        };
    
        std::vector<double> errs_x;
        std::vector<double> errs_y;
        std::vector<double> errs_z;
    
        for (size_t i = 0; i < sizes.size(); i++)
        {
            double h = sizes[i];