Dear Niels,
here's some outline of the code as a first idea (without any checking and warranty) in C++ syntax (so you should choose C++). This code calculates the total abstraction of mass from the system at well bcs, the total injection at flux bcs (assuming there's only injecting 2nd kind bcs), and sets fixed concentrations to all the nodes of the flux bcs.
PostTimeStep:
int nn=IfmGetNumberOfNodes(pDoc);
double mass = 0.; // total mass taken from the system at well bcs
double flow = 0.; // total flow at 2nd kind bcs
IfmBudget *mb = IfmBudgetMassCreate (pDoc);
IfmBudget *fb = IfmBudgetCreate(pDoc);
for (int i=0;i<nn;i++){
if (IfmGetBcFlowType(pDoc, i)==IfmBC_SINGLE_WELL){
mass = mass + IfmBudgetQueryMassAtNode (pDoc, mb, i);
}
else if (IfmGetBcFlowType(pDoc, i)==IfmBC_NEUMANN){
flow = flow + IfmBudgetQueryFlowAtNode (pDoc, fb, i);
}
}
IfmBudgetClose (pDoc, mb);
IfmBudgetClose (pDoc, fb);
for (int i=0;i<nn;i++){
if (IfmGetBcFlowType(pDoc, i)==IfmBC_NEUMANN){
double c = mass / flow;
IfmSetBcMassTypeAndValueAtCurrentTime(pDoc, i,IfmBC_DIRICHLET, 0, c);
}
}
Cheers,
Peter