Commit 6da4570a authored by Marcus Mohr's avatar Marcus Mohr
Browse files

Merge branch 'mohr/divergenceOperator-mc' into 'master'

Implements VectorToScalar and ScalarToVector operators

See merge request !371
parents ac388823 ed352a63
Pipeline #27263 passed with stages
in 109 minutes and 2 seconds
......@@ -23,6 +23,8 @@
#include "hyteg/composites/P1StokesFunction.hpp"
#include "hyteg/composites/StokesOperatorTraits.hpp"
#include "hyteg/p1functionspace/P1ConstantOperator.hpp"
#include "hyteg/p1functionspace/P1ScalarToP1VectorOperator.hpp"
#include "hyteg/p1functionspace/P1VectorToP1ScalarOperator.hpp"
namespace hyteg {
......@@ -39,9 +41,11 @@ class P1StokesOperator : public Operator< P1StokesFunction< real_t >, P1StokesFu
, div_x( storage, minLevel, maxLevel )
, div_y( storage, minLevel, maxLevel )
, div_z( storage, minLevel, maxLevel )
, div( storage, minLevel, maxLevel )
, divT_x( storage, minLevel, maxLevel )
, divT_y( storage, minLevel, maxLevel )
, divT_z( storage, minLevel, maxLevel )
, divT( storage, minLevel, maxLevel )
, pspg( storage, minLevel, maxLevel )
, pspg_inv_diag_( storage, minLevel, maxLevel )
, hasGlobalCells_( storage->hasGlobalCells() )
......@@ -87,6 +91,9 @@ class P1StokesOperator : public Operator< P1StokesFunction< real_t >, P1StokesFu
P1PSPGOperator pspg;
P1PSPGInvDiagOperator pspg_inv_diag_;
bool hasGlobalCells_;
P1ConstantDivOperator div;
P1ConstantDivTOperator divT;
};
template <>
......
......@@ -21,8 +21,10 @@
#include "hyteg/composites/P2P1TaylorHoodFunction.hpp"
#include "hyteg/composites/P2P1TaylorHoodStokesBlockPreconditioner.hpp"
#include "hyteg/mixedoperators/P1ScalarToP2VectorOperator.hpp"
#include "hyteg/mixedoperators/P1ToP2Operator.hpp"
#include "hyteg/mixedoperators/P2ToP1Operator.hpp"
#include "hyteg/mixedoperators/P2VectorToP1ScalarOperator.hpp"
#include "hyteg/p2functionspace/P2ConstantOperator.hpp"
namespace hyteg {
......@@ -39,9 +41,11 @@ class P2P1TaylorHoodStokesOperator : public Operator< P2P1TaylorHoodFunction< re
, div_x( storage, minLevel, maxLevel )
, div_y( storage, minLevel, maxLevel )
, div_z( storage, minLevel, maxLevel )
, div( storage, minLevel, maxLevel )
, divT_x( storage, minLevel, maxLevel )
, divT_y( storage, minLevel, maxLevel )
, divT_z( storage, minLevel, maxLevel )
, divT( storage, minLevel, maxLevel )
, pspg_( storage, minLevel, maxLevel )
, pspg_inv_diag_( storage, minLevel, maxLevel )
, hasGlobalCells_( storage->hasGlobalCells() )
......@@ -81,6 +85,9 @@ class P2P1TaylorHoodStokesOperator : public Operator< P2P1TaylorHoodFunction< re
P1ToP2ConstantDivTyOperator divT_y;
P1ToP2ConstantDivTzOperator divT_z;
P2ToP1ConstantDivOperator div;
P1ToP2ConstantDivTOperator divT;
/// this operator is need in the uzawa smoother
P1PSPGOperator pspg_;
P1PSPGInvDiagOperator pspg_inv_diag_;
......
/*
* Copyright (c) 2017-2019 Daniel Drzisga, Dominik Thoennes, Marcus Mohr, Nils Kohl.
*
* This file is part of HyTeG
* (see https://i10git.cs.fau.de/hyteg/hyteg).
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "hyteg/Operator.hpp"
#include "hyteg/p1functionspace/P1Function.hpp"
#include "hyteg/p1functionspace/P1VectorFunction.hpp"
#include "hyteg/p2functionspace/P2Function.hpp"
#include "hyteg/p2functionspace/P2VectorFunction.hpp"
namespace hyteg {
using walberla::real_t;
/// dummy operator used for cases where scalar operators are only available for 2D settings
class P2ToP1DummyOperator : public Operator< P2Function< real_t >, P1Function< real_t > >
{
public:
P2ToP1DummyOperator( const std::shared_ptr< PrimitiveStorage >& storage, size_t minLevel, size_t maxLevel )
: Operator( storage, minLevel, maxLevel )
{}
void apply( const P2Function< real_t >& src,
const P1Function< real_t >& dst,
size_t level,
DoFType flag,
UpdateType updateType = Replace ) const
{
WALBERLA_ABORT( "P2ToP1DummyOperator::apply() should never be called!" );
}
};
class P1ToP2DummyOperator : public Operator< P1Function< real_t >, P2Function< real_t > >
{
public:
P1ToP2DummyOperator( const std::shared_ptr< PrimitiveStorage >& storage, size_t minLevel, size_t maxLevel )
: Operator( storage, minLevel, maxLevel )
{}
void apply( const P1Function< real_t >& src,
const P2Function< real_t >& dst,
size_t level,
DoFType flag,
UpdateType updateType = Replace ) const
{
WALBERLA_ABORT( "P1ToP2DummyOperator::apply() should never be called!" );
}
};
} // namespace hyteg
/*
* Copyright (c) 2017-2019 Daniel Drzisga, Dominik Thoennes, Marcus Mohr, Nils Kohl.
*
* This file is part of HyTeG
* (see https://i10git.cs.fau.de/hyteg/hyteg).
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "hyteg/elementwiseoperators/P1ToP2ElementwiseOperator.hpp"
#include "hyteg/mixedoperators/MixedDummyOperators.hpp"
#include "hyteg/mixedoperators/P1ToP2Operator.hpp"
#include "hyteg/mixedoperators/P1ToP2VariableOperator.hpp"
#include "hyteg/p1functionspace/P1Function.hpp"
#include "hyteg/p2functionspace/P2Function.hpp"
#include "hyteg/p2functionspace/P2VectorFunction.hpp"
namespace hyteg {
using walberla::real_t;
template < class operX_t, class operY_t, class operZ_t >
class P1ScalarToP2VectorOperator : public Operator< P1VectorFunction< real_t >, P2Function< real_t > >
{
public:
P1ScalarToP2VectorOperator( const std::shared_ptr< PrimitiveStorage >& storage, size_t minLevel, size_t maxLevel )
: Operator( storage, minLevel, maxLevel )
, operX( storage, minLevel, maxLevel )
, operY( storage, minLevel, maxLevel )
, operZ( storage, minLevel, maxLevel )
{}
void apply( const P1Function< real_t >& src,
const P2VectorFunction< real_t >& dst,
size_t level,
DoFType flag,
UpdateType updateType = Replace ) const
{
operX.apply( src, dst[0], level, flag, updateType );
operY.apply( src, dst[1], level, flag, updateType );
if ( dst.getDimension() == 3 )
operZ.apply( src, dst[2], level, flag, updateType );
}
private:
operX_t operX;
operY_t operY;
operZ_t operZ;
};
// Some operators we might use more often than others
typedef P1ScalarToP2VectorOperator< P1ToP2ConstantDivTxOperator, P1ToP2ConstantDivTyOperator, P1ToP2ConstantDivTzOperator >
P1ToP2ConstantDivTOperator;
typedef P1ScalarToP2VectorOperator< P1ToP2BlendingDivTxOperator, P1ToP2BlendingDivTyOperator, P1ToP2DummyOperator >
P1ToP2VariableDivTOperator;
typedef P1ScalarToP2VectorOperator< P1ToP2ElementwiseBlendingDivTxOperator,
P1ToP2ElementwiseBlendingDivTyOperator,
P1ToP2ElementwiseBlendingDivTzOperator >
P1ToP2ElementwiseBlendingDivTOperator;
} // namespace hyteg
/*
* Copyright (c) 2017-2019 Daniel Drzisga, Dominik Thoennes, Marcus Mohr, Nils Kohl.
*
* This file is part of HyTeG
* (see https://i10git.cs.fau.de/hyteg/hyteg).
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "hyteg/elementwiseoperators/P2ToP1ElementwiseOperator.hpp"
#include "hyteg/mixedoperators/MixedDummyOperators.hpp"
#include "hyteg/mixedoperators/P2ToP1Operator.hpp"
#include "hyteg/mixedoperators/P2ToP1VariableOperator.hpp"
#include "hyteg/p1functionspace/P1Function.hpp"
#include "hyteg/p2functionspace/P2Function.hpp"
#include "hyteg/p2functionspace/P2VectorFunction.hpp"
namespace hyteg {
using walberla::real_t;
template < class operX_t, class operY_t, class operZ_t >
class P2VectorToP1ScalarOperator : public Operator< P2VectorFunction< real_t >, P1Function< real_t > >
{
public:
P2VectorToP1ScalarOperator( const std::shared_ptr< PrimitiveStorage >& storage, size_t minLevel, size_t maxLevel )
: Operator( storage, minLevel, maxLevel )
, operX( storage, minLevel, maxLevel )
, operY( storage, minLevel, maxLevel )
, operZ( storage, minLevel, maxLevel )
{}
void apply( const P2VectorFunction< real_t >& src,
const P1Function< real_t >& dst,
size_t level,
DoFType flag,
UpdateType updateType = Replace ) const
{
std::array< UpdateType, 3 > ut = {updateType, Add, Add};
operX.apply( src[0], dst, level, flag, ut[0] );
operY.apply( src[1], dst, level, flag, ut[1] );
if ( src.getDimension() == 3 )
operZ.apply( src[2], dst, level, flag, ut[2] );
}
private:
operX_t operX;
operY_t operY;
operZ_t operZ;
};
// Some operators we might use more often than others
typedef P2VectorToP1ScalarOperator< P2ToP1ConstantDivxOperator, P2ToP1ConstantDivyOperator, P2ToP1ConstantDivzOperator >
P2ToP1ConstantDivOperator;
typedef P2VectorToP1ScalarOperator< P2ToP1BlendingDivxOperator, P2ToP1BlendingDivyOperator, P2ToP1DummyOperator >
P2ToP1VariableDivOperator;
typedef P2VectorToP1ScalarOperator< P2ToP1ElementwiseBlendingDivxOperator,
P2ToP1ElementwiseBlendingDivyOperator,
P2ToP1ElementwiseBlendingDivzOperator >
P2ToP1ElementwiseBlendingDivOperator;
} // namespace hyteg
/*
* Copyright (c) 2017-2020 Marcus Mohr.
*
* This file is part of HyTeG
* (see https://i10git.cs.fau.de/hyteg/hyteg).
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "hyteg/p1functionspace/P1ConstantOperator.hpp"
#include "hyteg/p1functionspace/P1Function.hpp"
#include "hyteg/p1functionspace/P1VectorFunction.hpp"
namespace hyteg {
using walberla::real_t;
template < class operX_t, class operY_t, class operZ_t >
class P1ScalarToP1VectorOperator : public Operator< P1VectorFunction< real_t >, P1Function< real_t > >
{
public:
P1ScalarToP1VectorOperator( const std::shared_ptr< PrimitiveStorage >& storage, size_t minLevel, size_t maxLevel )
: Operator( storage, minLevel, maxLevel )
, operX( storage, minLevel, maxLevel )
, operY( storage, minLevel, maxLevel )
, operZ( storage, minLevel, maxLevel )
{}
void apply( const P1Function< real_t >& src,
const P1VectorFunction< real_t >& dst,
size_t level,
DoFType flag,
UpdateType updateType = Replace ) const
{
operX.apply( src, dst[0], level, flag, updateType );
operY.apply( src, dst[1], level, flag, updateType );
if ( dst.getDimension() == 3 )
operZ.apply( src, dst[2], level, flag, updateType );
}
private:
operX_t operX;
operY_t operY;
operZ_t operZ;
};
// Some operators we might use more often than others
typedef P1ScalarToP1VectorOperator< P1DivTxOperator, P1DivTyOperator, P1DivTzOperator >
P1ConstantDivTOperator;
} // namespace hyteg
......@@ -59,9 +59,9 @@ class P1VectorFunction
w.interpolate( expr, level, flag );
}
void interpolate( std::vector< std::function< ValueType( const hyteg::Point3D ) > >& expr,
size_t level,
DoFType flag = All ) const
void interpolate( const std::vector< std::function< ValueType( const hyteg::Point3D& ) > >& expr,
size_t level,
DoFType flag = All ) const
{
WALBERLA_ASSERT_GREATER( expr.size(), 0 );
WALBERLA_ASSERT_LESS_EQUAL( expr.size(), 3 );
......
/*
* Copyright (c) 2017-2020 Marcus Mohr.
*
* This file is part of HyTeG
* (see https://i10git.cs.fau.de/hyteg/hyteg).
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "hyteg/p1functionspace/P1ConstantOperator.hpp"
#include "hyteg/p1functionspace/P1Function.hpp"
#include "hyteg/p1functionspace/P1VectorFunction.hpp"
namespace hyteg {
using walberla::real_t;
template < class operX_t, class operY_t, class operZ_t >
class P1VectorToP1ScalarOperator : public Operator< P1VectorFunction< real_t >, P1Function< real_t > >
{
public:
P1VectorToP1ScalarOperator( const std::shared_ptr< PrimitiveStorage >& storage, size_t minLevel, size_t maxLevel )
: Operator( storage, minLevel, maxLevel )
, operX( storage, minLevel, maxLevel )
, operY( storage, minLevel, maxLevel )
, operZ( storage, minLevel, maxLevel )
{}
void apply( const P1VectorFunction< real_t >& src,
const P1Function< real_t >& dst,
size_t level,
DoFType flag,
UpdateType updateType = Replace ) const
{
std::array< UpdateType, 3 > ut = {updateType, Add, Add};
operX.apply( src[0], dst, level, flag, ut[0] );
operY.apply( src[1], dst, level, flag, ut[1] );
if ( src.getDimension() == 3 )
operZ.apply( src[2], dst, level, flag, ut[2] );
}
private:
operX_t operX;
operY_t operY;
operZ_t operZ;
};
// Some operators we might use more often than others
typedef P1VectorToP1ScalarOperator< P1DivxOperator, P1DivyOperator, P1DivzOperator >
P1ConstantDivOperator;
} // namespace hyteg
......@@ -72,9 +72,9 @@ class P2VectorFunction
w.interpolate( expr, level, flag );
}
void interpolate( std::vector< std::function< ValueType( const hyteg::Point3D ) > >& expr,
size_t level,
DoFType flag = All ) const
void interpolate( const std::vector< std::function< ValueType( const hyteg::Point3D& ) > >& expr,
size_t level,
DoFType flag = All ) const
{
WALBERLA_ASSERT_GREATER( expr.size(), 0 );
WALBERLA_ASSERT_LESS_EQUAL( expr.size(), 3 );
......
......@@ -97,14 +97,16 @@ public:
R.uvw.v.assign( {1.0}, {b.uvw.v}, level, flag_ );
stokesOperator.A.apply( u.uvw.u, tmp.uvw.u, level, flag_ );
stokesOperator.A.apply( u.uvw.v, tmp.uvw.v, level, flag_ );
stokesOperator.divT_x.apply( u.p, tmp.uvw.u, level, flag_, Add );
stokesOperator.divT_y.apply( u.p, tmp.uvw.v, level, flag_, Add );
// stokesOperator.divT_x.apply( u.p, tmp.uvw.u, level, flag_, Add );
// stokesOperator.divT_y.apply( u.p, tmp.uvw.v, level, flag_, Add );
stokesOperator.divT.apply( u.p, tmp.uvw, level, flag_, Add );
R.uvw.u.add( {-1.0}, {tmp.uvw.u}, level, flag_ );
R.uvw.v.add( {-1.0}, {tmp.uvw.v}, level, flag_ );
// pressure
stokesOperator.div_x.apply( u.uvw.u, tmp.p, level, flag_ | DirichletBoundary, Replace );
stokesOperator.div_y.apply( u.uvw.v, tmp.p, level, flag_ | DirichletBoundary, Add );
// stokesOperator.div_x.apply( u.uvw.u, tmp.p, level, flag_ | DirichletBoundary, Replace );
// stokesOperator.div_y.apply( u.uvw.v, tmp.p, level, flag_ | DirichletBoundary, Add );
stokesOperator.div.apply( u.uvw, tmp.p, level, flag_ | DirichletBoundary, Replace );
R.p.assign( {-1.0}, {tmp.p}, level, flag_ | DirichletBoundary );
/////////////
......@@ -116,10 +118,8 @@ public:
velocityBlockSolver_->solve( stokesOperator.A, RHat.uvw.v, R.uvw.v, level );
// pressure
stokesOperator.div_x.apply( RHat.uvw.u, RHat.p, level, flag_ | DirichletBoundary, Replace );
stokesOperator.div_y.apply( RHat.uvw.v, RHat.p, level, flag_ | DirichletBoundary, Add );
stokesOperator.div_x.apply( u.uvw.u, RHat.p, level, flag_ | DirichletBoundary, Add );
stokesOperator.div_y.apply( u.uvw.v, RHat.p, level, flag_ | DirichletBoundary, Add );
stokesOperator.div.apply( RHat.uvw, RHat.p, level, flag_ | DirichletBoundary, Replace );
stokesOperator.div.apply( u.uvw, RHat.p, level, flag_ | DirichletBoundary, Add );
///////////////
// R_tilde_0 //
......@@ -142,16 +142,16 @@ public:
// calculate M * P
// 1. calc tmp := A^-1 * B^T * P_pressure
stokesOperator.divT_x.apply( P.p, tmp.uvw.u, level, flag_ );
stokesOperator.divT_y.apply( P.p, tmp.uvw.v, level, flag_ );
// stokesOperator.divT_x.apply( P.p, tmp.uvw.u, level, flag_ );
// stokesOperator.divT_y.apply( P.p, tmp.uvw.v, level, flag_ );
stokesOperator.divT.apply( P.p, tmp.uvw, level, flag_ );
velocityBlockSolver_->solve( stokesOperator.A, tmp_2.uvw.u, tmp.uvw.u, level );
velocityBlockSolver_->solve( stokesOperator.A, tmp_2.uvw.v, tmp.uvw.v, level );
// 2. velocity of M * P
MP.uvw.u.assign( {1.0, 1.0}, {P.uvw.u, tmp_2.uvw.u}, level, flag_ );
MP.uvw.v.assign( {1.0, 1.0}, {P.uvw.v, tmp_2.uvw.v}, level, flag_ );
// 3. pressure of M * P
stokesOperator.div_x.apply( tmp_2.uvw.u, MP.p, level, flag_ | DirichletBoundary, Replace );
stokesOperator.div_y.apply( tmp_2.uvw.v, MP.p, level, flag_ | DirichletBoundary, Add );
stokesOperator.div.apply( tmp_2.uvw, MP.p, level, flag_ | DirichletBoundary, Replace );
alpha_d = P.p.dotGlobal( MP.p, level, flag_ | DirichletBoundary );
......@@ -252,16 +252,18 @@ public:
// calculate M * P
// 1. calc tmp := A^-1 * B^T * P_pressure
stokesOperator.divT_x.apply( P.p, tmp.uvw.u, level, flag_ );
stokesOperator.divT_y.apply( P.p, tmp.uvw.v, level, flag_ );
// stokesOperator.divT_x.apply( P.p, tmp.uvw.u, level, flag_ );
// stokesOperator.divT_y.apply( P.p, tmp.uvw.v, level, flag_ );
stokesOperator.divT.apply( P.p, tmp.uvw, level, flag_ );
velocityBlockSolver_->solve( stokesOperator.A, tmp_2.uvw.u, tmp.uvw.u, level );
velocityBlockSolver_->solve( stokesOperator.A, tmp_2.uvw.v, tmp.uvw.v, level );
// 2. velocity of M * P
MP.uvw.u.assign( {1.0, 1.0}, {P.uvw.u, tmp_2.uvw.u}, level, flag_ );
MP.uvw.v.assign( {1.0, 1.0}, {P.uvw.v, tmp_2.uvw.v}, level, flag_ );
// 3. pressure of M * P
stokesOperator.div_x.apply( tmp_2.uvw.u, MP.p, level, flag_ | DirichletBoundary, Replace );
stokesOperator.div_y.apply( tmp_2.uvw.v, MP.p, level, flag_ | DirichletBoundary, Add );
// stokesOperator.div_x.apply( tmp_2.uvw.u, MP.p, level, flag_ | DirichletBoundary, Replace );
// stokesOperator.div_y.apply( tmp_2.uvw.v, MP.p, level, flag_ | DirichletBoundary, Add );
stokesOperator.div.apply( tmp_2.uvw, MP.p, level, flag_ | DirichletBoundary, Replace );
alpha_d = P.p.dotGlobal( MP.p, level, flag_ | DirichletBoundary );
......
......@@ -267,6 +267,9 @@ if(CMAKE_BUILD_TYPE MATCHES "Release")
waLBerla_execute_test(NAME MassOperatorTestMPI COMMAND $<TARGET_FILE:MassOperatorTest> PROCESSES 2 )
endif()
waLBerla_compile_test(FILES operators/DivergenceOperatorTest.cpp DEPENDS hyteg core)
waLBerla_execute_test(NAME DivergenceOperatorTest )
waLBerla_compile_test(FILES operators/ElementwiseOperatorAdditiveApplyTest.cpp DEPENDS hyteg core)
waLBerla_execute_test(NAME ElementwiseOperatorAdditiveApplyTest)
......
......@@ -53,12 +53,13 @@ static void testP2Function()
P2VectorFunction< real_t > aux_f( "auxFunc", storage, minLevel, maxLevel );
// Interpolate
std::function< real_t( const hyteg::Point3D& ) > expr = []( const Point3D& ) -> real_t { return real_c( 2 ); };
std::function< real_t( const hyteg::Point3D& ) > xComp = []( const Point3D& ) { return real_c( 2 ); };
std::function< real_t( const hyteg::Point3D& ) > yComp = []( const Point3D& x ) { return x[0] * x[1]; };
walberla::WcTimingPool timer;
timer["Interpolate"].start();
vec_f.interpolate( expr, maxLevel, DoFType::All );
vec_f.interpolate( {xComp, yComp}, maxLevel, DoFType::All );
timer["Interpolate"].end();
// Assign
......
......@@ -64,7 +64,7 @@ static void exportFunctions2D()
std::function< real_t( const hyteg::Point3D& ) > xFunc = []( const Point3D& p ) -> real_t { return -2.0 * p[0]; };
std::function< real_t( const hyteg::Point3D& ) > yFunc = []( const Point3D& p ) -> real_t { return p[0] + p[1]; };
std::vector< std::function< real_t( const hyteg::Point3D ) > > vecExpr = {xFunc, yFunc};
std::vector< std::function< real_t( const hyteg::Point3D& ) > > vecExpr = {xFunc, yFunc};
p1VectorFunc.interpolate( vecExpr, maxLevel, DoFType::All );
p2VectorFunc.interpolate( vecExpr, maxLevel, DoFType::All );
......@@ -104,10 +104,10 @@ static void exportFunctions3D()
// std::function< real_t( const hyteg::Point3D& ) > xFunc = []( const Point3D& p ) -> real_t { return -2.0*p[0]; };
// std::function< real_t( const hyteg::Point3D& ) > yFunc = []( const Point3D& p ) -> real_t { return p[0]+p[1]+p[2]; };
// std::function< real_t( const hyteg::Point3D& ) > zFunc = []( const Point3D& p ) -> real_t { return 3.0*p[0]+p[2]; };
std::function< real_t( const hyteg::Point3D& ) > xFunc = []( const Point3D& p ) -> real_t { return p[0]; };
std::function< real_t( const hyteg::Point3D& ) > yFunc = []( const Point3D& p ) -> real_t { return p[1]; };
std::function< real_t( const hyteg::Point3D& ) > zFunc = []( const Point3D& p ) -> real_t { return p[2]; };
std::vector< std::function< real_t( const hyteg::Point3D ) > > vecExpr = {xFunc, yFunc, zFunc};
std::function< real_t( const hyteg::Point3D& ) > xFunc = []( const Point3D& p ) -> real_t { return p[0]; };
std::function< real_t( const hyteg::Point3D& ) > yFunc = []( const Point3D& p ) -> real_t { return p[1]; };
std::function< real_t( const hyteg::Point3D& ) > zFunc = []( const Point3D& p ) -> real_t { return p[2]; };
std::vector< std::function< real_t( const hyteg::Point3D& ) > > vecExpr = {xFunc, yFunc, zFunc};
// Setup some functions
P1Function< real_t > p1ScalarFunc1( "P1 scalar function 1", storage, minLevel, maxLevel );
......
/*
* Copyright (c) 2020 Marcus Mohr.
*
* This file is part of HyTeG
* (see https://i10git.cs.fau.de/hyteg/hyteg).