MCPcopy Create free account
hub / github.com/AMReX-Astro/Castro / construct_new_ext_source

Method construct_new_ext_source

Source/problems/Castro_problem_source.cpp:44–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42
43
44void
45Castro::construct_new_ext_source(MultiFab& source, const MultiFab& state_old, const MultiFab& state_new, Real time, Real dt)
46{
47 const Real strt_time = ParallelDescriptor::second();
48
49 if (!add_ext_src) {
50 return;
51 }
52
53 // In this routine, we have two options: we can either do an
54 // explicit predictor-corrector solve, or an implicit solve.
55 // If we are doing predictor-corrector, the goal is to have
56 // 0.5 * source_old + 0.5 * source_new. If we are doing an
57 // implicit solve, the goal is just to have 1.0 * source_new.
58 // This choice informs how we select mult_factor below.
59 // It is up to the implementer of the external source term
60 // to get it right if they choose to do an implicit solve.
61
62 Real mult_factor;
63
64 MultiFab ext_src(grids, dmap, source.nComp(), 0);
65
66 ext_src.setVal(0.0);
67
68 // Subtract off the old-time value first.
69
70 Real old_time = time - dt;
71
72 if (ext_src_implicit) {
73 mult_factor = -1.0;
74 } else {
75 mult_factor = -0.5;
76 }
77
78 fill_ext_source(old_time, dt, state_old, state_old, ext_src);
79
80 MultiFab::Saxpy(source, mult_factor, ext_src, 0, 0, source.nComp(), 0); // NOLINT(readability-suspicious-call-argument)
81
82 // Time center with the new data.
83
84 ext_src.setVal(0.0);
85
86 if (ext_src_implicit) {
87 mult_factor = 1.0;
88 } else {
89 mult_factor = 0.5;
90 }
91
92 fill_ext_source(time, dt, state_old, state_new, ext_src);
93
94 MultiFab::Saxpy(source, mult_factor, ext_src, 0, 0, source.nComp(), 0); // NOLINT(readability-suspicious-call-argument)
95
96 if (verbose > 1)
97 {
98 const int IOProc = ParallelDescriptor::IOProcessorNumber();
99 amrex::Real run_time = ParallelDescriptor::second() - strt_time;
100
101#ifdef BL_LAZY

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected