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

Teuchos: How to Convert ParameterList to XML without "junk data" #13194

Open
MalachiTimothyPhillips opened this issue Jul 2, 2024 · 0 comments
Assignees
Labels
pkg: Teuchos Issues primarily dealing with the Teuchos Package type: question

Comments

@MalachiTimothyPhillips
Copy link

MalachiTimothyPhillips commented Jul 2, 2024

I have a Teuchos::ParameterList that I programatically generate which corresponds to:

<ParameterList name="velocity_solve">
  <Parameter name="Type" type="string" value="Belos"/>
  <Parameter name="Solver Type" type="string" value="Pseudo Block GMRES"/>
  <ParameterList name="Solver Types">
    <ParameterList name="Pseudo Block GMRES">
      <Parameter name="Maximum Iterations" type="int" value="30"/>
      <Parameter name="Convergence Tolerance" type="double" value="1.00000000000000005e-04"/>
      <Parameter name="Implicit Residual Scaling" type="string" value="Norm of Initial Residual"/>
      <Parameter name="Explicit Residual Scaling" type="string" value="Norm of Initial Residual"/>
      <Parameter name="Num Blocks" type="int" value="30"/>
      <Parameter name="Maximum Restarts" type="int" value="1"/>
      <Parameter name="Orthogonalization" type="string" value="ICGS"/>
    </ParameterList>
  </ParameterList>
</ParameterList>

For my use-case, I would like to output the above Teuchos::ParameterList to an XML file.
For this, I construct a Teuchos::XMLParameterListWriter from the ParameterList

  // solver_parameters is a Teuchos::ParameterList corresponding to the above input
  Teuchos::XMLParameterListWriter myXMLWriter;
  auto myXMLObject = myXMLWriter.toXML(solver_parameters);
  myXMLObject.print(text, 0);

However, this outputs additional fields docString, id, isDefault, and isUsed, as below:

<ParameterList id="19" name="velocity_solve">
  <Parameter docString="" id="8" isDefault="false" isUsed="true" name="Type" type="string" value="Belos"/>
  <Parameter docString="" id="9" isDefault="false" isUsed="true" name="Solver Type" type="string" value="Pseudo Block GMRES"/>
  <ParameterList id="18" name="Solver Types">
    <ParameterList id="17" name="Pseudo Block GMRES">
      <Parameter docString="" id="10" isDefault="false" isUsed="true" name="Maximum Iterations" type="int" value="30"/>
      <Parameter docString="" id="11" isDefault="false" isUsed="true" name="Convergence Tolerance" type="double" value="1.00000000000000005e-04"/>
      <Parameter docString="" id="12" isDefault="false" isUsed="true" name="Implicit Residual Scaling" type="string" value="Norm of Initial Residual"/>
      <Parameter docString="" id="13" isDefault="false" isUsed="true" name="Explicit Residual Scaling" type="string" value="Norm of Initial Residual"/>
      <Parameter docString="" id="14" isDefault="false" isUsed="true" name="Num Blocks" type="int" value="30"/>
      <Parameter docString="" id="15" isDefault="false" isUsed="true" name="Maximum Restarts" type="int" value="1"/>
      <Parameter docString="" id="16" isDefault="false" isUsed="true" name="Orthogonalization" type="string" value="ICGS"/>
    </ParameterList>
  </ParameterList>
</ParameterList>

Is it possible to avoid outputting these additional fields?

ParameterEntryXMLConverter::fromParameterEntrytoXML(
would suggest no.

@MalachiTimothyPhillips MalachiTimothyPhillips self-assigned this Jul 2, 2024
@MalachiTimothyPhillips MalachiTimothyPhillips added the pkg: Teuchos Issues primarily dealing with the Teuchos Package label Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: Teuchos Issues primarily dealing with the Teuchos Package type: question
Projects
None yet
Development

No branches or pull requests

1 participant