Skip to content

Commit 882008c

Browse files
authored
Vec caas (#103)
* Non-conservative monotone integrated and non-integrated remapping schemes. * Implementation of CAAS with vector of inputs.
1 parent ecad04c commit 882008c

File tree

8 files changed

+714
-19
lines changed

8 files changed

+714
-19
lines changed

src/ApplyOfflineMap.cpp

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include "TempestRemapAPI.h"
2020
#include "OfflineMap.h"
2121
#include "netcdfcpp.h"
22+
#include "GridElements.h"
23+
#include "FiniteElementTools.h"
2224

2325
#include <fstream>
2426

@@ -273,14 +275,79 @@ try {
273275
AnnounceStartBlock("Applying first offline map to data");
274276
}
275277
*/
278+
279+
DataArray3D<int> dataGLLNodesIn;
280+
DataArray3D<double> dataGLLJacobianIn;
281+
282+
DataArray3D<int> dataGLLNodesOut;
283+
DataArray3D<double> dataGLLJacobianOut;
284+
285+
DataArray3D<int> * pdataGLLNodesIn = NULL;
286+
287+
DataArray3D<int> * pdataGLLNodesOut = NULL;
288+
289+
Mesh meshOverlap;
290+
Mesh meshSource;
291+
Mesh meshTarget;
292+
293+
Mesh * pmeshSource = NULL;
294+
Mesh * pmeshOverlap = NULL;
295+
296+
297+
if(optsApply.strInputMesh != ""){
298+
299+
//If the source mesh is finite volume, we need the source mesh for local p bounds preservation
300+
301+
meshSource.Read(optsApply.strInputMesh);
302+
meshSource.ConstructReverseNodeArray();
303+
meshSource.ConstructEdgeMap();
304+
pmeshSource = &meshSource;
305+
306+
307+
//If the source mesh is finite element, we need dataGLLNodes for local bounds preservation
308+
if(optsApply.fgll){
309+
310+
double dTotalAreaInput = meshSource.CalculateFaceAreas(optsApply.fContainsConcaveFaces);
311+
double dNumericalAreaIn = GenerateMetaData(meshSource,optsApply.nPin,false,dataGLLNodesIn,dataGLLJacobianIn);
312+
313+
pdataGLLNodesIn = &dataGLLNodesIn;
314+
315+
}
316+
317+
}
318+
319+
if(optsApply.strOverlapMesh != ""){
320+
321+
meshOverlap.Read(optsApply.strOverlapMesh);
322+
meshOverlap.RemoveZeroEdges();
323+
pmeshOverlap = &meshOverlap;
324+
325+
}
326+
327+
//If the target mesh is finite element, get dataGLLNodesOut
328+
if(optsApply.strOutputMesh != ""){
329+
330+
meshTarget.Read(optsApply.strOutputMesh);
331+
meshTarget.ConstructReverseNodeArray();
332+
meshTarget.ConstructEdgeMap();
333+
334+
double dTotalAreaOutput = meshTarget.CalculateFaceAreas(optsApply.fContainsConcaveFaces);
335+
double dNumericalAreaOut = GenerateMetaData(meshTarget,optsApply.nPout,false,dataGLLNodesOut,dataGLLJacobianOut);
336+
337+
pdataGLLNodesOut = &dataGLLNodesOut;
338+
339+
}
340+
276341
// OfflineMap
277342
AnnounceStartBlock("Loading offline map");
278343

279344
OfflineMap mapRemap;
280345
mapRemap.Read(strInputMap);
281346
mapRemap.SetFillValueOverrideDbl(optsApply.dFillValueOverride);
282347
mapRemap.SetFillValueOverride(static_cast<float>(optsApply.dFillValueOverride));
283-
mapRemap.SetEnforcementBounds(optsApply.strEnforceBounds);
348+
mapRemap.SetEnforcementBounds(optsApply.strEnforceBounds,pmeshSource,pmeshOverlap,pdataGLLNodesIn,
349+
pdataGLLNodesOut,optsApply.nPin);
350+
//mapRemap.SetEnforcementBounds(optsApply.strEnforceBounds);
284351

285352
AnnounceEndBlock("Done");
286353

src/ApplyOfflineMapExe.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,18 @@ int main(int argc, char** argv) {
5656
//CommandLineString(strVariables2, "var2", "");
5757
CommandLineString(optsApply.strNColName, "ncol_name", "ncol");
5858
CommandLineString(optsApply.strEnforceBounds, "bounds", "");
59+
CommandLineString(optsApply.strInputMesh,"mesh_in","");
60+
CommandLineString(optsApply.strOutputMesh,"mesh_out","");
61+
CommandLineString(optsApply.strOverlapMesh,"mesh_ov","");
62+
CommandLineInt(optsApply.nPin, "in_np", 0);
63+
CommandLineInt(optsApply.nPout, "out_np", 0);
5964
CommandLineBool(optsApply.fOutputDouble, "out_double");
6065
CommandLineString(optsApply.strPreserveVariables, "preserve", "");
6166
CommandLineBool(optsApply.fPreserveAll, "preserveall");
6267
CommandLineDouble(optsApply.dFillValueOverride, "fillvalue", 0.0);
6368
CommandLineString(optsApply.strLogDir, "logdir", "");
69+
CommandLineBool(optsApply.fContainsConcaveFaces,"concave");
70+
CommandLineBool(optsApply.fgll,"gll");
6471

6572
ParseCommandLine(argc, argv);
6673
EndCommandLine(argv)

src/FiniteVolumeTools.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ void GetTriangleThatContainsPoint(
291291

292292
// If this is a new Face, check whether it contains the point
293293
if (setAllFaces.find(iNewFace) == setAllFaces.end()) {
294+
294295
if(DoesTriangleContainPoint(mesh,iNewFace,dX,dY)){
295296

296297
iFaceFinal = iNewFace;
@@ -377,6 +378,7 @@ void GetFaceThatContainsPoint(
377378

378379
// If this is a new Face, check whether it contains the point
379380
if (setAllFaces.find(iNewFace) == setAllFaces.end()) {
381+
380382
if(DoesFaceContainPoint(mesh,iNewFace,dX,dY,dZ)){
381383

382384
iFaceFinal = iNewFace;
@@ -768,6 +770,7 @@ void TriangleLineIntersection(
768770

769771
_ASSERT(dCoeffs.GetRows() == 3);
770772

773+
771774
//Setup up columns of 3x3 matrix
772775
DataArray2D<double> dInterpMat(3,3);
773776

src/LinearRemapFV.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,12 +1298,11 @@ void LinearRemapIntegratedGeneralizedBarycentric(
12981298
// Get SparseMatrix representation of the OfflineMap
12991299
SparseMatrix<double> & smatMap = mapRemap.GetSparseMatrix();
13001300

1301-
//Dual mesh
13021301
Mesh meshInputDual = meshInput;
13031302

13041303
//Construct dual mesh
13051304
Dual(meshInputDual);
1306-
1305+
13071306
//Reverse node array
13081307
meshInputDual.ConstructReverseNodeArray();
13091308

@@ -1595,7 +1594,7 @@ void LinearRemapGeneralizedBarycentric(
15951594

15961595
//Construct dual mesh
15971596
Dual(meshInputDual);
1598-
1597+
15991598
//Reverse node array
16001599
meshInputDual.ConstructReverseNodeArray();
16011600

src/LinearRemapFV.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ void LinearRemapIntegratedTriangulation(
8484
/// Generate the OfflineMap for non-integrated remapping from finite volumes to finite
8585
/// volumes using generalized barycentric coordinates using the dual mesh
8686
/// </summary>
87-
8887
void LinearRemapIntegratedGeneralizedBarycentric(
8988
const Mesh & meshInput,
9089
const Mesh & meshOutput,
@@ -98,7 +97,6 @@ void LinearRemapIntegratedGeneralizedBarycentric(
9897
/// Generate the OfflineMap for integrated remapping from finite volumes to finite
9998
/// volumes using generalized barycentric coordinates using the dual mesh
10099
/// </summary>
101-
102100
void LinearRemapGeneralizedBarycentric(
103101
const Mesh & meshInput,
104102
const Mesh & meshOutput,
@@ -112,7 +110,6 @@ void LinearRemapGeneralizedBarycentric(
112110
/// Generate the OfflineMap for non-integrated remapping from finite volumes to finite
113111
/// volumes using a triangulation of the source mesh.
114112
/// </summary>
115-
116113
void LinearRemapTriangulation(
117114
const Mesh & meshInput,
118115
const Mesh & meshOutput,

0 commit comments

Comments
 (0)