Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
chengcli committed Nov 5, 2023
1 parent be3c201 commit 956456a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
21 changes: 21 additions & 0 deletions src/air_parcel.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// application
#include <application/exceptions.hpp>

// athena
#include <athena/mesh/mesh.hpp>

// climath
#include <climath/core.h> // sqr

Expand Down Expand Up @@ -723,4 +726,22 @@ void distribute_to_conserved(MeshBlock* pmb, int k, int j, int i,
}
}

AirColumn gather_from_primitive(MeshBlock const* pmb, int k, int j) {
return gather_from_primitive(pmb, k, j, 0, pmb->ncells1 - 1);
}

AirColumn gather_from_conserved(MeshBlock const* pmb, int k, int j) {
return gather_from_conserved(pmb, k, j, 0, pmb->ncells1 - 1);
}

void distribute_to_primitive(MeshBlock* pmb, int k, int j,
AirColumn const& ac) {
distribute_to_primitive(pmb, k, j, 0, pmb->ncells1 - 1, ac);
}

void distribute_to_conserved(MeshBlock* pmb, int k, int j,
AirColumn const& ac) {
distribute_to_conserved(pmb, k, j, 0, pmb->ncells1 - 1, ac);
}

} // namespace AirParcelHelper
9 changes: 7 additions & 2 deletions src/air_parcel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ using AirColumn = std::vector<AirParcel>;

namespace AirParcelHelper {
AirParcel gather_from_primitive(MeshBlock const *pmb, int k, int j, int i);
AirColumn gather_from_primitive(MeshBlock const *pmb, int k, int j);

inline AirColumn gather_from_primitive(MeshBlock const *pmb, int k, int j,
int il, int iu) {
Expand All @@ -134,6 +135,7 @@ inline AirColumn gather_from_primitive(MeshBlock const *pmb, int k, int j,
}

AirParcel gather_from_conserved(MeshBlock const *pmb, int k, int j, int i);
AirColumn gather_from_conserved(MeshBlock const *pmb, int k, int j);

inline AirColumn gather_from_conserved(MeshBlock const *pmb, int k, int j,
int il, int iu) {
Expand All @@ -146,7 +148,8 @@ inline AirColumn gather_from_conserved(MeshBlock const *pmb, int k, int j,
}

void distribute_to_primitive(MeshBlock *pmb, int k, int j, int i,
AirParcel const &prim);
AirParcel const &ac);
void distribute_to_primitive(MeshBlock *pmb, int k, int j, AirColumn const &ac);

inline void distribute_to_primitive(MeshBlock *pmb, int k, int j, int il,
int iu, AirColumn const &ac) {
Expand All @@ -156,14 +159,16 @@ inline void distribute_to_primitive(MeshBlock *pmb, int k, int j, int il,
}

void distribute_to_conserved(MeshBlock *pmb, int k, int j, int i,
AirParcel const &cons);
AirParcel const &ac);
void distribute_to_conserved(MeshBlock *pmb, int k, int j, AirColumn const &ac);

inline void distribute_to_conserved(MeshBlock *pmb, int k, int j, int il,
int iu, AirColumn const &ac) {
for (int i = il; i <= iu; ++i) {
distribute_to_conserved(pmb, k, j, i, ac[i - il]);
}
}

} // namespace AirParcelHelper

#endif // SRC_AIR_PARCEL_HPP_
6 changes: 2 additions & 4 deletions src/harp/radiation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ void Radiation::CalRadiativeFlux(MeshBlock const *pmb, int k, int j, int il,
int iu) {
auto pcoord = pmb->pcoord;

AirColumn &&ac =
AirParcelHelper::gather_from_primitive(pmb, k, j, 0, pmb->ncells1 - 1);
AirColumn &&ac = AirParcelHelper::gather_from_primitive(pmb, k, j);

Real grav = -pmb->phydro->hsrc.GetG1();

Expand All @@ -138,8 +137,7 @@ void Radiation::CalRadiance(MeshBlock const *pmb, int k, int j, int il,

auto pcoord = pmb->pcoord;

AirColumn &&ac =
AirParcelHelper::gather_from_primitive(pmb, k, j, 0, pmb->ncells1 - 1);
AirColumn &&ac = AirParcelHelper::gather_from_primitive(pmb, k, j);

Real grav = -pmb->phydro->hsrc.GetG1();

Expand Down

0 comments on commit 956456a

Please sign in to comment.