Skip to content
Snippets Groups Projects
Commit 1009591f authored by François Grand's avatar François Grand
Browse files

refactor: predams: do not remove results if the only error is a dichotomy convergence error

refs #302
parent 628bd85f
No related branches found
No related tags found
No related merge requests found
......@@ -1660,6 +1660,29 @@ export abstract class Nub extends ComputeNode implements IProperties {
return true;
}
/**
* @returns true if all messages in nub hierarchy have the same code
*/
public hasOnlyMessage(code: MessageCode): boolean {
for (const n of this.allChildNubIterator) {
if (!n.result.hasOnlyMessage(code)) {
return false;
}
}
return true;
}
public get uniqueMessageCodes(): MessageCode[] {
let res: MessageCode[] = [];
for (const n of this.allChildNubIterator) {
if (n.uid === "MDZ3aH") {
debugger
}
res = res.concat(n.result.uniqueMessageCodes);
}
return res;
}
// interface IObservable
/**
......
......@@ -381,7 +381,9 @@ export class PreBarrage extends Nub {
}
// if an error occurred in any nub, remove all results
if (!this.allResultsOk) {
// except if it's a dichotomy convergence error (and only this error)
if (!this.allResultsOk && !this.hasOnlyMessage(MessageCode.ERROR_DICHO_CONVERGE)) {
for (const c of this.allChildNubIterator) {
c.result.resultElement.removeValues();
}
......
......@@ -103,6 +103,28 @@ export class cLog {
return undefined;
}
/**
* @returns true if all messages have the same code
*/
public hasOnlyMessage(code: MessageCode): boolean {
for (const m of this.messages) {
if (m.code !== code) {
return false;
}
}
return true;
}
public get uniqueMessageCodes(): MessageCode[] {
const res: MessageCode[] = [];
for (const m of this.messages) {
if (res.indexOf(m.code) === -1) {
res.push(m.code);
}
}
return res;
}
/**
* compute error, warning, info count in a message list
*/
......
......@@ -299,6 +299,29 @@ export class Result extends JalhydObject {
return false;
}
/**
* determine if all messages have the same code
* @param code message code to find
*/
public hasOnlyMessage(code: MessageCode): boolean {
if (!this._globalLog.hasOnlyMessage(code)) {
return false;
}
if (!this.resultElement.log.hasOnlyMessage(code)) {
return false;
}
return true;
}
public get uniqueMessageCodes(): MessageCode[] {
let res: MessageCode[] = [];
res = res.concat(this._globalLog.uniqueMessageCodes);
res = res.concat(this.resultElement.log.uniqueMessageCodes);
return res;
}
/**
* compute log stats (# of error, warning, info) on all result element
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment