forked from idaholab/moose
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using function for transient interpolation instead idaholab#42
- Loading branch information
1 parent
13386bf
commit b57cc12
Showing
15 changed files
with
381 additions
and
296 deletions.
There are no files selected for viewing
21 changes: 0 additions & 21 deletions
21
modules/optimization/doc/content/source/auxkernels/ReporterNearestPointAux.md
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
modules/optimization/doc/content/source/functions/VectorNearestPointFunction.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# VectorNearestPointFunction | ||
|
||
!syntax description /Functions/VectorNearestPointFunction | ||
|
||
## Overview | ||
|
||
This function computes values based on coordinate and time data. This data comes in the form of vector reporter or vectorpostprocessor values. The required parameter [!param](/Functions/VectorNearestPointFunction/value) is the name of the vector containing the values used to set the variable to. [!param](/Functions/VectorNearestPointFunction/coord_x)/[!param](/Functions/VectorNearestPointFunction/coord_y)/[!param](/Functions/VectorNearestPointFunction/coord_z) are vectors with the x-/y-/z-coordinate data. The auxkernel will set the variable's nodal/elemental values based on the nearest point in this data. [!param](/Functions/VectorNearestPointFunction/time) is the name of the time data; the kernel will linearly interpolate between two closest times for a certain coordinate, without extrapolating. [!param](/Functions/VectorNearestPointFunction/coord_x), [!param](/Functions/VectorNearestPointFunction/coord_y), [!param](/Functions/VectorNearestPointFunction/coord_z), and [!param](/Functions/VectorNearestPointFunction/time) will assume to be 0 when not specified. When specified, [!param](/Functions/VectorNearestPointFunction/coord_x), [!param](/Functions/VectorNearestPointFunction/coord_y), [!param](/Functions/VectorNearestPointFunction/coord_z), and [!param](/Functions/VectorNearestPointFunction/time) must all be the same length as [!param](/Functions/VectorNearestPointFunction/value). | ||
|
||
## Example Input File Syntax | ||
|
||
Here are several examples different combinations of x, y, z, and time data is specified: | ||
|
||
!listing vector_nearest_point.i block=Functions Reporters | ||
|
||
Run this test to see how the function interpolates the data between specified times. | ||
|
||
!syntax parameters /Functions/VectorNearestPointFunction | ||
|
||
!syntax inputs /Functions/VectorNearestPointFunction | ||
|
||
!syntax children /Functions/VectorNearestPointFunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 0 additions & 46 deletions
46
modules/optimization/include/auxkernels/ReporterNearestPointAux.h
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
modules/optimization/include/functions/OptimizationFunction.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//* This file is part of the MOOSE framework | ||
//* https://www.mooseframework.org | ||
//* | ||
//* All rights reserved, see COPYRIGHT for full restrictions | ||
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT | ||
//* | ||
//* Licensed under LGPL 2.1, please see LICENSE for details | ||
//* https://www.gnu.org/licenses/lgpl-2.1.html | ||
|
||
#pragma once | ||
|
||
#include "Function.h" | ||
|
||
/** | ||
* Base class for functions used in inverse optimization | ||
* The parameterDerivative function is used in adjoint calculation to compute | ||
* gradients. | ||
*/ | ||
class OptimizationFunction : public Function | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
OptimizationFunction(const InputParameters & parameters); | ||
|
||
virtual std::vector<Real> parameterGradient(Real t, const Point & pt) const = 0; | ||
}; |
58 changes: 58 additions & 0 deletions
58
modules/optimization/include/functions/VectorNearestPointFunction.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
//* This file is part of the MOOSE framework | ||
//* https://www.mooseframework.org | ||
//* | ||
//* All rights reserved, see COPYRIGHT for full restrictions | ||
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT | ||
//* | ||
//* Licensed under LGPL 2.1, please see LICENSE for details | ||
//* https://www.gnu.org/licenses/lgpl-2.1.html | ||
|
||
#pragma once | ||
|
||
#include "OptimizationFunction.h" | ||
#include "ReporterInterface.h" | ||
|
||
class VectorNearestPointFunction : public OptimizationFunction, public ReporterInterface | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
VectorNearestPointFunction(const InputParameters & parameters); | ||
|
||
using Function::value; | ||
virtual Real value(Real t, const Point & p) const override; | ||
virtual RealGradient gradient(Real t, const Point & p) const override; | ||
virtual Real timeDerivative(Real t, const Point & p) const override; | ||
virtual std::vector<Real> parameterGradient(Real t, const Point & p) const override; | ||
|
||
protected: | ||
/** | ||
* Builds _coord_mapping object with coordinates from inputted vectors | ||
*/ | ||
void buildCoordinateMapping() const; | ||
|
||
/** | ||
* With an inputted time and point, gets the closest point and two closest times in | ||
* _coord_mapping. See ::value on how the return value is used. | ||
*/ | ||
std::array<std::pair<Real, std::size_t>, 2> findNearestPoint(Real t, const Point & p) const; | ||
|
||
/// x-coordinates from reporter | ||
const std::vector<Real> & _coordx; | ||
/// y-coordinates from reporter | ||
const std::vector<Real> & _coordy; | ||
/// z-coordinates from reporter | ||
const std::vector<Real> & _coordz; | ||
/// time-coordinates from reporter | ||
const std::vector<Real> & _coordt; | ||
/// values from reporter | ||
const std::vector<Real> & _values; | ||
|
||
/// Number of values from coordinate vectors | ||
mutable std::size_t _nval; | ||
/// Data structure for all current data | ||
mutable std::map<Point, std::vector<std::pair<Real, std::size_t>>> _coord_mapping; | ||
|
||
private: | ||
const std::vector<Real> _empty_vec = {}; | ||
}; |
154 changes: 0 additions & 154 deletions
154
modules/optimization/src/auxkernels/ReporterNearestPointAux.C
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.