MFEM  v4.5.2
Finite element discretization library
plinearform.cpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2023, Lawrence Livermore National Security, LLC. Produced
2 // at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3 // LICENSE and NOTICE for details. LLNL-CODE-806117.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability visit https://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the BSD-3 license. We welcome feedback and contributions, see file
10 // CONTRIBUTING.md for details.
11 
12 #include "../config/config.hpp"
13 
14 #ifdef MFEM_USE_MPI
15 
16 #include "fem.hpp"
17 
18 namespace mfem
19 {
20 
22 {
23  if (pf) { pfes = pf; }
25 }
26 
28 {
29  pfes = pf;
30  LinearForm::Update(pf,v,v_offset);
31 }
32 
34 {
35  LinearForm::MakeRef(f, v, v_offset);
36  pfes = dynamic_cast<ParFiniteElementSpace*>(f);
37  MFEM_ASSERT(pfes != NULL, "not a ParFiniteElementSpace");
38 }
39 
41 {
42  LinearForm::MakeRef(pf, v, v_offset);
43  pfes = pf;
44 }
45 
47 {
49 
50  if (interior_face_integs.Size())
51  {
54  }
55 }
56 
58 {
59  bool parallel;
60  bool local = LinearForm::SupportsDevice();
61  MPI_Allreduce(&local, &parallel, 1, MPI_C_BOOL, MPI_LAND, pfes->GetComm());
62  return parallel;
63 }
64 
66 {
67  Array<int> vdofs;
68  Vector elemvect;
69 
70  if (interior_face_integs.Size())
71  {
72  ParMesh *pmesh = pfes->GetParMesh();
73  for (int k = 0; k < interior_face_integs.Size(); k++)
74  {
75  for (int i = 0; i < pmesh->GetNSharedFaces(); i++)
76  {
77  FaceElementTransformations *tr = NULL;
78  tr = pmesh->GetSharedFaceTransformations(i);
79 
80  if (tr != NULL)
81  {
82  int Elem2Nbr = tr->Elem2No - pmesh->GetNE();
83  fes -> GetElementVDofs (tr -> Elem1No, vdofs);
85  AssembleRHSElementVect(*fes->GetFE(tr->Elem1No),
86  *pfes->GetFaceNbrFE(Elem2Nbr),
87  *tr, elemvect);
88  AddElementVector (vdofs, elemvect);
89  }
90  }
91  }
92  }
93 }
94 
96 {
97  const Operator* prolong = pfes->GetProlongationMatrix();
98  prolong->MultTranspose(*this, tv);
99 }
100 
102 {
104  const Operator* prolong = pfes->GetProlongationMatrix();
105  prolong->MultTranspose(*this, *tv);
106  return tv;
107 }
108 
109 }
110 
111 #endif
virtual void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator: y=A^t(x). The default behavior in class Operator is to generate an ...
Definition: operator.hpp:93
virtual const Operator * GetProlongationMatrix() const
The returned Operator is owned by the FiniteElementSpace.
Definition: pfespace.cpp:1153
HypreParVector * NewTrueDofVector()
Definition: pfespace.hpp:331
const FiniteElement * GetFaceNbrFE(int i) const
Definition: pfespace.cpp:1517
virtual void MakeRef(FiniteElementSpace *f, Vector &v, int v_offset)
Make the ParLinearForm reference external data on a new FiniteElementSpace.
Definition: plinearform.cpp:33
virtual void MakeRef(FiniteElementSpace *f, Vector &v, int v_offset)
Make the LinearForm reference external data on a new FiniteElementSpace.
Definition: linearform.cpp:360
void Assemble()
Assembles the linear form i.e. sums over all domain/bdr integrators.
Definition: linearform.cpp:168
A specialized ElementTransformation class representing a face and its two neighboring elements...
Definition: eltrans.hpp:480
Abstract parallel finite element space.
Definition: pfespace.hpp:28
virtual const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i&#39;th element in t...
Definition: fespace.cpp:2783
Array< LinearFormIntegrator * > interior_face_integs
Set of Internal Face Integrators to be applied.
Definition: linearform.hpp:66
double f(const Vector &xvec)
Definition: lor_mms.hpp:32
void Assemble()
Assembles the ParLinearForm i.e. sums over all domain/bdr integrators.
Definition: plinearform.cpp:46
FaceElementTransformations * GetSharedFaceTransformations(int sf, bool fill2=true)
Definition: pmesh.cpp:3080
ParMesh * GetParMesh() const
Definition: pfespace.hpp:277
FiniteElementSpace * fes
FE space on which the LinearForm lives. Not owned.
Definition: linearform.hpp:30
virtual bool SupportsDevice()
Return true if assembly on device is supported, false otherwise.
Definition: linearform.cpp:104
void AddElementVector(const Array< int > &dofs, const Vector &elemvect)
Add elements of the elemvect Vector to the entries listed in dofs. Negative dof values cause the -dof...
Definition: vector.cpp:640
virtual bool SupportsDevice()
Return true if assembly on device is supported, false otherwise.
Definition: plinearform.cpp:57
Wrapper for hypre&#39;s parallel vector class.
Definition: hypre.hpp:161
int GetNSharedFaces() const
Return the number of shared faces (3D), edges (2D), vertices (1D)
Definition: pmesh.cpp:3196
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition: fespace.hpp:96
HypreParVector * ParallelAssemble()
Returns the vector assembled on the true dofs, i.e. P^t v.
void Update()
Update the object according to the associated FE space fes.
Definition: linearform.cpp:344
int GetNE() const
Returns number of elements.
Definition: mesh.hpp:936
ParFiniteElementSpace * pfes
Points to the same object as fes.
Definition: plinearform.hpp:29
MPI_Comm GetComm() const
Definition: pfespace.hpp:273
Vector data type.
Definition: vector.hpp:60
Abstract operator.
Definition: operator.hpp:24
Class for parallel meshes.
Definition: pmesh.hpp:32