Commit dbd21a85 by Daniel Drzisga

parent 8cf29123
Pipeline #25788 failed with stages
in 180 minutes and 59 seconds
 import numpy as np from sympy import * def create_2d(): # Reference triangle reference = np.array([[0,0], [1,0], [0,1], [0.5,0.5], [0,0.5], [0.5,0]]) # Symbolic coordinate eta, xi = symbols('eta xi') # Construct local nodal basis functions basis = [1, eta, xi, eta*xi, eta**2, xi**2] phi = [] for i in range(len(basis)): a, b, c, d, e, f = symbols('a b c d e f') phi_l = a*basis[0] + b*basis[1] + c*basis[2] + d*basis[3] + e*basis[4] + f*basis[5] system = [] for j in range(6): phi_l_t = phi_l.subs([(eta,reference[j][0]), (xi,reference[j][1])]) system.append(Eq(phi_l_t, float(i==j))) sol = solve(system, [a,b,c,d,e,f]) phi.append(simplify(phi_l.subs(sol))) # Construct local nodal gradient basis functions def gradient(f): return simplify(Matrix([[diff(f,eta)], [diff(f,xi)]])) grad_phi = [] for p in phi: grad_phi.append(gradient(p)) return phi, grad_phi def create_3d(): # Reference tet reference = np.array([[0,0,0], [1,0,0], [0,1,0], [0,0,1], [0, 0.5, 0.5], [0.5, 0, 0.5], [0.5, 0.5, 0], [0, 0, 0.5], [0, 0.5, 0], [0.5, 0, 0]]) # Symbolic coordinate eta, xi, nu = symbols('eta xi nu') # Construct local nodal basis functions basis = [1, eta, xi, nu, eta*xi, eta*nu, xi*nu, eta**2, xi**2, nu**2] phi = [] for i in range(len(basis)): a, b, c, d, e, f, g, h, k, l = symbols('a b c d e f g h k l') phi_l = a*basis[0] + b*basis[1] + c*basis[2] + d*basis[3] + e*basis[4] + f*basis[5]+ g*basis[6] + h*basis[7] + k*basis[8] + l*basis[9] system = [] for j in range(10): phi_l_t = phi_l.subs([(eta,reference[j][0]), (xi,reference[j][1]), (nu,reference[j][2])]) system.append(Eq(phi_l_t, float(i==j))) sol = solve(system, [a,b,c,d,e,f,g,h,k,l]) phi.append(simplify(phi_l.subs(sol))) # Construct local nodal gradient basis functions def gradient(f): return simplify(Matrix([[diff(f,eta)], [diff(f,xi)], [diff(f,nu)]])) grad_phi = [] for p in phi: grad_phi.append(gradient(p)) return phi, grad_phi
 ... ... @@ -896,6 +896,9 @@ template class P2ElementwiseOperator< P2FenicsForm< p2_mass_cell_integral_0_othe // P2ElementwiseDivKGradOperator template class P2ElementwiseOperator< P2Form_divKgrad >; // P2ElementwiseDivKGradOBlendingperator template class P2ElementwiseOperator< P2Form_divKgradBlending >; // P2ElementwiseBlendingMassOperator template class P2ElementwiseOperator< P2Form_mass >; ... ...
 ... ... @@ -24,6 +24,7 @@ #include "hyteg/forms/form_fenics_base/P2FenicsForm.hpp" #include "hyteg/forms/form_fenics_generated/p2_polar_laplacian.h" #include "hyteg/forms/form_hyteg_manual/P2FormDivKGrad.hpp" #include "hyteg/forms/form_hyteg_manual/P2FormDivKGradBlending.hpp" #include "hyteg/forms/form_hyteg_manual/P2FormLaplace.hpp" #include "hyteg/forms/form_hyteg_manual/P2FormMass.hpp" #include "hyteg/forms/P2LinearCombinationForm.hpp" ... ... @@ -245,6 +246,7 @@ typedef P2ElementwiseOperator< P2Form_mass > P2ElementwiseBlendingMassOperato typedef P2ElementwiseOperator< P2Form_laplace > P2ElementwiseBlendingLaplaceOperator; typedef P2ElementwiseOperator< P2Form_divKgrad > P2ElementwiseDivKGradOperator; typedef P2ElementwiseOperator< P2Form_divKgradBlending > P2ElementwiseDivKGradBlendingOperator; typedef P2ElementwiseOperator< P2LinearCombinationForm > P2ElementwiseLinearCombinationOperator; ... ...
 /* * 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 progra m. If not, see . */ #include "hyteg/forms/form_hyteg_manual/P2FormDivKGradBlending.hpp" #include "hyteg/geometry/GeometryMap.hpp" #include "hyteg/types/matrix.hpp" #include "hyteg/types/pointnd.hpp" namespace hyteg { real_t neutralCallback( const Point3D& x, const std::shared_ptr< GeometryMap >& map ) { WALBERLA_UNUSED( x ); WALBERLA_UNUSED( map ); return real_c( 1.0 ); } std::function< real_t( const Point3D&, const std::shared_ptr< GeometryMap >& ) > P2Form_divKgradBlending::callback = &neutralCallback; } // namespace hyteg
