Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions example/PDE-OPT/0ld/stefan-boltzmann/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

IF(${PROJECT_NAME}_ENABLE_Intrepid AND
IF(${PROJECT_NAME}_ENABLE_Intrepid AND
${PROJECT_NAME}_ENABLE_Epetra AND
${PROJECT_NAME}_ENABLE_Amesos AND
${PROJECT_NAME}_ENABLE_Amesos2 AND
Expand All @@ -17,7 +17,6 @@ IF(${PROJECT_NAME}_ENABLE_Intrepid AND
# ARGS PrintItAll
# NUM_MPI_PROCS 4
# NUM_TOTAL_CORES_USED 4
# CATEGORIES CONTINUOUS
# PASS_REGULAR_EXPRESSION "TEST PASSED"
# ADD_DIR_TO_NAME
# )
Expand All @@ -28,7 +27,6 @@ IF(${PROJECT_NAME}_ENABLE_Intrepid AND
# ARGS PrintItAll
# NUM_MPI_PROCS 4
# NUM_TOTAL_CORES_USED 4
# CATEGORIES CONTINUOUS
# PASS_REGULAR_EXPRESSION "TEST PASSED"
# ADD_DIR_TO_NAME
# )
Expand Down
98 changes: 93 additions & 5 deletions example/PDE-OPT/TEST/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

IF(${PROJECT_NAME}_ENABLE_Intrepid AND
${PROJECT_NAME}_ENABLE_Epetra )
IF(${PROJECT_NAME}_ENABLE_Intrepid)

ROL_ADD_EXECUTABLE_AND_TEST(
test_01
Expand Down Expand Up @@ -92,6 +91,98 @@ IF(${PROJECT_NAME}_ENABLE_Intrepid AND

ENDIF()

IF(${PROJECT_NAME}_ENABLE_Intrepid2)

ROL_ADD_EXECUTABLE_AND_TEST(
test_01_Kokkos
SOURCES test_01K.cpp
ARGS PrintItAll
NUM_MPI_PROCS 1
NUM_TOTAL_CORES_USED 1
PASS_REGULAR_EXPRESSION "TEST PASSED"
ADD_DIR_TO_NAME
)

ROL_ADD_EXECUTABLE_AND_TEST(
test_02_Kokkos
SOURCES test_02K.cpp
ARGS PrintItAll
NUM_MPI_PROCS 1
NUM_TOTAL_CORES_USED 1
PASS_REGULAR_EXPRESSION "TEST PASSED"
ADD_DIR_TO_NAME
)

ROL_ADD_EXECUTABLE_AND_TEST(
test_03_Kokkos
SOURCES test_03K.cpp
ARGS PrintItAll
NUM_MPI_PROCS 1
NUM_TOTAL_CORES_USED 1
PASS_REGULAR_EXPRESSION "TEST PASSED"
ADD_DIR_TO_NAME
)

ROL_ADD_EXECUTABLE_AND_TEST(
test_04_Kokkos
SOURCES test_04K.cpp
ARGS PrintItAll
NUM_MPI_PROCS 1
NUM_TOTAL_CORES_USED 1
PASS_REGULAR_EXPRESSION "TEST PASSED"
ADD_DIR_TO_NAME
)

ROL_ADD_EXECUTABLE_AND_TEST(
test_05_Kokkos
SOURCES test_05K.cpp
ARGS PrintItAll
NUM_MPI_PROCS 1
NUM_TOTAL_CORES_USED 1
PASS_REGULAR_EXPRESSION "TEST PASSED"
ADD_DIR_TO_NAME
)

ROL_ADD_EXECUTABLE_AND_TEST(
test_07_Kokkos
SOURCES test_07K.cpp
ARGS PrintItAll
NUM_MPI_PROCS 1
NUM_TOTAL_CORES_USED 1
PASS_REGULAR_EXPRESSION "TEST PASSED"
ADD_DIR_TO_NAME
)

ROL_ADD_EXECUTABLE_AND_TEST(
test_08_Kokkos
SOURCES test_08K.cpp
ARGS PrintItAll
NUM_MPI_PROCS 1
NUM_TOTAL_CORES_USED 1
PASS_REGULAR_EXPRESSION "TEST PASSED"
ADD_DIR_TO_NAME
)

ROL_ADD_EXECUTABLE_AND_TEST(
test_09_Kokkos
SOURCES test_09K.cpp
ARGS PrintItAll
NUM_MPI_PROCS 1
NUM_TOTAL_CORES_USED 1
PASS_REGULAR_EXPRESSION "TEST PASSED"
ADD_DIR_TO_NAME
)

ROL_COPY_FILES_TO_BINARY_DIR(
TestDataCopyK
SOURCE_FILES
input_01.xml input_02.xml input_03.xml input_04.xml input_05.xml input_07.xml input_08.xml input_09.xml cube.txt L-cubes.txt
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
DEST_DIR "${CMAKE_CURRENT_BINARY_DIR}"
)

ENDIF()


#IF(${PROJECT_NAME}_ENABLE_Sacado)
# ROL_ADD_EXECUTABLE_AND_TEST(
Expand All @@ -104,6 +195,3 @@ ENDIF()
# ADD_DIR_TO_NAME
# )
#ENDIF()



166 changes: 166 additions & 0 deletions example/PDE-OPT/TEST/test_01K.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
// @HEADER
// *****************************************************************************
// Rapid Optimization Library (ROL) Package
//
// Copyright 2014 NTESS and the ROL contributors.
// SPDX-License-Identifier: BSD-3-Clause
// *****************************************************************************
// @HEADER

/*! \file test_01.cpp
\brief Unit test for the mesh manager and the degree-of-freedom manager.
Mesh type: RECTANGLE with QUAD CELLS and HGRAD SPACE.
*/

#include "ROL_Algorithm.hpp"
#include "ROL_BoundConstraint_SimOpt.hpp"
#include "ROL_Vector_SimOpt.hpp"

#include "ROL_Stream.hpp"
#include "ROL_GlobalMPISession.hpp"
#include "Teuchos_XMLParameterListHelpers.hpp"

#include "Intrepid2_HGRAD_QUAD_C1_FEM.hpp"
#include "Intrepid2_HGRAD_QUAD_C2_FEM.hpp"

#include <Kokkos_Core.hpp>

#include <iostream>
#include <algorithm>

#include "../TOOLS/meshmanagerK.hpp"
#include "../TOOLS/dofmanagerK.hpp"

using RealT = double;
using DeviceT = Kokkos::HostSpace;

using scalar_view = typename MeshManager<RealT, DeviceT>::scalar_view;
using int_view = typename MeshManager<RealT, DeviceT>::int_view;
using basis_ptr = Intrepid2::BasisPtr<DeviceT, RealT, RealT>;

int main(int argc, char *argv[]) {

ROL::GlobalMPISession mpiSession(&argc, &argv);
Kokkos::ScopeGuard kokkosScope(argc, argv);
// This little trick lets us print to std::cout only if a (dummy) command-line argument is provided.
int iprint = argc - 1;
ROL::Ptr<std::ostream> outStream;
ROL::nullstream bhs; // outputs nothing
if (iprint > 0)
outStream = ROL::makePtrFromRef(std::cout);
else
outStream = ROL::makePtrFromRef(bhs);

int errorFlag = 0;

// *** Example body.
try {

/*** Read in XML input ***/
std::string filename = "input_01.xml";
Teuchos::RCP<Teuchos::ParameterList> parlist
= Teuchos::rcp( new Teuchos::ParameterList() );
Teuchos::updateParametersFromXmlFile( filename, parlist.ptr() );

/*** Initialize mesh / degree-of-freedom manager. ***/
MeshManager_Rectangle<RealT, DeviceT> meshmgr(*parlist);
scalar_view nodes = meshmgr.getNodes();
int_view cellToNodeMap = meshmgr.getCellToNodeMap();
int_view cellToEdgeMap = meshmgr.getCellToEdgeMap();
ROL::Ptr<std::vector<std::vector<std::vector<int> > > > sideSetsPtr = meshmgr.getSideSets();

std::vector<std::vector<std::vector<int> > > &sideSets = *sideSetsPtr;
*outStream << "Number of nodes = " << meshmgr.getNumNodes() << std::endl; // << nodes;
*outStream << "Number of cells = " << meshmgr.getNumCells() << std::endl; // << cellToNodeMap;
*outStream << "Number of edges = " << meshmgr.getNumEdges() << std::endl; // << cellToEdgeMap;
// Print mesh info to file.
std::ofstream meshfile;
meshfile.open("cells.txt");
for (int i=0; i<cellToNodeMap.extent_int(0); ++i) {
meshfile << cellToNodeMap(i,0) << " "
<< cellToNodeMap(i,1) << " "
<< cellToNodeMap(i,2) << " "
<< cellToNodeMap(i,3) << std::endl;
}
meshfile.close();
meshfile.open("edges.txt");
for (int i=0; i<cellToEdgeMap.extent_int(0); ++i) {
meshfile << cellToEdgeMap(i,0) << " "
<< cellToEdgeMap(i,1) << " "
<< cellToEdgeMap(i,2) << " "
<< cellToEdgeMap(i,3) << std::endl;
}
meshfile.close();
meshfile.open("nodes.txt");
for (int i=0; i<nodes.extent_int(0); ++i) {
meshfile << nodes(i,0) << " "
<< nodes(i,1) << std::endl;
}
meshfile.close();
meshfile.open("sideset.txt");
for (int i=0; i<static_cast<int>(sideSets.size()); ++i) {
for (int j=0; j<static_cast<int>(sideSets[i].size()); ++j) {
if (sideSets[i][j].size() > 0) {
for (int k=0; k<static_cast<int>(sideSets[i][j].size()); ++k) {
meshfile << sideSets[i][j][k] << std::endl;
}
}
meshfile << std::endl << std::endl;
}
}
meshfile.close();

basis_ptr basisPtrQ1 = ROL::makePtr<Intrepid2::Basis_HGRAD_QUAD_C1_FEM<DeviceT, RealT, RealT>>();
basis_ptr basisPtrQ2 = ROL::makePtr<Intrepid2::Basis_HGRAD_QUAD_C2_FEM<DeviceT, RealT, RealT>>();

std::vector<basis_ptr> basisPtrs(3, ROL::nullPtr);
basisPtrs[0] = basisPtrQ2;
basisPtrs[1] = basisPtrQ1;
basisPtrs[2] = basisPtrQ2;

ROL::Ptr<MeshManager<RealT, DeviceT> > meshmgrPtr = ROL::makePtrFromRef(meshmgr);

DofManager<RealT, DeviceT> dofmgr(meshmgrPtr, basisPtrs);

*outStream << "Number of node dofs = " << dofmgr.getNumNodeDofs() << std::endl; // << dofmgr.getNodeDofs();
*outStream << "Number of edge dofs = " << dofmgr.getNumEdgeDofs() << std::endl; // << dofmgr.getEdgeDofs();
*outStream << "Number of face dofs = " << dofmgr.getNumFaceDofs() << std::endl; // << dofmgr.getFaceDofs();
*outStream << "Number of void dofs = " << dofmgr.getNumVoidDofs() << std::endl; // << dofmgr.getVoidDofs();
*outStream << "Total number of dofs = " << dofmgr.getNumDofs() << std::endl; // << dofmgr.getCellDofs();

std::vector<std::vector<int>> fieldPattern = dofmgr.getFieldPattern();
for (int i=0; i<dofmgr.getNumFields(); ++i) {
*outStream << "\nField " << i << " pattern: ";
for (int j=0; j<dofmgr.getLocalFieldSize(i); ++j) {
*outStream << fieldPattern[i][j] << " ";
}
*outStream << std::endl;
}

for (int i=0; i<dofmgr.getNumFields(); ++i) {
*outStream << "\nField " << i << std::endl;
// *outStream << dofmgr.getFieldDofs(i);
}

bool correct = true;
static const int checkDofs[] = {20, 23, 35, 32, 55, 63, 69, 61, 81};
for (int i=0; i<dofmgr.getLocalFieldSize(2); ++i) {
correct = correct && ( (dofmgr.getFieldDofs(2))(5,i) == checkDofs[i] );
}
if (!correct) {
errorFlag = -1;
}

}
catch (std::logic_error& err) {
*outStream << err.what() << "\n";
errorFlag = -1000;
}; // end try

if (errorFlag != 0)
std::cout << "End Result: TEST FAILED\n";
else
std::cout << "End Result: TEST PASSED\n";

return 0;
}
Loading