Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c95789ba3c |
+9
-10
@@ -38,8 +38,9 @@ GridFunction::GridFunction(Mesh *m, std::istream &input)
|
|||||||
// Grid functions are stored on the device
|
// Grid functions are stored on the device
|
||||||
UseDevice(true);
|
UseDevice(true);
|
||||||
|
|
||||||
fes = new FiniteElementSpace;
|
owned_fes.reset(new FiniteElementSpace);
|
||||||
fec = fes->Load(m, input);
|
fes = owned_fes.get();
|
||||||
|
fec.reset(fes->Load(m, input));
|
||||||
|
|
||||||
skip_comment_lines(input, '#');
|
skip_comment_lines(input, '#');
|
||||||
istream::int_type next_char = input.peek();
|
istream::int_type next_char = input.peek();
|
||||||
@@ -81,10 +82,11 @@ GridFunction::GridFunction(Mesh *m, GridFunction *gf_array[], int num_pieces)
|
|||||||
int vdim, ordering;
|
int vdim, ordering;
|
||||||
|
|
||||||
fes = gf_array[0]->FESpace();
|
fes = gf_array[0]->FESpace();
|
||||||
fec = FiniteElementCollection::New(fes->FEColl()->Name());
|
fec.reset(FiniteElementCollection::New(fes->FEColl()->Name()));
|
||||||
vdim = fes->GetVDim();
|
vdim = fes->GetVDim();
|
||||||
ordering = fes->GetOrdering();
|
ordering = fes->GetOrdering();
|
||||||
fes = new FiniteElementSpace(m, fec, vdim, ordering);
|
owned_fes.reset(new FiniteElementSpace(m, fec.get(), vdim, ordering));
|
||||||
|
fes = owned_fes.get();
|
||||||
SetSize(fes->GetVSize());
|
SetSize(fes->GetVSize());
|
||||||
|
|
||||||
if (m->NURBSext)
|
if (m->NURBSext)
|
||||||
@@ -153,12 +155,9 @@ GridFunction::GridFunction(Mesh *m, GridFunction *gf_array[], int num_pieces)
|
|||||||
|
|
||||||
void GridFunction::Destroy()
|
void GridFunction::Destroy()
|
||||||
{
|
{
|
||||||
if (fec)
|
owned_fes.reset();
|
||||||
{
|
fec.reset();
|
||||||
delete fes;
|
fes = nullptr;
|
||||||
delete fec;
|
|
||||||
fec = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GridFunction::Update()
|
void GridFunction::Update()
|
||||||
|
|||||||
+7
-24
@@ -20,6 +20,7 @@
|
|||||||
#include "../general/adios2stream.hpp"
|
#include "../general/adios2stream.hpp"
|
||||||
#endif
|
#endif
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
#include <memory>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@@ -30,14 +31,13 @@ namespace mfem
|
|||||||
class GridFunction : public Vector
|
class GridFunction : public Vector
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
/// FE space on which the grid function lives. Owned if #fec is not NULL.
|
/// FE space on which the grid function lives.
|
||||||
FiniteElementSpace *fes;
|
FiniteElementSpace *fes;
|
||||||
|
|
||||||
/** @brief Used when the grid function is read from a file. It can also be
|
/** @brief Used when the grid function is read from a file. It can also be
|
||||||
set explicitly, see MakeOwner().
|
set explicitly, see MakeOwner(). */
|
||||||
|
std::shared_ptr<FiniteElementCollection> fec;
|
||||||
If not NULL, this pointer is owned by the GridFunction. */
|
std::shared_ptr<FiniteElementSpace> owned_fes;
|
||||||
FiniteElementCollection *fec;
|
|
||||||
|
|
||||||
long fes_sequence; // see FiniteElementSpace::sequence, Mesh::sequence
|
long fes_sequence; // see FiniteElementSpace::sequence, Mesh::sequence
|
||||||
|
|
||||||
@@ -74,11 +74,6 @@ public:
|
|||||||
|
|
||||||
GridFunction() { fes = NULL; fec = NULL; fes_sequence = 0; UseDevice(true); }
|
GridFunction() { fes = NULL; fec = NULL; fes_sequence = 0; UseDevice(true); }
|
||||||
|
|
||||||
/// Copy constructor. The internal true-dof vector #t_vec is not copied.
|
|
||||||
GridFunction(const GridFunction &orig)
|
|
||||||
: Vector(orig), fes(orig.fes), fec(NULL), fes_sequence(orig.fes_sequence)
|
|
||||||
{ UseDevice(true); }
|
|
||||||
|
|
||||||
/// Construct a GridFunction associated with the FiniteElementSpace @a *f.
|
/// Construct a GridFunction associated with the FiniteElementSpace @a *f.
|
||||||
GridFunction(FiniteElementSpace *f) : Vector(f->GetVSize())
|
GridFunction(FiniteElementSpace *f) : Vector(f->GetVSize())
|
||||||
{ fes = f; fec = NULL; fes_sequence = f->GetSequence(); UseDevice(true); }
|
{ fes = f; fec = NULL; fes_sequence = f->GetSequence(); UseDevice(true); }
|
||||||
@@ -107,21 +102,12 @@ public:
|
|||||||
|
|
||||||
GridFunction(Mesh *m, GridFunction *gf_array[], int num_pieces);
|
GridFunction(Mesh *m, GridFunction *gf_array[], int num_pieces);
|
||||||
|
|
||||||
/// Copy assignment. Only the data of the base class Vector is copied.
|
|
||||||
/** It is assumed that this object and @a rhs use FiniteElementSpace%s that
|
|
||||||
have the same size.
|
|
||||||
|
|
||||||
@note Defining this method overwrites the implicitly defined copy
|
|
||||||
assignment operator. */
|
|
||||||
GridFunction &operator=(const GridFunction &rhs)
|
|
||||||
{ return operator=((const Vector &)rhs); }
|
|
||||||
|
|
||||||
/// Make the GridFunction the owner of #fec and #fes.
|
/// Make the GridFunction the owner of #fec and #fes.
|
||||||
/** If the new FiniteElementCollection, @a fec_, is NULL, ownership of #fec
|
/** If the new FiniteElementCollection, @a fec_, is NULL, ownership of #fec
|
||||||
and #fes is taken away. */
|
and #fes is taken away. */
|
||||||
void MakeOwner(FiniteElementCollection *fec_) { fec = fec_; }
|
void MakeOwner(FiniteElementCollection *fec_) { fec.reset(fec_); }
|
||||||
|
|
||||||
FiniteElementCollection *OwnFEC() { return fec; }
|
FiniteElementCollection *OwnFEC() { return fec.get(); }
|
||||||
|
|
||||||
int VectorDim() const;
|
int VectorDim() const;
|
||||||
int CurlDim() const;
|
int CurlDim() const;
|
||||||
@@ -754,9 +740,6 @@ public:
|
|||||||
/** @brief Write the GridFunction in STL format. Note that the mesh dimension
|
/** @brief Write the GridFunction in STL format. Note that the mesh dimension
|
||||||
must be 2 and that quad elements will be broken into two triangles.*/
|
must be 2 and that quad elements will be broken into two triangles.*/
|
||||||
void SaveSTL(std::ostream &out, int TimesToRefine = 1);
|
void SaveSTL(std::ostream &out, int TimesToRefine = 1);
|
||||||
|
|
||||||
/// Destroys grid function.
|
|
||||||
virtual ~GridFunction() { Destroy(); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+6
-4
@@ -39,9 +39,11 @@ ParGridFunction::ParGridFunction(ParMesh *pmesh, const GridFunction *gf,
|
|||||||
{
|
{
|
||||||
const FiniteElementSpace *glob_fes = gf->FESpace();
|
const FiniteElementSpace *glob_fes = gf->FESpace();
|
||||||
// duplicate the FiniteElementCollection from 'gf'
|
// duplicate the FiniteElementCollection from 'gf'
|
||||||
fec = FiniteElementCollection::New(glob_fes->FEColl()->Name());
|
fec.reset(FiniteElementCollection::New(glob_fes->FEColl()->Name()));
|
||||||
// create a local ParFiniteElementSpace from the global one:
|
// create a local ParFiniteElementSpace from the global one:
|
||||||
fes = pfes = new ParFiniteElementSpace(pmesh, glob_fes, partitioning, fec);
|
fes = pfes = new ParFiniteElementSpace(pmesh, glob_fes, partitioning,
|
||||||
|
fec.get());
|
||||||
|
owned_fes.reset(pfes);
|
||||||
SetSize(pfes->GetVSize());
|
SetSize(pfes->GetVSize());
|
||||||
|
|
||||||
if (partitioning)
|
if (partitioning)
|
||||||
@@ -81,10 +83,10 @@ ParGridFunction::ParGridFunction(ParMesh *pmesh, std::istream &input)
|
|||||||
: GridFunction(pmesh, input)
|
: GridFunction(pmesh, input)
|
||||||
{
|
{
|
||||||
// Convert the FiniteElementSpace, fes, to a ParFiniteElementSpace:
|
// Convert the FiniteElementSpace, fes, to a ParFiniteElementSpace:
|
||||||
pfes = new ParFiniteElementSpace(pmesh, fec, fes->GetVDim(),
|
pfes = new ParFiniteElementSpace(pmesh, fec.get(), fes->GetVDim(),
|
||||||
fes->GetOrdering());
|
fes->GetOrdering());
|
||||||
delete fes;
|
|
||||||
fes = pfes;
|
fes = pfes;
|
||||||
|
owned_fes.reset(pfes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParGridFunction::Update()
|
void ParGridFunction::Update()
|
||||||
|
|||||||
@@ -49,10 +49,6 @@ protected:
|
|||||||
public:
|
public:
|
||||||
ParGridFunction() { pfes = NULL; }
|
ParGridFunction() { pfes = NULL; }
|
||||||
|
|
||||||
/// Copy constructor. The internal vector #face_nbr_data is not copied.
|
|
||||||
ParGridFunction(const ParGridFunction &orig)
|
|
||||||
: GridFunction(orig), pfes(orig.pfes) { }
|
|
||||||
|
|
||||||
ParGridFunction(ParFiniteElementSpace *pf) : GridFunction(pf), pfes(pf) { }
|
ParGridFunction(ParFiniteElementSpace *pf) : GridFunction(pf), pfes(pf) { }
|
||||||
|
|
||||||
/// Construct a ParGridFunction using previously allocated array @a data.
|
/// Construct a ParGridFunction using previously allocated array @a data.
|
||||||
@@ -93,15 +89,6 @@ public:
|
|||||||
constructed. The new ParGridFunction assumes ownership of both. */
|
constructed. The new ParGridFunction assumes ownership of both. */
|
||||||
ParGridFunction(ParMesh *pmesh, std::istream &input);
|
ParGridFunction(ParMesh *pmesh, std::istream &input);
|
||||||
|
|
||||||
/// Copy assignment. Only the data of the base class Vector is copied.
|
|
||||||
/** It is assumed that this object and @a rhs use ParFiniteElementSpace%s
|
|
||||||
that have the same size.
|
|
||||||
|
|
||||||
@note Defining this method overwrites the implicitly defined copy
|
|
||||||
assignment operator. */
|
|
||||||
ParGridFunction &operator=(const ParGridFunction &rhs)
|
|
||||||
{ return operator=((const Vector &)rhs); }
|
|
||||||
|
|
||||||
/// Assign constant values to the ParGridFunction data.
|
/// Assign constant values to the ParGridFunction data.
|
||||||
ParGridFunction &operator=(double value)
|
ParGridFunction &operator=(double value)
|
||||||
{ GridFunction::operator=(value); return *this; }
|
{ GridFunction::operator=(value); return *this; }
|
||||||
@@ -459,8 +446,6 @@ public:
|
|||||||
|
|
||||||
/// Merge the local grid functions
|
/// Merge the local grid functions
|
||||||
void SaveAsOne(std::ostream &out = mfem::out) const;
|
void SaveAsOne(std::ostream &out = mfem::out) const;
|
||||||
|
|
||||||
virtual ~ParGridFunction() { }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user