@@ -25,7 +25,9 @@ CmvAdvection::CmvAdvection(string constit_name,
2525 _constit_ind=pTransModel->GetConstituentIndex (constit_name);
2626
2727 int nAdvConnections =pTransModel->GetNumAdvConnections ();
28+ int nWaterStores =pTransModel->GetNumWaterCompartments ();
2829 CHydroProcessABC::DynamicSpecifyConnections (3 *nAdvConnections+1 );// +2 once GW added
30+ // CHydroProcessABC::DynamicSpecifyConnections(nAdvConnections+nWaterStores+1);//+2 once GW added
2931
3032 for (int q=0 ;q<nAdvConnections;q++) // for regular advection
3133 {
@@ -42,18 +44,29 @@ CmvAdvection::CmvAdvection(string constit_name,
4244 iFrom[2 *nAdvConnections+q]=pModel->GetStateVarIndex (CONSTITUENT_SRC,_constit_ind);
4345 iTo [2 *nAdvConnections+q]=iTo[q];
4446 }
47+ // for Dirichlet source corrections
48+ // for (int ii = 0; ii < nWaterStores; ii++) {
49+ // iFrom[nAdvConnections+ii]=pModel->GetStateVarIndex(CONSTITUENT_SRC,_constit_ind);
50+ // iTo [nAdvConnections+ii]=pTransModel->GetStorWaterIndex(ii);
51+ // }
52+
4553 // advection into surface water
4654 int iSW=pModel->GetStateVarIndex (SURFACE_WATER);
4755 int m=pTransModel->GetLayerIndex (_constit_ind,iSW);
4856 iFrom[3 *nAdvConnections]=pModel->GetStateVarIndex (CONSTITUENT,m);
4957 iTo [3 *nAdvConnections]=pModel->GetStateVarIndex (CONSTITUENT_SW,0 );
5058
59+ // iFrom[nAdvConnections+nWaterStores]=pModel->GetStateVarIndex(CONSTITUENT,m);
60+ // iTo [nAdvConnections+nWaterStores]=pModel->GetStateVarIndex(CONSTITUENT_SW,0);
61+
5162 // advection into groundwater
5263 // int iGW=pModel->GetStateVarIndex(GROUNDWATER);
5364 // int m=pTransModel->GetLayerIndex(constit_ind,iGW);
5465 // iFrom[3*nAdvConnections+1]=pModel->GetStateVarIndex(CONSTITUENT,m);
5566 // iTo [3*nAdvConnections+1]=pModel->GetStateVarIndex(CONSTITUENT_GW,0);
5667
68+ // iFrom[nAdvConnections+nWaterStores+1]=pModel->GetStateVarIndex(CONSTITUENT,m);
69+ // iTo [nAdvConnections+nWaterStores+1]=pModel->GetStateVarIndex(CONSTITUENT_SW,0);
5770}
5871
5972// ////////////////////////////////////////////////////////////////
@@ -223,6 +236,8 @@ void CmvAdvection::GetRatesOfChange(const double *state_vars,
223236 mass =sv[iFrom[q]];
224237 dirichlet_mass=Cs*sv[iFromWater]; // Cs*V
225238 rates[nAdvConnections+q]+=(dirichlet_mass-mass)/Options.timestep ; // From CONSTITUENT_SRC
239+ // iiFromWater=pTransModel->GetWaterStorIndexFromSVIndex(iFromWater);
240+ // rates[nAdvConnections+iiFromWater]+=(dirichlet_mass-mass)/Options.timestep; //From CONSTITUENT_SRC //JRC: Reduced memory edit (or _aStorIndex[iFromWater])
226241 sv[iFrom[q]]=dirichlet_mass; // override previous mass/enthalpy
227242 }
228243
@@ -237,6 +252,8 @@ void CmvAdvection::GetRatesOfChange(const double *state_vars,
237252 mass =sv[iTo[q]];
238253 dirichlet_mass=Cs*sv[iToWater]; // C*V
239254 rates[2 *nAdvConnections+q]+=(dirichlet_mass-mass)/Options.timestep ; // From CONSTITUENT_SRC
255+ // iiToWater=pTransModel->GetWaterStorIndexFromSVIndex(iToWater);
256+ // rates[nAdvConnections+iiToWater]+=(dirichlet_mass-mass)/Options.timestep; //From CONSTITUENT_SRC //JRC: Reduced memory edit (or _aStorIndex[iFromWater] of size _nWaterStores)
240257 sv[iTo[q]]=dirichlet_mass; // override previous mass/enthalpy
241258 }
242259
0 commit comments