https://github.com/hpc-maths/GenEO
Tip revision: 885ab129b2402c353548bcfc51214f608f09bade authored by Loic Gouarin on 02 December 2022, 12:34:47 UTC
add fenics example and update environment.yml
add fenics example and update environment.yml
Tip revision: 885ab12
rhs.py
# Authors:
# Loic Gouarin <loic.gouarin@cmap.polytechnique.fr>
# Nicole Spillane <nicole.spillane@cmap.polytechnique.fr>
#
# License: BSD 3 clause
from .utils import buildVecWithFunction
from.assembling import buildMassMatrix
def buildRHS(da, h, apply_func):
"""
Construct the right hand side of the elasticity problem.
Parameters
==========
da : petsc.DMDA
The mesh structure.
h : list
The space step in each direction.
apply_func: function
Function corresponding to the f (rhs, or source term) in the
elasticity problem.
Returns
=======
b: petsc.Vec
The right hand side.
"""
b = da.createGlobalVec()
A = buildMassMatrix(da, h)
A.assemble()
tmp = buildVecWithFunction(da, apply_func)
A.mult(tmp, b)
return b