This diff is collapsed.
 ... ... @@ -32,9 +32,10 @@ #include "hyteg/solvers/CGSolver.hpp" #include "hyteg/elementwiseoperators/P2ElementwiseOperator.hpp" #include "hyteg//geometry/IcosahedralShellMap.hpp" #include "hyteg/petsc/PETScMinResSolver.hpp" #include "hyteg/petsc/PETScLUSolver.hpp" #include "hyteg/petsc/PETScManager.hpp" #include "hyteg//geometry/AnnulusMap.hpp" //#include "hyteg/petsc/PETScMinResSolver.hpp" //#include "hyteg/petsc/PETScLUSolver.hpp" //#include "hyteg/petsc/PETScManager.hpp" using walberla::real_t; using walberla::uint_c; ... ... @@ -52,7 +53,7 @@ void P2DivKGradBlendingElementwiseCGTest() auto storage = std::make_shared< PrimitiveStorage >( setupStorage ); writeDomainPartitioningVTK( storage, "../../output", "P2DivKGradBlendingElementwiseCGTest_domain" ); hyteg::P2ElementwiseBlendingLaplaceOperator L( storage, level, level ); hyteg::P2ElementwiseDivKGradBlendingOperator L( storage, level, level ); hyteg::P2Function< real_t > r( "r", storage, level, level ); hyteg::P2Function< real_t > f( "f", storage, level, level ); ... ... @@ -70,7 +71,7 @@ void P2DivKGradBlendingElementwiseCGTest() communication::syncP2FunctionBetweenPrimitives( u, level ); auto solver = hyteg::CGSolver< hyteg::P2ElementwiseBlendingLaplaceOperator >( storage, level, level ); auto solver = hyteg::CGSolver< hyteg::P2ElementwiseDivKGradBlendingOperator >( storage, level, level ); solver.setPrintInfo( true ); // auto solver = std::make_shared< PETScLUSolver< hyteg::P2ElementwiseBlendingLaplaceOperator > >( storage, level ); ... ... @@ -95,7 +96,7 @@ void P2DivKGradBlendingElementwiseCGTest() WALBERLA_LOG_INFO_ON_ROOT( "discrete L2 error = " << discr_l2_err << " (level " << level << ", " << "unknowns incl boundary: " << npoints << ")" ); WALBERLA_CHECK_LESS( discr_l2_err, 1e-05 ); WALBERLA_CHECK_LESS( discr_l2_err, 3.5e-05 ); } } // namespace hyteg ... ... @@ -106,6 +107,6 @@ int main( int argc, char* argv[] ) walberla::logging::Logging::instance()->setLogLevel( walberla::logging::Logging::PROGRESS ); walberla::MPIManager::instance()->useWorldComm(); hyteg::PETScManager manager( &argc, &argv ); // hyteg::PETScManager manager( &argc, &argv ); hyteg::P2DivKGradBlendingElementwiseCGTest(); } \ No newline at end of file
• Developer

Hi,

I'd suggest to place P2FormDivKGradBlending.[hc]pp in src/hyteg/forms/form_hyteg_generated instead of form_hyteg_manual. Then we have those forms that are completely code-generated from a Python script separated from the ones that use a partly manual approach in combination with macro expansion.

Looks cool though :-)

Cheers
Marcus

• Maintainer

Thank you for noticing this mistake. I moved the generated files to the corresponding folder.

Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!