Skip to content

Commit

Permalink
get truth solutions
Browse files Browse the repository at this point in the history
  • Loading branch information
srinathdama committed Sep 5, 2021
1 parent f337a09 commit 8c332ad
Show file tree
Hide file tree
Showing 13 changed files with 3,060 additions and 1,170 deletions.
Binary file added mesh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plot_mesh_valus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plot_mesh_valus_with_nodes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions rbnics/problems/base/parametrized_reduced_differential_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,26 @@ def _compute_error(self, **kwargs):
#
return error

def compute_reduced_truth_solutions(self, **kwargs):
"""
returns the reduced and truth solutions similar to 'compute_error' function
"""

self.truth_problem.solve(**kwargs)
(components, inner_product) = self._preprocess_compute_error_and_relative_error_kwargs(**kwargs)

N = self._solution.N
reduced_solution = self.basis_functions[:N] * self._solution
truth_solution = self.truth_problem._solution

return [reduced_solution, truth_solution]






def compute_relative_error(self, **kwargs):
"""
It returns the function _compute_relative_error() evaluated for the desired parameter.
Expand Down
39 changes: 39 additions & 0 deletions rbnics/reduction_methods/base/rb_reduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,45 @@ def N_generator_max():
error_analysis_table.save(
self.folder["error_analysis"], "error_analysis" if filename is None else filename)

def save_data(self, N_generator=None, filename=None, **kwargs):
"""
It computes the error of the reduced order approximation with respect to the full order one
over the testing set.
:param N_generator: generator of dimension of reduced problem.
"""
self._init_error_analysis(**kwargs)
reduced_solution_temp, truth_solution_temp = self._save_data(filename, **kwargs)
# self._finalize_error_analysis(**kwargs)
return [reduced_solution_temp, truth_solution_temp]

def _save_data(self, filename=None, **kwargs):

print(TextBox(self.truth_problem.name() + " " + self.label + " data gen begins", fill="="))
print("")


# for (mu_index, mu) in enumerate(self.testing_set):
for (mu_index, mu) in enumerate(self.training_set):
print(TextLine(str(mu_index), fill="#"))

self.reduced_problem.set_mu(mu)
self.reduced_problem.solve(**kwargs)

reduced_solution_temp, truth_solution_temp = self.reduced_problem.compute_reduced_truth_solutions(**kwargs)


# Print
print("")

print("")
print(TextBox(self.truth_problem.name() + " " + self.label + " data generation ends", fill="="))
print("")

return [reduced_solution_temp, truth_solution_temp]



def speedup_analysis(self, N_generator=None, filename=None, **kwargs):
"""
It computes the speedup of the reduced order approximation with respect to the full order one
Expand Down
17 changes: 10 additions & 7 deletions tutorials/01_thermal_block/data/generate_mesh.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -12,7 +12,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -27,7 +27,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -37,7 +37,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -76,7 +76,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -98,12 +98,15 @@
},
"language_info": {
"codemirror_mode": {
"name": "ipython"
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python"
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
}
},
"nbformat": 4,
Expand Down
2,257 changes: 1,340 additions & 917 deletions tutorials/01_thermal_block/data/thermal_block.xml

Large diffs are not rendered by default.

Loading

0 comments on commit 8c332ad

Please sign in to comment.