Skip to content

Vector pa kernels #4861

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 47 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
68ae66c
vecmass PA setup
camierjs May 9, 2025
93dbe14
PAVectorMassApply3D with Eval3d
camierjs May 9, 2025
3949dec
PAVectorMassApply2D with Eval2d
camierjs May 10, 2025
d2e2834
VectorMassIntegrator PA specializations
camierjs May 10, 2025
b08d12b
VectorMassIntegrator 2D with MatrixFunctionCoefficients
camierjs May 12, 2025
0892f19
VectorMassIntegrator 3D MatrixFunctionCoefficient
camierjs May 12, 2025
1c04593
VectorMassIntegrator cleanup
camierjs May 12, 2025
72d28e0
VectorDiffusionIntegrator AssemblePA vector coefficients
camierjs May 12, 2025
ba4befc
VectorDiffusionIntegrator wip Matrix coefficient
camierjs May 12, 2025
c707a4d
jj=ii
camierjs May 12, 2025
3086dae
WIP PAVectorDiffusionApply2D mcoeff
camierjs May 13, 2025
5827732
WIP 0 1
camierjs May 13, 2025
7f7e5f6
All c, d
camierjs May 13, 2025
031cd67
VectorDiffusionIntegrator 2D mcoeff
camierjs May 13, 2025
2a3c1c5
VectorDiffusionIntegrator 2D cleanup
camierjs May 13, 2025
3c2f98b
test_vector_pa_integrator all tests passed
camierjs May 13, 2025
3fb13a3
WIP 3D vector diffusion with sym mcoeff
camierjs May 13, 2025
d27fa84
Pre AssemblePA 2D vector diffusion
camierjs May 13, 2025
580dc6f
Simplify VectorDiffusionIntegrator::AssemblePA
camierjs May 13, 2025
6a04555
SmemPAVectorDiffusionApply2D
camierjs May 13, 2025
795a121
SmemPAVectorDiffusionApply3D
camierjs May 13, 2025
686feff
VectorDiffusionAddMultPA registered
camierjs May 13, 2025
51c28ad
Fix grad ii vs. jj matrix coeff
camierjs May 14, 2025
eb68434
Simplify regs_t kernels types on CPU
May 15, 2025
e41c782
Use explicit type names for registers
May 15, 2025
62dd1ae
Cleanup
May 16, 2025
ea25a9b
Remove PAVectorDiffusionApply kernels, fuse SDIM != DIM diffusion vec…
camierjs May 17, 2025
3b88332
Merge branch 'master' into vector-pa-kernels
camierjs May 17, 2025
6bb5f8a
Change pa data layout
camierjs May 18, 2025
190c4a0
WIP SmemPAVectorMassApply2D layouts
camierjs May 18, 2025
2ead488
Pre SmemPAVectorMassApply2D cleanup
camierjs May 18, 2025
82c2e01
Cleanup
camierjs May 18, 2025
7a37cc2
MSVC header guards
camierjs May 18, 2025
c50905e
MAX_T1D for WIN32
camierjs May 18, 2025
f3443f9
MSVC fix
camierjs May 18, 2025
b3e9ddd
WIN32 cmath
camierjs May 18, 2025
f9972a5
Simplify back SmemPAVectorMassApply2D
camierjs May 19, 2025
716c201
GPU vector kernels fix
camierjs May 19, 2025
0742475
test_pa_kernels tags
camierjs May 19, 2025
189c201
Fix shadowing
camierjs May 19, 2025
7dba460
Move kernel methods to fem/kernels.hpp
camierjs May 19, 2025
acbe258
CMake remove header
camierjs May 19, 2025
6145305
Merge branch 'master' into vector-pa-kernels
camierjs May 28, 2025
2e70688
Merge branch 'master' into vector-pa-kernels
camierjs Jun 13, 2025
ba70885
Merge branch 'master' into vector-pa-kernels
camierjs Jun 16, 2025
319b870
Use future namespace for tensor
camierjs Jun 16, 2025
5edabb6
Merge branch 'master' into vector-pa-kernels
camierjs Jun 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove PAVectorDiffusionApply kernels, fuse SDIM != DIM diffusion vec…
…tor into same kernel
  • Loading branch information
