Skip to content

Commit

Permalink
Merge pull request #3000 from boutproject/preserve-regionid
Browse files Browse the repository at this point in the history
Fix: preserve regionID
  • Loading branch information
bendudson authored Oct 22, 2024
2 parents 43aa3bf + 9ba18d8 commit d17fb59
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/field/field3d.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ Field3D::Field3D(Mesh* localmesh, CELL_LOC location_in, DirectionTypes direction
/// Doesn't copy any data, just create a new reference to the same data (copy on change
/// later)
Field3D::Field3D(const Field3D& f)
: Field(f), data(f.data), yup_fields(f.yup_fields), ydown_fields(f.ydown_fields) {
: Field(f), data(f.data), yup_fields(f.yup_fields), ydown_fields(f.ydown_fields),
regionID(f.regionID) {

TRACE("Field3D(Field3D&)");

Expand Down Expand Up @@ -252,6 +253,7 @@ Field3D& Field3D::operator=(const Field3D& rhs) {
// Copy parallel slices or delete existing ones.
yup_fields = rhs.yup_fields;
ydown_fields = rhs.ydown_fields;
regionID = rhs.regionID;

// Copy the data and data sizes
nx = rhs.nx;
Expand All @@ -274,6 +276,7 @@ Field3D& Field3D::operator=(Field3D&& rhs) {
nx = rhs.nx;
ny = rhs.ny;
nz = rhs.nz;
regionID = rhs.regionID;

data = std::move(rhs.data);

Expand All @@ -292,6 +295,7 @@ Field3D& Field3D::operator=(const Field2D& rhs) {
// Delete existing parallel slices. We don't copy parallel slices, so any
// that currently exist will be incorrect.
clearParallelSlices();
resetRegion();

setLocation(rhs.getLocation());

Expand Down Expand Up @@ -319,6 +323,7 @@ void Field3D::operator=(const FieldPerp& rhs) {
// Delete existing parallel slices. We don't copy parallel slices, so any
// that currently exist will be incorrect.
clearParallelSlices();
resetRegion();

/// Make sure there's a unique array to copy data into
allocate();
Expand All @@ -333,6 +338,7 @@ Field3D& Field3D::operator=(const BoutReal val) {
// Delete existing parallel slices. We don't copy parallel slices, so any
// that currently exist will be incorrect.
clearParallelSlices();
resetRegion();

allocate();

Expand Down

0 comments on commit d17fb59

Please sign in to comment.