mirror of
https://github.com/cosmo-sims/monofonIC.git
synced 2024-09-19 17:03:45 +02:00
removed superfluous grid operators
This commit is contained in:
parent
f4d6b9e669
commit
5d60b59f6c
2 changed files with 14 additions and 12 deletions
|
@ -1,10 +1,18 @@
|
|||
#pragma once
|
||||
|
||||
/*
|
||||
|
||||
operators.hh - This file is part of MUSIC2 -
|
||||
a code to generate multi-scale initial conditions
|
||||
for cosmological simulations
|
||||
|
||||
Copyright (C) 2019 Oliver Hahn
|
||||
|
||||
*/
|
||||
#include <general.hh>
|
||||
|
||||
namespace op{
|
||||
|
||||
//!== long list of primitive operators to work on fields ==!//
|
||||
//!== list of primitive operators to work on fields ==!//
|
||||
|
||||
template< typename field>
|
||||
inline auto assign_to( field& g ){return [&g](auto i, auto v){ g[i] = v; };}
|
||||
|
@ -15,15 +23,9 @@ inline auto multiply_add_to( field& g, val x ){return [&g,x](auto i, auto v){ g[
|
|||
template< typename field>
|
||||
inline auto add_to( field& g ){return [&g](auto i, auto v){ g[i] += v; };}
|
||||
|
||||
template< typename field>
|
||||
inline auto add_twice_to( field& g ){return [&g](auto i, auto v){ g[i] += 2*v; };}
|
||||
|
||||
template< typename field>
|
||||
inline auto subtract_from( field& g ){return [&g](auto i, auto v){ g[i] -= v; };}
|
||||
|
||||
template< typename field>
|
||||
inline auto subtract_twice_from( field& g ){return [&g](auto i, auto v){ g[i] -= 2*v; };}
|
||||
|
||||
//! vanilla standard gradient
|
||||
class fourier_gradient{
|
||||
private:
|
||||
|
|
|
@ -353,7 +353,7 @@ int Run( config_file& the_config )
|
|||
music::ilog << std::setw(40) << std::setfill('.') << std::left << "Computing phi(3a) term" << std::flush;
|
||||
phi3a.FourierTransformForward(false);
|
||||
Conv.convolve_Hessians(phi, {0, 0}, phi, {1, 1}, phi, {2, 2}, op::assign_to(phi3a));
|
||||
Conv.convolve_Hessians(phi, {0, 1}, phi, {0, 2}, phi, {1, 2}, op::add_twice_to(phi3a));
|
||||
Conv.convolve_Hessians(phi, {0, 1}, phi, {0, 2}, phi, {1, 2}, op::multiply_add_to(phi3a,2.0));
|
||||
Conv.convolve_Hessians(phi, {1, 2}, phi, {1, 2}, phi, {0, 0}, op::subtract_from(phi3a));
|
||||
Conv.convolve_Hessians(phi, {0, 2}, phi, {0, 2}, phi, {1, 1}, op::subtract_from(phi3a));
|
||||
Conv.convolve_Hessians(phi, {0, 1}, phi, {0, 1}, phi, {2, 2}, op::subtract_from(phi3a));
|
||||
|
@ -367,9 +367,9 @@ int Run( config_file& the_config )
|
|||
Conv.convolve_SumOfHessians(phi, {0, 0}, phi2, {1, 1}, {2, 2}, op::assign_to(phi3b));
|
||||
Conv.convolve_SumOfHessians(phi, {1, 1}, phi2, {2, 2}, {0, 0}, op::add_to(phi3b));
|
||||
Conv.convolve_SumOfHessians(phi, {2, 2}, phi2, {0, 0}, {1, 1}, op::add_to(phi3b));
|
||||
Conv.convolve_Hessians(phi, {0, 1}, phi2, {0, 1}, op::subtract_twice_from(phi3b));
|
||||
Conv.convolve_Hessians(phi, {0, 2}, phi2, {0, 2}, op::subtract_twice_from(phi3b));
|
||||
Conv.convolve_Hessians(phi, {1, 2}, phi2, {1, 2}, op::subtract_twice_from(phi3b));
|
||||
Conv.convolve_Hessians(phi, {0, 1}, phi2, {0, 1}, op::multiply_add_to(phi3b,-2.0));
|
||||
Conv.convolve_Hessians(phi, {0, 2}, phi2, {0, 2}, op::multiply_add_to(phi3b,-2.0));
|
||||
Conv.convolve_Hessians(phi, {1, 2}, phi2, {1, 2}, op::multiply_add_to(phi3b,-2.0));
|
||||
phi3b.apply_InverseLaplacian();
|
||||
phi3b *= 0.5; // factor 1/2 from definition of phi(3b)!
|
||||
music::ilog << std::setw(20) << std::setfill(' ') << std::right << "took " << get_wtime() - wtime << "s" << std::endl;
|
||||
|
|
Loading…
Reference in a new issue