Skip to content

Add DAGP_fv for FCI - #3478

Open
dschwoerer wants to merge 3 commits into
nextfrom
dagp-fv
Open

Add DAGP_fv for FCI#3478
dschwoerer wants to merge 3 commits into
nextfrom
dagp-fv

Conversation

@dschwoerer

Copy link
Copy Markdown
Contributor

Add the DAGP_fv operator needed for boutproject/hermes-3#643

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread include/bout/fv_ops.hxx
Comment thread include/bout/fv_ops.hxx
Comment thread src/mesh/fv_ops.cxx
Comment thread src/mesh/fv_ops.cxx
Comment thread src/mesh/fv_ops.cxx
Comment thread src/mesh/fv_ops.cxx Outdated
Comment thread src/mesh/fv_ops.cxx Outdated
Comment thread src/mesh/fv_ops.cxx Outdated
Comment thread src/mesh/fv_ops.cxx Outdated
Comment thread src/mesh/fv_ops.cxx Outdated

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread src/mesh/fv_ops.cxx Outdated

@ZedThree ZedThree left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, a few comments though. Also:

  • please expand the docs
  • needs tests -- should be pretty easy to add to fv_mms?
  • please can we change the name? :)

Comment thread include/bout/fv_ops.hxx

/// Div ( a g Grad_perp(f) )
///
/// This version uses pre-computed coefficient. It can also be used

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's some text missing?

It could definitely do with some more docs, I guess that g is precomputed here given that the call operator only takes a and f?

Certainly we need something about how to create one

Comment thread include/bout/fv_ops.hxx
/// Div ( a g Grad_perp(f) )
///
/// This version uses pre-computed coefficient. It can also be used
class dagp_fv {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in the FV namespace, right? So we can drop the _fv (unless it doesn't stand for finite volume here?)

I'm also not a big fan of the name -- all our other operators are spelt out (well, most of them. I guess Delp2 is not great!) which helps the readability of the physics models.

So can we go for:

Suggested change
class dagp_fv {
class Div_a_g_Grad_perp {

Comment thread include/bout/fv_ops.hxx

private:
template <bool extra, bool upwinding>
Field3D operator()(const Field3D& a, const Field3D& f, Field3D* low_xlow,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const?

Comment thread include/bout/fv_ops.hxx
Comment on lines +215 to +217
BoutReal xflux(const Field3D& a, const Field3D& f, const Ind3D& i);
template <bool upwinding>
BoutReal zflux(const Field3D& a, const Field3D& f, const Ind3D& i);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const?

Comment thread src/mesh/fv_ops.cxx
Comment on lines +762 to +763
result /= volume;
return result;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
result /= volume;
return result;
return result / volume;

Comment thread include/bout/fv_ops.hxx
Comment on lines +195 to +197
Field3D operator()(const Field3D& a, const Field3D& f, Field3D& low_xlow,
Field3D& flow_zlow, bool upwinding);
Field3D operator()(const Field3D& a, const Field3D& f, bool upwinding);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these be const?

low_xlow and flow_zlow need some docs -- not sure that flow is a great name either, I think it's f_low rather than flow?

Comment thread src/mesh/fv_ops.cxx
volume /= fac * fac;
return *this;
}
dagp_fv& dagp_fv::operator/=(BoutReal fac) { return operator*=(1 / fac); }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this used anywhere? Or is it anticipated to be used in user code?

Comment thread src/mesh/fv_ops.cxx
std::map<Mesh*, std::weak_ptr<dagp_fv>> dagp_fv_cache;
}

std::shared_ptr<dagp_fv> getDagp_fv(Mesh* mesh, BoutReal rho_s0) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this were instead a static method on the class (and named something like create?), could we inline operator*= here and drop it? Or is it also needed elsewhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants