Skip to content

Commit

Permalink
Merge branch 'AMReX-Codes:development' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
ruohai0925 authored Aug 22, 2024
2 parents 1f6e3ec + b05f69f commit fabdd5d
Show file tree
Hide file tree
Showing 27 changed files with 1,540 additions and 606 deletions.
32 changes: 32 additions & 0 deletions Docs/sphinx_documentation/source/RuntimeParameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1204,3 +1204,35 @@ enabled.
which are unnecessary for correctness, could potentially degrade the
performance.

.. py:data:: tiny_profiler.enabled
:type: bool
:value: true

.. versionadded:: 24.09
Runtime parameter `tiny_profiler.enabled``.

This parameter can be used to disable tiny profiling including
:cpp:`CArena` memory profiling at run time.

.. py:data:: tiny_profiler.memprof_enabled
:type: bool
:value: true

.. versionadded:: 24.09
Runtime parameter ``tiny_profiler.memprof_enabled``.

This parameter can be used to disable :cpp:`CArena` memory profiling at
run time. If ``tiny_profiler.enabled`` is false, this parameter has no
effects.

.. py:data:: tiny_profiler.output_file
:type: string
:value: [empty]

.. versionadded:: 24.09
Runtime parameter ``tiny_profiler.output_file``.

If this parameter is empty, the output of tiny profiling is dumped on the
default out stream of AMReX. If it's not empty, it specifies the file
name for the output. Note that ``/dev/null`` is a special name that mean
a null file.
315 changes: 114 additions & 201 deletions Docs/sphinx_documentation/source/TimeIntegration_Chapter.rst

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions Src/Base/AMReX_FEIntegrator.H
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ public:
// So we initialize S_new by copying the old state.
IntegratorOps<T>::Copy(S_new, S_old);

// Call the pre RHS hook
BaseT::pre_rhs_action(S_new, time);

// F = RHS(S, t)
T& F = *F_nodes[0];
BaseT::Rhs(F, S_new, time);
Expand Down
8 changes: 8 additions & 0 deletions Src/Base/AMReX_Geometry.H
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,14 @@ public:
*/
void computeRoundoffDomain ();

//! Returns roundoff domain's lower end
[[nodiscard]] GpuArray<ParticleReal, AMREX_SPACEDIM> const&
RoundOffLo () const { return roundoff_lo; }

//! Returns roundoff domain's higher end
[[nodiscard]] GpuArray<ParticleReal, AMREX_SPACEDIM> const&
RoundOffHi () const { return roundoff_hi; }

private:
void read_params ();

Expand Down
33 changes: 8 additions & 25 deletions Src/Base/AMReX_IntegratorBase.H
Original file line number Diff line number Diff line change
Expand Up @@ -165,31 +165,25 @@ protected:
/**
* \brief Rhs is the right-hand-side function the integrator will use.
*/
std::function<void(T& rhs, const T& state, const amrex::Real time)> Rhs;
std::function<void(T& rhs, T& state, const amrex::Real time)> Rhs;

/**
* \brief RhsIm is the implicit right-hand-side function an ImEx integrator
* will use.
*/
std::function<void(T& rhs, const T& state, const amrex::Real time)> RhsIm;
std::function<void(T& rhs, T& state, const amrex::Real time)> RhsIm;

/**
* \brief RhsEx is the explicit right-hand-side function an ImEx integrator
* will use.
*/
std::function<void(T& rhs, const T& state, const amrex::Real time)> RhsEx;
std::function<void(T& rhs, T& state, const amrex::Real time)> RhsEx;

/**
* \brief RhsFast is the fast timescale right-hand-side function a multirate
* integrator will use.
*/
std::function<void(T& rhs, const T& state, const amrex::Real time)> RhsFast;

/**
* \brief The pre_rhs_action function is called by the integrator on state
* data before using it to evaluate a right-hand side.
*/
std::function<void (T&, amrex::Real)> pre_rhs_action;
std::function<void(T& rhs, T& state, const amrex::Real time)> RhsFast;

/**
* \brief The post_stage_action function is called by the integrator on
Expand Down Expand Up @@ -283,28 +277,23 @@ public:

virtual ~IntegratorBase () = default;

void set_rhs (std::function<void(T&, const T&, const amrex::Real)> F)
void set_rhs (std::function<void(T&, T&, const amrex::Real)> F)
{
Rhs = F;
}

void set_imex_rhs (std::function<void(T&, const T&, const amrex::Real)> Fi,
std::function<void(T&, const T&, const amrex::Real)> Fe)
void set_imex_rhs (std::function<void(T&, T&, const amrex::Real)> Fi,
std::function<void(T&, T&, const amrex::Real)> Fe)
{
RhsIm = Fi;
RhsEx = Fe;
}

void set_fast_rhs (std::function<void(T&, const T&, const amrex::Real)> F)
void set_fast_rhs (std::function<void(T&, T&, const amrex::Real)> F)
{
RhsFast = F;
}

void set_pre_rhs_action (std::function<void (T&, amrex::Real)> A)
{
pre_rhs_action = A;
}

void set_post_stage_action (std::function<void (T&, amrex::Real)> A)
{
post_stage_action = A;
Expand All @@ -325,12 +314,6 @@ public:
post_fast_step_action = A;
}

void set_post_update (std::function<void (T&, amrex::Real)> A)
{
set_post_stage_action(A);
set_post_step_action(A);
}

amrex::Real get_time_step ()
{
return time_step;
Expand Down
69 changes: 68 additions & 1 deletion Src/Base/AMReX_ParmParse.H
Original file line number Diff line number Diff line change
Expand Up @@ -1041,14 +1041,41 @@ public:
/**
* \brief Query with Parser. If `name` is found, this uses amrex::Parser
* to parse the entire list of empty space separated values as a single
* scalar. The return value indicates whether it's found.
* scalar. The return value indicates whether it's found. Note that
* queryWithParser will be used recursively for unresolved symbols.
*/
int queryWithParser (const char* name, int& ref) const;
int queryWithParser (const char* name, long& ref) const;
int queryWithParser (const char* name, long long& ref) const;
int queryWithParser (const char* name, float& ref) const;
int queryWithParser (const char* name, double& ref) const;

/**
* \brief Query with Parser. The return value indicates whether it's
* found. Note that queryWithParser will be used for unresolved
* symbols. If the number of elements in the input does not equal to
* `nvals`, it's a runtime error.
*/
int queryarrWithParser (const char* name, int nvals, int* ref) const;
int queryarrWithParser (const char* name, int nvals, long* ref) const;
int queryarrWithParser (const char* name, int nvals, long long* ref) const;
int queryarrWithParser (const char* name, int nvals, float* ref) const;
int queryarrWithParser (const char* name, int nvals, double* ref) const;
template <typename T, std::enable_if_t<std::is_same_v<T,int> ||
std::is_same_v<T,long> ||
std::is_same_v<T,long long> ||
std::is_same_v<T,float> ||
std::is_same_v<T,double>,int> = 0>
int queryarrWithParser (const char* name, int nvals, std::vector<T>& ref) const
{
if (this->contains(name)) {
if (int(ref.size()) < nvals) { ref.resize(nvals); }
return this->queryarrWithParser(name, nvals, ref.data());
} else {
return 0;
}
}

/**
* \brief Query with Parser. If `name` is found, this uses amrex::Parser
* to parse the entire list of empty space separated values as a single
Expand Down Expand Up @@ -1087,6 +1114,42 @@ public:
}
}

/**
* \brief Get with Parser. If `name` is not found, it's a runtime
* error. If the number of elements does not equal to `nvals`, it's also
* a runtime error.
*/
template <typename T, std::enable_if_t<std::is_same_v<T,int> ||
std::is_same_v<T,long> ||
std::is_same_v<T,long long> ||
std::is_same_v<T,float> ||
std::is_same_v<T,double>,int> = 0>
void getarrWithParser (const char* name, int nvals, T* ref) const
{
int exist = this->queryarrWithParser(name, nvals, ref);
if (!exist) {
amrex::Error(std::string("ParmParse::getarrWithParser: failed to get ")+name);
}
}

/**
* \brief Get with Parser. If `name` is not found, it's a runtime
* error. If the number of elements does not equal to `nvals`, it's also
* a runtime error.
*/
template <typename T, std::enable_if_t<std::is_same_v<T,int> ||
std::is_same_v<T,long> ||
std::is_same_v<T,long long> ||
std::is_same_v<T,float> ||
std::is_same_v<T,double>,int> = 0>
void getarrWithParser (const char* name, int nvals, std::vector<T>& ref) const
{
int exist = this->queryarrWithParser(name, nvals, ref);
if (!exist) {
amrex::Error(std::string("ParmParse::getarrWithParser: failed to get ")+name);
}
}

/*
* \brief Query two names.
*
Expand Down Expand Up @@ -1289,6 +1352,10 @@ public:
//! Write the contents of the table in ASCII to the ostream.
static void dumpTable (std::ostream& os, bool prettyPrint = false);

//! Write the table in a pretty way to the ostream. If there are
//! duplicates, only the last one is printed.
static void prettyPrintTable (std::ostream& os);

//! Add keys and values from a file to the end of the PP table.
static void addfile (std::string const& filename);

Expand Down
Loading

0 comments on commit fabdd5d

Please sign in to comment.