@@ -567,6 +567,10 @@ void Coordinates::readFromMesh(Options* mesh_options, const std::string& suffix)
567567 dy_ = interpolateAndExtrapolate (dy_, location, extrapolate_x, extrapolate_y, false ,
568568 transform.get ());
569569
570+ setDx (dx_);
571+ setDy (dy_);
572+ setDz (dz_);
573+
570574 // grid data source has staggered fields, so read instead of interpolating
571575 // Diagonal components of metric tensor g^{ij} (default to 1)
572576 const auto g11 = getAtLocOrUnaligned (localmesh, " g11" , 1.0 , suffix, location);
@@ -758,27 +762,39 @@ const Field2D& Coordinates::zlength() const {
758762 return *zlength_cache;
759763}
760764
761- int Coordinates::communicateAndCheckMeshSpacing () {
762- TRACE (" Coordinates::communicateAndCheckMeshSpacing" );
763-
764- localmesh->communicate (dx_, dy_, dz_, Bxy_, J ());
765- covariantMetricTensor.communicate (localmesh);
766- contravariantMetricTensor.communicate (localmesh);
767-
768- output_progress.write (" Calculating differential geometry terms\n " );
769-
770- if (min (abs (dx ())) < 1e-8 ) {
765+ void Coordinates::setDx (FieldMetric dx) {
766+ if (min (abs (dx)) < 1e-8 ) {
771767 throw BoutException (" dx magnitude less than 1e-8" );
772768 }
773769
774- if (min (abs (dy ())) < 1e-8 ) {
770+ dx_ = std::move (dx);
771+ localmesh->communicate (dx_);
772+ }
773+
774+ void Coordinates::setDy (FieldMetric dy) {
775+ if (min (abs (dy)) < 1e-8 ) {
775776 throw BoutException (" dy magnitude less than 1e-8" );
776777 }
777778
778- if (min (abs (dz ())) < 1e-8 ) {
779+ dy_ = std::move (dy);
780+ localmesh->communicate (dy_);
781+ }
782+
783+ void Coordinates::setDz (FieldMetric dz) {
784+ if (min (abs (dz)) < 1e-8 ) {
779785 throw BoutException (" dz magnitude less than 1e-8" );
780786 }
781787
788+ dz_ = std::move (dz);
789+ localmesh->communicate (dz_);
790+ }
791+
792+ int Coordinates::communicateAndCheckMeshSpacing () {
793+ TRACE (" Coordinates::communicateAndCheckMeshSpacing" );
794+
795+ covariantMetricTensor.communicate (localmesh);
796+ contravariantMetricTensor.communicate (localmesh);
797+
782798 return 0 ;
783799}
784800
@@ -1503,21 +1519,24 @@ void Coordinates::checkContravariant() {
15031519FieldMetric& Coordinates::J () const {
15041520 if (jacobian_cache == nullptr ) {
15051521 const auto j = recalculateJacobian ();
1506- auto ptr = std::make_unique<FieldMetric>(j);
1507- jacobian_cache = std::move (ptr);
1522+ jacobian_cache = std::make_unique<FieldMetric>(j);
15081523 }
15091524 return *jacobian_cache;
15101525}
15111526
15121527void Coordinates::setJ (const FieldMetric& J) {
1528+ bout::checkFinite (J, " J" , " RGN_NOCORNERS" );
1529+ bout::checkPositive (J, " J" , " RGN_NOCORNERS" );
1530+
15131531 // TODO: Calculate J and check value is close
1514- auto ptr = std::make_unique<FieldMetric>(J);
1515- jacobian_cache = std::move (ptr );
1532+ jacobian_cache = std::make_unique<FieldMetric>(J);
1533+ localmesh-> communicate (*jacobian_cache );
15161534}
15171535
15181536void Coordinates::setBxy (FieldMetric Bxy) {
15191537 // TODO: Calculate Bxy and check value is close
15201538 Bxy_ = std::move (Bxy);
1539+ localmesh->communicate (Bxy_);
15211540}
15221541
15231542void Coordinates::setContravariantMetricTensor (
0 commit comments