Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to plot multple Fields in the AmrCore turtorial. #3877

Closed
ztdepztdep opened this issue Apr 7, 2024 · 1 comment
Closed

How to plot multple Fields in the AmrCore turtorial. #3877

ztdepztdep opened this issue Apr 7, 2024 · 1 comment

Comments

@ztdepztdep
Copy link

In the amrcore exaples, I want to add the phi_old to the output file.
In the "PlotFileMF()" function, i add the following line, but it seems doesn't work. the "phi_old" variable take nan values in visit.

amrex::Vector<const amrex::MultiFab*> ScalarTransport_MultiLevel::PlotFileMF () const
{
	amrex::Vector<const amrex::MultiFab*> r;
	for (int i = 0; i <= finest_level; ++i) {
		r.push_back(&phi_new[i]);
	}
	
	for (int i = 0; i <= finest_level; ++i) {
		r.push_back(&phi_old[i]);
	}
	return r;
}
@WeiqunZhang
Copy link
Member

First, you need to make sure phi_old does not contain NaNs. In the AmrCore example, we do not initialize phi_old because it is not needed. But if you want to save phi_old in plotfiles, you need to initialize phi_old every time you remake an old level or creating a new level from scratch.

The modification to PlotFileMF will not work even if phi_old has no NaNs. The returned vector must have the size of finest_level+1, not 2*(finiest_level+1), because it is expected to have one MulitFab per level. There are two approaches you can take. You can put phi_new and phi_old in the same MultiFab. Or you can create a temporary 2 components MultiFab for plotfiles. For example,

Vector<MultiFab> plotmf(nlevels);
.

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

No branches or pull requests

2 participants