camierjs committed May 17, 2025
commit ea25a9bb7b089eb5a6e4c8d666e1c35f146aac5d
92 changes: 45 additions & 47 deletions fem/bilininteg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2557,41 +2557,40 @@ class GroupConvectionIntegrator : public BilinearFormIntegrator
by scalar FE through standard transformation. */
class VectorMassIntegrator: public BilinearFormIntegrator
{
private:
int vdim;
int vdim = -1, Q_order = 0;
Vector shape, te_shape, vec;
DenseMatrix partelmat;
DenseMatrix mcoeff;
int Q_order;

protected:
Coefficient *Q;
VectorCoefficient *VQ;
MatrixCoefficient *MQ;
Coefficient *Q = nullptr;
VectorCoefficient *VQ = nullptr;
MatrixCoefficient *MQ = nullptr;
// PA extension
Vector pa_data;
const DofToQuad *maps; ///< Not owned
const GeometricFactors *geom; ///< Not owned
int dim, ne, nq, dofs1D, quad1D;
int ne, dim, dofs1D, quad1D, coeff_vdim;
Vector pa_data;

public:
/// Construct an integrator with coefficient 1.0
VectorMassIntegrator()
: vdim(-1), Q_order(0), Q(NULL), VQ(NULL), MQ(NULL) { }
VectorMassIntegrator() = default;

/** Construct an integrator with scalar coefficient q. If possible, save
memory by using a scalar integrator since the resulting matrix is block
diagonal with the same diagonal block repeated. */
VectorMassIntegrator(Coefficient &q, int qo = 0)
: vdim(-1), Q_order(qo), Q(&q), VQ(NULL), MQ(NULL) { }
VectorMassIntegrator(Coefficient &q, const IntegrationRule *ir)
: BilinearFormIntegrator(ir), vdim(-1), Q_order(0), Q(&q), VQ(NULL),
MQ(NULL) { }
VectorMassIntegrator(Coefficient &q, int qo = 0): Q_order(qo), Q(&q) { }

VectorMassIntegrator(Coefficient &q, const IntegrationRule *ir):
BilinearFormIntegrator(ir), Q(&q) { }

/// Construct an integrator with diagonal coefficient q
VectorMassIntegrator(VectorCoefficient &q, int qo = 0)
: vdim(q.GetVDim()), Q_order(qo), Q(NULL), VQ(&q), MQ(NULL) { }
VectorMassIntegrator(VectorCoefficient &q, int qo = 0):
vdim(q.GetVDim()), Q_order(qo), VQ(&q) { }

/// Construct an integrator with matrix coefficient q
VectorMassIntegrator(MatrixCoefficient &q, int qo = 0)
: vdim(q.GetVDim()), Q_order(qo), Q(NULL), VQ(NULL), MQ(&q) { }
VectorMassIntegrator(MatrixCoefficient &q, int qo = 0):
vdim(q.GetVDim()), Q_order(qo), MQ(&q) { }

int GetVDim() const { return vdim; }
void SetVDim(int vdim_) { vdim = vdim_; }
Expand All @@ -2603,6 +2602,7 @@ class VectorMassIntegrator: public BilinearFormIntegrator
const FiniteElement &test_fe,
ElementTransformation &Trans,
DenseMatrix &elmat) override;

using BilinearFormIntegrator::AssemblePA;
void AssemblePA(const FiniteElementSpace &fes) override;
void AssembleMF(const FiniteElementSpace &fes) override;
Expand All @@ -2613,7 +2613,8 @@ class VectorMassIntegrator: public BilinearFormIntegrator
bool SupportsCeed() const override { return DeviceCanUseCeed(); }

using VectorMassAddMultPAType =
void(*)(const int, const Array<real_t>&, const Vector&,
void(*)(const int, const int,
const Array<real_t>&, const Vector&,
const Vector&, Vector&, const int, const int);

MFEM_REGISTER_KERNELS(VectorMassAddMultPA,
Expand Down Expand Up @@ -3061,40 +3062,36 @@ class DivDivIntegrator: public BilinearFormIntegrator
to be the spatial dimension (i.e. 2-dimension or 3-dimension). */
class VectorDiffusionIntegrator : public BilinearFormIntegrator
{
protected:
Coefficient *Q = NULL;
VectorCoefficient *VQ = NULL;
MatrixCoefficient *MQ = NULL;
int vdim = -1;
DenseMatrix dshape, dshapedxt, pelmat;
DenseMatrix mcoeff;
Vector vcoeff;

protected:
Coefficient *Q = nullptr;
VectorCoefficient *VQ = nullptr;
MatrixCoefficient *MQ = nullptr;
// PA extension
const DofToQuad *maps; ///< Not owned
const GeometricFactors *geom; ///< Not owned
int dim, sdim, ne, dofs1D, quad1D;
int coeff_vdim;
int ne, dim, sdim, dofs1D, quad1D, coeff_vdim;
Vector pa_data;

private:
DenseMatrix dshape, dshapedxt, pelmat;
int vdim = -1;
DenseMatrix mcoeff;
Vector vcoeff;

public:
VectorDiffusionIntegrator() { }
/// Construct an integrator with coefficient 1.0
VectorDiffusionIntegrator() = default;

/** \brief Integrator with unit coefficient for caller-specified vector
dimension.

If the vector dimension does not match the true dimension of the space,
the resulting element matrix will be mathematically invalid. */
VectorDiffusionIntegrator(int vector_dimension)
: vdim(vector_dimension) { }
VectorDiffusionIntegrator(int vector_dimension): vdim(vector_dimension) { }

VectorDiffusionIntegrator(Coefficient &q)
: Q(&q) { }
VectorDiffusionIntegrator(Coefficient &q): Q(&q) { }

VectorDiffusionIntegrator(Coefficient &q, const IntegrationRule *ir)
: BilinearFormIntegrator(ir), Q(&q) { }
VectorDiffusionIntegrator(Coefficient &q, const IntegrationRule *ir):
BilinearFormIntegrator(ir), Q(&q) { }

/** \brief Integrator with scalar coefficient for caller-specified vector
dimension.
Expand All @@ -3104,8 +3101,8 @@ class VectorDiffusionIntegrator : public BilinearFormIntegrator

If the vector dimension does not match the true dimension of the space,
the resulting element matrix will be mathematically invalid. */
VectorDiffusionIntegrator(Coefficient &q, int vector_dimension)
: Q(&q), vdim(vector_dimension) { }
VectorDiffusionIntegrator(Coefficient &q, int vector_dimension):
vdim(vector_dimension), Q(&q) { }

/** \brief Integrator with \c VectorCoefficient. The vector dimension of the
\c FiniteElementSpace is assumed to be the same as the dimension of the
Expand All @@ -3116,8 +3113,8 @@ class VectorDiffusionIntegrator : public BilinearFormIntegrator

If the vector dimension does not match the true dimension of the space,
the resulting element matrix will be mathematically invalid. */
VectorDiffusionIntegrator(VectorCoefficient &vq)
: VQ(&vq), vdim(vq.GetVDim()) { }
VectorDiffusionIntegrator(VectorCoefficient &vq):
vdim(vq.GetVDim()), VQ(&vq) { }

/** \brief Integrator with \c MatrixCoefficient. The vector dimension of the
\c FiniteElementSpace is assumed to be the same as the dimension of the
Expand All @@ -3128,15 +3125,16 @@ class VectorDiffusionIntegrator : public BilinearFormIntegrator

If the vector dimension does not match the true dimension of the space,
the resulting element matrix will be mathematically invalid. */
VectorDiffusionIntegrator(MatrixCoefficient& mq)
: MQ(&mq), vdim(mq.GetVDim()) { }
VectorDiffusionIntegrator(MatrixCoefficient& mq):
vdim(mq.GetVDim()), MQ(&mq) { }

void AssembleElementMatrix(const FiniteElement &el,
ElementTransformation &Trans,
DenseMatrix &elmat) override;
void AssembleElementVector(const FiniteElement &el,
ElementTransformation &Tr,
const Vector &elfun, Vector &elvect) override;

using BilinearFormIntegrator::AssemblePA;
void AssemblePA(const FiniteElementSpace &fes) override;
void AssembleMF(const FiniteElementSpace &fes) override;
Expand All @@ -3150,11 +3148,11 @@ class VectorDiffusionIntegrator : public BilinearFormIntegrator
void(*)(const int, const int,
const Array<real_t>&, const Array<real_t>&,
const Vector&, const Vector&, Vector&,
const int, const int);
const int, const int, const int);

MFEM_REGISTER_KERNELS(VectorDiffusionAddMultPA,
VectorDiffusionAddMultPAType,
(int, int, int));
(int, int, int, int));
};

/** Integrator for the linear elasticity form:
Expand Down
2 changes: 1 addition & 1 deletion fem/integ/bilininteg_mass_pa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void MassIntegrator::AssemblePA(const FiniteElementSpace &fes)

const int NE = ne;
const int Q1D = quad1D;
const int NQ = pow(Q1D, dim);
const int NQ = static_cast<int>(pow(Q1D, dim));
const bool const_c = coeff.Size() == 1;
const bool by_val = map_type == FiniteElement::VALUE;
const auto W = Reshape(ir->GetWeights().Read(), NQ);
Expand Down
Loading